|
TPCCLIB
|
NNLS (non-negative least squares) and required subroutines. More...
#include "libtpcmodel.h"Go to the source code of this file.
Functions | |
| int | nnls (double **a, int m, int n, double *b, double *x, double *rnorm, double *wp, double *zzp, int *indexp) |
| int | nnlsWght (int N, int M, double **A, double *b, double *weight) |
| int | nnlsWghtSquared (int N, int M, double **A, double *b, double *sweight) |
NNLS (non-negative least squares) and required subroutines.
This routine is based on the text and Fortran code in C.L. Lawson and R.J. Hanson, Solving Least Squares Problems, Prentice-Hall, Englewood Cliffs, New Jersey, 1974.
Definition in file nnls.c.
| int nnls | ( | double ** | a, |
| int | m, | ||
| int | n, | ||
| double * | b, | ||
| double * | x, | ||
| double * | rnorm, | ||
| double * | wp, | ||
| double * | zzp, | ||
| int * | indexp ) |
Algorithm NNLS (Non-negative least-squares).
Given an m by n matrix A, and an m-vector B, computes an n-vector X, that solves the least squares problem A * X = B , subject to X>=0
Instead of pointers for working space, NULL can be given to let this function to allocate and free the required memory.
| a | On entry, a[ 0... N ][ 0 ... M ] contains the M by N matrix A. On exit, a[][] contains the product matrix Q*A, where Q is an m by n orthogonal matrix generated implicitly by this function. |
| m | Matrix dimension m |
| n | Matrix dimension n |
| b | On entry, b[] must contain the m-vector B. On exit, b[] contains Q*B |
| x | On exit, x[] will contain the solution vector |
| rnorm | On exit, rnorm contains the squared Euclidean norm of the residual vector, R^2 (Sum-of-Squares). If NULL is given, no rnorm is calculated |
| wp | An n-array of working space, wp[]. On exit, wp[] will contain the dual solution vector. wp[i]=0.0 for all i in set p and wp[i]<=0.0 for all i in set z. Can be NULL, which causes this algorithm to allocate memory for it. |
| zzp | An m-array of working space, zz[]. Can be NULL, which causes this algorithm to allocate memory for it. |
| indexp | An n-array of working space, index[]. Can be NULL, which causes this algorithm to allocate memory for it. |
Definition at line 37 of file nnls.c.
Referenced by fitExpDecayNNLS(), and img_k1_using_ki().
| int nnlsWght | ( | int | N, |
| int | M, | ||
| double ** | A, | ||
| double * | b, | ||
| double * | weight ) |
Algorithm for weighting the problem that is given to nnls-algorithm.
Square roots of weights are used because in nnls the difference w*A-w*b is squared.
| N | NNLS dimension N (nr of parameters). |
| M | NNLS dimension M (nr of samples). |
| A | NNLS matrix A. |
| b | NNLS vector B. |
| weight | Weights for each sample (array of length M). |
Definition at line 257 of file nnls.c.
| int nnlsWghtSquared | ( | int | N, |
| int | M, | ||
| double ** | A, | ||
| double * | b, | ||
| double * | sweight ) |
Algorithm for weighting the problem that is given to nnls-algorithm.
Square roots of weights are used because in nnls the difference w*A-w*b is squared. Here user must give squared weights; this makes calculation faster, when this function needs to be called many times.
| N | NNLS dimension N (nr of parameters). |
| M | NNLS dimension M (nr of samples). |
| A | NNLS matrix A. |
| b | NNLS vector B. |
| sweight | Squared weights for each sample (array of length M). |
Definition at line 306 of file nnls.c.