summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/codec/c++/math.hpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/codec/c++/math.hpp b/modules/codec/c++/math.hpp
index ec051df..090005c 100644
--- a/modules/codec/c++/math.hpp
+++ b/modules/codec/c++/math.hpp
@@ -32,6 +32,9 @@ data<schema::Scalar<T>,Encoding> sqrt(const data<schema::Scalar<T>,Encoding>& in
template<typename T, uint64_t D, typename Encoding = encode::Native>
data<schema::Vector<T,D>, Encoding> normalize(const data<schema::Vector<T,D>>& input ) {
auto inp_dot = dot<T,D,Encoding>(input,input);
+ if(inp_dot.at({}).get() <= 0){
+ return input;
+ }
auto sqrt_inp_dot = sqrt<T>(inp_dot);
saw::data<schema::Vector<T,D>, Encoding> out;