MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / length

Function length

Common/nvVector.h:987–997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985 // return the length of the provided vector
986 template< class T>
987 inline typename T::value_type length(const T &vec)
988 {
989 typename T::value_type r = 0;
990
991 for (int i = 0; i < vec.size(); i++)
992 {
993 r += vec._array[i]*vec._array[i];
994 }
995
996 return typename T::value_type(sqrt(r));
997 }
998
999 // return the squared norm
1000 template< class T>

Callers

nothing calls this directly

Calls 2

sqrtFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected