computeSigmaPoints method

  1. @override
Matrix computeSigmaPoints(
  1. Matrix x,
  2. dynamic p
)
override

Computes Sigma Points and returns it in matrix form

Implementation

@override
Matrix computeSigmaPoints(Matrix x, var p) {
  assert(n == x.rowsNum * x.columnsNum);

  Matrix tmp;
  int newN = n;

  if (x is num) {
    x = Matrix.fromList([
      [x as double]
    ]);
  }

  if (p is num) {
    tmp = Matrix.identity(newN) * p;
  } else {
    tmp = atLeast2D(p);
  }

  double lambda = (pow(_alpha, 2) * (newN + _kappa)) - newN;
  tmp = tmp * (lambda + newN);
  List<List<double>> test = matrixToList(tmp);

  Matrix u = Matrix.fromList(choleskyDecomposition(test)).transpose();

  List<List<double>> output =
      List.generate(2 * newN + 1, (i) => List.generate(newN, (j) => 0));
  output[0] = x[0].toList();

  for (int i = 0; i < newN; i++) {
    output[i + 1] = (x[0] + u[i]).toList();
    output[newN + i + 1] = (x[0] - u[i]).toList();
  }

  return Matrix.fromList(output);
}