10 #ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_H 11 #define EIGEN_SELFADJOINT_MATRIX_MATRIX_H 18 template<
typename Scalar,
typename Index,
int Pack1,
int Pack2_dummy,
int StorageOrder>
21 template<
int BlockRows>
inline 25 for(
Index k=0; k<i; k++)
26 for(
Index w=0; w<BlockRows; w++)
27 blockA[count++] = lhs(i+w,k);
30 for(
Index k=i; k<i+BlockRows; k++)
32 for(
Index w=0; w<h; w++)
33 blockA[count++] = numext::conj(lhs(k, i+w));
35 blockA[count++] = numext::real(lhs(k,k));
37 for(
Index w=h+1; w<BlockRows; w++)
38 blockA[count++] = lhs(i+w, k);
42 for(
Index k=i+BlockRows; k<cols; k++)
43 for(
Index w=0; w<BlockRows; w++)
44 blockA[count++] = numext::conj(lhs(k, i+w));
46 void operator()(Scalar* blockA,
const Scalar* _lhs,
Index lhsStride,
Index cols,
Index rows)
53 const Index peeled_mc3 = Pack1>=3*PacketSize ? (rows/(3*PacketSize))*(3*PacketSize) : 0;
54 const Index peeled_mc2 = Pack1>=2*PacketSize ? peeled_mc3+((rows-peeled_mc3)/(2*PacketSize))*(2*PacketSize) : 0;
55 const Index peeled_mc1 = Pack1>=1*PacketSize ? (rows/(1*PacketSize))*(1*PacketSize) : 0;
57 if(Pack1>=3*PacketSize)
58 for(
Index i=0; i<peeled_mc3; i+=3*PacketSize)
59 pack<3*PacketSize>(blockA, lhs, cols, i, count);
61 if(Pack1>=2*PacketSize)
62 for(
Index i=peeled_mc3; i<peeled_mc2; i+=2*PacketSize)
63 pack<2*PacketSize>(blockA, lhs, cols, i, count);
65 if(Pack1>=1*PacketSize)
66 for(
Index i=peeled_mc2; i<peeled_mc1; i+=1*PacketSize)
67 pack<1*PacketSize>(blockA, lhs, cols, i, count);
70 for(
Index i=peeled_mc1; i<rows; i++)
72 for(
Index k=0; k<i; k++)
73 blockA[count++] = lhs(i, k);
75 blockA[count++] = numext::real(lhs(i, i));
77 for(
Index k=i+1; k<cols; k++)
78 blockA[count++] = numext::conj(lhs(k, i));
83 template<
typename Scalar,
typename Index,
int nr,
int StorageOrder>
87 void operator()(Scalar* blockB,
const Scalar* _rhs,
Index rhsStride,
Index rows,
Index cols,
Index k2)
89 Index end_k = k2 + rows;
92 Index packet_cols8 = nr>=8 ? (cols/8) * 8 : 0;
93 Index packet_cols4 = nr>=4 ? (cols/4) * 4 : 0;
96 for(
Index j2=0; j2<k2; j2+=nr)
98 for(
Index k=k2; k<end_k; k++)
100 blockB[count+0] = rhs(k,j2+0);
101 blockB[count+1] = rhs(k,j2+1);
104 blockB[count+2] = rhs(k,j2+2);
105 blockB[count+3] = rhs(k,j2+3);
109 blockB[count+4] = rhs(k,j2+4);
110 blockB[count+5] = rhs(k,j2+5);
111 blockB[count+6] = rhs(k,j2+6);
112 blockB[count+7] = rhs(k,j2+7);
119 Index end8 = nr>=8 ? (std::min)(k2+rows,packet_cols8) : k2;
122 for(
Index j2=k2; j2<end8; j2+=8)
126 for(
Index k=k2; k<j2; k++)
128 blockB[count+0] = numext::conj(rhs(j2+0,k));
129 blockB[count+1] = numext::conj(rhs(j2+1,k));
130 blockB[count+2] = numext::conj(rhs(j2+2,k));
131 blockB[count+3] = numext::conj(rhs(j2+3,k));
132 blockB[count+4] = numext::conj(rhs(j2+4,k));
133 blockB[count+5] = numext::conj(rhs(j2+5,k));
134 blockB[count+6] = numext::conj(rhs(j2+6,k));
135 blockB[count+7] = numext::conj(rhs(j2+7,k));
140 for(
Index k=j2; k<j2+8; k++)
143 for (
Index w=0 ; w<h; ++w)
144 blockB[count+w] = rhs(k,j2+w);
146 blockB[count+h] = numext::real(rhs(k,k));
149 for (
Index w=h+1 ; w<8; ++w)
150 blockB[count+w] = numext::conj(rhs(j2+w,k));
155 for(
Index k=j2+8; k<end_k; k++)
157 blockB[count+0] = rhs(k,j2+0);
158 blockB[count+1] = rhs(k,j2+1);
159 blockB[count+2] = rhs(k,j2+2);
160 blockB[count+3] = rhs(k,j2+3);
161 blockB[count+4] = rhs(k,j2+4);
162 blockB[count+5] = rhs(k,j2+5);
163 blockB[count+6] = rhs(k,j2+6);
164 blockB[count+7] = rhs(k,j2+7);
171 for(
Index j2=end8; j2<(std::min)(k2+rows,packet_cols4); j2+=4)
175 for(
Index k=k2; k<j2; k++)
177 blockB[count+0] = numext::conj(rhs(j2+0,k));
178 blockB[count+1] = numext::conj(rhs(j2+1,k));
179 blockB[count+2] = numext::conj(rhs(j2+2,k));
180 blockB[count+3] = numext::conj(rhs(j2+3,k));
185 for(
Index k=j2; k<j2+4; k++)
188 for (
Index w=0 ; w<h; ++w)
189 blockB[count+w] = rhs(k,j2+w);
191 blockB[count+h] = numext::real(rhs(k,k));
194 for (
Index w=h+1 ; w<4; ++w)
195 blockB[count+w] = numext::conj(rhs(j2+w,k));
200 for(
Index k=j2+4; k<end_k; k++)
202 blockB[count+0] = rhs(k,j2+0);
203 blockB[count+1] = rhs(k,j2+1);
204 blockB[count+2] = rhs(k,j2+2);
205 blockB[count+3] = rhs(k,j2+3);
214 for(
Index j2=k2+rows; j2<packet_cols8; j2+=8)
216 for(
Index k=k2; k<end_k; k++)
218 blockB[count+0] = numext::conj(rhs(j2+0,k));
219 blockB[count+1] = numext::conj(rhs(j2+1,k));
220 blockB[count+2] = numext::conj(rhs(j2+2,k));
221 blockB[count+3] = numext::conj(rhs(j2+3,k));
222 blockB[count+4] = numext::conj(rhs(j2+4,k));
223 blockB[count+5] = numext::conj(rhs(j2+5,k));
224 blockB[count+6] = numext::conj(rhs(j2+6,k));
225 blockB[count+7] = numext::conj(rhs(j2+7,k));
232 for(
Index j2=(std::max)(packet_cols8,k2+rows); j2<packet_cols4; j2+=4)
234 for(
Index k=k2; k<end_k; k++)
236 blockB[count+0] = numext::conj(rhs(j2+0,k));
237 blockB[count+1] = numext::conj(rhs(j2+1,k));
238 blockB[count+2] = numext::conj(rhs(j2+2,k));
239 blockB[count+3] = numext::conj(rhs(j2+3,k));
246 for(
Index j2=packet_cols4; j2<cols; ++j2)
250 for(
Index k=k2; k<half; k++)
252 blockB[count] = numext::conj(rhs(j2,k));
256 if(half==j2 && half<k2+rows)
258 blockB[count] = numext::real(rhs(j2,j2));
265 for(
Index k=half+1; k<k2+rows; k++)
267 blockB[count] = rhs(k,j2);
277 template <
typename Scalar,
typename Index,
278 int LhsStorageOrder,
bool LhsSelfAdjoint,
bool ConjugateLhs,
279 int RhsStorageOrder,
bool RhsSelfAdjoint,
bool ConjugateRhs,
283 template <
typename Scalar,
typename Index,
284 int LhsStorageOrder,
bool LhsSelfAdjoint,
bool ConjugateLhs,
285 int RhsStorageOrder,
bool RhsSelfAdjoint,
bool ConjugateRhs>
289 static EIGEN_STRONG_INLINE
void run(
290 Index rows, Index cols,
291 const Scalar* lhs, Index lhsStride,
292 const Scalar* rhs, Index rhsStride,
293 Scalar* res, Index resStride,
302 ::run(cols, rows, rhs, rhsStride, lhs, lhsStride, res, resStride, alpha, blocking);
306 template <
typename Scalar,
typename Index,
307 int LhsStorageOrder,
bool ConjugateLhs,
308 int RhsStorageOrder,
bool ConjugateRhs>
312 static EIGEN_DONT_INLINE
void run(
313 Index rows, Index cols,
314 const Scalar* _lhs, Index lhsStride,
315 const Scalar* _rhs, Index rhsStride,
316 Scalar* res, Index resStride,
320 template <
typename Scalar,
typename Index,
321 int LhsStorageOrder,
bool ConjugateLhs,
322 int RhsStorageOrder,
bool ConjugateRhs>
324 Index rows, Index cols,
325 const Scalar* _lhs, Index lhsStride,
326 const Scalar* _rhs, Index rhsStride,
327 Scalar* _res, Index resStride,
338 LhsMapper lhs(_lhs,lhsStride);
339 LhsTransposeMapper lhs_transpose(_lhs,lhsStride);
340 RhsMapper rhs(_rhs,rhsStride);
341 ResMapper res(_res, resStride);
343 Index kc = blocking.kc();
344 Index mc = (std::min)(rows,blocking.mc());
346 kc = (std::min)(kc,mc);
347 std::size_t sizeA = kc*mc;
348 std::size_t sizeB = kc*cols;
349 ei_declare_aligned_stack_constructed_variable(Scalar, blockA, sizeA, blocking.blockA());
350 ei_declare_aligned_stack_constructed_variable(Scalar, blockB, sizeB, blocking.blockB());
357 for(Index k2=0; k2<size; k2+=kc)
359 const Index actual_kc = (std::min)(k2+kc,size)-k2;
364 pack_rhs(blockB, rhs.getSubMapper(k2,0), actual_kc, cols);
370 for(Index i2=0; i2<k2; i2+=mc)
372 const Index actual_mc = (std::min)(i2+mc,k2)-i2;
374 pack_lhs_transposed(blockA, lhs_transpose.getSubMapper(i2, k2), actual_kc, actual_mc);
376 gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc, cols, alpha);
380 const Index actual_mc = (std::min)(k2+kc,size)-k2;
382 pack_lhs(blockA, &lhs(k2,k2), lhsStride, actual_kc, actual_mc);
384 gebp_kernel(res.getSubMapper(k2, 0), blockA, blockB, actual_mc, actual_kc, cols, alpha);
387 for(Index i2=k2+kc; i2<size; i2+=mc)
389 const Index actual_mc = (std::min)(i2+mc,size)-i2;
391 (blockA, lhs.getSubMapper(i2, k2), actual_kc, actual_mc);
393 gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc, cols, alpha);
399 template <
typename Scalar,
typename Index,
400 int LhsStorageOrder,
bool ConjugateLhs,
401 int RhsStorageOrder,
bool ConjugateRhs>
405 static EIGEN_DONT_INLINE
void run(
406 Index rows, Index cols,
407 const Scalar* _lhs, Index lhsStride,
408 const Scalar* _rhs, Index rhsStride,
409 Scalar* res, Index resStride,
413 template <
typename Scalar,
typename Index,
414 int LhsStorageOrder,
bool ConjugateLhs,
415 int RhsStorageOrder,
bool ConjugateRhs>
417 Index rows, Index cols,
418 const Scalar* _lhs, Index lhsStride,
419 const Scalar* _rhs, Index rhsStride,
420 Scalar* _res, Index resStride,
429 LhsMapper lhs(_lhs,lhsStride);
430 ResMapper res(_res,resStride);
432 Index kc = blocking.kc();
433 Index mc = (std::min)(rows,blocking.mc());
434 std::size_t sizeA = kc*mc;
435 std::size_t sizeB = kc*cols;
436 ei_declare_aligned_stack_constructed_variable(Scalar, blockA, sizeA, blocking.blockA());
437 ei_declare_aligned_stack_constructed_variable(Scalar, blockB, sizeB, blocking.blockB());
443 for(Index k2=0; k2<size; k2+=kc)
445 const Index actual_kc = (std::min)(k2+kc,size)-k2;
447 pack_rhs(blockB, _rhs, rhsStride, actual_kc, cols, k2);
450 for(Index i2=0; i2<rows; i2+=mc)
452 const Index actual_mc = (std::min)(i2+mc,rows)-i2;
453 pack_lhs(blockA, lhs.getSubMapper(i2, k2), actual_kc, actual_mc);
455 gebp_kernel(res.getSubMapper(i2, 0), blockA, blockB, actual_mc, actual_kc, cols, alpha);
468 template<
typename Lhs,
int LhsMode,
typename Rhs,
int RhsMode>
482 RhsIsSelfAdjoint = (RhsMode&
SelfAdjoint)==SelfAdjoint
485 template<
typename Dest>
486 static void run(Dest &dst,
const Lhs &a_lhs,
const Rhs &a_rhs,
const Scalar& alpha)
488 eigen_assert(dst.rows()==a_lhs.rows() && dst.cols()==a_rhs.cols());
493 Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(a_lhs)
494 * RhsBlasTraits::extractScalarFactor(a_rhs);
497 Lhs::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime, Lhs::MaxColsAtCompileTime,1> BlockingType;
499 BlockingType blocking(lhs.rows(), rhs.cols(), lhs.cols(), 1,
false);
508 lhs.rows(), rhs.cols(),
509 &lhs.coeffRef(0,0), lhs.outerStride(),
510 &rhs.coeffRef(0,0), rhs.outerStride(),
511 &dst.coeffRef(0,0), dst.outerStride(),
512 actualAlpha, blocking
521 #endif // EIGEN_SELFADJOINT_MATRIX_MATRIX_H Definition: BlasUtil.h:269
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:320
Definition: BlasUtil.h:28
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:71
Definition: SelfadjointMatrixMatrix.h:281
Definition: GeneralBlockPanelKernel.h:19
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:61
Definition: GenericPacketMath.h:96
Definition: GeneralMatrixMatrix.h:17
View matrix as a lower triangular matrix.
Definition: Constants.h:204
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: BlasUtil.h:256
View matrix as an upper triangular matrix.
Definition: Constants.h:206
Definition: GeneralBlockPanelKernel.h:859
Definition: BlasUtil.h:192
Definition: SelfadjointMatrixMatrix.h:84
Definition: BandTriangularSolver.h:13
Definition: SelfadjointMatrixMatrix.h:19
Used in BandMatrix and SelfAdjointView to indicate that the matrix is self-adjoint.
Definition: Constants.h:220
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:322
Definition: ProductEvaluators.h:736
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
Definition: GeneralMatrixMatrix.h:244
Definition: ForwardDeclarations.h:17
Definition: BlasUtil.h:25