10#ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_H
11#define EIGEN_SELFADJOINT_MATRIX_VECTOR_H
23template<
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjugateLhs,
bool ConjugateRhs,
int Version=Specialized>
24struct selfadjoint_matrix_vector_product;
26template<
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjugateLhs,
bool ConjugateRhs,
int Version>
33 const Scalar* lhs,
Index lhsStride,
39template<
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjugateLhs,
bool ConjugateRhs,
int Version>
43 const Scalar* lhs,
Index lhsStride,
50 const Index PacketSize =
sizeof(Packet)/
sizeof(Scalar);
53 IsRowMajor = StorageOrder==
RowMajor ? 1 : 0,
54 IsLower = UpLo ==
Lower ? 1 : 0,
55 FirstTriangular = IsRowMajor == IsLower
65 Scalar cjAlpha = ConjugateRhs ? numext::conj(alpha) : alpha;
71 for (
Index j=FirstTriangular ? bound : 0;
72 j<(FirstTriangular ?
size : bound);j+=2)
77 Scalar t0 = cjAlpha * rhs[j];
78 Packet ptmp0 = pset1<Packet>(t0);
79 Scalar t1 = cjAlpha * rhs[j+1];
80 Packet ptmp1 = pset1<Packet>(t1);
83 Packet ptmp2 = pset1<Packet>(t2);
85 Packet ptmp3 = pset1<Packet>(t3);
87 Index starti = FirstTriangular ? 0 : j+2;
90 Index alignedEnd = alignedStart + ((endi-alignedStart)/(PacketSize))*(PacketSize);
96 res[j] += cj0.
pmul(A1[j], t1);
97 t3 += cj1.
pmul(A1[j], rhs[j]);
101 res[j+1] += cj0.
pmul(A0[j+1],t0);
102 t2 += cj1.
pmul(A0[j+1], rhs[j+1]);
105 for (
Index i=starti; i<alignedStart; ++i)
107 res[i] += cj0.
pmul(A0[i], t0) + cj0.
pmul(A1[i],t1);
108 t2 += cj1.
pmul(A0[i], rhs[i]);
109 t3 += cj1.
pmul(A1[i], rhs[i]);
117 for (
Index i=alignedStart; i<alignedEnd; i+=PacketSize)
119 Packet A0i = ploadu<Packet>(a0It); a0It += PacketSize;
120 Packet A1i = ploadu<Packet>(a1It); a1It += PacketSize;
121 Packet Bi = ploadu<Packet>(rhsIt); rhsIt += PacketSize;
122 Packet Xi = pload <Packet>(resIt);
124 Xi = pcj0.
pmadd(A0i,ptmp0, pcj0.
pmadd(A1i,ptmp1,Xi));
125 ptmp2 = pcj1.
pmadd(A0i, Bi, ptmp2);
126 ptmp3 = pcj1.
pmadd(A1i, Bi, ptmp3);
127 pstore(resIt,Xi); resIt += PacketSize;
129 for (
Index i=alignedEnd; i<endi; i++)
131 res[i] += cj0.
pmul(A0[i], t0) + cj0.
pmul(A1[i],t1);
132 t2 += cj1.
pmul(A0[i], rhs[i]);
133 t3 += cj1.
pmul(A1[i], rhs[i]);
136 res[j] += alpha * (t2 +
predux(ptmp2));
137 res[j+1] += alpha * (t3 +
predux(ptmp3));
139 for (
Index j=FirstTriangular ? 0 : bound;j<(FirstTriangular ? bound :
size);j++)
143 Scalar t1 = cjAlpha * rhs[j];
146 for (
Index i=FirstTriangular ? 0 : j+1; i<(FirstTriangular ? j :
size); i++)
148 res[i] += cj0.
pmul(A0[i], t1);
149 t2 += cj1.
pmul(A0[i], rhs[i]);
151 res[j] += alpha * t2;
163template<
typename Lhs,
int LhsMode,
typename Rhs>
178 template<
typename Dest>
180 void run(Dest& dest,
const Lhs &a_lhs,
const Rhs &a_rhs,
const Scalar& alpha)
182 typedef typename Dest::Scalar ResScalar;
183 typedef typename Rhs::Scalar RhsScalar;
186 eigen_assert(dest.rows()==a_lhs.rows() && dest.cols()==a_rhs.cols());
191 Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(a_lhs)
192 * RhsBlasTraits::extractScalarFactor(a_rhs);
195 EvalToDest = (Dest::InnerStrideAtCompileTime==1),
196 UseRhs = (ActualRhsTypeCleaned::InnerStrideAtCompileTime==1)
203 EvalToDest ? dest.data() : static_dest.data());
206 UseRhs ?
const_cast<RhsScalar*
>(rhs.data()) : static_rhs.data());
210 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
212 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
214 MappedDest(actualDestPtr, dest.size()) = dest;
219 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
221 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
228 int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)>::run
231 &lhs.coeffRef(0,0), lhs.outerStride(),
238 dest = MappedDest(actualDestPtr, dest.size());
242template<
typename Lhs,
typename Rhs,
int RhsMode>
248 template<
typename Dest>
249 static void run(Dest& dest,
const Lhs &a_lhs,
const Rhs &a_rhs,
const Scalar& alpha)
EIGEN_DEVICE_FUNC RealReturnType real() const
Definition: CommonCwiseUnaryOps.h:100
#define EIGEN_RESTRICT
Definition: Macros.h:1170
#define EIGEN_PLAIN_ENUM_MIN(a, b)
Definition: Macros.h:1298
#define EIGEN_LOGICAL_XOR(a, b)
Definition: Macros.h:1323
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define EIGEN_DONT_INLINE
Definition: Macros.h:950
#define eigen_assert(x)
Definition: Macros.h:1047
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:768
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:75
Expression of the transpose of a matrix.
Definition: Transpose.h:54
@ Lower
View matrix as a lower triangular matrix.
Definition: Constants.h:209
@ Upper
View matrix as an upper triangular matrix.
Definition: Constants.h:211
@ AlignedMax
Definition: Constants.h:252
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:319
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:321
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:66
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux(const Packet &a)
Definition: GenericPacketMath.h:875
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
EIGEN_DEVICE_FUNC void pstore(Scalar *to, const Packet &from)
Definition: GenericPacketMath.h:696
EIGEN_DEVICE_FUNC Index first_default_aligned(const Scalar *array, Index size)
Definition: Memory.h:497
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
Definition: MathFunctions.h:1091
Namespace containing all symbols from the Eigen library.
Definition: MatrixExponential.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: Eigen_Colamd.h:50
Holds information about the various numeric (i.e.
Definition: NumTraits.h:233
const T type
Definition: Meta.h:214
Definition: BlasUtil.h:403
Definition: ConjHelper.h:63
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType pmadd(const LhsType &x, const RhsType &y, const ResultType &c) const
Definition: ConjHelper.h:67
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType pmul(const LhsType &x, const RhsType &y) const
Definition: ConjHelper.h:71
Definition: GeneralProduct.h:161
Definition: GenericPacketMath.h:107
T type
Definition: GenericPacketMath.h:108
T type
Definition: Meta.h:126
Definition: SelfadjointMatrixVector.h:29
static EIGEN_DONT_INLINE EIGEN_DEVICE_FUNC void run(Index size, const Scalar *lhs, Index lhsStride, const Scalar *rhs, Scalar *res, Scalar alpha)
Definition: SelfadjointMatrixVector.h:41
static void run(Dest &dest, const Lhs &a_lhs, const Rhs &a_rhs, const Scalar &alpha)
Definition: SelfadjointMatrixVector.h:249
Product< Lhs, Rhs >::Scalar Scalar
Definition: SelfadjointMatrixVector.h:245
internal::remove_all< ActualLhsType >::type ActualLhsTypeCleaned
Definition: SelfadjointMatrixVector.h:170
static EIGEN_DEVICE_FUNC void run(Dest &dest, const Lhs &a_lhs, const Rhs &a_rhs, const Scalar &alpha)
Definition: SelfadjointMatrixVector.h:180
LhsBlasTraits::DirectLinearAccessType ActualLhsType
Definition: SelfadjointMatrixVector.h:169
internal::blas_traits< Lhs > LhsBlasTraits
Definition: SelfadjointMatrixVector.h:168
RhsBlasTraits::DirectLinearAccessType ActualRhsType
Definition: SelfadjointMatrixVector.h:173
Product< Lhs, Rhs >::Scalar Scalar
Definition: SelfadjointMatrixVector.h:166
internal::remove_all< ActualRhsType >::type ActualRhsTypeCleaned
Definition: SelfadjointMatrixVector.h:174
internal::blas_traits< Rhs > RhsBlasTraits
Definition: SelfadjointMatrixVector.h:172
Definition: ProductEvaluators.h:793
Definition: ForwardDeclarations.h:17