rotate method

Matrix rotate(
  1. int p,
  2. int q,
  3. double c,
  4. double s,
)

Implementation

Matrix rotate(int p, int q, double c, double s) {
  int n = rowCount;
  Matrix result = _Utils.toNumMatrix(this);

  for (int i = 0; i < n; i++) {
    double api = c * this[i][p] - s * this[i][q];
    double aqi = s * this[i][p] + c * this[i][q];
    result[i][p] = api;
    result[i][q] = aqi;
  }

  for (int i = 0; i < n; i++) {
    double aip = c * this[p][i] - s * this[q][i];
    double aiq = s * this[p][i] + c * this[q][i];
    result[p][i] = aip;
    result[q][i] = aiq;
  }

  return result;
}