[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

| Matrix Functions [Linear Algebra] |

Basic matrix algebra, element-wise mathematical functions, row and columns statistics, data normalization etc. More...

## Functions

template<class T, class C>
linalg::TemporaryMatrix< T > | abs (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
linalg::TemporaryMatrix< T > | acos (MultiArrayView< 2, T, C > const &v)
template<class T, class C1, class C2, class C3>
void | add (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b, MultiArrayView< 2, T, C3 > &r)
template<class T, class C>
int | argMax (MultiArrayView< 2, T, C > const &a)
template<class T, class C, class UnaryFunctor>
int | argMaxIf (MultiArrayView< 2, T, C > const &a, UnaryFunctor condition)
template<class T, class C>
int | argMin (MultiArrayView< 2, T, C > const &a)
template<class T, class C, class UnaryFunctor>
int | argMinIf (MultiArrayView< 2, T, C > const &a, UnaryFunctor condition)
template<class T, class C>
linalg::TemporaryMatrix< T > | asin (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
linalg::TemporaryMatrix< T > | atan (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
linalg::TemporaryMatrix< T > | ceil (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
MultiArrayIndex | columnCount (const MultiArrayView< 2, T, C > &x)
template<... >
void | columnStatistics (...)
template<class T, class C>
MultiArrayView< 2, T, C > | columnVector (MultiArrayView< 2, T, C > const &m, MultiArrayShape< 2 >::type first, int end)
template<class T, class C>
MultiArrayView< 2, T, C > | columnVector (MultiArrayView< 2, T, C > const &m, MultiArrayIndex d)
template<class T, class C>
linalg::TemporaryMatrix< T > | cos (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
TemporaryMatrix< T > | covarianceMatrixOfColumns (MultiArrayView< 2, T, C > const &features)
template<class T1, class C1, class T2, class C2>
void | covarianceMatrixOfColumns (MultiArrayView< 2, T1, C1 > const &features, MultiArrayView< 2, T2, C2 > &covariance)
template<class T, class C>
TemporaryMatrix< T > | covarianceMatrixOfRows (MultiArrayView< 2, T, C > const &features)
template<class T1, class C1, class T2, class C2>
void | covarianceMatrixOfRows (MultiArrayView< 2, T1, C1 > const &features, MultiArrayView< 2, T2, C2 > &covariance)
template<class T, class C1, class C2>
TemporaryMatrix< T > | cross (const MultiArrayView< 2, T, C1 > &x, const MultiArrayView< 2, T, C2 > &y)
template<class T, class C1, class C2, class C3>
void | cross (const MultiArrayView< 2, T, C1 > &x, const MultiArrayView< 2, T, C2 > &y, MultiArrayView< 2, T, C3 > &r)
template<class T, class C1, class C2, class C3>
void | cross (const MultiArrayView< 1, T, C1 > &x, const MultiArrayView< 1, T, C2 > &y, MultiArrayView< 1, T, C3 > &r)
template<class T, class C>
TemporaryMatrix< T > | diagonalMatrix (MultiArrayView< 2, T, C > const &v)
template<class T, class C1, class C2>
void | diagonalMatrix (MultiArrayView< 2, T, C1 > const &v, MultiArrayView< 2, T, C2 > &r)
template<class T, class C1, class C2>
NormTraits< T >::SquaredNormType | dot (const MultiArrayView< 1, T, C1 > &x, const MultiArrayView< 1, T, C2 > &y)
template<class T, class C1, class C2>
NormTraits< T >::SquaredNormType | dot (const MultiArrayView< 2, T, C1 > &x, const MultiArrayView< 2, T, C2 > &y)
template<class T, class C>
linalg::TemporaryMatrix< T > | exp (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
linalg::TemporaryMatrix< T > | floor (MultiArrayView< 2, T, C > const &v)
template<class T>
TemporaryMatrix< T > | identityMatrix (MultiArrayIndex size)
template<class T, class C>
void | identityMatrix (MultiArrayView< 2, T, C > &r)
template<class T, class C>
bool | isSymmetric (const MultiArrayView< 2, T, C > &v)
template<class T, class C1, class C2>
TemporaryMatrix< T > | joinHorizontally (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b)
template<class T, class C1, class C2>
TemporaryMatrix< T > | joinVertically (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b)
template<class T, class C>
linalg::TemporaryMatrix< T > | log (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
linalg::TemporaryMatrix< T > | log10 (MultiArrayView< 2, T, C > const &v)
template<class T, class C1, class C2>
TemporaryMatrix< T > | mmul (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b)
template<class T, class C1, class C2, class C3>
void | mmul (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b, MultiArrayView< 2, T, C3 > &r)
template<class T, class ALLOC>
Matrix< T, ALLLOC >::NormType | norm (const Matrix< T, ALLLOC > &a)
template<class T, class C1, class C2>
TemporaryMatrix< T > | operator* (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b)
template<class T, int N, class DATA, class DERIVED, class A>
TinyVector< T, N > | operator* (const TinyVectorBase< T, N, DATA, DERIVED > &a, const Matrix< T, A > &b)
template<class T, class A, int N, class DATA, class DERIVED>
TinyVector< T, N > | operator* (const Matrix< T, A > &a, const TinyVectorBase< T, N, DATA, DERIVED > &b)
template<class T, class C>
TemporaryMatrix< T > | operator* (T a, const MultiArrayView< 2, T, C > &b)
template<class T, class C>
TemporaryMatrix< T > | operator* (const MultiArrayView< 2, T, C > &a, T b)
template<class T, class C, class U>
TemporaryMatrix< T > | operator* (const MultiArrayView< 2, T, C > &a, PointWise< U > b)
template<class T, class C>
TemporaryMatrix< T > | operator+ (T a, const MultiArrayView< 2, T, C > &b)
template<class T, class C>
TemporaryMatrix< T > | operator+ (const MultiArrayView< 2, T, C > &a, T b)
template<class T, class C1, class C2>
TemporaryMatrix< T > | operator+ (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b)
template<class T, class C>
TemporaryMatrix< T > | operator- (T a, const MultiArrayView< 2, T, C > &b)
template<class T, class C>
TemporaryMatrix< T > | operator- (const MultiArrayView< 2, T, C > &a, T b)
template<class T, class C>
TemporaryMatrix< T > | operator- (const MultiArrayView< 2, T, C > &a)
template<class T, class C1, class C2>
TemporaryMatrix< T > | operator- (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b)
template<class T, class C>
TemporaryMatrix< T > | operator/ (T a, const MultiArrayView< 2, T, C > &b)
template<class T, class C>
TemporaryMatrix< T > | operator/ (const MultiArrayView< 2, T, C > &a, T b)
template<class T, class C, class U>
TemporaryMatrix< T > | operator/ (const MultiArrayView< 2, T, C > &a, PointWise< U > b)
template<class T, class C>
std::ostream & | operator<< (std::ostream &s, const vigra::MultiArrayView< 2, T, C > &m)
template<class T, class C>
TemporaryMatrix< T > | outer (const MultiArrayView< 2, T, C > &x)
template<class T, class C1, class C2>
TemporaryMatrix< T > | outer (const MultiArrayView< 2, T, C1 > &x, const MultiArrayView< 2, T, C2 > &y)
template<class T, class C1, class C2, class C3>
void | outer (const MultiArrayView< 2, T, C1 > &x, const MultiArrayView< 2, T, C2 > &y, MultiArrayView< 2, T, C3 > &r)
template<class T, class C1, class C2>
TemporaryMatrix< T > | pdiv (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b)
template<class T, class C1, class C2, class C3>
void | pdiv (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b, MultiArrayView< 2, T, C3 > &r)
template<class T, class C1, class C2>
TemporaryMatrix< T > | pmul (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b)
template<class T, class C1, class C2, class C3>
void | pmul (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b, MultiArrayView< 2, T, C3 > &r)
template<class T, class C>
linalg::TemporaryMatrix< T > | pow (MultiArrayView< 2, T, C > const &v, T exponent)
template<... >
void | prepareColumns (...)
template<... >
void | prepareRows (...)
template<class T, class C>
TemporaryMatrix< T > | repeatMatrix (MultiArrayView< 2, T, C > const &v, unsigned int verticalCount, unsigned int horizontalCount)
template<class T, class C1, class C2>
void | repeatMatrix (MultiArrayView< 2, T, C1 > const &v, MultiArrayView< 2, T, C2 > &r, unsigned int verticalCount, unsigned int horizontalCount)
template<class T, class C>
linalg::TemporaryMatrix< T > | round (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
MultiArrayIndex | rowCount (const MultiArrayView< 2, T, C > &x)
template<... >
void | rowStatistics (...)
template<class T, class C>
MultiArrayView< 2, T, C > | rowVector (MultiArrayView< 2, T, C > const &m, MultiArrayShape< 2 >::type first, MultiArrayIndex end)
template<class T, class C>
MultiArrayView< 2, T, C > | rowVector (MultiArrayView< 2, T, C > const &m, MultiArrayIndex d)
template<class T, class C1, class C2>
void | sdiv (const MultiArrayView< 2, T, C1 > &a, T b, MultiArrayView< 2, T, C2 > &r)
template<class T, class C>
linalg::TemporaryMatrix< T > | sign (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
linalg::TemporaryMatrix< T > | sin (MultiArrayView< 2, T, C > const &v)
template<class T, class C2, class C3>
void | smul (T a, const MultiArrayView< 2, T, C2 > &b, MultiArrayView< 2, T, C3 > &r)
template<class T, class C1, class C2>
void | smul (const MultiArrayView< 2, T, C1 > &a, T b, MultiArrayView< 2, T, C2 > &r)
template<class T, class C>
linalg::TemporaryMatrix< T > | sq (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
linalg::TemporaryMatrix< T > | sqrt (MultiArrayView< 2, T, C > const &v)
template<class T, class ALLOC>
Matrix< T, ALLLOC > ::SquaredNormType | squaredNorm (const Matrix< T, ALLLOC > &a)
template<class T, class C1, class C2, class C3>
void | sub (const MultiArrayView< 2, T, C1 > &a, const MultiArrayView< 2, T, C2 > &b, MultiArrayView< 2, T, C3 > &r)
template<class T, class C>
linalg::TemporaryMatrix< T > | tan (MultiArrayView< 2, T, C > const &v)
template<class T, class C>
MultiArrayView< 2, T, StridedArrayTag > | transpose (MultiArrayView< 2, T, C > const &v)
template<class T, class C1, class C2>
void | transpose (const MultiArrayView< 2, T, C1 > &v, MultiArrayView< 2, T, C2 > &r)

## Detailed Description

Basic matrix algebra, element-wise mathematical functions, row and columns statistics, data normalization etc.

## Function Documentation

template<class T, class C>
MultiArrayIndex rowCount | ( | const MultiArrayView< 2, T, C > & | x | ) |

Number of rows of a matrix represented as a `MultiArrayView<2, ...>`

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C>
MultiArrayIndex columnCount | ( | const MultiArrayView< 2, T, C > & | x | ) |

Number of columns of a matrix represented as a `MultiArrayView<2, ...>`

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C>
MultiArrayView< 2, T, C > rowVector | ( | MultiArrayView< 2, T, C > const & | m,
|  | MultiArrayIndex | d |
| ) |  |  |

Create a row vector view for row d of the matrix m

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C>
MultiArrayView<2, T, C> vigra::linalg::rowVector | ( | MultiArrayView< 2, T, C > const & | m,
|  | MultiArrayShape< 2 >::type | first,
|  | MultiArrayIndex | end |
| ) |  |  |

Create a row vector view of the matrix m starting at element first and ranging to column end (non-inclusive).

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C>
MultiArrayView< 2, T, C > columnVector | ( | MultiArrayView< 2, T, C > const & | m,
|  | MultiArrayIndex | d |
| ) |  |  |

Create a column vector view for column d of the matrix m

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C>
MultiArrayView<2, T, C> vigra::linalg::columnVector | ( | MultiArrayView< 2, T, C > const & | m,
|  | MultiArrayShape< 2 >::type | first,
|  | int | end |
| ) |  |  |

Create a column vector view of the matrix m starting at element first and ranging to row end (non-inclusive).

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C>
bool isSymmetric | ( | MultiArrayView< 2, T, C > const & | m | ) |

Check whether matrix m is symmetric.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

Matrix<T, ALLLOC>::SquaredNormType vigra::linalg::squaredNorm | ( | const Matrix< T, ALLLOC > & | a | ) |

calculate the squared Frobenius norm of a matrix. Equal to the sum of squares of the matrix elements.

#include <vigra/matrix.hxx> Namespace: vigra

template<class T, class ALLOC>
Matrix<T, ALLLOC>::NormType vigra::linalg::norm | ( | const Matrix< T, ALLLOC > & | a | ) |

calculate the Frobenius norm of a matrix. Equal to the root of the sum of squares of the matrix elements.

#include <vigra/matrix.hxx> Namespace: vigra

template<class T, class C>
void vigra::linalg::identityMatrix | ( | MultiArrayView< 2, T, C > & | r | ) |

initialize the given square matrix as an identity matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T>
TemporaryMatrix<T> vigra::linalg::identityMatrix | ( | MultiArrayIndex | size | ) |

create n identity matrix of the given size. Usage:

            vigra::Matrix<double> m = vigra::identityMatrix<double>(size);

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2>
void vigra::linalg::diagonalMatrix | ( | MultiArrayView< 2, T, C1 > const & | v,
|  | MultiArrayView< 2, T, C2 > & | r |
| ) |  |  |

make a diagonal matrix from a vector. The vector is given as matrix v, which must either have a single row or column. The result is witten into the square matrix r.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::diagonalMatrix | ( | MultiArrayView< 2, T, C > const & | v | ) |

create a diagonal matrix from a vector. The vector is given as matrix v, which must either have a single row or column. The result is returned as a temporary matrix. Usage:

            vigra::Matrix<double> v(1, len);
            v = ...;

            vigra::Matrix<double> m = diagonalMatrix(v);

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2>
void transpose | ( | const MultiArrayView< 2, T, C1 > & | v,
|  | MultiArrayView< 2, T, C2 > & | r |
| ) |  |  |

transpose matrix v. The result is written into r which must have the correct (i.e. transposed) shape.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

MultiArrayView<2, T, StridedArrayTag> vigra::linalg::transpose | ( | MultiArrayView< 2, T, C > const & | v | ) |

create the transpose of matrix v. This does not copy any data, but only creates a transposed view to the original matrix. A copy is only made when the transposed view is assigned to another matrix. Usage:

            vigra::Matrix<double> v(rows, cols);
            v = ...;

            vigra::Matrix<double> m = transpose(v);

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::joinVertically | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b |
| ) |  |  |

Create new matrix by concatenating two matrices a and b vertically, i.e. on top of each other. The two matrices must have the same number of columns. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::joinHorizontally | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b |
| ) |  |  |

Create new matrix by concatenating two matrices a and b horizontally, i.e. side by side. The two matrices must have the same number of rows. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
void vigra::linalg::repeatMatrix | ( | MultiArrayView< 2, T, C1 > const & | v,
|  | MultiArrayView< 2, T, C2 > & | r,
|  | unsigned int | verticalCount,
|  | unsigned int | horizontalCount |
| ) |  |  |

Initialize a matrix with repeated copies of a given matrix.

Matrix r will consist of verticalCount downward repetitions of v, and horizontalCount side-by-side repetitions. When v has size `m` by `n`, r must have size `(m*verticalCount)` by `(n*horizontalCount)`.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::repeatMatrix | ( | MultiArrayView< 2, T, C > const & | v,
|  | unsigned int | verticalCount,
|  | unsigned int | horizontalCount |
| ) |  |  |

Create a new matrix by repeating a given matrix.

The resulting matrix r will consist of verticalCount downward repetitions of v, and horizontalCount side-by-side repetitions, i.e. it will be of size `(m*verticalCount)` by `(n*horizontalCount)` when v has size `m` by `n`. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2, class C3>
void vigra::linalg::add | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b,
|  | MultiArrayView< 2, T, C3 > & | r |
| ) |  |  |

add matrices a and b. The result is written into r. All three matrices must have the same shape.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::operator+ | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b |
| ) |  |  |

add matrices a and b. The two matrices must have the same shape. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator+ | ( | const MultiArrayView< 2, T, C > & | a,
|  | T | b |
| ) |  |  |

add scalar b to every element of the matrix a. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator+ | ( | T | a,
|  | const MultiArrayView< 2, T, C > & | b |
| ) |  |  |

add scalar a to every element of the matrix b. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2, class C3>
void vigra::linalg::sub | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b,
|  | MultiArrayView< 2, T, C3 > & | r |
| ) |  |  |

subtract matrix b from a. The result is written into r. All three matrices must have the same shape.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::operator- | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b |
| ) |  |  |

subtract matrix b from a. The two matrices must have the same shape. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator- | ( | const MultiArrayView< 2, T, C > & | a | ) |

negate matrix a. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator- | ( | const MultiArrayView< 2, T, C > & | a,
|  | T | b |
| ) |  |  |

subtract scalar b from every element of the matrix a. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator- | ( | T | a,
|  | const MultiArrayView< 2, T, C > & | b |
| ) |  |  |

subtract every element of the matrix b from scalar a. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
NormTraits<T>::SquaredNormType vigra::linalg::dot | ( | const MultiArrayView< 2, T, C1 > & | x,
|  | const MultiArrayView< 2, T, C2 > & | y |
| ) |  |  |

calculate the inner product of two matrices representing vectors. Typically, matrix x has a single row, and matrix y has a single column, and the other dimensions match. In addition, this function handles the cases when either or both of the two inputs are transposed (e.g. it can compute the dot product of two column vectors). A `PreconditionViolation` exception is thrown when the shape conditions are violated.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2>
NormTraits<T>::SquaredNormType vigra::linalg::dot | ( | const MultiArrayView< 1, T, C1 > & | x,
|  | const MultiArrayView< 1, T, C2 > & | y |
| ) |  |  |

calculate the inner product of two vectors. The vector lengths must match.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2, class C3>
void vigra::linalg::cross | ( | const MultiArrayView< 1, T, C1 > & | x,
|  | const MultiArrayView< 1, T, C2 > & | y,
|  | MultiArrayView< 1, T, C3 > & | r |
| ) |  |  |

calculate the cross product of two vectors of length 3. The result is written into r.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2, class C3>
void vigra::linalg::cross | ( | const MultiArrayView< 2, T, C1 > & | x,
|  | const MultiArrayView< 2, T, C2 > & | y,
|  | MultiArrayView< 2, T, C3 > & | r |
| ) |  |  |

calculate the cross product of two matrices representing vectors. That is, x, y, and r must have a single column of length 3. The result is written into r.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::cross | ( | const MultiArrayView< 2, T, C1 > & | x,
|  | const MultiArrayView< 2, T, C2 > & | y |
| ) |  |  |

calculate the cross product of two matrices representing vectors. That is, x, and y must have a single column of length 3. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2, class C3>
void vigra::linalg::outer | ( | const MultiArrayView< 2, T, C1 > & | x,
|  | const MultiArrayView< 2, T, C2 > & | y,
|  | MultiArrayView< 2, T, C3 > & | r |
| ) |  |  |

calculate the outer product of two matrices representing vectors. That is, matrix x must have a single column, and matrix y must have a single row, and the other dimensions must match. The result is written into r.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::outer | ( | const MultiArrayView< 2, T, C1 > & | x,
|  | const MultiArrayView< 2, T, C2 > & | y |
| ) |  |  |

calculate the outer product of two matrices representing vectors. That is, matrix x must have a single column, and matrix y must have a single row, and the other dimensions must match. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::outer | ( | const MultiArrayView< 2, T, C > & | x | ) |

calculate the outer product of a matrix (representing a vector) with itself. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

template<class T, class C1, class C2>
void vigra::linalg::smul | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | T | b,
|  | MultiArrayView< 2, T, C2 > & | r |
| ) |  |  |

multiply matrix a with scalar b. The result is written into r. a and r must have the same shape.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C2, class C3>
void vigra::linalg::smul | ( | T | a,
|  | const MultiArrayView< 2, T, C2 > & | b,
|  | MultiArrayView< 2, T, C3 > & | r |
| ) |  |  |

multiply scalar a with matrix b. The result is written into r. b and r must have the same shape.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2, class C3>
void vigra::linalg::mmul | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b,
|  | MultiArrayView< 2, T, C3 > & | r |
| ) |  |  |

perform matrix multiplication of matrices a and b. The result is written into r. The three matrices must have matching shapes.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::mmul | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b |
| ) |  |  |

perform matrix multiplication of matrices a and b. a and b must have matching shapes. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2, class C3>
void vigra::linalg::pmul | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b,
|  | MultiArrayView< 2, T, C3 > & | r |
| ) |  |  |

multiply two matrices a and b pointwise. The result is written into r. All three matrices must have the same shape.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::pmul | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b |
| ) |  |  |

