iCub-main
Loading...
Searching...
No Matches
Functions
iCub::learningmachine::math Namespace Reference

Functions

void dchud (double *r, int ldr, int p, double *x, double *z, int ldz, int nz, double *y, double *rho, double *c, double *s, unsigned char rtrans=0, unsigned char ztrans=0)
 Mathematical helper functions for use in the learningMachine library.
 
void gsl_linalg_cholesky_update (gsl_matrix *R, gsl_vector *x, gsl_vector *c, gsl_vector *s, gsl_matrix *Z=NULL, gsl_vector *y=NULL, gsl_vector *rho=NULL, unsigned char rtrans=0, unsigned char ztrans=0)
 
void cholupdate (yarp::sig::Matrix &R, const yarp::sig::Vector &x, yarp::sig::Vector &c, yarp::sig::Vector &s, yarp::sig::Matrix &Z, const yarp::sig::Vector &y, yarp::sig::Vector &rho, bool rtrans=0, bool ztrans=0)
 Perform a rank-1 update to a Cholesky factor, while updating additional vectors using the used Given's rotations and updating the norm of residuals.
 
void cholupdate (yarp::sig::Matrix &R, const yarp::sig::Vector &x, bool rtrans=0)
 Perform a rank-1 update to a Cholesky factor.
 
void cholsolve (const yarp::sig::Matrix &R, const yarp::sig::Matrix &B, yarp::sig::Matrix &X)
 Solves a system A*x=b for multiple row vectors in B using a precomputed Cholesky factor R.
 
yarp::sig::Matrix cholsolve (const yarp::sig::Matrix &R, const yarp::sig::Matrix &B)
 Solves a system A*x=b for multiple row vectors in B using a precomputed Cholesky factor R.
 
void cholsolve (const yarp::sig::Matrix &R, const yarp::sig::Vector &b, yarp::sig::Vector &x)
 Solves a system A*x=b for using a precomputed Cholesky factor R.
 
yarp::sig::Vector cholsolve (const yarp::sig::Matrix &R, const yarp::sig::Vector &b)
 Solves a system A*x=b for using a precomputed Cholesky factor R.
 
yarp::sig::Matrix outerprod (const yarp::sig::Vector &v1, const yarp::sig::Vector &v2)
 Computes the outer product of two vectors.
 
yarp::sig::Vector & addvec (yarp::sig::Vector &v, double val)
 Adds a scalar to a vector inplace.
 
void trsolve (const yarp::sig::Matrix &A, const yarp::sig::Vector &b, yarp::sig::Vector &x, bool transa=false)
 Solves a triangular linear system Ax=b where A is triangular.
 
yarp::sig::Vector trsolve (const yarp::sig::Matrix &A, const yarp::sig::Vector &b, bool transa=false)
 Solves a linear system Ax=b where A is triangular.
 
void fillrandom (yarp::sig::Vector &v, yarp::math::RandScalar &prng)
 Fills an entire vector using the provided pseudo random number generator.
 
void fillrandom (yarp::sig::Matrix &M, yarp::math::RandScalar &prng)
 Fills an entire matrix using the provided pseudo random number generator.
 
void fillrandom (yarp::sig::Vector &v, yarp::math::RandnScalar &prng)
 Fills an entire vector using the provided pseudo random number generator.
 
void fillrandom (yarp::sig::Matrix &M, yarp::math::RandnScalar &prng)
 Fills an entire matrix using the provided pseudo random number generator.
 
yarp::sig::Vector random (int length, yarp::math::RandScalar &prng)
 Returns a random vector with given dimensionality.
 
yarp::sig::Matrix random (int rows, int columns, yarp::math::RandScalar &prng)
 Returns a random matrix with given dimensionality.
 
yarp::sig::Vector random (int length, yarp::math::RandnScalar &prng)
 Returns a random vector with given dimensionality.
 
yarp::sig::Matrix random (int rows, int columns, yarp::math::RandnScalar &prng)
 Returns a random matrix with given dimensionality.
 
yarp::sig::Vector & map (yarp::sig::Vector &v, double(op)(double))
 Performs a unary operator inplace on each element of a vector.
 
yarp::sig::Matrix & map (yarp::sig::Matrix &M, double(op)(double))
 Performs a unary operator inplace on each element of a matrix.
 
yarp::sig::Vector map (const yarp::sig::Vector &v, double(op)(double))
 Performs a unary operator on each element of a vector.
 
yarp::sig::Matrix map (const yarp::sig::Matrix &M, double(op)(double))
 Performs a unary operator on each element of a matrix.
 
yarp::sig::Matrix & cosmat (yarp::sig::Matrix &M)
 Computes the cosine of a matrix element-wise inplace.
 
