From 91348e7c099266e649ec1847f855630178d6cc07 Mon Sep 17 00:00:00 2001 From: Leto Date: Fri, 27 Dec 2024 23:41:16 +0100 Subject: [PATCH] Added operations for floats --- matrices.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/matrices.h b/matrices.h index 4311640..57f6c03 100644 --- a/matrices.h +++ b/matrices.h @@ -36,7 +36,10 @@ class Matrix{ inline Matrix operator+(const Matrix*); inline Matrix operator-(const Matrix*); inline Matrix operator*(const Matrix*); - // TODO : Add float parameters for these + + inline Matrix operator+(float); + inline Matrix operator-(float); + inline Matrix operator*(float); // Constructors inline Matrix(int, int); @@ -59,6 +62,18 @@ Matrix Matrix::operator*(const Matrix* other){ return this->Multiply(other); } +Matrix Matrix::operator+(float value){ + return this->Add(value); +} + +Matrix Matrix::operator-(float value){ + return this->Substract(value); +} + +Matrix Matrix::operator*(float value){ + return this->Multiply(value); +} + // Constructs a zero matrix Matrix::Matrix(int rows, int cols){ for(int m = 0; m < rows; m++){