10 #ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_H 11 #define EIGEN_SELFADJOINT_MATRIX_VECTOR_H 23 template<
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjugateLhs,
bool ConjugateRhs,
int Version=Specialized>
26 template<
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjugateLhs,
bool ConjugateRhs,
int Version>
32 const Scalar* lhs,
Index lhsStride,
38 template<
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjugateLhs,
bool ConjugateRhs,
int Version>
41 const Scalar* lhs,
Index lhsStride,
48 const Index PacketSize =
sizeof(Packet)/
sizeof(Scalar);
51 IsRowMajor = StorageOrder==
RowMajor ? 1 : 0,
52 IsLower = UpLo ==
Lower ? 1 : 0,
53 FirstTriangular = IsRowMajor == IsLower
63 Scalar cjAlpha = ConjugateRhs ?
numext::conj(alpha) : alpha;
70 for (
Index j=FirstTriangular ? bound : 0;
71 j<(FirstTriangular ? size : bound);j+=2)
76 Scalar t0 = cjAlpha * rhs[j];
77 Packet ptmp0 = pset1<Packet>(t0);
78 Scalar t1 = cjAlpha * rhs[j+1];
79 Packet ptmp1 = pset1<Packet>(t1);
82 Packet ptmp2 = pset1<Packet>(t2);
84 Packet ptmp3 = pset1<Packet>(t3);
86 Index starti = FirstTriangular ? 0 : j+2;
89 Index alignedEnd = alignedStart + ((endi-alignedStart)/(PacketSize))*(PacketSize);
95 res[j] += cj0.
pmul(A1[j], t1);
96 t3 += cj1.
pmul(A1[j], rhs[j]);
100 res[j+1] += cj0.
pmul(A0[j+1],t0);
101 t2 += cj1.
pmul(A0[j+1], rhs[j+1]);
104 for (
Index i=starti; i<alignedStart; ++i)
106 res[i] += cj0.
pmul(A0[i], t0) + cj0.
pmul(A1[i],t1);
107 t2 += cj1.
pmul(A0[i], rhs[i]);
108 t3 += cj1.
pmul(A1[i], rhs[i]);
116 for (
Index i=alignedStart; i<alignedEnd; i+=PacketSize)
118 Packet A0i = ploadu<Packet>(a0It); a0It += PacketSize;
119 Packet A1i = ploadu<Packet>(a1It); a1It += PacketSize;
120 Packet Bi = ploadu<Packet>(rhsIt); rhsIt += PacketSize;
121 Packet Xi = pload <Packet>(resIt);
123 Xi = pcj0.
pmadd(A0i,ptmp0, pcj0.
pmadd(A1i,ptmp1,Xi));
124 ptmp2 = pcj1.
pmadd(A0i, Bi, ptmp2);
125 ptmp3 = pcj1.
pmadd(A1i, Bi, ptmp3);
126 pstore(resIt,Xi); resIt += PacketSize;
128 for (
Index i=alignedEnd; i<endi; i++)
130 res[i] += cj0.
pmul(A0[i], t0) + cj0.
pmul(A1[i],t1);
131 t2 += cj1.
pmul(A0[i], rhs[i]);
132 t3 += cj1.
pmul(A1[i], rhs[i]);
135 res[j] += alpha * (t2 +
predux(ptmp2));
136 res[j+1] += alpha * (t3 +
predux(ptmp3));
138 for (
Index j=FirstTriangular ? 0 : bound;j<(FirstTriangular ? bound :
size);j++)
142 Scalar t1 = cjAlpha * rhs[j];
145 for (
Index i=FirstTriangular ? 0 : j+1; i<(FirstTriangular ? j :
size); i++)
147 res[i] += cj0.
pmul(A0[i], t1);
148 t2 += cj1.
pmul(A0[i], rhs[i]);
150 res[j] += alpha * t2;
162 template<
typename Lhs,
int LhsMode,
typename Rhs>
177 template<
typename Dest>
178 static void run(Dest& dest,
const Lhs &a_lhs,
const Rhs &a_rhs,
const Scalar& alpha)
180 typedef typename Dest::Scalar ResScalar;
181 typedef typename Rhs::Scalar RhsScalar;
184 eigen_assert(dest.rows()==a_lhs.rows() && dest.cols()==a_rhs.cols());
189 Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(a_lhs)
190 * RhsBlasTraits::extractScalarFactor(a_rhs);
193 EvalToDest = (Dest::InnerStrideAtCompileTime==1),
194 UseRhs = (ActualRhsTypeCleaned::InnerStrideAtCompileTime==1)
201 EvalToDest ? dest.data() : static_dest.data());
204 UseRhs ?
const_cast<RhsScalar*
>(rhs.data()) : static_rhs.data());
208 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 210 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
212 MappedDest(actualDestPtr, dest.size()) = dest;
217 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 219 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
226 int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)>
::run 229 &lhs.coeffRef(0,0), lhs.outerStride(),
236 dest = MappedDest(actualDestPtr, dest.size());
240 template<
typename Lhs,
typename Rhs,
int RhsMode>
246 template<
typename Dest>
247 static void run(Dest& dest,
const Lhs &a_lhs,
const Rhs &a_rhs,
const Scalar& alpha)
260 #endif // EIGEN_SELFADJOINT_MATRIX_VECTOR_H static void run(Dest &dest, const Lhs &a_lhs, const Rhs &a_rhs, const Scalar &alpha)
internal::remove_all< ActualLhsType >::type ActualLhsTypeCleaned
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
EIGEN_DEVICE_FUNC RealReturnType real() const
Expression of the product of two arbitrary matrices or vectors.
A matrix or vector expression mapping an existing array of data.
Expression of the transpose of a matrix.
RhsBlasTraits::DirectLinearAccessType ActualRhsType
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
Product< Lhs, Rhs >::Scalar Scalar
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux(const Packet &a)
#define EIGEN_LOGICAL_XOR(a, b)
const unsigned int RowMajorBit
#define EIGEN_DONT_INLINE
static Index first_default_aligned(const DenseBase< Derived > &m)
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() max(const half &a, const half &b)
internal::blas_traits< Rhs > RhsBlasTraits
static void run(Dest &dest, const Lhs &a_lhs, const Rhs &a_rhs, const Scalar &alpha)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
LhsBlasTraits::DirectLinearAccessType ActualLhsType
Product< Lhs, Rhs >::Scalar Scalar
static EIGEN_DONT_INLINE void run(Index size, const Scalar *lhs, Index lhsStride, const Scalar *rhs, Scalar *res, Scalar alpha)
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
EIGEN_DEVICE_FUNC void pstore(Scalar *to, const Packet &from)
EIGEN_STRONG_INLINE Scalar pmadd(const LhsScalar &x, const RhsScalar &y, const Scalar &c) const
#define EIGEN_PLAIN_ENUM_MIN(a, b)
internal::remove_all< ActualRhsType >::type ActualRhsTypeCleaned
EIGEN_STRONG_INLINE Scalar pmul(const LhsScalar &x, const RhsScalar &y) const
internal::blas_traits< Lhs > LhsBlasTraits