10 #ifndef EIGEN_SELFADJOINT_PRODUCT_H
11 #define EIGEN_SELFADJOINT_PRODUCT_H
22 template<
typename Scalar,
typename Index,
int UpLo,
bool ConjLhs,
bool ConjRhs>
23 struct selfadjoint_rank1_update<Scalar,
Index,
ColMajor,UpLo,ConjLhs,ConjRhs>
25 static void run(
Index size, Scalar* mat,
Index stride,
const Scalar* vecX,
const Scalar* vecY,
const Scalar& alpha)
30 for (
Index i=0; i<size; ++i)
33 += (alpha * cj(vecY[i])) * ConjLhsType(OtherMap(vecX+(UpLo==
Lower ? i : 0),UpLo==
Lower ? size-i : (i+1)));
38 template<
typename Scalar,
typename Index,
int UpLo,
bool ConjLhs,
bool ConjRhs>
39 struct selfadjoint_rank1_update<Scalar,
Index,
RowMajor,UpLo,ConjLhs,ConjRhs>
41 static void run(
Index size, Scalar* mat,
Index stride,
const Scalar* vecX,
const Scalar* vecY,
const Scalar& alpha)
43 selfadjoint_rank1_update<Scalar,Index,ColMajor,UpLo==Lower?Upper:Lower,ConjRhs,ConjLhs>::run(size,mat,stride,vecY,vecX,alpha);
47 template<
typename MatrixType,
typename OtherType,
int UpLo,
bool OtherIsVector = OtherType::IsVectorAtCompileTime>
48 struct selfadjoint_product_selector;
50 template<
typename MatrixType,
typename OtherType,
int UpLo>
51 struct selfadjoint_product_selector<MatrixType,OtherType,UpLo,true>
53 static void run(MatrixType& mat,
const OtherType& other,
const typename MatrixType::Scalar& alpha)
55 typedef typename MatrixType::Scalar Scalar;
57 typedef typename OtherBlasTraits::DirectLinearAccessType ActualOtherType;
58 typedef typename internal::remove_all<ActualOtherType>::type _ActualOtherType;
59 typename internal::add_const_on_value_type<ActualOtherType>::type actualOther = OtherBlasTraits::extract(other.derived());
61 Scalar actualAlpha = alpha * OtherBlasTraits::extractScalarFactor(other.derived());
65 UseOtherDirectly = _ActualOtherType::InnerStrideAtCompileTime==1
69 ei_declare_aligned_stack_constructed_variable(Scalar, actualOtherPtr, other.size(),
70 (UseOtherDirectly ?
const_cast<Scalar*
>(actualOther.data()) : static_other.data()));
78 ::run(other.size(), mat.data(), mat.outerStride(), actualOtherPtr, actualOtherPtr, actualAlpha);
82 template<
typename MatrixType,
typename OtherType,
int UpLo>
83 struct selfadjoint_product_selector<MatrixType,OtherType,UpLo,false>
85 static void run(MatrixType& mat,
const OtherType& other,
const typename MatrixType::Scalar& alpha)
87 typedef typename MatrixType::Scalar Scalar;
89 typedef typename OtherBlasTraits::DirectLinearAccessType ActualOtherType;
90 typedef typename internal::remove_all<ActualOtherType>::type _ActualOtherType;
91 typename internal::add_const_on_value_type<ActualOtherType>::type actualOther = OtherBlasTraits::extract(other.derived());
93 Scalar actualAlpha = alpha * OtherBlasTraits::extractScalarFactor(other.derived());
97 OtherIsRowMajor = _ActualOtherType::Flags&
RowMajorBit ? 1 : 0
100 Index size = mat.cols();
101 Index depth = actualOther.cols();
104 MatrixType::MaxColsAtCompileTime, MatrixType::MaxColsAtCompileTime, _ActualOtherType::MaxColsAtCompileTime> BlockingType;
106 BlockingType blocking(size, size, depth, 1,
false);
112 IsRowMajor ?
RowMajor :
ColMajor, MatrixType::InnerStrideAtCompileTime, UpLo>
114 actualOther.data(), actualOther.outerStride(), actualOther.data(), actualOther.outerStride(),
115 mat.data(), mat.innerStride(), mat.outerStride(), actualAlpha, blocking);
121 template<
typename MatrixType,
unsigned int UpLo>
122 template<
typename DerivedU>
124 ::rankUpdate(
const MatrixBase<DerivedU>& u,
const Scalar& alpha)
126 selfadjoint_product_selector<MatrixType,DerivedU,UpLo>::run(_expression().const_cast_derived(), u.derived(), alpha);
133 #endif // EIGEN_SELFADJOINT_PRODUCT_H