Here you can find the source of transpose(final double[][] A)
Parameter | Description |
---|---|
A | a parameter |
public static final double[][] transpose(final double[][] A)
//package com.java2s; /**/*from w w w . j a v a2 s. c o m*/ * Copyright (C) 2012 Fredrik Ekelund <fredrik@ipx.se> * * This file is part of Decision Trees. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * * @param A * @return */ public static final double[][] transpose(final double[][] A) { final int m = A.length; final int n = m > 0 ? A[0].length : 0; final double[][] aT = new double[n][m]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { aT[j][i] = A[i][j]; } } return aT; } /** * * @param a * @return */ public static final double[][] transpose(final double[] a) { final int m = a.length; final double[][] aT = new double[m][1]; for (int i = 0; i < m; i++) { aT[i][0] = a[i]; } return aT; } }