|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.jagrlib.Formula
public class Formula
Mathematical support (excluding geometric stuff - see Geometry class).
Field Summary | |
---|---|
static int |
BLUE_WEIGHT
Blue importance weight. |
protected static int[] |
exp
|
static int |
FIRST_PRIMES
Number of prime numbers in smallPrimes array. |
static java.text.NumberFormat |
fmtDouble
|
static java.text.NumberFormat |
fmtInt
|
static int |
GREEN_WEIGHT
Green importance weight. |
static HashFunction |
hashFunction
Hash-function instance (accelerator). |
static java.lang.String |
LINE_SEPARATOR
Line separator string. |
static byte[] |
LINE_SEPARATOR_BYTES
Line separator as byte array. |
protected static int[] |
primes
Prime numbers - approximately geometric sequence. |
protected static int |
PRIMES_MAX
|
static int |
RED_WEIGHT
Red importance weight. |
static int[] |
smallPrimes
First prime numbers for hashing steps. |
static double |
WEIGHT_INVERSE
Importance weight total inverse. |
static int |
WEIGHT_SHIFT
Importance weight shift. |
static int |
WEIGHT_TOTAL
Importance weight total. |
Constructor Summary | |
---|---|
Formula()
|
Method Summary | |
---|---|
static int |
argMax(double[] array)
Return index of array item with maximum absolute value. |
static int |
bits(long n)
Computes number of bits to represent the given number of possibilities (log_2{n} rounded up). |
static double |
clamp(double source,
double min,
double max)
Clamps the source value to the given range. |
static float |
clamp(float source,
float min,
float max)
Clamps the source value to the given range. |
static int |
clamp(int source,
int min,
int max)
Clamps the source value to the given range. |
static long |
clamp(long source,
long min,
long max)
Clamps the source value to the given range. |
static double[] |
cloneArray(double[] arr)
Clone the given array of doubles. |
static float[] |
cloneArray(float[] arr)
Clone the given array of floats. |
static int[] |
cloneArray(int[] arr)
Clone the given array of integers. |
static double[] |
colorRamp(double x,
double[] color)
Computes double[3] color from the visualization color-ramp. |
static float[] |
colorRamp(double x,
float[] color)
Computes float[3] color from the visualization color-ramp. |
static int[] |
colorRamp(double x,
int[] color)
Computes color from the visualization color-ramp. |
static java.lang.String |
colorToString(java.awt.Color c)
Returns String representation of the given Color . |
static double |
diagonal(double x,
double y,
double z)
Computes diagonal of the rectangle block. |
static int |
findPrime(int from)
Returns prime number from the predefined sequence. |
static double |
frexp(double x,
int[] exp)
Function for C[++] compatibility: computes normalized mantissa ( 0.5 to 1.0 ) and binary exponent
from the given floating-point number. |
static float |
frexp(float x,
int[] exp)
Function for C[++] compatibility: computes normalized mantissa ( 0.5 to 1.0 ) and binary exponent
from the given floating-point number. |
static int |
gcd(int u,
int v)
Computes greates common divisor of two unsigned integers. |
static int |
getSmallPrime(int key)
Returns small prime number based on the given key (hash). |
static int |
granularity(int value,
int granul)
Returns the given value rounded up to the given granularity. |
static int |
hashClassName(java.lang.Object object)
Returns hash-number computed from class name of the given instance. |
static double[] |
hsvToRgb(double h,
double s,
double v,
double[] rgb)
HSV (HSB) to RGB conversion. |
static org.nfunk.jep.JEP |
initExpression(java.lang.String expr)
Initializes expression to be repeatedly evaluated. |
static boolean |
isIntFormat(java.lang.String fmt)
Checks format string for numeric type class (integer / floating-point). |
static double |
ldexp(double mant,
int exp)
Function for C[++] compatibility: composes floating-point number from the mantissa and binary exponent. |
static float |
ldexp(float mant,
int exp)
Function for C[++] compatibility: composes floating-point number from the mantissa and binary exponent. |
static float |
loadFloat(byte[] array,
int index)
Reads a float-number from byte-array (used in serialization, PersistentParamsBinary , ..). |
static int |
loadUnsigned16(byte[] array,
int index)
Reads a 16-bit unsigned integer from byte-array (used in serialization, PersistentParamsBinary , ..). |
static java.awt.Color |
parseColor(java.lang.String s)
Parse textual color representation. |
static double[] |
parseColorDouble(java.lang.String s)
Parse textual color representation (components are from range [ 0.0, 1.0 ] ). |
static java.lang.String[] |
parseStringList(java.lang.String str)
Parse sequence of (comma, semicolon)-separated quoted strings. |
static int |
percent(long part,
long total)
Returns integer percent value. |
static long |
permutationsWithRepetition(int[] freq)
freq[] array can contain zeroes.. |
static double |
power(double a,
int e)
Computes double-precision number powered to integer exponent. |
static java.lang.String |
relativePath(java.lang.String path)
Returns path relative to current directory. |
static double |
remainder(double a,
double b)
Computes floating-point remainder which is periodic and positive unlike the Math.IEEEremainder(double, double) . |
static void |
RGBeToRGB(byte[] rgbe,
int startRgbe,
double[] rgb,
int startRgb)
Conversion from Radiance's RGBe 32-bit format into HDR floating-point RGB format. |
static double |
rgbToGray(double r,
double g,
double b)
RGB -> gray value convertor. |
static int |
rgbToGray(int r,
int g,
int b)
RGB -> gray value convertor. |
static double[] |
rgbToHsv(double r,
double g,
double b,
double[] hsv)
RGB to HSV (HSB) conversion. |
static void |
RGBToRGBe(byte[] rgbe,
int startRgbe,
double R,
double G,
double B)
Conversion from HDR floating-point RGB format to Radiance's RGBe 32-bit format. |
static int |
round(double a)
Rounds double number to the nearest integer. |
static int |
storeFloat(byte[] array,
int index,
float f)
Converts a float number into four bytes (used in serialization, PersistentParamsBinary , ..). |
static int |
storeUnsigned16(byte[] array,
int index,
int s)
Converts a 16-bit unsigned integer into two bytes (used in serialization, PersistentParamsBinary , ..). |
static java.lang.String |
stringValue(java.lang.Object value)
Converts arbitrary object instance to String representation (for persistance). |
static long |
swapBytes(long a,
int bits)
Swaps the given number (containing multiple of 8 bits). |
static java.lang.String |
timeHMS(double time)
Converts number of seconds to readable (HH:MM:SS) format. |
static double |
toMega(long n)
Converts integer number into binary million (Mega) units. |
static java.lang.String |
vectorToString(double[] v)
Converts double[] vector to readable form. |
static java.lang.String |
vectorToString(int[] v)
Converts int[] vector to readable form. |
static long |
vlc(int a)
Returns Variable-length code for the given integer number. |
static int |
vlcInv(long code)
Returns original signed number from its Variable-length code. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String LINE_SEPARATOR
public static final byte[] LINE_SEPARATOR_BYTES
public static final java.text.NumberFormat fmtInt
public static final java.text.NumberFormat fmtDouble
public static final int RED_WEIGHT
public static final int GREEN_WEIGHT
public static final int BLUE_WEIGHT
public static final int WEIGHT_SHIFT
public static final int WEIGHT_TOTAL
public static final double WEIGHT_INVERSE
protected static int[] exp
protected static final int[] primes
protected static final int PRIMES_MAX
public static final int[] smallPrimes
public static final int FIRST_PRIMES
smallPrimes
array.
Has to be power of two!
public static HashFunction hashFunction
Constructor Detail |
---|
public Formula()
Method Detail |
---|
public static final double power(double a, int e)
a
- Base.e
- Exponent (all integer values are handled correctly).
a
to the power of e
.public static final double diagonal(double x, double y, double z)
public static final double remainder(double a, double b)
Math.IEEEremainder(double, double)
.
public static final int gcd(int u, int v)
public static final int bits(long n)
public static final int clamp(int source, int min, int max)
public static final long clamp(long source, long min, long max)
public static final float clamp(float source, float min, float max)
public static final double clamp(double source, double min, double max)
public static final int argMax(double[] array)
public static final int round(double a)
For double -> long
rounding, use Math.round(double)
,
for float -> int
rounding, use Math.round(float)
.
public static final long vlc(int a)
0
.. 0, 1
.. 1, -1
.. 2,
2
.. 3, -2
.. 4, etc.
public static final int vlcInv(long code)
0
.. 0, 1
.. 1, 2
.. -1,
3
.. 2, 4
.. -2, etc.
public static final int percent(long part, long total)
public static final int granularity(int value, int granul)
public static final double ldexp(double mant, int exp)
frexp(double,int[])
public static final float ldexp(float mant, int exp)
frexp(float,int[])
public static final double frexp(double x, int[] exp)
0.5
to 1.0
) and binary exponent
from the given floating-point number.
ldexp(double,int)
public static final float frexp(float x, int[] exp)
0.5
to 1.0
) and binary exponent
from the given floating-point number.
ldexp(float,int)
public static final int storeUnsigned16(byte[] array, int index, int s)
PersistentParamsBinary
, ..).
array
- Target of the conversion.index
- Start index.s
- Number to convert.
loadUnsigned16(byte[], int)
public static final int loadUnsigned16(byte[] array, int index)
PersistentParamsBinary
, ..).
array
- Source array.index
- Start index.
storeUnsigned16(byte[], int, int)
public static final int storeFloat(byte[] array, int index, float f)
PersistentParamsBinary
, ..).
array
- Target of the conversion.index
- Start index.f
- Floating number to convert.
loadFloat(byte[], int)
public static final float loadFloat(byte[] array, int index)
PersistentParamsBinary
, ..).
array
- Source array.index
- Start index.
storeFloat(byte[], int, float)
public static final double toMega(long n)
public static long permutationsWithRepetition(int[] freq)
public static long swapBytes(long a, int bits)
public static org.nfunk.jep.JEP initExpression(java.lang.String expr)
expr
- String representation of the expression.
JEP.addVariable(String,double)
,
JEP.getValue()
public static java.lang.String[] parseStringList(java.lang.String str)
public static boolean isIntFormat(java.lang.String fmt)
String.format()
-like sequence and
returns whether it needs integer numeric value.
public static java.lang.String timeHMS(double time)
public static final int rgbToGray(int r, int g, int b)
public static final double rgbToGray(double r, double g, double b)
public static final java.lang.String colorToString(java.awt.Color c)
Color
.
parseColor(java.lang.String)
public static final java.awt.Color parseColor(java.lang.String s)
s
- Input string in "[Red;Green;Blue]" format.
public static final double[] parseColorDouble(java.lang.String s)
[ 0.0, 1.0 ]
).
Input format: "[Red;Green;Blue]"
s
- Input string in "[Red;Green;Blue]" format.
public static final int[] colorRamp(double x, int[] color)
x
- Ramp position from 0.0
to 1.0
.color
- Pre-allocated array to hold result.
public static final double[] colorRamp(double x, double[] color)
double[3]
color from the visualization color-ramp.
x
- Ramp position from 0.0
to 1.0
.color
- Pre-allocated array to hold result.
public static final float[] colorRamp(double x, float[] color)
float[3]
color from the visualization color-ramp.
x
- Ramp position from 0.0f
to 1.0f
.color
- Pre-allocated array to hold result.
public static final void RGBeToRGB(byte[] rgbe, int startRgbe, double[] rgb, int startRgb)
public static final void RGBToRGBe(byte[] rgbe, int startRgbe, double R, double G, double B)
public static final double[] rgbToHsv(double r, double g, double b, double[] hsv)
0.0 <= H < 360.0
, 0.0 <= S <= 1.0
, V has the same
magnitude as RGB.
public static final double[] hsvToRgb(double h, double s, double v, double[] rgb)
0.0 <= H < 360.0
, 0.0 <= S <= 1.0
, V has the same
magnitude as RGB result.
public static final int findPrime(int from)
from
- Lower bound (inclusive) for the prime.
from
.public static final int getSmallPrime(int key)
public static final float[] cloneArray(float[] arr)
public static final double[] cloneArray(double[] arr)
public static final int[] cloneArray(int[] arr)
public static final java.lang.String vectorToString(int[] v)
int[]
vector to readable form.
public static final java.lang.String vectorToString(double[] v)
double[]
vector to readable form.
public static final int hashClassName(java.lang.Object object)
public static java.lang.String relativePath(java.lang.String path)
public static final java.lang.String stringValue(java.lang.Object value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |