aboutsummaryrefslogtreecommitdiff
path: root/examples/matmul.cpp
diff options
context:
space:
mode:
authory-jan137 <yousefjan24000@gmail.com>2026-03-14 14:49:46 +0300
committery-jan137 <yousefjan24000@gmail.com>2026-03-14 14:49:46 +0300
commit7db0d82731ababdf0b2f4d986dd54da3b4650954 (patch)
tree145564ba45b9ae74a7eeebc319027c730c7177bc /examples/matmul.cpp
parent5ac9489c079f3f1a0ba1d2d8385001ada83a13b8 (diff)
Add triangular solve
Diffstat (limited to 'examples/matmul.cpp')
-rw-r--r--examples/matmul.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/matmul.cpp b/examples/matmul.cpp
new file mode 100644
index 0000000..c6245f3
--- /dev/null
+++ b/examples/matmul.cpp
@@ -0,0 +1,32 @@
+#include "matrix.hpp"
+
+#include <iomanip>
+#include <iostream>
+
+int main() {
+ const linalg::Matrix a{
+ {1.0, 2.0, 3.0},
+ {4.0, 5.0, 6.0}
+ };
+ const linalg::Matrix b{
+ {7.0, 8.0},
+ {9.0, 10.0},
+ {11.0, 12.0}
+ };
+
+ const linalg::Matrix c = a * b;
+
+ std::cout << "Matrix multiplication\n";
+ std::cout << "A is " << a.rows() << " x " << a.cols() << '\n';
+ std::cout << "B is " << b.rows() << " x " << b.cols() << '\n';
+ std::cout << "C = A * B:\n";
+
+ for (std::size_t i = 0; i < c.rows(); ++i) {
+ for (std::size_t j = 0; j < c.cols(); ++j) {
+ std::cout << std::fixed << std::setprecision(2) << c(i, j)
+ << (j + 1 == c.cols() ? '\n' : ' ');
+ }
+ }
+
+ return 0;
+}