00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EIGEN_STATIC_ASSERT_H
00027 #define EIGEN_STATIC_ASSERT_H
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef EIGEN_NO_STATIC_ASSERT
00043
00044 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00045
00046
00047 #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
00048
00049 #else // CXX0X
00050
00051 template<bool condition>
00052 struct ei_static_assert {};
00053
00054 template<>
00055 struct ei_static_assert<true>
00056 {
00057 enum {
00058 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX,
00059 YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES,
00060 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES,
00061 THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE,
00062 THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE,
00063 YOU_MADE_A_PROGRAMMING_MISTAKE,
00064 YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR,
00065 UNALIGNED_LOAD_AND_STORE_OPERATIONS_UNIMPLEMENTED_ON_ALTIVEC,
00066 NUMERIC_TYPE_MUST_BE_FLOATING_POINT,
00067 COEFFICIENT_WRITE_ACCESS_TO_SELFADJOINT_NOT_SUPPORTED,
00068 WRITING_TO_TRIANGULAR_PART_WITH_UNIT_DIAGONAL_IS_NOT_SUPPORTED,
00069 THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE,
00070 INVALID_MATRIX_PRODUCT,
00071 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS,
00072 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION,
00073 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY,
00074 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES,
00075 THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES,
00076 INVALID_MATRIX_TEMPLATE_PARAMETERS,
00077 INVALID_MATRIXBASE_TEMPLATE_PARAMETERS,
00078 BOTH_MATRICES_MUST_HAVE_THE_SAME_STORAGE_ORDER,
00079 THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX
00080 };
00081 };
00082
00083
00084
00085
00086 #ifdef _MSC_VER
00087
00088 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
00089 {Eigen::ei_static_assert<CONDITION ? true : false>::MSG;}
00090
00091 #else
00092
00093 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
00094 if (Eigen::ei_static_assert<CONDITION ? true : false>::MSG) {}
00095
00096 #endif
00097
00098 #endif // not CXX0X
00099
00100 #else // EIGEN_NO_STATIC_ASSERT
00101
00102 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) ei_assert((CONDITION) && #MSG);
00103
00104 #endif // EIGEN_NO_STATIC_ASSERT
00105
00106
00107
00108 #define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE) \
00109 EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime, \
00110 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX)
00111
00112
00113 #define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE) \
00114 EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime!=Eigen::Dynamic, \
00115 YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR)
00116
00117
00118 #define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE) \
00119 EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime && TYPE::SizeAtCompileTime==SIZE, \
00120 THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE)
00121
00122
00123 #define EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(TYPE, ROWS, COLS) \
00124 EIGEN_STATIC_ASSERT(TYPE::RowsAtCompileTime==ROWS && TYPE::ColsAtCompileTime==COLS, \
00125 THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE)
00126
00127
00128 #define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1) \
00129 EIGEN_STATIC_ASSERT( \
00130 (int(TYPE0::SizeAtCompileTime)==Eigen::Dynamic \
00131 || int(TYPE1::SizeAtCompileTime)==Eigen::Dynamic \
00132 || int(TYPE0::SizeAtCompileTime)==int(TYPE1::SizeAtCompileTime)),\
00133 YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES)
00134
00135 #define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
00136 ((int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \
00137 || int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \
00138 || int(TYPE0::RowsAtCompileTime)==int(TYPE1::RowsAtCompileTime)) \
00139 && (int(TYPE0::ColsAtCompileTime)==Eigen::Dynamic \
00140 || int(TYPE1::ColsAtCompileTime)==Eigen::Dynamic \
00141 || int(TYPE0::ColsAtCompileTime)==int(TYPE1::ColsAtCompileTime)))
00142
00143
00144 #define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
00145 EIGEN_STATIC_ASSERT( \
00146 EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1),\
00147 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES)
00148
00149 #endif // EIGEN_STATIC_ASSERT_H