multiply matrices a and b pointwise. a and b must have matching shapes. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C, class U>
TemporaryMatrix<T> vigra::linalg::operator* | ( | const MultiArrayView< 2, T, C > & | a,
|  | PointWise< U > | b |
| ) |  |  |

multiply matrices a and b pointwise. a and b must have matching shapes. The result is returned as a temporary matrix.

Usage:

            Matrix<double> a(m,n), b(m,n);

            Matrix<double> c = a * pointWise(b);
            // is equivalent to
            // Matrix<double> c = pmul(a, b);

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator* | ( | const MultiArrayView< 2, T, C > & | a,
|  | T | b |
| ) |  |  |

multiply matrix a with scalar b. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator* | ( | T | a,
|  | const MultiArrayView< 2, T, C > & | b |
| ) |  |  |

multiply scalar a with matrix b. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class A, int N, class DATA, class DERIVED>
TinyVector<T, N> vigra::linalg::operator* | ( | const Matrix< T, A > & | a,
|  | const TinyVectorBase< T, N, DATA, DERIVED > & | b |
| ) |  |  |

multiply matrix a with TinyVector b. a must be of size `N x N`. Vector b and the result vector are interpreted as column vectors.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, int N, class DATA, class DERIVED, class A>
TinyVector<T, N> vigra::linalg::operator* | ( | const TinyVectorBase< T, N, DATA, DERIVED > & | a,
|  | const Matrix< T, A > & | b |
| ) |  |  |

