Template Size vs Dynamic Size

I’ve noticed a few functions, such as quad_form_sym with the following signature:

template <typename TA, int RA, int CA, typename TB, int RB, int CB>
inline typename
boost::enable_if_c< boost::is_same<TA, var>::value ||
  boost::is_same<TB, var>::value,
  Eigen::Matrix<var, CB, CB> >::type
quad_form_sym(const Eigen::Matrix<TA, RA, CA>& A,
              const Eigen::Matrix<TB, RB, CB>& B)

Why are we using the template type TA and RA, instead of Eigen::Dynamic?

I think the answer is that if you substitute Eigen::Dynamic for both TA and TB then it expects a matrix, whereas we can call it with TA or TB as 1, then it works with column vectors or row vectors.

TA is the scalar type, so TA is going to be var or double or fvar<var>.

RA is the static rows and CA the static columns for argument A. The reason they’re template parameters is what Ben said, RA=1, CA=-1 is for vectors, RA=-1, CA=1 for row vectors, and RA=-1, CA=-1 for matrices. -1 is the value of Eigen::Dynamic.

Thank you for the answer @bgoodri and @Bob_Carpenter.