1 | // This file is part of Eigen, a lightweight C++ template library
|
---|
2 | // for linear algebra. Eigen itself is part of the KDE project.
|
---|
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 | #include "main.h"
|
---|
11 |
|
---|
12 | template<typename Scalar> void smallVectors()
|
---|
13 | {
|
---|
14 | typedef Matrix<Scalar, 1, 2> V2;
|
---|
15 | typedef Matrix<Scalar, 3, 1> V3;
|
---|
16 | typedef Matrix<Scalar, 1, 4> V4;
|
---|
17 | Scalar x1 = ei_random<Scalar>(),
|
---|
18 | x2 = ei_random<Scalar>(),
|
---|
19 | x3 = ei_random<Scalar>(),
|
---|
20 | x4 = ei_random<Scalar>();
|
---|
21 | V2 v2(x1, x2);
|
---|
22 | V3 v3(x1, x2, x3);
|
---|
23 | V4 v4(x1, x2, x3, x4);
|
---|
24 | VERIFY_IS_APPROX(x1, v2.x());
|
---|
25 | VERIFY_IS_APPROX(x1, v3.x());
|
---|
26 | VERIFY_IS_APPROX(x1, v4.x());
|
---|
27 | VERIFY_IS_APPROX(x2, v2.y());
|
---|
28 | VERIFY_IS_APPROX(x2, v3.y());
|
---|
29 | VERIFY_IS_APPROX(x2, v4.y());
|
---|
30 | VERIFY_IS_APPROX(x3, v3.z());
|
---|
31 | VERIFY_IS_APPROX(x3, v4.z());
|
---|
32 | VERIFY_IS_APPROX(x4, v4.w());
|
---|
33 | }
|
---|
34 |
|
---|
35 | void test_eigen2_smallvectors()
|
---|
36 | {
|
---|
37 | for(int i = 0; i < g_repeat; i++) {
|
---|
38 | CALL_SUBTEST( smallVectors<int>() );
|
---|
39 | CALL_SUBTEST( smallVectors<float>() );
|
---|
40 | CALL_SUBTEST( smallVectors<double>() );
|
---|
41 | }
|
---|
42 | }
|
---|