multiply TinyVector a with matrix b. b must be of size `N x N`. Vector a and the result vector are interpreted as row vectors.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::operator* | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b |
| ) |  |  |

perform matrix multiplication of matrices a and b. a and b must have matching shapes. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
void vigra::linalg::sdiv | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | T | b,
|  | MultiArrayView< 2, T, C2 > & | r |
| ) |  |  |

divide matrix a by scalar b. The result is written into r. a and r must have the same shape.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2, class C3>
void vigra::linalg::pdiv | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b,
|  | MultiArrayView< 2, T, C3 > & | r |
| ) |  |  |

divide two matrices a and b pointwise. The result is written into r. All three matrices must have the same shape.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C1, class C2>
TemporaryMatrix<T> vigra::linalg::pdiv | ( | const MultiArrayView< 2, T, C1 > & | a,
|  | const MultiArrayView< 2, T, C2 > & | b |
| ) |  |  |

divide matrices a and b pointwise. a and b must have matching shapes. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C, class U>
TemporaryMatrix<T> vigra::linalg::operator/ | ( | const MultiArrayView< 2, T, C > & | a,
|  | PointWise< U > | b |
| ) |  |  |

divide matrices a and b pointwise. a and b must have matching shapes. The result is returned as a temporary matrix.

Usage:

            Matrix<double> a(m,n), b(m,n);

            Matrix<double> c = a / pointWise(b);
            // is equivalent to
            // Matrix<double> c = pdiv(a, b);

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator/ | ( | const MultiArrayView< 2, T, C > & | a,
|  | T | b |
| ) |  |  |

