org.knowceans.util
Class Vectors

java.lang.Object
  extended by org.knowceans.util.Vectors

public class Vectors
extends java.lang.Object

Static vector manipulation routines for Matlab porting and other numeric operations. The routines work for int and double partly; the class is extended as needed.

TODO: The question remains whether it makes sense to have a formal IntVector, analoguous to IntMatrix that allows performing search and indexing operations, such as views, etc.

Author:
heinrich

Constructor Summary
Vectors()
           
 
Method Summary
static void add(double[][] mat, double scalar)
          add a scalar to the matrix
static void add(double[] vec, double scalar)
          add a scalar to the vector
static void add(double[] a, double[] b)
          a+=b
static void add(double[] a, int[] b)
          a+=b
static double[] add(int[] vec, double scalar)
          add a scalar to the vector.
static void add(int[] vec, int scalar)
          add a scalar to the vector
static void add(int[] a, int[] b)
          a+=b
static int[] cast(double[] vec)
          cast a double[] to an int[]
static double[] cast(int[] vec)
          cast a double[] to an int[]
static double[] chooseColumn(double[][] matrix, int col)
          Extract the column from the 2-dim matrix / array (stored row-wise in Java)
static double[][] chooseElements(double[][] matrix, int[] rows, int[] cols)
          Create a matrix that contains the rows and columns of the argument matrix in the order given by rows and cols
static double[] chooseElements(double[] vector, int[] keep)
          Create vector that contains the elements of the argument in the order as given by keep
static int[][] chooseElements(int[][] matrix, int[] rows)
          Create a matrix that contains the rows of the argument matrix in the order given by rows.
static int[][] chooseElements(int[][] matrix, int[] rows, int[] cols)
          Create a matrix that contains the rows and columns of the argument matrix in the order given by rows and cols
static int[] chooseElements(int[] vector, int[] keep)
          Create vector that contains the elements of the argument in the order as given by keep
static double[][] concat(double[][] x, double[][] y, boolean rowwise)
           
static double[][] concat(double[][] x, double[] y, boolean rowwise)
           
static double[] concat(double[] x, double[] y)
           
static double[] concat(double[] x, double[] y, double[] z)
          w = [x y z]
static int[][] concat(int[][] x, int[][] y, boolean rowwise)
           
static int[] concat(int[] x, int[] y)
           
static double[] copy(double[] source)
          copies a the source to the destination
static void copy(double[] source, double[] dest)
          copy source to dest (no generics to keep performant)
static void copy(double[] source, int[] dest)
          copy source to dest (no generics to keep performant)
static float[] copy(float[] source)
           
static int[] copy(int[] source)
          copies a the source to the destination
static void copy(int[] source, double[] dest)
          copy source to dest (no generics to keep performant)
static void copy(int[] source, int[] dest)
          copy source to dest (no generics to keep performant)
static java.lang.Object copy(java.lang.Object source)
          copies the vector of int or double
static double[] copyDouble(int[] source)
          copies a the source to the destination
static double[] cumsum(double[] vec)
          cumulative sum of the elements, starting at element 0.
static float[] cumsum(float[] vec)
           
static void dotmult(double[] a, double[] b)
          a *= b
static int[] find(int[] vec, int val)
          find indices with val
static double[] getColumn(double[][] matrix, int col)
          get the column of the matrix
static int[] getColumn(int[][] matrix, int col)
          get the column of the matrix
static int[] getFormat()
          Get the format settings for doubles.
static double[][] increaseSize(double[][] matrix, int morerows, int morecols)
          Create new matrix of larger size and data of the argument.
static double[] increaseSize(double[] vector, int moreelements)
          Create new vector of larger size and data of the argument.
static int[][] increaseSize(int[][] matrix, int morerows, int morecols)
          Create new matrix of larger size and data of the argument.
static int[] increaseSize(int[] vector, int moreelements)
          Create new vector of larger size and data of the argument.
static boolean isDegenerate(double alpha)
          check if argument is nan or infinity
static boolean isDegenerate(double[] ds)
          check if argument contains nan or infinity
