kao.math.matvec.Vector Class Reference

A multi-threaded Vector class. More...

List of all members.

Classes

class  Bounds
 Calculates the element range to use for multi-threaded processing.

Public Member Functions

 Vector (int n)
 Vector (int firstElement, int n)
void init ()
double get (int i)
void set (int i, double e)
void set (Vector v)
int getLength ()
double[] getData ()
int getFirstElement ()
int getLastElement ()
void setFirstElement (int firstElement)
boolean isEmpty ()
void print (String s)
Vector add (Vector x)
Vector add (double s)
Vector sub (Vector x)
Vector sub (double s)
double innerProd (Vector x)
Matrix outerProd (Vector x, boolean sparse)
Vector mult (Vector x)
Vector mult (double s)
Vector div (Vector x)
Vector div (double s)
Vector copy ()
Vector copy (int startIdx, int n)
double l2Norm ()
Vector abs ()
double[] max ()
double[] min ()
Vector resize (int n, boolean preserve)
double sum ()
boolean isSameDimension (Vector v)

Static Public Member Functions

static Vector random (int firstElement, int n, double min, double max)
static Vector zeros (Vector v)
static Vector empty (Vector v)
static Vector data (int firstElement, double[] x)
static Vector data (double[] x)

Detailed Description

A multi-threaded Vector class.

Author:
David Kao

Constructor & Destructor Documentation

kao.math.matvec.Vector.Vector ( int  n  ) 

Create a 0 index based Vector with the specified number of elements.

Parameters:
[in] n Number of elements
kao.math.matvec.Vector.Vector ( int  firstElement,
int  n 
)

Create a Vector with the specified number of elements with a specified start index.

Parameters:
[in] firstElement First element of Vector
[in] n Number of elements

Member Function Documentation

Vector kao.math.matvec.Vector.abs (  ) 

Return the absolute Vector of this one

Returns:
Absolute Vector
Vector kao.math.matvec.Vector.add ( double  s  ) 

Scalar addition

Parameters:
[in] s Scalar to add to this
Returns:
Scalar addition
Vector kao.math.matvec.Vector.add ( Vector  x  ) 

Vector addition

Parameters:
[in] x Vector to add to this
Returns:
Vector addition
Vector kao.math.matvec.Vector.copy ( int  startIdx,
int  n 
)

Copy a subset of this Vector

Parameters:
startIdx Index of first element to copy
n Number of elements to copy
Returns:
Subset of Vector
Vector kao.math.matvec.Vector.copy (  ) 

Copy Vector

Returns:
Copy of this Vector
static Vector kao.math.matvec.Vector.data ( double[]  x  )  [static]

Create a zero indexed Vector from an array

Parameters:
[in] x Data array
Returns:
Vector of array
static Vector kao.math.matvec.Vector.data ( int  firstElement,
double[]  x 
) [static]

Create a Vector from an array with a specified index for the first element

Parameters:
[in] firstElement Index of first element
[in] x Data array
Returns:
Vector of array
Vector kao.math.matvec.Vector.div ( double  s  ) 

Scalar division

Parameters:
[in] s Scalar to divide from this
Returns:
Scalar division
Vector kao.math.matvec.Vector.div ( Vector  x  ) 

Vector element division

Parameters:
[in] x Vector to divide from this
Returns:
Vector element division
static Vector kao.math.matvec.Vector.empty ( Vector  v  )  [static]

Create an empty Vector with same index of the first element as v

Parameters:
[in] v Vector v
Returns:
Empty Vector
double kao.math.matvec.Vector.get ( int  i  ) 

Get v(i)

Parameters:
[in] i Index i
Returns:
Value of element i
double [] kao.math.matvec.Vector.getData (  ) 

Get array of Vector data

Returns:
Array of Vector data
int kao.math.matvec.Vector.getFirstElement (  ) 

Get first element index of Vector

