Panda3D
|
00001 // Filename: lsimpleMatrix.h 00002 // Created by: drose (15Dec11) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef LSIMPLEMATRIX_H 00016 #define LSIMPLEMATRIX_H 00017 00018 #include "pandabase.h" 00019 00020 #ifdef HAVE_EIGEN 00021 #include <Eigen/Dense> 00022 #endif 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : LSimpleMatrix 00026 // Description : This class provides an underlying storage of the 00027 // various linear-algebra classes (e.g. LVecBase3, 00028 // LMatrix4) in the absence of the Eigen linear algebra 00029 // library. 00030 //////////////////////////////////////////////////////////////////// 00031 template <class FloatType, int NumRows, int NumCols> 00032 class LSimpleMatrix { 00033 public: 00034 INLINE LSimpleMatrix(); 00035 INLINE LSimpleMatrix(const LSimpleMatrix<FloatType, NumRows, NumCols> ©); 00036 INLINE void operator = (const LSimpleMatrix<FloatType, NumRows, NumCols> ©); 00037 INLINE const FloatType &operator () (int row, int col) const; 00038 INLINE FloatType &operator () (int row, int col); 00039 INLINE const FloatType &operator () (int col) const; 00040 INLINE FloatType &operator () (int col); 00041 00042 private: 00043 FloatType _array[NumRows][NumCols]; 00044 }; 00045 00046 #include "lsimpleMatrix.I" 00047 00048 // Now, do we actually use LSimpleMatrix, or do we use Eigen::Matrix? 00049 #ifdef HAVE_EIGEN 00050 #define UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::DontAlign | Eigen::RowMajor> 00051 00052 #ifdef LINMATH_ALIGN 00053 #define LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix<FloatType, NumRows, NumCols, Eigen::RowMajor> 00054 #else // LINMATH_ALIGN 00055 #define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) 00056 #endif // LINMATH_ALIGN 00057 00058 #else // HAVE_EIGEN 00059 #define UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) LSimpleMatrix<FloatType, NumRows, NumCols> 00060 #define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) 00061 #endif // HAVE_EIGEN 00062 00063 // This is as good a place as any to define this alignment macro. 00064 #ifdef LINMATH_ALIGN 00065 #define ALIGN_LINMATH ALIGN_16BYTE 00066 #else 00067 #define ALIGN_LINMATH 00068 #endif // LINMATH_ALIGN 00069 00070 #endif 00071 00072