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();
65 template<
typename Derived>
66 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 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 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
207 EIGEN_USING_STD_MATH(pow)
208 return pow(m.
cwiseAbs().array().pow(p).sum(), RealScalar(1)/p);
212 template<
typename Derived>
213 struct lpNorm_selector<Derived, 1>
222 template<
typename Derived>
223 struct lpNorm_selector<Derived, 2>
232 template<
typename Derived>
233 struct lpNorm_selector<Derived, Infinity>
239 if(Derived::SizeAtCompileTime==0 || (Derived::SizeAtCompileTime==
Dynamic && m.
size()==0))
240 return RealScalar(0);
257 template<
typename Derived>
259 #ifndef EIGEN_PARSED_BY_DOXYGEN 262 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))
315 #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:299
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:121
Derived & derived()
Definition: EigenBase.h:45
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:38
void normalize()
Definition: Dot.h:142
RealScalar norm() const
Definition: Dot.h:105
void stableNormalize()
Definition: Dot.h:188
RealScalar squaredNorm() const
Definition: Dot.h:93
Index size() const
Definition: EigenBase.h:66
const PlainObject stableNormalized() const
Definition: Dot.h:164
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:69
RealScalar lpNorm() const
Definition: Dot.h:264
bool isOrthogonal(const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Dot.h:280
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