basic_algebra.c File Reference

Detailed Description

Definition of the basic lineal algebra routines used in the CuikSuite.

These basic routines are implemented using BLAS, if available.

Definition in file basic_algebra.c.

Functions

CBLAS_INLINE double GeneralDotProduct (unsigned int s, double *v1, double *v2)
 Computes the dot product of two general vectors. More...
 
CBLAS_INLINE void ScaleVector (double f, unsigned int s, double *v)
 Scales a vector. More...
 
CBLAS_INLINE void ScaleVector2 (double f, unsigned int s, double *v, double *vout)
 Scales a vector. More...
 
CBLAS_INLINE void AccumulateVector (unsigned int s, double *v1, double *v2)
 Adds a vector to another vectors. More...
 
CBLAS_INLINE void SumVector (unsigned int s, double *v1, double *v2, double *v)
 Adds two vectors. More...
 
CBLAS_INLINE void SumVectorScale (unsigned int s, double *v1, double w, double *v2, double *v)
 Adds two vectors with a scale. More...
 
void CosVector (unsigned int s, double *v, double *co)
 Cosine on a vector. More...
 
void SinVector (unsigned int s, double *v, double *si)
 Sine on a vector. More...
 
unsigned int MaxVectorElement (unsigned int m, double *v)
 Index of the maximum element of a vector. More...
 
double MaxVector (unsigned int m, double *v)
 Value of the maximum element of a vector. More...
 
unsigned int MinVectorElement (unsigned int m, double *v)
 Index of the minimum element of a vector. More...
 
double MinVector (unsigned int m, double *v)
 Value of the minimum element of a vector. More...
 
CBLAS_INLINE void SubtractVector (unsigned int s, double *v1, double *v2)
 Substracts a vector from another vector. More...
 
void DifferenceVector (unsigned int s, double *v1, double *v2, double *v)
 Substracts two vectors. More...
 
void DifferenceVectorTopology (unsigned int s, unsigned int *tp, double *v1, double *v2, double *v)
 Substracts two vectors. More...
 
CBLAS_INLINE double Norm (unsigned int s, double *v)
 Computes the norm of a vector. More...
 
CBLAS_INLINE double NormWithStride (unsigned int s, unsigned int st, double *v)
 Computes the norm of a vector. More...
 
double SquaredDistance (unsigned int s, double *v1, double *v2)
 Computes the squared distance of two points. More...
 
double Distance (unsigned int s, double *v1, double *v2)
 Computes the distance of two points. More...
 
double SquaredDistanceTopology (unsigned int s, unsigned int *tp, double *v1, double *v2)
 Computes the squared distance of two points. More...
 
double SquaredDistanceTopologyMin (double t2, unsigned int s, unsigned int *tp, double *v1, double *v2)
 Computes the squared distance of two points. More...
 
double DistanceTopology (unsigned int s, unsigned int *tp, double *v1, double *v2)
 Computes the distance of two points. More...
 
double DistanceTopologyMin (double t, unsigned int s, unsigned int *tp, double *v1, double *v2)
 Computes the distance of two points, if it is below a given threshold. More...
 
boolean CrossTopologyBorder (unsigned int s, unsigned int *tp, double *v1, double *v2)
 Determines if the line between two points crosses the topology boder. More...
 
CBLAS_INLINE void Normalize (unsigned int s, double *v)
 Normalizes a vector. More...
 
double Mean (unsigned int s, double *v)
 Computes the mean. More...
 
double StdDev (unsigned int s, double m, double *v)
 Computes the standard deviation. More...
 
void ArrayPi2Pi (unsigned int n, unsigned int *t, double *a)
 Applies PI2PI to an array. More...
 
CBLAS_INLINE void GetRow (unsigned int k, unsigned int r, unsigned int c, double *m, double *v)
 Gets a row from a matrix. More...
 
CBLAS_INLINE void GetColumn (unsigned int k, unsigned int r, unsigned int c, double *m, double *v)
 Gets a column from a matrix. More...
 
CBLAS_INLINE void SetRow (double *v, unsigned int k, unsigned int r, unsigned int c, double *m)
 Sets a row of a matrix. More...
 
CBLAS_INLINE void SetColumn (double *v, unsigned int k, unsigned int r, unsigned int c, double *m)
 Sets a column of a matrix. More...
 
CBLAS_INLINE double RowSquaredNorm (unsigned int k, unsigned int r, unsigned int c, double *m)
 Computes the squared norm of a row of a matrix. More...
 
CBLAS_INLINE double ColumnSquaredNorm (unsigned int k, unsigned int r, unsigned int c, double *m)
 Computes the squared norm of a column of a matrix. More...
 
CBLAS_INLINE void MatrixVectorProduct (unsigned int r, unsigned int c, double *A, double *b, double *o)
 Product of a matrix and a vector. More...
 
CBLAS_INLINE void TMatrixVectorProduct (unsigned int r, unsigned int c, double *A, double *b, double *o)
 Product of a transposed matrix and a vector. More...
 
CBLAS_INLINE void TMatrixVectorStrideProduct (unsigned int r, unsigned int c, double *A, unsigned int s, double *b, double *o)
 Product of a transposed matrix and a vector. More...
 
CBLAS_INLINE void MatrixMatrixProduct (unsigned int ra, unsigned int ca, double *A, unsigned int cb, double *B, double *C)
 C = A * B. More...
 
CBLAS_INLINE void TMatrixMatrixProduct (unsigned int ra, unsigned int ca, double *A, unsigned int cb, double *B, double *C)
 C = A^t * B. More...
 
double MinCosinusBetweenSubSpaces (unsigned int m, unsigned int k, double *T1, double *T2)
 Computes the cosinus of the maximum angle between two lineal sub-spaces. More...
 
CBLAS_INLINE void SubMatrixFromMatrix (unsigned int nr1, unsigned int nc1, double *m1, unsigned int nri, unsigned int nci, unsigned int nr, unsigned int nc, double *m)
 Defines a submatrix in a matrix. More...
 
CBLAS_INLINE void SubMatrixFromTMatrix (unsigned int nr1, unsigned int nc1, double *m1, unsigned int nri, unsigned int nci, unsigned int nr, unsigned int nc, double *m)
 Defines a submatrix in a matrix. More...
 
void PrintVector (FILE *f, char *label, unsigned int n, double *v)
 Prints a vector. More...
 
void PrintMatrix (FILE *f, char *label, unsigned int r, unsigned int c, double *m)
 Prints a matrix. More...
 
void PrintTMatrix (FILE *f, char *label, unsigned int r, unsigned int c, double *m)
 Prints a transposed matrix. More...
 

Function Documentation

CBLAS_INLINE double GeneralDotProduct ( unsigned int  s,
double *  v1,
double *  v2 
)

Computes the dot product of two general vectors.

Parameters
sThe dimensionality of the vectors.
v1First vector.
v2Second vector.
Returns
The dot produt.

Definition at line 15 of file basic_algebra.c.

Referenced by AddBorderConstraint(), CutPolytopeWithFace(), DetermineSPolytopeNeighbour(), EnlargeSPolytope(), InsidePolytope(), InsideSPolytope(), PolytopeBoundaryPointFromExternalCornerInt(), and RefineSingularPoint().

CBLAS_INLINE void ScaleVector ( double  f,
unsigned int  s,
double *  v 
)
CBLAS_INLINE void ScaleVector2 ( double  f,
unsigned int  s,
double *  v,
double *  vout 
)

Multiplies all the elements of a vector by a given factor and stores the result in a new vector.

Parameters
fThe factor.
sNumber of elements in the vector.
vThe vector.
voutThe output vector.

Definition at line 42 of file basic_algebra.c.

Referenced by EvaluateTransSeq().

CBLAS_INLINE void AccumulateVector ( unsigned int  s,
double *  v1,
double *  v2 
)

Adds a vector to another vector

Parameters
sNumber of elements in the vector.
v1The vector to add.
v2The vector where to add v1.

Definition at line 55 of file basic_algebra.c.

Referenced by AddBranchToAtlasRRT(), AddBranchToRRT(), ConnectSamplesChart(), EvaluateMEquationXVectors(), EvaluateTransSeq(), InitPatchTrans(), Local2Global(), PolytopeBoundaryPointFromExternalCornerInt(), and PrintTransSeq().

CBLAS_INLINE void SumVector ( unsigned int  s,
double *  v1,
double *  v2,
double *  v 
)

Adds two vectors and stores the result in another vector..

