gov.sandia.cognition.math
Class AbstractRing<RingType extends Ring<RingType>>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractRing<RingType>
Type Parameters:
RingType - Type of Ring that this can operate upon (usually itself)
All Implemented Interfaces:
Ring<RingType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
AbstractEuclideanRing, AbstractMatrix, AbstractRandomVariable, AbstractVectorSpace

@CodeReviews(reviews={@CodeReview(reviewer="Kevin R. Dixon",date="2008-02-08",changesNeeded=false,comments="Looks fine."),@CodeReview(reviewer="Justin Basilico",date="2006-04-25",changesNeeded=false,comments={"Only a few minor modifications were made to the documentation.","Everything checks out."})})
public abstract class AbstractRing<RingType extends Ring<RingType>>
extends AbstractCloneableSerializable
implements Ring<RingType>

Implements the non-inline versions of the various Ring functions. It implements these by making use of the clone method to get a copy of the object it is operating on and then returning that clone.

Since:
1.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Constructor Summary
AbstractRing()
           
 
Method Summary
 RingType clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 RingType dotTimes(RingType other)
          Element-wise multiplication of this and other
 boolean isZero()
          Determines if this ring is equal to zero.
 RingType minus(RingType other)
          Arithmetic subtraction of other from this
 RingType negative()
          Returns the element-wise negation of this, such that this.plus( this.negative() ) has only zero elements.
 void negativeEquals()
          Inline element-wise negation of this
 RingType plus(RingType other)
          Arithmetic addition of this and other
 RingType scale(double scaleFactor)
          Element-wise scaling of this by scaleFactor
 RingType scaledMinus(double scaleFactor, RingType other)
          Arithmetic subtraction other after element-wise scaling of other by scaleFactor from this.
 void scaledMinusEquals(double scaleFactor, RingType other)
          Inline arithmetic subtraction of other after element-wise scaling of other by scaleFactor from this.
 RingType scaledPlus(double scaleFactor, RingType other)
          Arithmetic addition of this and other after element-wise scaling of other by scaleFactor.
 void zero()
          Zeros out all elements of this, so that the following are equivalent r1.scaleEquals( 0.0 ); and r1.zero(); Furthermore, r1.zero(); anything.dotTimes( r1 ).equals( r1 );
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.math.Ring
dotTimesEquals, equals, equals, isZero, minusEquals, plusEquals, scaledPlusEquals, scaleEquals
 

Constructor Detail

AbstractRing

public AbstractRing()
Method Detail

clone

public RingType clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface Ring<RingType extends Ring<RingType>>
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

dotTimes

public RingType dotTimes(RingType other)
Description copied from interface: Ring
Element-wise multiplication of this and other

Specified by:
dotTimes in interface Ring<RingType extends Ring<RingType>>
Parameters:
other - elements of other will be multiplied to the corresponding elements of this
Returns:
element-wise multiplication of this and other

minus

public RingType minus(RingType other)
Description copied from interface: Ring
Arithmetic subtraction of other from this

Specified by:
minus in interface Ring<RingType extends Ring<RingType>>
Parameters:
other - object to subtract from this
Returns:
difference of this and other

plus

public RingType plus(RingType other)
Description copied from interface: Ring
Arithmetic addition of this and other

Specified by:
plus in interface Ring<RingType extends Ring<RingType>>
Parameters:
other - object to add to this
Returns:
sum of this and other

scale

public RingType scale(double scaleFactor)
Description copied from interface: Ring
Element-wise scaling of this by scaleFactor

Specified by:
scale in interface Ring<RingType extends Ring<RingType>>
Parameters:
scaleFactor - amount to scale the elements of this
Returns:
scaling of this

scaledPlus

public RingType scaledPlus(double scaleFactor,
                           RingType other)
Description copied from interface: Ring
Arithmetic addition of this and other after element-wise scaling of other by scaleFactor. If this is x, other is y, and scaleFactor is a, then this method is equivalent to x + a * y. It is typically a more efficient way of doing this.plus(other.scale(scaleFactor)) since it can avoid intermediate object creation.

Specified by:
scaledPlus in interface Ring<RingType extends Ring<RingType>>
Parameters:
scaleFactor - The scale factor to multiply by the elements of other before adding to the elements of this.
other - Object to scale and then add to this.
Returns:
The result of applying the scale factor to other then adding to this.

scaledMinus

public RingType scaledMinus(double scaleFactor,
                            RingType other)
Description copied from interface: Ring
Arithmetic subtraction other after element-wise scaling of other by scaleFactor from this. If this is x, other is y, and scaleFactor is a, then this method is equivalent to x - a * y. It is typically a more efficient way of doing this.minus(other.scale(scaleFactor)) since it can avoid intermediate object creation.

Specified by:
scaledMinus in interface Ring<RingType extends Ring<RingType>>
Parameters:
scaleFactor - The scale factor to multiply by the elements of other before subtracting from the elements of this.
other - Object to scale and then subtract from this.
Returns:
The result of applying the scale factor to other then subtract from this.

scaledMinusEquals

public void scaledMinusEquals(double scaleFactor,
                              RingType other)
Description copied from interface: Ring
Inline arithmetic subtraction of other after element-wise scaling of other by scaleFactor from this. If this is x, other is y, and scaleFactor is a, then this method is equivalent to x -= a * y. It is typically a more efficient way of doing this.minusEquals(other.scale(scaleFactor)) since it can avoid intermediate object creation.

Specified by:
scaledMinusEquals in interface Ring<RingType extends Ring<RingType>>
Parameters:
scaleFactor - The scale factor to multiply by the elements of other before adding to the elements of this.
other - Object to scale and then add to this.

negative

public RingType negative()
Description copied from interface: Ring
Returns the element-wise negation of this, such that this.plus( this.negative() ) has only zero elements.

Specified by:
negative in interface Ring<RingType extends Ring<RingType>>
Returns:
element-wise negation of this

negativeEquals

public void negativeEquals()
Description copied from interface: Ring
Inline element-wise negation of this

Specified by:
negativeEquals in interface Ring<RingType extends Ring<RingType>>

zero

public void zero()
Description copied from interface: Ring
Zeros out all elements of this, so that the following are equivalent r1.scaleEquals( 0.0 ); and r1.zero(); Furthermore, r1.zero(); anything.dotTimes( r1 ).equals( r1 );

Specified by:
zero in interface Ring<RingType extends Ring<RingType>>

isZero

public boolean isZero()
Description copied from interface: Ring
Determines if this ring is equal to zero.

Specified by:
isZero in interface Ring<RingType extends Ring<RingType>>
Returns:
True if all of the elements of this ring are zero.