fhm.edu.fem.calc.objects
Class Vector

java.lang.Object
  extended by fhm.edu.fem.calc.objects.Vector
All Implemented Interfaces:
MathObject

public class Vector
extends java.lang.Object
implements MathObject

Class Description: This class represents a vector. Do not confuse it with the Vector class of the Java API which is a thread-safe implementation of ArrayList. The index i starts at 1 not at 0.

Author:
Thomas Woellert (thomas@woellert.net), Stefan Weissbach (weissbst@gmx.de)

Field Summary
protected  double[] data
           
protected  java.lang.String name
           
protected  int size
           
 
Constructor Summary
Vector(java.lang.String name)
          Construct a new vector
Vector(java.lang.String name, double[] array)
          Construct a new vector with the given initial data
Vector(java.lang.String name, int size)
          Construct a new vector with the given initiale size
 
Method Summary
 java.lang.Object clone()
          Clone the vector
 java.lang.String getName()
          Retrieve the name of this matrix
 double getValue(int index)
          Retrieve a value from the vector
 Vector mult(double value)
          Multiply all values in the vector with the given value and return the new resulting vector
 Vector mult(Matrix matrix, boolean transponate)
          Multiply this vector with the given matrix and return the new resulting vector
 double mult(Vector vector)
          Multiply this vector with the given vector and return the new resulting vector
 Vector normVectorTo(double normValue)
          Norm the vector to the given number (meaning: the max value is equal to the given number, all other smaller values are adjusted based on the max value)
 void setName(java.lang.String name)
          Set a new name for this matrix
 void setValue(int index, double value)
          Replace an existing value
 int size()
          Retrieve the current number of elements in the vector
 java.lang.String toString()
          toString Implementation
 java.lang.String toString(int numberOfValues)
          toString Implementation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected double[] data

name

protected java.lang.String name

size

protected int size
Constructor Detail

Vector

public Vector(java.lang.String name)
Construct a new vector

Parameters:
name, - the name of the vector

Vector

public Vector(java.lang.String name,
              double[] array)
Construct a new vector with the given initial data

Parameters:
name, - the name of the vector
double[], - the data array

Vector

public Vector(java.lang.String name,
              int size)
Construct a new vector with the given initiale size

Parameters:
name, - the name of the vector
size, - the number of expected elements in the vector
Method Detail

clone

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

Overrides:
clone in class java.lang.Object
Returns:
the cloned vector

getName

public java.lang.String getName()
Retrieve the name of this matrix

Returns:
the name

getValue

public double getValue(int index)
                throws java.lang.IndexOutOfBoundsException
Retrieve a value from the vector

Parameters:
index, - the index of the value to retrieve (first index is 1 not 0)
Returns:
the retrieved value
Throws:
java.lang.IndexOutOfBoundsException

mult

public Vector mult(double value)
Multiply all values in the vector with the given value and return the new resulting vector

Parameters:
value, - the value to multiply the vector with
Returns:
the new resulting vector

mult

public Vector mult(Matrix matrix,
                   boolean transponate)
            throws java.lang.IndexOutOfBoundsException
Multiply this vector with the given matrix and return the new resulting vector

Parameters:
matrix, - the matrix to multiply the vector with
boolean, - true if the vector is transponated, false otherwise
Returns:
the new resulting vector
Throws:
java.lang.IndexOutOfBoundsException

mult

public double mult(Vector vector)
            throws java.lang.IndexOutOfBoundsException
Multiply this vector with the given vector and return the new resulting vector

Parameters:
vector, - the vector to multiply the vector with
Returns:
the result number
Throws:
java.lang.IndexOutOfBoundsException

normVectorTo

public Vector normVectorTo(double normValue)
Norm the vector to the given number (meaning: the max value is equal to the given number, all other smaller values are adjusted based on the max value)

Parameters:
normValue, - the max value to norm to
Returns:
Vector, the new adjusted vector (the original one is not changed)

setName

public void setName(java.lang.String name)
Set a new name for this matrix

Parameters:
name -

setValue

public void setValue(int index,
                     double value)
              throws java.lang.IndexOutOfBoundsException
Replace an existing value

Parameters:
index, - the index of the value (first index is 1 not 0)
value, - the new value
Throws:
java.lang.IndexOutOfBoundsException

size

public int size()
Retrieve the current number of elements in the vector

Returns:

toString

public java.lang.String toString()
toString Implementation

Overrides:
toString in class java.lang.Object
Returns:
the string

toString

public java.lang.String toString(int numberOfValues)
toString Implementation

Parameters:
int, - the number of values to display
Returns:
the string