divide matrix a by scalar b. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::operator/ | ( | T | a,
|  | const MultiArrayView< 2, T, C > & | b |
| ) |  |  |

Create a matrix whose elements are the quotients between scalar a and matrix b. The result is returned as a temporary matrix.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: vigra::linalg

template<class T, class C>
int vigra::linalg::argMin | ( | MultiArrayView< 2, T, C > const & | a | ) |

Find the index of the minimum element in a matrix.

The function returns the index in column-major scan-order sense, i.e. according to the order used by `MultiArrayView::operator[]`. If the matrix is actually a vector, this is just the row or columns index. In case of a truely 2-dimensional matrix, the index can be converted to an index pair by calling `MultiArrayView::scanOrderIndexToCoordinate()`

Required Interface:

            bool f = a[0] < NumericTraits<T>::max();

#include <vigra/matrix.hxx>
Namespace: vigra

template<class T, class C>
int vigra::linalg::argMax | ( | MultiArrayView< 2, T, C > const & | a | ) |

Find the index of the maximum element in a matrix.

The function returns the index in column-major scan-order sense, i.e. according to the order used by `MultiArrayView::operator[]`. If the matrix is actually a vector, this is just the row or columns index. In case of a truely 2-dimensional matrix, the index can be converted to an index pair by calling `MultiArrayView::scanOrderIndexToCoordinate()`

