pow method Null safety

  1. @override
void pow(
  1. Tensor<double> right,
  2. {bool swapArguments = false}
)
override

Calculates pow(a,b) for each element.

Element i is calculated with the formula:

x[i] = pow(x[i], right[i]);

If swapArguments is true, base and power arguments will be swapped.

Throws ArgumentError if tensor shapes are not equal.

Implementation

@override
void pow(Tensor<double> right, {bool swapArguments = false}) {
  final elements = this.elements;
  final rightElements = right.elements;
  final n = length;
  if (swapArguments) {
    for (var i = 0; i < n; i++) {
      elements[i] = math.pow(rightElements[i], elements[i]).toDouble();
    }
  } else {
    for (var i = 0; i < n; i++) {
      elements[i] = math.pow(elements[i], rightElements[i]).toDouble();
    }
  }
}