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

Public Types | Public Member Functions
Matrix< T, ALLOC > Class Template Reference

#include <vigra/matrix.hxx>

Inheritance diagram for Matrix< T, ALLOC >:
MultiArray< 2, T, ALLOC > MultiArrayView< N, T >

List of all members.

Public Types

typedef ALLOC allocator_type
typedef BaseType::const_pointer const_pointer
typedef BaseType::const_reference const_reference
typedef BaseType::difference_type difference_type
typedef BaseType::difference_type_1 difference_type_1
typedef Matrix< T, ALLOC > matrix_type
typedef BaseType::pointer pointer
typedef BaseType::reference reference
typedef BaseType::value_type value_type
typedef MultiArrayView< 2, T,
UnstridedArrayTag
view_type
- Public Types inherited from MultiArray< 2, T, ALLOC >
typedef T * const_iterator
typedef
vigra::detail::MultiIteratorChooser
< UnstridedArrayTag >
::template Traverser< N, T, T
const &, T const * >::type 
const_traverser
typedef T * iterator
typedef view_type::size_type size_type
typedef
vigra::detail::MultiIteratorChooser
< UnstridedArrayTag >
::template Traverser< N, T, T
&, T * >::type 
traverser
- Public Types inherited from MultiArrayView< N, T >
enum  ActualDimension

Public Member Functions

difference_type_1 columnCount () const
view_type columnVector (difference_type_1 d) const
difference_type_1 elementCount () const
template<class U >
Matrixinit (const U &init)
bool isSymmetric () const
 Matrix ()
 Matrix (ALLOC const &alloc)
 Matrix (const difference_type &shape, ALLOC const &alloc=allocator_type())
 Matrix (difference_type_1 rows, difference_type_1 columns, ALLOC const &alloc=allocator_type())
 Matrix (const difference_type &shape, const_reference init, allocator_type const &alloc=allocator_type())
 Matrix (difference_type_1 rows, difference_type_1 columns, const_reference init, allocator_type const &alloc=allocator_type())
 Matrix (const difference_type &shape, const_pointer init, RawArrayMemoryLayout layout=RowMajor, allocator_type const &alloc=allocator_type())
 Matrix (difference_type_1 rows, difference_type_1 columns, const_pointer init, RawArrayMemoryLayout layout=RowMajor, allocator_type const &alloc=allocator_type())
 Matrix (const Matrix &rhs)
 Matrix (const TemporaryMatrix< T, ALLOC > &rhs)
template<class U , class C >
 Matrix (const MultiArrayView< 2, U, C > &rhs)
NormTraits< Matrix >::NormType norm () const
value_typeoperator() (difference_type_1 row, difference_type_1 column)
value_type operator() (difference_type_1 row, difference_type_1 column) const
template<class U , class C >
Matrixoperator*= (MultiArrayView< 2, U, C > const &other)
Matrixoperator*= (T other)
template<class U , class C >
Matrixoperator+= (MultiArrayView< 2, U, C > const &other)
Matrixoperator+= (T other)
template<class U , class C >
Matrixoperator-= (MultiArrayView< 2, U, C > const &other)
Matrixoperator-= (T other)
template<class U , class C >
Matrixoperator/= (MultiArrayView< 2, U, C > const &other)
Matrixoperator/= (T other)
Matrixoperator= (const Matrix &rhs)
Matrixoperator= (const TemporaryMatrix< T, ALLOC > &rhs)
template<class U , class C >
Matrixoperator= (const MultiArrayView< 2, U, C > &rhs)
void reshape (difference_type_1 rows, difference_type_1 columns)
void reshape (difference_type_1 rows, difference_type_1 columns, const_reference init)
void reshape (difference_type const &shape)
void reshape (difference_type const &shape, const_reference init)
difference_type_1 rowCount () const
view_type rowVector (difference_type_1 d) const
NormTraits< Matrix >
::SquaredNormType 
squaredNorm () const
MultiArrayView< 2, vluae_type,
StridedArrayTag
transpose () const
- Public Member Functions inherited from MultiArray< 2, T, ALLOC >
allocator_type const & allocator () const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
 MultiArray ()
 MultiArray (allocator_type const &alloc)
 MultiArray (const difference_type &shape, allocator_type const &alloc=allocator_type())
 MultiArray (const difference_type &shape, const_reference init, allocator_type const &alloc=allocator_type())
 MultiArray (const difference_type &shape, const_pointer init, allocator_type const &alloc=allocator_type())
 MultiArray (const MultiArray &rhs)
 MultiArray (const MultiArrayView< N, U, C > &rhs, allocator_type const &alloc=allocator_type())