static boolean isDegenerate(double[][] pp)
          check if argument contains nan or infinity
static boolean isEqual(int[] a, int[] b)
          checks equality
static boolean isNegative(double[] ds)
          check if argument contains positive
static boolean isNegative(double[][] pp)
          check if argument positive
static boolean isNegative(int[] ds)
          check if argument contains positive
static boolean isNegative(int[][] pp)
          check if argument positive
static
<T> boolean
isNegative(T ds)
           
static boolean isPositive(double[] ds)
          check if argument contains positive
static boolean isPositive(double[][] pp)
          check if argument positive
static boolean isPositive(int[] ds)
          check if argument contains positive
static boolean isPositive(int[][] pp)
          check if argument positive
static
<T> boolean
isPositive(T ds)
           
static double max(double[] vec)
          maximum value in vec
static double max(float[] vec)
           
static int max(int[] vec)
          maximum value in vec
static double min(double[] vec)
          minimum value in vec
static float min(float[] vec)
           
static int min(int[] vec)
          minimum value in vec
static void mult(double[] ds, double d)
          multiplicates the vector with a scalar.
static double mult(double[] ds, double[] dt)
          multiplicates the vector with a vector (inner product).
static int[] ones(int len)
           
static double[] ones(int len, double factor)
           
static int[] ones(int len, int factor)
           
static java.lang.String print(double[] x)
          prints a double representation of the vector.
static java.lang.String print(double[][] x)
          prints a double representation of an array.
static java.lang.String print(float[] x)
           
static java.lang.String print(float[][] x)
           
static java.lang.String print(int[] x)
          prints a double representation of the vector.
static java.lang.String print(int[][] x)
          prints a double representation of an array.
static java.lang.String print(int[][] x, java.lang.String delim)
          prints a double representation of an array.
static java.lang.String print(java.lang.Object x)
           
static java.lang.String print(java.lang.Object[] x)
          Print the array of objects via their toString() methods.
static java.lang.String print(java.lang.Object[] x, java.lang.String delim)
          Print the array of objects via their toString() methods, using the delimiter.
static
<T> java.lang.String
printf(T x, java.lang.String format, java.lang.String delim)
          Print the double array of objects via their toString() methods, using the delimiter.
static double product(double[] vec)
          product of the values in vec
static double[] range(double start, double end)
           
static double[] range(double start, double end, double step)
          create sequence [start : step : end] of double values.
static int[] range(int start, int end)
           
static int[] range(int start, int end, int step)
           
static int[] rangeComplement(int[] set, int length)
          return the complement of the sorted subset of the set 0:length-1 in Matlab notation
static double[] removeElement(double[] vector, int element)
          Create new vector with data of the argument and removed element.
static int[] removeElement(int[] vector, int element)
          Create new vector with data of the argument and removed element.
static double[][] removeElements(double[][] matrix, int[] rows, int[] cols)
          Create new matrix with data of the argument and removed rows and columns.
static double[] removeElements(double[] vector, int[] elements)
          Create new vector with data of the argument and removed elements.
static int[][] removeElements(int[][] matrix, int[] rows, int[] cols)
          Create new matrix with data of the argument and removed rows and columns.
static int[] removeElements(int[] vector, int[] elements)
          Create new vector with data of the argument and removed elements.
static void removeFirst(double[] x, double val, int len, double gapval)
          remove first element of the array that has value val by shifting all subsequent elements of the vector up to (old size) len, setting the final element to gapval.
static void removeFirst(int[] x, int val, int len, int gapval)
          remove first element of the array that has value val by shifting all subsequent elements of the vector up to (old size) len, setting the final element to gapval.
static
<T> void
removeFirst(T[] x, T val, int len, T gapval)
          remove first element of the array that has value val by shifting all subsequent elements of the vector up to (old size) len, setting the final element to gapval.
static double[][] repmat(double[][] a, int rows, int cols)
          create matroid with matrix a as element repeated for rows and cols
static int[][] repmat(int[][] a, int rows, int cols)
          create matroid with matrix a as element repeated for rows and cols
