Java Code Examples for cern.colt.list.DoubleArrayList#add()
The following examples show how to use
cern.colt.list.DoubleArrayList#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoubleMatrix3D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** Fills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values. <p> In general, fill order is <i>unspecified</i>. This implementation fill like: <tt>for (slice = 0..slices-1) for (row = 0..rows-1) for (column = 0..colums-1) do ... </tt>. However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell). For an example, see {@link DoubleMatrix2D#getNonZeros(IntArrayList,IntArrayList,DoubleArrayList)}. @param sliceList the list to be filled with slice indexes, can have any size. @param rowList the list to be filled with row indexes, can have any size. @param columnList the list to be filled with column indexes, can have any size. @param valueList the list to be filled with values, can have any size. */ public void getNonZeros(IntArrayList sliceList, IntArrayList rowList, IntArrayList columnList, DoubleArrayList valueList) { sliceList.clear(); rowList.clear(); columnList.clear(); valueList.clear(); int s = slices; int r = rows; int c = columns; for (int slice=0; slice < s; slice++) { for (int row=0; row < r; row++) { for (int column=0; column < c; column++) { double value = getQuick(slice,row,column); if (value != 0) { sliceList.add(slice); rowList.add(row); columnList.add(column); valueList.add(value); } } } } }
Example 2
Source File: DoubleMatrix3D.java From database with GNU General Public License v2.0 | 6 votes |
/** Fills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values. <p> In general, fill order is <i>unspecified</i>. This implementation fill like: <tt>for (slice = 0..slices-1) for (row = 0..rows-1) for (column = 0..colums-1) do ... </tt>. However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell). For an example, see {@link DoubleMatrix2D#getNonZeros(IntArrayList,IntArrayList,DoubleArrayList)}. @param sliceList the list to be filled with slice indexes, can have any size. @param rowList the list to be filled with row indexes, can have any size. @param columnList the list to be filled with column indexes, can have any size. @param valueList the list to be filled with values, can have any size. */ public void getNonZeros(IntArrayList sliceList, IntArrayList rowList, IntArrayList columnList, DoubleArrayList valueList) { sliceList.clear(); rowList.clear(); columnList.clear(); valueList.clear(); int s = slices; int r = rows; int c = columns; for (int slice=0; slice < s; slice++) { for (int row=0; row < r; row++) { for (int column=0; column < c; column++) { double value = getQuick(slice,row,column); if (value != 0) { sliceList.add(slice); rowList.add(row); columnList.add(column); valueList.add(value); } } } } }
Example 3
Source File: QuantileFinderTest.java From database with GNU General Public License v2.0 | 5 votes |
/** * This method was created in VisualAge. * @return double[] * @param values cern.it.hepodbms.primitivearray.DoubleArrayList * @param phis double[] */ public static DoubleArrayList observedEpsilonsAtPhis(DoubleArrayList phis, ExactDoubleQuantileFinder exactFinder, DoubleQuantileFinder approxFinder, double desiredEpsilon) { DoubleArrayList epsilons = new DoubleArrayList(phis.size()); for (int i=phis.size(); --i >=0;) { double epsilon = observedEpsilonAtPhi(phis.get(i), exactFinder, approxFinder); epsilons.add(epsilon); if (epsilon>desiredEpsilon) System.out.println("Real epsilon = "+epsilon+" is larger than desired by "+(epsilon-desiredEpsilon)); } return epsilons; }
Example 4
Source File: DistributionAggregateFunction.java From arx with Apache License 2.0 | 5 votes |
@Override public <T> double getError(Distribution distribution) { if (!(type instanceof DataTypeWithRatioScale)) { return 0d; } @SuppressWarnings("unchecked") DataTypeWithRatioScale<T> rType = (DataTypeWithRatioScale<T>) this.type; DoubleArrayList list = new DoubleArrayList(); Iterator<Double> it = DistributionIterator.createIteratorDouble(distribution, dictionary, rType); while (it.hasNext()) { Double value = it.next(); value = value == null ? (ignoreMissingData ? null : 0d) : value; if (value != null) { list.add(value); } } // Determine and check mode int mode = getMode(distribution); if (mode == -1) { return 1d; } // Compute error return getNMSE(minimum, maximum, Arrays.copyOf(list.elements(), list.size()), rType.toDouble(rType.parse(dictionary[mode]))); }
Example 5
Source File: DistributionAggregateFunction.java From arx with Apache License 2.0 | 5 votes |
@Override public <T> double getError(Distribution distribution) { if (!(type instanceof DataTypeWithRatioScale)) { return 0d; } @SuppressWarnings("unchecked") DataTypeWithRatioScale<T> rType = (DataTypeWithRatioScale<T>) this.type; DoubleArrayList list = new DoubleArrayList(); Iterator<Double> it = DistributionIterator.createIteratorDouble(distribution, dictionary, rType); while (it.hasNext()) { Double value = it.next(); value = value == null ? (ignoreMissingData ? null : 0d) : value; if (value != null) { list.add(value); } } // Determine and check mode String mean = aggregate(distribution); if (mean == DataType.NULL_VALUE) { return 1d; } // Compute error return getNMSE(minimum, maximum, Arrays.copyOf(list.elements(), list.size()), rType.toDouble(rType.parse(mean))); }
Example 6
Source File: QuantileBin1D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 5 votes |
/** Divides (rebins) a copy of the receiver at the given <i>interval boundaries</i> into bins and returns these bins, such that each bin <i>approximately</i> reflects the data elements of its range. For each interval boundary of the axis (including -infinity and +infinity), computes the percentage (quantile inverse) of elements less than the boundary. Then lets {@link #splitApproximately(DoubleArrayList,int)} do the real work. @param axis an axis defining interval boundaries. @param resolution a measure of accuracy; the desired number of subintervals per interval. */ public synchronized MightyStaticBin1D[] splitApproximately(hep.aida.IAxis axis, int k) { DoubleArrayList percentages = new DoubleArrayList(new hep.aida.ref.Converter().edges(axis)); percentages.beforeInsert(0,Double.NEGATIVE_INFINITY); percentages.add(Double.POSITIVE_INFINITY); for (int i=percentages.size(); --i >= 0; ) { percentages.set(i, quantileInverse(percentages.get(i))); } return splitApproximately(percentages,k); }
Example 7
Source File: MightyStaticBin1D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns the moment of <tt>k</tt>-th order with value <tt>c</tt>, * which is <tt>Sum( (x[i]-c)<sup>k</sup> ) / size()</tt>. * * @param k the order; must be greater than or equal to zero. * @param c any number. * @throws IllegalArgumentException if <tt>k < 0</tt>. * @return <tt>Double.NaN</tt> if <tt>!hasSumOfPower(k)</tt>. */ public synchronized double moment(int k, double c) { if (k<0) throw new IllegalArgumentException("k must be >= 0"); //checkOrder(k); if (!hasSumOfPowers(k)) return Double.NaN; int maxOrder = Math.min(k,getMaxOrderForSumOfPowers()); DoubleArrayList sumOfPows = new DoubleArrayList(maxOrder+1); sumOfPows.add(size()); sumOfPows.add(sum()); sumOfPows.add(sumOfSquares()); for (int i=3; i<=maxOrder; i++) sumOfPows.add(sumOfPowers(i)); return Descriptive.moment(k, c, size(), sumOfPows.elements()); }
Example 8
Source File: QuantileFinderTest.java From jAudioGIT with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method was created in VisualAge. * @return double[] * @param values cern.it.hepodbms.primitivearray.DoubleArrayList * @param phis double[] */ public static DoubleArrayList observedEpsilonsAtPhis(DoubleArrayList phis, ExactDoubleQuantileFinder exactFinder, DoubleQuantileFinder approxFinder, double desiredEpsilon) { DoubleArrayList epsilons = new DoubleArrayList(phis.size()); for (int i=phis.size(); --i >=0;) { double epsilon = observedEpsilonAtPhi(phis.get(i), exactFinder, approxFinder); epsilons.add(epsilon); if (epsilon>desiredEpsilon) System.out.println("Real epsilon = "+epsilon+" is larger than desired by "+(epsilon-desiredEpsilon)); } return epsilons; }
Example 9
Source File: Stats2.java From gama with GNU General Public License v3.0 | 5 votes |
static DoubleArrayList from(final IScope scope, final IContainer values) { final DoubleArrayList d = new DoubleArrayList(values.length(scope)); for (final Object o : values.iterable(scope)) { if (o instanceof Number) { d.add(((Number) o).doubleValue()); } } return d; }
Example 10
Source File: KernelDensityEstimator2D.java From beast-mcmc with GNU Lesser General Public License v2.1 | 5 votes |
public double bandwidthNRD(double[] in) { DoubleArrayList inList = new DoubleArrayList(in.length); for (double d : in) inList.add(d); inList.sort(); final double h = (Descriptive.quantile(inList, 0.75) - Descriptive.quantile(inList, 0.25)) / 1.34; return 4 * 1.06 * Math.min(Math.sqrt(DiscreteStatistics.variance(in)), h) * Math.pow(in.length, -0.2); }
Example 11
Source File: DoubleMatrix2D.java From database with GNU General Public License v2.0 | 4 votes |
/** Fills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values. <p> In general, fill order is <i>unspecified</i>. This implementation fills like <tt>for (row = 0..rows-1) for (column = 0..columns-1) do ... </tt>. However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell). <p> <b>Example:</b> <br> <pre> 2 x 3 matrix: 0, 0, 8 0, 7, 0 --> rowList = (0,1) columnList = (2,1) valueList = (8,7) </pre> In other words, <tt>get(0,2)==8, get(1,1)==7</tt>. @param rowList the list to be filled with row indexes, can have any size. @param columnList the list to be filled with column indexes, can have any size. @param valueList the list to be filled with values, can have any size. */ public void getNonZeros(IntArrayList rowList, IntArrayList columnList, DoubleArrayList valueList) { rowList.clear(); columnList.clear(); valueList.clear(); int r = rows; int c = columns; for (int row=0; row < r; row++) { for (int column=0; column < c; column++) { double value = getQuick(row,column); if (value != 0) { rowList.add(row); columnList.add(column); valueList.add(value); } } } }
Example 12
Source File: DoubleMatrix1D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 4 votes |
/** Fills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values. <p> In general, fill order is <i>unspecified</i>. This implementation fills like: <tt>for (index = 0..size()-1) do ... </tt>. However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell). <p> <b>Example:</b> <br> <pre> 0, 0, 8, 0, 7 --> indexList = (2,4) valueList = (8,7) </pre> In other words, <tt>get(2)==8, get(4)==7</tt>. @param indexList the list to be filled with indexes, can have any size. @param valueList the list to be filled with values, can have any size. */ public void getNonZeros(IntArrayList indexList, DoubleArrayList valueList, int maxCardinality) { boolean fillIndexList = indexList != null; boolean fillValueList = valueList != null; int card = cardinality(maxCardinality); if (fillIndexList) indexList.setSize(card); if (fillValueList) valueList.setSize(card); if (!(card<maxCardinality)) return; if (fillIndexList) indexList.setSize(0); if (fillValueList) valueList.setSize(0); int s = size; for (int i=0; i < s; i++) { double value = getQuick(i); if (value != 0) { if (fillIndexList) indexList.add(i); if (fillValueList) valueList.add(value); } } }
Example 13
Source File: DoubleMatrix1D.java From database with GNU General Public License v2.0 | 4 votes |
/** Fills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values. <p> In general, fill order is <i>unspecified</i>. This implementation fills like: <tt>for (index = 0..size()-1) do ... </tt>. However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell). <p> <b>Example:</b> <br> <pre> 0, 0, 8, 0, 7 --> indexList = (2,4) valueList = (8,7) </pre> In other words, <tt>get(2)==8, get(4)==7</tt>. @param indexList the list to be filled with indexes, can have any size. @param valueList the list to be filled with values, can have any size. */ public void getNonZeros(IntArrayList indexList, DoubleArrayList valueList, int maxCardinality) { boolean fillIndexList = indexList != null; boolean fillValueList = valueList != null; int card = cardinality(maxCardinality); if (fillIndexList) indexList.setSize(card); if (fillValueList) valueList.setSize(card); if (!(card<maxCardinality)) return; if (fillIndexList) indexList.setSize(0); if (fillValueList) valueList.setSize(0); int s = size; for (int i=0; i < s; i++) { double value = getQuick(i); if (value != 0) { if (fillIndexList) indexList.add(i); if (fillValueList) valueList.add(value); } } }
Example 14
Source File: DoubleMatrix2D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 4 votes |
/** Fills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values. <p> In general, fill order is <i>unspecified</i>. This implementation fills like <tt>for (row = 0..rows-1) for (column = 0..columns-1) do ... </tt>. However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell). <p> <b>Example:</b> <br> <pre> 2 x 3 matrix: 0, 0, 8 0, 7, 0 --> rowList = (0,1) columnList = (2,1) valueList = (8,7) </pre> In other words, <tt>get(0,2)==8, get(1,1)==7</tt>. @param rowList the list to be filled with row indexes, can have any size. @param columnList the list to be filled with column indexes, can have any size. @param valueList the list to be filled with values, can have any size. */ public void getNonZeros(IntArrayList rowList, IntArrayList columnList, DoubleArrayList valueList) { rowList.clear(); columnList.clear(); valueList.clear(); int r = rows; int c = columns; for (int row=0; row < r; row++) { for (int column=0; column < c; column++) { double value = getQuick(row,column); if (value != 0) { rowList.add(row); columnList.add(column); valueList.add(value); } } } }
Example 15
Source File: OpenIntDoubleHashMap.java From jAudioGIT with GNU Lesser General Public License v2.1 | 3 votes |
/** Fills all pairs satisfying a given condition into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists both have a new size, the number of pairs satisfying the condition. Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}. <p> <b>Example:</b> <br> <pre> IntDoubleProcedure condition = new IntDoubleProcedure() { // match even keys only public boolean apply(int key, double value) { return key%2==0; } } keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt> </pre> @param condition the condition to be matched. Takes the current key as first and the current value as second argument. @param keyList the list to be filled with keys, can have any size. @param valueList the list to be filled with values, can have any size. */ public void pairsMatching(final IntDoubleProcedure condition, final IntArrayList keyList, final DoubleArrayList valueList) { keyList.clear(); valueList.clear(); for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL && condition.apply(table[i],values[i])) { keyList.add(table[i]); valueList.add(values[i]); } } }
Example 16
Source File: OpenDoubleIntHashMap.java From jAudioGIT with GNU Lesser General Public License v2.1 | 3 votes |
/** Fills all pairs satisfying a given condition into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists both have a new size, the number of pairs satisfying the condition. Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(DoubleProcedure)}. <p> <b>Example:</b> <br> <pre> DoubleIntProcedure condition = new DoubleIntProcedure() { // match even values only public boolean apply(double key, int value) { return value%2==0; } } keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt> </pre> @param condition the condition to be matched. Takes the current key as first and the current value as second argument. @param keyList the list to be filled with keys, can have any size. @param valueList the list to be filled with values, can have any size. */ public void pairsMatching(final DoubleIntProcedure condition, final DoubleArrayList keyList, final IntArrayList valueList) { keyList.clear(); valueList.clear(); for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL && condition.apply(table[i],values[i])) { keyList.add(table[i]); valueList.add(values[i]); } } }
Example 17
Source File: DoubleMatrix1D.java From jAudioGIT with GNU Lesser General Public License v2.1 | 3 votes |
/** Fills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values. <p> In general, fill order is <i>unspecified</i>. This implementation fills like: <tt>for (index = 0..size()-1) do ... </tt>. However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell). <p> <b>Example:</b> <br> <pre> 0, 0, 8, 0, 7 --> indexList = (2,4) valueList = (8,7) </pre> In other words, <tt>get(2)==8, get(4)==7</tt>. @param indexList the list to be filled with indexes, can have any size. @param valueList the list to be filled with values, can have any size. */ public void getNonZeros(IntArrayList indexList, DoubleArrayList valueList) { boolean fillIndexList = indexList != null; boolean fillValueList = valueList != null; if (fillIndexList) indexList.clear(); if (fillValueList) valueList.clear(); int s = size; for (int i=0; i < s; i++) { double value = getQuick(i); if (value != 0) { if (fillIndexList) indexList.add(i); if (fillValueList) valueList.add(value); } } }
Example 18
Source File: DoubleMatrix1D.java From database with GNU General Public License v2.0 | 3 votes |
/** Fills the coordinates and values of cells having non-zero values into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists all have a new size, the number of non-zero values. <p> In general, fill order is <i>unspecified</i>. This implementation fills like: <tt>for (index = 0..size()-1) do ... </tt>. However, subclasses are free to us any other order, even an order that may change over time as cell values are changed. (Of course, result lists indexes are guaranteed to correspond to the same cell). <p> <b>Example:</b> <br> <pre> 0, 0, 8, 0, 7 --> indexList = (2,4) valueList = (8,7) </pre> In other words, <tt>get(2)==8, get(4)==7</tt>. @param indexList the list to be filled with indexes, can have any size. @param valueList the list to be filled with values, can have any size. */ public void getNonZeros(IntArrayList indexList, DoubleArrayList valueList) { boolean fillIndexList = indexList != null; boolean fillValueList = valueList != null; if (fillIndexList) indexList.clear(); if (fillValueList) valueList.clear(); int s = size; for (int i=0; i < s; i++) { double value = getQuick(i); if (value != 0) { if (fillIndexList) indexList.add(i); if (fillValueList) valueList.add(value); } } }
Example 19
Source File: OpenDoubleIntHashMap.java From database with GNU General Public License v2.0 | 3 votes |
/** Fills all pairs satisfying a given condition into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists both have a new size, the number of pairs satisfying the condition. Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(DoubleProcedure)}. <p> <b>Example:</b> <br> <pre> DoubleIntProcedure condition = new DoubleIntProcedure() { // match even values only public boolean apply(double key, int value) { return value%2==0; } } keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt> </pre> @param condition the condition to be matched. Takes the current key as first and the current value as second argument. @param keyList the list to be filled with keys, can have any size. @param valueList the list to be filled with values, can have any size. */ public void pairsMatching(final DoubleIntProcedure condition, final DoubleArrayList keyList, final IntArrayList valueList) { keyList.clear(); valueList.clear(); for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL && condition.apply(table[i],values[i])) { keyList.add(table[i]); valueList.add(values[i]); } } }
Example 20
Source File: OpenIntDoubleHashMap.java From database with GNU General Public License v2.0 | 3 votes |
/** Fills all pairs satisfying a given condition into the specified lists. Fills into the lists, starting at index 0. After this call returns the specified lists both have a new size, the number of pairs satisfying the condition. Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}. <p> <b>Example:</b> <br> <pre> IntDoubleProcedure condition = new IntDoubleProcedure() { // match even keys only public boolean apply(int key, double value) { return key%2==0; } } keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt> </pre> @param condition the condition to be matched. Takes the current key as first and the current value as second argument. @param keyList the list to be filled with keys, can have any size. @param valueList the list to be filled with values, can have any size. */ public void pairsMatching(final IntDoubleProcedure condition, final IntArrayList keyList, final DoubleArrayList valueList) { keyList.clear(); valueList.clear(); for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL && condition.apply(table[i],values[i])) { keyList.add(table[i]); valueList.add(values[i]); } } }