|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJSci.maths.AbstractMath
JSci.maths.ArrayMath
public final class ArrayMath
Arrays are faster than object, so this class is here to take full advantage of arrays without encapsulation. All methods are safe, that is, they create copies of arrays whenever necessary This makes for slower methods, but the programmer can always define his own methods optimized for performance.
Method Summary | |
---|---|
static double[] |
abs(double[] v)
Takes the absolute value of each component of an array. |
static double[][] |
abs(double[][] v)
Takes the absolute value of each component of an array. |
static int[] |
abs(int[] v)
Takes the absolute value of each component of an array. |
static int[][] |
abs(int[][] v)
Takes the absolute value of each component of an array. |
static double[] |
add(double[] w,
double a)
Add a scalar to every element in the array. |
static double[] |
add(double[] a,
double[] b)
Add the two arrays together (componentwise). |
static double[] |
add(double[] w,
double a,
double[] v,
int p)
Add to an array w, a time v where a is a scalar... |
static int[] |
add(int[] w,
double a,
int[] v,
int p)
Add to an array w, a time v where a is a scalar... |
static int[] |
add(int[] w,
int a)
Add a scalar to every element in the array. |
static int[] |
add(int[] a,
int[] b)
Add the two arrays together (componentwise). |
static Complex[] |
apply(ComplexMapping m,
Complex[] v)
Apply a map to every component of an array. |
static Complex[][] |
apply(ComplexMapping m,
Complex[][] v)
Apply a map to every component of an array. |
static double[] |
apply(Mapping m,
double[] v)
Apply a map to every component of an array. |
static double[][] |
apply(Mapping m,
double[][] v)
Apply a map to every component of an array. |
static double[] |
copy(double[] v)
Return a copy of the array. |
static double[][] |
copy(double[][] v)
Return a copy of the array. |
static int[] |
copy(int[] v)
Return a copy of the array. |
static int[][] |
copy(int[][] v)
Return a copy of the array. |
static double |
correlation(double[] v1,
double[] v2)
Compute the (linear) correlation between two arrays. |
static double |
correlation(int[] v1,
int[] v2)
Compute the (linear) correlation between two arrays. |
static double |
covariance(double[] v1,
double[] v2)
Compute the covariance. |
static double |
covariance(int[] v1,
int[] v2)
|
static boolean |
equals(double[] a,
double[] b)
Deprecated. |
static boolean |
equals(int[] a,
int[] b)
Deprecated. |
static double[] |
extract(int k0,
int k1,
double[] invect)
Extract a sub-array (will invert the resulting array if k0 > k1). |
static int[] |
extract(int k0,
int k1,
int[] invect)
Extract a sub-array (will invert the resulting array if k0 > k1). |
static double[] |
invert(double[] v)
Invert an array from left to right. |
static int[] |
invert(int[] v)
Invert an array from left to right. |
static double |
mass(double[] v)
Return the sum of the elements of the array. |
static int |
mass(int[] v)
Return the sum of the elements of the array. |
static double |
max(double[] v)
Return the maximum of an array. |
static double |
max(double[][] v)
Return the maximum of an array. |
static int |
max(int[] v)
Return the maximum of an array. |
static int |
max(int[][] v)
Return the maximum of an array. |
static double |
mean(double[] v)
Compute the mean. |
static double |
mean(int[] v)
Compute the mean. |
static double |
median(double[] v)
Compute the median of an array. |
static double |
median(int[] v)
Compute the median of an array. |
static double |
min(double[] v)
Return the minimum of an array. |
static double |
min(double[][] v)
Return the minimum of an array. |
static int |
min(int[] v)
Return the minimum of an array. |
static int |
min(int[][] v)
Return the minimum of an array. |
static double[] |
mod(Complex[] v)
Return the componentwise modulus of an array of Complex numbers. |
static double[][] |
mod(Complex[][] v)
Return the componentwise modulus of an array of Complex numbers. |
static double |
norm(double[] data)
Compute the L2 norm of an array (Euclidean norm or "length"). |
static double |
norm(int[] data)
Compute the L2 norm of an array (Euclidean norm or "length"). |
static double[] |
normalize(double[] v)
Renormalize the array so that its L2 norm is 1 (up to computational errors). |
static double[] |
padding(int n0,
int pos,
double[] v)
Fills in with zero to get to the desired length; original array with be at the specified position. |
static int[] |
padding(int n0,
int pos,
int[] v)
Fills in with zeroes to get to the specified length; original array with be at the specified position |
static double |
percentile(double[] v,
double p)
Gives the percentile of an array |
static double |
percentile(int[] v,
double p)
Gives the percentile of an array. |
static void |
print(double[] v)
Print to screen an array. |
static void |
print(double[][] v)
Print to screen an array. |
static void |
print(int[] v)
Print to screen an array. |
static void |
print(int[][] v)
Print to screen an array. |
static double[] |
range(double b)
Generate an array going for 0 to b with steps of size 1. |
static double[] |
range(double a,
double b)
Generate an array going for a to b inclusively with steps of size 1. |
static double[] |
range(double a,
double b,
double step)
Generate an array going for a to b with steps of size step. |
static int[] |
range(int b)
Generate an array going for 0 to b with steps of size 1. |
static int[] |
range(int a,
int b)
Generate an array going for a to b with steps of size 1. |
static int[] |
range(int a,
int b,
int step)
|
static double[] |
scalarMultiply(double a,
double[] v)
Multiply every component of an array by a scalar. |
static double[] |
scalarMultiply(double a,
int[] v)
Multiply every component of an array by a scalar. |
static double[] |
scalarMultiplyFast(double a,
double[] v)
Fast scalar multiplication for sparse arrays. |
static double[] |
scalarMultiplyFast(double a,
int[] v)
Fast scalar multiplication for sparse arrays. |
static double |
scalarProduct(double[][] w0,
double[][] w1)
Compute the scalar product of two array as if they were matrices. |
static double |
scalarProduct(double[] w0,
double[] w1)
Compute the scalar product of two array as if they were vectors. |
static double |
scalarProduct(int[][] w0,
int[][] w1)
Compute the scalar product of two array as if they were matrices. |
static int |
scalarProduct(int[] w0,
int[] w1)
Compute the scalar product of two array as if they were vectors. |
static double[] |
setLengthFromBeginning(double[] data,
int length)
Set an array to the specified length scraping or padding the end if necessary. |
static int[] |
setLengthFromBeginning(int[] data,
int length)
Set an array to the specified length scraping or padding the end if necessary. |
static double[] |
setLengthFromEnd(double[] data,
int length)
Set an array to the specified length scraping or padding the beginning if necessary. |
static int[] |
setLengthFromEnd(int[] data,
int length)
Set an array to the specified length scraping or padding the beginning if necessary. |
static double[] |
sortMaxToMin(double[] v)
Return a sorted array from the maximum to the minimum value. |
static int[] |
sortMaxToMin(int[] v)
Return a sorted array from the maximum to the minimum value. |
static double[] |
sortMinToMax(double[] v)
Return a sorted array from the minimum to the maximum value. |
static int[] |
sortMinToMax(int[] v)
Return a sorted array from the minimum to the maximum value. |
static double |
standardDeviation(double[] v)
Compute the standard deviation of an array. |
static double |
standardDeviation(int[] v)
Return the standard deviation of an array. |
static double[] |
subtract(double[] a,
double[] b)
Subtract the two arrays together (componentwise) |
static int[] |
subtract(int[] a,
int[] b)
Subtract the two arrays together (componentwise). |
static double |
sumSquares(double[] data)
Sum the squares of all components; also called the energy of the array. |
static double |
sumSquares(double[][] data)
Sum the squares of all components; also called the energy of the array. |
static int |
sumSquares(int[] data)
Sum the squares of all components; also called the energy of the array. |
static int |
sumSquares(int[][] data)
Sum the squares of all components; also called the energy of the array. |
static java.lang.String |
toString(double[] array)
Returns a comma delimited string representing the value of the array. |
static java.lang.String |
toString(double[][] array)
Returns a comma delimited string representing the value of the array. |
static java.lang.String |
toString(int[] array)
Returns a comma delimited string representing the value of the array. |
static java.lang.String |
toString(int[][] array)
Returns a comma delimited string representing the value of the array. |
static double[][] |
transpose(double[][] M)
Takes the transpose of an array (like the matrix operation). |
static int[][] |
transpose(int[][] M)
Takes the transpose of an array (like the matrix operation). |
static double |
variance(double[] v)
Compute the variance. |
static double |
variance(int[] v)
Compute the variance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static double[] apply(Mapping m, double[] v)
public static double[][] apply(Mapping m, double[][] v)
public static Complex[] apply(ComplexMapping m, Complex[] v)
public static Complex[][] apply(ComplexMapping m, Complex[][] v)
public static double[] normalize(double[] v)
public static double[] setLengthFromEnd(double[] data, int length)
public static double[] setLengthFromBeginning(double[] data, int length)
public static double[] copy(double[] v)
public static double[][] copy(double[][] v)
public static double variance(double[] v)
public static double covariance(double[] v1, double[] v2)
public static double correlation(double[] v1, double[] v2)
public static double mean(double[] v)
public static double standardDeviation(double[] v)
public static double[] sortMinToMax(double[] v)
public static double[] sortMaxToMin(double[] v)
public static double percentile(double[] v, double p)
p
- percentile, must be between 0 and 1
java.lang.IllegalArgumentException
- if parameter.
p is not between 0 and 1.public static double median(double[] v)
public static boolean equals(double[] a, double[] b)
public static double[] abs(double[] v)
public static double[][] abs(double[][] v)
public static double max(double[] v)
public static double max(double[][] v)
public static double min(double[] v)
public static double min(double[][] v)
public static double[] mod(Complex[] v)
public static double[][] mod(Complex[][] v)
public static double norm(double[] data)
public static double sumSquares(double[] data)
public static double sumSquares(double[][] data)
public static double scalarProduct(double[] w0, double[] w1)
java.lang.IllegalArgumentException
- if the don't have the same lengthpublic static double scalarProduct(double[][] w0, double[][] w1)
java.lang.IllegalArgumentException
- if the don't have the same lengthpublic static double[] extract(int k0, int k1, double[] invect)
k0
- location of the first componentk1
- location of the last componentpublic static double[] invert(double[] v)
public static double[] padding(int n0, int pos, double[] v)
n0
- length of the new array.pos
- position of the old array.public static double[] add(double[] w, double a, double[] v, int p)
a
- scalar.p
- position.public static double[] add(double[] w, double a)
public static double[][] transpose(double[][] M)
java.lang.IllegalArgumentException
- if the array is not a matrixpublic static double[] range(double a, double b, double step)
step
- size of steps, must be positive.a
- first value of array.b
- last value of array.
java.lang.IllegalArgumentException
- if step is negative of if a=b.public static double[] range(double a, double b)
public static double[] range(double b)
public static double[] add(double[] a, double[] b)
java.lang.IllegalArgumentException
- if the
two arrays don't have the same length.public static double[] subtract(double[] a, double[] b)
java.lang.IllegalArgumentException
- if the
two arrays don't have the same length.public static double[] scalarMultiply(double a, double[] v)
public static java.lang.String toString(double[] array)
public static java.lang.String toString(double[][] array)
public static double mass(double[] v)
public static double[] scalarMultiplyFast(double a, double[] v)
public static void print(double[] v)
public static void print(double[][] v)
public static int[] setLengthFromEnd(int[] data, int length)
public static int[] setLengthFromBeginning(int[] data, int length)
public static int[] copy(int[] v)
public static int[][] copy(int[][] v)
public static double variance(int[] v)
public static double covariance(int[] v1, int[] v2)
public static double correlation(int[] v1, int[] v2)
public static double mean(int[] v)
public static double standardDeviation(int[] v)
public static int[] sortMinToMax(int[] v)
public static int[] sortMaxToMin(int[] v)
public static java.lang.String toString(int[] array)
public static java.lang.String toString(int[][] array)
public static double percentile(int[] v, double p)
p
- percentile, must be between 0 and 1
java.lang.IllegalArgumentException
- if parameter
p is not between 0 and 1.public static double median(int[] v)
public static boolean equals(int[] a, int[] b)
public static int[] abs(int[] v)
public static int[][] abs(int[][] v)
public static int max(int[] v)
public static int max(int[][] v)
public static int min(int[] v)
public static int min(int[][] v)
public static double norm(int[] data)
public static int sumSquares(int[] data)
public static int sumSquares(int[][] data)
public static int scalarProduct(int[] w0, int[] w1)
java.lang.IllegalArgumentException
- if the
don't have the same length.public static double scalarProduct(int[][] w0, int[][] w1)
java.lang.IllegalArgumentException
- if the
don't have the same length.public static int[] extract(int k0, int k1, int[] invect)
k0
- location of the first component.k1
- location of the last component.public static int[] invert(int[] v)
public static int[] padding(int n0, int pos, int[] v)
n0
- length of the new array.pos
- position of the old array.public static int[] add(int[] w, double a, int[] v, int p)
a
- scalar.p
- position.w
- longer array.v
- shorter array.
java.lang.IllegalArgumentException
- if the second array
is not shorter than the first one.public static int[] add(int[] w, int a)
public static int[] range(int a, int b)
public static int[] range(int b)
public static int[] range(int a, int b, int step)
public static int[][] transpose(int[][] M)
java.lang.IllegalArgumentException
- if the array
is not a matrixpublic static int[] add(int[] a, int[] b)
java.lang.IllegalArgumentException
- if the
two arrays don't have the same length.public static int[] subtract(int[] a, int[] b)
java.lang.IllegalArgumentException
- if the
two arrays don't have the same length.public static int mass(int[] v)
public static double[] scalarMultiply(double a, int[] v)
public static double[] scalarMultiplyFast(double a, int[] v)
public static void print(int[] v)
public static void print(int[][] v)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |