aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/util
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-01-04 15:26:32 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-01-04 15:26:32 +0000
commit15ca6659acea545178116096bff3e42068b4f4cb (patch)
tree0f4093c77a3312b69dff071db7fd1ad14a3d6d25 /Eigen/src/Core/util
parentd9e5fd393a48db368dd90cf7119ebb3d774111cb (diff)
* the 4th template param of Matrix is now Options. One bit for storage
order, one bit for enabling/disabling auto-alignment. If you want to disable, do: Matrix<float,4,1,Matrix_DontAlign> The Matrix_ prefix is the only way I can see to avoid ambiguity/pollution. The old RowMajor, ColMajor constants are deprecated, remain for now. * this prompted several improvements in matrix_storage. ei_aligned_array renamed to ei_matrix_array and moved there. The %16==0 tests are now much more centralized in 1 place there. * unalignedassert test: updated * update FindEigen2.cmake from KDElibs * determinant test: use VERIFY_IS_APPROX to fix false positives; add testing of 1 big matrix
Diffstat (limited to 'Eigen/src/Core/util')
-rw-r--r--Eigen/src/Core/util/Constants.h11
-rw-r--r--Eigen/src/Core/util/ForwardDeclarations.h3
-rw-r--r--Eigen/src/Core/util/Macros.h6
-rw-r--r--Eigen/src/Core/util/Memory.h19
-rw-r--r--Eigen/src/Core/util/XprHelper.h22
5 files changed, 25 insertions, 36 deletions
diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h
index 203f3b294..a535e2417 100644
--- a/Eigen/src/Core/util/Constants.h
+++ b/Eigen/src/Core/util/Constants.h
@@ -223,8 +223,15 @@ enum {
};
enum {
- ColMajor = 0,
- RowMajor = RowMajorBit
+ Matrix_ColMajor = 0,
+ Matrix_RowMajor = 0x1, // it is only a coincidence that this is equal to RowMajorBit -- don't rely on that
+ /** \internal Don't require alignment for the matrix itself (the array of coefficients, if dynamically allocated, may still be
+ requested to be aligned) */
+ ColMajor = Matrix_ColMajor, // deprecated
+ RowMajor = Matrix_RowMajor, // deprecated
+ Matrix_DontAlign = 0,
+ /** \internal Align the matrix itself */
+ Matrix_AutoAlign = 0x2
};
enum {
diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h
index b61316dfc..bb4567ad0 100644
--- a/Eigen/src/Core/util/ForwardDeclarations.h
+++ b/Eigen/src/Core/util/ForwardDeclarations.h
@@ -28,7 +28,8 @@
template<typename T> struct ei_traits;
template<typename T> struct NumTraits;
-template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder = ColMajor,
+template<typename _Scalar, int _Rows, int _Cols,
+ int _Options = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION | Matrix_AutoAlign,
int _MaxRows = _Rows, int _MaxCols = _Cols> class Matrix;
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged;
diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h
index 422bc7bd1..3160ce7f6 100644
--- a/Eigen/src/Core/util/Macros.h
+++ b/Eigen/src/Core/util/Macros.h
@@ -28,6 +28,12 @@
#undef minor
+#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
+#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Matrix_RowMajor
+#else
+#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Matrix_ColMajor
+#endif
+
/** \internal Defines the maximal loop size to enable meta unrolling of loops.
* Note that the value here is expressed in Eigen's own notion of "number of FLOPS",
* it does not correspond to the number of iterations or the number of instructions
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h
index 35b6b4ab9..0e49ffeae 100644
--- a/Eigen/src/Core/util/Memory.h
+++ b/Eigen/src/Core/util/Memory.h
@@ -31,25 +31,6 @@
extern "C" int posix_memalign (void **, size_t, size_t) throw ();
#endif
-/** \internal
- * Static array automatically aligned if the total byte size is a multiple of 16
- */
-template <typename T, int Size, bool Align> struct ei_aligned_array
-{
- EIGEN_ALIGN_128 T array[Size];
-
- ei_aligned_array()
- {
- ei_assert((reinterpret_cast<size_t>(array) & 0xf) == 0
- && "this assertion is explained here: http://eigen.tuxfamily.org/api/UnalignedArrayAssert.html **** READ THIS WEB PAGE !!! ****");
- }
-};
-
-template <typename T, int Size> struct ei_aligned_array<T,Size,false>
-{
- T array[Size];
-};
-
struct ei_byte_forcing_aligned_malloc
{
unsigned char c; // sizeof must be 1.
diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h
index ae8703958..739eb1108 100644
--- a/Eigen/src/Core/util/XprHelper.h
+++ b/Eigen/src/Core/util/XprHelper.h
@@ -85,22 +85,16 @@ template<typename T> struct ei_unpacket_traits
enum {size=1};
};
-
-template<typename Scalar, int Rows, int Cols, int StorageOrder, int MaxRows, int MaxCols>
+template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
class ei_compute_matrix_flags
{
enum {
- row_major_bit = (Rows != 1 && Cols != 1) // if this is not a vector,
- // then the storage order really matters,
- // so let us strictly honor the user's choice.
- ? StorageOrder
- : Cols > 1 ? RowMajorBit : 0,
+ row_major_bit = Options&Matrix_RowMajor ? RowMajorBit : 0,
inner_max_size = row_major_bit ? MaxCols : MaxRows,
is_big = inner_max_size == Dynamic,
- is_packet_size_multiple = (Cols * Rows)%ei_packet_traits<Scalar>::size==0,
- packet_access_bit = ei_packet_traits<Scalar>::size > 1
- && (is_big || is_packet_size_multiple) ? PacketAccessBit : 0,
- aligned_bit = packet_access_bit && (is_big || is_packet_size_multiple) ? AlignedBit : 0
+ is_packet_size_multiple = (Cols*Rows) % ei_packet_traits<Scalar>::size == 0,
+ aligned_bit = ((Options&Matrix_AutoAlign) && (is_big || is_packet_size_multiple)) ? AlignedBit : 0,
+ packet_access_bit = ei_packet_traits<Scalar>::size > 1 && aligned_bit ? PacketAccessBit : 0
};
public:
@@ -123,7 +117,7 @@ template<typename T> struct ei_eval<T,IsDense>
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
- ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor,
+ Matrix_AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? Matrix_RowMajor : Matrix_ColMajor),
ei_traits<T>::MaxRowsAtCompileTime,
ei_traits<T>::MaxColsAtCompileTime
> type;
@@ -144,7 +138,7 @@ template<typename T> struct ei_plain_matrix_type
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
- ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor,
+ Matrix_AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? Matrix_RowMajor : Matrix_ColMajor),
ei_traits<T>::MaxRowsAtCompileTime,
ei_traits<T>::MaxColsAtCompileTime
> type;
@@ -157,7 +151,7 @@ template<typename T> struct ei_plain_matrix_type_column_major
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
- ColMajor,
+ Matrix_AutoAlign | Matrix_ColMajor,
ei_traits<T>::MaxRowsAtCompileTime,
ei_traits<T>::MaxColsAtCompileTime
> type;