public interface Vectori extends Clonable
Vector
, which defines vectors of doubles.Modifier and Type | Method and Description |
---|---|
boolean |
equals(Vectori v1)
Returns true if the elements of this vector exactly equal those of vector
v1 . |
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.
|
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.
|
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.
|
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 (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.
|
int size()
int get(int i)
i
- element indexvoid get(int[] values)
>=
the size of the vector.values
- array into which values are copiedvoid set(int i, int value)
i
- element indexvalue
- element valuevoid set(int[] values)
>=
the current vector size. Otherwise, the vector is resized to the
array length.values
- array from which values are copiedvoid set(Vectori v)
v
- vector from which values are copiedImproperSizeException
- vectors have different sizes and this vector cannot be resized
accordingly.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()
int oneNorm()
int infinityNorm()
int maxElement()
int minElement()
boolean equals(Vectori 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 (for integers) 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 (for integers) 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 4 5 3 ]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 (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.fmtStr
- printf style format stringNumberFormat
java.lang.String toString(NumberFormat fmt)
printf
style format (for integers) as
decribed by the parameter NumberFormat
.fmt
- numeric format