Matrix Utilities
Functions | |
cxdouble | giraffe_matrix_sigma_mean (const cpl_matrix *matrix, cxdouble mean) |
Compute sigma of matrix elements, with a given mean value. | |
cxdouble | giraffe_matrix_sigma_fit (const cpl_matrix *matrix, const cpl_matrix *matrix_fit) |
Compute sigma of matrix fit. | |
cpl_image * | giraffe_matrix_create_image (const cpl_matrix *matrix) |
Converts a matrix into an image. | |
cxint | giraffe_matrix_sort (cpl_matrix *mA) |
Sort in place the matrix elements in ascending order. | |
cpl_matrix * | giraffe_matrix_leastsq (const cpl_matrix *mA, const cpl_matrix *mB) |
Computes the solution of an equation using a pseudo-inverse. | |
cpl_matrix * | giraffe_matrix_solve_cholesky (const cpl_matrix *A, const cpl_matrix *b, const cpl_matrix *Cb, cpl_matrix *Cx) |
Solve a linear system using the Cholesky decomposition. | |
cxint | giraffe_matrix_clear (cpl_matrix *matrix) |
Set all elements of a matrix to zero. | |
void | giraffe_matrix_dump (const cpl_matrix *matrix, cxint max_rows) |
Output a maximum number of rows of the input matrix. |
Detailed Description
TBD
Function Documentation
cxint giraffe_matrix_clear | ( | cpl_matrix * | matrix | ) |
Set all elements of a matrix to zero.
- Parameters:
-
matrix The matrix to update.
- Returns:
- The function returns 0 on success, or a non-zero value otherwise.
The function replaces the value of each matrix element of matrix with 0
.
Definition at line 804 of file gimatrix.c.
cpl_image* giraffe_matrix_create_image | ( | const cpl_matrix * | matrix | ) |
Converts a matrix into an image.
- Parameters:
-
matrix The matrix to convert.
- Returns:
- The newly image created from the matrix, or
NULL
if the image cannot be created.
The function converts a CPL matrix into a CPL image. The matrix elements are copied into the image pixel buffer.
Definition at line 345 of file gimatrix.c.
void giraffe_matrix_dump | ( | const cpl_matrix * | matrix, | |
cxint | max_rows | |||
) |
Output a maximum number of rows of the input matrix.
- Parameters:
-
matrix Matrix to print. max_rows Maximum number of rows to print.
- Returns:
- Nothing.
Function prints part of a matrix. Printed are all columns, but only up to max_rows, number of rows. Each column has the column number printed as a header.
- Note:
- This function should be moved to CPL proper...
Definition at line 844 of file gimatrix.c.
Referenced by giraffe_slitgeometry_print(), and giraffe_wcalsolution_dump().
cpl_matrix* giraffe_matrix_leastsq | ( | const cpl_matrix * | mA, | |
const cpl_matrix * | mB | |||
) |
Computes the solution of an equation using a pseudo-inverse.
- Parameters:
-
mA left hand side [nr, nc] coefficients matrix. mB right hand side [nr, nc] matrix of the equation.
- Returns:
- The function returns the solution vector as a [nr, 1] column matrix.
The function solves the linear system
mX * mA = mB
for the unknown column matrix mX. The solution is given by the expression
mX = mB * transpose(mA) * inverse(mA * transpose(mA))
The solution matrix is solving the equation according to a least-squares criterion. To destroy this matrix the function cpl_matrix_delete()
should be used.
- Note:
- This function works properly only in the case all the elements of the input matrix do not contain garbage (such as
NaN
or infinity).
Definition at line 511 of file gimatrix.c.
cxdouble giraffe_matrix_sigma_fit | ( | const cpl_matrix * | matrix, | |
const cpl_matrix * | matrix_fit | |||
) |
Compute sigma of matrix fit.
- Parameters:
-
matrix Original matrix matrix_fit Matrix to compare
- Returns:
- Sigma of fit
Function computes sigma of fit between two matrixes
- Note:
- This function may be moved to CPL
Definition at line 283 of file gimatrix.c.
cxdouble giraffe_matrix_sigma_mean | ( | const cpl_matrix * | matrix, | |
cxdouble | mean | |||
) |
Compute sigma of matrix elements, with a given mean value.
- Parameters:
-
matrix Input matrix mean Value to be used as mean value during calculation
- Returns:
- Sigma of matrix
Function computes sigma of matrix elements, with a given mean value
- Note:
- This function might be moved to CPL.
Definition at line 237 of file gimatrix.c.
cpl_matrix* giraffe_matrix_solve_cholesky | ( | const cpl_matrix * | A, | |
const cpl_matrix * | b, | |||
const cpl_matrix * | Cb, | |||
cpl_matrix * | Cx | |||
) |
Solve a linear system using the Cholesky decomposition.
- Parameters:
-
A The design matrix of the system b The right hand side of the system Cb The covariance matrix of the right hand side. Cx The covariance matrix of the solution vector.
- Returns:
- The function returns the solution vector of the linear system, or
NULL
in case of an error.
The function solves the over-determined linear system Ax = b, where A is an m
times n
matrix, b is an m
times 1
matrix (a column vector), and x is the n
times 1
solution matrix.
A covariance matrix Cb of the right hand side vector b may be given. If it is not NULL, it is when the system is solved. It has to be a m
times m
matrix.
Similarly if the covariance matrix of the solution vector x, Cx, is not NULL
, the computed covariance matrix of the solution is stored there. It must be a n
times n
matrix. Any contents of this matrix is overwritten, and its contents is undetermined if the function returns with an error.
Definition at line 587 of file gimatrix.c.
cxint giraffe_matrix_sort | ( | cpl_matrix * | mA | ) |
Sort in place the matrix elements in ascending order.
- Parameters:
-
mA The matrix to sort.
- Returns:
- 0 on success, -1 on failure
The input matrix mA is sorted in place. On the successfull return the matrix mA contains the original values sorted in ascending order.
Definition at line 388 of file gimatrix.c.