JWS C Library
C language utility library
matrix_math.h File Reference

Declarations for mathematical matrix operations. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include "jwsc/base/error.h"
#include "jwsc/math/complex.h"
#include "jwsc/vector/vector.h"
#include "jwsc/matrix/matrix.h"
Include dependency graph for matrix_math.h:

Go to the source code of this file.

Functions

add_scalar_to_matrix

Adds a scalar to a matrix.

void add_scalar_to_matrix_f (Matrix_f **m_out, const Matrix_f *m_in, float a)
 Adds a scalar to a single precision matrix.
void add_scalar_to_matrix_d (Matrix_d **m_out, const Matrix_d *m_in, double a)
 Adds a scalar to a double precision matrix.
void add_scalar_to_matrix_cf (Matrix_cf **m_out, const Matrix_cf *m_in, Complex_f z)
 Adds a scalar to a single precision complex matrix.
void add_scalar_to_matrix_cd (Matrix_cd **m_out, const Matrix_cd *m_in, Complex_d z)
 Adds a scalar to a double precision complex matrix.
multiply_matrix_by_scalar

Multiplies a matrix by a scalar.

void multiply_matrix_by_scalar_f (Matrix_f **m_out, const Matrix_f *m_in, float a)
 Multiplies a single precision matrix by a scalar.
void multiply_matrix_by_scalar_d (Matrix_d **m_out, const Matrix_d *m_in, double a)
 Multiplies a double precision matrix by a scalar.
void multiply_matrix_by_scalar_cf (Matrix_cf **m_out, const Matrix_cf *m_in, Complex_f z)
 Multiplies a single precision complex matrix by a scalar.
void multiply_matrix_by_scalar_cd (Matrix_cd **m_out, const Matrix_cd *m_in, Complex_d z)
 Multiplies a double precision complex matrix by a scalar.
multiply_matrices

Multiplies a two matrices.

Errormultiply_matrices_f (Matrix_f **m_out, const Matrix_f *m_1, const Matrix_f *m_2)
 Multiples two single precision matrices.
Errormultiply_matrices_d (Matrix_d **m_out, const Matrix_d *m_1, const Matrix_d *m_2)
 Multiples two double precision matrices.
Errormultiply_matrices_cf (Matrix_cf **m_out, const Matrix_cf *m_1, const Matrix_cf *m_2)
 Multiples two single precision complex matrices.
Errormultiply_matrices_cd (Matrix_cd **m_out, const Matrix_cd *m_1, const Matrix_cd *m_2)
 Multiples two double precision complex matrices.
multiply_matrices_elt_wise

Multiplies a two matrices element by element.

Errormultiply_matrices_elt_wise_f (Matrix_f **m_out, const Matrix_f *m_1, const Matrix_f *m_2)
 Multiples two single precision matrices element by element.
Errormultiply_matrices_elt_wise_d (Matrix_d **m_out, const Matrix_d *m_1, const Matrix_d *m_2)
 Multiples two double precision matrices element by element.
Errormultiply_matrices_elt_wise_cf (Matrix_cf **m_out, const Matrix_cf *m_1, const Matrix_cf *m_2)
 Multiples two single precision complex matrices element by element.
Errormultiply_matrices_elt_wise_cd (Matrix_cd **m_out, const Matrix_cd *m_1, const Matrix_cd *m_2)
 Multiples two double precision complex matrices element by element.
transpose_matrix

Transposes a matrix.

void transpose_matrix_f (Matrix_f **m_out, const Matrix_f *m_in)
 Transposes a single precision matrix.
void transpose_matrix_d (Matrix_d **m_out, const Matrix_d *m_in)
 Transposes a double precision matrix.
void transpose_matrix_cf (Matrix_cf **m_out, const Matrix_cf *m_in)
 Transposes a single precision matrix.
void transpose_matrix_cd (Matrix_cd **m_out, const Matrix_cd *m_in)
 Transposes a double precision complex matrix.
multiply_matrix_and_vector

Multiplies a matrix and a vector.

Errormultiply_matrix_and_vector_f (Vector_f **v_out, const Matrix_f *m_in, const Vector_f *v_in)
 Multiplies a single precision matrix and vector.
Errormultiply_matrix_and_vector_d (Vector_d **v_out, const Matrix_d *m_in, const Vector_d *v_in)
 Multiplies a double precision matrix and vector.
Errormultiply_matrix_and_vector_cf (Vector_cf **v_out, const Matrix_cf *m_in, const Vector_cf *v_in)
 Multiplies a single precision complex matrix and vector.
Errormultiply_matrix_and_vector_cd (Vector_cd **v_out, const Matrix_cd *m_in, const Vector_cd *v_in)
 Multiplies a double precision complex matrix and vector.
add_matrices

Adds two matrices element-wise.

