operator * method
Vector
operator *(
- dynamic other
)
Implementation
Vector operator *(dynamic other) {
Vector result = Vector(length);
if (other is num || other is Complex) {
for (int i = 0; i < length; i++) {
result[i] = this[i] * (other is num ? Complex(other) : other);
}
} else if (other is Matrix) {
result = Vector((other * this).flatten());
} else if (other is Vector) {
if (length != other.length) {
throw ArgumentError(
"Vectors must have the same length for subtraction.");
}
for (int i = 0; i < length; i++) {
result[i] = this[i] * other[i];
}
}
return result;
}