11#ifndef PRIMATOLOGIST_MATH_MATRIX_H
12#define PRIMATOLOGIST_MATH_MATRIX_H
14#include <cartodata/volume/volume.h>
15#include <cartobase/type/string_conversion.h>
130 template <
typename T,
typename U>
135 template <
typename T>
140 template <
typename T>
148 template <
typename T,
typename U>
152 template <
typename T,
typename U>
155 template <
typename T>
158 template <
typename T,
typename U>
162 template <
typename T,
typename U>
166 template <
typename T,
typename U>
170 template <
typename T,
typename U>
174 template <
typename T,
typename U>
178 template <
typename T,
typename U>
182 template <
typename T,
typename U>
186 template <
typename T,
typename U>
190 template <
typename T,
typename U>
194 template <
typename T,
typename U>
202 template <
typename T>
203 std::ostream &
operator<< ( std::ostream & out,
206 template <
typename T>
218 std::logic_error(
std::string(
"[aims::math::MatrixBase] Matrices "
219 "should have compatible numbers of rows and columns for a matrix "
220 "product. (") + carto::toString(ncol) +
std::string(
" and ") +
221 carto::toString(nrow) +
std::string(
").") )
Matrix class implementing matrix operations.
MatrixBase< T > & transpose()
Matrix transposition.
int size() const
Number of elements.
MatrixBase< T > & invert()
Matrix inversion.
MatrixBase(const std::vector< U > &vector)
Copy constructor.
double trace() const
Returns the trace of the matrix, i.e.
friend MatrixBase< T > asMatrix(carto::VolumeRef< T > &)
Interprets the volume as a matrix.
MatrixBase< T > & operator*=(const MatrixBase< U > &)
Matrix product.
MatrixBase(const carto::VolumeRef< U > &volume)
Copy constructor.
MatrixBase(int nrow=1, int ncol=1)
Standard constructor Allocate a matrix of size nrow x ncol.
MatrixBase< T > & operator=(const carto::VolumeRef< U > &matrix)
Assignment operator The content from other is entirely copied.
incompatible_matrix_exception(int nrow, int ncol)
MatrixBase< float > Vector
MatrixBase< double > VectorD
MatrixBase< T > transpose(const MatrixBase< T > &)
Matrix transposition.
MatrixBase< T > asMatrix(carto::VolumeRef< T > &volume)
Interprets the volume as a matrix.
MatrixBase< float > Matrix
MatrixBase< typename carto::volumeutil::multiplies< T, U >::result_type > operator*(const MatrixBase< T > &a, const MatrixBase< U > &b)
Matrix product.
MatrixBase< T > invert(const MatrixBase< T > &)
Matrix inversion.
bool operator!=(const MatrixBase< T > &vol, const MatrixBase< U > &other)
Returns false if dimensions are not the same or if any couple of elements is not equal.
MatrixBase< double > MatrixD
bool operator==(const MatrixBase< T > &vol, const MatrixBase< U > &other)
Returns true if the dimensions are the same and if all elements are equal.
MatrixBase< T > operator-(const MatrixBase< T > &vol)
Returns a Matrix filled with opposite elements.
void write(const MatrixBase< T > &matrix, const std::string &file)
Write the matrix content in an image file.
MatrixBase< typename carto::volumeutil::divides< T, U >::result_type > operator/(const MatrixBase< T > &vol, const U &value)
Matrix / Scalar.
std::ostream & operator<<(std::ostream &out, const MatrixBase< T > &matrix)
Print the matrix content on the standard output.
MatrixBase< typename carto::volumeutil::plus< T, U >::result_type > operator+(const MatrixBase< T > &vol, const U &value)
Matrix + Scalar.