dot method

num dot(
  1. NumericColumn that
)

The dot product of this and that.

Implementation

num dot(NumericColumn that) {
  if (that.length != length) {
    throw PackhorseError.badStructure(
        "Dot product on columns with different lengths.");
  }

  if ((values.any((x) => x.isNaN)) || (that.values.any((x) => x.isNaN))) {
    throw PackhorseError.badStructure(
        "Dot product on columns with missing values.");
  }
  return [for (var i = 0; i < length; i++) this[i] * that[i]]
      .fold<num>(0, (a, b) => a + b);
}