From 205f2459063a123cabd83fb66b3880a72fb357bf Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 23 Jun 2017 21:19:11 +0100 Subject: Continuing tests --- include/YAGE/Math/matrix.hpp | 22 +++++++++++++-- test/matrixtest.cpp | 66 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 77 insertions(+), 11 deletions(-) diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.hpp index d4566c98..d1c5fd74 100644 --- a/include/YAGE/Math/matrix.hpp +++ b/include/YAGE/Math/matrix.hpp @@ -235,6 +235,22 @@ Matrix operator-(const T &lhs, Matrix rhs) return rhs; } +template +bool operator==(const Matrix &lhs, const Matrix &rhs) +{ + for(int i=0; i std::ostream& operator<<(std::ostream &os, const Matrix &mat) { @@ -304,12 +320,12 @@ template Matrix transpose(const Matrix return trans; } -template T dot(const Vector &v1, const Vector &v2) +template T dot(const Matrix &m1, const Matrix &m2) { T sum=0; for(int i=0; i multiply(const Matrix &m1, const Matrix &m2) { for(int j=0; j m; m[2][3]=5; - return m[2][3]==5; + return m[2][3]==4; } bool matrixAddition() { yage::Matrix<4, 4, int> m1, m2; - m1[1][1] = 293; - m2[1][1] = 583; + m1[1][1]=293; + m2[1][1]=583; - yage::Matrix<4, 4, int> m3 = m1 + m2; + yage::Matrix<4, 4, int> m3=m1+m2; - return m3[1][1] == 876; + return m3[1][1]==876; +} + +bool vectorDotProduct() +{ + yage::Vector<3, int> v1, v2; + v1[0] = 2; + v1[1] = 3; + v1[2] = 5; + v2[0] = 9; + v2[1] = 6; + v2[2] = 8; + + int x = yage::matrix::dot(v1, v2); + + return x==76; +} + +bool matrixMultiplication() +{ + } int main() { TestBench tb; - test(tb, "Matrix Assign", matrixAssign()); - test(tb, "Matrix Addition", matrixAddition()); + bool all_passed=true; + + try + { + test(tb, "Matrix Assign", matrixAssign()); + } + catch(std::exception e) + { + std::cout<