20template<
typename T,
typename U,
22 bool NeedToTranspose = T::IsVectorAtCompileTime
23 && U::IsVectorAtCompileTime
24 && ((int(T::RowsAtCompileTime) == 1 && int(U::ColsAtCompileTime) == 1)
27 (int(T::ColsAtCompileTime) == 1 && int(U::RowsAtCompileTime) == 1))
31 typedef scalar_conj_product_op<typename traits<T>::Scalar,
typename traits<U>::Scalar> conj_prod;
32 typedef typename conj_prod::result_type ResScalar;
35 static ResScalar run(
const MatrixBase<T>& a,
const MatrixBase<U>& b)
37 return a.template binaryExpr<conj_prod>(b).sum();
41template<
typename T,
typename U>
42struct dot_nocheck<T, U, true>
44 typedef scalar_conj_product_op<typename traits<T>::Scalar,
typename traits<U>::Scalar> conj_prod;
45 typedef typename conj_prod::result_type ResScalar;
48 static ResScalar run(
const MatrixBase<T>& a,
const MatrixBase<U>& b)
50 return a.transpose().template binaryExpr<conj_prod>(b).sum();
67template<
typename Derived>
68template<
typename OtherDerived>
74 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
75 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
76 EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
77#if !(defined(EIGEN_NO_STATIC_ASSERT) && defined(EIGEN_NO_DEBUG))
78 typedef internal::scalar_conj_product_op<Scalar,typename OtherDerived::Scalar> func;
79 EIGEN_CHECK_BINARY_COMPATIBILIY(func,
Scalar,
typename OtherDerived::Scalar);
82 eigen_assert(
size() == other.
size());
84 return internal::dot_nocheck<Derived,OtherDerived>::run(*
this, other);
95template<
typename Derived>
98 return numext::real((*this).cwiseAbs2().sum());
107template<
typename Derived>
122template<
typename Derived>
123EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const typename MatrixBase<Derived>::PlainObject
126 typedef typename internal::nested_eval<Derived,2>::type _Nested;
128 RealScalar
z = n.squaredNorm();
131 return n / numext::sqrt(
z);
144template<
typename Derived>
165template<
typename Derived>
166EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const typename MatrixBase<Derived>::PlainObject
169 typedef typename internal::nested_eval<Derived,3>::type _Nested;
171 RealScalar
w = n.cwiseAbs().maxCoeff();
174 return n / (numext::sqrt(
z)*
w);
190template<
typename Derived>
196 derived() /= numext::sqrt(z)*w;
203template<
typename Derived,
int p>
204struct lpNorm_selector
208 static inline RealScalar run(
const MatrixBase<Derived>& m)
211 return pow(m.
cwiseAbs().array().pow(p).sum(), RealScalar(1)/p);
215template<
typename Derived>
216struct lpNorm_selector<Derived, 1>
225template<
typename Derived>
226struct lpNorm_selector<Derived, 2>
235template<
typename Derived>
236struct lpNorm_selector<Derived,
Infinity>
240 static inline RealScalar run(
const MatrixBase<Derived>& m)
242 if(Derived::SizeAtCompileTime==0 || (Derived::SizeAtCompileTime==
Dynamic && m.
size()==0))
243 return RealScalar(0);
260template<
typename Derived>
262#ifndef EIGEN_PARSED_BY_DOXYGEN
265EIGEN_DEVICE_FUNC MatrixBase<Derived>::RealScalar
269 return internal::lpNorm_selector<Derived, p>::run(*
this);
280template<
typename Derived>
281template<
typename OtherDerived>
283(
const MatrixBase<OtherDerived>& other,
const RealScalar& prec)
const
285 typename internal::nested_eval<Derived,2>::type nested(derived());
286 typename internal::nested_eval<OtherDerived,2>::type otherNested(other.
derived());
287 return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
301template<
typename Derived>
304 typename internal::nested_eval<Derived,1>::type self(
derived());
307 if(!internal::isApprox(self.col(i).squaredNorm(),
static_cast<RealScalar
>(1), prec))
309 for(
Index j = 0; j < i; ++j)
310 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
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition EigenBase.h:63
Derived & derived()
Definition EigenBase.h:46
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition EigenBase.h:67
Scalar & z()
Definition DenseCoeffsBase.h:451
Scalar & w()
Definition DenseCoeffsBase.h:461
void stableNormalize()
Definition Dot.h:191
const PlainObject stableNormalized() const
Definition Dot.h:167
const PlainObject normalized() const
Definition Dot.h:124
RealScalar lpNorm() const
Definition Dot.h:267
ScalarBinaryOpTraits< typenameinternal::traits< Derived >::Scalar, typenameinternal::traits< OtherDerived >::Scalar >::ReturnType dot(const MatrixBase< OtherDerived > &other) const
Definition Dot.h:72
bool isUnitary(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Dot.h:302
const MatrixPowerReturnValue< Homogeneous< MatrixType, _Direction > > pow(const RealScalar &p) const
RealScalar squaredNorm() const
Definition Dot.h:96
void normalize()
Definition Dot.h:145
RealScalar norm() const
Definition Dot.h:108
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:283
Namespace containing all symbols from the Eigen library.
Definition Core:141
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:233
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition XprHelper.h:806