RingType
- Type of Ring that this can operate upon (usually itself)@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>
Constructor and Description |
---|
AbstractRing() |
Modifier and Type | Method and Description |
---|---|
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 ); |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dotTimesEquals, equals, equals, isZero, minusEquals, plusEquals, scaledPlusEquals, scaleEquals
public RingType clone()
AbstractCloneableSerializable
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.clone
in interface Ring<RingType extends Ring<RingType>>
clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public RingType dotTimes(RingType other)
Ring
this
and other
public RingType minus(RingType other)
Ring
other
from this
public RingType plus(RingType other)
Ring
this
and other
public RingType scale(double scaleFactor)
Ring
this
by scaleFactor
public RingType scaledPlus(double scaleFactor, RingType other)
Ring
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.scaledPlus
in interface Ring<RingType extends Ring<RingType>>
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.public RingType scaledMinus(double scaleFactor, RingType other)
Ring
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.scaledMinus
in interface Ring<RingType extends Ring<RingType>>
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.public void scaledMinusEquals(double scaleFactor, RingType other)
Ring
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.scaledMinusEquals
in interface Ring<RingType extends Ring<RingType>>
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.public RingType negative()
Ring
this
, such that
this.plus( this.negative() )
has only zero elements.public void negativeEquals()
Ring
this
negativeEquals
in interface Ring<RingType extends Ring<RingType>>
public void zero()
Ring
this
, so that the following are
equivalent
r1.scaleEquals( 0.0 );
and
r1.zero();
Furthermore,
r1.zero(); anything.dotTimes( r1 ).equals( r1 );