Constructor and Description |
---|
VectoriBase() |
Modifier and Type | Method and Description |
---|---|
VectoriBase |
clone() |
boolean |
equals(Vectori v1)
Returns true if the elements of this vector exactly equal those of vector
v1 . |
abstract int |
get(int i)
Gets a single element of this vector.
|
void |
get(int[] values)
Copies the elements of this vector into an array of doubles.
|
static java.lang.String |
getDefaultFormat()
Returns the default format string used in
toString . |
int |
infinityNorm()
Returns the infinity norm of this vector.
|
boolean |
isFixedSize()
Returns true if this vector is of fixed size.
|
int |
maxElement()
Returns the maximum element value.
|
int |
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.
|
int |
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(int[] values)
Sets the elements of this vector from an array of doubles.
|
abstract void |
set(int i,
int value)
Sets a single element of this vector.
|
void |
set(Vectori v)
Sets the values of this vector to those of another vector.
|
static void |
setDefaultFormat(java.lang.String fmtStr)
Sets the default format string used in
toString . |
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 (for integers) 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 (for
integers). |
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.
|
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 "%d". For a description of the format string syntax,
see NumberFormat
.public abstract int size()
public abstract int get(int i)
public void get(int[] values)
>=
the size of the vector.public abstract void set(int i, int value)
public void set(int[] values)
>=
the current vector size. Otherwise, the vector is resized to the
array length.public void set(Vectori v)
public boolean isFixedSize()
setSize
, or implicitly when used as a result for various
vector operations.isFixedSize
in interface Vectori
Vectori.setSize(int)
public void setSize(int n)
isFixedSize
returns false.setSize
in interface Vectori
n
- new sizeVectori.isFixedSize()
public double norm()
public double normSquared()
normSquared
in interface Vectori
public int oneNorm()
public int infinityNorm()
infinityNorm
in interface Vectori
public int maxElement()
maxElement
in interface Vectori
public int minElement()
minElement
in interface Vectori
public boolean equals(Vectori v1)
v1
. If the vectors have different sizes, false is
returned.public void write(java.io.PrintWriter pw, NumberFormat fmt) throws java.io.IOException
printf
style (for integers) 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 (for integers) 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 4 5 3 ]defines a vector of size 4.
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
integers). The exact format for this string is described in the
documentation for NumberFormat.set(String)
{NumberFormat.set(String)}. 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 Vectori
fmtStr
- printf style format stringNumberFormat
public java.lang.String toString(NumberFormat fmt)
printf
style format (for integers) as
decribed by the parameter NumberFormat
.public VectoriBase clone()