1 | // This file is part of Eigen, a lightweight C++ template library
|
---|
2 | // for linear algebra.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2012 Chen-Pang He <jdh8@ms63.hinet.net>
|
---|
5 | //
|
---|
6 | // This Source Code Form is subject to the terms of the Mozilla
|
---|
7 | // Public License v. 2.0. If a copy of the MPL was not distributed
|
---|
8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
---|
9 |
|
---|
10 | #ifndef EIGEN_GENERAL_RANK1UPDATE_H
|
---|
11 | #define EIGEN_GENERAL_RANK1UPDATE_H
|
---|
12 |
|
---|
13 | namespace internal {
|
---|
14 |
|
---|
15 | /* Optimized matrix += alpha * uv' */
|
---|
16 | template<typename Scalar, typename Index, int StorageOrder, bool ConjLhs, bool ConjRhs>
|
---|
17 | struct general_rank1_update;
|
---|
18 |
|
---|
19 | template<typename Scalar, typename Index, bool ConjLhs, bool ConjRhs>
|
---|
20 | struct general_rank1_update<Scalar,Index,ColMajor,ConjLhs,ConjRhs>
|
---|
21 | {
|
---|
22 | static void run(Index rows, Index cols, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha)
|
---|
23 | {
|
---|
24 | typedef Map<const Matrix<Scalar,Dynamic,1> > OtherMap;
|
---|
25 | typedef typename conj_expr_if<ConjLhs,OtherMap>::type ConjRhsType;
|
---|
26 | conj_if<ConjRhs> cj;
|
---|
27 |
|
---|
28 | for (Index i=0; i<cols; ++i)
|
---|
29 | Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i,rows) += alpha * cj(v[i]) * ConjRhsType(OtherMap(u,rows));
|
---|
30 | }
|
---|
31 | };
|
---|
32 |
|
---|
33 | template<typename Scalar, typename Index, bool ConjLhs, bool ConjRhs>
|
---|
34 | struct general_rank1_update<Scalar,Index,RowMajor,ConjLhs,ConjRhs>
|
---|
35 | {
|
---|
36 | static void run(Index rows, Index cols, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha)
|
---|
37 | {
|
---|
38 | general_rank1_update<Scalar,Index,ColMajor,ConjRhs,ConjRhs>::run(rows,cols,mat,stride,u,v,alpha);
|
---|
39 | }
|
---|
40 | };
|
---|
41 |
|
---|
42 | } // end namespace internal
|
---|
43 |
|
---|
44 | #endif // EIGEN_GENERAL_RANK1UPDATE_H
|
---|