include/lwpr_math.h File Reference

Prototypes for some rather simple vector and matrix operations. More...

Go to the source code of this file.

Functions

double lwpr_math_norm2 (const double *x, int n)
 Computes the square norm of a vector of doubles.
double lwpr_math_dot_product (const double *a, const double *b, int n)
 Computes the dot product between two vectors of doubles.
void lwpr_math_scalar_vector (double *y, double a, const double *x, int n)
 Multiplies a vector by a scalar and stores the result in another vector.
void lwpr_math_add_scalar_vector (double *y, double a, const double *x, int n)
 Multiplies a vector by a scalar and adds the result to another vector.
void lwpr_math_scale_add_scalar_vector (double b, double *y, double a, const double *x, int n)
 Multiplies a vector by a scalar and adds the result to another vector, which is scaled before the addition.
int lwpr_math_cholesky (int N, int Ns, double *R, const double *A)
 Computes the Cholesky decomposition of a matrix.

Detailed Description

Prototypes for some rather simple vector and matrix operations.


Function Documentation

void lwpr_math_add_scalar_vector ( double *  y,
double  a,
const double *  x,
int  n 
)

Multiplies a vector by a scalar and adds the result to another vector.

Parameters:
[in,out] y Output vector, must point to an array of n doubles
[in] a Scalar multiplier
[in] x Input vector, must point to an array of n doubles
[in] n Length of the vectors

Computes

\[\mathbf{y} \leftarrow \mathbf{y} + a\mathbf{x}\quad\Leftrightarrow\quad y_i \leftarrow y_i + a x_i \quad i=1\dots n\]

Referenced by LWPR_ReceptiveFieldObject::slope().

int lwpr_math_cholesky ( int  N,
int  Ns,
double *  R,
const double *  A 
)

Computes the Cholesky decomposition of a matrix.

Parameters:
[in] N Number of columns and rows of the matrix
[in] Ns Stride parameter, i.e. offset between the first element of adjacent columns
[in,out] R Upper triangular Cholesky factor. Also serves as input matrix if A==NULL
[in] A Matrix to decompose. May be NULL, in which case the decomposition of R is done in place.
Returns:
  • 1 in case of succes
  • 0 in case of failure (e.g. input matrix is not positive definite)

Given a positive definite matrix A, this function computes an upper triangular matrix R such that

\[\mathbf{R}^T\mathbf{R} = \mathbf{A}.\]

Since the decomposition is done in place, you can also call

   lwpr_math_cholesky(n,n,R,NULL);

if you can afford to overwrite the original contents of the matrix.

double lwpr_math_dot_product ( const double *  a,
const double *  b,
int  n 
)

Computes the dot product between two vectors of doubles.

Parameters:
[in] a First input vector, must point to an array of n doubles
[in] b Second input vector, must point to an array of n doubles
[in] n Length of the vectors
Returns:
The dot product

\[\mathbf{a}\cdot\mathbf{b} = \sum_{i=1}^n a_i b_i\]

Referenced by LWPR_ReceptiveFieldObject::slope().

double lwpr_math_norm2 ( const double *  x,
int  n 
)

Computes the square norm of a vector of doubles.

Parameters:
[in] x Input vector, must point to an array of n doubles
[in] n Length of the vector
Returns:
The square norm

\[\|\mathbf{x}\|^2 = \sum_{i=1}^n x_i^2\]

void lwpr_math_scalar_vector ( double *  y,
double  a,
const double *  x,
int  n 
)

Multiplies a vector by a scalar and stores the result in another vector.

Parameters:
[out] y Output vector, must point to an array of n doubles
[in] a Scalar multiplier
[in] x Input vector, must point to an array of n doubles
[in] n Length of the vectors

Computes

\[\mathbf{y} \leftarrow a\mathbf{x}\quad\Leftrightarrow\quad y_i \leftarrow a x_i \quad i=1\dots n\]

Referenced by LWPR_ReceptiveFieldObject::slope().

void lwpr_math_scale_add_scalar_vector ( double  b,
double *  y,
double  a,
const double *  x,
int  n 
)

Multiplies a vector by a scalar and adds the result to another vector, which is scaled before the addition.

Parameters:
[in] b Scalar multiplier for y before the addition
[in,out] y Output vector, must point to an array of n doubles
[in] a Scalar multiplier for x
[in] x Input vector, must point to an array of n doubles
[in] n Length of the vectors

Computes

\[\mathbf{y} \leftarrow b\mathbf{y} + a\mathbf{x}\quad\Leftrightarrow\quad y_i \leftarrow b y_i + a x_i \quad i=1\dots n\]

Generated on Thu Feb 9 08:18:35 2012 for LWPR Library by  doxygen 1.6.3