MultiArrayoperator*= (const MultiArrayView< N, U, C > &rhs)
MultiArrayoperator*= (const T &rhs)
MultiArrayoperator+= (const MultiArrayView< N, U, C > &rhs)
MultiArrayoperator+= (const T &rhs)
MultiArrayoperator-= (const MultiArrayView< N, U, C > &rhs)
MultiArrayoperator-= (const T &rhs)
MultiArrayoperator/= (const MultiArrayView< N, U, C > &rhs)
MultiArrayoperator/= (const T &rhs)
MultiArrayoperator= (const MultiArray &rhs)
MultiArrayoperator= (const MultiArrayView< N, U, C > &rhs)
void swap (MultiArray &other)
 ~MultiArray ()
- Public Member Functions inherited from MultiArrayView< N, T >
MultiArrayView< N-1, T,
typename
vigra::detail::MaybeStrided< M >
::type > 
bind (difference_type_1 d) const
MultiArrayView< N-1, T,
StridedArrayTag
bindAt (difference_type_1 m, difference_type_1 d) const
MultiArrayView< N-M, T,
StridedArrayTag
bindInner (const TinyVector< MultiArrayIndex, M > &d) const
MultiArrayView< N-1, T,
StridedArrayTag
bindInner (difference_type_1 d) const
MultiArrayView< N-M, T, C > bindOuter (const TinyVector< MultiArrayIndex, M > &d) const
MultiArrayView< N-1, T, C > bindOuter (difference_type_1 d) const
difference_type_1 coordinateToScanOrderIndex (const difference_type &d) const
void copy (const MultiArrayView &rhs)
void copy (const MultiArrayView< N, U, CN > &rhs)
pointer data () const
bool hasData () const
MultiArrayView< N+1, T, C > insertSingletonDimension (difference_type_1 i) const
bool isInside (difference_type const &p) const
 MultiArrayView ()
 MultiArrayView (const difference_type &shape, pointer ptr)
 MultiArrayView (const difference_type &shape, const difference_type &stride, pointer ptr)
NormTraits< MultiArrayView >
::NormType 
norm (int type=2, bool useSquaredNorm=true) const
bool operator!= (MultiArrayView< N, U, C1 > const &rhs) const
reference operator() (difference_type_1 x)
reference operator() (difference_type_1 x, difference_type_1 y, difference_type_1 z)
reference operator() (difference_type_1 x, difference_type_1 y, difference_type_1 z, difference_type_1 u)
reference operator() (difference_type_1 x, difference_type_1 y, difference_type_1 z, difference_type_1 u, difference_type_1 v)
const_reference operator() (difference_type_1 x) const
const_reference operator() (difference_type_1 x, difference_type_1 y, difference_type_1 z) const
const_reference operator() (difference_type_1 x, difference_type_1 y, difference_type_1 z, difference_type_1 u) const
const_reference operator() (difference_type_1 x, difference_type_1 y, difference_type_1 z, difference_type_1 u, difference_type_1 v) const
MultiArrayViewoperator*= (MultiArrayView< N, U, C1 > const &rhs)
MultiArrayViewoperator+= (MultiArrayView< N, U, C1 > const &rhs)
MultiArrayViewoperator-= (MultiArrayView< N, U, C1 > const &rhs)
MultiArrayViewoperator/= (MultiArrayView< N, U, C1 > const &rhs)
MultiArrayViewoperator= (MultiArrayView const &rhs)
MultiArrayViewoperator= (MultiArrayView< N, U, C1 > const &rhs)
bool operator== (MultiArrayView< N, U, C1 > const &rhs) const
reference operator[] (const difference_type &d)
const_reference operator[] (const difference_type &d) const
MultiArrayView< N-M, T,
StridedArrayTag
operator[] (const TinyVector< MultiArrayIndex, M > &d) const
reference operator[] (difference_type_1 d)
const_reference operator[] (difference_type_1 d) const
MultiArrayView< N, T,
StridedArrayTag
permuteDimensions (const difference_type &s) const
MultiArrayView< N, T,
StridedArrayTag
permuteStridesAscending () const
MultiArrayView< N, T,
StridedArrayTag
permuteStridesDescending () const
difference_type scanOrderIndexToCoordinate (difference_type_1 d) const
const difference_typeshape () const
difference_type_1 shape (difference_type_1 n) const
difference_type_1 size () const
difference_type_1 size (difference_type_1 n) const
const difference_typestride () const
difference_type_1 stride (int n) const
MultiArrayView< N, T,
StridedArrayTag
stridearray (const difference_type &s) const
difference_type strideOrdering () const
MultiArrayView subarray (const difference_type &p, const difference_type &q) const
void swapData (MultiArrayView rhs)
void swapData (MultiArrayView< N, T2, C2 > rhs)
traverser traverser_begin ()
const_traverser traverser_begin () const
traverser traverser_end ()
const_traverser traverser_end () const

