nr
Class Vec_array

java.lang.Object
  extended by nr.Vec_array
All Implemented Interfaces:
Vec

public class Vec_array
extends java.lang.Object
implements Vec

Implements a simple Vec based on a fixed array

Author:
Daniel Wachsstock

Constructor Summary
Vec_array(double[] data)
          Creates a new instance of Vec_array by copying the input array
Vec_array(int size)
          Creates a new instance of Vec_array.
Vec_array(Vec_array v)
          Copy-creates a new instance of Vec_array.
Vec_array(Vec v)
          Copy-create a new instance of Vec_array.
 
Method Summary
 double[] asArray()
          get the data
 Vec copy()
          return a copy of this, or some version that the user can manipulate at will.
 double get(int i)
          the i-th element
 void set(double[] d)
          Copy the vector from an array
 void set(int i, double d)
          set the i-th element
 void set(Vec v)
          Copy the vector from an array
 int size()
          the size of the vector
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vec_array

public Vec_array(int size)
Creates a new instance of Vec_array.

Parameters:
size - the number of dimensions of this vector

Vec_array

public Vec_array(double[] data)
Creates a new instance of Vec_array by copying the input array

Parameters:
data - the array to copy

Vec_array

public Vec_array(Vec_array v)
Copy-creates a new instance of Vec_array.

Parameters:
v - the vector to copy

Vec_array

public Vec_array(Vec v)
Copy-create a new instance of Vec_array. Less efficient than Vec_array(Vec_array) since it uses the interface to get elements

Parameters:
v - the vector to copy
Method Detail

get

public double get(int i)
Description copied from interface: Vec
the i-th element

Specified by:
get in interface Vec

set

public void set(int i,
                double d)
Description copied from interface: Vec
set the i-th element

Specified by:
set in interface Vec
Parameters:
i - the element to set
d - the value to set it to

set

public void set(double[] d)
Description copied from interface: Vec
Copy the vector from an array

Specified by:
set in interface Vec
Parameters:
d - the array to copy from

set

public void set(Vec v)
Description copied from interface: Vec
Copy the vector from an array

Specified by:
set in interface Vec
Parameters:
v - the vector to copy from

size

public int size()
Description copied from interface: Vec
the size of the vector

Specified by:
size in interface Vec

copy

public Vec copy()
Description copied from interface: Vec
return a copy of this, or some version that the user can manipulate at will. If the implementation of this is immutable, can return the original, or the implementation can do some kind of copy-on-write.

Specified by:
copy in interface Vec
Returns:
a copy of the data

asArray

public double[] asArray()
Description copied from interface: Vec
get the data

Specified by:
asArray in interface Vec
Returns:
the data as a double[]

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object