50#ifndef LASS_GUARDIAN_OF_INCLUSION_NUM_MATRIX_H
51#define LASS_GUARDIAN_OF_INCLUSION_NUM_MATRIX_H
67 typename S = impl::MStorage<T>
75 typedef typename TStorage::TSize TSize;
76 typedef typename num::NumTraits<TSize>::signedType TSigned;
78 typedef typename util::CallTraits<T>::TValue TValue;
79 typedef typename util::CallTraits<T>::TParam TParam;
80 typedef typename util::CallTraits<T>::TReference TReference;
81 typedef typename util::CallTraits<T>::TConstReference TConstReference;
82 typedef num::NumTraits<T> TNumTraits;
83 typedef TValue* TPointer;
85 template <
typename U>
struct Rebind
94 T& operator[](TSize
column) {
return matrix_(row_,
column); }
95 const T& operator[](TSize
column)
const {
return matrix_(row_,
column); }
96 T&
at(TSigned
column) { LASS_ASSERT(
static_cast<TSigned
>(row_) >= 0);
return matrix_.
at(
static_cast<TSigned
>(row_),
column); }
97 const T&
at(TSigned
column)
const { LASS_ASSERT(
static_cast<TSigned
>(row_) >= 0);
return matrix_.
at(
static_cast<TSigned
>(row_),
column); }
98 const TSize size()
const {
return matrix_.
columns(); }
99 iterator begin() {
return iterator(*
this, 0); }
100 iterator end() {
return iterator(*
this, size()); }
102 friend class Matrix<T, S>;
111 ConstRow(
const Row& other): matrix_(other.matrix_), row_(other.row_) {}
112 const T& operator[](TSize
column)
const {
return matrix_(row_,
column); }
113 const T&
at(TSigned
column)
const { LASS_ASSERT(
static_cast<TSigned
>(row_) >= 0);
return matrix_.
at(
static_cast<TSigned
>(row_),
column); }
114 const TSize size()
const {
return matrix_.
columns(); }
116 friend class Matrix<T, S>;
126 T& operator[](TSize
row) {
return matrix_(
row, column_); }
127 const T& operator[](TSize
row)
const {
return matrix_(
row, column_); }
128 T&
at(TSigned
row) { LASS_ASSERT(
static_cast<TSigned
>(column_) >= 0);
return matrix_.
at(
row,
static_cast<TSigned
>(column_)); }
129 const T&
at(TSigned
row)
const { LASS_ASSERT(
static_cast<TSigned
>(column_) >= 0);
return matrix_.
at(
row,
static_cast<TSigned
>(column_)); }
130 const TSize size()
const {
return matrix_.
rows(); }
131 iterator begin() {
return iterator(*
this, 0); }
132 iterator end() {
return iterator(*
this, matrix_.
columns()); }
134 friend class Matrix<T, S>;
143 ConstColumn(
const Column& other): matrix_(other.matrix_), column_(other.column_) {}
144 const T& operator[](TSize
row)
const {
return matrix_(
row, column_); }
145 const T&
at(TSigned
row)
const { LASS_ASSERT(
static_cast<TSigned
>(column_) >= 0);
return matrix_.
at(
row,
static_cast<TSigned
>(column_)); }
146 const TSize size()
const {
return matrix_.
rows(); }
148 friend class Matrix<T, S>;
156 explicit Matrix(
const TStorage& storage);
169 ConstRow
row(TSigned index)
const;
194 const TStorage& storage()
const;
203template <
typename T,
typename S1,
typename S2>
205template <
typename T,
typename S1,
typename S2>
208template <
typename T,
typename S1,
typename S2>
210template <
typename T,
typename S1,
typename S2>
212template <
typename T,
typename S1,
typename S2>
215template <
typename T,
typename S>
217template <
typename T,
typename S>
219template <
typename T,
typename S>
222template <
typename T,
typename S>
224template <
typename T,
typename S>
226template <
typename T,
typename S>
228template <
typename T,
typename S>
231template <
typename T,
typename S,
typename S2>
235template <
typename T,
typename S,
typename Char,
typename Traits>
236std::basic_ostream<Char, Traits>&
237operator<<(std::basic_ostream<Char, Traits>& stream,
const Matrix<T, S>& matrix);
245#ifdef LASS_GUARDIAN_OF_INCLUSION_NUM_VECTOR_H
a dynamic sized n-dimensional matrix with expression templates
bool isDiagonal() const
test if this matrix is an diagonal matrix
Column column(TSigned index)
return a column of matrix.
Matrix< T, S > & operator=(const Matrix< T2, S2 > &other)
assign storage/expression matrix to this (this should be a storage matrix).
Matrix< T, S > & operator/=(TParam scalar)
scalar multiplication assignment of matrix
void setIdentity(TSize size)
set matrix to an identity matrix.
bool isIdentity() const
test if this matrix equals a identity matrix
Matrix< T, S > & operator*=(TParam scalar)
scalar multiplication assignment of matrix
Matrix< T, S > & operator-=(const Matrix< T, S2 > &other)
componentswise subtraction assignment of two matrices This method is equivalent to this+=(-iB) .
bool isSquare() const
return true if matrix has as many rows as columns
TReference at(TSigned row, TSigned column)
access the component value at position (row, column) (row, column) will be wrapped to range [0,...
Matrix(const Matrix< T2, S2 > &other)
assign storage/expression matrix to this (this should be a storage matrix).
void invert()
replace matrix by its inverse.
const TValue at(TSigned row, TSigned column) const
return the component value at position (row, column) (row, column) will be wrapped to range [0,...
Row row(TSigned index)
return a row of matrix.
const Matrix< T, impl::MNeg< T, S > > operator-() const
return a vector with all components negated (-a)(i, j) == -(a(i, j)).
Matrix()
constructs an empty matrix
const TSize columns() const
return number of columns in matrix.
void setZero(TSize rows, TSize columns)
set this to a zero matrix of rows rows and columns columns.
const Matrix< T, S > & operator+() const
A weird way to get back the same object.
TReference operator()(TSize row, TSize column)
access the component value at position (row, column)
const TSize rows() const
return number of rows in matrix.
ConstRow row(TSigned index) const
return a row of matrix.
const Matrix< T, impl::MTrans< T, S > > transposed() const
return transposed matrix
void swap(Matrix< T, S > &other)
swap two matrices
bool isEmpty() const
return true if this is a (0�0) matrix
ConstColumn column(TSigned index) const
return a column of matrix.
Matrix(TSize rows, TSize columns)
Construct a matrix of dimension rows x columns.
Matrix< T, S > & operator+=(const Matrix< T, S2 > &other)
componentswise addition assignment of two matrices
const TValue operator()(TSize row, TSize column) const
return the component value at position (row, column)
bool isZero() const
test if this matrix equals a zero matrix.
iterator adaptor to access members.
numeric types and traits.
Library for Assembled Shared Sources.