static double[] resize(double[] x, int newlen, double fillval)
          resize the array by copying it into a new array of size K.
static int[] resize(int[] x, int newlen, int fillval)
          resize the array by copying it into a new array of size K.
static
<T> T[]
resize(T[] x, int newlen, T elementType)
          resize the array by copying it into a new array of size newlen and filling it with null if grown.
static int[] round(double[] x)
          rounds vector and converts to integer
static int[][] round(double[][] x)
          rounds matrix and converts to integer
static int[] round(float[] x)
           
static int[][] round(float[][] x)
           
static void setFormat(int colwidth, int ndigits)
          Set the format of the following double print calls to the column width and number of digits.
static void setSubVector(int[] vec, int[] indices, int replacement)
          set the elements of vec at indices with the replacement.
static void setSubVector(int[] vec, int[] indices, int[] replacements)
          set the elements of vec at indices with the respective replacements.
static int[] setSubVectorCopy(int[] vec, int[] indices, int[] replacements)
          set the elements of a copy of vec at indices with the respective replacements.
static double sqabs(double[] a)
          squared absolute value of vector
static double sqdist(double[] a, double[] b)
          squared euclidean distance between vectors.
static double[] sub(double[] vec, int start, int length)
           
static int[] sub(int[] vec, int start, int length)
           
static void subtract(double[] a, double[] b)
          a-=b
static void subtract(double[] a, int[] b)
          a-=b
static void subtract(int[] a, double[] b)
          a-=b
static void subtract(int[] a, int[] b)
          a-=b
static double[] subVector(double[] vec, int[] indices)
          returns a copy of the vector elements with the given indices in the original vector.
static double[] subVector(double[] vec, int start, int end)
           
static int[] subVector(int[] vec, int[] indices)
          returns a copy of the vector elements with the given indices in the original vector.
static double sum(double[] vec)
          sum the elements of vec
static double sum(float[] vec)
          sum the elements of vec
static int sum(int[] vec)
          sum the elements of vec
static double[][] transpose(double[][] mat)
          transpose the matrix
static int[][] transpose(int[][] mat)
          transpose the matrix
static void unsetFormat()
          Unset the format settings for doubles.
static double[] zeros(int len)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vectors

public Vectors()
Method Detail

setFormat

public static final void setFormat(int colwidth,
                                   int ndigits)
Set the format of the following double print calls to the column width and number of digits. Note that this is a static setting, it can be undone using unsetFormat.

Parameters:
colwidth -
ndigits -

getFormat

public static final int[] getFormat()
Get the format settings for doubles.

Returns:

unsetFormat

public static final void unsetFormat()
Unset the format settings for doubles.


range

public static int[] range(int start,
                          int end,
                          int step)
Parameters:
start -
end -
step -
Returns:
[start : step : end]

range

public static int[] range(int start,
                          int end)
Parameters:
start -
end -
Returns:
[start : end]

range

public static double[] range(double start,
                             double end,
                             double step)
create sequence [start : step : end] of double values. TODO: check precision.

Parameters:
start - double value of start, if integer, use "1.0" notation.
end - double value of end, if integer, use "1.0" notation.
step - double value of step size
Returns:

range

public static double[] range(double start,
                             double end)
Parameters:
start -
end -
Returns:
[start : end]

sum

public static double sum(double[] vec)
sum the elements of vec

Parameters:
vec -
Returns:

product

public static double product(double[] vec)
product of the values in vec

Parameters:
vec -
Returns:

sum

public static double sum(float[] vec)
sum the elements of vec

Parameters:
vec -
Returns:

sum

public static int sum(int[] vec)
sum the elements of vec

Parameters:
vec -
Returns:

cumsum

public static double[] cumsum(double[] vec)
cumulative sum of the elements, starting at element 0.

Parameters:
vec -
Returns:
vector containing the cumulative sum of the elements of vec

cumsum

public static float[] cumsum(float[] vec)

max

public static int max(int[] vec)
maximum value in vec

Parameters:
vec -
Returns:

max

