maspack.matrix

## Interface Vectori

• All Superinterfaces:
Clonable, java.lang.Cloneable
All Known Implementing Classes:
Vector2i, Vector3i, VectoriBase, VectorNi

```public interface Vectori
extends Clonable```
General interface for vectors of integers. The functionality is a subset of that provided by `Vector`, which defines vectors of doubles.
• ### Method Summary

All Methods
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.
• ### Methods inherited from interface maspack.util.Clonable

`clone`
• ### Method Detail

• #### size

`int size()`
Returns the number of elements in this vector.
Returns:
number of elements
• #### get

`int get(int i)`
Gets a single element of this vector.
Parameters:
`i` - element index
Returns:
element value
• #### get

`void get(int[] values)`
Copies the elements of this vector into an array of doubles. The array length must be `>=` the size of the vector.
Parameters:
`values` - array into which values are copied
• #### set

```void set(int i,
int value)```
Sets a single element of this vector.
Parameters:
`i` - element index
`value` - element value
• #### set

`void set(int[] values)`
Sets the elements of this vector from an array of doubles. If the vector has a fixed size, then the array must have a length `>=` the current vector size. Otherwise, the vector is resized to the array length.
Parameters:
`values` - array from which values are copied
• #### set

`void set(Vectori v)`
Sets the values of this vector to those of another vector.
Parameters:
`v` - vector from which values are copied
Throws:
`ImproperSizeException` - vectors have different sizes and this vector cannot be resized accordingly.
• #### isFixedSize

`boolean isFixedSize()`
Returns true if this vector is of fixed size. If this vector is not of fixed size, then it can be resized dynamically, either explicitly using `setSize`, or implicitly when used as a result for various vector operations.
Returns:
true if this vector is of fixed size
`setSize(int)`
• #### setSize

```void setSize(int n)
throws java.lang.UnsupportedOperationException```
Sets the size of this vector. This operation is only supported if `isFixedSize` returns false.
Parameters:
`n` - new size
Throws:
`java.lang.UnsupportedOperationException` - if this operation is not supported
`isFixedSize()`
• #### norm

`double norm()`
Returns the 2 norm of this vector. This is the square root of the sum of the squares of the elements.
Returns:
vector 2 norm
• #### normSquared

`double normSquared()`
Returns the square of the 2 norm of this vector. This is the sum of the squares of the elements.
Returns:
square of the 2 norm
• #### oneNorm

`int oneNorm()`
Returns the 1 norm of this vector. This is the sum of the absolute values of the elements.
Returns:
vector 1 norm
• #### infinityNorm

`int infinityNorm()`
Returns the infinity norm of this vector. This is the maximum absolute value over all elements.
Returns:
vector infinity norm
• #### maxElement

`int maxElement()`
Returns the maximum element value.
Returns:
maximal element
• #### minElement

`int minElement()`
Returns the minimum element value.
Returns:
minimal element
• #### equals

`boolean equals(Vectori v1)`
Returns true if the elements of this vector exactly equal those of vector `v1`. If the vectors have different sizes, false is returned.
Parameters:
`v1` - vector to compare with
Returns:
false if the vectors are not equal or have different sizes
• #### write

```void write(java.io.PrintWriter pw,
NumberFormat fmt)
throws java.io.IOException```
Writes the contents of this vector to a PrintWriter. Element values are separated by spaces, and each element is formatted using a C `printf` style (for integers) as decribed by the parameter `NumberFormat`.
Parameters:
`pw` - PrintWriter to write this vector to
`fmt` - numeric format
Throws:
`java.io.IOException`
• #### write

```void write(java.io.PrintWriter pw,
NumberFormat fmt,
boolean withBrackets)
throws java.io.IOException```
Writes the contents of this vector to a PrintWriter. Element values are separated by spaces, and optionally surrounded by square brackets ```[ ]``` if `withBrackets` is set true. Each element is formatted using a C `printf` style (for integers) as decribed by the parameter `NumberFormat`.
Parameters:
`pw` - PrintWriter to write this vector to
`fmt` - numeric format
`withBrackets` - if true, causes the output to be surrounded by square brackets.
Throws:
`java.io.IOException`
• #### scan

```void scan(ReaderTokenizer rtok)
throws java.io.IOException```
Sets the contents of this vector to values read from a ReaderTokenizer. The input should consist of a sequence of numbers, separated by white space and optionally surrounded by square brackets `[ ]`.

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.
Parameters:
`rtok` - Tokenizer from which vector values are read. Number parsing should be enabled.
Throws:
`ImproperSizeException` - if this vector has a fixed size which is incompatible with the input
`java.io.IOException`
• #### toString

`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). 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.
Parameters:
`fmtStr` - printf style format string
Returns:
String representation of this vector
`NumberFormat`
`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`.
`fmt` - numeric format