1#ifndef GfxTL__MATRIXX_HEADER__
2#define GfxTL__MATRIXX_HEADER__
3#ifndef _USE_MATH_DEFINES
4#define _USE_MATH_DEFINES
23 template <
unsigned int D,
class T>
27 template <
unsigned int C,
unsigned int R,
class T>
31 template <
unsigned int C,
unsigned int R,
class T>
32 MatrixXX<C, R, T>&
operator+=(MatrixXX<C, R, T>& m,
const MatrixXX<C, R, T>& b);
33 template <
unsigned int C,
unsigned int R,
class T>
34 MatrixXX<C, R, T>&
operator-=(MatrixXX<C, R, T>& m,
const MatrixXX<C, R, T>& b);
35 template <
unsigned int C,
unsigned int R,
class T>
36 MatrixXX<C, R, T>&
operator*=(MatrixXX<C, R, T>& m,
const MatrixXX<C, R, T>& b);
37 template <
unsigned int C,
unsigned int R,
class T>
38 MatrixXX<C, R, T>&
operator*=(MatrixXX<C, R, T>& m,
T s);
39 template <
unsigned int C,
unsigned int R,
class T>
40 MatrixXX<C, R, T>&
operator/=(MatrixXX<C, R, T>& m,
T s);
41 template <
unsigned int C,
unsigned int R,
class T>
42 bool operator==(
const MatrixXX<C, R, T>& a,
const MatrixXX<C, R, T>& b);
43 template <
unsigned int C,
unsigned int R,
class T>
44 bool operator!=(
const MatrixXX<C, R, T>& a,
const MatrixXX<C, R, T>& b);
49 template <
unsigned int C,
unsigned int R,
class T>
79 memset(
_m, 0,
sizeof(
_m));
98 for (
unsigned int i = 0; i < C * R; ++i)
107 for (
unsigned int i = 0; i < C * R; ++i)
117 for (
unsigned int c = 0;
c < C; ++
c)
118 for (
unsigned int r = 0; r < R; ++r)
120 (*t)[r][
c] = (*this)[
c][r];
130 template <
unsigned int C,
unsigned int R,
class T>
230 template <
unsigned int A,
unsigned int B>
237 Error_InvalidDimension();
244 template <
unsigned int A>
256 class MatrixXX<1, 1,
T> :
public Internal::BaseMatrixXX<1, 1, T>
259 typedef Internal::BaseMatrixXX<1, 1, T>
SuperType;
303 operator const T()
const
315 template <
unsigned int C,
unsigned int R,
class T>
319 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
321 m.Data()[i] += b.Data()[i];
326 template <
unsigned int C,
unsigned int R,
class T>
327 inline MatrixXX<C, R, T>&
330 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
332 m.Data()[i] -= b.Data()[i];
337 template <
unsigned int C,
unsigned int R,
class T>
338 inline MatrixXX<C, R, T>&
345 template <
unsigned int C,
unsigned int R,
class T>
346 inline MatrixXX<C, R, T>&
349 return m *= (
const T)b;
352 template <
unsigned int C,
unsigned int R,
class T>
353 inline MatrixXX<C, R, T>&
356 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
363 template <
unsigned int C,
unsigned int R,
class T>
364 inline MatrixXX<C, R, T>&
367 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
374 template <
unsigned int C,
unsigned int R,
class T>
375 inline MatrixXX<C, R, T>
379 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
386 template <
unsigned int C,
unsigned int R,
class T>
390 return memcmp(a.Data(), b.Data(),
sizeof(a)) == 0;
393 template <
unsigned int C,
unsigned int R,
class T>
397 return memcmp(a.Data(), b.Data(),
sizeof(a)) != 0;
400 template <
unsigned int C,
unsigned int R,
class T>
401 inline const MatrixXX<C, R, T>
409 template <
unsigned int C,
unsigned int R,
class T>
410 inline const MatrixXX<C, R, T>
416 template <
unsigned int C,
unsigned int R,
class T>
417 inline const MatrixXX<C, R, T>
426 template <
unsigned int C,
unsigned int R,
unsigned int C2,
class T>
427 inline const MatrixXX<C2, R, T>
431 for (
int c = 0;
c < C2; ++
c)
433 for (
int r = 0; r < R; ++r)
435 x[
c][r] = a[0][r] * b[
c][0];
436 for (
int i = 1; i < C; ++i)
438 x[
c][r] += a[i][r] * b[
c][i];
445 template <
unsigned int C,
unsigned int R,
class T>
446 inline const MatrixXX<C, R, T>
449 return ((
const T)a) * b;
452 template <
unsigned int C,
unsigned int R,
class T>
453 inline const MatrixXX<C, R, T>
457 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
459 c.Data()[i] = a.Data()[i] + b.Data()[i];
464 template <
unsigned int C,
unsigned int R,
class T>
465 inline const MatrixXX<C, R, T>
469 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
471 c.Data()[i] = a.Data()[i] - b.Data()[i];
476 template <
unsigned int N,
class T>
481 for (
unsigned int i = 0; i < N; ++i)
488 template <
unsigned int N,
class T>
493 for (
unsigned int i = 0; i < N; ++i)
510 template <
unsigned int N,
class T>
516 for (
unsigned int i = 0; i < N; ++i, j *= -1)
519 for (
unsigned int k = 1, kk = 0; kk < N - 1; ++kk, ++k)
521 for (
unsigned int l = 0, ll = 0; ll < N - 1; ++ll, ++l)
539 return a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
540 a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) +
541 a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
548 return a[0][0] * a[1][1] - a[1][0] * a[0][1];
562 (*a)[0][0] = std::cos(rad);
563 (*a)[0][1] = std::sin(rad);
564 (*a)[1][0] = -(*a)[0][1];
565 (*a)[1][1] = (*a)[0][0];
568 template <
unsigned int N,
class T>
572 for (
unsigned int c = 0;
c < N; ++
c)
580 for (++r; r < N; ++r)
587 template <
unsigned int N,
class T>
597 template <
unsigned int C,
unsigned int R,
class T>
602 for (
unsigned int i = 0; i < C; ++i)
614 template <
unsigned int C,
unsigned int R,
class T>
615 inline MatrixXX<C, R, T>
620 for (
unsigned int c = 0;
c < C; ++
c)
621 for (
unsigned int r = 0; r < R; ++r)
623 m[
c][r] =
min(a[
c][r], b[
c][r]);
628 template <
unsigned int C,
unsigned int R,
class T>
629 inline MatrixXX<C, R, T>
634 for (
unsigned int c = 0;
c < C; ++
c)
635 for (
unsigned int r = 0; r < R; ++r)
637 m[
c][r] =
max(a[
c][r], b[
c][r]);
class A(deque< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
Enables hashing of std::list.
Matrix in column major order.
BaseMatrixXX< C, R, T > ThisType
const VectorXD< R, T > & operator[](unsigned int col) const
void Transpose(BaseMatrixXX< R, C, T > *t) const
VectorXD< R, T > & operator[](unsigned int col)
MatrixXX(const MatrixXX< 1, R, T > &a, const MatrixXX< 1, R, T > &b, const MatrixXX< 1, R, T > &c, const MatrixXX< 1, R, T > &d)
ThisType & operator=(T v)
MatrixXX< C, R, ScalarT > ThisType
TransposedType Transposed()
MatrixXX< C, R, T > & ComponentMul(const MatrixXX< C, R, T > &a)
MatrixXX(const MatrixXX< 1, R, T > &a, const MatrixXX< 1, R, T > &b, const MatrixXX< 1, R, T > &c)
MatrixXX(const ThisType &mat)
MatrixXX< R, C, ScalarT > TransposedType
Internal::BaseMatrixXX< C, R, ScalarT > SuperType
ThisType & operator=(const ThisType &v)
MatrixXX(const SuperType &mat)
MatrixXX(const MatrixXX< 1, R, T > &a, const MatrixXX< 1, R, T > &b)
const MatrixXX< C, R, T > SqrComponentMul(const MatrixXX< C, R, T > &a)
MatrixXX< C, R, T > min(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
T Determinant(const MatrixXX< N, N, T > &a)
const MatrixXX< C, R, T > operator+(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< 4, 4, float > Matrix4f
const MatrixXX< C, R, T > operator*(T s, const MatrixXX< C, R, T > &a)
std::ostream & operator<<(std::ostream &o, const Array< DimT, IteratorT > &a)
MatrixXX< 3, 3, float > Mat3f
MatrixXX< 4, 4, float > Mat4f
MatrixXX< C, R, T > operator-(const MatrixXX< C, R, T > &a)
MatrixXX< 2, 2, float > Matrix2f
MatrixXX< C, R, T > & operator/=(MatrixXX< C, R, T > &m, T s)
MatrixXX< 2, 2, float > Mat2f
MatrixXX< C, R, T > & operator*=(MatrixXX< C, R, T > &m, const MatrixXX< C, R, T > &b)
bool operator!=(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
void Identity(MatrixXX< N, N, T > *a)
MatrixXX< 3, 3, float > Matrix3f
MatrixXX< C, R, T > max(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< C, R, T > & operator+=(MatrixXX< C, R, T > &m, const MatrixXX< C, R, T > &b)
const MatrixXX< C, R, T > ComponentMul(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
bool operator==(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
T TraceAbs(const MatrixXX< N, N, T > &a)
T Trace(const MatrixXX< N, N, T > &a)
MatrixXX< 3, 3, float > mat3
MatrixXX< C, R, T > & operator-=(MatrixXX< C, R, T > &m, const MatrixXX< C, R, T > &b)
void Rotation(T rad, MatrixXX< 2, 2, T > *a)
MatrixXX< 2, 2, float > mat2
MatrixXX< 4, 4, float > mat4
double a(double t, double a0, double j)
double v(double t, double v0, double a0, double j)
This file offers overloads of toIce() and fromIce() functions for STL container types.
static void AssertEqual()
static void AssertEqual()