All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hep.aida.tdouble.bin.AbstractDoubleBin Maven / Gradle / Ivy

Go to download

Parallel Colt is a multithreaded version of Colt - a library for high performance scientific computing in Java. It contains efficient algorithms for data analysis, linear algebra, multi-dimensional arrays, Fourier transforms, statistics and histogramming.

The newest version!
package hep.aida.tdouble.bin;

/**
 * Abstract base class for all arbitrary-dimensional bins consumes
 * double elements. First see the package summary and javadoc tree view to get the broad picture.
 * 

* This class is fully thread safe (all public methods are synchronized). Thus, * you can have one or more threads adding to the bin as well as one or more * threads reading and viewing the statistics of the bin while it is * filled. For high performance, add data in large chunks (buffers) via * method addAllOf rather than piecewise via method add. * * @author [email protected] * @version 0.9, 03-Jul-99 */ public abstract class AbstractDoubleBin extends cern.colt.PersistentObject { /** * */ private static final long serialVersionUID = 1L; /** * Makes this class non instantiable, but still let's others inherit from * it. */ protected AbstractDoubleBin() { } /** * Returns center(0). */ public final double center() { return center(0); } /** * Returns a custom definable "center" measure; override this method if * necessary. Returns the absolute or relative center of this bin. For * example, the center of gravity. * * The real absolute center can be obtained as follow: * partition(i).min(j) * bin(j).offset() + bin(j).center(i), where * i is the dimension. and j is the index of this bin. * *

* This default implementation always returns 0.5. * * @param dimension * the dimension to be considered (zero based). */ public synchronized double center(int dimension) { return 0.5; } /** * Removes all elements from the receiver. The receiver will be empty after * this call returns. */ public abstract void clear(); /** * Returns whether two objects are equal; This default implementation * returns true if the other object is a bin and has the same size, value, * error and center. */ public boolean equals(Object otherObj) { if (!(otherObj instanceof AbstractDoubleBin)) return false; AbstractDoubleBin other = (AbstractDoubleBin) otherObj; return size() == other.size() && value() == other.value() && error() == other.error() && center() == other.center(); } /** * Returns error(0). */ public final double error() { return error(0); } /** * Returns a custom definable error measure; override this method if * necessary. This default implementation always returns 0. * * @param dimension * the dimension to be considered. */ public synchronized double error(int dimension) { return 0; } /** * Returns whether a client can obtain all elements added to the receiver. * In other words, tells whether the receiver internally preserves all added * elements. If the receiver is rebinnable, the elements can be obtained via * elements() methods. */ public abstract boolean isRebinnable(); /** * Returns offset(0). */ public final double offset() { return offset(0); } /** * Returns the relative or absolute position for the center of the bin; * override this method if necessary. Returns 1.0 if a relative center is * stored in the bin. Returns 0.0 if an absolute center is stored in the * bin. * *

* This default implementation always returns 1.0 (relative). * * @param dimension * the index of the considered dimension (zero based); */ public double offset(int dimension) { return 1.0; } /** * Returns the number of elements contained. * * @return the number of elements contained. */ public abstract int size(); /** * Returns a String representation of the receiver. */ public synchronized String toString() { StringBuffer buf = new StringBuffer(); buf.append(getClass().getName()); buf.append("\n-------------"); /* * buf.append("\nValue: "+value()); buf.append("\nError: "+error()); * buf.append("\nRMS: "+rms()+"\n"); */ buf.append("\n"); return buf.toString(); } /** * Trims the capacity of the receiver to be the receiver's current size. * Releases any superfluos internal memory. An application can use this * operation to minimize the storage of the receiver. * * This default implementation does nothing. */ public synchronized void trimToSize() { } /** * Returns value(0). */ public final double value() { return value(0); } /** * Returns a custom definable "value" measure; override this method if * necessary. *

* This default implementation always returns 0.0. * * @param dimension * the dimension to be considered. */ public double value(int dimension) { return 0; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy