operator unary- method

Vector operator unary-()

Negates this vector element-wise.

Returns a new vector containing the result of the element-wise negation.

Example:

var vector = Vector([1, 2, 3]);
var result = -vector;
print(result);
// Output:   /// // -1 -2 -3

Implementation

Vector operator -() {
  List newData = List.generate(length, (i) => -_data[i]);

  return Vector(newData);
}