Here you can find the source of toShortArray(double[][] array)
public static short[][] toShortArray(double[][] array)
//package com.java2s; //License from project: Open Source License public class Main { public static short[][] toShortArray(double[][] array) { int nr = array.length; int nc = array[0].length; short[][] ret = new short[nr][nc]; for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { ret[i][j] = (short) array[i][j]; }//from w w w.j a v a 2 s .c o m } return ret; } public static short[][] toShortArray(float[][] array) { int nr = array.length; int nc = array[0].length; short[][] ret = new short[nr][nc]; for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { ret[i][j] = (short) array[i][j]; } } return ret; } public static short[][] toShortArray(int[][] array) { int nr = array.length; int nc = array[0].length; short[][] ret = new short[nr][nc]; for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { ret[i][j] = (short) array[i][j]; } } return ret; } public static short[][] toShortArray(long[][] array) { int nr = array.length; int nc = array[0].length; short[][] ret = new short[nr][nc]; for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { ret[i][j] = (short) array[i][j]; } } return ret; } public static short[][] toShortArray(byte[][] array) { int nr = array.length; int nc = array[0].length; short[][] ret = new short[nr][nc]; for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { ret[i][j] = (short) array[i][j]; } } return ret; } public static short[][] toShortArray(String[][] array) { int nr = array.length; int nc = array[0].length; short[][] ret = new short[nr][nc]; for (int i = 0; i < nr; i++) { for (int j = 0; j < nc; j++) { ret[i][j] = Short.parseShort(array[i][j]); } } return ret; } }