MCPcopy Create free account
hub / github.com/VectorDB-NTU/RaBitQ-Library / normalized

Method normalized

include/rabitqlib/third/Eigen/src/Core/Dot.h:123–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121 */
122template<typename Derived>
123EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject
124MatrixBase<Derived>::normalized() const
125{
126 typedef typename internal::nested_eval<Derived,2>::type _Nested;
127 _Nested n(derived());
128 RealScalar z = n.squaredNorm();
129 // NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU
130 if(z>RealScalar(0))
131 return n / numext::sqrt(z);
132 else
133 return n;
134}
135
136/** Normalizes the vector, i.e. divides it by its own norm.
137 *

Callers 3

ex_bits_codeFunction · 0.45
runMethod · 0.45

Calls 2

sqrtFunction · 0.70
squaredNormMethod · 0.45

Tested by

no test coverage detected