Mir 1.0
Mir application programming interface
Singular Value Decomposition

Data Structures

struct  mirml_nr_svd_t_
 Structure for Singular Value Decomposition (SVD) of matrices: A=U*W*V^T. More...
 

Typedefs

typedef struct mirml_nr_svd_t_ mirml_nr_svd_t
 Structure for Singular Value Decomposition (SVD) of matrices: A=U*W*V^T.
 

Functions

mirkl_error_tmirml_nr_svd_init (mirml_nr_svd_t **svd)
 Allocation and initialization of SVD structure.
 
mirkl_error_tmirml_nr_svd_decompose (mirml_matrix_t *a, mirkl_size_t i0, mirkl_size_t j0, mirkl_size_t cm, mirkl_size_t cn, mirml_nr_svd_t *svd)
 SVD decomposition. More...
 
mirkl_error_tmirml_nr_svd_reorder (mirml_nr_svd_t *svd)
 Sorting of singular values and matrices U and V after succesful mirml_nr_svd_decompose.
 
void mirml_nr_svd_free (mirml_nr_svd_t *svd)
 Deallocates SVD structure and its content. More...
 
mirkl_error_tmirml_nr_svd_invert (mirml_nr_svd_t *svd, mirml_matrix_t **out_m)
 Calculation of inverted matrix with help of SVD decomposition. More...
 
mirkl_error_tmirml_nr_svd_vsolve (mirml_nr_svd_t *svd, mirml_vector_t *b, mirml_vector_t **x)
 Solves A*x=b for a vector x using the pseudoinverse of A as obtained by SVD. More...
 
mirkl_error_tmirml_nr_svd_msolve (mirml_nr_svd_t *svd, mirml_matrix_t *b, mirml_matrix_t **x)
 Solves m sets of n equations A*X=B using the pseudoinverse of A. More...
 
mirkl_error_tmirml_nr_svd_range (mirml_nr_svd_t *svd, mirml_matrix_t **rnge)
 Give an orthonormal basis for the range of SVD'ed matrix as the columns of a returned matrix. More...
 
mirkl_error_tmirml_nr_svd_nullspace (mirml_nr_svd_t *svd, mirml_matrix_t **nullsp)
 Give an orthonormal basis for the nullspace of SVD'ed matrix as the columns of a returned matrix. More...
 

Detailed Description

Function Documentation

◆ mirml_nr_svd_decompose()

mirkl_error_t * mirml_nr_svd_decompose ( mirml_matrix_t a,
mirkl_size_t  i0,
mirkl_size_t  j0,
mirkl_size_t  cm,
mirkl_size_t  cn,
mirml_nr_svd_t svd 
)

SVD decomposition.

Parameters
[in]aMatrix to be decomposed.
[in]i0Starting row index, from which the input matrix should be processed.
[in]j0Starting column index, from which the input matrix should be processed.
[in]cmCustom number of rows in input matrix to be processed. All rows of input matrix starting from index i0 will be processed if cm is 0.
[in]cnCustom number of columns in input matrix to be processed. All columns of input matrix starting from index j0 will be processed if cn is 0.
[in,out]svdPreallocated and initialized structure with results of SVD decomposition on output.
Note
The allocated structure must be freed with the mirml_nr_svd_free.
i0, j0, cm, cn are all zero in simplest case when the whole input matrix should be decomposed.

◆ mirml_nr_svd_free()

void mirml_nr_svd_free ( mirml_nr_svd_t svd)

Deallocates SVD structure and its content.

Note
The pointer svd after the call is not valid anymore.

◆ mirml_nr_svd_invert()

mirkl_error_t * mirml_nr_svd_invert ( mirml_nr_svd_t svd,
mirml_matrix_t **  out_m 
)

Calculation of inverted matrix with help of SVD decomposition.

Parameters
[in]svdStructure of SVD.
[in,out]out_mInverted matrix on output. Can be preallocated, otherwise it is allocated inside the function.
Note
This function must be called after the mirml_nr_svd_decompose function.
Warning
It is user's responsibility to free the output matrix.

◆ mirml_nr_svd_msolve()

mirkl_error_t * mirml_nr_svd_msolve ( mirml_nr_svd_t svd,
mirml_matrix_t b,
mirml_matrix_t **  x 
)

Solves m sets of n equations A*X=B using the pseudoinverse of A.

Parameters
[in]svdStructure of SVD.
[in]bright-hand sides as b[0..n-1][0..m-1].
[in,out]xReturned solutions as x[0..n-1][0..m-1]. This matrix can be preallocated, otherwise it is allocated inside the function.
Note
This function must be called after the mirml_nr_svd_decompose function.
Warning
It is user's responsibility to free the output matrix.

◆ mirml_nr_svd_nullspace()

mirkl_error_t * mirml_nr_svd_nullspace ( mirml_nr_svd_t svd,
mirml_matrix_t **  nullsp 
)

Give an orthonormal basis for the nullspace of SVD'ed matrix as the columns of a returned matrix.

Parameters
[in]svdStructure of SVD.
[in,out]nullspReturned range matrix. It can be preallocated, otherwise it is allocated inside the function.
Note
This function must be called after the mirml_nr_svd_decompose function.
Warning
It is user's responsibility to free the output matrix.

◆ mirml_nr_svd_range()

mirkl_error_t * mirml_nr_svd_range ( mirml_nr_svd_t svd,
mirml_matrix_t **  rnge 
)

Give an orthonormal basis for the range of SVD'ed matrix as the columns of a returned matrix.

Parameters
[in]svdStructure of SVD.
[in,out]rngeReturned range matrix. It can be preallocated, otherwise it is allocated inside the function.
Note
This function must be called after the mirml_nr_svd_decompose function.
Warning
It is user's responsibility to free the output matrix.

◆ mirml_nr_svd_vsolve()

mirkl_error_t * mirml_nr_svd_vsolve ( mirml_nr_svd_t svd,
mirml_vector_t b,
mirml_vector_t **  x 
)

Solves A*x=b for a vector x using the pseudoinverse of A as obtained by SVD.

Parameters
[in]svdStructure of SVD.
[in]bRight-hand-side vector.
[in,out]xLeft-hand-side vector of unknowns to be determined. Can be preallocated, otherwise it is allocated inside the function.
Note
This function must be called after the mirml_nr_svd_decompose function.
Warning
It is user's responsibility to free the output vector.