Erroradd_matrices_f (Matrix_f **m_out, const Matrix_f *m_1, const Matrix_f *m_2)
 Adds two single precision matrices element-wise.
Erroradd_matrices_d (Matrix_d **m_out, const Matrix_d *m_1, const Matrix_d *m_2)
 Adds two double precision matrices element-wise.
Erroradd_matrices_cf (Matrix_cf **m_out, const Matrix_cf *m_1, const Matrix_cf *m_2)
 Adds two single precision complex matrices element-wise.
Erroradd_matrices_cd (Matrix_cd **m_out, const Matrix_cd *m_1, const Matrix_cd *m_2)
 Adds two double precision complex matrices element-wise.
subtract_matrices

Subtracts two matrices element-wise.

Errorsubtract_matrices_f (Matrix_f **m_out, const Matrix_f *m_1, const Matrix_f *m_2)
 Subtracts two single precision matrices element-wise.
Errorsubtract_matrices_d (Matrix_d **m_out, const Matrix_d *m_1, const Matrix_d *m_2)
 Subtracts two double precision matrices element-wise.
Errorsubtract_matrices_cf (Matrix_cf **m_out, const Matrix_cf *m_1, const Matrix_cf *m_2)
 Subtracts two single precision complex matrices element-wise.
Errorsubtract_matrices_cd (Matrix_cd **m_out, const Matrix_cd *m_1, const Matrix_cd *m_2)
 Subtracts two double precision complex matrices element-wise.
calc_matrix_asum

Calculates the absolute sum of a real matrix.

void calc_matrix_asum_f (float *sum_out, const Matrix_f *m)
 Calculates the absolute value sum of a single precision matrix.
void calc_matrix_asum_d (double *sum_out, const Matrix_d *m)
 Calculates the absolute value sum of a double precision matrix.
normalize_matrix_sum

Normalizes a real matrix by its sum.

void normalize_matrix_sum_f (Matrix_f **m_out, const Matrix_f *m_in)
 Normalizes a single precision matrix by its sum.
void normalize_matrix_sum_d (Matrix_d **m_out, const Matrix_d *m_in)
 Normalizes a double precision matrix by its sum.
calc_frobenius_norm

Calculates the Frobenius norm (Euclidean norm) of a matrix.

void calc_frobenius_norm_f (float *norm_out, const Matrix_f *m)
 Calculates the Frobenius norm of a single precision matrix.
void calc_frobenius_norm_d (double *norm_out, const Matrix_d *m)
 Calculates the Frobenius norm of a double precision matrix.
calc_frobenius_norm_diff

Calculates the Frobenius norm (Euclidean norm) of a difference of two matrices.

Errorcalc_frobenius_norm_diff_f (float *norm_out, const Matrix_f *m_1, const Matrix_f *m_2)
 Calculates the Frobenius norm of a difference of two single precision matrix.
Errorcalc_frobenius_norm_diff_d (double *norm_out, const Matrix_d *m_1, const Matrix_d *m_2)
 Calculates the Frobenius norm of a difference of two double precision matrix.
calc_frobenius_norm_abs_diff

Calculates the Frobenius norm (Euclidean norm) of a difference of two matrices, applying the absolute value to each matrix first.

Errorcalc_frobenius_norm_abs_diff_f (float *norm_out, const Matrix_f *m_1, const Matrix_f *m_2)
 Calculates the Frobenius norm of a difference of two single precision matrix, applying the absolute value to each matrix first.
Errorcalc_frobenius_norm_abs_diff_d (double *norm_out, const Matrix_d *m_1, const Matrix_d *m_2)
 Calculates the Frobenius norm of a difference of two double precision matrix, applying the absolute value to each matrix first.
calc_lu_matrix_determinant

Calculates the determinant of an LU decomposed matrix.

Errorcalc_lu_matrix_determinant_f (float *det_out, const Matrix_f *m, const Vector_i32 *pivot)
 Calculates the determinant of an LU decomposed single precision matrix.
Errorcalc_lu_matrix_determinant_d (double *det_out, const Matrix_d *m, const Vector_i32 *pivot)
 Calculates the determinant of an LU decomposed double precision matrix.
create_euler_rotation_matrix

Creates a standard Euler rotation matrix with angles phi, theta and psi.

void create_euler_rotation_matrix_f (Matrix_f **m_out, float phi, float theta, float psi)
 Creates a single precision Euler rotation matrix.
void create_euler_rotation_matrix_d (Matrix_d **m_out, float phi, float theta, float psi)
 Creates a double precision Euler rotation matrix.
create_3d_rotation_matrix

Creates a matrix for rotating points around an arbitrary vector.

Errorcreate_3d_rotation_matrix_1_f (Matrix_f **m_out, float phi, const Vector_f *v)
 Creates a single precision matrix for rotating points around an arbitrary vector.
