Here you can find the source of toNumberMatrix(byte[][] matrix)
Parameter | Description |
---|---|
matrix | the matrix to convert |
public static Number[][] toNumberMatrix(byte[][] matrix)
//package com.java2s; /*/*from ww w . j ava 2s .co m*/ * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 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 Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Turns the Number matrix into one consisting of primitive bytes. * * @param matrix the matrix to convert * @return the converted matrix */ public static Number[][] toNumberMatrix(byte[][] matrix) { Byte[][] result; int i; int n; result = new Byte[matrix.length][]; for (i = 0; i < matrix.length; i++) { result[i] = new Byte[matrix[i].length]; for (n = 0; n < matrix[i].length; n++) result[i][n] = new Byte(matrix[i][n]); } return result; } /** * Turns the Number matrix into one consisting of primitive shorts. * * @param matrix the matrix to convert * @return the converted matrix */ public static Number[][] toNumberMatrix(short[][] matrix) { Short[][] result; int i; int n; result = new Short[matrix.length][]; for (i = 0; i < matrix.length; i++) { result[i] = new Short[matrix[i].length]; for (n = 0; n < matrix[i].length; n++) result[i][n] = new Short(matrix[i][n]); } return result; } /** * Turns the primitve int matrix into one consisting of Integers. * * @param matrix the matrix to convert * @return the converted matrix */ public static Number[][] toNumberMatrix(int[][] matrix) { Integer[][] result; int i; int n; result = new Integer[matrix.length][]; for (i = 0; i < matrix.length; i++) { result[i] = new Integer[matrix[i].length]; for (n = 0; n < matrix[i].length; n++) result[i][n] = new Integer(matrix[i][n]); } return result; } /** * Turns the primitive long matrix into one consisting of Longs. * * @param matrix the matrix to convert * @return the converted matrix */ public static Number[][] toNumberMatrix(long[][] matrix) { Long[][] result; int i; int n; result = new Long[matrix.length][]; for (i = 0; i < matrix.length; i++) { result[i] = new Long[matrix[i].length]; for (n = 0; n < matrix[i].length; n++) result[i][n] = new Long(matrix[i][n]); } return result; } /** * Turns the primitive float matrix into one consisting of Floats. * * @param matrix the matrix to convert * @return the converted matrix */ public static Number[][] toNumberMatrix(float[][] matrix) { Float[][] result; int i; int n; result = new Float[matrix.length][]; for (i = 0; i < matrix.length; i++) { result[i] = new Float[matrix[i].length]; for (n = 0; n < matrix[i].length; n++) result[i][n] = new Float(matrix[i][n]); } return result; } /** * Turns the primitive double matrix into one consisting of Doubles. * * @param matrix the matrix to convert * @return the converted matrix */ public static Number[][] toNumberMatrix(double[][] matrix) { Double[][] result; int i; int n; result = new Double[matrix.length][]; for (i = 0; i < matrix.length; i++) { result[i] = new Double[matrix[i].length]; for (n = 0; n < matrix[i].length; n++) result[i][n] = new Double(matrix[i][n]); } return result; } }