public static DoubleColumn create(final String name, final float[] arr) { final double[] doubles = new double[arr.length]; for (int i = 0; i < arr.length; i++) { doubles[i] = arr[i]; } return new DoubleColumn(name, new DoubleArrayList(doubles)); }
public static DoubleColumn create(final String name, final int[] arr) { final double[] doubles = new double[arr.length]; for (int i = 0; i < arr.length; i++) { doubles[i] = arr[i]; } return new DoubleColumn(name, new DoubleArrayList(doubles)); }
public static DoubleColumn create(final String name, final long[] arr) { final double[] doubles = new double[arr.length]; for (int i = 0; i < arr.length; i++) { doubles[i] = arr[i]; } return new DoubleColumn(name, new DoubleArrayList(doubles)); }
public static DoubleColumn create(final String name, final Number[] numbers) { final double[] doubles = new double[numbers.length]; for (int i = 0; i < numbers.length; i++) { doubles[i] = numbers[i].doubleValue(); } return new DoubleColumn(name, new DoubleArrayList(doubles)); }
public static DoubleColumn create(final String name, final double[] arr) { return new DoubleColumn(name, new DoubleArrayList(arr)); }
public static DoubleColumn create(final String name, final List<Number> numberList) { final double[] doubles = new double[numberList.size()]; for (int i = 0; i < numberList.size(); i++) { doubles[i] = numberList.get(i).doubleValue(); } return new DoubleColumn(name, new DoubleArrayList(doubles)); }
@Override public DoubleArrayList deserialize(ByteBuffer byteBuffer) { int numValues = byteBuffer.getInt(); DoubleArrayList doubleArrayList = new DoubleArrayList(numValues); for (int i = 0; i < numValues; i++) { doubleArrayList.add(byteBuffer.getDouble()); } return doubleArrayList; } };
@Nonnull @Override public DoubleArrayList extractGroupByResult(@Nonnull GroupByResultHolder groupByResultHolder, int groupKey) { DoubleArrayList doubleArrayList = groupByResultHolder.getResult(groupKey); if (doubleArrayList == null) { return new DoubleArrayList(); } else { return doubleArrayList; } }
@Nonnull @Override public DoubleArrayList extractAggregationResult(@Nonnull AggregationResultHolder aggregationResultHolder) { DoubleArrayList doubleArrayList = aggregationResultHolder.getResult(); if (doubleArrayList == null) { return new DoubleArrayList(); } else { return doubleArrayList; } }
/** * Constructor for the class. * * @param initialCapacity Initial capacity for the priority queue * @param minHeap Min order, ie smallest element on top. */ public IntDoubleIndexedPriorityQueue(int initialCapacity, boolean minHeap) { super(initialCapacity, minHeap); _values = new DoubleArrayList(initialCapacity); _reusablePair = new IntDoublePair(0, 0.0); }
protected DoubleColumn(final String name) { super(DoubleColumnType.instance(), name); this.data = new DoubleArrayList(DEFAULT_ARRAY_SIZE); }
/** * Returns the value list from the result holder or creates a new one if it does not exist. * * @param aggregationResultHolder Result holder * @return Value list from the result holder */ protected static DoubleArrayList getValueList(@Nonnull AggregationResultHolder aggregationResultHolder) { DoubleArrayList valueList = aggregationResultHolder.getResult(); if (valueList == null) { valueList = new DoubleArrayList(); aggregationResultHolder.setValue(valueList); } return valueList; }
public DoubleToIdMap() { _valueToIdMap = new Double2IntOpenHashMap(); _valueToIdMap.defaultReturnValue(INVALID_KEY); _idToValueMap = new DoubleArrayList(); }
/** * Returns the value list for the given group key. If one does not exist, creates a new one and returns that. * * @param groupByResultHolder Result holder * @param groupKey Group key for which to return the value list * @return Value list for the group key */ protected static DoubleArrayList getValueList(@Nonnull GroupByResultHolder groupByResultHolder, int groupKey) { DoubleArrayList valueList = groupByResultHolder.getResult(groupKey); if (valueList == null) { valueList = new DoubleArrayList(); groupByResultHolder.setValueForKey(groupKey, valueList); } return valueList; } }
@Override public DoubleColumn lag(int n) { final int srcPos = n >= 0 ? 0 : 0 - n; final double[] dest = new double[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(); } double[] array = data.toDoubleArray(); System.arraycopy(array, srcPos, dest, destPos, length); return new DoubleColumn(name() + " lag(" + n + ")", new DoubleArrayList(dest)); }
private static double[] filterDoubles(DoubleSet doubleSet, double[] source) { DoubleList doubleList = new DoubleArrayList(); for (double value : source) { if (doubleSet.contains(value)) { doubleList.add(value); } } if (doubleList.size() == source.length) { return source; } else { return doubleList.toDoubleArray(); } }
@Test public void testDoubleArrayList() { for (int i = 0; i < NUM_ITERATIONS; i++) { int size = RANDOM.nextInt(100); DoubleArrayList expected = new DoubleArrayList(size); for (int j = 0; j < size; j++) { expected.add(RANDOM.nextDouble()); } byte[] bytes = ObjectSerDeUtils.serialize(expected); DoubleArrayList actual = ObjectSerDeUtils.deserialize(bytes, ObjectSerDeUtils.ObjectType.DoubleArrayList); assertEquals(actual, expected, ERROR_MESSAGE); } }
@Override public DoubleColumn bottom(final int n) { DoubleArrayList bottom = new DoubleArrayList(); double[] values = data.toDoubleArray(); DoubleArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new DoubleColumn(name() + "[Bottoms " + n + "]", bottom); }
@Override public DoubleColumn top(int n) { DoubleArrayList top = new DoubleArrayList(); double[] values = data.toDoubleArray(); DoubleArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new DoubleColumn(name() + "[Top " + n + "]", top); }
public RowSequentialAccessSparseMatrix(int rows, int columns, DataFrame df, DataFrameIndex rowDataFrameIndex, int itemColumn, int valueColumn) { super(rows, columns); rowVectors = new VectorBasedSequentialSparseVector[rows]; for (int rowIndex = 0; rowIndex < rows; rowIndex++) { IntArrayList positions = rowDataFrameIndex.getIndices(rowIndex); IntArrayList indices = new IntArrayList(positions.size()); DoubleArrayList doubleValues = new DoubleArrayList(positions.size()); for (int position : positions) { indices.add((int) df.get(itemColumn,position)); doubleValues.add((double) df.get(valueColumn,position)); } rowVectors[rowIndex] = new VectorBasedSequentialSparseVector( columns, indices, doubleValues); } }