Errorcreate_3d_rotation_matrix_1_d (Matrix_d **m_out, double phi, const Vector_d *v)
 Creates a double precision matrix for rotating points around an arbitrary vector.
Errorcreate_3d_rotation_matrix_2_f (Matrix_f **m_out, float phi, float x, float y, float z)
 Creates a single precision matrix for rotating points around an arbitrary vector.
Errorcreate_3d_rotation_matrix_2_d (Matrix_d **m_out, double phi, double x, double y, double z)
 Creates a double precision matrix for rotating points around an arbitrary vector.
create_3d_homo_rotation_matrix

Creates a homogeneous matrix for rotating points around an arbitrary vector.

Errorcreate_3d_homo_rotation_matrix_1_f (Matrix_f **m_out, float phi, const Vector_f *v)
 Creates a single precision homogeneous matrix for rotating points around an arbitrary vector.
Errorcreate_3d_homo_rotation_matrix_1_d (Matrix_d **m_out, double phi, const Vector_d *v)
 Creates a double precision homogeneous matrix for rotating points around an arbitrary vector.
Errorcreate_3d_homo_rotation_matrix_2_f (Matrix_f **m_out, float phi, float x, float y, float z)
 Creates a single precision homogeneous matrix for rotating points around an arbitrary vector.
Errorcreate_3d_homo_rotation_matrix_2_d (Matrix_d **m_out, double phi, double x, double y, double z)
 Creates a double precision homogeneous matrix for rotating points around an arbitrary vector.
create_3d_scaling_matrix

Creates a matrix for scaling points.

Errorcreate_3d_scaling_matrix_1_f (Matrix_f **m_out, const Vector_f *v)
 Creates a single precision matrix for scaling points.
Errorcreate_3d_scaling_matrix_1_d (Matrix_d **m_out, const Vector_d *v)
 Creates a double precision matrix for scaling points.
Errorcreate_3d_scaling_matrix_2_f (Matrix_f **m_out, float x, float y, float z)
 Creates a single precision matrix for scaling points.
Errorcreate_3d_scaling_matrix_2_d (Matrix_d **m_out, double x, double y, double z)
 Creates a double precision matrix for scaling points.
create_3d_homo_scaling_matrix

Creates a homogeneous matrix for scaling points.

Errorcreate_3d_homo_scaling_matrix_1_f (Matrix_f **m_out, const Vector_f *v)
 Creates a single precision homogeneous matrix for scaling points.
Errorcreate_3d_homo_scaling_matrix_1_d (Matrix_d **m_out, const Vector_d *v)
 Creates a double precision homogeneous matrix for scaling points.
Errorcreate_3d_homo_scaling_matrix_2_f (Matrix_f **m_out, float x, float y, float z)
 Creates a single precision homogeneous matrix for scaling points.
Errorcreate_3d_homo_scaling_matrix_2_d (Matrix_d **m_out, double x, double y, double z)
 Creates a double precision homogeneous matrix for scaling points.
create_3d_homo_translation_matrix

Creates a homogeneous matrix for translating points in R^3.

Errorcreate_3d_homo_translation_matrix_1_f (Matrix_f **m_out, const Vector_f *v)
 Creates a single precision homogeneous matrix for translating points in R^3.
Errorcreate_3d_homo_translation_matrix_1_d (Matrix_d **m_out, const Vector_d *v)
 Creates a double precision homogeneous matrix for translating points in R^3.
Errorcreate_3d_homo_translation_matrix_2_f (Matrix_f **m_out, float x, float y, float z)
 Creates a single precision homogeneous matrix for translating points in R^3.
Errorcreate_3d_homo_translation_matrix_2_d (Matrix_d **m_out, double x, double y, double z)
 Creates a double precision homogeneous matrix for translating points in R^3.

Detailed Description

Declarations for mathematical matrix operations.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Many of the functions are accelerated if linked against an optimized BLAS library.

Definition in file matrix_math.h.


Function Documentation

void add_scalar_to_matrix_f ( Matrix_f **  m_out,
const Matrix_f m_in,
float  a 
)

Adds a scalar to a single precision matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to add a to.
aScalar to add to the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 87 of file matrix_math.c.

void add_scalar_to_matrix_d ( Matrix_d **  m_out,
const Matrix_d m_in,
double  a 
)

Adds a scalar to a double precision matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to add a to.
aScalar to add to the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 122 of file matrix_math.c.

void add_scalar_to_matrix_cf ( Matrix_cf **  m_out,
const Matrix_cf m_in,
Complex_f  z 
)

Adds a scalar to a single precision complex matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to add a to.
zScalar to add to the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 157 of file matrix_math.c.

void add_scalar_to_matrix_cd ( Matrix_cd **  m_out,
const Matrix_cd m_in,
Complex_d  z 
)

