List of usage examples for java.util Arrays copyOf
public static boolean[] copyOf(boolean[] original, int newLength)
From source file:FileMangement.PathFinder.java
public static Path[] NullCleaner(Path[] test) { int i = 0;/*w w w . ja va 2 s. c om*/ int nullAmount = 0; while (i < test.length) { if (test[i] == null) { nullAmount++; i++; } else { i++; } } Path[] cleanArray = Arrays.copyOf(test, test.length - nullAmount); return cleanArray; }
From source file:net.shipilev.fjptrace.util.PairedList.java
private void ensureCapacity(int newSize) { if (newSize >= size) { k1 = Arrays.copyOf(k1, multiply(newSize)); k2 = Arrays.copyOf(k2, multiply(newSize)); size = multiply(newSize);// ww w.ja v a2s .c o m } }
From source file:com.opengamma.analytics.math.statistics.descriptive.QuartileSkewnessCalculator.java
/** * @param x The array of data, not null. Must contain at least three points. * @return The quartile skewness./* w w w .j av a2 s . co m*/ */ @Override public Double evaluate(final double[] x) { Validate.notNull(x, "x"); final int n = x.length; Validate.isTrue(n >= 3, "Need at least three points to calculate interquartile range"); if (n == 3) { return (x[2] - 2 * x[1] + x[0]) / 2.; } final double[] copy = Arrays.copyOf(x, n); Arrays.sort(copy); double[] lower, upper; if (n % 2 == 0) { lower = Arrays.copyOfRange(copy, 0, n / 2); upper = Arrays.copyOfRange(copy, n / 2, n); } else { lower = Arrays.copyOfRange(copy, 0, n / 2 + 1); upper = Arrays.copyOfRange(copy, n / 2, n); } final double q1 = MEDIAN.evaluate(lower); final double q2 = MEDIAN.evaluate(x); final double q3 = MEDIAN.evaluate(upper); return (q1 - 2 * q2 + q3) / (q3 - q1); }
From source file:it.unibo.alchemist.model.implementations.positions.ContinuousGenericEuclidean.java
private ContinuousGenericEuclidean(final boolean copy, final double... coord) { if (copy) {//from w ww. j a v a2 s.co m c = Arrays.copyOf(coord, coord.length); } else { c = coord; } org.apache.commons.math3.util.MathUtils.checkFinite(c); }
From source file:edu.illinois.cs.cogcomp.saul.test.TestReal.java
public TestReal(Learner classifier, Classifier oracle, Parser parser) { int examples = 0; double totalDifference = 0; double[] actuals = {}; double[] predictions = {}; classifier.write(System.out); for (Object example = parser.next(); example != null; example = parser.next()) { double prediction = classifier.realValue(example); predictions = Arrays.copyOf(predictions, predictions.length + 1); predictions[predictions.length - 1] = prediction; double value = oracle.realValue(example); actuals = Arrays.copyOf(actuals, actuals.length + 1); actuals[actuals.length - 1] = value; double difference = Math.abs(prediction - value); totalDifference += difference;/*w ww .j a v a 2 s .c o m*/ classifier.classify(example); ++examples; System.out.println( "Example " + examples + " difference: " + difference + " (prediction: " + prediction + ")"); } System.out.println("test examples number: " + examples); double avg = totalDifference / examples; System.out.println("Average difference: " + avg); double p = getPearsonCorrelation(predictions, actuals); System.out.println("Pearson correlation:" + p); SpearmansCorrelation e = new SpearmansCorrelation(); double sp = e.correlation(predictions, actuals); System.out.println("Spearman correlation:" + sp); }
From source file:gaffer.function.simple.filter.MultiRegex.java
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_OBJECT) @JsonProperty("value") public Pattern[] getPatterns() { return Arrays.copyOf(patterns, patterns.length); }
From source file:com.offbynull.peernetic.playground.chorddht.messages.external.GetClosestFingerRequest.java
public byte[] getSkipId() { return Arrays.copyOf(skipId, skipId.length); }
From source file:org.leandreck.endpoints.processor.model.RequestMapping.java
public String[] produces() { return Arrays.copyOf(produces, produces.length); }
From source file:hivemall.utils.lang.ArrayUtils.java
@Nonnull public static double[] set(@Nonnull double[] src, final int index, final double value) { if (index >= src.length) { src = Arrays.copyOf(src, src.length * 2); }/* w w w.j a v a 2s. com*/ src[index] = value; return src; }
From source file:at.jku.traces.json.UserTrace.java
/** * //from ww w. j a v a 2s . c om * @param id * user id * @param tr * GPS points */ public UserTrace(final int id, final GPSPoint[] tr) { mi = id; trace = Arrays.copyOf(tr, tr.length); }