11 #ifndef EIGEN_ORTHOMETHODS_H
12 #define EIGEN_ORTHOMETHODS_H
21 template<
typename Derived,
typename OtherDerived,
int Size>
24 typedef typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,
typename internal::traits<OtherDerived>::Scalar>::ReturnType Scalar;
28 return_type run(
const MatrixBase<Derived>&
first,
const MatrixBase<OtherDerived>& second)
35 typename
internal::nested_eval<Derived,2>::type lhs(
first.derived());
36 typename
internal::nested_eval<OtherDerived,2>::type rhs(second.derived());
38 numext::
conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)),
39 numext::
conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)),
40 numext::
conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0))
46 template<typename Derived, typename OtherDerived>
47 struct cross_impl<Derived, OtherDerived, 2>
49 typedef typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,
typename internal::traits<OtherDerived>::Scalar>::ReturnType Scalar;
50 typedef Scalar return_type;
53 return_type run(
const MatrixBase<Derived>&
first,
const MatrixBase<OtherDerived>& second)
57 typename internal::nested_eval<Derived,2>::type lhs(
first.derived());
58 typename internal::nested_eval<OtherDerived,2>::type rhs(second.derived());
59 return numext::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0));
84 template<
typename Derived>
85 template<
typename OtherDerived>
87 #ifndef EIGEN_PARSED_BY_DOXYGEN
88 typename internal::cross_impl<Derived, OtherDerived>::return_type
90 inline std::conditional_t<SizeAtCompileTime==2, Scalar, PlainObject>
94 return internal::cross_impl<Derived, OtherDerived>::run(*
this, other);
99 template<
int Arch,
typename VectorLhs,
typename VectorRhs,
100 typename Scalar =
typename VectorLhs::Scalar,
103 EIGEN_DEVICE_FUNC static inline typename internal::plain_matrix_type<VectorLhs>::type
104 run(
const VectorLhs& lhs,
const VectorRhs& rhs)
106 return typename internal::plain_matrix_type<VectorLhs>::type(
107 numext::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)),
108 numext::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)),
109 numext::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)),
126 template<
typename Derived>
127 template<
typename OtherDerived>
134 typedef typename internal::nested_eval<Derived,2>::type DerivedNested;
135 typedef typename internal::nested_eval<OtherDerived,2>::type OtherDerivedNested;
136 DerivedNested lhs(derived());
137 OtherDerivedNested rhs(other.
derived());
153 template<
typename ExpressionType,
int Direction>
154 template<
typename OtherDerived>
161 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
163 typename internal::nested_eval<ExpressionType,2>::type
mat(_expression());
164 typename internal::nested_eval<OtherDerived,2>::type vec(other.
derived());
169 eigen_assert(CrossReturnType::RowsAtCompileTime==3 &&
"the matrix must have exactly 3 rows");
176 eigen_assert(CrossReturnType::ColsAtCompileTime==3 &&
"the matrix must have exactly 3 columns");
186 template<
typename Derived,
int Size = Derived::SizeAtCompileTime>
187 struct unitOrthogonal_selector
189 typedef typename plain_matrix_type<Derived>::type VectorType;
190 typedef typename traits<Derived>::Scalar Scalar;
194 static inline VectorType run(
const Derived& src)
196 VectorType perp = VectorType::Zero(src.size());
199 src.cwiseAbs().maxCoeff(&
maxi);
202 RealScalar invnm = RealScalar(1)/(
Vector2() << src.coeff(sndi),src.coeff(
maxi)).finished().norm();
210 template<
typename Derived>
211 struct unitOrthogonal_selector<Derived,3>
213 typedef typename plain_matrix_type<Derived>::type VectorType;
214 typedef typename traits<Derived>::Scalar Scalar;
217 static inline VectorType run(
const Derived& src)
230 RealScalar invnm = RealScalar(1)/src.template
head<2>().norm();
233 perp.coeffRef(2) = 0;
241 RealScalar invnm = RealScalar(1)/src.template
tail<2>().norm();
242 perp.coeffRef(0) = 0;
251 template<
typename Derived>
252 struct unitOrthogonal_selector<Derived,2>
254 typedef typename plain_matrix_type<Derived>::type VectorType;
256 static inline VectorType run(
const Derived& src)
271 template<
typename Derived>
276 return internal::unitOrthogonal_selector<Derived>::run(derived());
ConjugateReturnType conjugate() const
#define EIGEN_DEVICE_FUNC
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define EIGEN_STATIC_ASSERT(X, MSG)
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Base class for all dense matrices, vectors, and expressions.
internal::cross_impl< Derived, OtherDerived >::return_type cross(const MatrixBase< OtherDerived > &other) const
Base::PlainObject PlainObject
The matrix class, also used for vectors and row-vectors.
ExpressionType::PlainObject CrossReturnType
const CrossReturnType cross(const MatrixBase< OtherDerived > &other) const
PlainObject unitOrthogonal(void) const
PlainObject cross3(const MatrixBase< OtherDerived > &other) const
const unsigned int PacketAccessBit
Matrix< Type, 2, 1 > Vector2
[c++11] 2×1 vector of type Type.
typename remove_all< T >::type remove_all_t
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.