Adds a scalar to a double precision complex matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to add a to.
zScalar to add to the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 193 of file matrix_math.c.

void multiply_matrix_by_scalar_f ( Matrix_f **  m_out,
const Matrix_f m_in,
float  a 
)

Multiplies a single precision matrix by a scalar.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to multiply scalar with.
aScalar to multiply by the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 241 of file matrix_math.c.

void multiply_matrix_by_scalar_d ( Matrix_d **  m_out,
const Matrix_d m_in,
double  a 
)

Multiplies a double precision matrix by a scalar.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to multiply scalar with.
aScalar to multiply by the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 289 of file matrix_math.c.

void multiply_matrix_by_scalar_cf ( Matrix_cf **  m_out,
const Matrix_cf m_in,
Complex_f  z 
)

Multiplies a single precision complex matrix by a scalar.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to multiply scalar with.
zScalar to multiply by the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 337 of file matrix_math.c.

void multiply_matrix_by_scalar_cd ( Matrix_cd **  m_out,
const Matrix_cd m_in,
Complex_d  z 
)

Multiplies a double precision complex matrix by a scalar.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to multiply scalar with.
zScalar to multiply by the values of m_in.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 390 of file matrix_math.c.

Error* multiply_matrices_f ( Matrix_f **  m_out,
const Matrix_f m_1,
const Matrix_f m_2 
)

Multiples two single precision matrices.

The matrices must have the proper dimensions for multiplication.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1First (left) matrix in the multiply operation.
m_2Second (right) matrix in the multiply operation.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
  • ERROR_INV_ARG Matrices m_1 and m_2 do not have compatible dimensions for multiplying.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 463 of file matrix_math.c.

Error* multiply_matrices_d ( Matrix_d **  m_out,
const Matrix_d m_1,
const Matrix_d m_2 
)

Multiples two double precision matrices.

The matrices must have the proper dimensions for multiplication.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1First (left) matrix in the multiply operation.
m_2Second (right) matrix in the multiply operation.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
  • ERROR_INV_ARG Matrices m_1 and m_2 do not have compatible dimensions for multiplying.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 544 of file matrix_math.c.

Error* multiply_matrices_cf ( Matrix_cf **  m_out,
const Matrix_cf m_1,
const Matrix_cf m_2 
)

Multiples two single precision complex matrices.

The matrices must have the proper dimensions for multiplication.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1First (left) matrix in the multiply operation.
m_2Second (right) matrix in the multiply operation.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
  • ERROR_INV_ARG Matrices m_1 and m_2 do not have compatible dimensions for multiplying.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 625 of file matrix_math.c.

Error* multiply_matrices_cd ( Matrix_cd **  m_out,
const Matrix_cd m_1,
const Matrix_cd m_2 
)

Multiples two double precision complex matrices.

The matrices must have the proper dimensions for multiplication.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1First (left) matrix in the multiply operation.
m_2Second (right) matrix in the multiply operation.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
  • ERROR_INV_ARG Matrices m_1 and m_2 do not have compatible dimensions for multiplying.
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 715 of file matrix_math.c.

Error* multiply_matrices_elt_wise_f ( Matrix_f **  m_out,
const Matrix_f m_1,
const Matrix_f m_2 
)

Multiples two single precision matrices element by element.

The matrices must have the same dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1First (left) matrix in the multiply operation.
m_2Second (right) matrix in the multiply operation.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 816 of file matrix_math.c.

Error* multiply_matrices_elt_wise_d ( Matrix_d **  m_out,
const Matrix_d m_1,
const Matrix_d m_2 
)

Multiples two double precision matrices element by element.

Definition at line 858 of file matrix_math.c.

Error* multiply_matrices_elt_wise_cf ( Matrix_cf **  m_out,
const Matrix_cf m_1,
const Matrix_cf m_2 
)

Multiples two single precision complex matrices element by element.

Definition at line 902 of file matrix_math.c.

Error* multiply_matrices_elt_wise_cd ( Matrix_cd **  m_out,
const Matrix_cd m_1,
const Matrix_cd m_2 
)

Multiples two double precision complex matrices element by element.

Definition at line 953 of file matrix_math.c.

void transpose_matrix_f ( Matrix_f **  m_out,
const Matrix_f m_in 
)

Transposes a single precision matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inmatrix to transpose.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1019 of file matrix_math.c.

void transpose_matrix_d ( Matrix_d **  m_out,
const Matrix_d m_in 
)

Transposes a double precision matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inmatrix to transpose.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1057 of file matrix_math.c.

void transpose_matrix_cf ( Matrix_cf **  m_out,
const Matrix_cf m_in 
)

Transposes a single precision matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inmatrix to transpose.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1095 of file matrix_math.c.

