Functions | |
| void | cpl_matrix_dump (cpl_matrix *matrix) |
| Print a matrix. More... | |
| cpl_matrix * | cpl_matrix_new (int rows, int columns) |
| Create a zero matrix of given size. More... | |
| cpl_matrix * | cpl_matrix_new_from_data (double *data, int rows, int columns) |
| Create a new matrix from existing data. More... | |
| cpl_matrix * | cpl_matrix_new_constant (double value, int rows, int columns) |
| Create a new matrix initialised to a given value. More... | |
| cpl_matrix * | cpl_matrix_new_identity (int size) |
| Create an identity matrix. More... | |
| cpl_matrix * | cpl_matrix_new_diagonal (double *diagonal, int size) |
| Create a diagonal matrix. More... | |
| void | cpl_matrix_delete (cpl_matrix *matrix) |
| Delete a matrix. More... | |
| void | cpl_matrix_delete_but_data (cpl_matrix *matrix) |
| Delete a matrix, but not its data buffer. More... | |
| int | cpl_matrix_get_nrow (cpl_matrix *matrix) |
| Get the number of rows of a matrix. More... | |
| int | cpl_matrix_get_ncol (cpl_matrix *matrix) |
| Get the number of columns of a matrix. More... | |
| double * | cpl_matrix_get_data (cpl_matrix *matrix) |
| Get the pointer to a matrix data buffer. More... | |
| double | cpl_matrix_get (cpl_matrix *matrix, int row, int column) |
| Get the value of a matrix element. More... | |
| cpl_error_code | cpl_matrix_set (cpl_matrix *matrix, int row, int column, double value) |
| Write a value to a matrix element. More... | |
| cpl_matrix * | cpl_matrix_duplicate (cpl_matrix *matrix) |
| Make a copy of a matrix. More... | |
| cpl_matrix * | cpl_matrix_extract (cpl_matrix *matrix, int start_row, int start_column, int step_row, int step_column, int nrows, int ncolumns) |
| Copy a submatrix from a matrix. More... | |
| cpl_matrix * | cpl_matrix_extract_row (cpl_matrix *matrix, int row) |
| Copy a matrix row. More... | |
| cpl_error_code | cpl_matrix_copy_row (cpl_matrix *matrix, double *values, int row) |
| Write an array of values to a matrix row. More... | |
| cpl_matrix * | cpl_matrix_extract_column (cpl_matrix *matrix, int column) |
| Copy a matrix column. More... | |
| cpl_error_code | cpl_matrix_copy_column (cpl_matrix *matrix, double *values, int column) |
| Write an array of values to a matrix column. More... | |
| cpl_matrix * | cpl_matrix_extract_diagonal (cpl_matrix *matrix, int diagonal) |
| Copy a matrix diagonal. More... | |
| cpl_error_code | cpl_matrix_copy_diagonal (cpl_matrix *matrix, double *values, int diagonal) |
| Write an array of values to a matrix diagonal. More... | |
| cpl_error_code | cpl_matrix_fill (cpl_matrix *matrix, double value) |
| Write the same value to all matrix elements. More... | |
| cpl_error_code | cpl_matrix_fill_row (cpl_matrix *matrix, double value, int row) |
| Write the same value to a matrix row. More... | |
| cpl_error_code | cpl_matrix_fill_column (cpl_matrix *matrix, double value, int column) |
| Write the same value to a matrix column. More... | |
| cpl_error_code | cpl_matrix_fill_diagonal (cpl_matrix *matrix, double value, int diagonal) |
| Write the same value to a matrix diagonal. More... | |
| cpl_error_code | cpl_matrix_copy_submatrix (cpl_matrix *matrix, cpl_matrix *submatrix, int row, int col) |
| Write the values of a matrix into another matrix. More... | |
| cpl_error_code | cpl_matrix_fill_submatrix (cpl_matrix *matrix, double value, int row, int col, int nrow, int ncol) |
| Write the same value into a submatrix of a matrix. More... | |
| cpl_error_code | cpl_matrix_shift (cpl_matrix *matrix, int rshift, int cshift) |
| Shift matrix elements. More... | |
| cpl_error_code | cpl_matrix_chop (cpl_matrix *matrix, double tolerance) |
| Rounding to zero very small numbers in matrix. More... | |
| int | cpl_matrix_is_zero (cpl_matrix *matrix, double tolerance) |
| Check for zero matrix. More... | |
| int | cpl_matrix_is_diagonal (cpl_matrix *matrix, double tolerance) |
| Check if a matrix is diagonal. More... | |
| int | cpl_matrix_is_identity (cpl_matrix *matrix, double tolerance) |
| Check for identity matrix. More... | |
| cpl_error_code | cpl_matrix_swap_rows (cpl_matrix *matrix, int row1, int row2) |
| Swap two matrix rows. More... | |
| cpl_error_code | cpl_matrix_swap_columns (cpl_matrix *matrix, int column1, int column2) |
| Swap two matrix columns. More... | |
| cpl_error_code | cpl_matrix_swap_rowcolumn (cpl_matrix *matrix, int row) |
| Swap a matrix column with a matrix row. More... | |
| cpl_error_code | cpl_matrix_flip_rows (cpl_matrix *matrix) |
| Reverse order of rows in matrix. More... | |
| cpl_error_code | cpl_matrix_flip_columns (cpl_matrix *matrix) |
| Reverse order of columns in matrix. More... | |
| cpl_matrix * | cpl_matrix_transpose (cpl_matrix *matrix) |
| Create transposed matrix. More... | |
| cpl_error_code | cpl_matrix_sort_rows (cpl_matrix *matrix, int mode) |
| Sort matrix by rows. More... | |
| cpl_error_code | cpl_matrix_sort_columns (cpl_matrix *matrix, int mode) |
| Sort matrix by columns. More... | |
| cpl_error_code | cpl_matrix_delete_rows (cpl_matrix *matrix, int start, int count) |
| Delete rows from a matrix. More... | |
| cpl_error_code | cpl_matrix_delete_columns (cpl_matrix *matrix, int start, int count) |
| Delete columns from a matrix. More... | |
| cpl_error_code | cpl_matrix_reshape (cpl_matrix *matrix, int top, int bottom, int left, int right) |
| Reshape a matrix. More... | |
| cpl_error_code | cpl_matrix_resize (cpl_matrix *matrix, int rows, int columns) |
| Resize a matrix. More... | |
| cpl_error_code | cpl_matrix_merge (cpl_matrix *matrix1, cpl_matrix *matrix2, int mode) |
| Merge two matrices. More... | |
| cpl_error_code | cpl_matrix_add (cpl_matrix *matrix1, cpl_matrix *matrix2) |
| Add two matrices. More... | |
| cpl_error_code | cpl_matrix_subtract (cpl_matrix *matrix1, cpl_matrix *matrix2) |
| Subtract a matrix from another. More... | |
| cpl_error_code | cpl_matrix_multiply (cpl_matrix *matrix1, cpl_matrix *matrix2) |
| Multiply two matrices element by element. More... | |
| cpl_error_code | cpl_matrix_divide (cpl_matrix *matrix1, cpl_matrix *matrix2) |
| Divide a matrix by another element by element. More... | |
| cpl_error_code | cpl_matrix_const_op (cpl_matrix *matrix, double value, int operation) |
| Constant arithmetic on a matrix. More... | |
| cpl_error_code | cpl_matrix_add_constant (cpl_matrix *matrix, double value) |
| Add a scalar to a matrix. More... | |
| cpl_error_code | cpl_matrix_multiply_constant (cpl_matrix *matrix, double value) |
| Multiply a matrix by a scalar. More... | |
| cpl_error_code | cpl_matrix_logarithm (cpl_matrix *matrix, double base) |
| Compute the logarithm of matrix elements. More... | |
| cpl_error_code | cpl_matrix_exponential (cpl_matrix *matrix, double base) |
| Compute the exponential of matrix elements. More... | |
| cpl_error_code | cpl_matrix_power (cpl_matrix *matrix, double exponent) |
| Compute a power of matrix elements. More... | |
| cpl_matrix * | cpl_matrix_product (cpl_matrix *matrix1, cpl_matrix *matrix2) |
| Rows-by-columns product of two matrices. More... | |
| cpl_error_code | cpl_matrix_echelon (cpl_matrix *matrix) |
| Reduce the matrix in row echelon form. More... | |
| double | cpl_matrix_determinant (cpl_matrix *matrix) |
| Compute the determinant of a matrix. More... | |
| cpl_matrix * | cpl_matrix_solve_system (cpl_matrix *coeff, cpl_matrix *nonhomo) |
| Solution of a linear system. More... | |
| cpl_matrix * | cpl_matrix_inverse (cpl_matrix *matrix) |
| Find a matrix inverse. More... | |
| cpl_matrix * | cpl_matrix_leastsq (cpl_matrix *coeff, cpl_matrix *nonhomo) |
| Solution of an equation using a pseudo-inverse. More... | |
| double | cpl_matrix_mean (cpl_matrix *matrix) |
| Find the mean of matrix elements. More... | |
| double | cpl_matrix_stdev (cpl_matrix *matrix) |
| Find the standard deviation of matrix elements. More... | |
| double | cpl_matrix_median (cpl_matrix *matrix) |
| Find the median of matrix elements. More... | |
| double | cpl_matrix_min (cpl_matrix *matrix) |
| Find the minimum value of matrix elements. More... | |
| double | cpl_matrix_max (cpl_matrix *matrix) |
| Find the maximum value of matrix elements. More... | |
| cpl_error_code | cpl_matrix_minpos (cpl_matrix *matrix, int *row, int *column) |
| Find position of minimum value of matrix elements. More... | |
| cpl_error_code | cpl_matrix_maxpos (cpl_matrix *matrix, int *row, int *column) |
| Find position of the maximum value of matrix elements. More... | |
NULL pointer the functions will stop with an assertion failure, unless differently specified in the documentation.#include <cpl_matrix.h>
|
||||||||||||
|
Add two matrices.
|
|
||||||||||||
|
Add a scalar to a matrix.
|
|
||||||||||||
|
Rounding to zero very small numbers in matrix.
DBL_EPSILON is used.
|
|
||||||||||||||||
|
Constant arithmetic on a matrix.
l' or the 'e' operation. All the available operations are in practice carried out by the functions
cpl_matrix_const_op(matrix, 1.23, '^'); cpl_matrix_power(matrix, 1.23);
|
|
||||||||||||||||
|
Write an array of values to a matrix column.
NULL, an assertion failure will be generated. The input values are physically copied to the indicated matrix column. No check is performed on the buffer length, which is assumed to be equal to the number of rows in the matrix. The column number is counted from 0, and an assertion failure would be generated if the specified column were outside the matrix boundaries. |
|
||||||||||||||||
|
Write an array of values to a matrix diagonal.
NULL, an assertion failure will be generated. The input values are physically copied to the indicated matrix diagonal. No check is performed on the buffer length, which is assumed to be equal to the smaller dimension of the matrix. The diagonal number is counted from 0, corresponding to the diagonal starting at element (0,0). A square matrix has just one diagonal; if M != N, the number of diagonals in the matrix is |M - N| + 1. To specify a diagonal sequence number outside this range would generate an assertion failure. |
|
||||||||||||||||
|
Write an array of values to a matrix row.
NULL, an assertion failure will be generated. The input values are physically copied to the indicated matrix row. No check is performed on the buffer length, which is assumed to be equal to the number of columns in the matrix. The row number is counted from 0, and an assertion failure would be generated if the specified row were outside the matrix boundaries. |
|
||||||||||||||||||||
|
Write the values of a matrix into another matrix.
CPL_ERROR_ACCESS_OUT_OF_RANGE is returned. |
|
|
Delete a matrix.
NULL, nothing is done. |
|
|
Delete a matrix, but not its data buffer.
cpl_matrix_new_from_data() constructor, if the data buffer specified then was not allocated using the functions of the cpl_memory module. In such a case, the data buffer should be deallocated separately. See the documentation of the function cpl_matrix_new_from_data(). If matrix is NULL, nothing is done. |
|
||||||||||||||||
|
Delete columns from a matrix.
cpl_matrix_get_data() should be discarded. The first column to delete must be within the matrix boundaries, and the number of columns to delete must be greater than zero, or an assertion failure would be generated. The specified segment can extend beyond the end of the matrix, but the attempt to remove all matrix columns is flagged as an error because zero length matrices are illegal. Columns are counted starting from 0. |
|
||||||||||||||||
|
Delete rows from a matrix.
cpl_matrix_get_data() should be discarded. The first row to delete must be within the matrix boundaries, and the number of rows to delete must be greater than zero, or an assertion failure would be generated. The specified segment can extend beyond the end of the matrix, but the attempt to remove all matrix rows is flagged as an error because zero length matrices are illegal. Rows are counted starting from 0. |
|
|
Compute the determinant of a matrix.
|
|
||||||||||||
|
Divide a matrix by another element by element.
|
|
|
Print a matrix.
printf(). |
|
|
Make a copy of a matrix.
NULL, a NULL is returned and a CPL_ERROR_NULL_INPUT is set. To destroy the duplicated matrix the function cpl_matrix_delete() should be used. |
|
|
Reduce the matrix in row echelon form.
|
|
||||||||||||
|
Compute the exponential of matrix elements.
|
|
||||||||||||||||||||||||||||||||
|
Copy a submatrix from a matrix.
NULL, a NULL is returned and a CPL_ERROR_NULL_INPUT is set. Otherwise the new matrix will include the nrows x ncolumns values read from the input matrix elements starting from position (start_row, start_column), in a grid of steps step_row and step_column. If the extraction parameters exceed the input matrix boundaries, just the overlap matrix is returned. Such matrix would have sizes smaller than nrows x ncolumns. Only in case the start element is outside the input matrix boundaries, or the specified steps are zero or negative, the function would stop with an assertion failure. To destroy the new matrix the function cpl_matrix_delete() should be used. |
|
||||||||||||
|
Copy a matrix column.
NULL, a NULL pointer is returned and a CPL_ERROR_NULL_INPUT is set. Otherwise if a MxN matrix is given in input, the extracted column is a Mx1 matrix. The column number is counted from 0, and an assertion failure would be generated if the specified column were outside the matrix boundaries. To destroy the new matrix the function cpl_matrix_delete() should be used. |
|
||||||||||||
|
Copy a matrix diagonal.
NULL, a NULL is returned and a CPL_ERROR_NULL_INPUT is set. Otherwise, if a MxN matrix is given in input, the extracted diagonal is a Mx1 matrix if N >= M, or a 1xN matrix if N < M. The diagonal number is counted from 0, corresponding to the matrix diagonal starting at element (0,0). A square matrix has just one diagonal; if M != N, the number of diagonals in the matrix is |M - N| + 1. To specify a diagonal sequence number outside this range would generate an assertion failure. To destroy the new matrix the function cpl_matrix_delete() should be used. |
|
||||||||||||
|
Copy a matrix row.
NULL, a NULL pointer is returned and a CPL_ERROR_NULL_INPUT is set. Otherwise if a MxN matrix is given in input, the extracted row is a 1xN matrix. The row number is counted from 0, and an assertion failure would be generated if the specified row were outside the matrix boundaries. To destroy the new matrix the function cpl_matrix_delete() should be used. |
|
||||||||||||
|
Write the same value to all matrix elements.
|
|
||||||||||||||||
|
Write the same value to a matrix column.
|
|
||||||||||||||||
|
Write the same value to a matrix diagonal.
|
|
||||||||||||||||
|
Write the same value to a matrix row.
|
|
||||||||||||||||||||||||||||
|
Write the same value into a submatrix of a matrix.
|
|
|
Reverse order of columns in matrix.
|
|
|
Reverse order of rows in matrix.
|
|
||||||||||||||||
|
Get the value of a matrix element.
|
|
|
Get the pointer to a matrix data buffer.
0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3
4 5 6 7
8 9 10 11
|
|
|
Get the number of columns of a matrix.
NULL, zero is returned and a CPL_ERROR_NULL_INPUT is set. |
|
|
Get the number of rows of a matrix.
NULL, zero is returned and a CPL_ERROR_NULL_INPUT is set. |
|
|
Find a matrix inverse.
NULL pointer is returned, and a CPL_ERROR_SINGULAR_MATRIX is set. To destroy the new matrix the function cpl_matrix_delete() should be used.
|
|
||||||||||||
|
Check if a matrix is diagonal.
DBL_EPSILON is used.
|
|
||||||||||||
|
Check for identity matrix.
DBL_EPSILON is used.
|
|
||||||||||||
|
Check for zero matrix.
DBL_EPSILON is used.
|
|
||||||||||||
|
Solution of an equation using a pseudo-inverse.
coeff * X = nonhomo where X is the unknown column matrix, the pseudo-inverse solution to this equation is defined as:
solution = nonhomo * transp(coeff) * inverse(coeff * transp(coeff))
The solution matrix is solving the equation according to a least-squares criterion. To destroy this matrix the function
|
|
||||||||||||
|
Compute the logarithm of matrix elements.
CPL_ERROR_ILLEGAL_INPUT will be returned.
|
|
|
Find the maximum value of matrix elements.
|
|
||||||||||||||||
|
Find position of the maximum value of matrix elements.
NULL input pointers.
|
|
|
Find the mean of matrix elements.
|
|
|
Find the median of matrix elements.
|
|
||||||||||||||||
|
Merge two matrices.
|
|
|
Find the minimum value of matrix elements.
|
|
||||||||||||||||
|
Find position of minimum value of matrix elements.
NULL input pointers.
|
|
||||||||||||
|
Multiply two matrices element by element.
|
|
||||||||||||
|
Multiply a matrix by a scalar.
|
|
||||||||||||
|
Create a zero matrix of given size.
cpl_matrix_delete() should be used. |
|
||||||||||||||||
|
Create a new matrix initialised to a given value.
cpl_matrix_delete() should be used. |
|
||||||||||||
|
Create a diagonal matrix.
NULL input pointer. Note that the size of the data buffer is not checked in any way, and it is expected to match the specified matrix size. The data buffer is physically copied, so it could be deallocated also while the matrix is still in use. To destroy this matrix the function cpl_matrix_delete() should be used. |
|
||||||||||||||||
|
Create a new matrix from existing data.
NULL input pointer. Note that the size of the input data array is not checked in any way, and it is expected to match the specified matrix sizes. The input arrays is supposed to contain in sequence all the new cpl_matrix rows. For instance, in the case of a 3x4 matrix, the input array should contain 12 elements 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3
4 5 6 7
8 9 10 11
cpl_matrix_delete() would take care of deallocating it. To avoid problems with the memory managment, the specified data buffer should be allocated using the functions of the cpl_memory module, and also statically allocated data should be strictly avoided. If this were not the case, this matrix should not be destroyed using cpl_matrix_delete(), but cpl_matrix_delete_but_data() should be used instead; moreover, functions implying memory handling (as cpl_matrix_resize(), or cpl_matrix_delete_row() ) should not be used. |
|
|
Create an identity matrix.
cpl_matrix_delete() should be used. |
|
||||||||||||
|
Compute a power of matrix elements.
CPL_ERROR_ILLEGAL_INPUT is returned and the matrix will be left unchanged. If the exponent is zero, then any (non negative) matrix element would be assigned the value 1.0.
|
|
||||||||||||
|
Rows-by-columns product of two matrices.
cpl_matrix_delete() should be used.
|
|
||||||||||||||||||||||||
|
Reshape a matrix.
|
|
||||||||||||||||
|
Resize a matrix.
|
|
||||||||||||||||||||
|
Write a value to a matrix element.
|
|
||||||||||||||||
|
Shift matrix elements.
|
|
||||||||||||
|
Solution of a linear system.
coeff * X = nonhomo
coeff must be an NxN matrix, and nonhomo a Nx1 matrix (a one-column matrix). If such conditions are not fulfilled, an assertion failure is generated. To destroy the solution matrix the function
|
|
||||||||||||
|
Sort matrix by columns.
|
|
||||||||||||
|
Sort matrix by rows.
|
|
|
Find the standard deviation of matrix elements.
|
|
||||||||||||
|
Subtract a matrix from another.
|
|
||||||||||||||||
|
Swap two matrix columns.
CPL_ERROR_NONE is still returned. |
|
||||||||||||
|
Swap a matrix column with a matrix row.
|
|
||||||||||||||||
|
Swap two matrix rows.
CPL_ERROR_NONE is still returned. |
|
|
Create transposed matrix.
cpl_matrix_delete() should be used. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002