public static double max(double[] vec)
maximum value in vec

Parameters:
vec -
Returns:

max

public static double max(float[] vec)

min

public static int min(int[] vec)
minimum value in vec

Parameters:
vec -
Returns:

min

public static double min(double[] vec)
minimum value in vec

Parameters:
vec -
Returns:

min

public static float min(float[] vec)

round

public static int[][] round(double[][] x)
rounds matrix and converts to integer

Parameters:
x -
Returns:

round

public static int[][] round(float[][] x)

round

public static int[] round(double[] x)
rounds vector and converts to integer

Parameters:
x -
Returns:

round

public static int[] round(float[] x)

concat

public static double[] concat(double[] x,
                              double[] y)
Parameters:
x -
y -
Returns:
[x y]

concat

public static int[] concat(int[] x,
                           int[] y)
Parameters:
x -
y -
Returns:
[x y]

concat

public static double[][] concat(double[][] x,
                                double[] y,
                                boolean rowwise)
Parameters:
x -
y -
rowwise - ? [x; y] : [x, y]
Returns:
[x {;,} y]

concat

public static double[][] concat(double[][] x,
                                double[][] y,
                                boolean rowwise)
Parameters:
x -
y -
rowwise - ? [x; y] : [x, y]
Returns:
[x {;,} y]

concat

public static int[][] concat(int[][] x,
                             int[][] y,
                             boolean rowwise)
Parameters:
x -
y -
rowwise - ? [x; y] : [x, y]
Returns:
[x {;,} y]

repmat

public static double[][] repmat(double[][] a,
                                int rows,
                                int cols)
create matroid with matrix a as element repeated for rows and cols

Parameters:
a -
rows -
cols -
Returns:

repmat

public static int[][] repmat(int[][] a,
                             int rows,
                             int cols)
create matroid with matrix a as element repeated for rows and cols

Parameters:
a -
rows -
cols -
Returns:

concat

public static double[] concat(double[] x,
                              double[] y,
                              double[] z)
w = [x y z]

Parameters:
x -
y -
Returns:
[x y z]

increaseSize

public static double[] increaseSize(double[] vector,
                                    int moreelements)
Create new vector of larger size and data of the argument.

Parameters:
vector - source array
moreelements - number of elements to add
Returns:
larger vector

increaseSize

public static double[][] increaseSize(double[][] matrix,
                                      int morerows,
                                      int morecols)
Create new matrix of larger size and data of the argument.

Parameters:
matrix -
more - rows
more - cols
Returns:
larger matrix

removeElement

public static double[] removeElement(double[] vector,
                                     int element)
Create new vector with data of the argument and removed element.

Parameters:
vector -
element -
Returns:
shorter vector

removeElements

public static double[][] removeElements(double[][] matrix,
                                        int[] rows,
                                        int[] cols)
Create new matrix with data of the argument and removed rows and columns.

Parameters:
matrix -
rows - ordered vector of rows to remove
cols - ordered vector of cols to remove
Returns:
smaller matrix

removeElements

public static double[] removeElements(double[] vector,
                                      int[] elements)
Create new vector with data of the argument and removed elements.

Parameters:
vector -
elements - ordered elements to remove
Returns:
smaller vector

rangeComplement

public static int[] rangeComplement(int[] set,
                                    int length)
return the complement of the sorted subset of the set 0:length-1 in Matlab notation

Parameters:
set - sorted set of elements < length
length - of superset of set and its returned complement
Returns:

getColumn

public static int[] getColumn(int[][] matrix,
                              int col)
get the column of the matrix


getColumn

public static double[] getColumn(double[][] matrix,
                                 int col)
get the column of the matrix


chooseElements

public static double[][] chooseElements(double[][] matrix,
                                        int[] rows,
                                        int[] cols)
Create a matrix that contains the rows and columns of the argument matrix in the order given by rows and cols

Parameters:
matrix -
rows -
cols -
Returns:

chooseElements

public static double[] chooseElements(double[] vector,
                                      int[] keep)
Create vector that contains the elements of the argument in the order as given by keep