void transpose_matrix_cd ( Matrix_cd **  m_out,
const Matrix_cd m_in 
)

Transposes a double precision complex matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inmatrix to transpose.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 1133 of file matrix_math.c.

Error* multiply_matrix_and_vector_f ( Vector_f **  v_out,
const Matrix_f m_in,
const Vector_f v_in 
)

Multiplies a single precision matrix and vector.

The vector is treated as a column vector in the multiplication. The matrix and vector must have compatible dimensions for the matrix and column vector multiplication.

Parameters:
v_outResult parameter. If *v_out is NULL, a vector is allocated; otherwise its space is re-used.
m_inMatrix to multiply.
v_inColumn vector to multiply.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
Note:
If *v_out == v_in, then v_in is overwritten.

Definition at line 1194 of file matrix_math.c.

Error* multiply_matrix_and_vector_d ( Vector_d **  v_out,
const Matrix_d m_in,
const Vector_d v_in 
)

Multiplies a double precision matrix and vector.

The vector is treated as a column vector in the multiplication. The matrix and vector must have compatible dimensions for the matrix and column vector multiplication.

Parameters:
v_outResult parameter. If *v_out is NULL, a vector is allocated; otherwise its space is re-used.
m_inMatrix to multiply.
v_inColumn vector to multiply.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
Note:
If *v_out == v_in, then v_in is overwritten.

Definition at line 1269 of file matrix_math.c.

Error* multiply_matrix_and_vector_cf ( Vector_cf **  v_out,
const Matrix_cf m_in,
const Vector_cf v_in 
)

Multiplies a single precision complex matrix and vector.

The vector is treated as a column vector in the multiplication. The matrix and vector must have compatible dimensions for the matrix and column vector multiplication.

Parameters:
v_outResult parameter. If *v_out is NULL, a vector is allocated; otherwise its space is re-used.
m_inMatrix to multiply.
v_inColumn vector to multiply.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
Note:
If *v_out == v_in, then v_in is overwritten.

Definition at line 1344 of file matrix_math.c.

Error* multiply_matrix_and_vector_cd ( Vector_cd **  v_out,
const Matrix_cd m_in,
const Vector_cd v_in 
)

Multiplies a double precision complex matrix and vector.

The vector is treated as a column vector in the multiplication. The matrix and vector must have compatible dimensions for the matrix and column vector multiplication.

Parameters:
v_outResult parameter. If *v_out is NULL, a vector is allocated; otherwise its space is re-used.
m_inMatrix to multiply.
v_inColumn vector to multiply.
Returns:
On success, NULL is returned; otherwise an Error is returned and *m_out is freed and set to NULL (if it is not an input matrix).
Note:
If *v_out == v_in, then v_in is overwritten.

Definition at line 1428 of file matrix_math.c.

Error* add_matrices_f ( Matrix_f **  m_out,
const Matrix_f m_1,
const Matrix_f m_2 
)

Adds two single precision matrices element-wise.

The matrix must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1Matrix to add.
m_2Matrix to add.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 1520 of file matrix_math.c.

Error* add_matrices_d ( Matrix_d **  m_out,
const Matrix_d m_1,
const Matrix_d m_2 
)

Adds two double precision matrices element-wise.

The Matrix must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1Matrix to add.
m_2Matrix to add.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 1608 of file matrix_math.c.

Error* add_matrices_cf ( Matrix_cf **  m_out,
const Matrix_cf m_1,
const Matrix_cf m_2 
)

Adds two single precision complex matrices element-wise.

The Matrix must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1Matrix to add.
m_2Matrix to add.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 1696 of file matrix_math.c.

Error* add_matrices_cd ( Matrix_cd **  m_out,
const Matrix_cd m_1,
const Matrix_cd m_2 
)

Adds two double precision complex matrices element-wise.

The Matrix must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1Matrix to add.
m_2Matrix to add.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 1788 of file matrix_math.c.

Error* subtract_matrices_f ( Matrix_f **  m_out,
const Matrix_f m_1,
const Matrix_f m_2 
)

Subtracts two single precision matrices element-wise.

The Matrix must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1Matrix to subtract.
m_2Matrix to subtract.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 1892 of file matrix_math.c.

Error* subtract_matrices_d ( Matrix_d **  m_out,
const Matrix_d m_1,
const Matrix_d m_2 
)

Subtracts two double precision matrices element-wise.

The Matrix must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1Matrix to subtract.
m_2Matrix to subtract.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 1984 of file matrix_math.c.

Error* subtract_matrices_cf ( Matrix_cf **  m_out,
const Matrix_cf m_1,
const Matrix_cf m_2 
)

Subtracts two single precision complex matrices element-wise.

The Matrix must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1Matrix to subtract.
m_2Matrix to subtract.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 2076 of file matrix_math.c.

