Java Matrix Convert To matrixCastToDouble(String[][] m)

Here you can find the source of matrixCastToDouble(String[][] m)

Description

matrix Cast To Double

License

Open Source License

Declaration

public static double[][] matrixCastToDouble(String[][] m) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double[][] matrixCastToDouble(String[][] m) {
        double[][] matrixDouble = new double[m.length][];

        for (int i = 0; i < m.length; i++)
            matrixDouble[i] = arrayCastToDouble(m[i]);

        return matrixDouble;
    }/*from   w ww .j  a v  a  2  s  .co  m*/

    public static double[] arrayCastToDouble(int[] arrayInt) {
        double[] arrayDouble = new double[arrayInt.length];

        for (int i = 0; i < arrayDouble.length; i++)
            arrayDouble[i] = (double) arrayInt[i];

        return arrayDouble;
    }

    public static double[] arrayCastToDouble(Integer[] arrayInt) {
        double[] arrayDouble = new double[arrayInt.length];

        for (int i = 0; i < arrayDouble.length; i++)
            arrayDouble[i] = arrayInt[i].doubleValue();

        return arrayDouble;
    }

    public static double[] arrayCastToDouble(Double[] arrayIn) {
        double[] arrayDouble = new double[arrayIn.length];

        for (int i = 0; i < arrayDouble.length; i++)
            arrayDouble[i] = arrayIn[i];

        return arrayDouble;
    }

    public static double[] arrayCastToDouble(float[] arrayFloat) {
        double[] arrayDouble = new double[arrayFloat.length];

        for (int i = 0; i < arrayDouble.length; i++)
            arrayDouble[i] = (double) arrayFloat[i];

        return arrayDouble;
    }

    public static double[] arrayCastToDouble(String[] arrayString) {
        double[] arrayDouble = new double[arrayString.length];

        for (int i = 0; i < arrayDouble.length; i++)
            arrayDouble[i] = Double.parseDouble(arrayString[i]);

        return arrayDouble;
    }
}

Related

  1. matrixToArray(double[][] m)
  2. matrixToArray(int[][] input, int fromRow, int rows, int fromColumn, int columns)
  3. matrixToQuaternion(float[] m)
  4. matrixToShort(final byte[][] b)