Parameters
sNumber of elements in the vector.
v1The first vector to add.
v2The second vector to add.
vThe vector where to store the result.

Definition at line 67 of file basic_algebra.c.

Referenced by Chart2Manifold(), GetJointTransSeq(), Local2Global(), PrintJoint(), and PrintTransSeq().

CBLAS_INLINE void SumVectorScale ( unsigned int  s,
double *  v1,
double  w,
double *  v2,
double *  v 
)

Adds two vectors /scaling the second vector) and stores the result in another vector.. This is basically used in Gram-Smidth orthogonalization.

Parameters
sNumber of elements in the vector.
v1The first vector to add.
wThe weight to scale the second vector.
v2The second vector to scale and add.
vThe vector where to store the result.

Definition at line 86 of file basic_algebra.c.

Referenced by AddBranchToRRT(), ConnectSamples(), ConnectSamplesChart(), EvaluateTransSeq(), EvaluateVectorsPATrans(), FindPointInOtherBranch(), FindSingularPoint(), GeodesicDistance(), GetJointDOFValues(), GetJointTransform(), InitWorldFromMolecule(), MoveJointFromTransforms(), NewTemptativeSample(), and PointTowardRandSample().

void CosVector ( unsigned int  s,
double *  v,
double *  co 
)

Compputes the cosine for all the elements of a vector.

Parameters
sNumber of elements in the vector.
vThe vector.
coThe vector with the cosines (output, allocated externally).

Definition at line 108 of file basic_algebra.c.

void SinVector ( unsigned int  s,
double *  v,
double *  si 
)

Compputes the sine for all the elements of a vector.

Parameters
sNumber of elements in the vector.
vThe vector.
siThe vector with the sine (output, allocated externally).

Definition at line 116 of file basic_algebra.c.

unsigned int MaxVectorElement ( unsigned int  m,
double *  v 
)

Returns the index of the maximum element in the given vector.

Parameters
mThe size of the vector.
vThe vector.
Returns
The index for the maximum element or NO_UINT if the vector is empty.

Definition at line 124 of file basic_algebra.c.

References NO_UINT.

double MaxVector ( unsigned int  m,
double *  v 
)

Returns the value of the maximum element in the given vector.

Parameters
mThe size of the vector.
vThe vector.
Returns
The value for the maximum element or 0 if the vector is empty.

Definition at line 148 of file basic_algebra.c.

Referenced by ErrorInInequalities(), ErrorInSimpInequalitiesOnPoint(), InequalitiesHoldOnPoint(), and SimpInequalitiesHoldOnPoint().

unsigned int MinVectorElement ( unsigned int  m,
double *  v 
)

Returns the index of the minimum element in the given vector.

Parameters
mThe size of the vector.
vThe vector.
Returns
The index for the minimum element or NO_UINT if the vector is empty.

Definition at line 167 of file basic_algebra.c.

References NO_UINT.

double MinVector ( unsigned int  m,
double *  v 
)

Returns the value of the minimum element in the given vector.

Parameters
mThe size of the vector.
vThe vector.
Returns
The value for the minimum element or 0 if the vector is empty.

Definition at line 191 of file basic_algebra.c.

CBLAS_INLINE void SubtractVector ( unsigned int  s,
double *  v1,
double *  v2 
)

Substracts a vector from another vector: v1=v1-v2

Parameters
sNumber of elements in the vector.
v1The vector from where to substract.
v2The vector to substract.

Definition at line 210 of file basic_algebra.c.

Referenced by GradientSmooth(), and PolytopeBoundaryPointFromExternalCornerInt().

void DifferenceVector ( unsigned int  s,
double *  v1,
double *  v2,
double *  v 
)
inline

Substracts two vectors and stores the result in another vector: v=v1-v2

Parameters
sNumber of elements in the vector.
v1The vector from where to substract.
v2The vector to substract.
vThe vector where to store the result.

Definition at line 223 of file basic_algebra.c.

Referenced by AdjustBioWorldGeometry(), Atoms2Transforms(), ConnectSamplesChart(), DifferenceVectorTopology(), FindSingularPoint(), GenerateJointSolution(), GetJointDOFValues(), InitPatchTrans(), InitWorldFromMolecule(), Manifold2Chart(), MoveJointFromTransforms(), PointTowardRandSample(), and TriangulateAtlas().

