multiplyVector method

List<double> multiplyVector(
  1. List<double> vec
)

Fast vector * matrix multiply: vec (length = rows) * this (rows x cols) Returns a new List

Implementation

List<double> multiplyVector(List<double> vec) {
  if (vec.length != rows) throw ArgumentError('vec length must equal rows');
  final out = List<double>.filled(cols, 0.0);
  // Use local references for speed
  final localData = data;
  final r = rows;
  final c = cols;
  for (var col = 0; col < c; col++) {
    var acc = 0.0;
    for (var row = 0; row < r; row++) {
      acc += vec[row] * localData[row * c + col];
    }
    out[col] = acc;
  }
  return out;
}