Allow Armadillo conversions with `conv_to`
This simple PR allows the following to work:
conv_to<coot::mat>::from(arma::mat())
conv_to<arma::mat>::from(coot::mat())
It also fixes a bug where you could use conv_to
with weird expression types. Now a static assertion checks that conv_to<T>
is such that T
is coot::Mat
, coot::Col
, coot::Row
, arma::Mat
, arma::Col
, or arma::Row
.
(CC @conradsnicta for the next paragraphs)
One weak point I am trying to solve in this MR is the lack of ADL support for classes. Suppose I have a function written with templates, like this:
template<typename MatType>
MatType do_something()
{
return chol(square(MatType) + 4);
}
That function will work with both Armadillo and Bandicoot through ADL. But there is an exception when classes are used... both arma::conv_to
and coot::conv_to
exist, and ADL cannot determine which of those to use. My thought is that coot::conv_to
can always be used for any arma::conv_to
operation, suggesting that a user could switch their code from Armadillo to Bandicoot by
(1) depending on ADL for all matrix operations, so no arma::func_name()
anywhere;
(2) change all direct uses of Armadillo types (like arma::mat
) to Bandicoot types (like coot::mat
)
(3) either add using coot::conv_to
or change any conv_to
calls to be qualified as coot::conv_to
This would be important for advertising^ bandicoot as an easy drop-in replacement for Armadillo. I'd appreciate thoughts on whether this conv_to
support is a reasonable way to accomplish that, or if perhaps changes in Armadillo might be a better way to go, or if something else I overlooked might be a better strategy.
^ I don't actually know if I would have written advertizing or advertising here before !57 (merged)... neither of them "look right" anymore!