Required Interface:

            bool f = NumericTraits<T>::min() < a[0];

#include <vigra/matrix.hxx>
Namespace: vigra

template<class T, class C, class UnaryFunctor>
int vigra::linalg::argMinIf | ( | MultiArrayView< 2, T, C > const & | a,
|  | UnaryFunctor | condition |
| ) |  |  |

Find the index of the minimum element in a matrix subject to a condition.

The function returns `-1` if no element conforms to condition. Otherwise, the index of the maximum element is returned in column-major scan-order sense, i.e. according to the order used by `MultiArrayView::operator[]`. If the matrix is actually a vector, this is just the row or columns index. In case of a truely 2-dimensional matrix, the index can be converted to an index pair by calling `MultiArrayView::scanOrderIndexToCoordinate()`

Required Interface:

            bool c = condition(a[0]);
            bool f = a[0] < NumericTraits<T>::max();

#include <vigra/matrix.hxx>
Namespace: vigra

template<class T, class C, class UnaryFunctor>
int vigra::linalg::argMaxIf | ( | MultiArrayView< 2, T, C > const & | a,
|  | UnaryFunctor | condition |
| ) |  |  |

Find the index of the maximum element in a matrix subject to a condition.

The function returns `-1` if no element conforms to condition. Otherwise, the index of the maximum element is returned in column-major scan-order sense, i.e. according to the order used by `MultiArrayView::operator[]`. If the matrix is actually a vector, this is just the row or columns index. In case of a truely 2-dimensional matrix, the index can be converted to an index pair by calling `MultiArrayView::scanOrderIndexToCoordinate()`