void DifferenceVectorTopology ( unsigned int  s,
unsigned int *  tp,
double *  v1,
double *  v2,
double *  v 
)

Substracts two vectors and stores the result in another vector considering the topology for each dimension.

Parameters
sNumber of elements in the vector.
tpThe topology for each variable.
v1The vector from where to substract.
v2The vector to substract.
vThe vector where to store the result.

Definition at line 245 of file basic_algebra.c.

References DifferenceVector(), PI2PI, and TOPOLOGY_S.

Referenced by AddBranchToAtlasRRT(), AddBranchToRRT(), Chart2Manifold(), ConnectSamples(), ConnectSamplesChart(), GeodesicDistance(), and Manifold2Chart().

CBLAS_INLINE double NormWithStride ( unsigned int  s,
unsigned int  st,
double *  v 
)

Computes the norm of a vector with the given size and whose elements might not be continuous in memory but separated by a given stride.

Parameters
sNumber of elements in the vector.
stThe stride (separation between elements of v).
vThe vector.
Returns
The norm of the vector.

Definition at line 280 of file basic_algebra.c.

double SquaredDistance ( unsigned int  s,
double *  v1,
double *  v2 
)
inline

Computes the distance between two points given as a vector with a given size.

Parameters
sNumber of elements in the vectors.
v1The first point.
v2The second point.
Returns
The distance between the points.

Definition at line 297 of file basic_algebra.c.

Referenced by Distance(), DistanceTopology(), and SquaredDistanceTopology().

double Distance ( unsigned int  s,
double *  v1,
double *  v2 
)
inline

Computes the distance between two points given as a vector with a given size.

Parameters
sNumber of elements in the vectors.
v1The first point.
v2The second point.
Returns
The distance between the points.

Definition at line 323 of file basic_algebra.c.

References SquaredDistance().

Referenced by AddBranchToAtlasRRT(), AdjustBioWorldGeometry(), BioWorldRMSE(), CrossTopologyBorder(), DistanceOnChart(), HTransformIsIdentity(), main(), NewTemptativeSample(), PathInChart(), and ReadSTL().

double SquaredDistanceTopology ( unsigned int  s,
unsigned int *  tp,
double *  v1,
double *  v2 
)

Computes the squared distance between two points given as a vector with a given size and considering the topology for each dimension.

Parameters
sNumber of elements in the vectors.
tpThe topology for each dimension.
v1The first point.
v2The second point.
Returns
The squared distance between the points.

Definition at line 328 of file basic_algebra.c.

References M_PI, PI2PI, SquaredDistance(), and TOPOLOGY_S.

Referenced by GetRRTNN().

double SquaredDistanceTopologyMin ( double  t2,
unsigned int  s,
unsigned int *  tp,
double *  v1,
double *  v2 
)

Computes the squared distance between two points given as a vector with a given size and considering the topology for each dimension.

The squared distance is only fully computed for points closer than a given threshold. This accelerates the distance computations.

Parameters
t2The threshold (a square distance!).
sNumber of elements in the vectors.
tpThe topology for each dimension.
v1The first point.
v2The second point.
Returns
The squared distance between the points.

Definition at line 352 of file basic_algebra.c.

References M_PI, PI2PI, and TOPOLOGY_S.

double DistanceTopology ( unsigned int  s,
unsigned int *  tp,
double *  v1,
double *  v2 
)
double DistanceTopologyMin ( double  t,
unsigned int  s,
unsigned int *  tp,
double *  v1,
double *  v2 
)

This is like DistanceTopology, but it only computes the distance as far it is below a given threshold. This is usefuls to rapidly abort computing distances for points that are further away than other points when searching for nearest neighbours.

Note that if the output is above the given threshold, the distance is not actually fully computed (the output is not the true distance between the given points).

Parameters
tThe threshold.
sNumber of elements in the vectors.
tpThe topology for each dimension.
v1The first point.
v2The second point.
Returns
The distance between the points.

Definition at line 406 of file basic_algebra.c.

References M_PI, PI2PI, and TOPOLOGY_S.

Referenced by GetRRTNN(), GetRRTNNInBall(), GetRRTNNInBranch(), and GetRRTNNInChart().

