operator + method
dynamic
operator +(
- dynamic other
Implementation
dynamic operator +(dynamic other) {
if (other is Matrix) {
return other + this;
} else if (other is num || other is Complex) {
Vector result = Vector(length);
for (int i = 0; i < length; i++) {
result[i] = this[i] + (other is num ? Complex(other) : other);
}
}
if (length != other.length) {
throw ArgumentError("Vectors must have the same length for addition.");
}
if (other is! Vector && other is! List) {
throw ArgumentError(
"Invalid right-hand value type (Vector or List<num>).");
}
Vector result = Vector(length);
for (int i = 0; i < length; i++) {
result[i] = this[i] + other[i];
}
return result;
}