-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[math] fix matrix vector multiplication & add unittest
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2011, Fabian Greif | ||
* Copyright (c) 2012, Niklas Hauser | ||
* Copyright (c) 2017, Marten | ||
* Copyright (c) 2019, Markus Schmidt | ||
* Copyright (c) 2019, Sebastan Birke | ||
* | ||
* This file is part of the modm project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#include <modm/math/matrix.hpp> | ||
#include <modm/math/geometry/vector.hpp> | ||
|
||
#include "matrix_vector_test.hpp" | ||
|
||
void | ||
MatrixVectorTest::testMatrixVectorMultiplication() | ||
{ | ||
const float_t m[] = { | ||
5., | ||
8., | ||
-4., | ||
6., | ||
9., | ||
-5., | ||
4., | ||
7., | ||
-2. | ||
}; | ||
|
||
const float_t v[] = { | ||
2., | ||
-3., | ||
1. | ||
}; | ||
|
||
const modm::Matrix<float_t, 3, 3> a(m); | ||
const modm::Vector3f b(v); | ||
|
||
modm::Vector3f c = a * b; | ||
|
||
TEST_ASSERT_EQUALS(c[0], -18); | ||
TEST_ASSERT_EQUALS(c[1], -20); | ||
TEST_ASSERT_EQUALS(c[2], -15); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2009, Martin Rosekeit | ||
* Copyright (c) 2009-2011, Fabian Greif | ||
* Copyright (c) 2012, Niklas Hauser | ||
* Copyright (c) 2019, Markus Schmidt | ||
* Copyright (c) 2019, Sebastan Birke | ||
* | ||
* This file is part of the modm project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#include <unittest/testsuite.hpp> | ||
|
||
class MatrixVectorTest : public unittest::TestSuite | ||
{ | ||
public: | ||
void | ||
testMatrixVectorMultiplication(); | ||
}; |