Eigne Matrix Class Library

Dependents:   MPC_current_control HydraulicControlBoard_SW AHRS Test_ekf ... more

Committer:
jsoh91
Date:
Tue Sep 24 00:18:23 2019 +0000
Revision:
1:3b8049da21b8
Parent:
0:13a5d365ba16
ignore and revise some of error parts

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ykuroda 0:13a5d365ba16 1 // This file is part of Eigen, a lightweight C++ template library
ykuroda 0:13a5d365ba16 2 // for linear algebra.
ykuroda 0:13a5d365ba16 3 //
ykuroda 0:13a5d365ba16 4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
ykuroda 0:13a5d365ba16 5 // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
ykuroda 0:13a5d365ba16 6 //
ykuroda 0:13a5d365ba16 7 // This Source Code Form is subject to the terms of the Mozilla
ykuroda 0:13a5d365ba16 8 // Public License v. 2.0. If a copy of the MPL was not distributed
ykuroda 0:13a5d365ba16 9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
ykuroda 0:13a5d365ba16 10
ykuroda 0:13a5d365ba16 11 #ifndef EIGEN_STATIC_ASSERT_H
ykuroda 0:13a5d365ba16 12 #define EIGEN_STATIC_ASSERT_H
ykuroda 0:13a5d365ba16 13
ykuroda 0:13a5d365ba16 14 /* Some notes on Eigen's static assertion mechanism:
ykuroda 0:13a5d365ba16 15 *
ykuroda 0:13a5d365ba16 16 * - in EIGEN_STATIC_ASSERT(CONDITION,MSG) the parameter CONDITION must be a compile time boolean
ykuroda 0:13a5d365ba16 17 * expression, and MSG an enum listed in struct internal::static_assertion<true>
ykuroda 0:13a5d365ba16 18 *
ykuroda 0:13a5d365ba16 19 * - define EIGEN_NO_STATIC_ASSERT to disable them (and save compilation time)
ykuroda 0:13a5d365ba16 20 * in that case, the static assertion is converted to the following runtime assert:
ykuroda 0:13a5d365ba16 21 * eigen_assert(CONDITION && "MSG")
ykuroda 0:13a5d365ba16 22 *
ykuroda 0:13a5d365ba16 23 * - currently EIGEN_STATIC_ASSERT can only be used in function scope
ykuroda 0:13a5d365ba16 24 *
ykuroda 0:13a5d365ba16 25 */
ykuroda 0:13a5d365ba16 26
ykuroda 0:13a5d365ba16 27 #ifndef EIGEN_NO_STATIC_ASSERT
ykuroda 0:13a5d365ba16 28
ykuroda 0:13a5d365ba16 29 #if __has_feature(cxx_static_assert) || (defined(__cplusplus) && __cplusplus >= 201103L) || (EIGEN_COMP_MSVC >= 1600)
ykuroda 0:13a5d365ba16 30
ykuroda 0:13a5d365ba16 31 // if native static_assert is enabled, let's use it
ykuroda 0:13a5d365ba16 32 #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
ykuroda 0:13a5d365ba16 33
ykuroda 0:13a5d365ba16 34 #else // not CXX0X
ykuroda 0:13a5d365ba16 35
ykuroda 0:13a5d365ba16 36 namespace Eigen {
ykuroda 0:13a5d365ba16 37
ykuroda 0:13a5d365ba16 38 namespace internal {
ykuroda 0:13a5d365ba16 39
ykuroda 0:13a5d365ba16 40 template<bool condition>
ykuroda 0:13a5d365ba16 41 struct static_assertion {};
ykuroda 0:13a5d365ba16 42
ykuroda 0:13a5d365ba16 43 template<>
ykuroda 0:13a5d365ba16 44 struct static_assertion<true>
ykuroda 0:13a5d365ba16 45 {
ykuroda 0:13a5d365ba16 46 enum {
ykuroda 0:13a5d365ba16 47 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX,
ykuroda 0:13a5d365ba16 48 YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES,
ykuroda 0:13a5d365ba16 49 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES,
ykuroda 0:13a5d365ba16 50 THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE,
ykuroda 0:13a5d365ba16 51 THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE,
ykuroda 0:13a5d365ba16 52 THIS_METHOD_IS_ONLY_FOR_OBJECTS_OF_A_SPECIFIC_SIZE,
ykuroda 0:13a5d365ba16 53 YOU_MADE_A_PROGRAMMING_MISTAKE,
ykuroda 0:13a5d365ba16 54 EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT,
ykuroda 0:13a5d365ba16 55 EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE,
ykuroda 0:13a5d365ba16 56 YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR,
ykuroda 0:13a5d365ba16 57 YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR,
ykuroda 0:13a5d365ba16 58 UNALIGNED_LOAD_AND_STORE_OPERATIONS_UNIMPLEMENTED_ON_ALTIVEC,
ykuroda 0:13a5d365ba16 59 THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES,
ykuroda 0:13a5d365ba16 60 FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED,
ykuroda 0:13a5d365ba16 61 NUMERIC_TYPE_MUST_BE_REAL,
ykuroda 0:13a5d365ba16 62 COEFFICIENT_WRITE_ACCESS_TO_SELFADJOINT_NOT_SUPPORTED,
ykuroda 0:13a5d365ba16 63 WRITING_TO_TRIANGULAR_PART_WITH_UNIT_DIAGONAL_IS_NOT_SUPPORTED,
ykuroda 0:13a5d365ba16 64 THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE,
ykuroda 0:13a5d365ba16 65 INVALID_MATRIX_PRODUCT,
ykuroda 0:13a5d365ba16 66 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS,
ykuroda 0:13a5d365ba16 67 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION,
ykuroda 0:13a5d365ba16 68 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY,
ykuroda 0:13a5d365ba16 69 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES,
ykuroda 0:13a5d365ba16 70 THIS_METHOD_IS_ONLY_FOR_ROW_MAJOR_MATRICES,
ykuroda 0:13a5d365ba16 71 INVALID_MATRIX_TEMPLATE_PARAMETERS,
ykuroda 0:13a5d365ba16 72 INVALID_MATRIXBASE_TEMPLATE_PARAMETERS,
ykuroda 0:13a5d365ba16 73 BOTH_MATRICES_MUST_HAVE_THE_SAME_STORAGE_ORDER,
ykuroda 0:13a5d365ba16 74 THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX,
ykuroda 0:13a5d365ba16 75 THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE,
ykuroda 0:13a5d365ba16 76 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES,
ykuroda 0:13a5d365ba16 77 YOU_ALREADY_SPECIFIED_THIS_STRIDE,
ykuroda 0:13a5d365ba16 78 INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION,
ykuroda 0:13a5d365ba16 79 THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD,
ykuroda 0:13a5d365ba16 80 PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1,
ykuroda 0:13a5d365ba16 81 THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS,
ykuroda 0:13a5d365ba16 82 YOU_CANNOT_MIX_ARRAYS_AND_MATRICES,
ykuroda 0:13a5d365ba16 83 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION,
ykuroda 0:13a5d365ba16 84 THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY,
ykuroda 0:13a5d365ba16 85 YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT,
ykuroda 0:13a5d365ba16 86 THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS,
ykuroda 0:13a5d365ba16 87 THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_OF_BOOL,
ykuroda 0:13a5d365ba16 88 THIS_METHOD_IS_ONLY_FOR_ARRAYS_NOT_MATRICES,
ykuroda 0:13a5d365ba16 89 YOU_PASSED_A_ROW_VECTOR_BUT_A_COLUMN_VECTOR_WAS_EXPECTED,
ykuroda 0:13a5d365ba16 90 YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED,
ykuroda 0:13a5d365ba16 91 THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE,
ykuroda 0:13a5d365ba16 92 THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH,
ykuroda 0:13a5d365ba16 93 OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG,
ykuroda 0:13a5d365ba16 94 IMPLICIT_CONVERSION_TO_SCALAR_IS_FOR_INNER_PRODUCT_ONLY,
ykuroda 0:13a5d365ba16 95 STORAGE_LAYOUT_DOES_NOT_MATCH
ykuroda 0:13a5d365ba16 96 };
ykuroda 0:13a5d365ba16 97 };
ykuroda 0:13a5d365ba16 98
ykuroda 0:13a5d365ba16 99 } // end namespace internal
ykuroda 0:13a5d365ba16 100
ykuroda 0:13a5d365ba16 101 } // end namespace Eigen
ykuroda 0:13a5d365ba16 102
ykuroda 0:13a5d365ba16 103 // Specialized implementation for MSVC to avoid "conditional
ykuroda 0:13a5d365ba16 104 // expression is constant" warnings. This implementation doesn't
ykuroda 0:13a5d365ba16 105 // appear to work under GCC, hence the multiple implementations.
ykuroda 0:13a5d365ba16 106 #ifdef _MSC_VER
ykuroda 0:13a5d365ba16 107
ykuroda 0:13a5d365ba16 108 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
ykuroda 0:13a5d365ba16 109 {Eigen::internal::static_assertion<bool(CONDITION)>::MSG;}
ykuroda 0:13a5d365ba16 110
ykuroda 0:13a5d365ba16 111 #else
ykuroda 0:13a5d365ba16 112
ykuroda 0:13a5d365ba16 113 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \
ykuroda 0:13a5d365ba16 114 if (Eigen::internal::static_assertion<bool(CONDITION)>::MSG) {}
ykuroda 0:13a5d365ba16 115
ykuroda 0:13a5d365ba16 116 #endif
ykuroda 0:13a5d365ba16 117
ykuroda 0:13a5d365ba16 118 #endif // not CXX0X
ykuroda 0:13a5d365ba16 119
ykuroda 0:13a5d365ba16 120 #else // EIGEN_NO_STATIC_ASSERT
ykuroda 0:13a5d365ba16 121
ykuroda 0:13a5d365ba16 122 #define EIGEN_STATIC_ASSERT(CONDITION,MSG) eigen_assert((CONDITION) && #MSG);
ykuroda 0:13a5d365ba16 123
ykuroda 0:13a5d365ba16 124 #endif // EIGEN_NO_STATIC_ASSERT
ykuroda 0:13a5d365ba16 125
ykuroda 0:13a5d365ba16 126
ykuroda 0:13a5d365ba16 127 // static assertion failing if the type \a TYPE is not a vector type
ykuroda 0:13a5d365ba16 128 #define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE) \
ykuroda 0:13a5d365ba16 129 EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime, \
ykuroda 0:13a5d365ba16 130 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX)
ykuroda 0:13a5d365ba16 131
ykuroda 0:13a5d365ba16 132 // static assertion failing if the type \a TYPE is not fixed-size
ykuroda 0:13a5d365ba16 133 #define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE) \
ykuroda 0:13a5d365ba16 134 EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime!=Eigen::Dynamic, \
ykuroda 0:13a5d365ba16 135 YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR)
ykuroda 0:13a5d365ba16 136
ykuroda 0:13a5d365ba16 137 // static assertion failing if the type \a TYPE is not dynamic-size
ykuroda 0:13a5d365ba16 138 #define EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(TYPE) \
ykuroda 0:13a5d365ba16 139 EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime==Eigen::Dynamic, \
ykuroda 0:13a5d365ba16 140 YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR)
ykuroda 0:13a5d365ba16 141
ykuroda 0:13a5d365ba16 142 // static assertion failing if the type \a TYPE is not a vector type of the given size
ykuroda 0:13a5d365ba16 143 #define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE) \
ykuroda 0:13a5d365ba16 144 EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime && TYPE::SizeAtCompileTime==SIZE, \
ykuroda 0:13a5d365ba16 145 THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE)
ykuroda 0:13a5d365ba16 146
ykuroda 0:13a5d365ba16 147 // static assertion failing if the type \a TYPE is not a vector type of the given size
ykuroda 0:13a5d365ba16 148 #define EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(TYPE, ROWS, COLS) \
ykuroda 0:13a5d365ba16 149 EIGEN_STATIC_ASSERT(TYPE::RowsAtCompileTime==ROWS && TYPE::ColsAtCompileTime==COLS, \
ykuroda 0:13a5d365ba16 150 THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE)
ykuroda 0:13a5d365ba16 151
ykuroda 0:13a5d365ba16 152 // static assertion failing if the two vector expression types are not compatible (same fixed-size or dynamic size)
ykuroda 0:13a5d365ba16 153 #define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1) \
ykuroda 0:13a5d365ba16 154 EIGEN_STATIC_ASSERT( \
ykuroda 0:13a5d365ba16 155 (int(TYPE0::SizeAtCompileTime)==Eigen::Dynamic \
ykuroda 0:13a5d365ba16 156 || int(TYPE1::SizeAtCompileTime)==Eigen::Dynamic \
ykuroda 0:13a5d365ba16 157 || int(TYPE0::SizeAtCompileTime)==int(TYPE1::SizeAtCompileTime)),\
ykuroda 0:13a5d365ba16 158 YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES)
ykuroda 0:13a5d365ba16 159
ykuroda 0:13a5d365ba16 160 #define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
ykuroda 0:13a5d365ba16 161 ( \
ykuroda 0:13a5d365ba16 162 (int(TYPE0::SizeAtCompileTime)==0 && int(TYPE1::SizeAtCompileTime)==0) \
ykuroda 0:13a5d365ba16 163 || (\
ykuroda 0:13a5d365ba16 164 (int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \
ykuroda 0:13a5d365ba16 165 || int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \
ykuroda 0:13a5d365ba16 166 || int(TYPE0::RowsAtCompileTime)==int(TYPE1::RowsAtCompileTime)) \
ykuroda 0:13a5d365ba16 167 && (int(TYPE0::ColsAtCompileTime)==Eigen::Dynamic \
ykuroda 0:13a5d365ba16 168 || int(TYPE1::ColsAtCompileTime)==Eigen::Dynamic \
ykuroda 0:13a5d365ba16 169 || int(TYPE0::ColsAtCompileTime)==int(TYPE1::ColsAtCompileTime))\
ykuroda 0:13a5d365ba16 170 ) \
ykuroda 0:13a5d365ba16 171 )
ykuroda 0:13a5d365ba16 172
ykuroda 0:13a5d365ba16 173 #ifdef EIGEN2_SUPPORT
ykuroda 0:13a5d365ba16 174 #define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \
ykuroda 0:13a5d365ba16 175 eigen_assert(!NumTraits<Scalar>::IsInteger);
ykuroda 0:13a5d365ba16 176 #else
ykuroda 0:13a5d365ba16 177 #define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \
ykuroda 0:13a5d365ba16 178 EIGEN_STATIC_ASSERT(!NumTraits<TYPE>::IsInteger, THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES)
ykuroda 0:13a5d365ba16 179 #endif
ykuroda 0:13a5d365ba16 180
ykuroda 0:13a5d365ba16 181
ykuroda 0:13a5d365ba16 182 // static assertion failing if it is guaranteed at compile-time that the two matrix expression types have different sizes
ykuroda 0:13a5d365ba16 183 #define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
ykuroda 0:13a5d365ba16 184 EIGEN_STATIC_ASSERT( \
ykuroda 0:13a5d365ba16 185 EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1),\
ykuroda 0:13a5d365ba16 186 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES)
ykuroda 0:13a5d365ba16 187
ykuroda 0:13a5d365ba16 188 #define EIGEN_STATIC_ASSERT_SIZE_1x1(TYPE) \
ykuroda 0:13a5d365ba16 189 EIGEN_STATIC_ASSERT((TYPE::RowsAtCompileTime == 1 || TYPE::RowsAtCompileTime == Dynamic) && \
ykuroda 0:13a5d365ba16 190 (TYPE::ColsAtCompileTime == 1 || TYPE::ColsAtCompileTime == Dynamic), \
ykuroda 0:13a5d365ba16 191 THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS)
ykuroda 0:13a5d365ba16 192
ykuroda 0:13a5d365ba16 193 #define EIGEN_STATIC_ASSERT_LVALUE(Derived) \
ykuroda 0:13a5d365ba16 194 EIGEN_STATIC_ASSERT(internal::is_lvalue<Derived>::value, \
ykuroda 0:13a5d365ba16 195 THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY)
ykuroda 0:13a5d365ba16 196
ykuroda 0:13a5d365ba16 197 #define EIGEN_STATIC_ASSERT_ARRAYXPR(Derived) \
ykuroda 0:13a5d365ba16 198 EIGEN_STATIC_ASSERT((internal::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value), \
ykuroda 0:13a5d365ba16 199 THIS_METHOD_IS_ONLY_FOR_ARRAYS_NOT_MATRICES)
ykuroda 0:13a5d365ba16 200
ykuroda 0:13a5d365ba16 201 #define EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2) \
ykuroda 0:13a5d365ba16 202 EIGEN_STATIC_ASSERT((internal::is_same<typename internal::traits<Derived1>::XprKind, \
ykuroda 0:13a5d365ba16 203 typename internal::traits<Derived2>::XprKind \
ykuroda 0:13a5d365ba16 204 >::value), \
ykuroda 0:13a5d365ba16 205 YOU_CANNOT_MIX_ARRAYS_AND_MATRICES)
ykuroda 0:13a5d365ba16 206
ykuroda 0:13a5d365ba16 207
ykuroda 0:13a5d365ba16 208 #endif // EIGEN_STATIC_ASSERT_H