boolean CrossTopologyBorder ( unsigned int  s,
unsigned int *  tp,
double *  v1,
double *  v2 
)

Checks if the shortest line connecting two points crosses the borders imposed by the topology of each variable, i.e., if it goes across the pi,-pi discontinuity.

Parameters
sNumber of elements in the vectors.
tpThe topology for each dimension.
v1The first point.
v2The second point.
Returns
TRUE if the line crosses the topology border.

Definition at line 437 of file basic_algebra.c.

References Distance(), and DistanceTopology().

Referenced by TriangulateAtlas().

CBLAS_INLINE void Normalize ( unsigned int  s,
double *  v 
)

Normalizes a generic vector with the given size.

Parameters
sThe size of the vector.
vThe vector to normalize. We output overwrite the input.

Definition at line 442 of file basic_algebra.c.

References Error(), and Norm().

Referenced by Atoms2Transforms(), CDCallBackInfo(), EvaluatePATrans(), GenerateJointSolution(), GetJointDOFValues(), GetJointTransform(), and PointTowardRandSample().

double Mean ( unsigned int  s,
double *  v 
)

Computes the mean of an array of doubles.

Parameters
sThe size of the vector.
vThe vector with the data.
Returns
The mean of the elements in the vector.

Definition at line 466 of file basic_algebra.c.

Referenced by PrintAverages().

double StdDev ( unsigned int  s,
double  m,
double *  v 
)

Computes the sample standard deviation of an array of doubles.

Parameters
sThe size of the vector.
mThe mean of the data (see Mean).
vThe vector with the data.
Returns
The mean of the elements in the vector.

Definition at line 478 of file basic_algebra.c.

Referenced by PrintAverages().

void ArrayPi2Pi ( unsigned int  n,
unsigned int *  t,
double *  a 
)

Applies PI2PI to an array but only to those elements that have sphere topology.

Parameters
nSize of the array.
tThe topology for each entry in the array.
aThe array to adjust.

Definition at line 496 of file basic_algebra.c.

References PI2PI, and TOPOLOGY_S.

Referenced by AddChart2Btree(), AddNodeToRRT(), Chart2Manifold(), ConnectSamples(), ConnectSamplesChart(), CuikNewtonInBox(), CuikNewtonSimp(), Local2Global(), Manifold2Chart(), Newton2ManifoldPlane(), RefineSingularPoint(), and SearchInBtree().

CBLAS_INLINE void GetRow ( unsigned int  k,
unsigned int  r,
unsigned int  c,
double *  m,
double *  v 
)

Defines a vector taking the values from the row of a matrix.

Parameters
kThe row to use.
rNumber of rows of the matrix.
cNumber of columns of the matrix.
mThe matrix.
vThe vector to define.

Definition at line 509 of file basic_algebra.c.

References RC2INDEX.

CBLAS_INLINE void GetColumn ( unsigned int  k,
unsigned int  r,
unsigned int  c,
double *  m,
double *  v 
)

Defines a vector taking the values from the column of a matrix.

Parameters
kThe column to use.
rNumber of rows of the matrix.
cNumber of columns of the matrix.
mThe matrix.
vThe vector to define.

Definition at line 521 of file basic_algebra.c.

References RC2INDEX.

Referenced by FindRightNullVector(), and RefineSingularPoint().

CBLAS_INLINE void SetRow ( double *  v,
unsigned int  k,
unsigned int  r,
unsigned int  c,
double *  m 
)

Defines a row of a matrix taking the values from a vector.

Parameters
vThe vector with the values to use.
kThe row to replace.
rNumber of rows of the matrix.
cNumber of columns of the matrix.
mThe matrix to update.

Definition at line 533 of file basic_algebra.c.

References RC2INDEX.

Referenced by Newton2ManifoldPlane().

CBLAS_INLINE void SetColumn ( double *  v,
unsigned int  k,
unsigned int  r,
unsigned int  c,
double *  m 
)

Defines a column of a matrix taking the values from a vector.

Parameters
vThe vector with the values to use.
kThe column to replace.
rNumber of rows of the matrix.
cNumber of columns of the matrix.
mThe matrix to update.

Definition at line 545 of file basic_algebra.c.

References RC2INDEX.

CBLAS_INLINE double RowSquaredNorm ( unsigned int  k,
unsigned int  r,
unsigned int  c,
double *  m 
)

