Package com.dkt.graphics.utils
Class MathUtils
java.lang.Object
com.dkt.graphics.utils.MathUtils
- Author:
- Federico Vera <[email protected]>
-
Method Summary
Modifier and TypeMethodDescriptionstatic intabs(int n) Computes the absolute value of a number without branching
The original code can be found in: ...static doubleboxcar(double t, double a, double b) Boxcar functionstatic doublehs(double t) This class is the Heaviside step function omitting the value of1/2fort = 0static intmax(int a, int b) Provides an unbranched version of max for POSITIVE ints, it does 7 operation instead of branching (which is somewhat slower, but it's mainly here for educational purposes)
The original code can be found in: ...static intmin(int a, int b) Provides an unbranched version of min for POSITIVE ints, it does 7 operations instead of branching (which is somewhat slower, but it's mainly here for educational purposes)
The original code can be found in: ...static doublerect(double t) Rectangular function
-
Method Details
-
hs
public static double hs(double t) This class is the Heaviside step function omitting the value of1/2fort = 0- Parameters:
t- parameter- Returns:
0ift < 0and1otherwise
-
rect
public static double rect(double t) Rectangular function- Parameters:
t- parameter- Returns:
1if-0.5 <= t <= 0.5and0otherwise- See Also:
-
boxcar
public static double boxcar(double t, double a, double b) Boxcar function- Parameters:
t- parametera- the left boundb- the right bound- Returns:
1ifa <= t <= band0otherwise
-
min
public static int min(int a, int b) Provides an unbranched version of min for POSITIVE ints, it does 7 operations instead of branching (which is somewhat slower, but it's mainly here for educational purposes)
The original code can be found in: ...- Parameters:
a- first value to compareb- second value to compare- Returns:
- the smallest number
-
max
public static int max(int a, int b) Provides an unbranched version of max for POSITIVE ints, it does 7 operation instead of branching (which is somewhat slower, but it's mainly here for educational purposes)
The original code can be found in: ...- Parameters:
a- first value to compareb- second value to compare- Returns:
- the biggest number
-
abs
public static int abs(int n) Computes the absolute value of a number without branching
The original code can be found in: ...- Parameters:
n- number- Returns:
- the absolute value of this number
-