Required Interface:

            bool c = condition(a[0]);
            bool f = NumericTraits<T>::min() < a[0];

#include <vigra/matrix.hxx>
Namespace: vigra

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::pow | ( | MultiArrayView< 2, T, C > const & | v,
|  | T | exponent |
| ) |  |  |

Matrix point-wise power.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::sqrt | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise sqrt.

Examples:
  palette.cxx.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::exp | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise exp.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::log | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise log.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::log10 | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise log10.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::sin | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise sin.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::asin | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise asin.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::cos | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise cos.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::acos | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise acos.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::tan | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise tan.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::atan | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise atan.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::round | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise round.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::floor | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise floor.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::ceil | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise ceil.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::abs | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise abs.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::sq | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise square.

template<class T, class C>
linalg::TemporaryMatrix<T> vigra::linalg::sign | ( | MultiArrayView< 2, T, C > const & | v | ) |

Matrix point-wise sign.

template<class T, class C>
std::ostream& vigra::operator<< | ( | std::ostream & | s,
|  | const vigra::MultiArrayView< 2, T, C > & | m |
| ) |  |  |

print a matrix m to the stream s.

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespace: std

template<... >
void vigra::linalg::columnStatistics | ( |  | ... | ) |

Compute statistics of every column of matrix A.

