SciLib.Math
Class integerVector

java.lang.Object
  extended by SciLib.Math.integerVector

public class integerVector
extends java.lang.Object

This class defines a dynamic vector of type intger.


Constructor Summary
integerVector()
          Allocates an empty vector.
integerVector(int n)
          Allocates a vector of size n with initiařized values 0.
integerVector(int[] vec)
          Allocates a vector from the array vec.
integerVector(integerVector x)
          Make a copy of the vector x.
 
Method Summary
 void add(int x)
          Add an element of value x to the vector.
 void append(integerVector x)
          Append an integerVector x to this vector
 int argmax()
          Compute the index of the maximum element in the vector.
 int argmin()
          Compute the index of the minimum element in the vector.
 void concat(integerVector x)
          Append a vector x to this vector
static integerVector copy(integerVector x)
          Make a copy of the vector x.
static int dot(integerVector i1, integerVector i2)
          compute the dot product of two sparse binary vector a sparse vectors.
static int dot(integerVector i1, integerVector x, integerVector i2, integerVector y)
          compute the dot product of two sparse binary vector a sparse vectors.
 int elementAt(int i)
          return the value of vector at index i.
static integerVector generate(int from, int to)
          create an integerVector that has elements from an integer "from" to an integer "to".
static integerVector generateIndex(integerVector v)
          create integerVector that stores the indexes of the nonzero elements of a sparse vector .
static integerVector generateIndex(integerVector v, integerVector val)
          create integerVector that stores the indexes of the nonzero elements of a sparse integerVector and stores them in val.
static integerVector generateIndex(integerVector v, vector val)
          create integerVector that stores the indexes of the nonzero elements of a sparse vector and stores them in val.
static integerVector generateIndex(vector v)
          create integerVector that stores the indexes of the nonzero elements of a sparse vector .
static integerVector generateIndex(vector v, vector val)
          create integerVector that stores the indexes of the nonzero elements of a sparse vector and stores them in val.
 int[] getData()
          Make an intger array that contains all data of the vector.
 int max()
          return the maximum value of the vector.
 int min()
          return the minimum value of the vector.
 void minus(integerVector x)
          minus this vector with the vector x and store the result in this vector.
static integerVector minus(integerVector x, integerVector y)
          minus two vector x, y.
static integerVector ones(int n)
          Make a vector of length n whose elements have value 1.
 void print()
          Print all elements of the vector using System.out.
 void read(java.lang.String fileName)
          Read data from a file to an integer vector.
 void resize(int n)
          Change the size of the vector to n.
 void setElementAt(int x, int i)
          change the value of element at index i with the integer x.
 int size()
          Return the length of the vector.
 double squareDistance(integerVector x)
          compute the square distance between this point vector to a vector x
static double squareDistance(integerVector x, integerVector y)
          compute the square distance between to point vector
 int squareNorm()
          return the square of the norm of the vector.
static int squareNorm(integerVector index, integerVector val)
          return the square of the norm of the vector.
 integerVector subvector(int from)
          make a vector whose elements are equal to elements of this vector with the indexes from an integer "from" to the end of this vector.
 integerVector subvector(int from, int to)
          Make a vector whose elements are equal to elements of this vector with the indexes from an integer "from" to an intger "to".
 java.lang.String toString()
          create a String that contains the elements of the vector.
 void translate(int s)
          plus all elements of the vector with an integer factor s.
 void trimToSize()
          Remove all the unused elements of the vector.
 void write(java.lang.String fileName)
          write an integerVector to a file
static integerVector zeros(int n)
          Make a vector of length n whose elements have value 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

integerVector

public integerVector()
Allocates an empty vector.


integerVector

public integerVector(int n)
Allocates a vector of size n with initiařized values 0.

Parameters:
n - The length of the vector

integerVector

public integerVector(int[] vec)
Allocates a vector from the array vec.

Parameters:
vec - An array of type double

integerVector

public integerVector(integerVector x)
Make a copy of the vector x.

Parameters:
x - An integerVector
Method Detail

copy

public static integerVector copy(integerVector x)
Make a copy of the vector x.

Parameters:
x - An integerVector

add

public void add(int x)
Add an element of value x to the vector.

Parameters:
x - An integer value

append

public void append(integerVector x)
Append an integerVector x to this vector

Parameters:
x - A vector

argmax

public final int argmax()
Compute the index of the maximum element in the vector.

Returns:
An integer

argmin

public final int argmin()
Compute the index of the minimum element in the vector.

Returns:
An integer

concat

public void concat(integerVector x)
Append a vector x to this vector

Parameters:
x - A vector

elementAt

public int elementAt(int i)
              throws java.lang.ArrayIndexOutOfBoundsException
return the value of vector at index i.

Parameters:
i - An integer
Throws:
java.lang.ArrayIndexOutOfBoundsException

generate

public static integerVector generate(int from,
                                     int to)