Additional Inherited Members

- Protected Member Functions inherited from MultiArray< 2, T, ALLOC >
void allocate (pointer &ptr, difference_type_1 s, const_reference init)
void allocate (pointer &ptr, difference_type_1 s, U const *init)
void allocate (pointer &ptr, MultiArrayView< N, U, C > const &init)
void deallocate (pointer &ptr, difference_type_1 s)
- Protected Attributes inherited from MultiArray< 2, T, ALLOC >
allocator_type m_alloc
- Protected Attributes inherited from MultiArrayView< N, T >
pointer m_ptr
difference_type m_shape
difference_type m_stride

Detailed Description

template<class T, class ALLOC = std::allocator<T>>
class vigra::linalg::Matrix< T, ALLOC >

Matrix class.

This is the basic class for all linear algebra computations. Matrices are strored in a column-major format, i.e. the row index is varying fastest. This is the same format as in the lapack and gmm++ libraries, so it will be easy to interface these libraries. In fact, if you need optimized high performance code, you should use them. The VIGRA linear algebra functionality is provided for smaller problems and rapid prototyping (no one wants to spend half the day installing a new library just to discover that the new algorithm idea didn't work anyway).

See also:

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


Member Typedef Documentation

typedef Matrix<T, ALLOC> matrix_type

the matrix type associated with this array.

Reimplemented from MultiArray< 2, T, ALLOC >.

the view type associated with this array.

Reimplemented from MultiArray< 2, T, ALLOC >.

typedef BaseType::value_type value_type

the array's value type

Reimplemented from MultiArray< 2, T, ALLOC >.

pointer type

Reimplemented from MultiArray< 2, T, ALLOC >.

const pointer type

Reimplemented from MultiArray< 2, T, ALLOC >.

reference type (result of operator[])

Reimplemented from MultiArray< 2, T, ALLOC >.

const reference type (result of operator[] const)

Reimplemented from MultiArray< 2, T, ALLOC >.

difference type (used for multi-dimensional offsets and indices)

Reimplemented from MultiArray< 2, T, ALLOC >.

difference and index type for a single dimension

Reimplemented from MultiArray< 2, T, ALLOC >.

typedef ALLOC allocator_type

the allocator type used to allocate the memory

Reimplemented from MultiArray< 2, T, ALLOC >.


Constructor & Destructor Documentation

Matrix ( )

default constructor

Matrix ( ALLOC const &  alloc)
explicit

construct with given allocator

Matrix ( const difference_type shape,
ALLOC const &  alloc = allocator_type() 
)
explicit

construct with given shape and init all elements with zero. Note that the order of the axes is difference_type(rows, columns) which is the opposite of the usual VIGRA convention.

Matrix ( difference_type_1  rows,
difference_type_1  columns,
ALLOC const &  alloc = allocator_type() 
)

construct with given shape and init all elements with zero. Note that the order of the axes is (rows, columns) which is the opposite of the usual VIGRA convention.

Matrix ( const difference_type shape,
const_reference  init,
allocator_type const &  alloc = allocator_type() 
)

construct with given shape and init all elements with the constant init. Note that the order of the axes is difference_type(rows, columns) which is the opposite of the usual VIGRA convention.

Matrix ( difference_type_1  rows,
difference_type_1  columns,
const_reference  init,
allocator_type const &  alloc = allocator_type() 
)

construct with given shape and init all elements with the constant init. Note that the order of the axes is (rows, columns) which is the opposite of the usual VIGRA convention.

Matrix ( const difference_type shape,
const_pointer  init,
RawArrayMemoryLayout  layout = RowMajor,
allocator_type const &  alloc = allocator_type() 
)

construct with given shape and copy data from C-style array init. Unless layout is ColumnMajor, the elements in this array are assumed to be given in row-major order (the C standard order) and will automatically be converted to the required column-major format. Note that the order of the axes is difference_type(rows, columns) which is the opposite of the usual VIGRA convention.

Matrix ( difference_type_1  rows,
difference_type_1  columns,
const_pointer  init,
RawArrayMemoryLayout  layout = RowMajor,
allocator_type const &  alloc = allocator_type() 
)

construct with given shape and copy data from C-style array init. Unless layout is ColumnMajor, the elements in this array are assumed to be given in row-major order (the C standard order) and will automatically be converted to the required column-major format. Note that the order of the axes is (rows, columns) which is the opposite of the usual VIGRA convention.

Matrix ( const Matrix< T, ALLOC > &  rhs)

copy constructor. Allocates new memory and copies tha data.

Matrix ( const TemporaryMatrix< T, ALLOC > &  rhs)

construct from temporary matrix, which looses its data.

This operation is equivalent to

TemporaryMatrix<T> temp = ...;
Matrix<T> m;
m.swap(temp);
Matrix ( const MultiArrayView< 2, U, C > &  rhs)

construct from a MultiArrayView. Allocates new memory and copies tha data. rhs is assumed to be in column-major order already.


Member Function Documentation

Matrix& operator= ( const Matrix< T, ALLOC > &  rhs)

assignment. If the size of rhs is the same as the matrix's old size, only the data are copied. Otherwise, new storage is allocated, which invalidates all objects (array views, iterators) depending on the matrix.

Matrix& operator= ( const TemporaryMatrix< T, ALLOC > &  rhs)

assign a temporary matrix. If the shapes of the two matrices match, only the data are copied (in order to not invalidate views and iterators depending on this matrix). Otherwise, the memory is swapped between the two matrices, so that all depending objects (array views, iterators) ar invalidated.

Matrix& operator= ( const MultiArrayView< 2, U, C > &  rhs)

assignment from arbitrary 2-dimensional MultiArrayView.
If the size of rhs is the same as the matrix's old size, only the data are copied. Otherwise, new storage is allocated, which invalidates all objects (array views, iterators) depending on the matrix. rhs is assumed to be in column-major order already.

Matrix& init ( const U &  init)

init elements with a constant

Reimplemented from MultiArray< 2, T, ALLOC >.

void reshape ( difference_type_1  rows,
difference_type_1  columns 
)

reshape to the given shape and initialize with zero.

void reshape ( difference_type_1  rows,
difference_type_1  columns,
const_reference  init 
)

reshape to the given shape and initialize with init.

void reshape ( difference_type const &  shape)

reshape to the given shape and initialize with zero.

Reimplemented from MultiArray< 2, T, ALLOC >.

void reshape ( difference_type const &  shape,
const_reference  init 
)

reshape to the given shape and initialize with init.

Reimplemented from MultiArray< 2, T, ALLOC >.

view_type rowVector ( difference_type_1  d) const

Create a matrix view that represents the row vector of row d.

view_type columnVector ( difference_type_1  d) const

Create a matrix view that represents the column vector of column d.

difference_type_1 rowCount ( ) const

number of rows (height) of the matrix.

difference_type_1 columnCount ( ) const

number of columns (width) of the matrix.

difference_type_1 elementCount ( ) const

number of elements (width*height) of the matrix.

Reimplemented from MultiArrayView< N, T >.

bool isSymmetric ( ) const

check whether the matrix is symmetric.

value_type& operator() ( difference_type_1  row,
difference_type_1  column 
)

read/write access to matrix element (row, column). Note that the order of the argument is the opposite of the usual VIGRA convention due to column-major matrix order.

Reimplemented from MultiArrayView< N, T >.

value_type operator() ( difference_type_1  row,
difference_type_1  column 
) const

read access to matrix element (row, column). Note that the order of the argument is the opposite of the usual VIGRA convention due to column-major matrix order.

Reimplemented from MultiArrayView< N, T >.

NormTraits<Matrix>::SquaredNormType squaredNorm ( ) const

squared Frobenius norm. Sum of squares of the matrix elements.

Reimplemented from MultiArrayView< N, T >.

NormTraits<Matrix>::NormType norm ( ) const

Frobenius norm. Root of sum of squares of the matrix elements.

MultiArrayView<2, vluae_type, StridedArrayTag> transpose ( ) const

create a transposed view of this matrix. No data are copied. If you want to transpose this matrix permanently, you have to assign the transposed view:

a = a.transpose();

Reimplemented from MultiArrayView< N, T >.

Matrix& operator+= ( MultiArrayView< 2, U, C > const &  other)

add other to this (sizes must match).

Matrix& operator-= ( MultiArrayView< 2, U, C > const &  other)

subtract other from this (sizes must match).

Matrix& operator*= ( MultiArrayView< 2, U, C > const &  other)

multiply other element-wise with this matrix (sizes must match).

Matrix& operator/= ( MultiArrayView< 2, U, C > const &  other)

divide this matrix element-wise by other (sizes must match).

Matrix& operator+= ( other)

add other to each element of this matrix

Matrix& operator-= ( other)

subtraxt other from each element of this matrix

Matrix& operator*= ( other)

scalar multiply this with other

Matrix& operator/= ( other)

scalar devide this by other


The documentation for this class was generated from the following file:

© 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.7.1 (Tue Jul 10 2012)