Java Utililty Methods Matrix Transpose

List of utility methods to do Matrix Transpose

Description

The list of methods to do Matrix Transpose are organized into topic(s).

Method

Object[][]transpose(Object[][] matrix)
Transposes the matrix
Object[][] temp = new Object[matrix[0].length][matrix.length];
for (int i = 0; i < matrix.length; i++)
    for (int j = 0; j < matrix[0].length; j++)
        temp[j][i] = matrix[i][j];
return temp;
voidtranspose2d(Object[][] array)
A method for transposing square 2D arrays in-place.
if (array == null) {
    throw new IllegalArgumentException("Array must not be null");
for (int j = 0; j < array[0].length; j++) {
    for (int i = j + 0; i < array.length; i++) {
        swap2d(array, i, j, j, i);
Double[][]transpose2DArray(Double[][] data)
Transpose a 2D array of Double
Double[][] transposed = new Double[data[0].length][data.length];
for (int rowIndex = 0; rowIndex < data.length; rowIndex++) {
    for (int columnIndex = 0; columnIndex < data[0].length; columnIndex++) {
        if (data[rowIndex][columnIndex] != null) {
            transposed[columnIndex][rowIndex] = data[rowIndex][columnIndex];
return transposed;
float[][]transpose3x3Matrix(float[][] m)
Utility function that returns the transpose of the given 3X3 matrix.
float[][] matrix = new float[4][4];
for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
        matrix[i][j] = m[j][i];
return matrix;
voidtranspose4x4(float m[], float t[])
Transpose the given matrix, and write the result into the given target matrix.
float m0 = m[0];
float m1 = m[1];
float m2 = m[2];
float m3 = m[3];
float m4 = m[4];
float m5 = m[5];
float m6 = m[6];
float m7 = m[7];
...
Objecttranspose_image(Object source, int width, int height)
transposimage
if (source instanceof float[]) {
    float[] temp = new float[width * height];
    for (int i = 0; i < width; i++) {
        float[] temp2 = (float[]) get_image_col(source, width, height, i);
        System.arraycopy(temp2, 0, temp, i * height, height);
    return temp;
} else {
...
boolean[][]transposeBooleanMatrix(boolean[][] matrix)
Transpose a 2D array of boolean
boolean[][] transposed = new boolean[matrix.length][matrix[0].length];
for (int rowIndex = 0; rowIndex < matrix.length; rowIndex++) {
    for (int columnIndex = 0; columnIndex < matrix[0].length; columnIndex++) {
        if (matrix[rowIndex][columnIndex]) {
            transposed[columnIndex][rowIndex] = true;
return transposed;
float[]transposeInPlace(float[] src)
transpose In Place
float v1 = src[1];
float v2 = src[2];
float v3 = src[3];
float v6 = src[6];
float v7 = src[7];
float v11 = src[11];
src[1] = src[4];
src[2] = src[8];
...
double[][]transposeMatrix(double[][] m)
transpose Matrix
double[][] temp = new double[m[0].length][m.length];
for (int i = 0; i < m.length; i++)
    for (int j = 0; j < m[0].length; j++)
        temp[j][i] = m[i][j];
return temp;
double[][]transposeMatrix(double[][] m)
transpose Matrix
double[][] temp = new double[m[0].length][m.length];
for (int i = 0; i < m.length; i++)
    for (int j = 0; j < m[0].length; j++)
        temp[j][i] = m[i][j];
return temp;