Computes the squared norm of a row of a matrix.

Parameters
kThe row to use.
rNumber of rows of the matrix.
cNumber of columns of the matrix.
mThe matrix to update.
Returns
The squared norm of the selected row.

Definition at line 557 of file basic_algebra.c.

References RC2INDEX.

CBLAS_INLINE double ColumnSquaredNorm ( unsigned int  k,
unsigned int  r,
unsigned int  c,
double *  m 
)

Computes the squared norm of a column of a matrix.

Parameters
kThe column to use.
rNumber of rows of the matrix.
cNumber of columns of the matrix.
mThe matrix to update.
Returns
The squared norm of the selected column.

Definition at line 578 of file basic_algebra.c.

References RC2INDEX.

Referenced by FindRightNullVector().

CBLAS_INLINE void MatrixVectorProduct ( unsigned int  r,
unsigned int  c,
double *  A,
double *  b,
double *  o 
)

Product of a matrix with r rows and c columns by a vector with c elements. The output is a vector of r entries.

The input and output vectors must be allocated externally. Here we assume they have the correct size.

Parameters
rNumber of rows of the matrix.
cNumber of columns of the matrix.
AThe matrix (stored as a vector row/column major).
bThe vector.
oThe resulting vector.

Definition at line 599 of file basic_algebra.c.

References RC2INDEX.

Referenced by Local2Global(), and RefineSingularPoint().

CBLAS_INLINE void TMatrixVectorProduct ( unsigned int  r,
unsigned int  c,
double *  A,
double *  b,
double *  o 
)

Product of a transposed matrix with r rows and c columns by a vector with r elements. The output is a vector of c entries.

The input and output vectors must be allocated externally. Here we assume they have the correct size.

Parameters
rNumber of rows of the matrix (before transposing).
cNumber of columns of the matrix (before transposing).
AThe matrix (before transposing) stored as a vector (row or column major).
bThe vector (of size r).
oThe resulting vector.

Definition at line 615 of file basic_algebra.c.

References RC2INDEX.

Referenced by Chart2Manifold(), GradientSmooth(), Manifold2Chart(), MinCosinusBetweenSubSpaces(), and RefineSingularPoint().

CBLAS_INLINE void TMatrixVectorStrideProduct ( unsigned int  r,
unsigned int  c,
double *  A,
unsigned int  s,
double *  b,
double *  o 
)

Product of a transposed matrix with r rows and c columns by a vector with r elements where the elements are separeted by stride positions. The output is a vector of c entries.

The input and output vectors must be allocated externally. Here we assume they have the correct size.

Parameters
rNumber of rows of the matrix (before transposing).
cNumber of columns of the matrix (before transposing).
AThe matrix (before transposing) stored as a vector (row or column major).
sThe stride between elements in b.
bThe vector (of size r).
oThe resulting vector.

Definition at line 631 of file basic_algebra.c.

References RC2INDEX.

Referenced by MinCosinusBetweenSubSpaces().

CBLAS_INLINE void MatrixMatrixProduct ( unsigned int  ra,
unsigned int  ca,
double *  A,
unsigned int  cb,
double *  B,
double *  C 
)

Computes the product of a matrix by another matrix.

Parameters
raNumber of rows of A.
caNumer of columns of A. This also gives the number of rows of B.
AThe first matrix (ra x ca).
cbNumer of columns of B.
BThe second matrix (ca x cb)
CThe resulting matrix (ra x cb). The space for this matrix must be allocated (deallocated) externally.

Definition at line 647 of file basic_algebra.c.

References RC2INDEX.

CBLAS_INLINE void TMatrixMatrixProduct ( unsigned int  ra,
unsigned int  ca,
double *  A,
unsigned int  cb,
double *  B,
double *  C 
)

Computes the product of a matrix transposed by another matrix.

Parameters
raNumber of rows of A (without transposing). This also gives the number of rows of B.
caNumer of columns of A (without transposing).
AThe first matrix (ra x ca).
cbNumer of columns of B.
BThe second matrix (ra x cb)
CThe resulting matrix (ca x cb). The space for this matrix must be allocated (deallocated) externally.

Definition at line 672 of file basic_algebra.c.

References RC2INDEX.

