| 121 | */ |
| 122 | template<typename Derived> |
| 123 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject |
| 124 | MatrixBase<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 | * |
no test coverage detected