Error* subtract_matrices_cd ( Matrix_cd **  m_out,
const Matrix_cd m_1,
const Matrix_cd m_2 
)

Subtracts two double precision complex matrices element-wise.

The Matrix must have equal dimensions.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_1Matrix to subtract.
m_2Matrix to subtract.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL (if it is not m_1 or m_2).
Note:
If *m_out == m_[12], it is overwritten.

Definition at line 2172 of file matrix_math.c.

void calc_matrix_asum_f ( float *  sum_out,
const Matrix_f m 
)

Calculates the absolute value sum of a single precision matrix.

Parameters:
sum_outResult parameter. Sum of the absolute values of m.
mMatrix to calculate the sum of.

Definition at line 2268 of file matrix_math.c.

void calc_matrix_asum_d ( double *  sum_out,
const Matrix_d m 
)

Calculates the absolute value sum of a double precision matrix.

Parameters:
sum_outResult parameter. Sum of the absolute values of m.
mMatrix to calculate the sum of.

Definition at line 2292 of file matrix_math.c.

void normalize_matrix_sum_f ( Matrix_f **  m_out,
const Matrix_f m_in 
)

Normalizes a single precision matrix by its sum.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to normalize.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 2331 of file matrix_math.c.

void normalize_matrix_sum_d ( Matrix_d **  m_out,
const Matrix_d m_in 
)

Normalizes a double precision matrix by its sum.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
m_inMatrix to normalize.
Note:
If *m_out == m_in, then m_in is overwritten.

Definition at line 2354 of file matrix_math.c.

void calc_frobenius_norm_f ( float *  norm_out,
const Matrix_f m 
)

Calculates the Frobenius norm of a single precision matrix.

Parameters:
norm_outResult parameter.
mMatrix to calcualte the norm of.

Definition at line 2386 of file matrix_math.c.

void calc_frobenius_norm_d ( double *  norm_out,
const Matrix_d m 
)

Calculates the Frobenius norm of a double precision matrix.

Parameters:
norm_outResult parameter.
mMatrix to calcualte the norm of.

Definition at line 2411 of file matrix_math.c.

Error* calc_frobenius_norm_diff_f ( float *  norm_out,
const Matrix_f m_1,
const Matrix_f m_2 
)

Calculates the Frobenius norm of a difference of two single precision matrix.

Parameters:
norm_outResult parameter.
m_1Matrix to calcualte the norm of.
m_2Matrix to calcualte the norm of.

Definition at line 2451 of file matrix_math.c.

Error* calc_frobenius_norm_diff_d ( double *  norm_out,
const Matrix_d m_1,
const Matrix_d m_2 
)

Calculates the Frobenius norm of a difference of two double precision matrix.

Parameters:
norm_outResult parameter.
m_1Matrix to calcualte the norm of.
m_2Matrix to calcualte the norm of.

Definition at line 2493 of file matrix_math.c.

Error* calc_frobenius_norm_abs_diff_f ( float *  norm_out,
const Matrix_f m_1,
const Matrix_f m_2 
)

Calculates the Frobenius norm of a difference of two single precision matrix, applying the absolute value to each matrix first.

Parameters:
norm_outResult parameter.
m_1Matrix to calcualte the norm of.
m_2Matrix to calcualte the norm of.

Definition at line 2548 of file matrix_math.c.

Error* calc_frobenius_norm_abs_diff_d ( double *  norm_out,
const Matrix_d m_1,
const Matrix_d m_2 
)

Calculates the Frobenius norm of a difference of two double precision matrix, applying the absolute value to each matrix first.

Parameters:
norm_outResult parameter.
m_1Matrix to calcualte the norm of.
m_2Matrix to calcualte the norm of.

Definition at line 2590 of file matrix_math.c.

Error* calc_lu_matrix_determinant_f ( float *  det_out,
const Matrix_f m,
const Vector_i32 pivot 
)

Calculates the determinant of an LU decomposed single precision matrix.

Parameters:
det_outResult parameter.
mLU decomposed matrix to calculate the determinate of.
pivotPivot elements of the LU decomposition.
Returns:
On success, NULL is returned. On error, an Error is returned.

Definition at line 3086 of file matrix_math.c.

Error* calc_lu_matrix_determinant_d ( double *  det_out,
const Matrix_d m,
const Vector_i32 pivot 
)

Calculates the determinant of an LU decomposed double precision matrix.

Parameters:
det_outResult parameter.
mLU decomposed matrix to calculate the determinate of.
pivotPivot elements of the LU decomposition.
Returns:
On success, NULL is returned. On error, an Error is returned.

Definition at line 3127 of file matrix_math.c.

void create_euler_rotation_matrix_f ( Matrix_f **  m_out,
float  phi,
float  theta,
float  psi 
)

