Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
gtsam
3rdparty
Eigen
test
ctorleak.cpp
Go to the documentation of this file.
1
#include "
main.h
"
2
3
#include <exception>
// std::exception
4
5
struct
Foo
6
{
7
static
Index
object_count
;
8
static
Index
object_limit
;
9
int
dummy
;
10
11
Foo
()
12
{
13
#ifdef EIGEN_EXCEPTIONS
14
// TODO: Is this the correct way to handle this?
15
if
(
Foo::object_count
>
Foo::object_limit
) { std::cout <<
"\nThrow!\n"
;
throw
Foo::Fail
(); }
16
#endif
17
std::cout <<
'+'
;
18
++
Foo::object_count
;
19
}
20
21
~Foo
()
22
{
23
std::cout <<
'-'
;
24
--
Foo::object_count
;
25
}
26
27
class
Fail
:
public
std::exception {};
28
};
29
30
Index
Foo::object_count
= 0;
31
Index
Foo::object_limit
= 0;
32
33
#undef EIGEN_TEST_MAX_SIZE
34
#define EIGEN_TEST_MAX_SIZE 3
35
36
void
test_ctorleak
()
37
{
38
typedef
Matrix<Foo, Dynamic, Dynamic>
MatrixX;
39
typedef
Matrix<Foo, Dynamic, 1>
VectorX
;
40
Foo::object_count
= 0;
41
for
(
int
i
= 0;
i
<
g_repeat
;
i
++) {
42
Index
rows
= internal::random<Index>(2,
EIGEN_TEST_MAX_SIZE
),
cols
= internal::random<Index>(2,
EIGEN_TEST_MAX_SIZE
);
43
Foo::object_limit
= internal::random<Index>(0, rows*
cols
- 2);
44
std::cout <<
"object_limit ="
<<
Foo::object_limit
<< std::endl;
45
#ifdef EIGEN_EXCEPTIONS
46
try
47
{
48
#endif
49
std::cout <<
"\nMatrixX m("
<< rows <<
", "
<<
cols
<<
");\n"
;
50
MatrixX
m
(rows, cols);
51
#ifdef EIGEN_EXCEPTIONS
52
VERIFY
(
false
);
// not reached if exceptions are enabled
53
}
54
catch
(
const
Foo::Fail
&) {
/* ignore */
}
55
#endif
56
VERIFY_IS_EQUAL
(
Index
(0),
Foo::object_count
);
57
58
{
59
Foo::object_limit
= (rows+1)*(
cols
+1);
60
MatrixX
A
(rows,
cols
);
61
VERIFY_IS_EQUAL
(
Foo::object_count
, rows*
cols
);
62
VectorX
v
=A.row(0);
63
VERIFY_IS_EQUAL
(
Foo::object_count
, (rows+1)*cols);
64
v = A.col(0);
65
VERIFY_IS_EQUAL
(
Foo::object_count
, rows*(cols+1));
66
}
67
VERIFY_IS_EQUAL
(
Index
(0),
Foo::object_count
);
68
}
69
}
m
Matrix3f m
Definition:
AngleAxis_mimic_euler.cpp:1
test_ctorleak
void test_ctorleak()
Definition:
ctorleak.cpp:36
cols
int cols
Definition:
Tutorial_commainit_02.cpp:1
Foo::Fail
Definition:
ctorleak.cpp:27
v
ArrayXcf v
Definition:
Cwise_arg.cpp:1
VectorX
Matrix< Scalar, Dynamic, 1 > VectorX
Definition:
sparse_lu.cpp:41
Foo::Foo
Foo()
Definition:
ctorleak.cpp:11
Foo::object_limit
static Index object_limit
Definition:
ctorleak.cpp:8
EIGEN_TEST_MAX_SIZE
#define EIGEN_TEST_MAX_SIZE
Definition:
ctorleak.cpp:34
Foo::object_count
static Index object_count
Definition:
ctorleak.cpp:7
main.h
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition:
main.h:331
Eigen::g_repeat
static int g_repeat
Definition:
main.h:144
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition:
Meta.h:33
A
Definition:
test_numpy_dtypes.cpp:254
Foo::~Foo
~Foo()
Definition:
ctorleak.cpp:21
VERIFY
#define VERIFY(a)
Definition:
main.h:325
Foo
Definition:
jacobisvd.cpp:72
Foo::dummy
int dummy
Definition:
ctorleak.cpp:9
rows
int rows
Definition:
Tutorial_commainit_02.cpp:1
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition:
3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:54