diff options
author | ancarola <raffaele.ancarola@epfl.ch> | 2019-06-30 22:21:54 +0200 |
---|---|---|
committer | ancarola <raffaele.ancarola@epfl.ch> | 2019-06-30 22:21:54 +0200 |
commit | 6e39d531ed36d043e6f6fee6befca2be00fd3f57 (patch) | |
tree | 9a1dad6301b5dde13bb64bfc7898b1922c6f2c5c /test/matrix_example.cpp | |
parent | Finally compiles (diff) | |
download | libmm-6e39d531ed36d043e6f6fee6befca2be00fd3f57.tar.gz libmm-6e39d531ed36d043e6f6fee6befca2be00fd3f57.zip |
Optimized matrix section
- Vector iterators: allow to iterate on rows, columns or diagonals
- Transposition doesn't affect allocated space, O(1)
Diffstat (limited to 'test/matrix_example.cpp')
-rw-r--r-- | test/matrix_example.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/matrix_example.cpp b/test/matrix_example.cpp index e7f6580..291feab 100644 --- a/test/matrix_example.cpp +++ b/test/matrix_example.cpp @@ -12,14 +12,15 @@ int main(int argc, char *argv[]) { std::cout << "a = \n" << a; std::cout << "b = \n" << b; std::cout << "c = \n" << c; - std::cout << std::endl; - + std::cout << std::endl; + // access elements std::cout << "Access elements" << std::endl; std::cout << "a.at(2,0) = " << a.at(2, 0) << std::endl; std::cout << "a[2][0] = " << a[2][0] << std::endl;; std::cout << std::endl; + /* // basic operations std::cout << "Basic operations" << std::endl; std::cout << "a + b = \n" << a + b; @@ -28,26 +29,25 @@ int main(int argc, char *argv[]) { std::cout << "a * 2 = \n" << a * 2; std::cout << "2 * a = \n" << 2 * a; std::cout << "a.td() = \n" << a.td(); // or a.trasposed(); - std::cout << std::endl; + std::cout << std::endl;*/ // special matrices - mm::square_matrix<std::complex<int>, 2> f {{{2, 3}, {1, 4}}, {{6, 1}, {-3, 4}}}; + /*mm::square_matrix<std::complex<int>, 2> f {{{2, 3}, {1, 4}}, {{6, 1}, {-3, 4}}}; std::cout << "Square matrix" << std::endl; std::cout << "f = \n" << f; - std::cout << "tr(f) = " << f.tr() /* or f.trace() */ << std::endl; + std::cout << "tr(f) = " << f.tr(); //or f.trace() << std::endl; - f.t(); - std::cout << "after in place transpose f.t(), f = \n" << f; + mm::t_square_matrix<std::complex<int>, 2>& ft = f.t(); + std::cout << "after in place transpose f.t(), f = \n" << ft; std::cout << std::endl; - auto identity = mm::square_matrix<int, 3>::identity(); std::cout << "Identity matrix" << std::endl; std::cout << "I = \n" << identity; - std::cout << std::endl; + std::cout << std::endl; */ return 0; |