|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.VectorBase
public abstract class VectorBase
Base implementation of Vector
.
Constructor Summary | |
---|---|
VectorBase()
|
Method Summary | |
---|---|
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 |
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()
|
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. |
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public VectorBase()
Method Detail |
---|
public static void setDefaultFormat(java.lang.String fmtStr)
toString
. For
a description of the format string syntax, see NumberFormat
.
fmtStr
- new format string
java.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()
size
in interface Vector
public abstract double get(int i)
get
in interface Vector
i
- element index
public void get(double[] values)
get
in interface Vector
values
- array into which values are copiedpublic void get(Vector v1) throws ImproperSizeException
get
in interface Vector
v1
- vector object into which values are copied
ImproperSizeException
public abstract void set(int i, double value)
set
in interface Vector
i
- element indexvalue
- element valuepublic void set(double[] values)
set
in interface Vector
values
- array from which values are copiedpublic void set(Vector v)
set
in interface Vector
v
- vector from which values are copiedpublic void set(Matrix M)
set
in interface Vector
M
- matrix from which values are copiedpublic 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()
norm
in interface Vector
public double normSquared()
normSquared
in interface Vector
public double oneNorm()
oneNorm
in interface Vector
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 vector
ImproperSizeException
- 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 tolerance
public boolean equals(Vector v1)
v1
. If the vectors have different sizes, false is
returned.
equals
in interface Vector
v1
- vector to compare with
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.
fmtStr
- numeric format specification
isColumnVectorStringsVertical()
public java.lang.String toString(NumberFormat fmt)
printf
style format as decribed by the
parameter NumberFormat
.
toString
in interface Vector
fmt
- numeric format
isColumnVectorStringsVertical()
public void write(java.io.PrintWriter pw, NumberFormat fmt) throws java.io.IOException
printf
style as decribed by the parameter
NumberFormat
.
write
in interface Vector
pw
- PrintWriter to write this vector tofmt
- numeric format
java.io.IOException
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
.
write
in interface Vector
pw
- PrintWriter to write this vector tofmt
- numeric formatwithBrackets
- if true, causes the output to be surrounded by square brackets.
java.io.IOException
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.
scan
in interface Vector
rtok
- Tokenizer from which vector values are read. Number parsing should be
enabled.
java.io.IOException
public boolean containsNaN()
public VectorNd copy()
public VectorNd copyAndNegate()
public VectorNd copyAndAdd(Vector v2)
public VectorNd copyAndSub(Vector v2)
public VectorNd copyAndSubLeft(Vector v2)
public VectorNd copyAndScale(double s)
public boolean isRowVector()
public boolean setRowVector(boolean isRow)
public boolean hasNaN()
public VectorBase clone()
clone
in interface Clonable
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |