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
test
schur_complex.cpp
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) 2010,2012 Jitse Niesen <jitse@maths.leeds.ac.uk>
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 "
main.h
"
11
#include <limits>
12
#include <Eigen/Eigenvalues>
13
14
template
<
typename
MatrixType>
void
schur
(
int
size
= MatrixType::ColsAtCompileTime)
15
{
16
typedef
typename
ComplexSchur<MatrixType>::ComplexScalar
ComplexScalar;
17
typedef
typename
ComplexSchur<MatrixType>::ComplexMatrixType
ComplexMatrixType;
18
19
// Test basic functionality: T is triangular and A = U T U*
20
for
(
int
counter = 0; counter <
g_repeat
; ++counter) {
21
MatrixType
A
= MatrixType::Random(
size
,
size
);
22
ComplexSchur<MatrixType>
schurOfA
(
A
);
23
VERIFY_IS_EQUAL
(
schurOfA
.info(),
Success
);
24
ComplexMatrixType
U
=
schurOfA
.matrixU();
25
ComplexMatrixType
T
=
schurOfA
.matrixT();
26
for
(
int
row
= 1;
row
<
size
; ++
row
) {
27
for
(
int
col
= 0;
col
<
row
; ++
col
) {
28
VERIFY
(
T
(
row
,
col
) == (
typename
MatrixType::Scalar
)0);
29
}
30
}
31
VERIFY_IS_APPROX
(
A
.template cast<ComplexScalar>(),
U
*
T
*
U
.adjoint());
32
}
33
34
// Test asserts when not initialized
35
ComplexSchur<MatrixType>
csUninitialized;
36
VERIFY_RAISES_ASSERT
(csUninitialized.
matrixT
());
37
VERIFY_RAISES_ASSERT
(csUninitialized.
matrixU
());
38
VERIFY_RAISES_ASSERT
(csUninitialized.
info
());
39
40
// Test whether compute() and constructor returns same result
41
MatrixType
A
= MatrixType::Random(
size
,
size
);
42
ComplexSchur<MatrixType>
cs1;
43
cs1.
compute
(
A
);
44
ComplexSchur<MatrixType>
cs2(
A
);
45
VERIFY_IS_EQUAL
(cs1.
info
(),
Success
);
46
VERIFY_IS_EQUAL
(cs2.
info
(),
Success
);
47
VERIFY_IS_EQUAL
(cs1.
matrixT
(), cs2.
matrixT
());
48
VERIFY_IS_EQUAL
(cs1.
matrixU
(), cs2.
matrixU
());
49
50
// Test maximum number of iterations
51
ComplexSchur<MatrixType>
cs3;
52
cs3.
setMaxIterations
(
ComplexSchur<MatrixType>::m_maxIterationsPerRow
*
size
).
compute
(
A
);
53
VERIFY_IS_EQUAL
(cs3.
info
(),
Success
);
54
VERIFY_IS_EQUAL
(cs3.
matrixT
(), cs1.
matrixT
());
55
VERIFY_IS_EQUAL
(cs3.
matrixU
(), cs1.
matrixU
());
56
cs3.
setMaxIterations
(1).
compute
(
A
);
57
VERIFY_IS_EQUAL
(cs3.
info
(),
size
> 1 ?
NoConvergence
:
Success
);
58
VERIFY_IS_EQUAL
(cs3.
getMaxIterations
(), 1);
59
60
MatrixType
Atriangular =
A
;
61
Atriangular.template triangularView<StrictlyLower>().setZero();
62
cs3.
setMaxIterations
(1).
compute
(Atriangular);
// triangular matrices do not need any iterations
63
VERIFY_IS_EQUAL
(cs3.
info
(),
Success
);
64
VERIFY_IS_EQUAL
(cs3.
matrixT
(), Atriangular.template cast<ComplexScalar>());
65
VERIFY_IS_EQUAL
(cs3.
matrixU
(), ComplexMatrixType::Identity(
size
,
size
));
66
67
// Test computation of only T, not U
68
ComplexSchur<MatrixType>
csOnlyT(
A
,
false
);
69
VERIFY_IS_EQUAL
(csOnlyT.
info
(),
Success
);
70
VERIFY_IS_EQUAL
(cs1.
matrixT
(), csOnlyT.
matrixT
());
71
VERIFY_RAISES_ASSERT
(csOnlyT.
matrixU
());
72
73
if
(
size
> 1 &&
size
< 20)
74
{
75
// Test matrix with NaN
76
A
(0,0) = std::numeric_limits<typename MatrixType::RealScalar>::quiet_NaN();
77
ComplexSchur<MatrixType>
csNaN(
A
);
78
VERIFY_IS_EQUAL
(csNaN.
info
(),
NoConvergence
);
79
}
80
}
81
82
EIGEN_DECLARE_TEST
(schur_complex)
83
{
84
CALL_SUBTEST_1
(( schur<Matrix4cd>() ));
85
CALL_SUBTEST_2
(( schur<MatrixXcf>(internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
/4)) ));
86
CALL_SUBTEST_3
((
schur
<
Matrix
<std::complex<float>, 1, 1> >() ));
87
CALL_SUBTEST_4
((
schur
<
Matrix<float, 3, 3, Eigen::RowMajor>
>() ));
88
89
// Test problem size constructors
90
CALL_SUBTEST_5
(
ComplexSchur<MatrixXf>
(10));
91
}
Eigen::ComplexSchur::setMaxIterations
ComplexSchur & setMaxIterations(Index maxIters)
Sets the maximum number of iterations allowed.
Definition:
ComplexSchur.h:228
col
m col(1)
MatrixType
MatrixXf MatrixType
Definition:
benchmark-blocking-sizes.cpp:52
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition:
main.h:386
Eigen::ComplexSchur::matrixT
const ComplexMatrixType & matrixT() const
Returns the triangular matrix in the Schur decomposition.
Definition:
ComplexSchur.h:162
schur
void schur(int size=MatrixType::ColsAtCompileTime)
Definition:
schur_complex.cpp:14
Eigen::Success
@ Success
Definition:
Constants.h:442
T
Eigen::Triplet< double > T
Definition:
Tutorial_sparse_example.cpp:6
schurOfA
cout<< "Here is a random 4x4 matrix, A:"<< endl<< A<< endl<< endl;ComplexSchur< MatrixXcf > schurOfA(A, false)
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(schur_complex)
Definition:
schur_complex.cpp:82
VERIFY_RAISES_ASSERT
#define VERIFY_RAISES_ASSERT(a)
Definition:
main.h:340
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition:
bench_gemm.cpp:48
size
Scalar Scalar int size
Definition:
benchVecAdd.cpp:17
Eigen::ComplexSchur::getMaxIterations
Index getMaxIterations()
Returns the maximum number of iterations.
Definition:
ComplexSchur.h:235
CALL_SUBTEST_4
#define CALL_SUBTEST_4(FUNC)
Definition:
split_test_helper.h:22
Eigen::ComplexSchur::info
ComputationInfo info() const
Reports whether previous computation was successful.
Definition:
ComplexSchur.h:217
CALL_SUBTEST_3
#define CALL_SUBTEST_3(FUNC)
Definition:
split_test_helper.h:16
CALL_SUBTEST_1
#define CALL_SUBTEST_1(FUNC)
Definition:
split_test_helper.h:4
Eigen::NoConvergence
@ NoConvergence
Definition:
Constants.h:446
CALL_SUBTEST_5
#define CALL_SUBTEST_5(FUNC)
Definition:
split_test_helper.h:28
Eigen::g_repeat
static int g_repeat
Definition:
main.h:169
Eigen::Triplet< double >
CALL_SUBTEST_2
#define CALL_SUBTEST_2(FUNC)
Definition:
split_test_helper.h:10
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition:
integer_types.cpp:15
Eigen::ComplexSchur::compute
ComplexSchur & compute(const EigenBase< InputType > &matrix, bool computeU=true)
Computes Schur decomposition of given matrix.
main.h
Eigen::ComplexSchur::matrixU
const ComplexMatrixType & matrixU() const
Returns the unitary matrix in the Schur decomposition.
Definition:
ComplexSchur.h:138
row
m row(1)
EIGEN_TEST_MAX_SIZE
#define EIGEN_TEST_MAX_SIZE
Definition:
boostmultiprec.cpp:16
U
@ U
Definition:
testDecisionTree.cpp:342
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition:
3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
Eigen::ComplexSchur
Performs a complex Schur decomposition of a real or complex square matrix.
Definition:
ComplexSchur.h:51
Scalar
SCALAR Scalar
Definition:
bench_gemm.cpp:46
VERIFY
#define VERIFY(a)
Definition:
main.h:380
gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:03:22