Loading...
Searching...
No Matches
cardano.h File Reference
`#include <vector>`
`#include <cstdint>`

Go to the source code of this file.

## Classes

struct | InHousePolynomialSolverResult

## Enumerations

enum class | CardanoResultCase : std::int8_t { notvalid , zerod , negatived , positived , quadratic , line }

## Functions

InHousePolynomialSolverResult | inHousePolynomialSolve (const std::vector< double > &polynome)

## Enumeration Type Documentation

## CardanoResultCase

enum class CardanoResultCase : std::int8_t

strong

Enumerator
notvalid |
zerod |
negatived |
positived |
quadratic |
line |

Definition at line 35 of file cardano.h.

{
notvalid,
zerod,
negatived,
positived,
quadratic,
line
};
CardanoResultCase::positived
@ positived
Definition cardano.h:40
CardanoResultCase::line
@ line
Definition cardano.h:42
CardanoResultCase::notvalid
@ notvalid
Definition cardano.h:37
CardanoResultCase::zerod
@ zerod
Definition cardano.h:38
CardanoResultCase::quadratic
@ quadratic
Definition cardano.h:41
CardanoResultCase::negatived
@ negatived
Definition cardano.h:39

## Function Documentation

## inHousePolynomialSolve()

InHousePolynomialSolverResult inHousePolynomialSolve | ( | const std::vector< double > & | polynome | ) |

Definition at line 115 of file cardano.cpp.

{
InHousePolynomialSolverResult res;
res.type = CardanoResultCase::notvalid;
std::size_t polynome_size = polynome.size();
double a, b, c, delta;
switch(polynome_size)
{
case 0:
break;
case 1:
break;
case 2: // linear// equation ax + b = 0
a = polynome[1];
b = polynome[0];
if(a != 0)
{
res.x1 = -b / a;
res.type = CardanoResultCase::line;
}
break;
case 3:
// quadratic equation ax**2 + bx + c = 0
a = polynome[2];
if(a == 0)
return res;
b = polynome[1];
c = polynome[0];
if(a == 0)
return res;
// calculate the discriminant
delta = (b * b) - (a * c * 4);
// qDebug() << delta;
if(delta < 0)
{
}
else if(std::abs(delta) <= 1e-20)
{
res.x1 = -b / (a * 2);
// qDebug() << x1.real() << " " << x2.real();
res.type = CardanoResultCase::quadratic;
}
else
{
// find two solutions
delta = std::sqrt(delta);
res.x1 = (-b + delta) / (a * 2);
res.x2 = (-b - delta) / (a * 2);
// qDebug() << x1.real() << " " << x2.real();
res.type = CardanoResultCase::quadratic;
}
break;
case 4:
cubic_solver(res, polynome[3], polynome[2], polynome[1], polynome[0]);
}
return res;
}
cubic_solver
void cubic_solver(InHousePolynomialSolverResult &res, double a1, double b, double c, double d)
Definition cardano.cpp:42
pappso::Enums::PrecisionUnit::res
@ res
Definition types.h:100
pappso::masschroq::PeakQualityCategory::a
@ a
peak detected using a single direct MS2 observation
Definition types.h:46
pappso::masschroq::PeakQualityCategory::c
@ c
Definition types.h:54
pappso::masschroq::PeakQualityCategory::b
@ b
Definition types.h:52
InHousePolynomialSolverResult
Definition cardano.h:47

References cubic_solver(), line, notvalid, and quadratic.

Referenced by pappso::MzCalibrationModel1::getMzFromTofIndex().