Closed jasonkaye closed 1 year ago
Ran into the same thing. I don't know if this is a good way to do it, but what about:
template <typename T> double norm2(nda::array<T, 1> const &v) { return std::sqrt(nda::blas::dot(v, v)); };
Thank you for the suggestion
I added a generic p-norm implementation here c2d519a
@jasonkaye Please have a look and let me know if you agree.
I moved the implementation into nda/linalg/norm.hpp
.
You make it available by including nda/linalg.hpp
It would be nice to have a function which computes the l^2 norm of an NDA vector, as
norm(v)
or
norm2(v).
One could also have norm(v,p) to compute l^p norm.