|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.encog.mathutil.VectorAlgebra
public class VectorAlgebra
Basic vector algebra operators. Vectors are represented as arrays of doubles. This class was created to support the calculations in the PSO algorithm. This class is thread safe. Contributed by: Geoffroy Noel https://github.com/goffer-looney
Constructor Summary | |
---|---|
VectorAlgebra()
|
Method Summary | |
---|---|
void |
add(double[] v1,
double[] v2)
v1 = v1 + v2 |
void |
clampComponents(double[] v,
double maxValue)
For each components, reset their value to maxValue if their absolute value exceeds it. |
void |
copy(double[] dst,
double[] src)
dst = src Copy a vector. |
double |
dotProduct(double[] v1,
double[] v2)
Take the dot product of two vectors. |
void |
mul(double[] v,
double k)
v = k * v The components of the vector are multiplied by k. |
void |
mulRand(double[] v,
double k)
v = k * U(0,1) * v The components of the vector are multiplied by k and a random number. |
void |
neg(double[] v)
v = -v |
void |
randomise(double[] v)
v = U(0, 0.1) |
void |
randomise(double[] v,
double maxValue)
v = U(-1, 1) * maxValue Randomise each component of a vector to [-maxValue, maxValue]. |
void |
sub(double[] v1,
double[] v2)
v1 = v1 - v2 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VectorAlgebra()
Method Detail |
---|
public void add(double[] v1, double[] v2)
v1
- an array of doublesv2
- an array of doublespublic void sub(double[] v1, double[] v2)
v1
- an array of doublesv2
- an array of doublespublic void neg(double[] v)
v
- an array of doublespublic void mulRand(double[] v, double k)
v
- an array of doubles.k
- a scalar.public void mul(double[] v, double k)
v
- an array of doubles.k
- a scalar.public void copy(double[] dst, double[] src)
dst
- an array of doublessrc
- an array of doublespublic void randomise(double[] v)
v
- an array of doublespublic void randomise(double[] v, double maxValue)
v
- an array of doublespublic void clampComponents(double[] v, double maxValue)
v
- an array of doublesmaxValue
- if -1 this function does nothingpublic double dotProduct(double[] v1, double[] v2)
v1
- The first vector.v2
- The second vector.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |