sugr.linalg
Interface Vector

All Superinterfaces:
java.lang.Cloneable, java.io.Serializable
All Known Implementing Classes:
VectorImplColt

public interface Vector
extends java.lang.Cloneable, java.io.Serializable

Interface to vector-methods

Note that s stands for this vector (source), r means result vector and letter a is chosen for scalar values, in all cases a double precision floating point.

Author:
Daniel Goldbach, Norbert Fischer

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.
 boolean equals(java.lang.Object obj)
          Test, whether s and v are identical or not
 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.
 

Method Detail

plus

public Vector plus(Vector v)
Add two vectors: r = s+v

Parameters:
v - vector to add
Returns:
s+v

minus

public Vector minus(Vector v)
Substracts to vectors: r = s-v

Parameters:
v - vector to substract
Returns:
s-v

scalarmult

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

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)
calulates the cross product: r = s x v.

Parameters:
v - vector to create cross product with
Returns:
a Vector orthogonal to both s and v

mult

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

Parameters:
f - scalar value
Returns:
a Vector multiplicated with a scalar

copy

public Vector copy()
Copies s into a new vector r

Returns:
a Vector r independent from s with s=r

set

public void set(int pos,
                double value)
Set an element of s

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)
Set a part of a 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)
Gets an element from s

Parameters:
pos - Position to get element from. Starts with 0
Returns:
the element as an double

get

public Vector get(int i0,
                  int i1)
Get a part of the 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()
Returns the dimension of s

Returns:
a int containing the dimension

getLength

public double getLength()
Calculates the length of s.

Returns:
a = sqrt(s*s)

normF

public double normF()
Calculates the Frobenius norm of a vector, which is the same as the getLength().

Returns:
a = sqrt(s*s)

normM

public double normM()
Calculates the maximum norm of a vector

Returns:
a = max|v_i|

print

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

Parameters:
w - describes the width of a single element
d - number of decimals after comma

print

public void print()
Prints this matrix to stdout


printMatlab

public void printMatlab()
Prints this matrix in Matlab format to stdout


toString

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

Returns:
a string for printing

equals

public boolean equals(java.lang.Object obj)
Test, whether s and v are identical or not

Parameters:
obj - vector to test
Returns:
boolean value true, if identical, otherwise false

getMatrix

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

Returns:
vector as a matrix

SkewSym

public Matrix SkewSym()
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.

Returns:
returns skewsym from 3-dim vector. matrix has rank 2

clone

public java.lang.Object clone()
Clone a vector.

Returns:
a copy of the vector.