20template<
typename T,
typename U,
21 bool NeedToTranspose = T::IsVectorAtCompileTime && U::IsVectorAtCompileTime &&
22 ((int(T::RowsAtCompileTime) == 1 && int(U::ColsAtCompileTime) == 1) ||
23 (int(T::ColsAtCompileTime) == 1 && int(U::RowsAtCompileTime) == 1))>
26 typedef scalar_conj_product_op<typename traits<T>::Scalar,
typename traits<U>::Scalar> conj_prod;
27 typedef typename conj_prod::result_type ResScalar;
30 static ResScalar run(
const MatrixBase<T>& a,
const MatrixBase<U>& b)
32 return a.template binaryExpr<conj_prod>(b).sum();
36template<
typename T,
typename U>
37struct dot_nocheck<T, U, true>
39 typedef scalar_conj_product_op<typename traits<T>::Scalar,
typename traits<U>::Scalar> conj_prod;
40 typedef typename conj_prod::result_type ResScalar;
43 static ResScalar run(
const MatrixBase<T>& a,
const MatrixBase<U>& b)
45 return a.transpose().template binaryExpr<conj_prod>(b).sum();
62template<
typename Derived>
63template<
typename OtherDerived>
69 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
70 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
71 EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
72#if !(defined(EIGEN_NO_STATIC_ASSERT) && defined(EIGEN_NO_DEBUG))
73 typedef internal::scalar_conj_product_op<Scalar,typename OtherDerived::Scalar> func;
74 EIGEN_CHECK_BINARY_COMPATIBILIY(func,
Scalar,
typename OtherDerived::Scalar);
77 eigen_assert(size() == other.size());
79 return internal::dot_nocheck<Derived,OtherDerived>::run(*
this, other);
90template<
typename Derived>
93 return numext::real((*this).cwiseAbs2().sum());
102template<
typename Derived>
117template<
typename Derived>
118EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const typename MatrixBase<Derived>::PlainObject
121 typedef typename internal::nested_eval<Derived,2>::type _Nested;
122 _Nested n(derived());
123 RealScalar z = n.squaredNorm();
126 return n / numext::sqrt(z);
139template<
typename Derived>
145 derived() /= numext::sqrt(z);
160template<
typename Derived>
161EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const typename MatrixBase<Derived>::PlainObject
164 typedef typename internal::nested_eval<Derived,3>::type _Nested;
165 _Nested n(derived());
166 RealScalar w = n.cwiseAbs().maxCoeff();
169 return n / (numext::sqrt(z)*w);
185template<
typename Derived>
188 RealScalar w =
cwiseAbs().maxCoeff();
191 derived() /= numext::sqrt(z)*w;
198template<
typename Derived,
int p>
199struct lpNorm_selector
203 static inline RealScalar run(
const MatrixBase<Derived>& m)
206 return pow(m.
cwiseAbs().array().pow(p).sum(), RealScalar(1)/p);
210template<
typename Derived>
211struct lpNorm_selector<Derived, 1>
220template<
typename Derived>
221struct lpNorm_selector<Derived, 2>
224 static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(
const MatrixBase<Derived>& m)
230template<
typename Derived>
231struct lpNorm_selector<Derived,
Infinity>
233 typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar;
235 static inline RealScalar run(
const MatrixBase<Derived>& m)
237 if(Derived::SizeAtCompileTime==0 || (Derived::SizeAtCompileTime==
Dynamic && m.size()==0))
238 return RealScalar(0);
239 return m.cwiseAbs().maxCoeff();
255template<
typename Derived>
257#ifndef EIGEN_PARSED_BY_DOXYGEN
260EIGEN_DEVICE_FUNC MatrixBase<Derived>::RealScalar
264 return internal::lpNorm_selector<Derived, p>::run(*
this);
275template<
typename Derived>
276template<
typename OtherDerived>
278(
const MatrixBase<OtherDerived>& other,
const RealScalar& prec)
const
280 typename internal::nested_eval<Derived,2>::type nested(derived());
281 typename internal::nested_eval<OtherDerived,2>::type otherNested(other.derived());
282 return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
296template<
typename Derived>
299 typename internal::nested_eval<Derived,1>::type self(derived());
300 for(
Index i = 0; i < cols(); ++i)
302 if(!internal::isApprox(self.col(i).squaredNorm(),
static_cast<RealScalar
>(1), prec))
304 for(
Index j = 0; j < i; ++j)
305 if(!internal::isMuchSmallerThan(self.col(i).dot(self.col(j)),
static_cast<Scalar>(1), prec))
const CwiseBinaryOp< internal::scalar_pow_op< Derived::Scalar, ScalarExponent >, Derived, Constant< ScalarExponent > > pow(const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent)
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:66
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
void stableNormalize()
Definition Dot.h:186
const PlainObject stableNormalized() const
Definition Dot.h:162
const PlainObject normalized() const
Definition Dot.h:119
RealScalar lpNorm() const
Definition Dot.h:262
ScalarBinaryOpTraits< typenameinternal::traits< Derived >::Scalar, typenameinternal::traits< OtherDerived >::Scalar >::ReturnType dot(const MatrixBase< OtherDerived > &other) const
Definition Dot.h:67
bool isUnitary(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Dot.h:297
const MatrixPowerReturnValue< MatrixWrapper< ExpressionType > > pow(const RealScalar &p) const
RealScalar squaredNorm() const
Definition Dot.h:91
void normalize()
Definition Dot.h:140
RealScalar norm() const
Definition Dot.h:103
const CwiseAbsReturnType cwiseAbs() const
Definition MatrixBase.h:34
bool isOrthogonal(const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Dot.h:278
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Infinity
Definition Constants.h:36
const int Dynamic
Definition Constants.h:22
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:236
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition XprHelper.h:806