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 #if !(defined(EIGEN_NO_STATIC_ASSERT) && defined(EIGEN_NO_DEBUG)) 74 typedef internal::scalar_conj_product_op<Scalar,typename OtherDerived::Scalar> func;
75 EIGEN_CHECK_BINARY_COMPATIBILIY(func,
Scalar,
typename OtherDerived::Scalar);
78 eigen_assert(size() == other.
size());
80 return internal::dot_nocheck<Derived,OtherDerived>::run(*
this, other);
91 template<
typename Derived>
94 return numext::real((*this).cwiseAbs2().sum());
103 template<
typename Derived>
106 return numext::sqrt(squaredNorm());
118 template<
typename Derived>
119 inline const typename MatrixBase<Derived>::PlainObject
122 typedef typename internal::nested_eval<Derived,2>::type _Nested;
123 _Nested n(derived());
124 RealScalar z = n.squaredNorm();
127 return n / numext::sqrt(z);
140 template<
typename Derived>
143 RealScalar z = squaredNorm();
146 derived() /= numext::sqrt(z);
161 template<
typename Derived>
162 inline const typename MatrixBase<Derived>::PlainObject
165 typedef typename internal::nested_eval<Derived,3>::type _Nested;
166 _Nested n(derived());
167 RealScalar w = n.cwiseAbs().maxCoeff();
168 RealScalar z = (n/w).squaredNorm();
170 return n / (numext::sqrt(z)*w);
186 template<
typename Derived>
189 RealScalar w = cwiseAbs().maxCoeff();
190 RealScalar z = (derived()/w).squaredNorm();
192 derived() /= numext::sqrt(z)*w;
199 template<
typename Derived,
int p>
200 struct lpNorm_selector
206 EIGEN_USING_STD_MATH(pow)
207 return pow(m.
cwiseAbs().array().pow(p).sum(), RealScalar(1)/p);
211 template<
typename Derived>
212 struct lpNorm_selector<Derived, 1>
221 template<
typename Derived>
222 struct lpNorm_selector<Derived, 2>
231 template<
typename Derived>
232 struct lpNorm_selector<Derived, Infinity>
238 if(Derived::SizeAtCompileTime==0 || (Derived::SizeAtCompileTime==
Dynamic && m.
size()==0))
239 return RealScalar(0);
256 template<
typename Derived>
258 #ifndef EIGEN_PARSED_BY_DOXYGEN 261 MatrixBase<Derived>::RealScalar
265 return internal::lpNorm_selector<Derived, p>::run(*
this);
276 template<
typename Derived>
277 template<
typename OtherDerived>
281 typename internal::nested_eval<Derived,2>::type nested(derived());
282 typename internal::nested_eval<OtherDerived,2>::type otherNested(other.
derived());
283 return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
297 template<
typename Derived>
300 typename internal::nested_eval<Derived,1>::type
self(derived());
301 for(
Index i = 0; i < cols(); ++i)
303 if(!internal::isApprox(
self.col(i).squaredNorm(), static_cast<RealScalar>(1), prec))
305 for(
Index j = 0; j < i; ++j)
306 if(!internal::isMuchSmallerThan(
self.col(i).dot(
self.col(j)), static_cast<Scalar>(1), prec))
314 #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:298
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:120
Derived & derived()
Definition: EigenBase.h:44
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:37
void normalize()
Definition: Dot.h:141
RealScalar norm() const
Definition: Dot.h:104
void stableNormalize()
Definition: Dot.h:187
RealScalar squaredNorm() const
Definition: Dot.h:92
Index size() const
Definition: EigenBase.h:65
const PlainObject stableNormalized() const
Definition: Dot.h:163
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:263
bool isOrthogonal(const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Dot.h:279
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