summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2019-03-02 11:22:17 +0100
committerNao Pross <naopross@thearcway.org>2019-03-02 11:22:17 +0100
commitb22ab9a435dceb362cb9eab8ec195d908fd8d5e9 (patch)
treebf92f98f8f594ca3abec3dd682c2f0b3f0ee29c3 /test
parentFix matrix operator[] to allow M[j][k] and operator<< formatting (diff)
downloadlibmm-b22ab9a435dceb362cb9eab8ec195d908fd8d5e9.tar.gz
libmm-b22ab9a435dceb362cb9eab8ec195d908fd8d5e9.zip
Update matrix test, add square matrix trace and fix comments
Diffstat (limited to 'test')
-rw-r--r--test/matrix_example.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/test/matrix_example.cpp b/test/matrix_example.cpp
index 26aeede..469cbff 100644
--- a/test/matrix_example.cpp
+++ b/test/matrix_example.cpp
@@ -12,18 +12,43 @@ 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;
// 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;
std::cout << "a - b = \n" << a - b;
std::cout << "a * c = \n" << a * c;
std::cout << "a * 2 = \n" << a * 2;
std::cout << "2 * a = \n" << 2 * a;
- std::cout << "tr(a) = \n" << a.trd();
+ std::cout << "a.td() = \n" << a.td(); // or a.trasposed();
+ std::cout << std::endl;
+
+ // special matrices
+ 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;
+
+ f.t();
+ std::cout << "after in place transpose f.t(), f = \n" << f;
+ 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;
+
return 0;
}