sugr.linalg
Class VectorImplColt

java.lang.Object
  extended bysugr.linalg.VectorImplColt
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, Vector

public class VectorImplColt
extends java.lang.Object
implements Vector

Author:
beder
See Also:
Serialized Form

Field Summary
protected  cern.colt.matrix.DoubleMatrix1D impl
           
private static long serialVersionUID
          Class version number for serialization
 
Constructor Summary
protected VectorImplColt()
           
  VectorImplColt(double[] values)
           
  VectorImplColt(int size)
           
  VectorImplColt(Vector v)
           
 
Method Summary
 java.lang.Object clone()
          Clone a vector.
 Vector copy()
          Copies s into a new vector r
 Vector crossProduct(Vector v)
          calulates the cross product: r = s x v.
 double get(int pos)
          Gets an element from s
 Vector get(int i0, int i1)
          Get a part of the vector.
 int getDim()
          Returns the dimension of s
 double getLength()
          Calculates the length of s.
 Matrix getMatrix()
          Creates a matrix from s
This is a "kind" of typecast.
 Vector minus(Vector v)
          Substracts to vectors: r = s-v
 Vector mult(double f)
          Multiplication with scalar: r = a*s
 double normF()
          Calculates the Frobenius norm of a vector, which is the same as the getLength().
 double normM()
          Calculates the maximum norm of a vector
 Vector plus(Vector v)
          Add two vectors: r = s+v
 void print()
          Prints this matrix to stdout
 void print(int w, int d)
          Prints this matrix to stdout
Note:It may be useful to select w > d.
 void printMatlab()
          Prints this matrix in Matlab format to stdout
 double scalarmult(Vector v)
          scalarmultiplication (or dot product)of two vectors: a = s*v, where a is a scalar value
 void set(int pos, double value)
          Set an element of s
 void set(int pos, Vector v)
          Set a part of a vector
 Matrix SkewSym()
          Creates a skew-symmetrix matrix from s. s must have dimension 3 to do that.
 java.lang.String toString()
          Delivers a string with the elements of the matrix.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sugr.linalg.Vector
equals
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Class version number for serialization

See Also:
Constant Field Values

impl

protected cern.colt.matrix.DoubleMatrix1D impl
Constructor Detail

VectorImplColt

public VectorImplColt(int size)

VectorImplColt

public VectorImplColt(double[] values)

VectorImplColt

public VectorImplColt(Vector v)

VectorImplColt

protected VectorImplColt()
Method Detail

plus

public Vector plus(Vector v)
Description copied from interface: Vector
Add two vectors: r = s+v

Specified by:
plus in interface Vector
Parameters:
v - vector to add
Returns:
s+v

minus

public Vector minus(Vector v)
Description copied from interface: Vector
Substracts to vectors: r = s-v

Specified by:
minus in interface Vector
Parameters:
v - vector to substract
Returns:
s-v

scalarmult

public double scalarmult(Vector v)
Description copied from interface: Vector
scalarmultiplication (or dot product)of two vectors: a = s*v, where a is a scalar value

Specified by:
scalarmult in interface Vector
Parameters:
v - vector to scalarmultiplicate
Returns:
s*v, where a = s_0*v_0 + s_1*v_1 + ... + s_n*v_n as double

crossProduct

public Vector crossProduct(Vector v)
Description copied from interface: Vector
calulates the cross product: r = s x v.

Specified by:
crossProduct in interface Vector
Parameters:
v - vector to create cross product with
Returns:
a Vector orthogonal to both s and v

mult

public Vector mult(double f)
Description copied from interface: Vector
Multiplication with scalar: r = a*s

Specified by:
mult in interface Vector
Parameters:
f - scalar value
Returns:
a Vector multiplicated with a scalar

copy

public Vector copy()
Description copied from interface: Vector
Copies s into a new vector r

Specified by:
copy in interface Vector
Returns:
a Vector r independent from s with s=r

set

public void set(int pos,
                double value)
Description copied from interface: Vector
Set an element of s

Specified by:
set in interface Vector
Parameters:
pos - Position to set a new value. First position is 0
value - new value to set

set

public void set(int pos,
                Vector v)
Description copied from interface: Vector
Set a part of a vector

Specified by:
set in interface Vector
Parameters:
pos - begining position (inclusive)
v - vector which hold the values to be set. All the values from the vector are copied to the target.

get

public double get(int pos)
Description copied from interface: Vector
Gets an element from s

Specified by:
get in interface Vector
Parameters:
pos - Position to get element from. Starts with 0
Returns:
the element as an double

get

public Vector get(int i0,
                  int i1)
Description copied from interface: Vector
Get a part of the vector.

Specified by:
get in interface Vector
Parameters:
i0 - index of first vector element
i1 - index of the last vector element
Returns:
a vector which is a part of the original vector.

getDim

public int getDim()
Description copied from interface: Vector
Returns the dimension of s

Specified by:
getDim in interface Vector
Returns:
a int containing the dimension

getLength

public double getLength()
Description copied from interface: Vector
Calculates the length of s.

Specified by:
getLength in interface Vector
Returns:
a = sqrt(s*s)

normF

public double normF()
Description copied from interface: Vector
Calculates the Frobenius norm of a vector, which is the same as the getLength().

Specified by:
normF in interface Vector
Returns:
a = sqrt(s*s)

normM

public double normM()
Description copied from interface: Vector
Calculates the maximum norm of a vector

Specified by:
normM in interface Vector
Returns:
a = max|v_i|

print

public void print(int w,
                  int d)
Description copied from interface: Vector
Prints this matrix to stdout
Note:It may be useful to select w > d. A common value is w=5, d=3

Specified by:
print in interface Vector
Parameters:
w - describes the width of a single element
d - number of decimals after comma

print

public void print()
Description copied from interface: Vector
Prints this matrix to stdout

Specified by:
print in interface Vector

printMatlab

public void printMatlab()
Description copied from interface: Vector
Prints this matrix in Matlab format to stdout

Specified by:
printMatlab in interface Vector

toString

public java.lang.String toString()
Delivers a string with the elements of the matrix.

Specified by:
toString in interface Vector
Returns:
a string for printing

getMatrix

public Matrix getMatrix()
Description copied from interface: Vector
Creates a matrix from s
This is a "kind" of typecast. Useful for matrix-/vectormultiplication

Specified by:
getMatrix in interface Vector
Returns:
vector as a matrix

SkewSym

public Matrix SkewSym()
Description copied from interface: Vector
Creates a skew-symmetrix matrix from s. s must have dimension 3 to do that.
 e.g.:         | a |                              |  0 -c   b |
       if  s = | b | , then s.Skewsym() returns   |  c  0  -a |
               | c |                              | -b  a   0 |
 
This matrix can be read as a cross product.

Specified by:
SkewSym in interface Vector
Returns:
returns skewsym from 3-dim vector. matrix has rank 2

clone

public java.lang.Object clone()
Description copied from interface: Vector
Clone a vector.

Specified by:
clone in interface Vector