MEPP2 Project
test_matrix_operations_aif.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12 
13 // must be the last include to avoid side effect of disabling NDEBUG
14 #undef NDEBUG
15 #include <cassert>
16 
17 
18 //------------------------------------------------------------------------------
19 
20 int
21 main(void)
22 {
23  //---------------------- Tests ---------------------
24 
25  std::cout << "testing maximum(vector)" << std::endl;
27  std::vector< int >{5, 8, 4, 3, -1}) == 8));
28 
29  std::cout << "testing minimum(vector)" << std::endl;
31  std::vector< int >{5, 8, 4, 3, -1}) == -1));
32 
33  std::cout << "testing mean(vector)" << std::endl;
34  assert((FEVV::Math::Vector::Stats::mean(std::vector< int >{5, 8, 4, 3, -1}) ==
35  3));
36 
37  std::cout << "testing median(vector)" << std::endl;
39  std::vector< int >{5, 8, 4, 3, -1}) == 4));
40 
41  std::cout << "testing dot_product(vector1, vector2)" << std::endl;
43  std::vector< int >{5, 8, 4, 3, -1},
44  std::vector< int >{10, -2, -3, 2, 1}) == 27));
45 
46  std::cout << "testing cross_product(vector1, vector2)" << std::endl;
47  assert((FEVV::Math::Vector::cross_product(std::vector< int >{4, 3, -1},
48  std::vector< int >{10, -2, -3}) ==
49  std::vector< int >{-11, 2, -38}));
50 
51  //--------------------------------------------------
52 
53  std::cout << "Test passed.\n";
54  return 0; // all tests passed
55 }
FEVV::Math::Vector::Stats::minimum
static ElementType minimum(const ElementType v[DIM])
Definition: MatrixOperations.hpp:103
FEVV::Math::Vector::Stats::maximum
static ElementType maximum(const ElementType v[DIM])
Definition: MatrixOperations.hpp:73
FEVV::Math::Vector::Stats::mean
static ElementType mean(const ElementType v[DIM])
Definition: MatrixOperations.hpp:133
FEVV::Math::Vector::cross_product
static std::vector< ElementType > cross_product(const ElementType v1[DIM], const ElementType v2[DIM])
Definition: MatrixOperations.hpp:460
main
int main(void)
Definition: test_matrix_operations_aif.cpp:21
FEVV::Math::Vector::Stats::median
static ElementType median(std::vector< ElementType > v)
Definition: MatrixOperations.hpp:266
MatrixOperations.hpp
FEVV::Math::Vector::dot_product
static ElementType dot_product(const ElementType v1[DIM], const ElementType v2[DIM])
Compute v1 * v2 scalar product.
Definition: MatrixOperations.hpp:421