matrix module
1.00.00
www.protokollkonverter.de
|
Data Structures | |
struct | _MATRIX |
internal description of a matrix More... | |
Macros | |
#define | VECTOR_STANDARD_DIMENSION 3 |
standard dimension for vectors, normal coordination system More... | |
Typedefs | |
typedef struct _MATRIX * | MATRIX |
instance pointer of a matrix More... | |
typedef struct _MATRIX * | VECTOR |
instance pointer of a vector More... | |
typedef double | MATRIX_VALUE |
type of supported value More... | |
typedef struct _MATRIX | TMATRIX |
dummy to avoid compiler warning More... | |
Functions | |
void | matrixPrint (MATRIX A) |
print matrix More... | |
MATRIX | matrixNew (const size_t rows, const size_t columns) |
create a new matrix More... | |
MATRIX | matrixNewUnit (const size_t dimension) |
create a new unit matrix More... | |
void | matrixDelete (MATRIX *A) |
free memory allocated by matrixNew More... | |
bool | matrixGetDimension (MATRIX A, size_t *rows, size_t *columns) |
get dimensions of matrix More... | |
bool | matrixEquals (MATRIX A, MATRIX B) |
compare two matrices More... | |
bool | matrixSetElement (MATRIX A, const size_t row, const size_t column, const MATRIX_VALUE value) |
set one element in matrix More... | |
bool | matrixSetRow (MATRIX A, const size_t row, const MATRIX_VALUE values[], const size_t valuesCount) |
set one row in matrix More... | |
bool | matrixSetColumn (MATRIX A, const size_t column, const MATRIX_VALUE values[], const size_t valuesCount) |
set one column in matrix More... | |
bool | matrixSet (MATRIX A, const MATRIX_VALUE values[], const size_t valuesCount) |
set values of matrix More... | |
bool | matrixGetElement (MATRIX A, const size_t row, const size_t column, MATRIX_VALUE *value) |
get one element in matrix More... | |
bool | matrixGetRow (MATRIX A, const size_t row, MATRIX_VALUE values[], size_t *valuesCount) |
get one row in matrix More... | |
bool | matrixGetColumn (MATRIX A, const size_t column, MATRIX_VALUE values[], size_t *valuesCount) |
get one column in matrix More... | |
bool | matrixGet (MATRIX A, MATRIX_VALUE values[], size_t *valuesCount) |
get values of matrix More... | |
MATRIX | matrixAddition (MATRIX A, MATRIX B) |
addition of two matrices More... | |
MATRIX | matrixSubstraction (MATRIX A, MATRIX B) |
subtraction of two matrices More... | |
MATRIX | matrixMultiplication (MATRIX A, MATRIX B) |
multiplication of two matrices More... | |
MATRIX | matrixMultiplicationScalar (MATRIX A, MATRIX_VALUE scalar) |
multiplication of matrix with scalar More... | |
MATRIX | matrixTransposition (MATRIX A) |
transposition of matrix More... | |
MATRIX | matrixInverse (MATRIX A) |
calculate inverse of matrix More... | |
bool | matrixDeterminant (MATRIX A, MATRIX_VALUE *determinant) |
calculate determinant of matrix More... | |
MATRIX | matrixClone (MATRIX A) |
clone a matrix More... | |
VECTOR | matrixSolve (MATRIX A, VECTOR y) |
solve matrix A with result vector y More... | |
static MATRIX | matrixSubDeterminant (MATRIX A, const size_t row, const size_t column) |
create a sub matrix More... | |
#define VECTOR_STANDARD_DIMENSION 3 |
standard dimension for vectors, normal coordination system
instance pointer of a matrix
instance pointer of a vector
The pointer is the same as MATRIX. It's for good programming style.
type of supported value
The type declares type of value to calculate with.
dummy to avoid compiler warning
void matrixPrint | ( | MATRIX | A | ) |
print matrix
Function prints matrix to stdout by puts and printf.
For example \(\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}\) will be printed as
[in] | A | matrix to print |
MATRIX matrixNew | ( | const size_t | rows, |
const size_t | columns | ||
) |
create a new matrix
Function allocates memory for a new matrix of given dimensions. All elements are set to 0.
[in] | rows | rows of matrix A to create |
[in] | columns | columns of matrix A to create |
MATRIX matrixNewUnit | ( | const size_t | dimension | ) |
create a new unit matrix
Function allocates memory for a new matrix of and initialize values.
For example matrixNewUnit(3) will create a matrix like
\[ \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} \]
[in] | dimension | dimension of rows and columns of matrix A to create |
void matrixDelete | ( | MATRIX * | A | ) |
free memory allocated by matrixNew
Function frees memory of matrix created by matrixNew or matrixNewUnit. The matrix pointer A will be set to NULL.
[in,out] | A | pointer to matrix do delete |
bool matrixGetDimension | ( | MATRIX | A, |
size_t * | rows, | ||
size_t * | columns | ||
) |
get dimensions of matrix
Function inserts dimensions of matrix in rows an columns if pointers are different to NULL.
[out] | rows | address of variable rows to insert count of rows of matrix, can be NULL if only columns are requested |
[out] | columns | address of variable columns to insert count of columns of matrix, can be NULL if only rows are requested |
compare two matrices
Function compares matrices. Matrices are equal if they have the same dimensions and all elements are equal.
[in] | A | matrix to compare with matrix B |
[in] | B | matrix to compare with matrix A |
bool matrixSetElement | ( | MATRIX | A, |
const size_t | row, | ||
const size_t | column, | ||
const MATRIX_VALUE | value | ||
) |
set one element in matrix
Function sets the value of one element in matrix. Rows are count from 0..(rows of matrix - 1) and columns from 0..(columns of matrix - 1).
[in] | A | matrix to set value in |
[in] | row | row of element |
[in] | column | column of element |
[in] | value | value to set to element |
bool matrixSetRow | ( | MATRIX | A, |
const size_t | row, | ||
const MATRIX_VALUE | values[], | ||
const size_t | valuesCount | ||
) |
set one row in matrix
Function sets values of one row in matrix. Rows are count from 0..(rows of matrix - 1). valuesCount must be equal to columns of matrix.
[in] | A | matrix to set value in |
[in] | row | row to set |
[in] | values | values to set |
[in] | valuesCount | count of values to set |
bool matrixSetColumn | ( | MATRIX | A, |
const size_t | column, | ||
const MATRIX_VALUE | values[], | ||
const size_t | valuesCount | ||
) |
set one column in matrix
Function sets values of one column in matrix. Columns are count from 0..(columns of matrix - 1).
[in] | A | matrix to set value in |
[in] | column | column to set |
[in] | values | values to set |
[in] | valuesCount | count of values to set |
bool matrixSet | ( | MATRIX | A, |
const MATRIX_VALUE | values[], | ||
const size_t | valuesCount | ||
) |
set values of matrix
Function sets all values of matrix. Columns are count from 0..(columns of matrix - 1).
values must be sorted in following way:
\(\lbrace a_{0,0}, a_{0,1}, .. a_{0,(columns-1)}, a_{1,0}, a_{1,1}, ..., a_{(rows-1),(columns-1)} \rbrace\)
[in] | A | matrix to set value in |
[in] | values | values to set |
[in] | valuesCount | count of values to set |
bool matrixGetElement | ( | MATRIX | A, |
const size_t | row, | ||
const size_t | column, | ||
MATRIX_VALUE * | value | ||
) |
get one element in matrix
Function gets the value of one element in matrix. Rows are count from 0..(rows of matrix - 1) and columns from 0..(columns of matrix - 1).
[in] | A | matrix to get value from |
[in] | row | row of element |
[in] | column | column of element |
[out] | value | pointer to value to set value of element in |
bool matrixGetRow | ( | MATRIX | A, |
const size_t | row, | ||
MATRIX_VALUE | values[], | ||
size_t * | valuesCount | ||
) |
get one row in matrix
Function gets values of one row in matrix. Rows are count from 0..(rows of matrix - 1).
[in] | A | matrix to get values from |
[in] | row | row to get |
[out] | values | pointer to values to copy value of elements to |
[in,out] | valuesCount | count of values in array contains afterwards count of copied values |
bool matrixGetColumn | ( | MATRIX | A, |
const size_t | column, | ||
MATRIX_VALUE | values[], | ||
size_t * | valuesCount | ||
) |
get one column in matrix
Function gets values of one column in matrix. Columns are count from 0..(columns of matrix - 1).
[in] | A | matrix to get values from |
[in] | column | column to get |
[out] | values | pointer to values to copy value of elements to |
[in,out] | valuesCount | count of values in array contains afterwards count of copied values |
bool matrixGet | ( | MATRIX | A, |
MATRIX_VALUE | values[], | ||
size_t * | valuesCount | ||
) |
get values of matrix
Function gets all values of matrix. Columns are count from 0..(columns of matrix - 1).
values are sorted in following way:
\(\lbrace a_{0,0}, a_{0,1}, .. a_{0,(columns-1)}, a_{1,0}, a_{1,1}, ..., a_{(rows-1),(columns-1)} \rbrace\)
[in] | A | matrix to get values from |
[out] | values | pointer to values to copy value of elements to |
[in,out] | valuesCount | count of values in array contains afterwards count of copied values |
addition of two matrices
Function adds two matrices.
[in] | A | matrix 1 to add |
[in] | B | matrix 2 to add |
subtraction of two matrices
Function subtract matrix B form A.
[in] | A | matrix to subtract from |
[in] | B | matrix to subtract from A |
multiplication of two matrices
Function multiplies matrix A and B.
[in] | A | matrix to multiply |
[in] | B | matrix to multiply to A |
MATRIX matrixMultiplicationScalar | ( | MATRIX | A, |
MATRIX_VALUE | scalar | ||
) |
multiplication of matrix with scalar
Function multiplies matrix A with scalar value.
[in] | A | matrix to multiply |
[in] | scalar | value to multiply matrix A with |
transposition of matrix
Function transpose matrix.
[in] | A | matrix to transpose |
calculate inverse of matrix
Function inverses matrix by recursive Leipniz.
[in] | A | matrix to inverse |
bool matrixDeterminant | ( | MATRIX | A, |
MATRIX_VALUE * | determinant | ||
) |
calculate determinant of matrix
Function calculate determinant of matrix by recursive Leipniz.
[in] | A | matrix to calculate |
[out] | determinant | pointer to value to set determinant of matrix in |
clone a matrix
Function creates a new matrix with the same dimensions and values like given matrix.
[in] | A | matrix to clone |
solve matrix A with result vector y
Function solves system of linear equations by Cramer with determinants by recursive Leipniz.
\[ A * \vec a = \vec y \]
[in] | A | matrix of a coefficients |
[in] | y | vector with results |
create a sub matrix
Function creates a sub matrix of matrix A. The sub matrix has dimensions (rows of A) - 1 and (columns of A) - 1. The new matrix contains all elements except the elements of given row and column.
\[ \begin{pmatrix} a_{0,0} & a_{0,1} & a_{0,1} \\ a_{1,0} & a_{1,1} & a_{1,2} \\ a_{2,0} & a_{2,1} & a_{2,2} \end{pmatrix} with \begin{Bmatrix} row := 1 \\ column := 2 \end{Bmatrix} => \begin{vmatrix} a_{0,0} & a_{0,1} \\ a_{2,0} & a_{2,1} \end{vmatrix} \]
[in] | A | matrix to create a sub matrix from |
[in] | row | row of matrix A to ignore |
[in] | column | column of matrix A to ignore |