From d8dda26de6d8eb4a1c1f278d3e0234a93b3ef6cf Mon Sep 17 00:00:00 2001 From: Kenneth Vanhoey Date: Wed, 30 Mar 2011 16:58:33 +0200 Subject: [PATCH] vector by transposed vector multiplication --- include/Geometry/matrix.h | 8 ++++++-- include/Geometry/matrix.hpp | 13 ++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/Geometry/matrix.h b/include/Geometry/matrix.h index 7c72e441..42e814d1 100644 --- a/include/Geometry/matrix.h +++ b/include/Geometry/matrix.h @@ -161,11 +161,15 @@ class Matrix // Vector / Matrix multiplication template -Vector operator*(const Vector& v, const Matrix& m); +Vector operator*(const Vector& v, const Matrix& m) ; // Scalar / Matrix multiplication template -Matrix operator*(T s, const Matrix& m); +Matrix operator*(T s, const Matrix& m) ; + +// Vector / Transposed vector multiplication +template +Matrix transposed_vectors_mult(const Vector& v1, const Vector& v2) ; /**********************************************/ diff --git a/include/Geometry/matrix.hpp b/include/Geometry/matrix.hpp index 3ade5395..85495aa1 100644 --- a/include/Geometry/matrix.hpp +++ b/include/Geometry/matrix.hpp @@ -405,9 +405,11 @@ bool Matrix::operator==(const Matrix& m) const { template std::ostream& operator<<(std::ostream& out, const Matrix& m) { - for(unsigned int i = 0; i < M; ++i) + for(unsigned int i = 0; i < M; ++i) { for(unsigned int j = 0; j < N; ++j) out << m(i,j) << " " ; + std::cout << std::endl ; + } return out ; } @@ -446,6 +448,15 @@ Matrix operator*(T s, const Matrix& m) return res ; } +template +Matrix transposed_vectors_mult(const Vector& v1, const Vector& v2) { + Matrix res ; + for(unsigned int i = 0; i < M; ++i) + for(unsigned int j = 0; j < N; ++j) + res(i,j) = v1[i] * v2[j] ; + return res ; +} + } // namespace Geom } // namespace CGoGN -- GitLab