Is it possible to use GLM with non-fundamental types?

  autodiff, c++, glm

I have some functions and data structures using glm for vector and matrix math.

Now I want to compute gradient’s with respect to the input variables. Since the computations are fairly complex, I’d like to use automatic differentiation to verify my manual gradient computation.

I’ve found, which is exactly what I need. Its scalar variables are based on a struct containing a shared_ptr to an expression. I’d like to use glm::vec<2, autodiff::Variable<float>, and similarly matrices, along with all the fun glm functions.

I already started porting the code, but I’m running into problems. for instance glm::dot contains a check

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
    GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
    return detail::compute_dot<vec<L, T, Q>, T, detail::is_aligned<Q>::value>::call(x, y);

I believe that in this case it’s safe to replace the check with std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE (along with making a pull request), but I’m not sure and I certainly don’t know about all the other places.

I have defined the following before including glm:


Is it at all realistic to use glm and autodiff together?

Source: Windows Questions C++