transpose Matrix - Android java.lang

Android examples for java.lang:Math Matrix

Description

transpose Matrix

Demo Code


//package com.java2s;

public class Main {
    public static float[][] transposeMatrix(float[][] m) {
        int cols = m.length;
        int rows = m[0].length;
        float[][] result = new float[rows][cols];

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                result[i][j] = m[j][i];// w  ww . j  a  va 2s.  com
            }
        }

        return result;
    }
}

Related Tutorials