Returns:
Index of first element
int kao.math.matvec.Vector.getLastElement (  ) 

Get last element index of Vector

Returns:
Index of last element
int kao.math.matvec.Vector.getLength (  ) 

Get length of Vector

Returns:
Length of vector
void kao.math.matvec.Vector.init (  ) 

Initialise Vector to zeros

double kao.math.matvec.Vector.innerProd ( Vector  x  ) 

Vector inner product

Parameters:
[in] x Vector to take inner product with this
Returns:
Vector inner product
boolean kao.math.matvec.Vector.isEmpty (  ) 

Does the Vector have zero length

Returns:
true/false
boolean kao.math.matvec.Vector.isSameDimension ( Vector  v  ) 

Does this Vector have the same dimensions as v

Parameters:
[in] v Vector v
Returns:
true/false
double kao.math.matvec.Vector.l2Norm (  ) 

Calculate the L2-norm (Euclidean) of the vector

Returns:
L2-norm
double [] kao.math.matvec.Vector.max (  ) 

Find the maximum of this Vector

Returns:
Maximum of this Vector.
  • Index 0 is the max value
  • Index 1 is the element index of the max value
double [] kao.math.matvec.Vector.min (  ) 

Find the minimum of this Vector

Returns:
Minimum of this Vector.
  • Index 0 is the min value
  • Index 1 is the element index of the min value
Vector kao.math.matvec.Vector.mult ( double  s  ) 

Scalar multiplication

Parameters:
[in] s Scalar to multiply to this
Returns:
Scalar multiplication
Vector kao.math.matvec.Vector.mult ( Vector  x  ) 

Vector element multiplication

Parameters:
[in] x Vector to multiply to this
Returns:
Vector element multiplication
Matrix kao.math.matvec.Vector.outerProd ( Vector  x,
boolean  sparse 
)

Vector outer product

Parameters:
[in] x Vector to take outer product with this
[in] sparse Is the resulting Matrix sparse
Returns:
Vector outer product
void kao.math.matvec.Vector.print ( String  s  ) 

Print the Vector prefixed with identifier s

Parameters:
[in] s String identifier
static Vector kao.math.matvec.Vector.random ( int  firstElement,
int  n,
double  min,
double  max 
) [static]

Create a randomly initialised vector

Parameters:
[in] firstElement Start index of vector
[in] n Number of elements in vector
[in] min Minimum value of random number
[in] max Maximum value of random number
Vector kao.math.matvec.Vector.resize ( int  n,
boolean  preserve 
)

Resize Vector to the specified number of elements. There is a flag to determine whether the data is preserved.

Parameters:
[in] n Number of elements
[in] preserve Preserve the vector data
Returns:
Resized Vector
void kao.math.matvec.Vector.set ( Vector  v  ) 

Set this Vector to v

Parameters:
[in] v Vector v
void kao.math.matvec.Vector.set ( int  i,
double  e 
)

Set element v(i) with the value of e.

Parameters:
[in] i Element i
[in] e Element value
void kao.math.matvec.Vector.setFirstElement ( int  firstElement  ) 

Set the first element index

Parameters:
[in] firstElement Index of start element
Vector kao.math.matvec.Vector.sub ( double  s  ) 

Scalar subtraction

Parameters:
[in] s Scalar to subtract from this
Returns:
Matrix subtraction
Vector kao.math.matvec.Vector.sub ( Vector  x  ) 

Vector subtraction

Parameters:
[in] x Vector to subtract from this
Returns:
Vector subtraction
double kao.math.matvec.Vector.sum (  ) 

Calculate the sum of all elements

Returns:
Sum of all elements
static Vector kao.math.matvec.Vector.zeros ( Vector  v  )  [static]

Create a Matrix of zeros with same dimensions as v

Parameters:
[in] v Vector v
Returns:
Zero Vector

Generated on Wed Apr 21 22:01:41 2010 for kao-math by  doxygen 1.6.1