|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.mines.jtk.opt.ArrayVect1f
public class ArrayVect1f
Implements a Vect by wrapping an array of floats. The embedded data are exposed by a getData method. For all practical purposes this member is public, except that this class must always point to the same array. The implementation as an array is the point of this class, to avoid duplicate implementations elsewhere. Multiple inheritance is prohibited and prevents the mixin pattern, but you can share the wrapped array as a private member of your own class, and easily delegate all implemented methods.
| Field Summary | |
|---|---|
protected float[] |
_data
Array of wrapped data |
protected int |
_firstSample
This is the first sample to treat as non-zero. |
protected double |
_variance
Variance of each ArrayVect1f |
| Constructor Summary | |
|---|---|
protected |
ArrayVect1f()
Constructor for derived classes that call init() |
|
ArrayVect1f(float[] data,
int firstSample,
double variance)
Construct from an array of data. |
| Method Summary | |
|---|---|
void |
add(double scaleThis,
double scaleOther,
VectConst other)
Add a scaled version of another vector to a scaled version of this vector. |
ArrayVect1f |
clone()
|
void |
constrain()
Optionally apply a hard constraint (such as an inequality) to the current vector. |
void |
dispose()
Optionally free any resources held by this object. |
double |
dot(VectConst other)
Return the Cartesian dot product of this vector with another vector (not including any inverse covariance). |
static void |
extractContainer(float[][] data,
VectContainer container)
Extract 2D array from a VectContainer with instances of ArrayVect1f. |
static void |
fillContainer(VectContainer container,
int[] firstSamples,
float[][] data,
double variance)
Fill a VectContainer with instances of ArrayVect1f from a 2D array. |
float[] |
getData()
Get the embedded data |
int |
getFirstSample()
This is the first sample to treat as non-zero. |
int |
getSize()
Return the size of the embedded array |
protected void |
init(float[] data,
int firstSample,
double variance)
Construct from an array of data. |
double |
magnitude()
This is the dot product of the vector with itself premultiplied by the inverse covariance. |
void |
multiplyInverseCovariance()
Optionally multiply a vector by the inverse covariance matrix. |
void |
postCondition()
Apply a linear filter that enhances components that should be optimized first, and suppresses components of lesser importance. |
void |
project(double scaleThis,
double scaleOther,
VectConst other)
Project another vector onto the space of this vector, then scale, and add to a scaled version of this vector. |
void |
setData(float[] data)
Set the internal data array to new values. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected float[] _data
protected double _variance
protected int _firstSample
| Constructor Detail |
|---|
public ArrayVect1f(float[] data,
int firstSample,
double variance)
data - This is the data that will be manipulated.firstSample - This is the first sample to treat as non-zero.
Earlier samples should be constrained to zero.variance - The method multiplyInverseCovariance()
will divide all samples by this number. Pass a value
of 1 if you do not care.protected ArrayVect1f()
| Method Detail |
|---|
protected void init(float[] data,
int firstSample,
double variance)
data - This is the data that will be manipulated.firstSample - This is the first sample to treat as non-zero.
Earlier samples should be constrained to zero.variance - The method multiplyInverseCovariance()
will divide all samples by this number. Pass a value
of 1 if you do not care.public int getFirstSample()
public int getSize()
public float[] getData()
public void setData(float[] data)
data - Copy this data into the internal wrapped array.
public static void fillContainer(VectContainer container,
int[] firstSamples,
float[][] data,
double variance)
container - Container to be filled with instances of float[]
wrapped as ArrayVect1f.data - Array of data to be wrapped.firstSamples - Array of first non-zero samples in each array.variance - Variance of each ArrayVect1f
public static void extractContainer(float[][] data,
VectContainer container)
data - Array of data to be extracted.container - Container of ArrayVect1f to be extracted from.public ArrayVect1f clone()
clone in interface Vectclone in interface VectConstclone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic double dot(VectConst other)
VectConst
dot in interface VectConstother - The vector to be dotted.
public void dispose()
Vect
dispose in interface Vectpublic void multiplyInverseCovariance()
Vect
multiplyInverseCovariance in interface Vectpublic void constrain()
Vect
constrain in interface Vect
public void add(double scaleThis,
double scaleOther,
VectConst other)
Vect
add in interface VectscaleThis - Multiply this vector by this scalar before adding.scaleOther - Multiply the other vector by this scalar before adding.other - The other vector to be multiplied.
public void project(double scaleThis,
double scaleOther,
VectConst other)
Vect
project in interface VectscaleThis - Multiply this vector by this scalar before adding.scaleOther - Multiply the other vector by this scalar before adding.other - The other vector to be projected, scaled, and added.public double magnitude()
VectConst
Vect vect = (Vect) this.clone();
vect.multiplyInverseCovariance();
return this.dot(vect);
But you can usually avoid the clone.
magnitude in interface VectConstpublic void postCondition()
Vect
postCondition in interface Vect
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||