@Override public FloatColumn bottom(final int n) { FloatArrayList bottom = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new FloatColumn(name() + "[Bottoms " + n + "]", bottom); }
@Override public FloatColumn top(int n) { FloatArrayList top = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new FloatColumn(name() + "[Top " + n + "]", top); }
@Override public FloatColumn lag(int n) { final int srcPos = n >= 0 ? 0 : 0 - n; final float[] dest = new float[size()]; final int destPos = n <= 0 ? 0 : n; final int length = n >= 0 ? size() - n : size() + n; for (int i = 0; i < size(); i++) { dest[i] = FloatColumnType.missingValueIndicator(); } float[] array = data.toFloatArray(); System.arraycopy(array, srcPos, dest, destPos, length); return new FloatColumn(name() + " lag(" + n + ")", new FloatArrayList(dest)); }
/** * Returns the smallest ("bottom") n values in the column * * @param n The maximum number of records to return. The actual number will be smaller if n is greater than the * number of observations in the column * @return A list, possibly empty, of the smallest n observations */ public FloatArrayList bottom(int n) { FloatArrayList bottom = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return bottom; }
/** * Returns the largest ("top") n values in the column * * @param n The maximum number of records to return. The actual number will be smaller if n is greater than the * number of observations in the column * @return A list, possibly empty, of the largest observations */ public FloatArrayList top(int n) { FloatArrayList top = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values, reverseFloatComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return top; }
@Override public FloatColumn bottom(final int n) { FloatArrayList bottom = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new FloatColumn(name() + "[Bottoms " + n + "]", bottom); }
@Override public FloatColumn top(int n) { FloatArrayList top = new FloatArrayList(); float[] values = data.toFloatArray(); FloatArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new FloatColumn(name() + "[Top " + n + "]", top); }
private void serializeList(final DataOutput out, final List list) throws IOException { Class oCls = list.getClass(); if (oCls.equals(IntArrayList.class)) { serialize(out, ((IntArrayList) list).toIntArray()); } else if (oCls.equals(FloatArrayList.class)) { serialize(out, ((FloatArrayList) list).toFloatArray()); } else if (oCls.equals(DoubleArrayList.class)) { serialize(out, ((DoubleArrayList) list).toDoubleArray()); } else if (oCls.equals(ShortArrayList.class)) { serialize(out, ((ShortArrayList) list).toShortArray()); } else if (oCls.equals(ByteArrayList.class)) { serialize(out, ((ByteArrayList) list).toByteArray()); } else if (oCls.equals(LongArrayList.class)) { serialize(out, ((LongArrayList) list).toLongArray()); } else if (oCls.equals(BooleanArrayList.class)) { serialize(out, ((BooleanArrayList) list).toBooleanArray()); } else if (oCls.equals(CharArrayList.class)) { serialize(out, ((CharArrayList) list).toCharArray()); } else { serialize(out, list.size()); for (Object obj : list) { serialize(out, obj); } } }
private void serializeList(final DataOutput out, final List list) throws IOException { Class oCls = list.getClass(); if (oCls.equals(IntArrayList.class)) { serialize(out, ((IntArrayList) list).toIntArray()); } else if (oCls.equals(FloatArrayList.class)) { serialize(out, ((FloatArrayList) list).toFloatArray()); } else if (oCls.equals(DoubleArrayList.class)) { serialize(out, ((DoubleArrayList) list).toDoubleArray()); } else if (oCls.equals(ShortArrayList.class)) { serialize(out, ((ShortArrayList) list).toShortArray()); } else if (oCls.equals(ByteArrayList.class)) { serialize(out, ((ByteArrayList) list).toByteArray()); } else if (oCls.equals(LongArrayList.class)) { serialize(out, ((LongArrayList) list).toLongArray()); } else if (oCls.equals(BooleanArrayList.class)) { serialize(out, ((BooleanArrayList) list).toBooleanArray()); } else if (oCls.equals(CharArrayList.class)) { serialize(out, ((CharArrayList) list).toCharArray()); } else { serialize(out, list.size()); for (Object obj : list) { serialize(out, obj); } } }
this.numOutputsToUpdate = numOutputs.size(); return partialDots.toFloatArray();
this.numOutputsToUpdate = outputs.size(); return partialDots.toFloatArray();
@Override public FloatColumn lag(int n) { final int srcPos = n >= 0 ? 0 : 0 - n; final float[] dest = new float[size()]; final int destPos = n <= 0 ? 0 : n; final int length = n >= 0 ? size() - n : size() + n; for (int i = 0; i < size(); i++) { dest[i] = FloatColumnType.missingValueIndicator(); } float[] array = data.toFloatArray(); System.arraycopy(array, srcPos, dest, destPos, length); return new FloatColumn(name() + " lag(" + n + ")", new FloatArrayList(dest)); }
@Override public void end() { if (elementClass == boolean.class) { parent.add(((BooleanArrayList) container).toBooleanArray()); } else if (elementClass == byte.class) { parent.add(((ByteArrayList) container).toByteArray()); } else if (elementClass == char.class) { parent.add(((CharArrayList) container).toCharArray()); } else if (elementClass == short.class) { parent.add(((ShortArrayList) container).toShortArray()); } else if (elementClass == int.class) { parent.add(((IntArrayList) container).toIntArray()); } else if (elementClass == long.class) { parent.add(((LongArrayList) container).toLongArray()); } else if (elementClass == float.class) { parent.add(((FloatArrayList) container).toFloatArray()); } else if (elementClass == double.class) { parent.add(((DoubleArrayList) container).toDoubleArray()); } else { parent.add(((ArrayList) container).toArray()); } }
private void execute(){ Spectrum spec; FloatArrayList pixelsValues = new FloatArrayList(); FloatArrayList meanValues = new FloatArrayList(); for (String sourceBand : this.sourceBands) { pixelsValues.clear(); Band band = this.sourceProduct.getBand(sourceBand); for (int intIndex = 0; intIndex < this.spectrumClassReferencePixels.getXPixelPositions().size(); intIndex++) { int x = this.spectrumClassReferencePixels.getXPixelPositions().getInt(intIndex); int y = this.spectrumClassReferencePixels.getYPixelPositions().getInt(intIndex); pixelsValues.add(band.getSampleFloat(x, y)); } double sum = 0; for (float value : pixelsValues) { sum += value; } meanValues.add((float) sum / pixelsValues.size()); } spec = new Spectrum(spectrumClassReferencePixels.getClassName(), meanValues.toFloatArray(new float[meanValues.size()])); this.spectrumContainer.addElements(spec); }