@Override public Object getField(Class forClass, Class type, boolean inherited) { ClassInitializer.initialize(forClass); return getField2(forClass, type, inherited); } private Object getField2(Class forClass, Class type, boolean inherited) {
/** * Returns the closest <code>int</code> to the specified argument. * * @param f the <code>float</code> value to be rounded to a <code>int</code> * @return the nearest <code>int</code> value. **/ public static int round(float f) { return (int) floor(f + 0.5f); } /**/
/** * Returns the natural logarithm (base <i>{@link #E e}</i>) of the specified * value. * * @param x the value greater than <code>0.0</code>. * @return the value y such as <code><i>e</i><sup>y</sup> == x</code> **/ public static double log(double x) { return MathLib._ieee754_log(x); } /**/
@Override public void setConcurrency(int concurrency) { // The setting of the concurrency can only reduce the number // of threads available in the context. int nbThreads = MathLib.min(parent.threads.length, concurrency); threads = new ConcurrentThreadImpl[nbThreads]; for (int i = 0; i < nbThreads; i++) { // Reused from parent threads. threads[i] = parent.threads[i]; } }
/** * Returns the decimal logarithm of the specified value. * * @param x the value greater than <code>0.0</code>. * @return the value y such as <code>10<sup>y</sup> == x</code> **/ public static double log10(double x) { return log(x) * INV_LOG10; } private static double INV_LOG10 = 0.43429448190325182765112891891661;
/** * Returns the closest integer value to this 64 bits floating point number. * * @return this number rounded to the nearest integer. */ public long round() { return MathLib.round(_value); }
/** * Returns the arc cosine of the specified value, * in the range of 0.0 through <i>pi</i>. * * @param x the value whose arc cosine is to be returned. * @return the arc cosine in radians for the specified value. **/ public static double acos(double x) { return HALF_PI - MathLib.asin(x); } /**/
/** * Returns <i>{@link #E e}</i> raised to the specified power. * * @param x the exponent. * @return <code><i>e</i><sup>x</sup></code> * @see <a href="http://mathworld.wolfram.com/ExponentialFunction.html"> * Exponential Function -- from MathWorld</a> **/ public static double exp(double x) { return MathLib._ieee754_exp(x); } /**/
/** * Returns a random number between zero and one. * * @return a <code>double</code> greater than or equal * to <code>0.0</code> and less than <code>1.0</code>. **/ public static double random() { return random(0, Integer.MAX_VALUE) * NORMALIZATION_FACTOR; } private static final double NORMALIZATION_FACTOR = -1.0 / Integer.MIN_VALUE;
/** * Sets explicitely the factory to be used for the specified class * (see {@link #getInstance}). * * @param factory the factory to use. * @param forClass the associated class. * @see #getInstance(Class) */ public static <T> void setInstance(ObjectFactory <T> factory, Class <T> forClass) { Reflection.getInstance().setField(factory, forClass, ObjectFactory.class); }
/** * Initializes all runtime and classpath classes. * * @see #initializeRuntime() * @see #initializeClassPath() */ public static void initializeAll() { initializeRuntime(); initializeClassPath(); }
@Override public int length() { if (bits.length == 0) return 0; return (bits.length << 6) - MathLib.numberOfLeadingZeros(bits[bits.length -1]); }
/** * Returns the closest <code>long</code> to the specified argument. * * @param d the <code>double</code> value to be rounded to a * <code>long</code> * @return the nearest <code>long</code> value. **/ public static long round(double d) { return (long) floor(d + 0.5d); } /**/
/** * Returns the natural logarithm (base <i>{@link #E e}</i>) of the specified * value. * * @param x the value greater than <code>0.0</code>. * @return the value y such as <code><i>e</i><sup>y</sup> == x</code> **/ public static double log(double x) { return MathLib._ieee754_log(x); }
/** * Returns a pseudo random <code>float</code> value in the range * <code>[min, max]</code> (fast and thread-safe without synchronization). * * @param min the minimum value inclusive. * @param max the maximum value inclusive. * @return a pseudo random number in the range <code>[min, max]</code>. */ public static float random(float min, float max) { return (float) random((double) min, (double) max); }
/** * Returns the closest <code>long</code> to the specified argument. * * @param d the <code>double</code> value to be rounded to a * <code>long</code> * @return the nearest <code>long</code> value. **/ public static long round(double d) { return (long) floor(d + 0.5d); }