1 #ifndef CLASSIC_FMatrix_HH
2 #define CLASSIC_FMatrix_HH
38 template<
class T,
int R,
int C>
87 template <
class T,
int R,
int C>
91 template <
class T,
int R,
int C>
95 template <
class T,
int R,
int C>
99 template <
class T,
int R,
int C>
103 template <
class T,
int R,
int C>
107 template <
class T,
int R,
int C>
111 template <
class T,
int R,
int C>
115 template <
class T,
int R,
int C>
119 template <
class T,
int C>
123 template <
class T,
int C>
130 template<
class T,
int R,
int C>
136 template<
class T,
int R,
int C>
142 template<
class T,
int R,
int C>
148 template<
class T,
int R,
int C>
154 template<
class T,
int R,
int C>
160 template<
class T,
int R,
int C>
167 template<
class T,
int R,
int C>
174 template<
class T,
int R,
int C>
176 std::transform(this->begin(), this->end(), this->begin(),
177 std::bind(std::multiplies<T>(), std::placeholders::_1, rhs));
182 template<
class T,
int R,
int C>
184 std::transform(this->begin(), this->end(), this->begin(),
185 std::bind(std::divides<T>(), std::placeholders::_1, rhs));
190 template<
class T,
int R,
int C>
192 std::transform(this->begin(), this->end(), array.
begin(), this->begin(),
198 template<
class T,
int R,
int C>
200 std::transform(this->begin(), this->end(), array.
begin(), this->begin(),
206 template <
class T,
int R,
int C>
210 for(
int i = 0; i <
R; ++i) {
211 std::copy(this->row_begin(i), this->row_end(i), result.
col_begin(i));
221 template<
class T,
int R,
int C>
224 std::transform(rhs.
begin(), rhs.
end(), result.
begin(), std::negate<T>());
229 template<
class T,
int R,
int C>
232 return result += rhs;
236 template<
class T,
int R,
int C>
239 return result -= rhs;
243 template <
class T,
int R,
int I,
int C>
247 for(
int i = 0; i <
R; i++) {
251 for(
int j = 0; j < C; j++) {
252 result(i, j) = std::inner_product(i1, i2, rhs.
col_begin(j),
T(0));
260 template<
class T,
int R,
int C>
264 for(
int i = 0; i <
R; ++i) {
273 template<
class T,
int R,
int C>
277 for(
int j = 0; j < C; j++) {
278 result[j] = std::inner_product(lhs.
begin(), lhs.
end(),
286 template<
class T,
int R,
int C>
289 return result *= rhs;
293 template<
class T,
int R,
int C>
296 return result *= lhs;
300 template<
class T,
int R,
int C>
303 return result /= rhs;
310 template<
class T,
int C>
313 for(
int i = 0; i < C; i++) result[i][i] += rhs;
318 template<
class T,
int C>
321 for(
int i = 0; i < C; i++) result[i][i] -= rhs;
325 #endif // CLASSIC_FMatrix_HH
Matrix< T > operator+(const Matrix< T > &, const Matrix< T > &)
Matrix addition.
FMatrix & operator=(const FMatrix &)
Assignment.
Matrix< T > operator/(const Matrix< T > &, const T &)
Matrix divided by scalar.
A templated representation for matrices.
A templated representation for vectors.
FMatrix()
Default constructor.
FMatrix & operator*=(const T &)
Multiply by scalar and assign.
FMatrix & operator+=(const FMatrix &)
Add matrix and assign.
Matrix< T > operator*(const Matrix< T > &, const Matrix< T > &)
Matrix multiply.
iterator begin()
Get iterator pointing to beginning of array.
iterator begin()
Get beginning of data.
iterator end()
Get pointer past end of data.
row_iterator row_end(int r)
Get row iterator.
FMatrix< T, C, R > transpose() const
FMatrix transpose.
FMatrix & operator/=(const T &)
Divide by scalar and assign.
col_iterator col_begin(int c)
Get column iterator.
const FArray2D< T, M, N > & operator=(const FArray2D< T, M, N > &)
Assignment.
iterator end()
Get iterator pointing past end of array.
const T * const_row_iterator
Iterator for access by rows.
Matrix< T > operator-(const Matrix< T > &, const Matrix< T > &)
Matrix subtraction.
FMatrix & operator-=(const FMatrix &)
Subtract ,atrix and assign.
A templated representation for 2-dimensional arrays.
row_iterator row_begin(int r)
Get row iterator.