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 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(_MSC_VER) && (_MSC_VER >= 1600))
00045
00046
00047 #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
00048
00049 #else // not CXX0X
00050
00051 namespace internal {
00052
00053 template<bool condition>
00054 struct static_assertion {};
00055
00056 template<>
00057 struct static_assertion<true>
00058 {
00059 enum {
00060 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX,
00061 YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES,
00062 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES,
00063 THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE,
00064 THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE,
00065 THIS_METHOD_IS_ONLY_FOR_OBJECTS_OF_A_SPECIFIC_SIZE,
00066 YOU_MADE_A_PROGRAMMING_MISTAKE,
00067 EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT,
00068 EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE,
00069 YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR,
00070 YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR,
00071 UNALIGNED_LOAD_AND_STORE_OPERATIONS_UNIMPLEMENTED_ON_ALTIVEC,
00072 THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES,
00073 NUMERIC_TYPE_MUST_BE_REAL,
00074 COEFFICIENT_WRITE_ACCESS_TO_SELFADJOINT_NOT_SUPPORTED,
00075 WRITING_TO_TRIANGULAR_PART_WITH_UNIT_DIAGONAL_IS_NOT_SUPPORTED,
00076 THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE,
00077 INVALID_MATRIX_PRODUCT,
00078 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS,
00079 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION,
00080 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY,
00081 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES,
00082 THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES,
00083 INVALID_MATRIX_TEMPLATE_PARAMETERS,
00084 INVALID_MATRIXBASE_TEMPLATE_PARAMETERS,
00085 BOTH_MATRICES_MUST_HAVE_THE_SAME_STORAGE_ORDER,
00086 THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX,
00087 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE,
00088 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES,
00089 YOU_ALREADY_SPECIFIED_THIS_STRIDE,
00090 INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION,
00091 THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD,
00092 PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1,
00093 THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS,
00094 YOU_CANNOT_MIX_ARRAYS_AND_MATRICES,
00095 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION,
00096 THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY,
00097 YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT,
00098 THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS
00099 };
00100 };
00101
00102 }
00103
00104
00105
00106
00107 #ifdef _MSC_VER
00108
00109 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
00110 {Eigen::internal::static_assertion<bool(CONDITION)>::MSG;}
00111
00112 #else
00113
00114 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
00115 if (Eigen::internal::static_assertion<bool(CONDITION)>::MSG) {}
00116
00117 #endif
00118
00119 #endif // not CXX0X
00120
00121 #else // EIGEN_NO_STATIC_ASSERT
00122
00123 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) eigen_assert((CONDITION) && #MSG);
00124
00125 #endif // EIGEN_NO_STATIC_ASSERT
00126
00127
00128
00129 #define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE) \
00130 EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime, \
00131 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX)
00132
00133
00134 #define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE) \
00135 EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime!=Eigen::Dynamic, \
00136 YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR)
00137
00138
00139 #define EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(TYPE) \
00140 EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime==Eigen::Dynamic, \
00141 YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR)
00142
00143
00144 #define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE) \
00145 EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime && TYPE::SizeAtCompileTime==SIZE, \
00146 THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE)
00147
00148
00149 #define EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(TYPE, ROWS, COLS) \
00150 EIGEN_STATIC_ASSERT(TYPE::RowsAtCompileTime==ROWS && TYPE::ColsAtCompileTime==COLS, \
00151 THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE)
00152
00153
00154 #define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1) \
00155 EIGEN_STATIC_ASSERT( \
00156 (int(TYPE0::SizeAtCompileTime)==Eigen::Dynamic \
00157 || int(TYPE1::SizeAtCompileTime)==Eigen::Dynamic \
00158 || int(TYPE0::SizeAtCompileTime)==int(TYPE1::SizeAtCompileTime)),\
00159 YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES)
00160
00161 #define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
00162 ( \
00163 (int(TYPE0::SizeAtCompileTime)==0 && int(TYPE1::SizeAtCompileTime)==0) \
00164 || (\
00165 (int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \
00166 || int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \
00167 || int(TYPE0::RowsAtCompileTime)==int(TYPE1::RowsAtCompileTime)) \
00168 && (int(TYPE0::ColsAtCompileTime)==Eigen::Dynamic \
00169 || int(TYPE1::ColsAtCompileTime)==Eigen::Dynamic \
00170 || int(TYPE0::ColsAtCompileTime)==int(TYPE1::ColsAtCompileTime))\
00171 ) \
00172 )
00173
00174 #ifdef EIGEN2_SUPPORT
00175 #define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \
00176 eigen_assert(!NumTraits<Scalar>::IsInteger);
00177 #else
00178 #define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \
00179 EIGEN_STATIC_ASSERT(!NumTraits<TYPE>::IsInteger, THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES)
00180 #endif
00181
00182
00183
00184 #define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
00185 EIGEN_STATIC_ASSERT( \
00186 EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1),\
00187 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES)
00188
00189 #define EIGEN_STATIC_ASSERT_SIZE_1x1(TYPE) \
00190 EIGEN_STATIC_ASSERT((TYPE::RowsAtCompileTime == 1 || TYPE::RowsAtCompileTime == Dynamic) && \
00191 (TYPE::ColsAtCompileTime == 1 || TYPE::ColsAtCompileTime == Dynamic), \
00192 THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS)
00193
00194 #define EIGEN_STATIC_ASSERT_LVALUE(Derived) \
00195 EIGEN_STATIC_ASSERT(internal::is_lvalue<Derived>::value, \
00196 THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY)
00197
00198 #endif // EIGEN_STATIC_ASSERT_H