operator + method
Implementation
ValueMatrix operator +(dynamic other) {
if (other is Value) {
return ValueMatrix(
_data.map((row) => row.map((v) => v + other).toList()).toList());
} else if (other is ValueMatrix) {
if (rows != other.rows || cols != other.cols) {
throw ArgumentError(
"Matrices must have the same dimensions for addition.");
}
return ValueMatrix(List.generate(rows,
(r) => List.generate(cols, (c) => _data[r][c] + other._data[r][c])));
}
throw UnimplementedError(
"Addition not supported for type ${other.runtimeType}");
}