Skip to content

Instantly share code, notes, and snippets.

@rpavlik
Last active October 23, 2015 18:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpavlik/97a08d66e6232a32a8d4 to your computer and use it in GitHub Desktop.
Save rpavlik/97a08d66e6232a32a8d4 to your computer and use it in GitHub Desktop.
Eigen metaprogramming notes

Eigen Metaprogramming Notes

Ryan Pavlik

Useful static constant members/enums:

  • ::IsRowMajor
  • ::IsVectorAtCompileTime
  • ::RowsAtCompileTime - note that in the case of dynamic sizes, this is weird (-1, iirc - specifically, Eigen::Dynamic)
  • ::ColsAtCompileTime - same as above
  • ::SizeAtCompileTime - works like picking the right one of the above for either arrangement of vectors, or full size (I assume?) for matrices.

Useful member typedefs

  • ::Scalar

Static assertions

These are primarily defined in Eigen/src/Core/util/StaticAssert.h - the ones I list here are just my favorites.

  • EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE) - excludes dynamic sized stuff, which is usually fine for the stuff I do.
  • EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
  • EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(TYPE, ROWS, COLS)
  • EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1) - lets through two dynamic-sized vectors
  • EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0,TYPE1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment