innerProd method

num innerProd(
  1. List<num> other
)

Returns the scalar product of this and other.

  • The elements of this and other are multiplied component-wise and summed.
  • Returns an int if both lists are of type List<int>, otherwise returns a double.

Info: Non-zero numerical vectors with the property: this * other == 0 are called orthogonal.

Implementation

num innerProd(List<num> other) {
  mustHaveSameLength(other, operatorSymbol: 'innerProd()');
  num sum = 0;
  for (var i = 0; i < length; i++) {
    sum += this[i] * other[i];
  }
  return sum;
}