level1_real_impl.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) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
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 #include "common.h"
11 
12 // computes the sum of magnitudes of all vector elements or, for a complex vector x, the sum
13 // res = |Rex1| + |Imx1| + |Rex2| + |Imx2| + ... + |Rexn| + |Imxn|, where x is a vector of order n
15 {
16 // std::cerr << "_asum " << *n << " " << *incx << "\n";
17 
18  Scalar* x = reinterpret_cast<Scalar*>(px);
19 
20  if(*n<=0) return 0;
21 
22  if(*incx==1) return make_vector(x,*n).cwiseAbs().sum();
23  else return make_vector(x,*n,std::abs(*incx)).cwiseAbs().sum();
24 }
25 
26 int EIGEN_CAT(i, EIGEN_BLAS_FUNC(amax))(int *n, RealScalar *px, int *incx)
27 {
28  if(*n<=0) return 0;
29  Scalar* x = reinterpret_cast<Scalar*>(px);
30 
32  if(*incx==1) make_vector(x,*n).cwiseAbs().maxCoeff(&ret);
33  else make_vector(x,*n,std::abs(*incx)).cwiseAbs().maxCoeff(&ret);
34  return int(ret)+1;
35 }
36 
37 int EIGEN_CAT(i, EIGEN_BLAS_FUNC(amin))(int *n, RealScalar *px, int *incx)
38 {
39  if(*n<=0) return 0;
40  Scalar* x = reinterpret_cast<Scalar*>(px);
41 
43  if(*incx==1) make_vector(x,*n).cwiseAbs().minCoeff(&ret);
44  else make_vector(x,*n,std::abs(*incx)).cwiseAbs().minCoeff(&ret);
45  return int(ret)+1;
46 }
47 
48 // computes a vector-vector dot product.
50 {
51 // std::cerr << "_dot " << *n << " " << *incx << " " << *incy << "\n";
52 
53  if(*n<=0) return 0;
54 
55  Scalar* x = reinterpret_cast<Scalar*>(px);
56  Scalar* y = reinterpret_cast<Scalar*>(py);
57 
58  if(*incx==1 && *incy==1) return (make_vector(x,*n).cwiseProduct(make_vector(y,*n))).sum();
59  else if(*incx>0 && *incy>0) return (make_vector(x,*n,*incx).cwiseProduct(make_vector(y,*n,*incy))).sum();
60  else if(*incx<0 && *incy>0) return (make_vector(x,*n,-*incx).reverse().cwiseProduct(make_vector(y,*n,*incy))).sum();
61  else if(*incx>0 && *incy<0) return (make_vector(x,*n,*incx).cwiseProduct(make_vector(y,*n,-*incy).reverse())).sum();
62  else if(*incx<0 && *incy<0) return (make_vector(x,*n,-*incx).reverse().cwiseProduct(make_vector(y,*n,-*incy).reverse())).sum();
63  else return 0;
64 }
65 
66 // computes the Euclidean norm of a vector.
67 // FIXME
69 {
70 // std::cerr << "_nrm2 " << *n << " " << *incx << "\n";
71  if(*n<=0) return 0;
72 
73  Scalar* x = reinterpret_cast<Scalar*>(px);
74 
75  if(*incx==1) return make_vector(x,*n).stableNorm();
76  else return make_vector(x,*n,std::abs(*incx)).stableNorm();
77 }
78 
80 {
81 // std::cerr << "_rot " << *n << " " << *incx << " " << *incy << "\n";
82  if(*n<=0) return 0;
83 
84  Scalar* x = reinterpret_cast<Scalar*>(px);
85  Scalar* y = reinterpret_cast<Scalar*>(py);
86  Scalar c = *reinterpret_cast<Scalar*>(pc);
87  Scalar s = *reinterpret_cast<Scalar*>(ps);
88 
91 
94 
98 
99 
100  return 0;
101 }
102 
103 /*
104 // performs rotation of points in the modified plane.
105 int EIGEN_BLAS_FUNC(rotm)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *param)
106 {
107  Scalar* x = reinterpret_cast<Scalar*>(px);
108  Scalar* y = reinterpret_cast<Scalar*>(py);
109 
110  // TODO
111 
112  return 0;
113 }
114 
115 // computes the modified parameters for a Givens rotation.
116 int EIGEN_BLAS_FUNC(rotmg)(RealScalar *d1, RealScalar *d2, RealScalar *x1, RealScalar *x2, RealScalar *param)
117 {
118  // TODO
119 
120  return 0;
121 }
122 */
s
RealScalar s
Definition: level1_cplx_impl.h:126
asum
RealScalar EIGEN_BLAS_FUNC() asum(int *n, RealScalar *px, int *incx)
Definition: level1_real_impl.h:14
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
int
return int(ret)+1
incx
int RealScalar int * incx
Definition: level1_real_impl.h:27
rvx
Reverse< StridedVectorType > rvx(vx)
ret
DenseIndex ret
Definition: level1_real_impl.h:31
Eigen::JacobiRotation
Rotation given by a cosine-sine pair.
Definition: ForwardDeclarations.h:283
rot
int EIGEN_BLAS_FUNC() rot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps)
Definition: level1_real_impl.h:79
dot
Scalar EIGEN_BLAS_FUNC() dot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_real_impl.h:49
n
int n
Definition: BiCGSTAB_simple.cpp:1
common.h
incy
int RealScalar int RealScalar int * incy
Definition: level1_cplx_impl.h:119
vy
StridedVectorType vy(make_vector(y, *n, std::abs(*incy)))
rvy
Reverse< StridedVectorType > rvy(vy)
EIGEN_BLAS_FUNC
#define EIGEN_BLAS_FUNC(X)
Definition: gtsam/3rdparty/Eigen/blas/common.h:173
make_vector
if incx make_vector(x, *n).cwiseAbs().maxCoeff(&ret)
Eigen::Reverse
Expression of the reverse of a vector or matrix.
Definition: Reverse.h:63
nrm2
Scalar EIGEN_BLAS_FUNC() nrm2(int *n, RealScalar *px, int *incx)
Definition: level1_real_impl.h:68
Eigen::Map
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:94
pc
int RealScalar int RealScalar int RealScalar * pc
Definition: level1_cplx_impl.h:119
y
Scalar * y
Definition: level1_cplx_impl.h:124
RealScalar
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:47
px
int RealScalar * px
Definition: level1_real_impl.h:26
Eigen::DenseIndex
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Definition: Meta.h:66
x
Scalar * x
Definition: level1_real_impl.h:29
ps
int RealScalar int RealScalar int RealScalar RealScalar * ps
Definition: level1_cplx_impl.h:120
abs
#define abs(x)
Definition: datatypes.h:17
py
int RealScalar int RealScalar * py
Definition: level1_cplx_impl.h:119
EIGEN_CAT
int EIGEN_CAT(i, EIGEN_BLAS_FUNC(amax))(int *n
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::internal::apply_rotation_in_the_plane
EIGEN_DEVICE_FUNC void apply_rotation_in_the_plane(DenseBase< VectorX > &xpr_x, DenseBase< VectorY > &xpr_y, const JacobiRotation< OtherScalar > &j)
Definition: Jacobi.h:453
vx
StridedVectorType vx(make_vector(x, *n, std::abs(*incx)))
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:41