Parameters:
vector -
keep -
Returns:

chooseColumn

public static double[] chooseColumn(double[][] matrix,
                                    int col)
Extract the column from the 2-dim matrix / array (stored row-wise in Java)

Parameters:
matrix -
col - column number to choose (must exist in each row of the matrix)
Returns:

increaseSize

public static int[] increaseSize(int[] vector,
                                 int moreelements)
Create new vector of larger size and data of the argument.

Parameters:
vector - source array
moreelements - number of elements to add
Returns:
larger vector

increaseSize

public static int[][] increaseSize(int[][] matrix,
                                   int morerows,
                                   int morecols)
Create new matrix of larger size and data of the argument.

Parameters:
matrix -
more - rows
more - cols
Returns:
larger matrix

removeElement

public static int[] removeElement(int[] vector,
                                  int element)
Create new vector with data of the argument and removed element.

Parameters:
vector -
element -
Returns:
shorter vector

removeElements

public static int[][] removeElements(int[][] matrix,
                                     int[] rows,
                                     int[] cols)
Create new matrix with data of the argument and removed rows and columns.

Parameters:
matrix -
rows - ordered vector of rows to remove
cols - ordered vector of cols to remove
Returns:
smaller matrix

removeElements

public static int[] removeElements(int[] vector,
                                   int[] elements)
Create new vector with data of the argument and removed elements.

Parameters:
vector -
elements - ordered elements to remove
Returns:
smaller vector

chooseElements

public static int[][] chooseElements(int[][] matrix,
                                     int[] rows,
                                     int[] cols)
Create a matrix that contains the rows and columns of the argument matrix in the order given by rows and cols

Parameters:
matrix -
rows -
cols -
Returns:

chooseElements

public static int[][] chooseElements(int[][] matrix,
                                     int[] rows)
Create a matrix that contains the rows of the argument matrix in the order given by rows. This method does not copy the rows.

Parameters:
matrix -
rows -
Returns:

chooseElements

public static int[] chooseElements(int[] vector,
                                   int[] keep)
Create vector that contains the elements of the argument in the order as given by keep

Parameters:
vector -
keep -
Returns:

print

public static java.lang.String print(double[] x)
prints a double representation of the vector.

Parameters:
x -
Returns:

print

public static java.lang.String print(float[] x)

print

public static java.lang.String print(java.lang.Object x)

print

public static java.lang.String print(java.lang.Object[] x)
Print the array of objects via their toString() methods.

Parameters:
x -
Returns:

print

public static java.lang.String print(java.lang.Object[] x,
                                     java.lang.String delim)
Print the array of objects via their toString() methods, using the delimiter.

Parameters:
x -
delim -
Returns:

printf

public static <T> java.lang.String printf(T x,
                                          java.lang.String format,
                                          java.lang.String delim)
Print the double array of objects via their toString() methods, using the delimiter.

Parameters:
x -
delim -
Returns:

print

public static java.lang.String print(double[][] x)
prints a double representation of an array.

Parameters:
x -
Returns:

print

public static java.lang.String print(float[][] x)

print

public static java.lang.String print(int[] x)
prints a double representation of the vector.

Parameters:
x -
Returns:

print

public static java.lang.String print(int[][] x)
prints a double representation of an array.

Parameters:
x -
Returns:

print

public static java.lang.String print(int[][] x,
                                     java.lang.String delim)
prints a double representation of an array.

Parameters:
x -
Returns:

ones

public static double[] ones(int len,
                            double factor)
Parameters:
len -
factor -
Returns:
factor * ones(1, len);

ones

public static int[] ones(int len,
                         int factor)
Parameters:
len -
factor -
Returns:
factor * ones(1, len);

zeros

public static double[] zeros(int len)
Parameters:
len -
Returns:
zeros(1, len)

ones

public static int[] ones(int len)
Parameters:
len -
Returns:
ones(1, len)

cast

public static int[] cast(double[] vec)
cast a double[] to an int[]

Parameters:
vec -
Returns:

cast

public static double[] cast(int[] vec)
cast a double[] to an int[]

