add method

  1. @override
void add(
  1. Tensor<double> right
)
override

Calculates sum of two tensors.

Element i is calculated with the formula:

x[i] = x[i] + right[i];

Throws ArgumentError if tensor shapes are not equal.

Implementation

@override
void add(Tensor<double> right) {
  _checkSameShape(right);
  final elements = this.elements;
  final rightElements = right.elements;
  final n = length;
  for (var i = 0; i < n; i++) {
    elements[i] += rightElements[i];
  }
}