#include <stdio.h>#include <stdlib.h>#include <assert.h>#include <math.h>#include "include/lss_lib.h"Go to the source code of this file.
Functions | |
| void | _lss_print_matrix (const double *M, int m, int n) |
| void | _lss_print_matrix2 (const double *M, int m, int n, int ice, int icv) |
| double | _lss_compare_matrix (const double *A, const double *B, int m, int n) |
| void | _lss_matrix_times_vector (const double *M, int m, int n, int m_t, int n_t, const double *v, int ie, double *x) |
| int | _lss_h12 (int mode, int lpivot, int l1, int m, double *u, int u_dim1, double *up, double *cm, int ice, int icv, int ncv) |
| void | _lss_g1 (double a, double b, double *cterm, double *sterm, double *sig) |
| int | _lss_hfti (double *A, int m_a, int m, int n_a, int n, double *B, int m_b, int n_b, double tau, int *krank, double *rnorm, double *w1, double *w2, int *ip) |
| double _lss_compare_matrix | ( | const double * | A, |
| const double * | B, | ||
| int | m, | ||
| int | n | ||
| ) |
Compares two m * n sized matrix and calculates
sum{i = 0...m}{ sum{j = 0...n } { (a_i,j - b_i,j)^2 } }
| A | Input matrix A size: mxn |
| B | Input matrix B size: mxn |
| m | matrix height |
| n | matrix width |
Definition at line 124 of file lss_lib.c.
Referenced by do_ldp(), do_lse(), do_lsi(), do_lss_hfti(), and do_nnls().
| void _lss_g1 | ( | double | a, |
| double | b, | ||
| double * | cterm, | ||
| double * | sterm, | ||
| double * | sig | ||
| ) |
| int _lss_h12 | ( | int | mode, |
| int | lpivot, | ||
| int | l1, | ||
| int | m, | ||
| double * | u, | ||
| int | u_dim1, | ||
| double * | up, | ||
| double * | cm, | ||
| int | ice, | ||
| int | icv, | ||
| int | ncv | ||
| ) |
Construction and/or application of a single Householder transformation: Q = I + U*(U**T)/B
Function returns 0 if succesful, or >0 in case of erroneous parameters.
| mode | mode=1 to construct and apply a Householder transformation, or mode=2 to apply a previously constructed transformation |
| lpivot | Index of the pivot element, on pivot vector |
| l1 | Transformation is constructed to zero elements indexed from l1 to M |
| m | Transformation is constructed to zero elements indexed from l1 to M |
| u | With mode=1: On entry, u[] must contain the pivot vector. On exit, u[] and up contain quantities defining the vector u[] of the Householder transformation. With mode=2: On entry, u[] and up should contain quantities previously computed with mode=1. These will not be modified. |
| u_dim1 | u_dim1 is the storage increment between elements. |
| up | with mode=1, here is stored an element defining housholder vector scalar, on mode=2 it's only used, and is not modified |
| cm | On entry, cm[] must contain the matrix (set of vectors) to which the Householder transformation is to be applied. On exit, cm[] will contain the set of transformed vectors |
| ice | Storage increment between elements of vectors in cm[] |
| icv | Storage increment between vectors in cm[] |
| ncv | Nr of vectors in cm[] to be transformed; if ncv<=0, then no operations will be done on cm[] |
Definition at line 191 of file lss_lib.c.
References ABS, LSS_TEST, and MAX.
Referenced by _lss_hfti(), do_lss_h12(), lse(), lsi(), and nnls().
| int _lss_hfti | ( | double * | A, |
| int | m_a, | ||
| int | m, | ||
| int | n_a, | ||
| int | n, | ||
| double * | B, | ||
| int | m_b, | ||
| int | n_b, | ||
| double | tau, | ||
| int * | krank, | ||
| double * | rnorm, | ||
| double * | w1, | ||
| double * | w2, | ||
| int * | ip | ||
| ) |
Solve least squares problem by housholder transformations
Solves Ax = b, but B can be matrix when it's columns are considered as distinct solutions
On successfull exit matrix B will contain the corresponding solution vectors
| A | A is a m_a * n_a matrix, defining the A'x = b, where A' is first m columns of A |
| m_a | matrix A dimension (true size) |
| m | matrix A dimension, dimension that will be user to solve the eq |
| n_a | matrix A dimension (true size) |
| n | matrix A dimension, dimension that will be used to solve the eq |
| B | B is a m_b * n_b size matrix defining the right hand side vectors b_i |
| m_b | matrix B dimension |
| n_b | matrix B dimension |
| tau | smallest number that is considered to be non-zero |
| krank | will contain pseudorank of the matrix on succesfull calculation |
| rnorm | vector of size n_b * 1, will containt residual norm of the solutin after successfull calculation, can be NULL |
| w1 | working space 1, n_a * 1 sized vector (array), if NULL then it will be allocated (and deleted) by the routine |
| w2 | working space 2, n_a * 1 sized vector (array), if NULL then it will be allocated (and deleted) by the routine |
| ip | n_a * 1 vector where routine records indices describing the permutation of column vectors, can be NULL |
Definition at line 422 of file lss_lib.c.
References _lss_h12(), _lss_print_matrix(), _lss_print_matrix2(), ABS, LSS_TEST, and MIN.
Referenced by do_lss_hfti(), and lse().
| void _lss_matrix_times_vector | ( | const double * | M, |
| int | m, | ||
| int | n, | ||
| int | m_t, | ||
| int | n_t, | ||
| const double * | v, | ||
| int | ie, | ||
| double * | x | ||
| ) |
Calculates x = M*v, where M is m * n matrix
actually matrix M is size m_t * n_t, but only first m * n values are used.
| M | The input matrix, true size m_t * n_t |
| m | Dimension used in multiply |
| n | Dimension used in multiply |
| m_t | The matrix true dimension |
| n_t | The matrix true dimension |
| v | Vector that is multiplied with |
| ie | Increment between element of vector |
| x | resulting vector |
Definition at line 154 of file lss_lib.c.
Referenced by lsi().
| void _lss_print_matrix | ( | const double * | M, |
| int | m, | ||
| int | n | ||
| ) |
Prints matrix M of m * n sized matrix to stdout
| M | matrix to print |
| m | M dimension is m x n |
| n | M dimension is m x n |
Definition at line 68 of file lss_lib.c.
Referenced by _lss_hfti(), do_ldp(), do_lse(), do_lsi(), do_lss_h12(), do_lss_hfti(), do_nnls(), ldp(), lse(), lsi(), and nnls().
| void _lss_print_matrix2 | ( | const double * | M, |
| int | m, | ||
| int | n, | ||
| int | ice, | ||
| int | icv | ||
| ) |
Prints matrix M of m * n sized matrix to stdout, with increment between element being ice and increament between vector icv
| M | matrix to print |
| m | M dimension is m x n |
| n | M dimension is m x n |
| ice | Increment between elements on matrix |
| icv | Increment between vectors on matrix |
Definition at line 94 of file lss_lib.c.
Referenced by _lss_hfti().
1.8.0