Java Matrix Transpose transpose(int N, double src[][])

Here you can find the source of transpose(int N, double src[][])

Description

transpose

License

Open Source License

Declaration

public static void transpose(int N, double src[][]) 

Method Source Code

//package com.java2s;
/*//  w  ww.ja v a2  s . c o m
 * #%L
 * Cyni Implementation (cyni-impl)
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2006 - 2013 The Cytoscape Consortium
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 2.1 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
 * #L%
 */

public class Main {
    public static void transpose(int M, int N, double src[][], double dst[][]) {
        for (int i = M - 1; i >= 0; i--) {
            for (int j = N - 1; j >= 0; j--)
                dst[j][i] = src[i][j];

        }

    }

    public static double[][] transpose(double src[][]) {
        int M = src.length;
        int N = src[0].length;
        double dst[][] = new double[N][M];
        for (int i = M - 1; i >= 0; i--) {
            for (int j = N - 1; j >= 0; j--)
                dst[j][i] = src[i][j];

        }

        return dst;
    }

    public static void transpose(int N, double src[][]) {
        for (int i = N - 1; i >= 0; i--) {
            for (int j = i - 1; j >= 0; j--) {
                double tmp = src[i][j];
                src[i][j] = src[j][i];
                src[j][i] = tmp;
            }

        }

    }
}

Related

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