Parameters:
vec -
Returns:

find

public static int[] find(int[] vec,
                         int val)
find indices with val

Parameters:
vec -
val -
Returns:
vector with 0-based indices.

subVector

public static double[] subVector(double[] vec,
                                 int[] indices)
returns a copy of the vector elements with the given indices in the original vector.

Parameters:
indices -
Returns:

subVector

public static int[] subVector(int[] vec,
                              int[] indices)
returns a copy of the vector elements with the given indices in the original vector.

Parameters:
cols -
Returns:

subVector

public static double[] subVector(double[] vec,
                                 int start,
                                 int end)
Parameters:
weights -
i -
j -
Returns:

sub

public static double[] sub(double[] vec,
                           int start,
                           int length)
Parameters:
weights -
i -
j -
Returns:

sub

public static int[] sub(int[] vec,
                        int start,
                        int length)
Parameters:
weights -
i -
j -
Returns:

setSubVector

public static void setSubVector(int[] vec,
                                int[] indices,
                                int[] replacements)
set the elements of vec at indices with the respective replacements. TODO: implement views as in the colt library

Parameters:
vec -
indices -
replacements -

setSubVector

public static void setSubVector(int[] vec,
                                int[] indices,
                                int replacement)
set the elements of vec at indices with the replacement. TODO: implement views as in the colt library

Parameters:
vec -
indices -
replacement -

add

public static void add(int[] vec,
                       int scalar)
add a scalar to the vector

Parameters:
vec -
scalar -

add

public static double[] add(int[] vec,
                           double scalar)
add a scalar to the vector. This creates a new double vector.

Parameters:
vec -
scalar -

add

public static void add(double[][] mat,
                       double scalar)
add a scalar to the matrix

Parameters:
vec -
scalar -

add

public static void add(double[] vec,
                       double scalar)
add a scalar to the vector

Parameters:
vec -
scalar -

add

public static void add(double[] a,
                       int[] b)
a+=b

Parameters:
a -
b -

add

public static void add(double[] a,
                       double[] b)
a+=b

Parameters:
a -
b -

add

public static void add(int[] a,
                       int[] b)
a+=b

Parameters:
a -
b -

subtract

public static void subtract(int[] a,
                            int[] b)
a-=b

Parameters:
a -
b -

subtract

public static void subtract(double[] a,
                            int[] b)
a-=b

Parameters:
a -
b -

subtract

public static void subtract(int[] a,
                            double[] b)
a-=b

Parameters:
a -
b -

subtract

public static void subtract(double[] a,
                            double[] b)
a-=b

Parameters:
a -
b -

sqdist

public static double sqdist(double[] a,
                            double[] b)
squared euclidean distance between vectors.

Parameters:
a -
b -
Returns:

sqabs

public static double sqabs(double[] a)
squared absolute value of vector

Parameters:
a -
Returns:

setSubVectorCopy

public static int[] setSubVectorCopy(int[] vec,
                                     int[] indices,
                                     int[] replacements)
set the elements of a copy of vec at indices with the respective replacements. TODO: implement views as in the colt library

Parameters:
vec -
indices -
replacements -
Returns:
the copied vector with the replacements;

copy

public static java.lang.Object copy(java.lang.Object source)
copies the vector of int or double

Parameters:
source -
Returns:

copy

public static double[] copy(double[] source)
copies a the source to the destination

Parameters:
alpha -
Returns:

copy

public static float[] copy(float[] source)

copy

public static int[] copy(int[] source)
copies a the source to the destination

Parameters:
alpha -
Returns:

copyDouble

public static double[] copyDouble(int[] source)
copies a the source to the destination

Parameters:
alpha -
Returns:

copy

public static void copy(int[] source,
                        double[] dest)
copy source to dest (no generics to keep performant)

Parameters:
source -
dest -

copy

public static void copy(double[] source,
                        int[] dest)
copy source to dest (no generics to keep performant)

Parameters:
source -
dest -

copy

public static void copy(int[] source,
                        int[] dest)
copy source to dest (no generics to keep performant)

