ComplexMatrix subtract(ComplexMatrix& x, ComplexMatrix& y) { if(sameDimensions(x,y)) { ComplexMatrix result(x.RSize(), x.CSize()); for (int i = 0; i < x.RSize(); i++) { for (int j = 0; j < x.CSize(); j++) { result(i, j) = x(i, j) - y(i, j); } } return result; } else { throw ("Matrices must be the same dimension to perform subtraction"); } }
//From Fransk CSharp code... a bug was fixed in this code.. bool sameDimensions(ComplexMatrix& x, ComplexMatrix& y) { return ((x.RSize() == y.RSize()) && (x.CSize() == y.CSize())) ? true : false; }