PackedSelfadjointProduct.h
Go to the documentation of this file.
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_SELFADJOINT_PACKED_PRODUCT_H
11 #define EIGEN_SELFADJOINT_PACKED_PRODUCT_H
12 
13 namespace Eigen {
14 namespace internal {
15 
16 /* Optimized matrix += alpha * uv'
17  * The matrix is in packed form.
18  */
19 template <typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjLhs, bool ConjRhs>
21 
22 template <typename Scalar, typename Index, int UpLo, bool ConjLhs, bool ConjRhs>
23 struct selfadjoint_packed_rank1_update<Scalar, Index, ColMajor, UpLo, ConjLhs, ConjRhs> {
25  static void run(Index size, Scalar* mat, const Scalar* vec, RealScalar alpha) {
26  typedef Map<const Matrix<Scalar, Dynamic, 1> > OtherMap;
27  typedef typename conj_expr_if<ConjLhs, OtherMap>::type ConjRhsType;
29 
30  for (Index i = 0; i < size; ++i) {
31  Map<Matrix<Scalar, Dynamic, 1> >(mat, UpLo == Lower ? size - i : (i + 1)) +=
32  alpha * cj(vec[i]) * ConjRhsType(OtherMap(vec + (UpLo == Lower ? i : 0), UpLo == Lower ? size - i : (i + 1)));
33  // FIXME This should be handled outside.
34  mat[UpLo == Lower ? 0 : i] = numext::real(mat[UpLo == Lower ? 0 : i]);
35  mat += UpLo == Lower ? size - i : (i + 1);
36  }
37  }
38 };
39 
40 template <typename Scalar, typename Index, int UpLo, bool ConjLhs, bool ConjRhs>
41 struct selfadjoint_packed_rank1_update<Scalar, Index, RowMajor, UpLo, ConjLhs, ConjRhs> {
43  static void run(Index size, Scalar* mat, const Scalar* vec, RealScalar alpha) {
45  size, mat, vec, alpha);
46  }
47 };
48 
49 } // namespace internal
50 } // namespace Eigen
51 
52 #endif // EIGEN_SELFADJOINT_PACKED_PRODUCT_H
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::SparseMatrix< double > mat
Definition: EigenUnitTest.cpp:10
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
float real
Definition: datatypes.h:10
@ Lower
Definition: Constants.h:211
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
RealScalar alpha
Definition: level1_cplx_impl.h:151
std::conditional<!Cond, const T &, CwiseUnaryOp< scalar_conjugate_op< typename traits< T >::Scalar >, T > > conj_expr_if
Definition: SelfadjointRank2Update.h:52
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Definition: Eigen_Colamd.h:49
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: ConjHelper.h:42
NumTraits< Scalar >::Real RealScalar
Definition: PackedSelfadjointProduct.h:24
static void run(Index size, Scalar *mat, const Scalar *vec, RealScalar alpha)
Definition: PackedSelfadjointProduct.h:25
NumTraits< Scalar >::Real RealScalar
Definition: PackedSelfadjointProduct.h:42
static void run(Index size, Scalar *mat, const Scalar *vec, RealScalar alpha)
Definition: PackedSelfadjointProduct.h:43
Definition: PackedSelfadjointProduct.h:20
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317