smallvectors.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) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
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 #define EIGEN_NO_STATIC_ASSERT
11 #include "main.h"
12 
13 template<typename Scalar> void smallVectors()
14 {
15  typedef Matrix<Scalar, 1, 2> V2;
16  typedef Matrix<Scalar, 3, 1> V3;
17  typedef Matrix<Scalar, 1, 4> V4;
18  typedef Matrix<Scalar, Dynamic, 1> VX;
19  Scalar x1 = internal::random<Scalar>(),
20  x2 = internal::random<Scalar>(),
21  x3 = internal::random<Scalar>(),
22  x4 = internal::random<Scalar>();
23  V2 v2(x1, x2);
24  V3 v3(x1, x2, x3);
25  V4 v4(x1, x2, x3, x4);
26  VERIFY_IS_APPROX(x1, v2.x());
27  VERIFY_IS_APPROX(x1, v3.x());
28  VERIFY_IS_APPROX(x1, v4.x());
29  VERIFY_IS_APPROX(x2, v2.y());
30  VERIFY_IS_APPROX(x2, v3.y());
31  VERIFY_IS_APPROX(x2, v4.y());
32  VERIFY_IS_APPROX(x3, v3.z());
33  VERIFY_IS_APPROX(x3, v4.z());
34  VERIFY_IS_APPROX(x4, v4.w());
35 
37  {
38  VERIFY_RAISES_ASSERT(V3(2, 1))
39  VERIFY_RAISES_ASSERT(V3(3, 2))
40  VERIFY_RAISES_ASSERT(V3(Scalar(3), 1))
41  VERIFY_RAISES_ASSERT(V3(3, Scalar(1)))
43  VERIFY_RAISES_ASSERT(V3(Scalar(123), Scalar(123)))
44 
45  VERIFY_RAISES_ASSERT(V4(1, 3))
46  VERIFY_RAISES_ASSERT(V4(2, 4))
47  VERIFY_RAISES_ASSERT(V4(1, Scalar(4)))
48  VERIFY_RAISES_ASSERT(V4(Scalar(1), 4))
50  VERIFY_RAISES_ASSERT(V4(Scalar(123), Scalar(123)))
51 
52  VERIFY_RAISES_ASSERT(VX(3, 2))
53  VERIFY_RAISES_ASSERT(VX(Scalar(3), 1))
54  VERIFY_RAISES_ASSERT(VX(3, Scalar(1)))
56  VERIFY_RAISES_ASSERT(VX(Scalar(123), Scalar(123)))
57  }
58 }
59 
61 {
62  for(int i = 0; i < g_repeat; i++) {
63  CALL_SUBTEST(smallVectors<int>() );
64  CALL_SUBTEST(smallVectors<float>() );
65  CALL_SUBTEST(smallVectors<double>() );
66  }
67 }
SCALAR Scalar
Definition: bench_gemm.cpp:33
#define VERIFY_RAISES_ASSERT(a)
Definition: main.h:285
Vector v2
void test_smallvectors()
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:150
void smallVectors()
#define VERIFY_IS_APPROX(a, b)
Vector v3
static int g_repeat
Definition: main.h:144
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
#define CALL_SUBTEST(FUNC)
Definition: main.h:342
Pose3 x1
Definition: testPose3.cpp:588
static string x4("x4")
The matrix class, also used for vectors and row-vectors.


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:44:13