plugin.hpp
Go to the documentation of this file.
1 
11 /*****************************************************************************
12 ** Ifdefs
13 *****************************************************************************/
14 
15 #ifndef ECL_LINEAR_ALGEBRA_EIGEN_PLUGIN_HPP_
16 #define ECL_LINEAR_ALGEBRA_EIGEN_PLUGIN_HPP_
17 
18 /*****************************************************************************
19 ** Includes
20 *****************************************************************************/
21 
22 #include "formatters.hpp"
23 
24 /*****************************************************************************
25 ** Code
26 *****************************************************************************/
27 
28 typedef MatrixFormatter<Derived,Scalar> Formatter;
29 
30 inline void conservativeResize(int rows, int cols)
31 {
32  PlainObject tmp(rows, cols); // alternatively: PlainObject::Zero(rows,cols)
33  const int common_rows = std::min(rows, this->rows());
34  const int common_cols = std::min(cols, this->cols());
35  tmp.block(0,0,common_rows,common_cols) = this->block(0,0,common_rows,common_cols);
36  this->derived().swap(tmp);
37 }
38 
39 inline void conservativeResize(int size)
40 {
41  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
42 
43  if (RowsAtCompileTime == 1)
44  {
45  PlainObject tmp(1,size); // alternatively: PlainObject::Zero(1,size)
46  const int common_size = std::min(cols(),size);
47  tmp.block(0,0,1,common_size) = this->block(0,0,1,common_size);
48  this->derived().swap(tmp);
49  }
50  else
51  {
52  PlainObject tmp(size,1); // alternatively: PlainObject::Zero(size,1)
53  const int common_size = std::min(rows(),size);
54  tmp.block(0,0,common_size,1) = this->block(0,0,common_size,1);
55  this->derived().swap(tmp);
56  }
57 }
58 
59 #endif /* ECL_LINEAR_ALGEBRA_EIGEN_PLUGIN_HPP_ */
MatrixFormatter< Derived, Scalar > Formatter
Definition: plugin.hpp:28
void conservativeResize(int rows, int cols)
Definition: plugin.hpp:30


ecl_linear_algebra
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:26