Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
u
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Classes
Class List
Class Hierarchy
Class Members
All
!
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
!
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
f
k
l
m
n
o
p
r
s
t
v
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
:
a
b
c
d
e
g
h
i
l
m
n
o
p
r
s
t
u
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
z
Enumerations
Enumerator
b
c
e
f
g
i
l
m
n
o
p
r
s
t
u
v
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
gtsam
3rdparty
Eigen
doc
special_examples
Tutorial_sparse_example.cpp
Go to the documentation of this file.
1
#include <Eigen/Sparse>
2
#include <vector>
3
#include <iostream>
4
5
typedef
Eigen::SparseMatrix<double>
SpMat
;
// declares a column-major sparse matrix type of double
6
typedef
Eigen::Triplet<double>
T
;
7
8
void
buildProblem
(std::vector<T>& coefficients, Eigen::VectorXd&
b
,
int
n
);
9
void
saveAsBitmap
(
const
Eigen::VectorXd&
x
,
int
n
,
const
char
*
filename
);
10
11
int
main
(
int
argc,
char
** argv)
12
{
13
if
(argc!=2) {
14
std::cerr <<
"Error: expected one and only one argument.\n"
;
15
return
-1;
16
}
17
18
int
n
= 300;
// size of the image
19
int
m
=
n
*
n
;
// number of unknowns (=number of pixels)
20
21
// Assembly:
22
std::vector<T> coefficients;
// list of non-zeros coefficients
23
Eigen::VectorXd
b
(
m
);
// the right hand side-vector resulting from the constraints
24
buildProblem
(coefficients,
b
,
n
);
25
26
SpMat
A
(
m
,
m
);
27
A
.setFromTriplets(coefficients.begin(), coefficients.end());
28
29
// Solving:
30
Eigen::SimplicialCholesky<SpMat>
chol(
A
);
// performs a Cholesky factorization of A
31
Eigen::VectorXd
x
= chol.solve(
b
);
// use the factorization to solve for the given right hand side
32
33
// Export the result to a file:
34
saveAsBitmap
(
x
,
n
, argv[1]);
35
36
return
0;
37
}
38
Eigen::SparseMatrix< double >
buildProblem
void buildProblem(std::vector< T > &coefficients, Eigen::VectorXd &b, int n)
Definition:
Tutorial_sparse_example_details.cpp:19
b
Scalar * b
Definition:
benchVecAdd.cpp:17
x
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 x
Definition:
gnuplot_common_settings.hh:12
T
Eigen::Triplet< double > T
Definition:
Tutorial_sparse_example.cpp:6
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition:
bench_gemm.cpp:48
n
int n
Definition:
BiCGSTAB_simple.cpp:1
A
Definition:
test_numpy_dtypes.cpp:300
relicense.filename
filename
Definition:
relicense.py:57
SpMat
Eigen::SparseMatrix< double > SpMat
Definition:
Tutorial_sparse_example.cpp:5
m
Matrix3f m
Definition:
AngleAxis_mimic_euler.cpp:1
Eigen::Triplet< double >
Eigen::SimplicialCholesky
Definition:
SimplicialCholesky.h:276
saveAsBitmap
void saveAsBitmap(const Eigen::VectorXd &x, int n, const char *filename)
Definition:
Tutorial_sparse_example_details.cpp:37
main
int main(int argc, char **argv)
Definition:
Tutorial_sparse_example.cpp:11
gtsam
Author(s):
autogenerated on Thu Apr 10 2025 03:08:37