public static double[] sumArray(double[] a1, double[] a2) throws IllegalArgumentException{
        if (a1 == null && a2 == null){
            throw new IllegalArgumentException("Given array size mismatch");
        }
        else if (a1 == null) {
            a1 = new double[a2.length];
        }
        else if (a2 == null) {
            a2 = new double[a1.length];
        }
        if (a1.length != a2.length) {
            throw new IllegalArgumentException("Given array size mismatch");
        }
        double[] res = new double[a1.length];
        for (int i = 0; i < a1.length; i++) {
            res[i] = ( a1[i] + a2[i]);
        }

        return res;
    }