13 #include "./InternalHeaderCheck.h"
22 template<
typename T,
typename U,
23 bool NeedToTranspose = T::IsVectorAtCompileTime && U::IsVectorAtCompileTime &&
24 ((int(T::RowsAtCompileTime) == 1 && int(U::ColsAtCompileTime) == 1) ||
25 (
int(T::ColsAtCompileTime) == 1 && int(U::RowsAtCompileTime) == 1))>
28 typedef scalar_conj_product_op<typename traits<T>::Scalar,
typename traits<U>::Scalar> conj_prod;
29 typedef typename conj_prod::result_type ResScalar;
32 static ResScalar run(
const MatrixBase<T>& a,
const MatrixBase<U>& b)
34 return a.template binaryExpr<conj_prod>(b).sum();
38 template<
typename T,
typename U>
39 struct dot_nocheck<T, U, true>
41 typedef scalar_conj_product_op<typename traits<T>::Scalar,
typename traits<U>::Scalar> conj_prod;
42 typedef typename conj_prod::result_type ResScalar;
45 static ResScalar run(
const MatrixBase<T>& a,
const MatrixBase<U>& b)
47 return a.transpose().template binaryExpr<conj_prod>(b).sum();
64 template<
typename Derived>
65 template<
typename OtherDerived>
68 typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,
typename internal::traits<OtherDerived>::Scalar>::ReturnType
71 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
72 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
73 EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
74 #if !(defined(EIGEN_NO_STATIC_ASSERT) && defined(EIGEN_NO_DEBUG))
75 typedef internal::scalar_conj_product_op<Scalar,typename OtherDerived::Scalar> func;
76 EIGEN_CHECK_BINARY_COMPATIBILIY(func,
Scalar,
typename OtherDerived::Scalar);
79 eigen_assert(size() == other.
size());
81 return internal::dot_nocheck<Derived,OtherDerived>::run(*
this, other);
92 template<
typename Derived>
95 return numext::real((*this).cwiseAbs2().sum());
104 template<
typename Derived>
107 return numext::sqrt(squaredNorm());
119 template<
typename Derived>
120 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const typename MatrixBase<Derived>::PlainObject
123 typedef typename internal::nested_eval<Derived,2>::type Nested_;
124 Nested_ n(derived());
125 RealScalar z = n.squaredNorm();
128 return n / numext::sqrt(z);
141 template<
typename Derived>
144 RealScalar z = squaredNorm();
147 derived() /= numext::sqrt(z);
162 template<
typename Derived>
163 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const typename MatrixBase<Derived>::PlainObject
166 typedef typename internal::nested_eval<Derived,3>::type Nested_;
167 Nested_ n(derived());
168 RealScalar w = n.cwiseAbs().maxCoeff();
169 RealScalar z = (n/w).squaredNorm();
171 return n / (numext::sqrt(z)*w);
187 template<
typename Derived>
190 RealScalar w = cwiseAbs().maxCoeff();
191 RealScalar z = (derived()/w).squaredNorm();
193 derived() /= numext::sqrt(z)*w;
200 template<
typename Derived,
int p>
201 struct lpNorm_selector
208 return pow(m.cwiseAbs().
array().pow(p).sum(), RealScalar(1)/p);
212 template<
typename Derived>
213 struct lpNorm_selector<Derived, 1>
218 return m.cwiseAbs().
sum();
222 template<
typename Derived>
223 struct lpNorm_selector<Derived, 2>
226 static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(
const MatrixBase<Derived>& m)
232 template<
typename Derived>
233 struct lpNorm_selector<Derived,
Infinity>
235 typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar;
237 static inline RealScalar run(
const MatrixBase<Derived>& m)
239 if(Derived::SizeAtCompileTime==0 || (Derived::SizeAtCompileTime==
Dynamic && m.size()==0))
240 return RealScalar(0);
241 return m.cwiseAbs().maxCoeff();
257 template<
typename Derived>
259 #ifndef EIGEN_PARSED_BY_DOXYGEN
260 EIGEN_DEVICE_FUNC
inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
262 EIGEN_DEVICE_FUNC MatrixBase<Derived>::RealScalar
266 return internal::lpNorm_selector<Derived, p>::run(*
this);
277 template<
typename Derived>
278 template<
typename OtherDerived>
282 typename internal::nested_eval<Derived,2>::type nested(derived());
283 typename internal::nested_eval<OtherDerived,2>::type otherNested(other.
derived());
284 return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
298 template<
typename Derived>
301 typename internal::nested_eval<Derived,1>::type
self(derived());
302 for(
Index i = 0; i < cols(); ++i)
304 if(!internal::isApprox(
self.col(i).squaredNorm(),
static_cast<RealScalar
>(1), prec))
306 for(
Index j = 0; j < i; ++j)
307 if(!internal::isMuchSmallerThan(
self.col(i).dot(
self.col(j)),
static_cast<Scalar>(1), prec))
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61
Scalar sum() const
Definition: Redux.h:461
Derived & derived()
Definition: EigenBase.h:48
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:69
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
void stableNormalize()
Definition: Dot.h:188
RealScalar norm() const
Definition: Dot.h:105
ArrayWrapper< Derived > array()
Definition: MatrixBase.h:315
const PlainObject stableNormalized() const
Definition: Dot.h:164
const PlainObject normalized() const
Definition: Dot.h:121
RealScalar lpNorm() const
Definition: Dot.h:264
bool isUnitary(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Dot.h:299
RealScalar squaredNorm() const
Definition: Dot.h:93
void normalize()
Definition: Dot.h:142
ScalarBinaryOpTraits< typename internal::traits< Derived >::Scalar, typename internal::traits< OtherDerived >::Scalar >::ReturnType dot(const MatrixBase< OtherDerived > &other) const
Definition: Dot.h:69
bool isOrthogonal(const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Dot.h:280
Namespace containing all symbols from the Eigen library.
Definition: Core:139
const int Infinity
Definition: Constants.h:38
const int Dynamic
Definition: Constants.h:24
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231