diff --git a/Matrix.h b/Matrix.h index c8ed8ca..b9b9d18 100644 --- a/Matrix.h +++ b/Matrix.h @@ -28,9 +28,17 @@ public: // but the data size should be equal to avoid problems // We cannot check the data size directly, but the row*col should be equal unsigned int matrixSize = this->cols * this->rows; - if (matrixSize != r->rows * r->cols) - // Exception??? For now we don't do anything + unsigned int resultSize = r->rows * r->cols; + if (matrixSize != resultSize) { + // Return a null matrix; + // We dont set data to nullptr because it is allocated memory + // Instead we write all zeros + for (int dataIx = 0; dataIx < resultSize; dataIx++) + r->data[dataIx] = 0.0f; + r->rows = 0; + r->cols = 0; return; + } r->cols = this->rows; r->rows = this->cols;