|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcox.jmatt.java.MathTools.MRadical
public class MRadical
The MRadical class provides an easy way to create and present radicals without requiring double approximation or other theatrics. Once created, MRadicals are immutable. The sign, radicand, and index can be examined but not changed. MRadical also has methods for comparing two MRadicals. Apart from these methods MRadical is primarily a formatting class.
The true power of this class is in the format() method. It provides tokens for the 'raw' radical as well as the simplified radical. If a radicand can be simplified, i.e. it contains a perfect-power factor, the perfect power is factored out, represented as a coefficient to the radical, and the radicand reduced appropriately. This is an automatic part of the formatting process.
Field Summary | |
---|---|
static java.lang.String |
FORMAT_DEBUG
Format string for debugging purposes. |
static java.lang.String |
FORMAT_LATEX
LaTeX raw form. |
static java.lang.String |
FORMAT_LATEX_SIMP
LaTeX simplified. |
static java.lang.String |
FORMAT_OO
OpenOffice.org, raw form. |
static java.lang.String |
FORMAT_OO_SIMP
OpenOffice.org, simplified . |
static java.lang.String |
FORMAT_STANDARD
Standard raw form for radicals: radical(index, radicand). |
static java.lang.String |
FORMAT_STANDARD_SIMP
Standard simplified form for radicals: coef radical(index, simp. |
Constructor Summary | |
---|---|
MRadical()
Standard script-exposure constructor. |
|
MRadical(int pIndex,
int pRadicand)
Constructor to specify all critical parts of the radical: radicand, and index. |
|
MRadical(MRadical pRadical)
Copy constructor. |
Method Summary | |
---|---|
int |
absRadicand()
Get the absolute value of the radicand. |
int |
compareTo(MRadical pRadical)
Compare this MRadical to another. |
static MRadical |
createMRadical(int pRadicand)
Static method to create a square root. |
static MRadical |
createMRadical(int pIndex,
int pRadicand)
Static method to create a MRadical given its radicand and index. |
static MRadical |
createMRadical(int pCoef,
int pIndex,
int pRadicand)
Method to construct a MRadical with a 'coefficient,' e.g. |
boolean |
equals(MRadical pRadical)
Check to see if the two MRadicals represent the same value. |
java.lang.String |
format()
Format this MRadical per its currently-set format String. |
java.lang.String |
format(java.lang.String pTemplate)
Format this MRadical per the template supplied. |
boolean |
identicalTo(MRadical pRadical)
This method tests to see if the two MRadicals are exactly identical, not just equal in value. |
int |
index()
Get the value of the index. |
MRadical |
newMRadical(int pRadicand)
Instance method to create a square root. |
MRadical |
newMRadical(int pIndex,
int pRadicand)
Instance method to create a new MRadical. |
MRadical |
newMRadical(int pCoef,
int pIndex,
int pRadicand)
Instance version of the three-int factory method. |
int |
radicand()
Get the value of the radicand. |
java.lang.String |
sCompareTo(MRadical pRadical)
Compare this MRadical to another but return a single-character String: '<', '=' or '>'. |
static void |
setDefaultFormat(java.lang.String pFormat)
Set the default format for all MRadicals created after this method is called. |
void |
setFormat(java.lang.String pFormat)
Set the format String for this MRadical. |
void |
setNewDefaultFormat(java.lang.String pFormat)
Instance version of setDefaultFormat() . |
int |
signum()
Return the sign of the MRadical: -1 if negative, 0 if zero, +1 if positive. |
double |
toDouble()
Evaluate the radical as a double. |
java.lang.String |
toMathML()
Express the radical using MathML. |
java.lang.String |
toString()
This method returns a constructor-like representation of the MRadical. |
java.lang.String |
toXML(java.lang.String pID)
Express the radical in simplified XML notation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String FORMAT_DEBUG
public static final java.lang.String FORMAT_STANDARD
public static final java.lang.String FORMAT_STANDARD_SIMP
public static final java.lang.String FORMAT_OO
public static final java.lang.String FORMAT_OO_SIMP
public static final java.lang.String FORMAT_LATEX
public static final java.lang.String FORMAT_LATEX_SIMP
Constructor Detail |
---|
public MRadical()
public MRadical(int pIndex, int pRadicand)
pRadicand
- The radicand.pIndex
- The index.public MRadical(MRadical pRadical)
Method Detail |
---|
public static MRadical createMRadical(int pIndex, int pRadicand)
public MRadical newMRadical(int pIndex, int pRadicand)
public static MRadical createMRadical(int pRadicand)
public MRadical newMRadical(int pRadicand)
public static MRadical createMRadical(int pCoef, int pIndex, int pRadicand)
pCoef
- The number multiplied onto the radical.pIndex
- The index (root) of the radical.pRadicand
- The radicand.public MRadical newMRadical(int pCoef, int pIndex, int pRadicand)
public java.lang.String toString()
toString
in class java.lang.Object
public double toDouble()
public int radicand()
public int absRadicand()
public int index()
public int signum()
public boolean equals(MRadical pRadical)
public boolean identicalTo(MRadical pRadical)
public int compareTo(MRadical pRadical)
java.lang.NullPointerException
- If pRadical is null.public java.lang.String sCompareTo(MRadical pRadical)
public java.lang.String format(java.lang.String pTemplate)
Format this MRadical per the template supplied. This is a standard Question.fillTemplate()
with the following tokens supplied:
MRadical maintains the sign separate from the radicand itself. Tokens 10 and 11 reflect this through the simplification process. The negative sign, if present, appears on the coefficient. When using the simplified tokens, if there is a chance the radicand might be negative token 2 should be used for the actual radicand, otherwise the negative sign may show up twice!
pTemplate
- The template to use when formatting the MRadical. If null or empty, FORMAT_STANDARD is used.
public java.lang.String toMathML()
public java.lang.String toXML(java.lang.String pID)
public void setFormat(java.lang.String pFormat)
public static void setDefaultFormat(java.lang.String pFormat)
public void setNewDefaultFormat(java.lang.String pFormat)
setDefaultFormat()
.
public java.lang.String format()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |