divScalar method

Tensor<T> divScalar(
  1. num right, {
  2. bool noNan = false,
  3. bool swapArguments = false,
})

Calculates element-wise fraction.

The formula for result element i is:

elements[i] / scalar;

If swapArguments is true, the formula is:

scalar / this[i];

If denominator is 0.0, the result is double.nan when using floating-point numbers and 0 when using integers. If noNan is true, the result is 0 when using floating-point numbers.

Throws ArgumentError if tensor shapes are not equal.

Example

// Element i will be:
//     1/x[i];
tensor.divScalar(1, swapArguments:true);

Implementation

Tensor<T> divScalar(
  num right, {
  bool noNan = false,
  bool swapArguments = false,
}) {
  final builder = toBuilder();
  builder.divScalar(right, noNan: noNan, swapArguments: swapArguments);
  return builder.build();
}