RMeli / irc

Transfrormation between Cartesian coordinates and redundant internal coordinates
MIT License
22 stars 8 forks source link

Template specialisation for linalg functions #23

Closed RMeli closed 4 years ago

peterbygrave commented 6 years ago

Ok, so this is how far I have got: https://godbolt.org/g/UKKdSf

This is an example of the same function signature for two different template types. To extend this to armadillo and eigen there are the replacements for std::is_same<T, A>::value being arma::is_arma_type<T>::value (included in or specifically https://gitlab.com/conradsnicta/armadillo-code/blob/unstable/include/armadillo_bits/traits.hpp), we can see how it is used in https://gitlab.com/conradsnicta/armadillo-code/blob/unstable/include/armadillo_bits/fn_norm.hpp which is a more complete return statement:

typename enable_if2< is_arma_type<T>::value, typename T::pod_type >::result

and possibly should be copied. This would then enable lazy evaluation.

The same is then possible for eigen with is_eigen_type<V1>::value

What I cannot work out is how to write the signature of the function that should be defined, which in some way defines what is needed. However, if the irc::linalg has not been completed then c++ will complain say it cant find the signature, which in someway documents. (https://godbolt.org/g/kN8rVq)