yarp::sig::Matrix & sinmat (yarp::sig::Matrix &M)
 Computes the sine of a matrix element-wise inplace.
 
yarp::sig::Vector & cosvec (yarp::sig::Vector &v)
 Computes the cosine of a vector element-wise inplace.
 
yarp::sig::Vector & sinvec (yarp::sig::Vector &v)
 Computes the sine of a vector element-wise inplace.
 
yarp::sig::Matrix cosmat (const yarp::sig::Matrix &M)
 Computes the cosine of a matrix element-wise.
 
yarp::sig::Matrix sinmat (const yarp::sig::Matrix &M)
 Computes the sine of a matrix element-wise.
 
yarp::sig::Vector cosvec (const yarp::sig::Vector &v)
 Computes the cosine of a vector element-wise.
 
yarp::sig::Vector sinvec (const yarp::sig::Vector &v)
 Computes the sine of a vector element-wise.
 

Function Documentation

◆ addvec()

yarp::sig::Vector & iCub::learningmachine::math::addvec ( yarp::sig::Vector &  v,
double  val 
)

Adds a scalar to a vector inplace.

Parameters
vthe vector
valthe scalar
Returns
the vector

Definition at line 223 of file Math.cpp.

◆ cholsolve() [1/4]

yarp::sig::Matrix iCub::learningmachine::math::cholsolve ( const yarp::sig::Matrix &  R,
const yarp::sig::Matrix &  B 
)

Solves a system A*x=b for multiple row vectors in B using a precomputed Cholesky factor R.

Parameters
Rthe Cholesky factor
Ba matrix containing any number of column vectors b
Returns
a matrix containing the same number of solutions x on its rows

Definition at line 185 of file Math.cpp.

◆ cholsolve() [2/4]

void iCub::learningmachine::math::cholsolve ( const yarp::sig::Matrix &  R,
const yarp::sig::Matrix &  B,
yarp::sig::Matrix &  X 
)

Solves a system A*x=b for multiple row vectors in B using a precomputed Cholesky factor R.

Parameters
Rthe Cholesky factor
Ba matrix containing any number of row vectors b
Xa matrix containing the same number of solutions x on its rows

Definition at line 167 of file Math.cpp.

◆ cholsolve() [3/4]

yarp::sig::Vector iCub::learningmachine::math::cholsolve ( const yarp::sig::Matrix &  R,
const yarp::sig::Vector &  b 
)

Solves a system A*x=b for using a precomputed Cholesky factor R.

Parameters
Rthe Cholesky factor
bthe vector b
Returns
the solution x

Definition at line 207 of file Math.cpp.

◆ cholsolve() [4/4]

void iCub::learningmachine::math::cholsolve ( const yarp::sig::Matrix &  R,
const yarp::sig::Vector &  b,
yarp::sig::Vector &  x 
)

Solves a system A*x=b for using a precomputed Cholesky factor R.

Parameters
Rthe Cholesky factor
bthe vector b
xthe solution x

Definition at line 191 of file Math.cpp.

◆ cholupdate() [1/2]

void iCub::learningmachine::math::cholupdate ( yarp::sig::Matrix &  R,
const yarp::sig::Vector &  x,
bool  rtrans = 0 
)

Perform a rank-1 update to a Cholesky factor.

For more information, please see chapter 10.2 of the LINPACK User's Guide.

Parameters
Ran upper triangular Cholesky factor
xthe vector used to update the Cholesky factor
rtransflag indicating whether R is provided transposed

Definition at line 152 of file Math.cpp.

◆ cholupdate() [2/2]

void iCub::learningmachine::math::cholupdate ( yarp::sig::Matrix &  R,
const yarp::sig::Vector &  x,
yarp::sig::Vector &  c,
yarp::sig::Vector &  s,
yarp::sig::Matrix &  Z,
const yarp::sig::Vector &  y,
yarp::sig::Vector &  rho,
bool  rtrans = 0,
bool  ztrans = 0 
)

Perform a rank-1 update to a Cholesky factor, while updating additional vectors using the used Given's rotations and updating the norm of residuals.

For more information, please see chapter 10.2 of the LINPACK User's Guide.

Parameters
Ran upper triangular Cholesky factor
xthe vector used to update the Cholesky factor
con output, the cosines of the Given's rotations
son output, the sines of the Given's rotations
Za number of column vectors updated along with R
ya vector containing scalars used to update Z
rhothe norm of the residuals
rtransflag indicating whether R is provided transposed
ztransflag indicating whether Z is provided transposed

Definition at line 136 of file Math.cpp.

◆ cosmat() [1/2]

