Package ffx.numerics.math
Class FloatMath
java.lang.Object
ffx.numerics.math.FloatMath
The FloatMath class is a simple math library that operates on 3-coordinate float arrays.
All methods are static and thread-safe.
Use instances of Float3 for convenience.
- Since:
- 1.0
- Author:
- Michael J. Schnieders
-
Method Summary
Modifier and TypeMethodDescriptionstatic float[]
add
(float[] a, float[] b) sumstatic float[]
add
(float[] a, float[] b, float[] ret) sumstatic float
angle
(float[] i, float[] j) anglestatic float
bondAngle
(float[] i, float[] j, float[] k) Finds the angle formed by three atomsstatic float
dihedralAngle
(float[] a, float[] b, float[] c, float[] d) Finds the dihedral angle formed between 4 atomsstatic float
dist
(float[] a, float[] b) Finds the distance between two vectors.static float
dist2
(float[] a, float[] b) Finds the squared distance between two vectors.static float
dot
(float[] a, float[] b) Finds the dot product between two vectors.static float[]
fma
(float[] a, float b, float[] c) Compute a * b + c and return the result in a new array.static float[]
fma
(float[] a, float b, float[] c, float[] ret) Compute a * b + c.static float
length
(float[] d) Finds the length of a vector.static float
length2
(float[] d) Finds the length of a vector squared.static void
log
(float[] v) logVectorstatic void
logVector.static float[]
normalize
(float[] n) Normalizes a vector.static float[]
normalize
(float[] n, float[] ret) Normalizes a vector.static float[]
scale
(float[] n, float a) Scales a vector.static float[]
scale
(float[] n, float a, float[] ret) Scales a vector.static float[]
square
(float[] n) Squares values of a vector.static float[]
square
(float[] n, float[] ret) Squares values of a vector.static float[]
squareRoot
(float[] n) Square root values of a vector.static float[]
squareRoot
(float[] n, float[] ret) Square root values of a vector.static float[]
sub
(float[] a, float[] b) Finds the difference between two vectors.static float[]
sub
(float[] a, float[] b, float[] ret) Finds the difference between two vectorsstatic String
toString
(float[] v) logVector.static String
vectorToString.static float[]
X
(float[] a, float[] b) Finds the cross-product between two vectors.static float[]
X
(float[] a, float[] b, float[] ret) Finds the cross-product between two vectors.
-
Method Details
-
fma
public static float[] fma(float[] a, float b, float[] c) Compute a * b + c and return the result in a new array.- Parameters:
a
- First vector.b
- Scalar.c
- Second vector.- Returns:
- Returns a * b + c.
-
fma
public static float[] fma(float[] a, float b, float[] c, float[] ret) Compute a * b + c.- Parameters:
a
- First vector.b
- Scalar.c
- Second vector.ret
- Result vector.- Returns:
- Returns a * b + c in the vector ret.
-
X
public static float[] X(float[] a, float[] b) Finds the cross-product between two vectors.- Parameters:
a
- First vector.b
- Second vector.- Returns:
- Returns the cross-product.
-
X
public static float[] X(float[] a, float[] b, float[] ret) Finds the cross-product between two vectors.- Parameters:
a
- First vector.b
- Second vector.ret
- The cross-product of a x b.- Returns:
- Returns the cross-product ret.
-
add
public static float[] add(float[] a, float[] b) sum- Parameters:
a
- an array of float.b
- an array of float.- Returns:
- Returns the array ret.
-
add
public static float[] add(float[] a, float[] b, float[] ret) sum- Parameters:
a
- an array of float.b
- an array of float.ret
- an array of float.- Returns:
- Returns the array ret.
-
angle
public static float angle(float[] i, float[] j) angle- Parameters:
i
- an array of float.j
- an array of float.- Returns:
- Returns the angle.
-
bondAngle
public static float bondAngle(float[] i, float[] j, float[] k) Finds the angle formed by three atoms- Parameters:
i
- Atom position vector.j
- Atom position vector (central atom).k
- Atom position vector.- Returns:
- Returns the angle in the range [ -pi, pi ].
-
dihedralAngle
public static float dihedralAngle(float[] a, float[] b, float[] c, float[] d) Finds the dihedral angle formed between 4 atoms- Parameters:
a
- Atom position vector.b
- Atom position vector.c
- Atom position vector.d
- Atom position vector.- Returns:
- The dihedral angle in the range [ -pi, pi ].
-
dist
public static float dist(float[] a, float[] b) Finds the distance between two vectors.- Parameters:
a
- First vector.b
- Second vector.- Returns:
- Returns the distance between vectors a and b.
-
dist2
public static float dist2(float[] a, float[] b) Finds the squared distance between two vectors.- Parameters:
a
- First vector.b
- Second vector.- Returns:
- Returns the squared distance between vectors a and b.
-
dot
public static float dot(float[] a, float[] b) Finds the dot product between two vectors.- Parameters:
a
- First vector.b
- Second vector.- Returns:
- Returns the dot product of a and b.
-
length
public static float length(float[] d) Finds the length of a vector.- Parameters:
d
- A vector to find the length of.- Returns:
- Returns the length of vector d.
-
length2
public static float length2(float[] d) Finds the length of a vector squared.- Parameters:
d
- A vector to find the length of squared.- Returns:
- Returns the length of vector d squared.
-
log
public static void log(float[] v) logVector- Parameters:
v
- an array of float.
-
log
logVector.- Parameters:
v
- an array ofinvalid reference
float
label
- aString
object.
-
normalize
public static float[] normalize(float[] n) Normalizes a vector.- Parameters:
n
- A vector to be normalized.- Returns:
- Returns the normalized vector.
-
normalize
public static float[] normalize(float[] n, float[] ret) Normalizes a vector.- Parameters:
n
- A vector to be normalized.ret
- The normalized vector.- Returns:
- Returns the normalized vector.
-
scale
public static float[] scale(float[] n, float a) Scales a vector.- Parameters:
n
- A vector to be scaled.a
- A scalar value.- Returns:
- Returns the scaled vector.
-
scale
public static float[] scale(float[] n, float a, float[] ret) Scales a vector.- Parameters:
n
- A vector to be scaled.a
- A scalar value.ret
- The scaled Vector.- Returns:
- Returns the array ret.
-
square
public static float[] square(float[] n) Squares values of a vector.- Parameters:
n
- A vector to be squared.- Returns:
- Returns the squared vector.
-
square
public static float[] square(float[] n, float[] ret) Squares values of a vector.- Parameters:
n
- A vector to be squared.ret
- The squared vector.- Returns:
- Returns the array ret.
-
squareRoot
public static float[] squareRoot(float[] n) Square root values of a vector.- Parameters:
n
- A vector to determine square root.- Returns:
- Returns the rooted vector.
-
squareRoot
public static float[] squareRoot(float[] n, float[] ret) Square root values of a vector.- Parameters:
n
- A vector to determine square root.ret
- The rooted vector.- Returns:
- Returns the array ret.
-
sub
public static float[] sub(float[] a, float[] b) Finds the difference between two vectors.- Parameters:
a
- First vectorb
- Second vector- Returns:
- Returns the difference ret.
-
sub
public static float[] sub(float[] a, float[] b, float[] ret) Finds the difference between two vectors- Parameters:
a
- First vectorb
- Second vectorret
- Return Values- Returns:
- Returns the difference ret.
-
toString
logVector.- Parameters:
v
- an array of float.- Returns:
- Returns a String description of the vector.
-
toString
vectorToString.- Parameters:
v
- an array ofinvalid reference
float
label
- aString
object.- Returns:
- Returns a String description of the vector.
-