20 template<
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;
34 static inline ResScalar run(
const MatrixBase<T>& a,
const MatrixBase<U>& b)
36 return a.template binaryExpr<conj_prod>(b).sum();
40 template<
typename T,
typename U>
41 struct dot_nocheck<T, U, true>
43 typedef scalar_conj_product_op<typename traits<T>::Scalar,
typename traits<U>::Scalar> conj_prod;
44 typedef typename conj_prod::result_type ResScalar;
46 static inline ResScalar run(
const MatrixBase<T>& a,
const MatrixBase<U>& b)
48 return a.transpose().template binaryExpr<conj_prod>(b).sum();
64 template<
typename Derived>
65 template<
typename OtherDerived>
67 typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,
typename internal::traits<OtherDerived>::Scalar>::ReturnType
70 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
71 EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
72 EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
73 typedef internal::scalar_conj_product_op<Scalar,typename OtherDerived::Scalar> func;
74 EIGEN_CHECK_BINARY_COMPATIBILIY(func,
Scalar,
typename OtherDerived::Scalar);
76 eigen_assert(size() == other.
size());
78 return internal::dot_nocheck<Derived,OtherDerived>::run(*
this, other);
89 template<
typename Derived>
92 return numext::real((*this).cwiseAbs2().sum());
101 template<
typename Derived>
104 return numext::sqrt(squaredNorm());
116 template<
typename Derived>
117 inline const typename MatrixBase<Derived>::PlainObject
120 typedef typename internal::nested_eval<Derived,2>::type _Nested;
121 _Nested n(derived());
122 RealScalar z = n.squaredNorm();
125 return n / numext::sqrt(z);
138 template<
typename Derived>
141 RealScalar z = squaredNorm();
144 derived() /= numext::sqrt(z);
159 template<
typename Derived>
160 inline const typename MatrixBase<Derived>::PlainObject
163 typedef typename internal::nested_eval<Derived,3>::type _Nested;
164 _Nested n(derived());
165 RealScalar w = n.cwiseAbs().maxCoeff();
166 RealScalar z = (n/w).squaredNorm();
168 return n / (numext::sqrt(z)*w);
184 template<
typename Derived>
187 RealScalar w = cwiseAbs().maxCoeff();
188 RealScalar z = (derived()/w).squaredNorm();
190 derived() /= numext::sqrt(z)*w;
197 template<
typename Derived,
int p>
198 struct lpNorm_selector
204 EIGEN_USING_STD_MATH(pow)
205 return pow(m.
cwiseAbs().array().pow(p).sum(), RealScalar(1)/p);
209 template<
typename Derived>
210 struct lpNorm_selector<Derived, 1>
219 template<
typename Derived>
220 struct lpNorm_selector<Derived, 2>
229 template<
typename Derived>
230 struct lpNorm_selector<Derived, Infinity>
236 if(Derived::SizeAtCompileTime==0 || (Derived::SizeAtCompileTime==
Dynamic && m.
size()==0))
237 return RealScalar(0);
254 template<
typename Derived>
256 #ifndef EIGEN_PARSED_BY_DOXYGEN 259 MatrixBase<Derived>::RealScalar
263 return internal::lpNorm_selector<Derived, p>::run(*
this);
274 template<
typename Derived>
275 template<
typename OtherDerived>
279 typename internal::nested_eval<Derived,2>::type nested(derived());
280 typename internal::nested_eval<OtherDerived,2>::type otherNested(other.
derived());
281 return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
295 template<
typename Derived>
298 typename internal::nested_eval<Derived,1>::type
self(derived());
299 for(
Index i = 0; i < cols(); ++i)
301 if(!internal::isApprox(
self.col(i).squaredNorm(), static_cast<RealScalar>(1), prec))
303 for(
Index j = 0; j < i; ++j)
304 if(!internal::isMuchSmallerThan(
self.col(i).dot(
self.col(j)), static_cast<Scalar>(1), prec))
312 #endif // EIGEN_DOT_H internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
bool isUnitary(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Dot.h:296
Namespace containing all symbols from the Eigen library.
Definition: Core:287
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:150
const PlainObject normalized() const
Definition: Dot.h:118
Derived & derived()
Definition: EigenBase.h:44
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:37
void normalize()
Definition: Dot.h:139
RealScalar norm() const
Definition: Dot.h:102
void stableNormalize()
Definition: Dot.h:185
RealScalar squaredNorm() const
Definition: Dot.h:90
Index size() const
Definition: EigenBase.h:65
const PlainObject stableNormalized() const
Definition: Dot.h:161
Definition: Eigen_Colamd.h:50
ScalarBinaryOpTraits< typename internal::traits< Derived >::Scalar, typename internal::traits< OtherDerived >::Scalar >::ReturnType dot(const MatrixBase< OtherDerived > &other) const
Definition: Dot.h:68
RealScalar lpNorm() const
Definition: Dot.h:261
bool isOrthogonal(const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Dot.h:277
const int Dynamic
Definition: Constants.h:21
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
const CwiseAbsReturnType cwiseAbs() const
Definition: MatrixBase.h:33