public abstract class VectorBase extends java.lang.Object implements Vector
Vector
.Constructor and Description |
---|
VectorBase() |
Modifier and Type | Method and Description |
---|---|
VectorBase |
clone() |
boolean |
containsNaN()
Returns true if any element of this vector is not a number.
|
VectorNd |
copy() |
VectorNd |
copyAndAdd(Vector v2) |
VectorNd |
copyAndNegate() |
VectorNd |
copyAndScale(double s) |
VectorNd |
copyAndSub(Vector v2) |
VectorNd |
copyAndSubLeft(Vector v2) |
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.
|
abstract 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.
|
static java.lang.String |
getDefaultFormat()
Returns the default format string used in
toString . |
boolean |
hasInf()
Returns true if one or more elements of this vector contains +/-INF.
|
boolean |
hasNaN()
Returns true if one or more elements of this vector is NaN.
|
double |
infinityNorm()
Returns the infinity norm of this vector.
|
static boolean |
isColumnVectorStringsVertical()
Returns true if the string representation of column vectors is vertical.
|
boolean |
isFixedSize()
Returns true if this vector is of fixed size.
|
boolean |
isRowVector() |
boolean |
isWritable() |
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 |
scan(ReaderTokenizer rtok,
java.lang.Object obj) |
void |
set(double[] values)
Sets the elements of this vector from an array of doubles.
|
abstract 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.
|
static void |
setColumnVectorStringsVertical(boolean enable)
Sets the string representation of column vectors to be vertical.
|
static void |
setDefaultFormat(java.lang.String fmtStr)
Sets the default format string used in
toString . |
boolean |
setRowVector(boolean isRow) |
void |
setSize(int n)
Sets the size of this vector.
|
abstract int |
size()
Returns the number of elements in this vector.
|
java.lang.String |
toString()
Returns a String representation of this vector, using the default format
returned by
getDefaultFormat . |
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.
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object obj) |
void |
writeToFile(java.lang.String fileName,
java.lang.String fmtStr) |
public static void setDefaultFormat(java.lang.String fmtStr)
toString
. For
a description of the format string syntax, see NumberFormat
.fmtStr
- new format stringjava.lang.IllegalArgumentException
- if the format string is invalidgetDefaultFormat()
public static java.lang.String getDefaultFormat()
toString
. If
unset, this string is "%g". For a description of the format string syntax,
see NumberFormat
.public static void setColumnVectorStringsVertical(boolean enable)
false
.enable
- if true, column vector strings are arranged vertically.isColumnVectorStringsVertical()
public static boolean isColumnVectorStringsVertical()
setColumnVectorStringsVertical(boolean)
public abstract int size()
public abstract double get(int i)
public void get(double[] values)
>=
the size of the vector.public void get(Vector v1) throws ImproperSizeException
get
in interface Vector
v1
- vector object into which values are copiedImproperSizeException
- if the vector objects have different sizespublic abstract void set(int i, double value)
public void set(double[] values)
>=
the
current vector size. Otherwise, the vector is resized to the array
length.public void set(Vector v)
public void set(Matrix M)
public boolean isFixedSize()
setSize
, or implicitly when used as a result for various
vector operations.isFixedSize
in interface Vector
Vector.setSize(int)
public void setSize(int n)
isFixedSize
returns false.setSize
in interface Vector
n
- new sizeVector.isFixedSize()
public double norm()
public double normSquared()
normSquared
in interface Vector
public double oneNorm()
public double infinityNorm()
infinityNorm
in interface Vector
public double maxElement()
maxElement
in interface Vector
public double minElement()
minElement
in interface Vector
public double dot(Vector v1) throws ImproperSizeException
dot
in interface Vector
v1
- right-hand vectorImproperSizeException
- if this vector and v1 have different sizespublic boolean epsilonEquals(Vector v1, double eps)
v1
within a prescribed tolerance epsilon
.
If the vectors have different sizes, false is returned.epsilonEquals
in interface Vector
v1
- vector to compare witheps
- comparison tolerancepublic boolean equals(Vector v1)
v1
. If the vectors have different sizes, false is
returned.public java.lang.String toString()
getDefaultFormat
.toString
in class java.lang.Object
toString(String)
public java.lang.String toString(java.lang.String fmtStr)
printf
style format string. For a
description of the format string syntax, see NumberFormat
. Note that when called numerous
times, toString(NumberFormat)
will be more
efficient because the NumberFormat
will
not need to be recreated each time from a specification string.toString
in interface Vector
fmtStr
- numeric format specificationisColumnVectorStringsVertical()
public java.lang.String toString(NumberFormat fmt)
printf
style format as decribed by the
parameter NumberFormat
.toString
in interface Vector
fmt
- numeric formatisColumnVectorStringsVertical()
public void writeToFile(java.lang.String fileName, java.lang.String fmtStr)
public void write(java.io.PrintWriter pw, NumberFormat fmt) throws java.io.IOException
printf
style as decribed by the parameter
NumberFormat
.public 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
.public 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.
public boolean isWritable()
public void scan(ReaderTokenizer rtok, java.lang.Object obj) throws java.io.IOException
java.io.IOException
public void write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object obj) throws java.io.IOException
java.io.IOException
public boolean containsNaN()
public VectorNd copy()
public VectorNd copyAndNegate()
public VectorNd copyAndScale(double s)
public boolean isRowVector()
public boolean setRowVector(boolean isRow)
public boolean hasNaN()
public boolean hasInf()
public VectorBase clone()