org.openmali.number
Class Radical1

java.lang.Object
  extended by org.openmali.number.Radical1
All Implemented Interfaces:
java.io.Serializable

public class Radical1
extends java.lang.Object
implements java.io.Serializable

Represents a simple subset of radicals, namely, a sum of rational*sqrt(rational). e.g. 4 + sqrt(3) + 5*sqrt(2) The class was designed for use with rotation matrices, where triginomic constants like sin(pi/2) can be represented in simple radical forms.

See Also:
Serialized Form

Field Summary
static Rational lowerTmp
           
static Rational lowerTmp2
           
static java.lang.Object MINUS_ONE
           
static Radical1 ONE
           
 java.util.HashMap<java.lang.Integer,Rational> radicands
           
static Rational upperTmp
           
static Rational upperTmp2
           
static Radical1 ZERO
           
 
Constructor Summary
Radical1()
           
Radical1(int value)
          helper to instanciate integer values (sqrt(1) * x/1 terms)
Radical1(int nom, int den, int radical)
          helper term to instanciate radicals with just one term
Radical1(Radical1 value)
           
Radical1(Rational rational)
          helper term to instanciate radicals with no sqrt terms (or sqrt(1) terms)
Radical1(Rational rational, int radical)
          helper term to instanciate radicals with just one term
 
Method Summary
 void absolute(Radical1 passback)
           
static Radical1 add(Radical1 a, Radical1 b, Radical1 result)
          result = a * b; can be performed in place, i.e. result can be the same argument as a parameter
 void addTerm(Rational multiplier, java.lang.Integer radicand)
          A radical is comprised of several terms e.g. this radical has 3 terms: 4 + 3*sqrt(2) + 2/3 * sqrt(3).
 Radical1 clone()
          
 boolean equals(java.lang.Object o)
          
static boolean equals(Radical1 a, Radical1 b)
           
 float floatValue()
           
 void get(Radical1 passback)
           
 void getBounds(Rational upperPassback, Rational lowerPassback)
          Retreives reasonably tight rational bounds.
 int hashCode()
          
static Radical1 mod(Radical1 rad, Rational mod, Radical1 passback)
          This performs rad % rational in closed form ...
static Radical1 mul(Radical1 a, Radical1 b, Radical1 result)
          result = a * b in radicand math.
 Radical1 mul(Rational factor, Radical1 passback)
           
 Radical1 negate()
           
 Radical1 negate(Radical1 passback)
           
static Radical1 parseRadical1(java.lang.String string)
           
 void set(Radical1 value)
           
 void setTerm(Rational multiplier, java.lang.Integer radicand)
          A radical is comprised of several terms e.g. this radical has 3 terms: 4 + 3*sqrt(2) + 2/3 * sqrt(3).
 void setTerm(Rational multiplier, Rational radicand)
          A radical is comprised of several terms e.g. this radical has 3 terms: 4 + 3*sqrt(2) + 2/3 * sqrt(3).
 void setZero()
           
static Radical1 sub(Radical1 a, Radical1 b, Radical1 result)
          result = a * b; can be performed in place, i.e. result can be the same argument as a parameter
 java.lang.String toString()
          compativle with the parse implementation (see Parser and parseRadicand1)
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

radicands

public java.util.HashMap<java.lang.Integer,Rational> radicands

upperTmp

public static final Rational upperTmp

lowerTmp

public static final Rational lowerTmp

upperTmp2

public static final Rational upperTmp2

lowerTmp2

public static final Rational lowerTmp2

ONE

public static Radical1 ONE

ZERO

public static Radical1 ZERO

MINUS_ONE

public static java.lang.Object MINUS_ONE
Constructor Detail

Radical1

public Radical1(Radical1 value)

Radical1

public Radical1()

Radical1

public Radical1(int value)
helper to instanciate integer values (sqrt(1) * x/1 terms)

Parameters:
value -

Radical1

public Radical1(Rational rational)
helper term to instanciate radicals with no sqrt terms (or sqrt(1) terms)

Parameters:
rational -

