Binds two linear arrays, producing a 2D array. - Java Collection Framework

Java examples for Collection Framework:Array Algorithm

Description

Binds two linear arrays, producing a 2D array.

Demo Code



public class Main{

    /**// w  w w.  j  a  va2s .  c  om
     * Binds two linear arrays, producing a 2D array.
     * 
     * @param axis The first component array.
     * @param seriesData The second component array.
     * @return Binded rows.
     * @throws DTWException If error occures.
     */
    public static double[][] rBind(double[] axis, double[] seriesData)
            throws DTWException {
        if (axis.length == seriesData.length) {
            int len = axis.length;
            double[][] res = new double[len][2];
            for (int i = 0; i < len; i++) {
                res[i][0] = axis[i];
                res[i][1] = seriesData[i];
            }
            return res;
        }
        throw new DTWException(
                "Error while binding rows: uneven arrays provided.");
    }
}

Related Tutorials