create an integerVector that has elements from an integer "from" to an integer "to".

Parameters:
from - An integer
to - An integer
Returns:
A integerVector

generateIndex

public static integerVector generateIndex(vector v)
create integerVector that stores the indexes of the nonzero elements of a sparse vector .

Parameters:
v - A vector
Returns:
An integerVector

generateIndex

public static integerVector generateIndex(integerVector v)
create integerVector that stores the indexes of the nonzero elements of a sparse vector .

Parameters:
v - An integerVector
Returns:
An integerVector

generateIndex

public static integerVector generateIndex(integerVector v,
                                          vector val)
create integerVector that stores the indexes of the nonzero elements of a sparse vector and stores them in val.

Parameters:
v - An integerVector
val - A vector
Returns:
An integerVector

generateIndex

public static integerVector generateIndex(integerVector v,
                                          integerVector val)
create integerVector that stores the indexes of the nonzero elements of a sparse integerVector and stores them in val.

Parameters:
v - An integerVector
val - A integerVector
Returns:
An integerVector

generateIndex

public static integerVector generateIndex(vector v,
                                          vector val)
create integerVector that stores the indexes of the nonzero elements of a sparse vector and stores them in val.

Parameters:
v - An vector
val - A vector
Returns:
An integerVector

dot

public static int dot(integerVector i1,
                      integerVector x,
                      integerVector i2,
                      integerVector y)
compute the dot product of two sparse binary vector a sparse vectors.

Parameters:
i1 - stores indexes of nozero elements of x, An integerVector
x - an array of integers, An integerVector
i2 - stores indexes of nozero elements of y, An integerVector
y - an ayyar of integers, An integerVector
Returns:
An integer value

dot

public static int dot(integerVector i1,
                      integerVector i2)
compute the dot product of two sparse binary vector a sparse vectors.

Parameters:
i1 - stores indexes of nozero elements of x, An integerVector
i2 - stores indexes of nozero elements of y, An integerVector
Returns:
An integer value

getData

public int[] getData()
Make an intger array that contains all data of the vector.

Returns:
An intger array

max

public final int max()
return the maximum value of the vector.

Returns:
An integer value

min

public final int min()
return the minimum value of the vector.

Returns:
An integer value

minus

public void minus(integerVector x)
           throws SizeException
minus this vector with the vector x and store the result in this vector.

Parameters:
x - A integerVector
Throws:
SizeException

minus

public static integerVector minus(integerVector x,
                                  integerVector y)
                           throws SizeException
minus two vector x, y. The result is stored in a new vector

Parameters:
x - A integerVector
y - A integerVector
Returns:
A integerVector that is equal to x - y
Throws:
SizeException

ones

public static integerVector ones(int n)
Make a vector of length n whose elements have value 1.


print

public void print()
Print all elements of the vector using System.out.


resize

public void resize(int n)
Change the size of the vector to n.

Parameters:
n - The new length of the vector

setElementAt

public void setElementAt(int x,
                         int i)
                  throws java.lang.ArrayIndexOutOfBoundsException
change the value of element at index i with the integer x.

Parameters:
x - An integer value
i - An index integer
Throws:
java.lang.ArrayIndexOutOfBoundsException

size

public final int size()
Return the length of the vector.

Returns:
An integer

squareNorm

public final int squareNorm()
return the square of the norm of the vector.

Returns:
An integer value

squareNorm

public static int squareNorm(integerVector index,
                             integerVector val)
return the square of the norm of the vector.

Returns:
An integer value

squareDistance

public double squareDistance(integerVector x)
compute the square distance between this point vector to a vector x

Parameters:
x - A integerVector
Returns:
A double value

squareDistance

public static double squareDistance(integerVector x,
                                    integerVector y)
compute the square distance between to point vector

Parameters:
x - A integerVector
y - A integerVector
Returns:
A double value

subvector

public integerVector subvector(int from,
                               int to)
Make a vector whose elements are equal to elements of this vector with the indexes from an integer "from" to an intger "to".

Parameters:
from - start index
to - end index
Returns:
A vector

subvector

public integerVector subvector(int from)
make a vector whose elements are equal to elements of this vector with the indexes from an integer "from" to the end of this vector.

Parameters:
from - start index
Returns:
A vector

toString

public java.lang.String toString()
create a String that contains the elements of the vector.

Overrides:
toString in class java.lang.Object
Returns:
A String

translate

public void translate(int s)
plus all elements of the vector with an integer factor s.

Parameters:
s - A double value

trimToSize

public void trimToSize()
Remove all the unused elements of the vector.


zeros

public static integerVector zeros(int n)
Make a vector of length n whose elements have value 0.

Parameters:
n - An integer

write

public void write(java.lang.String fileName)
write an integerVector to a file

Parameters:
fileName - A String

read

public void read(java.lang.String fileName)
Read data from a file to an integer vector.

Parameters:
fileName - a String