Parameters:
source -
dest -

copy

public static void copy(double[] source,
                        double[] dest)
copy source to dest (no generics to keep performant)

Parameters:
source -
dest -

mult

public static void mult(double[] ds,
                        double d)
multiplicates the vector with a scalar. The argument is modified.

Parameters:
ds -
d -

dotmult

public static void dotmult(double[] a,
                           double[] b)
a *= b

Parameters:
a -
scalar -

mult

public static double mult(double[] ds,
                          double[] dt)
multiplicates the vector with a vector (inner product). The argument is not modified.

Parameters:
ds -
d -
Returns:

transpose

public static double[][] transpose(double[][] mat)
transpose the matrix

Parameters:
mat -
Returns:

transpose

public static int[][] transpose(int[][] mat)
transpose the matrix

Parameters:
mat -
Returns:

isDegenerate

public static boolean isDegenerate(double alpha)
check if argument is nan or infinity

Parameters:
alpha -
Returns:

isDegenerate

public static boolean isDegenerate(double[] ds)
check if argument contains nan or infinity

Parameters:
pp -
Returns:

isDegenerate

public static boolean isDegenerate(double[][] pp)
check if argument contains nan or infinity

Parameters:
pp -
Returns:

isPositive

public static <T> boolean isPositive(T ds)

isPositive

public static boolean isPositive(double[] ds)
check if argument contains positive

Parameters:
pp -
Returns:

isPositive

public static boolean isPositive(double[][] pp)
check if argument positive

Parameters:
pp -
Returns:

isNegative

public static <T> boolean isNegative(T ds)

isNegative

public static boolean isNegative(double[] ds)
check if argument contains positive

Parameters:
pp -
Returns:

isNegative

public static boolean isNegative(double[][] pp)
check if argument positive

Parameters:
pp -
Returns:

isPositive

public static boolean isPositive(int[] ds)
check if argument contains positive

Parameters:
pp -
Returns:

isPositive

public static boolean isPositive(int[][] pp)
check if argument positive

Parameters:
pp -
Returns:

isNegative

public static boolean isNegative(int[] ds)
check if argument contains positive

Parameters:
pp -
Returns:

isNegative

public static boolean isNegative(int[][] pp)
check if argument positive

Parameters:
pp -
Returns:

isEqual

public static boolean isEqual(int[] a,
                              int[] b)
checks equality

Parameters:
a -
b -
Returns:

removeFirst

public static void removeFirst(int[] x,
                               int val,
                               int len,
                               int gapval)
remove first element of the array that has value val by shifting all subsequent elements of the vector up to (old size) len, setting the final element to gapval.

Parameters:
x -
val -
gapval -

removeFirst

public static void removeFirst(double[] x,
                               double val,
                               int len,
                               double gapval)
remove first element of the array that has value val by shifting all subsequent elements of the vector up to (old size) len, setting the final element to gapval.

Parameters:
x -
val -
gapval -

removeFirst

public static <T> void removeFirst(T[] x,
                                   T val,
                                   int len,
                                   T gapval)
remove first element of the array that has value val by shifting all subsequent elements of the vector up to (old size) len, setting the final element to gapval.

Parameters:
x -
val -
gapval -

resize

public static int[] resize(int[] x,
                           int newlen,
                           int fillval)
resize the array by copying it into a new array of size K. Changes the pointer of the array.

Parameters:
x - original array
newlen - new length
fillval - value to be filled into added elements
Returns:
resized array

resize

public static double[] resize(double[] x,
                              int newlen,
                              double fillval)
resize the array by copying it into a new array of size K. Changes the pointer of the array.

Parameters:
x - original array
newlen - new length
fillval - value to be filled into added elements
Returns:
resized array

resize

public static <T> T[] resize(T[] x,
                             int newlen,
                             T elementType)
resize the array by copying it into a new array of size newlen and filling it with null if grown. Changes the pointer of the array.

Parameters:
x - original array
newlen - new length
elementType - type of one element, so zero-length arrays can be robustly handled. Can be null if x.length > 0 can be guaranteed.