Eigen  5.0.1-dev+master
 
Loading...
Searching...
No Matches
Dot.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2006-2008, 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_DOT_H
12#define EIGEN_DOT_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
19namespace internal {
20
21// Accumulate low-precision norms in float without changing the public result type.
22template <typename RealScalar>
23struct stable_norm_accumulator {
24 using type = RealScalar;
25};
26
27template <>
28struct stable_norm_accumulator<half> {
29 using type = float;
30};
31
32template <>
33struct stable_norm_accumulator<bfloat16> {
34 using type = float;
35};
36
37template <typename RealScalar, typename Accumulator>
38struct stable_normalization_normal_min {
39 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Accumulator run() {
40 return static_cast<Accumulator>((numext::numeric_limits<RealScalar>::min)());
41 }
42};
43
44// The half and bfloat16 numeric_limits functions are not device functions.
45template <typename Accumulator>
46struct stable_normalization_normal_min<half, Accumulator> {
47 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Accumulator run() { return Accumulator(1) / Accumulator(16384); }
48};
49
50template <typename Accumulator>
51struct stable_normalization_normal_min<bfloat16, Accumulator> {
52 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Accumulator run() {
53 return static_cast<Accumulator>((numext::numeric_limits<float>::min)());
54 }
55};
56
57template <typename RealScalar, typename Accumulator>
58EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool stable_normalization_inv_scale(const Accumulator& value,
59 Accumulator& invScale) {
60 safe_scaling_factors<Accumulator> factors;
61 const Accumulator normalMin = stable_normalization_normal_min<RealScalar, Accumulator>::run();
62 if (!safe_scaling<Accumulator>::try_compute_ceiling_factors_with_normal_reciprocal(value, normalMin, factors))
63 return false;
64 invScale = factors.invScale;
65 return true;
66}
67
68template <typename Accumulator>
69EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool stable_normalization_combined_factor(const Accumulator& invScale,
70 const Accumulator& sqrtNorm,
71 Accumulator& factor) {
72 // Check before dividing: an overflowing reciprocal can raise FE_OVERFLOW even if the two-step fallback is used.
73 if (sqrtNorm < Accumulator(1) && invScale > Accumulator(NumTraits<Accumulator>::highest()) * sqrtNorm) return false;
74 Accumulator localSqrtNorm = sqrtNorm;
75 pbarrier(localSqrtNorm);
76 factor = invScale / localSqrtNorm;
77 return factor >= stable_normalization_normal_min<Accumulator, Accumulator>::run();
78}
79
80template <typename VectorType, typename Accumulator,
81 bool = bool(traits<VectorType>::Flags & DirectAccessBit) &&
82 (int(inner_stride_at_compile_time<VectorType>::value) != 1)>
83struct stable_normalization_dispatch {
84 using Scalar = typename traits<VectorType>::Scalar;
85 using RealScalar = typename NumTraits<Scalar>::Real;
86 // Only complex_array_access scalars have a writable component view.
87 using HasWritableRealView = bool_constant<!NumTraits<Scalar>::IsComplex || complex_array_access<Scalar>::value>;
88
89 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Accumulator max_abs(const VectorType& vec) {
90 return redux_with_identity(vec.realView().template cast<Accumulator>().cwiseAbs(),
91 scalar_max_op<Accumulator, Accumulator, PropagateNaN>(), 0);
92 }
93
94 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Accumulator scaled_squared_norm(const VectorType& vec,
95 const Accumulator& factor) {
96 return (vec.realView().template cast<Accumulator>() * factor).squaredNorm();
97 }
98
99 template <typename ResultType>
100 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void assign_scaled(ResultType& result, const VectorType& vec,
101 const Accumulator& factor) {
102 assign_scaled_impl(result, vec, factor, HasWritableRealView());
103 }
104
105 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void scale_in_place(VectorType& vec, const Accumulator& factor) {
106 assign_scaled_impl(vec, vec, factor, HasWritableRealView());
107 }
108
109 private:
110 template <typename ResultType>
111 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void assign_scaled_impl(ResultType& result, const VectorType& vec,
112 const Accumulator& factor, std::true_type) {
113 result.realView() = (vec.realView().template cast<Accumulator>() * factor).template cast<RealScalar>();
114 }
115
116 template <typename ResultType>
117 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void assign_scaled_impl(ResultType& result, const VectorType& vec,
118 const Accumulator& factor, std::false_type) {
119 result = vec * static_cast<RealScalar>(factor);
120 }
121};
122
123// Runtime-contiguous expressions can still use packet traversal.
124template <typename VectorType, typename Accumulator>
125struct stable_normalization_dispatch<VectorType, Accumulator, true> {
126 using Scalar = typename traits<VectorType>::Scalar;
127 using RealScalar = typename NumTraits<Scalar>::Real;
128 // A dynamic map avoids over-unrolling fixed-size normalization paths.
129 using PlainVector = Matrix<Scalar, Dynamic, 1>;
130 using ConstContiguousMap = Map<const PlainVector, evaluator<VectorType>::Alignment>;
131 using ContiguousMap = Map<PlainVector, evaluator<VectorType>::Alignment>;
132
133 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE bool is_contiguous(const VectorType& vec) {
134 return vec.innerStride() == 1 && (vec.outerSize() == 1 || vec.outerStride() == vec.innerSize());
135 }
136
137 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Accumulator max_abs(const VectorType& vec) {
138 if (is_contiguous(vec)) {
139 const ConstContiguousMap contiguous(vec.data(), vec.size());
140 return stable_normalization_dispatch<ConstContiguousMap, Accumulator, false>::max_abs(contiguous);
141 }
142 return stable_normalization_dispatch<VectorType, Accumulator, false>::max_abs(vec);
143 }
144
145 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Accumulator scaled_squared_norm(const VectorType& vec,
146 const Accumulator& factor) {
147 if (is_contiguous(vec)) {
148 const ConstContiguousMap contiguous(vec.data(), vec.size());
149 return stable_normalization_dispatch<ConstContiguousMap, Accumulator, false>::scaled_squared_norm(contiguous,
150 factor);
151 }
152 return stable_normalization_dispatch<VectorType, Accumulator, false>::scaled_squared_norm(vec, factor);
153 }
154
155 template <typename ResultType>
156 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void assign_scaled(ResultType& result, const VectorType& vec,
157 const Accumulator& factor) {
158 if (is_contiguous(vec)) {
159 const ConstContiguousMap contiguous(vec.data(), vec.size());
160 Map<PlainVector> output(result.data(), result.size());
161 stable_normalization_dispatch<ConstContiguousMap, Accumulator, false>::assign_scaled(output, contiguous, factor);
162 return;
163 }
164 stable_normalization_dispatch<VectorType, Accumulator, false>::assign_scaled(result, vec, factor);
165 }
166
167 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void scale_in_place(VectorType& vec, const Accumulator& factor) {
168 if (is_contiguous(vec)) {
169 ContiguousMap contiguous(vec.data(), vec.size());
170 stable_normalization_dispatch<ContiguousMap, Accumulator, false>::scale_in_place(contiguous, factor);
171 return;
172 }
173 stable_normalization_dispatch<VectorType, Accumulator, false>::scale_in_place(vec, factor);
174 }
175};
176
177// Prevent fast-math from merging normal scale factors into a subnormal factor.
178template <typename VectorType, typename Accumulator>
179EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE void stable_normalization_scale_in_place(VectorType& vec,
180 const Accumulator& factor) {
181 stable_normalization_dispatch<VectorType, Accumulator>::scale_in_place(vec, factor);
182}
183
184template <typename VectorType, typename Divisor>
185EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE void stable_normalization_divide_in_place(VectorType& vec, const Divisor& divisor) {
186 vec /= divisor;
189template <typename VectorType, typename Accumulator>
190EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void stable_normalization_with_division(VectorType& vec,
191 const Accumulator& maxCoeff) {
192 using RealScalar = typename NumTraits<typename traits<VectorType>::Scalar>::Real;
193 // Two normal divisors avoid an exceptional reciprocal and fast-math
194 // reassociation into multiplication by 1 / maxCoeff.
195 const Accumulator sqrtMax = numext::sqrt(maxCoeff);
196 const RealScalar scale1 = static_cast<RealScalar>(sqrtMax);
197 const RealScalar scale2 = static_cast<RealScalar>(maxCoeff / sqrtMax);
198 stable_normalization_divide_in_place(vec, scale1);
199 stable_normalization_divide_in_place(vec, scale2);
200 const Accumulator z = vec.realView().template cast<Accumulator>().squaredNorm();
201 if (z > Accumulator(0)) {
202 stable_normalization_scale_in_place(vec, Accumulator(1) / numext::sqrt(z));
203 }
204}
205
206template <typename VectorType, typename Accumulator,
207 bool = use_subnormal_preserving_scaling<Accumulator, typename traits<VectorType>::Scalar>::value>
208struct stable_normalization_subnormal_recovery {
209 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(VectorType&) {}
210};
211
212template <typename VectorType, typename Accumulator>
213struct stable_normalization_subnormal_recovery<VectorType, Accumulator, true> {
214 using RealScalar = typename NumTraits<typename traits<VectorType>::Scalar>::Real;
215
216 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(VectorType& vec) {
217 using Binary = binary_floating_point_traits<RealScalar>;
218 using Bits = typename Binary::Bits;
219 decltype(auto) components = vec.realView();
220 Bits maxBits = 0;
221 for (Index col = 0; col < components.cols(); ++col) {
222 for (Index row = 0; row < components.rows(); ++row) {
223 const Bits bits = Binary::magnitude(components.coeff(row, col));
224 if (bits > maxBits) maxBits = bits;
225 }
226 }
227 if (maxBits == 0 || maxBits >= Binary::kExponentUnit) return;
228
229 const Accumulator maxAbs = numext::bit_cast<RealScalar>(maxBits);
230 const auto factors = safe_scaling<Accumulator>::compute_ceiling_factors(maxAbs);
231 safe_scaling<Accumulator>::scale_in_place(vec, maxAbs, factors);
232 const Accumulator squaredNorm = components.template cast<Accumulator>().squaredNorm();
233 if (squaredNorm > Accumulator(0)) {
234 stable_normalization_divide_in_place(vec, numext::sqrt(squaredNorm));
235 }
236 }
237};
238
239// squaredNorm() reduces realView().cwiseAbs2(), a cwise expression with no direct access, so when
240// the underlying expression has an inner stride that is not statically 1 (a dynamic-inner-stride
241// Map/Ref, a row of a 1xN matrix, ...) the reduction falls back to a scalar traversal even though
242// the data is frequently contiguous at runtime. This trait flags the cases where a runtime
243// contiguity check is worthwhile; it mirrors the reduction fast path in Redux.h (redux_dispatch).
244// bool is excluded: its squared norm is any(), handled by a dedicated specialization below.
245template <typename Xpr>
246struct squared_norm_runtime_unit_stride {
247 using Scalar = typename traits<Xpr>::Scalar;
248 static constexpr bool value =
249 bool(traits<Xpr>::Flags & DirectAccessBit) && bool(packet_traits<Scalar>::Vectorizable) &&
250 !bool(internal::is_same<Scalar, bool>::value) && (int(inner_stride_at_compile_time<Xpr>::value) != 1);
251};
252
253template <typename Derived, typename Scalar = typename traits<Derived>::Scalar, typename Enable = void>
254struct squared_norm_impl {
255 using Real = typename NumTraits<Scalar>::Real;
256 static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Real run(const Derived& a) {
257 return a.realView().cwiseAbs2().sum();
258 }
259};
260
261template <typename Derived>
262struct squared_norm_impl<Derived, bool, void> {
263 static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE bool run(const Derived& a) { return a.any(); }
264};
265
266// Runtime contiguity fast path: when the data is contiguous at runtime (inner stride 1, and a
267// single inner panel or no gap between inner panels), reduce the underlying buffer as a contiguous
268// vector, recovering vectorization of the abs2 reduction.
269template <typename Derived, typename Scalar>
270struct squared_norm_impl<Derived, Scalar, std::enable_if_t<squared_norm_runtime_unit_stride<Derived>::value>> {
271 using Real = typename NumTraits<Scalar>::Real;
272 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Real run(const Derived& a) {
273 if (a.innerStride() == 1 && (a.outerSize() == 1 || a.outerStride() == a.innerSize())) {
274 using PlainVector = Matrix<Scalar, Dynamic, 1>;
276 return contiguous.realView().cwiseAbs2().sum();
277 }
278 return a.realView().cwiseAbs2().sum();
279 }
280};
281
282} // end namespace internal
283
295template <typename Derived>
296template <typename OtherDerived>
297EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE
299 typename internal::traits<OtherDerived>::Scalar>::ReturnType
300 MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const {
301 return internal::inner_product_dispatch<Derived, OtherDerived, true>::run(derived(), other.derived());
302}
303
304//---------- implementation of L2 norm and related functions ----------
305
312template <typename Derived>
313EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
315 return internal::squared_norm_impl<Derived>::run(derived());
316}
317
324template <typename Derived>
325EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
327 return numext::sqrt(squaredNorm());
328}
329
339template <typename Derived>
340EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject MatrixBase<Derived>::normalized()
341 const {
342 using Nested_ = typename internal::nested_eval<Derived, 2>::type;
343 Nested_ n(derived());
344 RealScalar z = n.squaredNorm();
345 // NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU
346 if (z > RealScalar(0))
347 return n / numext::sqrt(z);
348 else
349 return n;
350}
351
360template <typename Derived>
361EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MatrixBase<Derived>::normalize() {
362 RealScalar z = squaredNorm();
363 // NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU
364 if (z > RealScalar(0)) derived() /= numext::sqrt(z);
365}
366
379template <typename Derived>
380EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject
382 using Nested_ = typename internal::nested_eval<Derived, 3>::type;
383 using NestedClean = internal::remove_all_t<Nested_>;
384 using Accumulator = typename internal::stable_norm_accumulator<RealScalar>::type;
385 using Dispatch = internal::stable_normalization_dispatch<NestedClean, Accumulator>;
386 Nested_ vec(derived());
387 if (EIGEN_PREDICT_FALSE(vec.size() == 0)) return vec;
388
389 // Component-wise scaling stays finite when a finite complex value has an
390 // overflowing magnitude, and avoids a hypot per coefficient.
391 const Accumulator w = Dispatch::max_abs(vec);
392 const Accumulator highest = static_cast<Accumulator>(NumTraits<RealScalar>::highest());
393 if (EIGEN_PREDICT_FALSE(!(w > Accumulator(0)))) {
394 PlainObject normalized(vec);
395 internal::stable_normalization_subnormal_recovery<PlainObject, Accumulator>::run(normalized);
396 return normalized;
397 }
398 if (EIGEN_PREDICT_FALSE(!(w <= highest))) return vec;
399
400 Accumulator invScale;
401 if (EIGEN_PREDICT_TRUE((internal::stable_normalization_inv_scale<RealScalar>(w, invScale)))) {
402 const Accumulator z = Dispatch::scaled_squared_norm(vec, invScale);
403 if (z > Accumulator(0)) {
404 const Accumulator sqrt_z = numext::sqrt(z);
405 Accumulator factor;
406 PlainObject normalized(rows(), cols());
407 if (EIGEN_PREDICT_TRUE(internal::stable_normalization_combined_factor(invScale, sqrt_z, factor))) {
408 Dispatch::assign_scaled(normalized, vec, factor);
409 } else {
410 // invScale and sqrt_z are normal even though their quotient is not.
411 Dispatch::assign_scaled(normalized, vec, invScale);
412 internal::stable_normalization_divide_in_place(normalized, static_cast<RealScalar>(sqrt_z));
413 }
414 return normalized;
415 }
416 // Packet arithmetic may flush subnormal inputs even when the maximum reduction preserves them (ARMv7 NEON).
417 PlainObject normalized(vec);
418 internal::stable_normalization_subnormal_recovery<PlainObject, Accumulator>::run(normalized);
419 return normalized;
420 }
421
422 PlainObject normalized = vec;
423 internal::stable_normalization_with_division(normalized, w);
424 return normalized;
425}
426
438template <typename Derived>
439EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MatrixBase<Derived>::stableNormalize() {
440 using Accumulator = typename internal::stable_norm_accumulator<RealScalar>::type;
441 using Dispatch = internal::stable_normalization_dispatch<Derived, Accumulator>;
442 if (EIGEN_PREDICT_FALSE(size() == 0)) return;
443
444 const Accumulator w = Dispatch::max_abs(derived());
445 const Accumulator highest = static_cast<Accumulator>(NumTraits<RealScalar>::highest());
446 if (EIGEN_PREDICT_FALSE(!(w > Accumulator(0)))) {
447 internal::stable_normalization_subnormal_recovery<Derived, Accumulator>::run(derived());
448 return;
449 }
450 if (EIGEN_PREDICT_FALSE(!(w <= highest))) return;
451
452 Accumulator invScale;
453 if (EIGEN_PREDICT_TRUE((internal::stable_normalization_inv_scale<RealScalar>(w, invScale)))) {
454 const Accumulator z = Dispatch::scaled_squared_norm(derived(), invScale);
455 if (z > Accumulator(0)) {
456 const Accumulator sqrt_z = numext::sqrt(z);
457 Accumulator factor;
458 if (EIGEN_PREDICT_TRUE(internal::stable_normalization_combined_factor(invScale, sqrt_z, factor))) {
459 Dispatch::scale_in_place(derived(), factor);
460 } else {
461 internal::stable_normalization_scale_in_place(derived(), invScale);
462 internal::stable_normalization_divide_in_place(derived(), static_cast<RealScalar>(sqrt_z));
463 }
464 } else {
465 internal::stable_normalization_subnormal_recovery<Derived, Accumulator>::run(derived());
466 }
467 return;
468 }
469
470 internal::stable_normalization_with_division(derived(), w);
471}
472
473//---------- implementation of other norms ----------
474
475namespace internal {
476
477template <typename Derived, int p>
478struct lpNorm_selector {
479 using RealScalar = typename NumTraits<typename traits<Derived>::Scalar>::Real;
480 EIGEN_DEVICE_FUNC static inline RealScalar run(const MatrixBase<Derived>& m) {
481 return numext::pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1) / p);
482 }
483};
484
485template <typename Derived>
486struct lpNorm_selector<Derived, 1> {
487 EIGEN_DEVICE_FUNC static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(
488 const MatrixBase<Derived>& m) {
489 return m.cwiseAbs().sum();
490 }
491};
492
493template <typename Derived>
494struct lpNorm_selector<Derived, 2> {
495 EIGEN_DEVICE_FUNC static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(
496 const MatrixBase<Derived>& m) {
497 return m.norm();
498 }
499};
500
501template <typename Derived>
502struct lpNorm_selector<Derived, Infinity> {
503 using RealScalar = typename NumTraits<typename traits<Derived>::Scalar>::Real;
504 EIGEN_DEVICE_FUNC static inline RealScalar run(const MatrixBase<Derived>& m) {
505 // Like the other norms, NaN in, NaN out; PropagateFast may return an arbitrary coefficient.
506 return redux_with_identity(m.cwiseAbs(), scalar_max_op<RealScalar, RealScalar, PropagateNaN>(), 0);
507 }
508};
509
510} // end namespace internal
511
517 * In all cases, if \c *this is empty, then the value 0 is returned.
518 *
519 * \note For matrices, this function does not compute the <a
520 * href="https://en.wikipedia.org/wiki/Operator_norm">operator-norm</a>. That is, if \c *this is a matrix, then its
521 * coefficients are interpreted as a 1D vector. Nonetheless, you can easily compute the 1-norm and \f$\infty\f$-norm
522 * matrix operator norms using \link TutorialReductionsVisitorsBroadcastingReductionsNorm partial reductions \endlink.
523 *
524 * \sa norm()
525 */
526template <typename Derived>
527template <int p>
528#ifndef EIGEN_PARSED_BY_DOXYGEN
529EIGEN_DEVICE_FUNC inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
530#else
531EIGEN_DEVICE_FUNC MatrixBase<Derived>::RealScalar
532#endif
534 return internal::lpNorm_selector<Derived, p>::run(*this);
535}
536
542template <typename Derived>
543template <int p>
544EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::RealScalar DenseBase<Derived>::lpNorm() const {
545 return derived().matrix().template lpNorm<p>();
546}
547
548//---------- implementation of isUnitary ----------
549
561template <typename Derived>
562bool MatrixBase<Derived>::isUnitary(const RealScalar& prec) const {
563 typename internal::nested_eval<Derived, 1>::type self(derived());
564 for (Index i = 0; i < cols(); ++i) {
565 if (!internal::isApprox(self.col(i).squaredNorm(), static_cast<RealScalar>(1), prec)) return false;
566 for (Index j = 0; j < i; ++j)
567 if (!internal::isMuchSmallerThan(self.col(i).dot(self.col(j)), static_cast<Scalar>(1), prec)) return false;
568 }
569 return true;
570}
571
572} // end namespace Eigen
573
574#endif // EIGEN_DOT_H
internal::traits< Derived >::Scalar maxCoeff() const
Definition Redux.h:841
typename internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:63
RealScalar lpNorm() const
Definition Dot.h:544
constexpr CastXpr< NewType >::Type cast() const
Definition DenseBase.h:66
A matrix or vector expression mapping an existing array of data.
Definition Map.h:97
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:53
void stableNormalize()
Definition Dot.h:439
constexpr ScalarBinaryOpTraits< typenameinternal::traits< Derived >::Scalar, typenameinternal::traits< OtherDerived >::Scalar >::ReturnType dot(const MatrixBase< OtherDerived > &other) const
Definition Dot.h:300
const PlainObject stableNormalized() const
Definition Dot.h:381
const PlainObject normalized() const
Definition Dot.h:340
RealScalar lpNorm() const
Definition Dot.h:533
bool isUnitary(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Dot.h:562
const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > cwiseAbs() const
constexpr RealScalar squaredNorm() const
Definition Dot.h:314
void normalize()
Definition Dot.h:361
RealScalar norm() const
Definition Dot.h:326
constexpr unsigned int DirectAccessBit
Definition Constants.h:160
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:267
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition XprHelper.h:1080