The result matrices must be row vectors with as many columns as A.

Declarations:

compute only the mean:

        namespace vigra { namespace linalg {
            template <class T1, class C1, class T2, class C2>
            void
            columnStatistics(MultiArrayView<2, T1, C1> const & A,
                             MultiArrayView<2, T2, C2> & mean);
        } }

compute mean and standard deviation:

        namespace vigra { namespace linalg {
            template <class T1, class C1, class T2, class C2, class T3, class C3>
            void
            columnStatistics(MultiArrayView<2, T1, C1> const & A,
                             MultiArrayView<2, T2, C2> & mean,
                             MultiArrayView<2, T3, C3> & stdDev);
        } }

compute mean, standard deviation, and norm:

        namespace vigra { namespace linalg {
            template <class T1, class C1, class T2, class C2, class T3, class C3, class T4, class C4>
            void
            columnStatistics(MultiArrayView<2, T1, C1> const & A,
                             MultiArrayView<2, T2, C2> & mean,
                             MultiArrayView<2, T3, C3> & stdDev,
                             MultiArrayView<2, T4, C4> & norm);
        } }

Usage:

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

        Matrix A(rows, columns);
        .. // fill A
        Matrix columnMean(1, columns), columnStdDev(1, columns), columnNorm(1, columns);

        columnStatistics(A, columnMean, columnStdDev, columnNorm);

template<... >
void vigra::linalg::rowStatistics | ( |  | ... | ) |

Compute statistics of every row of matrix A.

The result matrices must be column vectors with as many rows as A.

Declarations:

compute only the mean:

        namespace vigra { namespace linalg {
            template <class T1, class C1, class T2, class C2>
            void
            rowStatistics(MultiArrayView<2, T1, C1> const & A,
                          MultiArrayView<2, T2, C2> & mean);
        } }

compute mean and standard deviation:

        namespace vigra { namespace linalg {
            template <class T1, class C1, class T2, class C2, class T3, class C3>
            void
            rowStatistics(MultiArrayView<2, T1, C1> const & A,
                          MultiArrayView<2, T2, C2> & mean,
                          MultiArrayView<2, T3, C3> & stdDev);
        } }

compute mean, standard deviation, and norm:

        namespace vigra { namespace linalg {
            template <class T1, class C1, class T2, class C2, class T3, class C3, class T4, class C4>
            void
            rowStatistics(MultiArrayView<2, T1, C1> const & A,
                          MultiArrayView<2, T2, C2> & mean,
                          MultiArrayView<2, T3, C3> & stdDev,
                          MultiArrayView<2, T4, C4> & norm);
        } }

Usage:

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

        Matrix A(rows, columns);
        .. // fill A
        Matrix rowMean(rows, 1), rowStdDev(rows, 1), rowNorm(rows, 1);

        rowStatistics(a, rowMean, rowStdDev, rowNorm);

template<class T1, class C1, class T2, class C2>
void vigra::linalg::covarianceMatrixOfColumns | ( | MultiArrayView< 2, T1, C1 > const & | features,
|  | MultiArrayView< 2, T2, C2 > & | covariance |
| ) |  |  |

Compute the covariance matrix between the columns of a matrix features.

The result matrix covariance must by a square matrix with as many rows and columns as the number of columns in matrix features.

#include <vigra/matrix.hxx>
Namespace: vigra

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::covarianceMatrixOfColumns | ( | MultiArrayView< 2, T, C > const & | features | ) |

Compute the covariance matrix between the columns of a matrix features.

The result is returned as a square temporary matrix with as many rows and columns as the number of columns in matrix features.

#include <vigra/matrix.hxx>
Namespace: vigra

template<class T1, class C1, class T2, class C2>
void vigra::linalg::covarianceMatrixOfRows | ( | MultiArrayView< 2, T1, C1 > const & | features,
|  | MultiArrayView< 2, T2, C2 > & | covariance |
| ) |  |  |

Compute the covariance matrix between the rows of a matrix features.

The result matrix covariance must by a square matrix with as many rows and columns as the number of rows in matrix features.

#include <vigra/matrix.hxx>
Namespace: vigra

template<class T, class C>
TemporaryMatrix<T> vigra::linalg::covarianceMatrixOfRows | ( | MultiArrayView< 2, T, C > const & | features | ) |

