Here you can find the source of mergeCoords(List
Parameter | Description |
---|---|
x | the x coordinates |
y | the y coordinates |
public static List<Double> mergeCoords(List<Double> x, List<Double> y)
//package com.java2s; /*// w w w . jav a 2 s.co m * * * Copyright 2015 Skymind,Inc. * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * */ import java.util.ArrayList; import java.util.List; public class Main { /** * This will merge the coordinates of the given coordinate system. * @param x the x coordinates * @param y the y coordinates * @return a vector such that each (x,y) pair is at ret[i],ret[i+1] */ public static double[] mergeCoords(double[] x, double[] y) { if (x.length != y.length) throw new IllegalArgumentException( "Sample sizes must be the same for each data applyTransformToDestination."); double[] ret = new double[x.length + y.length]; for (int i = 0; i < x.length; i++) { ret[i] = x[i]; ret[i + 1] = y[i]; } return ret; } /** * This will merge the coordinates of the given coordinate system. * @param x the x coordinates * @param y the y coordinates * @return a vector such that each (x,y) pair is at ret[i],ret[i+1] */ public static List<Double> mergeCoords(List<Double> x, List<Double> y) { if (x.size() != y.size()) throw new IllegalArgumentException( "Sample sizes must be the same for each data applyTransformToDestination."); List<Double> ret = new ArrayList<>(); for (int i = 0; i < x.size(); i++) { ret.add(x.get(i)); ret.add(y.get(i)); } return ret; } }