#include <stdio.h>#include <stdlib.h>#include <math.h>#include "include/nnls.h"#include "include/lss_lib.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) |
| 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 Euclidean norm of the residual vector. 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 63 of file nnls.c.
References _lss_g1(), _lss_h12(), _lss_print_matrix(), and NNLS_TEST.
Referenced by do_nnls(), and ldp().
| 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 307 of file nnls.c.
References M.
| 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 355 of file nnls.c.
References M.
1.8.0