Creates a single precision Euler rotation matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phi1st Euler rotation angle around the z-axis.
theta2nd Euler rotation angle around the x-axis.
psi3rd Euler rotation angle around the z-axis.
Note:
The rotations are clockwise.

Definition at line 3788 of file matrix_math.c.

void create_euler_rotation_matrix_d ( Matrix_d **  m_out,
float  phi,
float  theta,
float  psi 
)

Creates a double precision Euler rotation matrix.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phi1st Euler rotation angle around the z-axis.
theta2nd Euler rotation angle around the x-axis.
psi3rd Euler rotation angle around the z-axis.

Definition at line 3827 of file matrix_math.c.

Error* create_3d_rotation_matrix_1_f ( Matrix_f **  m_out,
float  phi,
const Vector_f v 
)

Creates a single precision matrix for rotating points around an arbitrary vector.

The vector v must have 3 dimensions. The resulting matrix will have dimensions 3x3.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phiAngle of rotation, in radians. Use a positive value for clockwise, negative for counter-clockwise.
vVector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.
  • ERROR_INV_ARG Vector v does not have 3 dimensions or large enough magnitude.

Definition at line 3885 of file matrix_math.c.

Error* create_3d_rotation_matrix_1_d ( Matrix_d **  m_out,
double  phi,
const Vector_d v 
)

Creates a double precision matrix for rotating points around an arbitrary vector.

The vector v must have 3 dimensions. The resulting matrix will have dimensions 3x3.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phiAngle of rotation, in radians. Use a positive value for clockwise, negative for counter-clockwise.
vVector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.
  • ERROR_INV_ARG Vector v does not have 3 dimensions or large enough magnitude.

Definition at line 3918 of file matrix_math.c.

Error* create_3d_rotation_matrix_2_f ( Matrix_f **  m_out,
float  phi,
float  x,
float  y,
float  z 
)

Creates a single precision matrix for rotating points around an arbitrary vector.

The resulting matrix will have dimensions 3x3.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phiAngle of rotation, in radians. Use a positive value for clockwise, negative for counter-clockwise.
xX-coord of the vector to rotate around.
yY-coord of the vector to rotate around.
zZ-coord of the vector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 3952 of file matrix_math.c.

Error* create_3d_rotation_matrix_2_d ( Matrix_d **  m_out,
double  phi,
double  x,
double  y,
double  z 
)

Creates a double precision matrix for rotating points around an arbitrary vector.

The resulting matrix will have dimensions 3x3.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phiAngle of rotation, in radians. Use a positive value for clockwise, negative for counter-clockwise.
xX-coord of the vector to rotate around.
yY-coord of the vector to rotate around.
zZ-coord of the vector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4049 of file matrix_math.c.

Error* create_3d_homo_rotation_matrix_1_f ( Matrix_f **  m_out,
float  phi,
const Vector_f v 
)

Creates a single precision homogeneous matrix for rotating points around an arbitrary vector.

The homogeneous vector v must have at least 3 dimensions. The homogeneous coordinate, if it has one, is ignored and assumed to be 1. The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phiAngle of rotation, in radians. Use a positive value for clockwise, negative for counter-clockwise.
vVector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.
  • ERROR_INV_ARG Vector v does not have at least 3 dimensions or large enough magnitude.

Definition at line 4157 of file matrix_math.c.

Error* create_3d_homo_rotation_matrix_1_d ( Matrix_d **  m_out,
double  phi,
const Vector_d v 
)

Creates a double precision homogeneous matrix for rotating points around an arbitrary vector.

The homogeneous vector v must have at least 3 dimensions. The homogeneous coordinate, if it has one, is ignored and assumed to be 1. The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phiAngle of rotation, in radians. Use a positive value for clockwise, negative for counter-clockwise.
vVector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.
  • ERROR_INV_ARG Vector v does not have at least 3 dimensions or large enough magnitude.

Definition at line 4191 of file matrix_math.c.

Error* create_3d_homo_rotation_matrix_2_f ( Matrix_f **  m_out,
float  phi,
float  x,
float  y,
float  z 
)

Creates a single precision homogeneous matrix for rotating points around an arbitrary vector.

The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phiAngle of rotation, in radians. Use a positive value for clockwise, negative for counter-clockwise.
xX-coord of the vector to rotate around.
yY-coord of the vector to rotate around.
zZ-coord of the vector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4225 of file matrix_math.c.

Error* create_3d_homo_rotation_matrix_2_d ( Matrix_d **  m_out,
double  phi,
double  x,
double  y,
double  z 
)

Creates a double precision homogeneous matrix for rotating points around an arbitrary vector.

The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
phiAngle of rotation, in radians. Use a positive value for clockwise, negative for counter-clockwise.
xX-coord of the vector to rotate around.
yY-coord of the vector to rotate around.
zZ-coord of the vector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4322 of file matrix_math.c.

