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,
33 const Scalar* _rhs, Index rhsIncr,
38 template<
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjugateLhs,
bool ConjugateRhs,
int Version>
41 const Scalar* lhs, Index lhsStride,
42 const Scalar* _rhs, Index rhsIncr,
47 const Index PacketSize =
sizeof(Packet)/
sizeof(Scalar);
50 IsRowMajor = StorageOrder==
RowMajor ? 1 : 0,
51 IsLower = UpLo ==
Lower ? 1 : 0,
52 FirstTriangular = IsRowMajor == IsLower
62 Scalar cjAlpha = ConjugateRhs ?
numext::conj(alpha) : alpha;
70 const Scalar* it = _rhs;
71 for (Index i=0; i<size; ++i, it+=rhsIncr)
75 Index bound = (std::max)(Index(0),size-8) & 0xfffffffe;
79 for (Index j=FirstTriangular ? bound : 0;
80 j<(FirstTriangular ? size : bound);j+=2)
85 Scalar t0 = cjAlpha *
rhs[j];
86 Packet ptmp0 = pset1<Packet>(t0);
87 Scalar t1 = cjAlpha * rhs[j+1];
88 Packet ptmp1 = pset1<Packet>(t1);
91 Packet ptmp2 = pset1<Packet>(t2);
93 Packet ptmp3 = pset1<Packet>(t3);
95 size_t starti = FirstTriangular ? 0 : j+2;
96 size_t endi = FirstTriangular ? j : size;
98 size_t alignedEnd = alignedStart + ((endi-alignedStart)/(PacketSize))*(PacketSize);
105 res[j] += cj0.pmul(A1[j], t1);
106 t3 += cj1.pmul(A1[j], rhs[j]);
110 res[j+1] += cj0.pmul(A0[j+1],t0);
111 t2 += cj1.pmul(A0[j+1], rhs[j+1]);
114 for (
size_t i=starti; i<alignedStart; ++i)
116 res[i] += t0 * A0[i] + t1 * A1[i];
126 for (
size_t i=alignedStart; i<alignedEnd; i+=PacketSize)
128 Packet A0i = ploadu<Packet>(a0It); a0It += PacketSize;
129 Packet A1i = ploadu<Packet>(a1It); a1It += PacketSize;
130 Packet Bi = ploadu<Packet>(rhsIt); rhsIt += PacketSize;
131 Packet Xi = pload <Packet>(resIt);
133 Xi = pcj0.pmadd(A0i,ptmp0, pcj0.pmadd(A1i,ptmp1,Xi));
134 ptmp2 = pcj1.pmadd(A0i, Bi, ptmp2);
135 ptmp3 = pcj1.pmadd(A1i, Bi, ptmp3);
136 pstore(resIt,Xi); resIt += PacketSize;
138 for (
size_t i=alignedEnd; i<endi; i++)
140 res[i] += cj0.pmul(A0[i], t0) + cj0.pmul(A1[i],t1);
141 t2 += cj1.pmul(A0[i], rhs[i]);
142 t3 += cj1.pmul(A1[i], rhs[i]);
145 res[j] += alpha * (t2 +
predux(ptmp2));
146 res[j+1] += alpha * (t3 +
predux(ptmp3));
148 for (Index j=FirstTriangular ? 0 : bound;j<(FirstTriangular ? bound : size);j++)
152 Scalar t1 = cjAlpha *
rhs[j];
156 for (Index i=FirstTriangular ? 0 : j+1; i<(FirstTriangular ? j : size); i++)
158 res[i] += cj0.pmul(A0[i], t1);
159 t2 += cj1.pmul(A0[i], rhs[i]);
161 res[j] += alpha * t2;
172 template<
typename Lhs,
int LhsMode,
typename Rhs>
174 :
traits<ProductBase<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true>, Lhs, Rhs> >
178 template<
typename Lhs,
int LhsMode,
typename Rhs>
180 :
public ProductBase<SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true>, Lhs, Rhs >
192 typedef typename Dest::Scalar ResScalar;
193 typedef typename Base::RhsScalar
RhsScalar;
196 eigen_assert(dest.rows()==m_lhs.rows() && dest.cols()==m_rhs.cols());
201 Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(m_lhs)
202 * RhsBlasTraits::extractScalarFactor(m_rhs);
205 EvalToDest = (Dest::InnerStrideAtCompileTime==1),
206 UseRhs = (_ActualRhsType::InnerStrideAtCompileTime==1)
213 EvalToDest ? dest.data() : static_dest.data());
216 UseRhs ?
const_cast<RhsScalar*
>(rhs.data()) : static_rhs.data());
220 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 221 int size = dest.size();
222 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
224 MappedDest(actualDestPtr, dest.size()) = dest;
229 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 230 int size = rhs.size();
231 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
240 &lhs.coeffRef(0,0), lhs.outerStride(),
247 dest = MappedDest(actualDestPtr, dest.size());
252 template<
typename Lhs,
typename Rhs,
int RhsMode>
254 :
traits<ProductBase<SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false>, Lhs, Rhs> >
258 template<
typename Lhs,
typename Rhs,
int RhsMode>
260 :
public ProductBase<SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false>, Lhs, Rhs >
275 Transpose<const Lhs>, 0,
true>(m_rhs.transpose(), m_lhs.transpose()).scaleAndAddTo(destT, alpha);
281 #endif // EIGEN_SELFADJOINT_MATRIX_VECTOR_H
#define EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived)
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
internal::traits< Derived >::Scalar Scalar
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
A matrix or vector expression mapping an existing array of data.
Expression of the transpose of a matrix.
iterative scaling algorithm to equilibrate rows and column norms in matrices
const unsigned int RowMajorBit
SelfadjointProductMatrix(const Lhs &lhs, const Rhs &rhs)
void pstore(Scalar *to, const Packet &from)
RealReturnType real() const
static EIGEN_DONT_INLINE void run(Index size, const Scalar *lhs, Index lhsStride, const Scalar *_rhs, Index rhsIncr, Scalar *res, Scalar alpha)
#define EIGEN_LOGICAL_XOR(a, b)
void scaleAndAddTo(Dest &dest, const Scalar &alpha) const
SelfadjointProductMatrix(const Lhs &lhs, const Rhs &rhs)
unpacket_traits< Packet >::type predux(const Packet &a)
void rhs(const real_t *x, real_t *f)
internal::traits< Rhs >::Scalar RhsScalar
void scaleAndAddTo(Dest &dest, const Scalar &alpha) const
#define EIGEN_DONT_INLINE
static Derived::Index first_aligned(const Derived &m)