nr
Class Vec_wrapper

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

public class Vec_wrapper
extends java.lang.Object
implements Vec

Implements a simple Vec based on an external array. The underlying data is publicly available

Author:
Daniel Wachsstock

Field Summary
 double[] data
          the data underlying this Vec
 
Constructor Summary
Vec_wrapper(double[] array)
          Creates a new instance of Vec_wrapper
 
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
 

Field Detail

data

public final double[] data
the data underlying this Vec

Constructor Detail

Vec_wrapper

public Vec_wrapper(double[] array)
Creates a new instance of Vec_wrapper

Parameters:
array - the array to use
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