MyraMath
bounds_Matrix


Source: tests/dense/bounds_Matrix.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // Containers.
12 #include <myramath/dense/Matrix.h>
13 
14 // Reporting.
15 #include <tests/myratest.h>
16 
17 using namespace myra;
18 
19 ADD_TEST("bounds_Matrix","[dense]")
20  {
21  // Make random A, access it out of bounds in a variety of ways.
22  auto A = Matrix<double>::random(3,3);
23  // Scalar access using at()
24  REQUIRE_EXCEPTION( auto a = A.at(3,0); );
25  REQUIRE_EXCEPTION( auto a = A.at(0,3); );
26  REQUIRE_EXCEPTION( auto a = A.at(-1,0); );
27  REQUIRE_EXCEPTION( auto a = A.at(0,-1); );
28  // Window access along i.
29  REQUIRE_EXCEPTION( auto a = A.rows(0,4); );
30  REQUIRE_EXCEPTION( auto a = A.rows(4,7); );
31  REQUIRE_EXCEPTION( auto a = A.rows(-1,1); );
32  REQUIRE_EXCEPTION( auto a = A.rows(2,-1); );
33  REQUIRE_EXCEPTION( auto a = A.rows(2,1); );
34  // Window access along j.
35  REQUIRE_EXCEPTION( auto a = A.columns(0,4); );
36  REQUIRE_EXCEPTION( auto a = A.columns(4,7); );
37  REQUIRE_EXCEPTION( auto a = A.columns(-1,1); );
38  REQUIRE_EXCEPTION( auto a = A.columns(2,-1); );
39  REQUIRE_EXCEPTION( auto a = A.columns(2,1); );
40  // Vector access.
41  REQUIRE_EXCEPTION( auto a = A.vector(-1); );
42  REQUIRE_EXCEPTION( auto a = A.vector(3); );
43  }
static Matrix< Number > random(int I, int J)
Generates a random Matrix of specified size.
Definition: Matrix.cpp:353
Definition: syntax.dox:1
General purpose dense matrix container, O(i*j) storage.


Results: [PASS]


Go back to Summary of /test programs.