yarp::sig::Matrix iCub::learningmachine::math::cosmat ( const yarp::sig::Matrix &  M)

Computes the cosine of a matrix element-wise.

Renamed to avoid possible ambiguity with the standard cos function.

Parameters
Ma constant reference to the matrix
Returns
the matrix of cosines

Definition at line 363 of file Math.cpp.

◆ cosmat() [2/2]

yarp::sig::Matrix & iCub::learningmachine::math::cosmat ( yarp::sig::Matrix &  M)

Computes the cosine of a matrix element-wise inplace.

Renamed to avoid possible ambiguity with the standard cos function.

Parameters
Ma reference to the matrix
Returns
the matrix of cosines

Definition at line 347 of file Math.cpp.

◆ cosvec() [1/2]

yarp::sig::Vector iCub::learningmachine::math::cosvec ( const yarp::sig::Vector &  v)

Computes the cosine of a vector element-wise.

Renamed to avoid possible ambiguity with the standard cos function.

Parameters
va constant reference to the vector
Returns
the vector of cosines

Definition at line 355 of file Math.cpp.

◆ cosvec() [2/2]

yarp::sig::Vector & iCub::learningmachine::math::cosvec ( yarp::sig::Vector &  v)

Computes the cosine of a vector element-wise inplace.

Renamed to avoid possible ambiguity with the standard cos function.

Parameters
va reference to the vector
Returns
the vector of cosines

Definition at line 339 of file Math.cpp.

◆ dchud()

void iCub::learningmachine::math::dchud ( double *  r,
int  ldr,
int  p,
double *  x,
double *  z,
int  ldz,
int  nz,
double *  y,
double *  rho,
double *  c,
double *  s,
unsigned char  rtrans = 0,
unsigned char  ztrans = 0 
)

Mathematical helper functions for use in the learningMachine library.

Author
Arjan Gijsberts

Definition at line 33 of file Math.cpp.

◆ fillrandom() [1/4]

void iCub::learningmachine::math::fillrandom ( yarp::sig::Matrix &  M,
yarp::math::RandnScalar &  prng 
)

Fills an entire matrix using the provided pseudo random number generator.

Parameters
Ma reference to the matrix
prnga reference to the pseudo random number generator

Definition at line 272 of file Math.cpp.

◆ fillrandom() [2/4]

void iCub::learningmachine::math::fillrandom ( yarp::sig::Matrix &  M,
yarp::math::RandScalar &  prng 
)

Fills an entire matrix using the provided pseudo random number generator.

Parameters
Ma reference to the matrix
prnga reference to the pseudo random number generator

Definition at line 256 of file Math.cpp.

◆ fillrandom() [3/4]

void iCub::learningmachine::math::fillrandom ( yarp::sig::Vector &  v,
yarp::math::RandnScalar &  prng 
)

Fills an entire vector using the provided pseudo random number generator.

Parameters
va reference to the vector
prnga reference to the pseudo random number generator

Definition at line 265 of file Math.cpp.

◆ fillrandom() [4/4]

void iCub::learningmachine::math::fillrandom ( yarp::sig::Vector &  v,
yarp::math::RandScalar &  prng 
)

Fills an entire vector using the provided pseudo random number generator.

Parameters
va reference to the vector
prnga reference to the pseudo random number generator

Definition at line 249 of file Math.cpp.

◆ gsl_linalg_cholesky_update()

void iCub::learningmachine::math::gsl_linalg_cholesky_update ( gsl_matrix *  R,
gsl_vector *  x,
gsl_vector *  c,
gsl_vector *  s,
gsl_matrix *  Z = NULL,
gsl_vector *  y = NULL,
gsl_vector *  rho = NULL,
unsigned char  rtrans = 0,
unsigned char  ztrans = 0 
)

Definition at line 99 of file Math.cpp.

◆ map() [1/4]

yarp::sig::Matrix iCub::learningmachine::math::map ( const yarp::sig::Matrix &  M,
double(op)(double)   
)

Performs a unary operator on each element of a matrix.

Parameters
Ma constant reference to the matrix
opthe operator
Returns
the matrix

Definition at line 329 of file Math.cpp.

◆ map() [2/4]

yarp::sig::Vector iCub::learningmachine::math::map ( const yarp::sig::Vector &  v,
double(op)(double)   
)

Performs a unary operator on each element of a vector.

Parameters
va constant reference to the vector
opthe operator
Returns
the vector

Definition at line 321 of file Math.cpp.

◆ map() [3/4]

yarp::sig::Matrix & iCub::learningmachine::math::map ( yarp::sig::Matrix &  M,
double(op)(double)   
)

Performs a unary operator inplace on each element of a matrix.