Error* create_3d_scaling_matrix_1_f ( Matrix_f **  m_out,
const Vector_f v 
)

Creates a single precision matrix for scaling points.

The vector v must have 3 dimensions. The resulting matrix will have dimensions 3x3.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
vVector to scale by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4427 of file matrix_math.c.

Error* create_3d_scaling_matrix_1_d ( Matrix_d **  m_out,
const Vector_d v 
)

Creates a double precision matrix for scaling points.

The vector v must have 3 dimensions. The resulting matrix will have dimensions 3x3.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
vVector to scale by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4457 of file matrix_math.c.

Error* create_3d_scaling_matrix_2_f ( Matrix_f **  m_out,
float  x,
float  y,
float  z 
)

Creates a single precision matrix for scaling points.

The resulting matrix will have dimensions 3x3.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
xX-coord of the vector to scale by.
yY-coord of the vector to scale by.
zZ-coord of the vector to scale by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4486 of file matrix_math.c.

Error* create_3d_scaling_matrix_2_d ( Matrix_d **  m_out,
double  x,
double  y,
double  z 
)

Creates a double precision matrix for scaling points.

The resulting matrix will have dimensions 3x3.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
xX-coord of the vector to scale by.
yY-coord of the vector to scale by.
zZ-coord of the vector to scale by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4515 of file matrix_math.c.

Error* create_3d_homo_scaling_matrix_1_f ( Matrix_f **  m_out,
const Vector_f v 
)

Creates a single precision homogeneous matrix for scaling points.

The homogeneous vector v must have at least 3 dimensions. The homogeneous coordinate, if it has one, is ignored and assumed to be 1. The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
vVector to scale by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4557 of file matrix_math.c.

Error* create_3d_homo_scaling_matrix_1_d ( Matrix_d **  m_out,
const Vector_d v 
)

Creates a double precision homogeneous matrix for scaling points.

The homogeneous vector v must have at least 3 dimensions. The homogeneous coordinate, if it has one, is ignored and assumed to be 1. The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
vVector to rotate around.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4588 of file matrix_math.c.

Error* create_3d_homo_scaling_matrix_2_f ( Matrix_f **  m_out,
float  x,
float  y,
float  z 
)

Creates a single precision homogeneous matrix for scaling points.

The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
xX-coord of the vector to scale by.
yY-coord of the vector to scale by.
zZ-coord of the vector to scale by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4617 of file matrix_math.c.

Error* create_3d_homo_scaling_matrix_2_d ( Matrix_d **  m_out,
double  x,
double  y,
double  z 
)

Creates a double precision homogeneous matrix for scaling points.

The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
xX-coord of the vector to scale by.
yY-coord of the vector to scale by.
zZ-coord of the vector to scale by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4646 of file matrix_math.c.

Error* create_3d_homo_translation_matrix_1_f ( Matrix_f **  m_out,
const Vector_f v 
)

Creates a single precision homogeneous matrix for translating points in R^3.

The homogeneous vector v must have at least 3 dimensions. The homogeneous coordinate, if it has one, is ignored and assumed to be 1. The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
vVector to translate by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.
  • ERROR_INV_ARG Vector v does not have at least 3 dimensions or large enough magnitude.

Definition at line 4688 of file matrix_math.c.

Error* create_3d_homo_translation_matrix_1_d ( Matrix_d **  m_out,
const Vector_d v 
)

Creates a double precision homogeneous matrix for translating points in R^3.

The homogeneous vector v must have at least 3 dimensions. The homogeneous coordinate, if it has one, is ignored and assumed to be 1. The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
vVector to translate by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.
  • ERROR_INV_ARG Vector v does not have at least 3 dimensions or large enough magnitude.

Definition at line 4719 of file matrix_math.c.

Error* create_3d_homo_translation_matrix_2_f ( Matrix_f **  m_out,
float  x,
float  y,
float  z 
)

Creates a single precision homogeneous matrix for translating points in R^3.

The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
xX-coord of the vector to translate by.
yY-coord of the vector to translate by.
zZ-coord of the vector to translate by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4748 of file matrix_math.c.

Error* create_3d_homo_translation_matrix_2_d ( Matrix_d **  m_out,
double  x,
double  y,
double  z 
)

Creates a double precision homogeneous matrix for translating points in R^3.

The resulting matrix will be in homogeneous coordinates with dimensions 4x4.

Parameters:
m_outResult parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used.
xX-coord of the vector to translate by.
yY-coord of the vector to translate by.
zZ-coord of the vector to translate by.
Returns:
On success, NULL is returned. On error, an Error is returned and *m_out is freed and set to NULL.

Definition at line 4777 of file matrix_math.c.