transpose function

List<double> transpose(
  1. List<double> out,
  2. List<double> a
)

Transpose the values of a mat2

@param {mat2} out the receiving matrix @param {ReadonlyMat2} a the source matrix @returns {mat2} out

Implementation

List<double> transpose(List<double> out, List<double> a) {
  // If we are transposing ourselves we can skip a few steps but have to cache
  // some values
  if (out == a) {
    double a1 = a[1];
    out[1] = a[2];
    out[2] = a1;
  } else {
    out[0] = a[0];
    out[1] = a[2];
    out[2] = a[1];
    out[3] = a[3];
  }

  return out;
}