geometry
Class Vector

java.lang.Object
  extended bygeometry.Vector

public class Vector
extends java.lang.Object

Represents a Column-Vector of doubles (least index is 1).

Author:
karsten

Field Summary
 JLinAlg.Vector v
          The internal representation as a JLinAlg vector.
 
Constructor Summary
Vector(double[] coords)
          Constructs a vector with the given entries.
Vector(int dim)
          Constructs a zero-vector.
Vector(int dim, int coord)
          Constructs a unit-coordinate-vector.
Vector(int dim, int coord, double length)
          Constructs a coordinate-vector.
Vector(JLinAlg.Vector vector)
          Constructs a vector directly referencing the given JLinAlg vector.
 
Method Summary
 Vector add(Vector other)
          Calculates the sum of two vectors.
 Vector copy()
          Returns a deep copy of this vector.
 int dim()
          Returns the dimension of this vector.
 double get(int i)
          Gets an entry of the vector.
 boolean isZero()
          Tests whether this is the zero vector
 double scalarProduct(Vector other)
          Calculates the scalar product of two vectors.
 Vector scale(double factor)
          Calculates a multiple of this vector.
 void set(int i, double value)
          Sets an entry of the vector to the given value.
 Vector subtract(Vector other)
          Calculates the difference beween two vectors.
 Vector subVector(int start, int end)
          Copies a part of the entries into a new vector.
 java.lang.String toString()
          Returns a String representation of this vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

v

public JLinAlg.Vector v
The internal representation as a JLinAlg vector.

Constructor Detail

Vector

public Vector(int dim)
Constructs a zero-vector. All entries will be zero.

Parameters:
dim - the number of coordinates

Vector

public Vector(int dim,
              int coord,
              double length)
Constructs a coordinate-vector. All entries except one will be zero.

Parameters:
dim - the number of coordinates
coord - the index of the only non-zero coordinate of this vector
length - the length of the vector

Vector

public Vector(int dim,
              int coord)
Constructs a unit-coordinate-vector. One entry will be one, the others will be zero.

Parameters:
dim - the number of coordinates
coord - the index of the only non-zero coordinate of this vector

Vector

public Vector(double[] coords)
Constructs a vector with the given entries. Attention: The first entry coords[0] will be the first entry of the vecor get(1)

Parameters:
coords - the entries of the vector

Vector

public Vector(JLinAlg.Vector vector)
Constructs a vector directly referencing the given JLinAlg vector. The entries of the given vector have to be instances of DoubleWrapper.

Parameters:
vector - the original vector to be referenced
Method Detail

subVector

public Vector subVector(int start,
                        int end)
Copies a part of the entries into a new vector.

Parameters:
start - the first entry to be copied
end - the last entry to be copied
Returns:
a copy of the selected entries

set

public void set(int i,
                double value)
Sets an entry of the vector to the given value. The first index is 1.

Parameters:
i - the index of the changing coordinate
value - the new value for the selected coordinate

get

public double get(int i)
Gets an entry of the vector. The first index is 1.

Parameters:
i - the index of a coordinate
Returns:
the value at the selected coordinate

dim

public int dim()
Returns the dimension of this vector.

Returns:
the length of this vector

subtract

public Vector subtract(Vector other)
Calculates the difference beween two vectors.

Parameters:
other - the vector, which is to be subtracted from this vector
Returns:
this vector minus the other vector

add

public Vector add(Vector other)
Calculates the sum of two vectors.

Parameters:
other - the vector, which is to be added to this vector
Returns:
this vector plus the other vector

scale

public Vector scale(double factor)
Calculates a multiple of this vector.

Parameters:
factor - the value this vector is to be multiplied with
Returns:
this vector multiplied by the factor

scalarProduct

public double scalarProduct(Vector other)
Calculates the scalar product of two vectors.

Parameters:
other - the vector, which is to be multiplied with this vector
Returns:
the scalar product of this vector and the other vector

toString

public java.lang.String toString()
Returns a String representation of this vector.

Returns:
a string containing every entry of this vector

copy

public Vector copy()
Returns a deep copy of this vector.


isZero

public boolean isZero()
Tests whether this is the zero vector

Returns:
true iff all entries are zero