
Orbital library  
PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
public interface Arithmetic
Arithmetic is implemented by all arithmetic objects that behave like algebraic numbers in terms of their compositional laws.
Such an arithmetic object should return objects of appropriate type as resulting values.
law of composition + (addition)  
add 
+:M×M→M; (a,b)↦a+b  for magmas  
minus 
−:M→M; a↦ −a  for groups  
subtract 
:M×M→M; (a,b)↦ab = a+(−b)  for groups  
law ⋅ (multiplication)  
multiply 
⋅:M×M→M; (a,b)↦a⋅b=a b  law of composition for rings  
inverse 
^{1}:M→M; (a,b)↦a^{1}  for fields  
divide 
∕:M×M→M; (a,b)↦a∕b = a⋅b^{1}  for fields  
scale 
·:R×M→M; (α,x)↦α·x  law of action for Rmodules  
multiply 
·:M×N→P; (a,b)↦a∙b=a·b  inner product for tensors 

extended law ^ (power)  
power 
^:M×M→M; (a,b)↦a^b = a^{b}  for rings, requires ㏒ and e^{a} in general case, Will often work only for b∈Z 
Note: Arithmetic objects may support composition with arithmetic objects of various types other than those in M as well. For simplicity these more general laws with a signature of M_{1}×M_{2}→M_{0} are omitted in the table above. Since they are indeed very useful they can nevertheless be implemented. Vectors for example can be multiplied with a scalar as well as a matrix or a vector resulting in different objects.
Also see the complete description of algebraic structures related to the interface Arithmetic.
An arithmetic object that supports an order should implement Comparable
as well.
Of course, a norm imposes a primitive order ≤ ⊆ M×M by x≤y :⇔ d(x,a)≤d(y,a), for any center a∈M.
But this will most likely differ from the natural ordering on M which should be implemented via Comparable
.
By the way, Operations
can be very useful to implement Arithmetic objects.
Arithmetic objects provides a strong type system which can be either dynamic or static. Operations generally depend polymorphically on the types of all arguments and thus may require dynamic dispatch with regard of the types of all arguments.
Operations
,
Comparable
,
Algebraic StructuresField Summary  

static Predicate 
numerical
Checks recursively whether the given arithmetic object is a numerical quantity, i.e., involves Real numerical approximations somewhere. 
Method Summary  

Arithmetic 
add(Arithmetic b)
Adds an arithmetic object to this returning the result. 
Arithmetic 
divide(Arithmetic b)
Divides this by an arithmetic object returning the result. 
boolean 
equals(java.lang.Object o,
Real tolerance)
Compares two arithmetic objects for tolerant equality. 
Arithmetic 
inverse()
Returns the multiplicative inverse of this arithmetic object. 
boolean 
isOne()
Checks for identity to 1. 
boolean 
isZero()
Checks for identity to 0. 
Arithmetic 
minus()
Returns the additive inverse of this arithmetic object. 
Arithmetic 
multiply(Arithmetic b)
Multiplies an arithmetic object to this returning the result. 
Arithmetic 
one()
1. 
Arithmetic 
power(Arithmetic b)
Returns the power of an arithmetic object to this base. 
Arithmetic 
scale(Arithmetic alpha)
Multiplies a scalar with this arithmetic object returning the result. 
Arithmetic 
subtract(Arithmetic b)
Subtracts an arithmetic object from this returning the result. 
java.lang.String 
toString()
Returns a string representation of the Arithmetic object. 
ValueFactory 
valueFactory()
Get the value factory producing this object 
Arithmetic 
zero()
0. 
Methods inherited from interface orbital.math.Normed 

norm 
Field Detail 

static final Predicate numerical
To be precise, for all numbers with machine precision can only be rational.
Nevertheless, we model the difference between (machine precision) reals
and explicit fractional numbers as Rational
s with numerator and denominator.
Method Detail 

boolean equals(java.lang.Object o, Real tolerance)
tolerance
 specifies how much the arithmetic objects may differ to be treated as equal.
boolean isZero() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
 if this algebraic structure does not have a 0.
This should not happen for monoids of +.boolean isOne() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
 if this algebraic structure does not have a 1.
