Java Matrix Transpose transpose(float[] mat, float[] dest)

Here you can find the source of transpose(float[] mat, float[] dest)

Description

transpose

License

Open Source License

Declaration

public static float[] transpose(float[] mat, float[] dest) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static float[] transpose(float[] mat, float[] dest) {
        // If we are transposing ourselves we can skip a few steps but have to
        // cache some values
        if (dest == null || mat == dest) {
            float a0 = mat[1], a2 = mat[2], a5 = mat[5];
            mat[1] = mat[3];//  w ww. jav  a  2 s.c  o m
            mat[2] = mat[6];
            mat[3] = a0;
            mat[5] = mat[7];
            mat[6] = a2;
            mat[7] = a5;
            return mat;
        }

        dest[0] = mat[0];
        dest[1] = mat[3];
        dest[2] = mat[6];
        dest[3] = mat[1];
        dest[4] = mat[4];
        dest[5] = mat[7];
        dest[6] = mat[2];
        dest[7] = mat[5];
        dest[8] = mat[8];
        return dest;
    }
}

Related

  1. transpose(double[][] matrix)
  2. transpose(final double[][] A)
  3. transpose(final double[][] m)
  4. transpose(final double[][] original)
  5. transpose(final double[][] src, final double[][] dest, int l1, int l2)
  6. transpose(float[][] data)
  7. transpose(int N, double src[][])
  8. transpose(int[][] input)
  9. transpose(int[][] M)