Panda3D
lsimpleMatrix.h
1 // Filename: lsimpleMatrix.h
2 // Created by: drose (15Dec11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef LSIMPLEMATRIX_H
16 #define LSIMPLEMATRIX_H
17 
18 #include "pandabase.h"
19 
20 #ifdef HAVE_EIGEN
21 #include <Eigen/Dense>
22 #endif
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : LSimpleMatrix
26 // Description : This class provides an underlying storage of the
27 // various linear-algebra classes (e.g. LVecBase3,
28 // LMatrix4) in the absence of the Eigen linear algebra
29 // library.
30 ////////////////////////////////////////////////////////////////////
31 template <class FloatType, int NumRows, int NumCols>
33 public:
34  INLINE LSimpleMatrix();
35  INLINE LSimpleMatrix(const LSimpleMatrix<FloatType, NumRows, NumCols> &copy);
36  INLINE void operator = (const LSimpleMatrix<FloatType, NumRows, NumCols> &copy);
37  INLINE const FloatType &operator () (int row, int col) const;
38  INLINE FloatType &operator () (int row, int col);
39  INLINE const FloatType &operator () (int col) const;
40  INLINE FloatType &operator () (int col);
41 
42 private:
43  FloatType _array[NumRows][NumCols];
44 };
45 
46 #include "lsimpleMatrix.I"
47 
48 // Now, do we actually use LSimpleMatrix, or do we use Eigen::Matrix?
49 #ifdef HAVE_EIGEN
50 #define UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::DontAlign | Eigen::RowMajor>
51 
52 #ifdef LINMATH_ALIGN
53 #define LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::RowMajor>
54 #else // LINMATH_ALIGN
55 #define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols)
56 #endif // LINMATH_ALIGN
57 
58 #else // HAVE_EIGEN
59 #define UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) LSimpleMatrix<FloatType, NumRows, NumCols>
60 #define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols)
61 #endif // HAVE_EIGEN
62 
63 // This is as good a place as any to define this alignment macro.
64 #if defined(LINMATH_ALIGN) && defined(HAVE_EIGEN) && defined(__AVX__)
65 #define ALIGN_LINMATH ALIGN_32BYTE
66 #elif defined(LINMATH_ALIGN)
67 #define ALIGN_LINMATH ALIGN_16BYTE
68 #else
69 #define ALIGN_LINMATH
70 #endif // LINMATH_ALIGN
71 
72 #endif
73 
74 
This class provides an underlying storage of the various linear-algebra classes (e.g.
Definition: lsimpleMatrix.h:32