This should not happen for monoids of ⋅.Arithmetic zero() throws java.lang.UnsupportedOperationException
0 = 0·x.
java.lang.UnsupportedOperationException
 if this algebraic structure does not have a 0.
This should not happen for monoids of +.Arithmetic one() throws java.lang.UnsupportedOperationException
1 = x^{0} at least for x≠0.
java.lang.UnsupportedOperationException
 if this algebraic structure does not have a 1.
This should not happen for monoids of ⋅.Arithmetic add(Arithmetic b) throws java.lang.ArithmeticException
java.lang.ArithmeticException
 if an exceptional arithmetic condition has occurred while
performing the operation. This should not happen for magmas of +.
java.lang.IllegalArgumentException
 if the argument type is illegal for this operation.
Note: for single type handling it is also allowed to throw a ClassCastException, instead.Arithmetic minus() throws java.lang.ArithmeticException
java.lang.ArithmeticException
 if an exceptional arithmetic condition has occurred while
performing the operation. This should not happen for groups of +.Arithmetic subtract(Arithmetic b) throws java.lang.ArithmeticException
java.lang.ArithmeticException
 if an exceptional arithmetic condition has occurred while
performing the operation. This should not happen for groups of +.
java.lang.IllegalArgumentException
 if the argument type is illegal for this operation.
Note: for single type handling it is also allowed to throw a ClassCastException, instead.Arithmetic multiply(Arithmetic b) throws java.lang.ArithmeticException, java.lang.UnsupportedOperationException
Note that if type checking permits, this method may implement both, a⋅b and a·b depending upon context. However, this is not a requirement, since there are a few pathological cases with differing scalar and ring multiplication on the same set.
java.lang.ArithmeticException
 if an exceptional arithmetic condition has occurred while
performing the operation. This should not happen for magmas of ⋅.
java.lang.IllegalArgumentException
 if the argument type is illegal for this operation.
Note: for single type handling it is also allowed to throw a ClassCastException, instead.
java.lang.UnsupportedOperationException
 if this class does not support this operation, principially,
regardless of the argument.scale(Arithmetic)
Arithmetic inverse() throws java.lang.ArithmeticException, java.lang.UnsupportedOperationException
java.lang.ArithmeticException
 if an exceptional arithmetic condition has occurred while
performing the operation. This should not happen for groups of ⋅.
java.lang.UnsupportedOperationException
 if this class does not support this operation, principially,
regardless of the argument.Arithmetic divide(Arithmetic b) throws java.lang.ArithmeticException, java.lang.UnsupportedOperationException
java.lang.ArithmeticException
 if an exceptional arithmetic condition has occurred while
performing the operation. This should not happen for groups of ⋅.
java.lang.IllegalArgumentException
 if the argument type is illegal for this operation.
Note: for single type handling it is also allowed to throw a ClassCastException, instead.
java.lang.UnsupportedOperationException
 if this class does not support this operation, principially,
regardless of the argument.Arithmetic scale(Arithmetic alpha) throws java.lang.ArithmeticException, java.lang.UnsupportedOperationException
alpha
 the factor α to scale this arithmetic object with (per law of action of scalar multiplication).
java.lang.ArithmeticException
 if an exceptional arithmetic condition has occurred while
performing the operation. This should not happen for Rmodules (where R=alpha.getClass()).
java.lang.IllegalArgumentException
 if the argument type is illegal for this operation.
Note: it is also allowed to throw a ClassCastException, instead.
java.lang.UnsupportedOperationException
 if this class does not support this operation, principially,
regardless of the argument.multiply(Arithmetic)
Arithmetic power(Arithmetic b) throws java.lang.ArithmeticException, java.lang.UnsupportedOperationException
java.lang.ArithmeticException
 if an exceptional arithmetic condition has occurred while
performing the operation.
java.lang.IllegalArgumentException
 if the argument type is illegal for this operation.
Note: for single type handling it is also allowed to throw a ClassCastException, instead.
java.lang.UnsupportedOperationException
 if this class does not support this operation, principially,
regardless of the argument.ValueFactory valueFactory()
java.lang.String toString()
Object
.
If it is overwritten it should return a sound representation of the Arithmetic object.
toString
in class java.lang.Object

Orbital library 1.3.0: 11 Apr 2009 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 