diff options
author | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-09-09 02:55:10 +0800 |
---|---|---|
committer | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-09-09 02:55:10 +0800 |
commit | 669db3d7768b3b94d31d6552a1012ee29f54b8d8 (patch) | |
tree | f974fb8d085873b74363264deaef3639aa2bf690 /blas/GeneralRank1Update.h | |
parent | 1b8f4164082f82265f8118d89de71bb14d7f0eb6 (diff) |
Extend rank-1 updates for different storage orders.
Diffstat (limited to 'blas/GeneralRank1Update.h')
-rw-r--r-- | blas/GeneralRank1Update.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/blas/GeneralRank1Update.h b/blas/GeneralRank1Update.h index a3301ed92..6d33fbcc1 100644 --- a/blas/GeneralRank1Update.h +++ b/blas/GeneralRank1Update.h @@ -13,15 +13,28 @@ namespace internal { /* Optimized matrix += alpha * uv' */ -template<typename Scalar, typename Index, bool ConjRhs> -struct general_rank1_update +template<typename Scalar, typename Index, int StorageOrder, bool ConjLhs, bool ConjRhs> +struct general_rank1_update; + +template<typename Scalar, typename Index, bool ConjLhs, bool ConjRhs> +struct general_rank1_update<Scalar,Index,ColMajor,ConjLhs,ConjRhs> { static void run(Index rows, Index cols, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha) { - typedef Matrix<Scalar,Dynamic,1> PlainVector; internal::conj_if<ConjRhs> cj; + typedef Map<const Matrix<Scalar,Dynamic,1> > OtherMap; + typedef typename internal::conditional<ConjLhs,typename OtherMap::ConjugateReturnType,const OtherMap&>::type ConjRhsType; for (Index i=0; i<cols; ++i) - Map<PlainVector>(mat+stride*i,rows) += alpha * cj(v[i]) * Map<const PlainVector>(u,rows); + Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i,rows) += alpha * cj(v[i]) * ConjRhsType(OtherMap(u,rows)); + } +}; + +template<typename Scalar, typename Index, bool ConjLhs, bool ConjRhs> +struct general_rank1_update<Scalar,Index,RowMajor,ConjLhs,ConjRhs> +{ + static void run(Index rows, Index cols, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha) + { + general_rank1_update<Scalar,Index,ColMajor,ConjRhs,ConjRhs>::run(rows,cols,mat,stride,u,v,alpha); } }; |