Compute the covariance matrix between the rows of a matrix features.

The result is returned as a square temporary matrix with as many rows and columns as the number of rows in matrix features.

#include <vigra/matrix.hxx>
Namespace: vigra

template<... >
void vigra::linalg::prepareColumns | ( |  | ... | ) |

Standardize the columns of a matrix according to given `DataPreparationGoals`.

For every column of the matrix A, this function computes mean, standard deviation, and norm. It then applies a linear transformation to the values of the column according to these statistics and the given `DataPreparationGoals`. The result is returned in matrix res which must have the same size as A. Optionally, the transformation applied can also be returned in the matrices offset and scaling (see below for an example how these matrices can be used to standardize more data according to the same transformation).

The following `DataPreparationGoals` are supported:

`ZeroMean`
  Subtract the column mean form every column if the values in the column are not constant. Do nothing in a constant column.
`UnitVariance`
  Divide by the column standard deviation if the values in the column are not constant. Do nothing in a constant column.
`UnitNorm`
  Divide by the column norm if it is non-zero.
`ZeroMean | UnitVariance`
  First subtact the mean and then divide by the standard deviation, unless the column is constant (in which case the column remains unchanged).
`ZeroMean | UnitNorm`
  If the column is non-constant, subtract the mean. Then divide by the norm of the result if the norm is non-zero.

Declarations:

Standardize the matrix and return the parameters of the linear transformation. The matrices offset and scaling must be row vectors with as many columns as A.

        namespace vigra { namespace linalg {
            template <class T, class C1, class C2, class C3, class C4>
            void
            prepareColumns(MultiArrayView<2, T, C1> const & A,
                           MultiArrayView<2, T, C2> & res,
                           MultiArrayView<2, T, C3> & offset,
                           MultiArrayView<2, T, C4> & scaling,
                           DataPreparationGoals goals = ZeroMean | UnitVariance);
        } }

Only standardize the matrix.

        namespace vigra { namespace linalg {
            template <class T, class C1, class C2>
            void
            prepareColumns(MultiArrayView<2, T, C1> const & A,
                           MultiArrayView<2, T, C2> & res,
                           DataPreparationGoals goals = ZeroMean | UnitVariance);
        } }

Usage:

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

        Matrix A(rows, columns);
        .. // fill A
        Matrix standardizedA(rows, columns), offset(1, columns), scaling(1, columns);

        prepareColumns(A, standardizedA, offset, scaling, ZeroMean | UnitNorm);

        // use offset and scaling to prepare additional data according to the same transformation
        Matrix newData(nrows, columns);

        Matrix standardizedNewData = (newData - repeatMatrix(offset, nrows, 1)) * pointWise(repeatMatrix(scaling, nrows, 1));

template<... >
void vigra::linalg::prepareRows | ( |  | ... | ) |

Standardize the rows of a matrix according to given `DataPreparationGoals`.

This algorithm works in the same way as prepareColumns() (see there for detailed documentation), but is applied to the rows of the matrix A instead. Accordingly, the matrices holding the parameters of the linear transformation must be column vectors with as many rows as A.

Declarations:

Standardize the matrix and return the parameters of the linear transformation. The matrices offset and scaling must be column vectors with as many rows as A.

        namespace vigra { namespace linalg {
            template <class T, class C1, class C2, class C3, class C4>
            void
            prepareRows(MultiArrayView<2, T, C1> const & A,
                        MultiArrayView<2, T, C2> & res,
                        MultiArrayView<2, T, C3> & offset,
                        MultiArrayView<2, T, C4> & scaling,
                        DataPreparationGoals goals = ZeroMean | UnitVariance)´;
        } }

Only standardize the matrix.

        namespace vigra { namespace linalg {
            template <class T, class C1, class C2>
            void
            prepareRows(MultiArrayView<2, T, C1> const & A,
                        MultiArrayView<2, T, C2> & res,
                        DataPreparationGoals goals = ZeroMean | UnitVariance);
        } }

Usage:

#include <vigra/matrix.hxx> or
#include <vigra/linear_algebra.hxx>
Namespaces: vigra and vigra::linalg

        Matrix A(rows, columns);
        .. // fill A
        Matrix standardizedA(rows, columns), offset(rows, 1), scaling(rows, 1);

        prepareRows(A, standardizedA, offset, scaling, ZeroMean | UnitNorm);

        // use offset and scaling to prepare additional data according to the same transformation
        Matrix newData(rows, ncolumns);

        Matrix standardizedNewData = (newData - repeatMatrix(offset, 1, ncolumns)) * pointWise(repeatMatrix(scaling, 1, ncolumns));

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python VIGRA 1.6.0 (13 Aug 2008)