Rank2Update.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_RANK2UPDATE_H
11 #define EIGEN_RANK2UPDATE_H
12 
13 namespace internal {
14 
15 /* Optimized selfadjoint matrix += alpha * uv' + conj(alpha)*vu'
16  * This is the low-level version of SelfadjointRank2Update.h
17  */
18 template<typename Scalar, typename Index, int UpLo>
20 {
21  static void run(Index size, Scalar* mat, Index stride, const Scalar* u, const Scalar* v, Scalar alpha)
22  {
23  typedef Map<const Matrix<Scalar,Dynamic,1> > OtherMap;
24  for (Index i=0; i<size; ++i)
25  {
26  Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1)) +=
27  numext::conj(alpha) * numext::conj(u[i]) * OtherMap(v+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1))
28  + alpha * numext::conj(v[i]) * OtherMap(u+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1));
29  }
30  }
31 };
32 
33 /* Optimized selfadjoint matrix += alpha * uv' + conj(alpha)*vu'
34  * The matrix is in packed form.
35  */
36 template<typename Scalar, typename Index, int UpLo>
38 {
39  static void run(Index size, Scalar* mat, const Scalar* u, const Scalar* v, Scalar alpha)
40  {
41  typedef Map<const Matrix<Scalar,Dynamic,1> > OtherMap;
42  Index offset = 0;
43  for (Index i=0; i<size; ++i)
44  {
45  Map<Matrix<Scalar,Dynamic,1> >(mat+offset, UpLo==Lower ? size-i : (i+1)) +=
46  numext::conj(alpha) * numext::conj(u[i]) * OtherMap(v+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1))
47  + alpha * numext::conj(v[i]) * OtherMap(u+(UpLo==Lower ? i : 0), UpLo==Lower ? size-i : (i+1));
48  //FIXME This should be handled outside.
49  mat[offset+(UpLo==Lower ? 0 : i)] = numext::real(mat[offset+(UpLo==Lower ? 0 : i)]);
50  offset += UpLo==Lower ? size-i : (i+1);
51  }
52  }
53 };
54 
55 } // end namespace internal
56 
57 #endif // EIGEN_RANK2UPDATE_H
alpha
RealScalar alpha
Definition: level1_cplx_impl.h:147
real
float real
Definition: datatypes.h:10
internal::rank2_update_selector
Definition: Rank2Update.h:19
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
internal::packed_rank2_update_selector::run
static void run(Index size, Scalar *mat, const Scalar *u, const Scalar *v, Scalar alpha)
Definition: Rank2Update.h:39
conj
AnnoyingScalar conj(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:104
Eigen::Lower
@ Lower
Definition: Constants.h:209
offset
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate offset
Definition: gnuplot_common_settings.hh:64
internal::packed_rank2_update_selector
Definition: Rank2Update.h:37
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
internal::rank2_update_selector::run
static void run(Index size, Scalar *mat, Index stride, const Scalar *u, const Scalar *v, Scalar alpha)
Definition: Rank2Update.h:21
internal
Definition: BandTriangularSolver.h:13
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:55