Radical1

public Radical1(Rational rational,
                int radical)
helper term to instanciate radicals with just one term

Parameters:
rational -

Radical1

public Radical1(int nom,
                int den,
                int radical)
helper term to instanciate radicals with just one term

Method Detail

setZero

public final void setZero()

set

public final void set(Radical1 value)

get

public final void get(Radical1 passback)

floatValue

public final float floatValue()

negate

public final Radical1 negate(Radical1 passback)

negate

public Radical1 negate()

absolute

public void absolute(Radical1 passback)

mul

public Radical1 mul(Rational factor,
                    Radical1 passback)

setTerm

public void setTerm(Rational multiplier,
                    java.lang.Integer radicand)
A radical is comprised of several terms e.g. this radical has 3 terms: 4 + 3*sqrt(2) + 2/3 * sqrt(3). Term 1 is 4 * sqrt(1), term 2 is 3*sqrt(2), term 3 is 2/3 * sqrt(3). The radicand terms are 1, 2 and 3 respectively. The multipliers are 4, 3 and 2/3 respectively. In this class of radicands, multipliers can be rational and radicands are always posative integers. This method allows just one term to be set (note this will overite the value of anyother multiplier with the same radicand VALUE)


setTerm

public void setTerm(Rational multiplier,
                    Rational radicand)
A radical is comprised of several terms e.g. this radical has 3 terms: 4 + 3*sqrt(2) + 2/3 * sqrt(3). Term 1 is 4 * sqrt(1), term 2 is 3*sqrt(2), term 3 is 2/3 * sqrt(3). The radicand terms are 1, 2 and 3 respectively. The multipliers are 4, 3 and 2/3 respectively. In this class of radicands, multipliers can be rational numbers as can the radicands. This method allows a rational radical argument such as sqrt(1/3), however the denominator is rationalized for storage, so sqrt(1/3) = 1/3 * sqrt(3)


addTerm

public void addTerm(Rational multiplier,
                    java.lang.Integer radicand)
A radical is comprised of several terms e.g. this radical has 3 terms: 4 + 3*sqrt(2) + 2/3 * sqrt(3). Term 1 is 4 * sqrt(1), term 2 is 3*sqrt(2), term 3 is 2/3 * sqrt(3). The radicand terms are 1, 2 and 3 respectively. The multipliers are 4, 3 and 2/3 respectively. In this class of radicands, multipliers can be rational and radicands are always posative integers. This method allows just a single term to be added to the current value, not the actual values will be intergrated into the expression if possible.


getBounds

public void getBounds(Rational upperPassback,
                      Rational lowerPassback)
Retreives reasonably tight rational bounds.

Parameters:
upperPassback -
lowerPassback -

add

public static Radical1 add(Radical1 a,
                           Radical1 b,
                           Radical1 result)
result = a * b; can be performed in place, i.e. result can be the same argument as a parameter


sub

public static Radical1 sub(Radical1 a,
                           Radical1 b,
                           Radical1 result)
result = a * b; can be performed in place, i.e. result can be the same argument as a parameter


mul

public static Radical1 mul(Radical1 a,
                           Radical1 b,
                           Radical1 result)
result = a * b in radicand math. Can be performed in place i.e. a or b can be the same object as the result without problems


mod

public static Radical1 mod(Radical1 rad,
                           Rational mod,
                           Radical1 passback)
This performs rad % rational in closed form ... HOWEVER, this might actually fail to compute, if bounds cannot be found tight enough This implementation of a mod always returns 0 < ans < mod

Parameters:
rad -
mod -
passback -
Throws:
java.lang.ArithmeticException - if tight bounds can't be found

toString

public java.lang.String toString()
compativle with the parse implementation (see Parser and parseRadicand1)

Overrides:
toString in class java.lang.Object
Returns:
a String representation

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

equals

public static final boolean equals(Radical1 a,
                                   Radical1 b)

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

clone

public Radical1 clone()

Overrides:
clone in class java.lang.Object

parseRadical1

public static Radical1 parseRadical1(java.lang.String string)