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