transpose method

  1. @override
RealMatrix transpose()
override

Returns the transpose of this matrix.

This is an operation that simply flips a matrix over its diagonal (so it switches the row and column indices of the matrix to create a new one).

Implementation

@override
RealMatrix transpose() {
  final source = List<double>.generate(rowCount * columnCount, (_) => 0);

  for (var i = 0; i < rowCount; i++) {
    for (var j = 0; j < columnCount; j++) {
      source[rowCount * j + i] = this(i, j);
    }
  }

  return RealMatrix.fromFlattenedData(
    rows: columnCount,
    columns: rowCount,
    data: source,
  );
}