Parameters
Ma reference to the matrix
opthe operator
Returns
a reference to the matrix

Definition at line 312 of file Math.cpp.

◆ map() [4/4]

yarp::sig::Vector & iCub::learningmachine::math::map ( yarp::sig::Vector &  v,
double(op)(double)   
)

Performs a unary operator inplace on each element of a vector.

Parameters
va reference to the vector
opthe operator
Returns
a reference to the vector

Definition at line 305 of file Math.cpp.

◆ outerprod()

yarp::sig::Matrix iCub::learningmachine::math::outerprod ( const yarp::sig::Vector &  v1,
const yarp::sig::Vector &  v2 
)

Computes the outer product of two vectors.

Parameters
v1the first vector
v2the second vector
Returns
the outer product

Definition at line 213 of file Math.cpp.

◆ random() [1/4]

yarp::sig::Vector iCub::learningmachine::math::random ( int  length,
yarp::math::RandnScalar &  prng 
)

Returns a random vector with given dimensionality.

Parameters
lengththe desired dimensionality of the vector
prnga reference to the pseudo random number generator
Returns
the random vector

Definition at line 293 of file Math.cpp.

◆ random() [2/4]

yarp::sig::Vector iCub::learningmachine::math::random ( int  length,
yarp::math::RandScalar &  prng 
)

Returns a random vector with given dimensionality.

Parameters
lengththe desired dimensionality of the vector
prnga reference to the pseudo random number generator
Returns
the random vector

Definition at line 281 of file Math.cpp.

◆ random() [3/4]

yarp::sig::Matrix iCub::learningmachine::math::random ( int  rows,
int  columns,
yarp::math::RandnScalar &  prng 
)

Returns a random matrix with given dimensionality.

Parameters
rowsthe desired number of rows for the matrix
colsthe desired number of columns for the matrix
prnga reference to the pseudo random number generator
Returns
the random matrix

Definition at line 299 of file Math.cpp.

◆ random() [4/4]

yarp::sig::Matrix iCub::learningmachine::math::random ( int  rows,
int  columns,
yarp::math::RandScalar &  prng 
)

Returns a random matrix with given dimensionality.

Parameters
rowsthe desired number of rows for the matrix
colsthe desired number of columns for the matrix
prnga reference to the pseudo random number generator
Returns
the random matrix

Definition at line 287 of file Math.cpp.

◆ sinmat() [1/2]

yarp::sig::Matrix iCub::learningmachine::math::sinmat ( const yarp::sig::Matrix &  M)

Computes the sine of a matrix element-wise.

Renamed to avoid possible ambiguity with the standard sin function.

Parameters
Ma constant reference to the matrix
Returns
the matrix of sines

Definition at line 367 of file Math.cpp.

◆ sinmat() [2/2]

yarp::sig::Matrix & iCub::learningmachine::math::sinmat ( yarp::sig::Matrix &  M)

Computes the sine of a matrix element-wise inplace.

Renamed to avoid possible ambiguity with the standard sin function.

Parameters
Ma reference to the matrix
Returns
the matrix of sines

Definition at line 351 of file Math.cpp.

◆ sinvec() [1/2]

yarp::sig::Vector iCub::learningmachine::math::sinvec ( const yarp::sig::Vector &  v)

Computes the sine of a vector element-wise.

Renamed to avoid possible ambiguity with the standard sin function.

Parameters
va constant reference to the vector
Returns
the vector of sines

Definition at line 359 of file Math.cpp.

◆ sinvec() [2/2]

yarp::sig::Vector & iCub::learningmachine::math::sinvec ( yarp::sig::Vector &  v)

Computes the sine of a vector element-wise inplace.

Renamed to avoid possible ambiguity with the standard sin function.

Parameters
va reference to the vector
Returns
the vector of sines

Definition at line 343 of file Math.cpp.

◆ trsolve() [1/2]

yarp::sig::Vector iCub::learningmachine::math::trsolve ( const yarp::sig::Matrix &  A,
const yarp::sig::Vector &  b,
bool  transa = false 
)

Solves a linear system Ax=b where A is triangular.

Parameters
Athe matrix A
bthe matrix b
transawhether A should be transposed
Returns
x the vector x

Definition at line 243 of file Math.cpp.

◆ trsolve() [2/2]

void iCub::learningmachine::math::trsolve ( const yarp::sig::Matrix &  A,
const yarp::sig::Vector &  b,
yarp::sig::Vector &  x,
bool  transa = false 
)

Solves a triangular linear system Ax=b where A is triangular.

Parameters
Athe matrix A
bthe vector b
xthe vector x
transawhether A should be transposed

Definition at line 230 of file Math.cpp.