DETMON Pipeline Reference Manual  1.2.4
Functions
1D-Polynomial roots

Functions

cpl_error_code irplib_polynomial_add (cpl_polynomial *self, const cpl_polynomial *first, const cpl_polynomial *second)
 Add two polynomials of the same dimension.
cpl_error_code irplib_polynomial_subtract (cpl_polynomial *self, const cpl_polynomial *first, const cpl_polynomial *second)
 Subtract two polynomials of the same dimension.
cpl_error_code irplib_polynomial_multiply_scalar (cpl_polynomial *self, const cpl_polynomial *other, double factor)
 Multiply a polynomial with a scalar.
cpl_error_code irplib_polynomial_solve_1d_all (const cpl_polynomial *self, cpl_vector *roots, cpl_size *preal)
 Compute all n roots of p(x) = 0, where p(x) is of degree n, n > 0.

Detailed Description


Function Documentation

cpl_error_code irplib_polynomial_add ( cpl_polynomial *  self,
const cpl_polynomial *  first,
const cpl_polynomial *  second 
)

Add two polynomials of the same dimension.

Parameters:
selfThe polynomial to hold the result
firstThe 1st polynomial to add
secondThe 2nd polynomial to add
Returns:
CPL_ERROR_NONE or the relevant CPL error code
Note:
self may be passed also as first and/or second

Possible CPL error code set in this function:

  • CPL_ERROR_NULL_INPUT if an input pointer is NULL
  • CPL_ERROR_INCOMPATIBLE_INPUT if the polynomials do not have identical dimensions
  • CPL_ERROR_UNSUPPORTED_MODE if the dimension is not 1 (FIXME)

Definition at line 134 of file irplib_polynomial.c.

cpl_error_code irplib_polynomial_multiply_scalar ( cpl_polynomial *  self,
const cpl_polynomial *  other,
double  factor 
)

Multiply a polynomial with a scalar.

Parameters:
selfThe polynomial to hold the result
otherThe polynomial to scale, may equal self
factorThe factor to multiply with
Returns:
CPL_ERROR_NONE or the relevant CPL error code

Possible CPL error code set in this function:

  • CPL_ERROR_NULL_INPUT if an input pointer is NULL
  • CPL_ERROR_UNSUPPORTED_MODE if the dimension is not 1 (FIXME)

Definition at line 253 of file irplib_polynomial.c.

cpl_error_code irplib_polynomial_solve_1d_all ( const cpl_polynomial *  self,
cpl_vector *  roots,
cpl_size *  preal 
)

Compute all n roots of p(x) = 0, where p(x) is of degree n, n > 0.

Parameters:
selfThe 1D-polynomial
rootsA pre-allocated vector of length n to hold the roots
prealThe number of real roots found, or undefined on error
Returns:
CPL_ERROR_NONE or the relevant CPL error code

The *preal real roots are stored first in ascending order, then follows for each pair of complex conjugate roots, the real and imaginary parts of the root in the positive imaginary half-plane, for example for a 3rd degree polynomial with 1 real root, the roots are represented as: x0 = v0 x1 = v1 + i v2 x2 = v1 - i v2, where v0, v1, v2 are the elements of the roots vector.

Possible CPL error code set in this function:

  • CPL_ERROR_NULL_INPUT if an input pointer is NULL
  • CPL_ERROR_INVALID_TYPE if the polynomial has the wrong dimension
  • CPL_ERROR_DATA_NOT_FOUND if the polynomial does not have a degree of at least 1.
  • CPL_ERROR_INCOMPATIBLE_INPUT if the roots vector does not have length n
  • CPL_ERROR_DIVISION_BY_ZERO if a division by zero occurs (n > 4)
  • CPL_ERROR_CONTINUE if the algorithm does not converge (n > 4)

Definition at line 310 of file irplib_polynomial.c.

cpl_error_code irplib_polynomial_subtract ( cpl_polynomial *  self,
const cpl_polynomial *  first,
const cpl_polynomial *  second 
)

Subtract two polynomials of the same dimension.

Parameters:
selfThe polynomial to hold the result
firstThe polynomial to subtract from
secondThe polynomial to subtract
Returns:
CPL_ERROR_NONE or the relevant CPL error code
Note:
self may be passed also as first and/or second

Possible CPL error code set in this function:

  • CPL_ERROR_NULL_INPUT if an input pointer is NULL
  • CPL_ERROR_INCOMPATIBLE_INPUT if the polynomials do not have identical dimensions
  • CPL_ERROR_UNSUPPORTED_MODE if the dimension is not 1 (FIXME)

Definition at line 195 of file irplib_polynomial.c.