innerProd method
Returns the scalar product of this
and other
.
- The elements of
this
andother
are multiplied component-wise and summed. - Returns an
int
if both lists are of typeList<int>
, otherwise returns adouble
.
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;
}