Here you can find the source of concatenate(double[] p1, double[] p2)
public static double[] concatenate(double[] p1, double[] p2)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static double[] concatenate(double[] p1, double[] p2) { double[] ret = new double[p1.length + p2.length]; ArrayList<Double> lst = new ArrayList<>(); for (int i = 0; i < p1.length; i++) { lst.add(p1[i]);// w w w .j a v a 2 s .c o m } for (int i = 0; i < p2.length; i++) { lst.add(p2[i]); } Double[] d = new Double[p1.length + p2.length]; d = lst.toArray(d); for (int i = 0; i < d.length; i++) { ret[i] = d[i]; } return ret; } public static int[] concatenate(int[] p1, int[] p2) { int[] ret = new int[p1.length + p2.length]; ArrayList<Integer> lst = new ArrayList<>(); for (int i = 0; i < p1.length; i++) { lst.add(p1[i]); } for (int i = 0; i < p2.length; i++) { lst.add(p2[i]); } Integer[] d = new Integer[p1.length + p2.length]; d = lst.toArray(d); for (int i = 0; i < d.length; i++) { ret[i] = d[i]; } return ret; } public static double[][] add(double[][] a, double[][] b) { double[][] d = new double[a.length][a[0].length]; if (isIdenticalMatrix(a, b)) { for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[0].length; j++) { d[i][j] = a[i][j] + b[i][j]; } } } else { } return d; } private static boolean isIdenticalMatrix(double[][] a, double[][] b) { if (a.length == b.length && a[0].length == b[0].length) { return true; } else { return false; } } }