TPCCLIB
|
BVLS (Bounded-value least-squares). More...
#include "libtpcmodel.h"
Go to the source code of this file.
Functions | |
int | bvls (int key, const int m, const int n, double *a, double *b, double *bl, double *bu, double *x, double *w, double *act, double *zz, int *istate, int *iter, int verbose) |
Bounded-value least-squares method to solve the linear problem A x ~ b , subject to limit1 <= x <= limit2. | |
int | llsqWght (int N, int M, double **A, double *a, double *b, double *weight) |
int | llsqWghtSquared (int N, int M, double **A, double *a, double *b, double *sweight) |
BVLS (Bounded-value least-squares).
Function bvls() is dependent on function qrLH() in qrlsq.c.
Definition in file bvls.c.
int bvls | ( | int | key, |
const int | m, | ||
const int | n, | ||
double * | a, | ||
double * | b, | ||
double * | bl, | ||
double * | bu, | ||
double * | x, | ||
double * | w, | ||
double * | act, | ||
double * | zz, | ||
int * | istate, | ||
int * | iter, | ||
int | verbose ) |
Bounded-value least-squares method to solve the linear problem A x ~ b , subject to limit1 <= x <= limit2.
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, and Fortran codes by R.L. Parker and P.B. Stark, and by J. Burkardt.
key | Enter 0 to solve the problem from scratch, or <>0 to initialize the routine using caller's guess about which parameters are active within their bounds, which are at their lower bounds, and which at their upper bounds, as supplied in the array istate ('warm start'). When key <> 0, the routine initially sets the active components to the averages of their upper and lower bounds. |
m | Number of samples in matrix A and the length of vector b. |
n | Number of parameters in matrix A and the length of vector x. The n must not be > m unless at least n-m variables are non-active (set to their bounds).. |
a | Pointer to matrix A; matrix must be given as an n*m array, containing n consecutive m-length vectors. Contents of A are modified in this routine. |
b | Pointer to vector b of length m. Contents of b are modified in this routine. |
bl | Array BL[0..n-1] of lower bounds for parameters. |
bu | Array BU[0..n-1] of upper bounds for parameters. |
x | Pointer to the result vector x of length n. |
w | Pointer to an array of length n, which will be used as working memory, and the minimum 2-norm || a.x-b ||, (R^2), will be written in w[0]. |
act | Pointer to an array of length m*(n+2), or m*(m+2) if m<n, which will be used as working memory. |
zz | Pointer to an array of length m, to be used as working memory. |
istate | Pointer to an integer array of length n+1. If parameter key <>0, then the last position istate[n] must contain the total number of components at their bounds (nbound, the ‘bound variables’). The absolute values of the first nbound entries of istate[] are the indices of these ‘bound’ components of x[]. The sign of istate[0.. nbound-1] entries indicates whether x[|istate[i]|] is at its upper (positive) or lower (negative) bound. Entries istate[nbound..n-1] contain the indices of the active components. |
iter | Number of performed iterations is returned in this variable. Maximum nr of iterations is set with this variable, or set it to 0 to use the default maximum, 3*n. |
verbose | Verbose level; if zero, then nothing is printed to stderr or stdout |
Definition at line 24 of file bvls.c.
int llsqWght | ( | int | N, |
int | M, | ||
double ** | A, | ||
double * | a, | ||
double * | b, | ||
double * | weight ) |
Algorithm for weighting the problem that is given to a LLSQ algorithm.
Square roots of weights are used because in LLSQ algorithms the difference w*A-w*b is squared.
N | Matrix A dimension N (nr of parameters). |
M | Matrix A dimension M (nr of samples). |
A | Pointer to matrix A[N][M]; enter NULL to use following matrix format instead. |
a | Pointer to matrix A[N*M]; enter NULL to use previous matrix format instead. |
b | Vector B of length M. |
weight | Weights for each sample (array of length M). |
Definition at line 419 of file bvls.c.
int llsqWghtSquared | ( | int | N, |
int | M, | ||
double ** | A, | ||
double * | a, | ||
double * | b, | ||
double * | sweight ) |
Algorithm for weighting the problem that is given to a LLSQ algorithm.
Square roots of weights are used because in LLSQ algorithms 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 | Matrix A dimension N (nr of parameters). |
M | Matrix A dimension M (nr of samples). |
A | Pointer to matrix A[N][M]; enter NULL to use following matrix format instead. |
a | Pointer to matrix A[N*M]; enter NULL to use previous matrix format instead. |
b | Vector B of length M. |
sweight | Squared weights for each sample (array of length M). |
Definition at line 474 of file bvls.c.