Referenced by CompareTangentSpaces(), and FindRightNullVector().

double MinCosinusBetweenSubSpaces ( unsigned int  m,
unsigned int  k,
double *  T1,
double *  T2 
)

We determine the cosinus of the maximum angle between tangent spaces.

Note that we actually return the minimum of the absolute values of the cosinus. This is so since aligned tangent spaces form an angle of 0 or of pi (with cosinus 1 or -1 respectively).

In other words, for subspaces to be equal this function shouls return 1. If the output is 0, the subspaces are orthogonal.

In any case, we assume that the matrices defining the subspaces are orthonormal.

Parameters
mRows of the matrices defining the sub-spaces.
kColumns of the matrices defining the sub-spaces.
T1The matrix with the first sub-space.
T2The matrix with the second sub-space.
Returns
The cosinus of the maximum angle (i.e., the minimum cosinus) between the sub-spaces.

Definition at line 697 of file basic_algebra.c.

References NEW, Norm(), RC2INDEX, TMatrixVectorProduct(), and TMatrixVectorStrideProduct().

Referenced by MinCosinusBetweenCharts().

CBLAS_INLINE void SubMatrixFromMatrix ( unsigned int  nr1,
unsigned int  nc1,
double *  m1,
unsigned int  nri,
unsigned int  nci,
unsigned int  nr,
unsigned int  nc,
double *  m 
)

Inserts a matrix as a submatrix of a larger matrix.

Parameters
nr1Number of rows of the matrix to insert.
nc1Number of columns of the matrix to insert.
m1The matrix to insert.
nriRow defining the position where to insert the matrix.
nciColumn defining the positon where to insert the matrix.
nrNumber of rows of the matrix to modify.
ncNumber of columns of the matrix to modify.
mThe matrix to modify.

Definition at line 741 of file basic_algebra.c.

References RC2INDEX.

Referenced by EvaluateJacobianInVector(), EvaluateJacobianSubSetInVector(), EvaluateTransposedJacobianInVector(), EvaluateTransposedJacobianSubSetInVector(), and RefineSingularPoint().

CBLAS_INLINE void SubMatrixFromTMatrix ( unsigned int  nr1,
unsigned int  nc1,
double *  m1,
unsigned int  nri,
unsigned int  nci,
unsigned int  nr,
unsigned int  nc,
double *  m 
)

Inserts a transposed matrix as a submatrix of a larger matrix.

Parameters
nr1Number of rows of the matrix to insert (before transposing it).
nc1Number of columns of the matrix to insert (before transposing it).
m1The matrix to insert.
nriRow defining the position where to insert the matrix.
nciColumn defining the positon where to insert the matrix.
nrNumber of rows of the matrix to modify.
ncNumber of columns of the matrix to modify.
mThe matrix to modify.

Definition at line 785 of file basic_algebra.c.

References RC2INDEX.

Referenced by Chart2Manifold(), GetChartDegree(), and RefineSingularPoint().

void PrintVector ( FILE *  f,
char *  label,
unsigned int  n,
double *  v 
)

Prints a vector into a file.

Parameters
fThe file where to store the vector.
labelThe name of the vector (possibly NULL).
nThe size of the vector.
vThe vector.

Definition at line 829 of file basic_algebra.c.

Referenced by ComputeJacobianKernelBasis(), and GetChartDegree().

void PrintMatrix ( FILE *  f,
char *  label,
unsigned int  r,
unsigned int  c,
double *  m 
)

Prints a matrix into a file.

Parameters
fThe file where to print the matrix.
labelTne name of the matrix (possibly NULL)
rNumber of rows of the matrix.
cNumber of columns of the matrix.
mThe matrix.

Definition at line 841 of file basic_algebra.c.

References RC2INDEX.

Referenced by FindRightNullVector(), and GetChartDegree().

void PrintTMatrix ( FILE *  f,
char *  label,
unsigned int  r,
unsigned int  c,
double *  m 
)

Prints a transposed matrix into a file.

Parameters
fThe file where to print the matrix.
labelTne name of the matrix (possibly NULL)
rNumber of rows of the matrix.
cNumber of columns of the matrix.
mThe matrix.

Definition at line 857 of file basic_algebra.c.

References RC2INDEX.

Referenced by ComputeJacobianKernelBasis(), and FindRightNullVector().