public interface Vector extends Clonable
setSize
for resizing, which
can be used unless the vector size is fixed (which can be determined using
isFixedSize
).
This base class does not publicly support vector operations such as addition
or scaling. The reason for this is that specific implementations may have a
specialized structure which could be compromised by arbitrary operations. For
instance, an implementation that represents only unit vectors, should not
allow an add
operation.
Of course, it is possible to corrupt any special implementation structure
using the set
methods provided in this base class, but it was
felt that not including such routines would be overly restrictive. It is
therefore up to the user to safeguard implementation integrity against misuse
of the set
methods.
Note that indices for vector elements are zerobased, so that the range of
valid indices for a vector of length n is [0, ... , n1]
.
Modifier and Type  Method and Description 

double 
dot(Vector v1)
Returns the dot product of this vector and v1.

boolean 
epsilonEquals(Vector v1,
double eps)
Returns true if the elements of this vector equal those of vector
v1 within a prescribed tolerance epsilon . 
boolean 
equals(Vector v1)
Returns true if the elements of this vector exactly equal those of vector
v1 . 
void 
get(double[] values)
Copies the elements of this vector into an array of doubles.

double 
get(int i)
Gets a single element of this vector.

void 
get(Vector v1)
Copies the elements of this vector into another vector object.

double 
infinityNorm()
Returns the infinity norm of this vector.

boolean 
isFixedSize()
Returns true if this vector is of fixed size.

double 
maxElement()
Returns the maximum element value.

double 
minElement()
Returns the minimum element value.

double 
norm()
Returns the 2 norm of this vector.

double 
normSquared()
Returns the square of the 2 norm of this vector.

double 
oneNorm()
Returns the 1 norm of this vector.

void 
scan(ReaderTokenizer rtok)
Sets the contents of this vector to values read from a ReaderTokenizer.

void 
set(double[] values)
Sets the elements of this vector from an array of doubles.

int 
set(double[] values,
int idx)
Sets the elements of this vector from an array of doubles,
starting from a particular location.

void 
set(int i,
double value)
Sets a single element of this vector.

void 
set(Matrix M)
Sets the values of this vector to those of a matrix object.

void 
set(Vector v)
}
Sets the values of this vector to those of another vector.

void 
setSize(int n)
Sets the size of this vector.

int 
size()
Returns the number of elements in this vector.

java.lang.String 
toString(NumberFormat fmt)
Returns a String representation of this vector, in which each element is
formatted using a C
printf style format as decribed by the
parameter NumberFormat . 
java.lang.String 
toString(java.lang.String fmtStr)
Returns a String representation of this vector, in which each element is
formatted using a C
printf style format string. 
void 
write(java.io.PrintWriter pw,
NumberFormat fmt)
Writes the contents of this vector to a PrintWriter.

void 
write(java.io.PrintWriter pw,
NumberFormat fmt,
boolean withBrackets)
Writes the contents of this vector to a PrintWriter.

int size()
double get(int i)
i
 element indexvoid get(double[] values)
>=
the size of the vector.values
 array into which values are copiedvoid get(Vector v1) throws ImproperSizeException
v1
 vector object into which values are copiedImproperSizeException
 if the vector objects have different sizesvoid set(int i, double value)
i
 element indexvalue
 element valuevoid set(double[] values)
>=
the
current vector size. Otherwise, the vector is resized to the array
length.values
 array from which values are copiedint set(double[] values, int idx)
values
 array from which values are copiedidx
 starting point within values from which copying should beginvoid set(Vector v)
v
 vector from which values are copiedImproperSizeException
 vectors have different sizes and this vector cannot be resized
accordingly.void set(Matrix M)
M
 matrix from which values are copiedImproperSizeException
 if this vector cannot be sized to match the dimensions of the matrix.boolean isFixedSize()
setSize
, or implicitly when used as a result for various
vector operations.setSize(int)
void setSize(int n) throws java.lang.UnsupportedOperationException
isFixedSize
returns false.n
 new sizejava.lang.UnsupportedOperationException
 if this operation is not supportedisFixedSize()
double norm()
double normSquared()
double oneNorm()
double infinityNorm()
double maxElement()
double minElement()
double dot(Vector v1)
v1
 righthand vectorImproperSizeException
 if this vector and v1 have different sizesboolean epsilonEquals(Vector v1, double eps)
v1
within a prescribed tolerance epsilon
.
If the vectors have different sizes, false is returned.v1
 vector to compare witheps
 comparison toleranceboolean equals(Vector v1)
v1
. If the vectors have different sizes, false is
returned.v1
 vector to compare withvoid write(java.io.PrintWriter pw, NumberFormat fmt) throws java.io.IOException
printf
style as decribed by the parameter
NumberFormat
.pw
 PrintWriter to write this vector tofmt
 numeric formatjava.io.IOException
void write(java.io.PrintWriter pw, NumberFormat fmt, boolean withBrackets) throws java.io.IOException
[ ]
if withBrackets
is set true. Each
element is formatted using a C printf
style as decribed by
the parameter NumberFormat
.pw
 PrintWriter to write this vector tofmt
 numeric formatwithBrackets
 if true, causes the output to be surrounded by square brackets.java.io.IOException
void scan(ReaderTokenizer rtok) throws java.io.IOException
[ ]
.
If the input is not surrounded by square brackets, then the number of
values should equal the current size
of this vector.
If the input is surrounded by square brackets, then all values up to the
closing bracket are read, and the resulting number of values should either
equal the current size
of this vector, or this vector should
be resizeable to fit the input. For example,
[ 1.2 4 5 3.1 ]defines a vector of size 4.
rtok
 Tokenizer from which vector values are read. Number parsing should be
enabled.ImproperSizeException
 if this vector has a fixed size which is incompatible with the inputjava.io.IOException
java.lang.String toString(java.lang.String fmtStr)
printf
style format string. The
exact format for this string is described in the documentation for
NumberFormat.set(String)
{NumberFormat.set(String)}.fmtStr
 printf style format stringNumberFormat
java.lang.String toString(NumberFormat fmt)
printf
style format as decribed by the
parameter NumberFormat
.fmt
 numeric format