edu.mines.jtk.opt
Class ScalarVect

java.lang.Object
  extended by edu.mines.jtk.opt.ScalarVect
All Implemented Interfaces:
Vect, VectConst, java.io.Serializable, java.lang.Cloneable

public class ScalarVect
extends java.lang.Object
implements Vect

Implements a Vect by wrapping a single double

See Also:
Serialized Form

Field Summary
protected  double _value
          wrapped data
protected  double _variance
          variance for value
 
Constructor Summary
protected ScalarVect()
          To be used with init()
  ScalarVect(double value, double variance)
          Specify the initial value
 
Method Summary
 void add(double scaleThis, double scaleOther, VectConst other)
          Add a scaled version of another vector to a scaled version of this vector.
 ScalarVect 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).
 double get()
          Get the value of the scalar.
 void init(double value, double variance)
          Initialize the Vect.
 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 set(double value)
          Set the value of the scalar.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_value

protected transient double _value
wrapped data


_variance

protected transient double _variance
variance for value

Constructor Detail

ScalarVect

public ScalarVect(double value,
                  double variance)
Specify the initial value

Parameters:
value - The initial value of the wrapped scalar
variance - The method multiplyInverseCovariance() will divide the scalar by this number. Pass a value of 1 if you do not care.

ScalarVect

protected ScalarVect()
To be used with init()

Method Detail

init

public final void init(double value,
                       double variance)
Initialize the Vect.

Parameters:
value - The initial value of the wrapped scalar .
variance - The method multiplyInverseCovariance() will divide the scalar by this number. Pass a value of 1 if you do not care.

get

public double get()
Get the value of the scalar.

Returns:
The wrapped scalar.

set

public void set(double value)
Set the value of the scalar.

Parameters:
value - The new value of the wrapped scalar.

clone

public ScalarVect clone()
Specified by:
clone in interface Vect
Specified by:
clone in interface VectConst
Overrides:
clone in class java.lang.Object

dot

public double dot(VectConst other)
Description copied from interface: VectConst
Return the Cartesian dot product of this vector with another vector (not including any inverse covariance). [Feel free to normalize by the number of elements in the array, if the inverse convariance is defined consistently.]

Specified by:
dot in interface VectConst
Parameters:
other - The vector to be dotted.
Returns:
The dot product.

toString

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

dispose

public void dispose()
Description copied from interface: Vect
Optionally free any resources held by this object. Will not be used again. This method can safely do nothing.

Specified by:
dispose in interface Vect

multiplyInverseCovariance

public void multiplyInverseCovariance()
Description copied from interface: Vect
Optionally multiply a vector by the inverse covariance matrix. Also called preconditioning. A method that does nothing is equivalent to an identity. [vect.magnitude() should return the same value as vect.dot(((Vect)vect.clone()).multiplyInverseCovariance()); This should enhance components that should be discouraged in the model and suppress components that are preferred. This operation slows convergence. This filter must be linear. For inversions, you should at least implement a scaling operation that correctly weights errors in the data versus the magnitude of the model.]

Specified by:
multiplyInverseCovariance in interface Vect

constrain

public void constrain()
Description copied from interface: Vect
Optionally apply a hard constraint (such as an inequality) to the current vector. This is used only by a non-linear optimization. This method can safely do nothing.

Specified by:
constrain in interface Vect

postCondition

public void postCondition()
Description copied from interface: Vect
Apply a linear filter that enhances components that should be optimized first, and suppresses components of lesser importance. Also called post-conditioning. This filter prefilters all perturbations of the model and speeds convergence on components of most importance in the model. The same result can be accomplished by Transform.inverseHessian(), but this location may be more convenient. Use this location if the conditioning is independent of the Transform and dependent on the implementation of the model. This method can safely do nothing.

Specified by:
postCondition in interface Vect

add

public void add(double scaleThis,
                double scaleOther,
                VectConst other)
Description copied from interface: Vect
Add a scaled version of another vector to a scaled version of this vector. [If this==other, then the result should be the same as scaling this by (scaleThis+scaleOther)]

Specified by:
add in interface Vect
Parameters:
scaleThis - 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.

project

public void project(double scaleThis,
                    double scaleOther,
                    VectConst other)
Description copied from interface: Vect
Project another vector onto the space of this vector, then scale, and add to a scaled version of this vector. (Useful for perturbing one vector with a constrained subspace.) This method should give the same result as add(), if the other Vect is an instance of the same class as this Vect. This operation need not be supported for any any types other than this Vect.

Specified by:
project in interface Vect
Parameters:
scaleThis - 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.

magnitude

public double magnitude()
Description copied from interface: VectConst
This is the dot product of the vector with itself premultiplied by the inverse covariance. If the inverse covariance is an identity, then the result is just the dot product with itself. Equivalently,
 Vect vect = (Vect) this.clone();
 vect.multiplyInverseCovariance();
 return this.dot(vect);
 
But you can usually avoid the clone.

Specified by:
magnitude in interface VectConst
Returns:
magnitude of vector.