I\'m trying to develop a func which allows to sum two matrix if they are equals to the same dimension, but I get an error \"EXC_BAD_INSTRUCTION\" on the try.
Here is
Actually your error is Index out of range
Replace your extension with this code.
extension Matrix: Operation {
mutating func sumWith(matrixB: Matrix) throws -> Matrix {
guard self == matrixB else { throw RisedError.DimensionNotEquals }
for row in 0...self.rows - 1 {
for column in 0...self.columns - 1 {
self[row, column] = matrixB[row, column] + self[row, column]
}
}
return self
}
}
Hope it would solve your problem.