Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

nnls.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "include/nnls.h"

Functions

void _nnls_g1 (double a, double b, double *cterm, double *sterm, double *sig)
int _nnls_h12 (int mode, int lpivot, int l1, int m, double *u, int iue, double *up, double *cm, int ice, int icv, int ncv)
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)

Function Documentation

void _nnls_g1 double  a,
double  b,
double *  cterm,
double *  sterm,
double *  sig
 

Compute orthogonal rotation matrix: (C, S) so that (C, S)(A) = (sqrt(A**2+B**2)) (-S,C) (-S,C)(B) ( 0 ) Compute sig = sqrt(A**2+B**2): sig is computed last to allow for the possibility that sig may be in the same location as A or B.

int _nnls_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.

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
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: 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.
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[]

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.

Returns:
Function returns 0 if succesful, 1, if iteration count exceeded 3*N, or 2 in case of invalid problem dimensions or memory allocation error.
Parameters:
a  On entry, a[n][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
wp  An n-array of working space, w[]. On exit, w[] will contain the dual solution vector. w[i]=0.0 for all i in set p and w[i]<=0.0 for all i in set z.
zzp  An m-array of working space, zz[].
indexp  An n-array of working space, index[].

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.

Returns:
Algorithm returns zero if successful, 1 if arguments are inappropriate.


Generated on Fri Jan 21 16:17:42 2005 for libPET by  doxygen 1.4.1