cart-elc

Source code for CART-ELC
git clone git://git.laack.co/cart-elc.git
Log | Files | Refs | README | LICENSE

ReshapedMethods.h (6915B)


      1 
      2 #ifdef EIGEN_PARSED_BY_DOXYGEN
      3 
      4 /// \returns an expression of \c *this with reshaped sizes.
      5 ///
      6 /// \param nRows the number of rows in the reshaped expression, specified at either run-time or compile-time, or AutoSize
      7 /// \param nCols the number of columns in the reshaped expression, specified at either run-time or compile-time, or AutoSize
      8 /// \tparam Order specifies whether the coefficients should be processed in column-major-order (ColMajor), in row-major-order (RowMajor),
      9 ///               or follows the \em natural order of the nested expression (AutoOrder). The default is ColMajor.
     10 /// \tparam NRowsType the type of the value handling the number of rows, typically Index.
     11 /// \tparam NColsType the type of the value handling the number of columns, typically Index.
     12 ///
     13 /// Dynamic size example: \include MatrixBase_reshaped_int_int.cpp
     14 /// Output: \verbinclude MatrixBase_reshaped_int_int.out
     15 ///
     16 /// The number of rows \a nRows and columns \a nCols can also be specified at compile-time by passing Eigen::fix<N>,
     17 /// or Eigen::fix<N>(n) as arguments. In the later case, \c n plays the role of a runtime fallback value in case \c N equals Eigen::Dynamic.
     18 /// Here is an example with a fixed number of rows and columns:
     19 /// \include MatrixBase_reshaped_fixed.cpp
     20 /// Output: \verbinclude MatrixBase_reshaped_fixed.out
     21 ///
     22 /// Finally, one of the sizes parameter can be automatically deduced from the other one by passing AutoSize as in the following example:
     23 /// \include MatrixBase_reshaped_auto.cpp
     24 /// Output: \verbinclude MatrixBase_reshaped_auto.out
     25 /// AutoSize does preserve compile-time sizes when possible, i.e., when the sizes of the input are known at compile time \b and
     26 /// that the other size is passed at compile-time using Eigen::fix<N> as above.
     27 ///
     28 /// \sa class Reshaped, fix, fix<N>(int)
     29 ///
     30 template<int Order = ColMajor, typename NRowsType, typename NColsType>
     31 EIGEN_DEVICE_FUNC
     32 inline Reshaped<Derived,...>
     33 reshaped(NRowsType nRows, NColsType nCols);
     34 
     35 /// This is the const version of reshaped(NRowsType,NColsType).
     36 template<int Order = ColMajor, typename NRowsType, typename NColsType>
     37 EIGEN_DEVICE_FUNC
     38 inline const Reshaped<const Derived,...>
     39 reshaped(NRowsType nRows, NColsType nCols) const;
     40 
     41 /// \returns an expression of \c *this with columns (or rows) stacked to a linear column vector
     42 ///
     43 /// \tparam Order specifies whether the coefficients should be processed in column-major-order (ColMajor), in row-major-order (RowMajor),
     44 ///               or follows the \em natural order of the nested expression (AutoOrder). The default is ColMajor.
     45 ///
     46 /// This overloads is essentially a shortcut for `A.reshaped<Order>(AutoSize,fix<1>)`.
     47 ///
     48 /// - If `Order==ColMajor` (the default), then it returns a column-vector from the stacked columns of \c *this.
     49 /// - If `Order==RowMajor`, then it returns a column-vector from the stacked rows of \c *this.
     50 /// - If `Order==AutoOrder`, then it returns a column-vector with elements stacked following the storage order of \c *this.
     51 ///   This mode is the recommended one when the particular ordering of the element is not relevant.
     52 ///
     53 /// Example:
     54 /// \include MatrixBase_reshaped_to_vector.cpp
     55 /// Output: \verbinclude MatrixBase_reshaped_to_vector.out
     56 ///
     57 /// If you want more control, you can still fall back to reshaped(NRowsType,NColsType).
     58 ///
     59 /// \sa reshaped(NRowsType,NColsType), class Reshaped
     60 ///
     61 template<int Order = ColMajor>
     62 EIGEN_DEVICE_FUNC
     63 inline Reshaped<Derived,...>
     64 reshaped();
     65 
     66 /// This is the const version of reshaped().
     67 template<int Order = ColMajor>
     68 EIGEN_DEVICE_FUNC
     69 inline const Reshaped<const Derived,...>
     70 reshaped() const;
     71 
     72 #else
     73 
     74 // This file is automatically included twice to generate const and non-const versions
     75 
     76 #ifndef EIGEN_RESHAPED_METHOD_2ND_PASS
     77 #define EIGEN_RESHAPED_METHOD_CONST const
     78 #else
     79 #define EIGEN_RESHAPED_METHOD_CONST
     80 #endif
     81 
     82 #ifndef EIGEN_RESHAPED_METHOD_2ND_PASS
     83 
     84 // This part is included once
     85 
     86 #endif
     87 
     88 template<typename NRowsType, typename NColsType>
     89 EIGEN_DEVICE_FUNC
     90 inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
     91                 internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
     92                 internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value>
     93 reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST
     94 {
     95   return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
     96                   internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
     97                   internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value>
     98                 (derived(),
     99                  internal::get_runtime_reshape_size(nRows,internal::get_runtime_value(nCols),size()),
    100                  internal::get_runtime_reshape_size(nCols,internal::get_runtime_value(nRows),size()));
    101 }
    102 
    103 template<int Order, typename NRowsType, typename NColsType>
    104 EIGEN_DEVICE_FUNC
    105 inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
    106                 internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
    107                 internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value,
    108                 internal::get_compiletime_reshape_order<Flags,Order>::value>
    109 reshaped(NRowsType nRows, NColsType nCols) EIGEN_RESHAPED_METHOD_CONST
    110 {
    111   return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,
    112                   internal::get_compiletime_reshape_size<NRowsType,NColsType,SizeAtCompileTime>::value,
    113                   internal::get_compiletime_reshape_size<NColsType,NRowsType,SizeAtCompileTime>::value,
    114                   internal::get_compiletime_reshape_order<Flags,Order>::value>
    115                 (derived(),
    116                  internal::get_runtime_reshape_size(nRows,internal::get_runtime_value(nCols),size()),
    117                  internal::get_runtime_reshape_size(nCols,internal::get_runtime_value(nRows),size()));
    118 }
    119 
    120 // Views as linear vectors
    121 
    122 EIGEN_DEVICE_FUNC
    123 inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,SizeAtCompileTime,1>
    124 reshaped() EIGEN_RESHAPED_METHOD_CONST
    125 {
    126   return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived,SizeAtCompileTime,1>(derived(),size(),1);
    127 }
    128 
    129 template<int Order>
    130 EIGEN_DEVICE_FUNC
    131 inline Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, SizeAtCompileTime, 1,
    132                 internal::get_compiletime_reshape_order<Flags,Order>::value>
    133 reshaped() EIGEN_RESHAPED_METHOD_CONST
    134 {
    135   EIGEN_STATIC_ASSERT(Order==RowMajor || Order==ColMajor || Order==AutoOrder, INVALID_TEMPLATE_PARAMETER);
    136   return Reshaped<EIGEN_RESHAPED_METHOD_CONST Derived, SizeAtCompileTime, 1,
    137                   internal::get_compiletime_reshape_order<Flags,Order>::value>
    138                 (derived(), size(), 1);
    139 }
    140 
    141 #undef EIGEN_RESHAPED_METHOD_CONST
    142 
    143 #ifndef EIGEN_RESHAPED_METHOD_2ND_PASS
    144 #define EIGEN_RESHAPED_METHOD_2ND_PASS
    145 #include "ReshapedMethods.h"
    146 #undef EIGEN_RESHAPED_METHOD_2ND_PASS
    147 #endif
    148 
    149 #endif // EIGEN_PARSED_BY_DOXYGEN