Class Dfp
- All Implemented Interfaces:
CalculusFieldElement<Dfp>,FieldElement<Dfp>
- Direct Known Subclasses:
DfpDec
Another floating point class. This one is built using radix 10000 which is 104, so its almost decimal.
The design goals here are:
- Decimal math, or close to it
- Settable precision (but no mix between numbers using different settings)
- Portability. Code should be kept as portable as possible.
- Performance
- Accuracy - Results should always be +/- 1 ULP for basic algebraic operation
- Comply with IEEE 854-1987 as much as possible. (See IEEE 854-1987 notes below)
Trade offs:
- Memory foot print. I'm using more memory than necessary to represent numbers to get better performance.
- Digits are bigger, so rounding is a greater loss. So, if you really need 12 decimal digits, better use 4 base 10000 digits there can be one partially filled.
Numbers are represented in the following form: \[ n = \mathrm{sign} \times \mathrm{mant} \times \mathrm{radix}^\mathrm{exp} \] where sign is ±1, mantissa represents a fractional number between zero and one. mant[0] is the least significant digit. exp is in the range of -32767 to 32768
IEEE 854-1987 Notes and differences
IEEE 854 requires the radix to be either 2 or 10. The radix here is 10000, so that requirement is not met, but it is possible that a subclassed can be made to make it behave as a radix 10 number. It is my opinion that if it looks and behaves as a radix 10 number then it is one and that requirement would be met.
The radix of 10000 was chosen because it should be faster to operate on 4 decimal digits at once instead of one at a time. Radix 10 behavior can be realized by adding an additional rounding step to ensure that the number of decimal digits represented is constant.
The IEEE standard specifically leaves out internal data encoding, so it is reasonable to conclude that such a subclass of this radix 10000 system is merely an encoding of a radix 10 system.
IEEE 854 also specifies the existence of "sub-normal" numbers. This class does not contain any such entities. The most significant radix 10000 digit is always non-zero. Instead, we support "gradual underflow" by raising the underflow flag for numbers less with exponent less than expMin, but don't flush to zero until the exponent reaches MIN_EXP-digits. Thus the smallest number we can represent would be: 1E(-(MIN_EXP-digits-1)*4), eg, for digits=5, MIN_EXP=-32767, that would be 1e-131092.
IEEE 854 defines that the implied radix point lies just to the right of the most significant digit and to the left of the remaining digits. This implementation puts the implied radix point to the left of all digits including the most significant one. The most significant digit here is the one just to the right of the radix point. This is a fine detail and is really only a matter of definition. Any side effects of this can be rendered invisible by a subclass.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe amount under/overflows are scaled by before going to trap handlerprotected intExponent.static final byteIndicator value for normal finite numbers.static final byteIndicator value for Infinity.protected int[]Mantissa.static final intThe maximum exponent before overflow is signaled and results flushed to infinitystatic final intThe minimum exponent before underflow is signaled.protected byteIndicator for non-finite / non-number values.static final byteIndicator value for quiet NaN.static final intThe radix, or base of this system.protected byteSign bit: 1 for positive, -1 for negative.static final byteIndicator value for signaling NaN. -
Constructor Summary
ConstructorsModifierConstructorDescriptionCopy constructor.protectedMakes an instance with a value of zero.protectedCreate an instance from a byte value.protectedCreates an instance with a non-finite value.protectedCreate an instance from a double value.protectedCreate an instance from an int value.protectedCreate an instance from a long value.protectedCreate an instance from a String representation. -
Method Summary
Modifier and TypeMethodDescriptionabs()absolute value.acos()Arc cosine operation.acosh()Inverse hyperbolic cosine operation.Add x to this.protected intalign(int e) Make our exp equal to the supplied one, this may cause rounding.asin()Arc sine operation.asinh()Inverse hyperbolic sine operation.atan()Arc tangent operation.Two arguments arc tangent operation.atanh()Inverse hyperbolic tangent operation.ceil()Round to an integer using the round ceil mode.intclassify()Returns the type - one of FINITE, INFINITE, SNAN, QNAN.protected intcomplement(int extra) Negate the mantissa of this by computing the complement.static DfpCreates an instance that is the same as x except that it has the sign of y.copySign(double s) Returns the instance with the sign of the argument.Returns the instance with the sign of the argument.cos()Cosine operation.cosh()Hyperbolic cosine operation.protected Stringdfp2sci()Convert an instance to a string using scientific notation.protected StringConvert an instance to a string using normal notation.divide(int divisor) Divide by a single digit less than radix.Divide this by divisor.Raises a trap.booleanCheck if instance is equal to x.exp()Exponential.expm1()Exponential minus 1.floor()Round to an integer using the round floor mode.Get the addendum to the real value of the number.intReturn the exponent of the instance, removing the bias.getField()getOne()Get the constant 1.getPi()Get the Archimedes constant π.intGet the number of radix digits of the instance.doublegetReal()Get the real value of the number.getTwo()Get the constant 2.getZero()Get the constant 0.booleangreaterThan(Dfp x) Check if instance is greater than x.inthashCode()Gets a hashCode for the instance.Returns the hypotenuse of a triangle with sidesthisandy- sqrt(this2 +y2) avoiding intermediate overflow or underflow.intintLog10()Get the exponent of the greatest power of 10 that is less than or equal to abs(this).intintValue()Convert this to an integer.booleanCheck if the instance is infinite.booleanisNaN()Check if the instance is Not a Number.booleanisZero()Check if instance is equal to zero.booleanCheck if instance is less than x.linearCombination(double[] a, Dfp[] b) Compute a linear combination.linearCombination(double a1, Dfp b1, double a2, Dfp b2) Compute a linear combination.linearCombination(double a1, Dfp b1, double a2, Dfp b2, double a3, Dfp b3) Compute a linear combination.linearCombination(double a1, Dfp b1, double a2, Dfp b2, double a3, Dfp b3, double a4, Dfp b4) Compute a linear combination.linearCombination(Dfp[] a, Dfp[] b) Compute a linear combination.linearCombination(Dfp a1, Dfp b1, Dfp a2, Dfp b2) Compute a linear combination.Compute a linear combination.Compute a linear combination.log()Natural logarithm.log10()Base 10 logarithm.intlog10K()Get the exponent of the greatest power of 10000 that is less than or equal to the absolute value of this.log1p()Shifted natural logarithm.multiply(int x) Multiply this by a single digit x.Multiply this by x.negate()Returns a number that is this number with the sign bit reversed.booleanCheck if instance is less than or equal to 0.Create an instance with a value of 0.newInstance(byte x) Create an instance from a byte value.newInstance(byte sig, byte code) Creates an instance with a non-finite value.newInstance(double x) Create an instance corresponding to a constant real value.newInstance(int x) Create an instance from an int value.newInstance(long x) Create an instance from a long value.Create an instance from a String representation.newInstance(Dfp d) Create an instance by copying an existing one.newInstance(DfpField targetField, DfpField.RoundingMode rmode) Creates an instance by converting the instance to a different field (i.e. different accuracy).Returns the next number greater than this one in the direction of x.booleanCheck if instance is greater than or equal to 0.pow(double p) Power operation.pow(int n) Integer power operation.Power operation.power10(int e) Return the specified power of 10.power10K(int e) Get the specified power of 10000.Returns the multiplicative inverse ofthiselement.remainder(double a) IEEE remainder operator.Returns the IEEE remainder.rint()Round to nearest integer using the round-half-even method.rootN(int n) Nth root.protected intround(int n) Round this given the next digit n using the current rounding mode.scalb(int n) Multiply the instance by a power of 2.protected voidShift the mantissa left, and adjust the exponent to compensate.protected voidShift the mantissa right, and adjust the exponent to compensate.sign()Compute the sign of the instance.sin()Sine operation.sinh()Hyperbolic sine operation.sinhCosh()Combined hyperbolic sine and cosine operation.sqrt()Compute the square root.square()Compute this × this.booleanCheck if instance is strictly less than 0.booleanCheck if instance is strictly greater than 0.Subtract x from this.tan()Tangent operation.tanh()Hyperbolic tangent operation.Convert radians to degrees, with error of less than 0.5 ULPdoubletoDouble()Convert the instance into a double.Convert degrees to radians, with error of less than 0.5 ULPdouble[]Convert the instance into a split double.toString()Get a string representation of the instance.protected DfpTrap handler.protected Dfptrunc(DfpField.RoundingMode rmode) Does the integer conversions with the specified rounding.ulp()Compute least significant bit (Unit in Last Position) for a number.booleanCheck if instance is not equal to x.
-
Field Details
-
RADIX
public static final int RADIXThe radix, or base of this system. Set to 10000- See Also:
-
MIN_EXP
public static final int MIN_EXPThe minimum exponent before underflow is signaled. Flush to zero occurs at minExp-DIGITS- See Also:
-
MAX_EXP
public static final int MAX_EXPThe maximum exponent before overflow is signaled and results flushed to infinity- See Also:
-
ERR_SCALE
public static final int ERR_SCALEThe amount under/overflows are scaled by before going to trap handler- See Also:
-
FINITE
public static final byte FINITEIndicator value for normal finite numbers.- See Also:
-
INFINITE
public static final byte INFINITEIndicator value for Infinity.- See Also:
-
SNAN
public static final byte SNANIndicator value for signaling NaN.- See Also:
-
QNAN
public static final byte QNANIndicator value for quiet NaN.- See Also:
-
mant
protected int[] mantMantissa. -
sign
protected byte signSign bit: 1 for positive, -1 for negative. -
exp
protected int expExponent. -
nans
protected byte nansIndicator for non-finite / non-number values.
-
-
Constructor Details
-
Dfp
Makes an instance with a value of zero.- Parameters:
field- field to which this instance belongs
-
Dfp
Create an instance from a byte value.- Parameters:
field- field to which this instance belongsx- value to convert to an instance
-
Dfp
Create an instance from an int value.- Parameters:
field- field to which this instance belongsx- value to convert to an instance
-
Dfp
Create an instance from a long value.- Parameters:
field- field to which this instance belongsx- value to convert to an instance
-
Dfp
Create an instance from a double value.- Parameters:
field- field to which this instance belongsx- value to convert to an instance
-
Dfp
Copy constructor.- Parameters:
d- instance to copy
-
Dfp
Create an instance from a String representation.- Parameters:
field- field to which this instance belongss- string representation of the instance
-
Dfp
Creates an instance with a non-finite value.
-
-
Method Details
-
newInstance
Create an instance with a value of 0. Use this internally in preference to constructors to facilitate subclasses- Returns:
- a new instance with a value of 0
-
newInstance
Create an instance from a byte value.- Parameters:
x- value to convert to an instance- Returns:
- a new instance with value x
-
newInstance
Create an instance from an int value.- Parameters:
x- value to convert to an instance- Returns:
- a new instance with value x
-
newInstance
Create an instance from a long value.- Parameters:
x- value to convert to an instance- Returns:
- a new instance with value x
-
newInstance
Create an instance corresponding to a constant real value.- Specified by:
newInstancein interfaceCalculusFieldElement<Dfp>- Parameters:
x- constant real value- Returns:
- instance corresponding to a constant real value
-
newInstance
Create an instance by copying an existing one. Use this internally in preference to constructors to facilitate subclasses.- Parameters:
d- instance to copy- Returns:
- a new instance with the same value as d
-
newInstance
Create an instance from a String representation. Use this internally in preference to constructors to facilitate subclasses.- Parameters:
s- string representation of the instance- Returns:
- a new instance parsed from specified string
-
newInstance
Creates an instance with a non-finite value. -
newInstance
Creates an instance by converting the instance to a different field (i.e. different accuracy).If the target field as a greater number of digits, the extra least significant digits will be set to zero.
- Parameters:
targetField- field to convert the instance tormode- rounding mode to use if target field as less digits than the instance, can be null otherwise- Returns:
- converted instance (or the instance itself if it already has the required number of digits)
- Since:
- 1.7
- See Also:
-
getField
Get theField(really aDfpField) to which the instance belongs.The field is linked to the number of digits and acts as a factory for
Dfpinstances.- Specified by:
getFieldin interfaceFieldElement<Dfp>- Returns:
Field(really aDfpField) to which the instance belongs
-
getRadixDigits
public int getRadixDigits()Get the number of radix digits of the instance.- Returns:
- number of radix digits
-
getZero
Get the constant 0.- Returns:
- a Dfp with value zero
-
getOne
Get the constant 1.- Returns:
- a Dfp with value one
-
getTwo
Get the constant 2.- Returns:
- a Dfp with value two
-
shiftLeft
protected void shiftLeft()Shift the mantissa left, and adjust the exponent to compensate. -
shiftRight
protected void shiftRight()Shift the mantissa right, and adjust the exponent to compensate. -
align
protected int align(int e) Make our exp equal to the supplied one, this may cause rounding. Also causes de-normalized numbers. These numbers are generally dangerous because most routines assume normalized numbers. Align doesn't round, so it will return the last digit destroyed by shifting right.- Parameters:
e- desired exponent- Returns:
- last digit destroyed by shifting right
-
lessThan
Check if instance is less than x.- Parameters:
x- number to check instance against- Returns:
- true if instance is less than x and neither are NaN, false otherwise
-
greaterThan
Check if instance is greater than x.- Parameters:
x- number to check instance against- Returns:
- true if instance is greater than x and neither are NaN, false otherwise
-
negativeOrNull
public boolean negativeOrNull()Check if instance is less than or equal to 0.- Returns:
- true if instance is not NaN and less than or equal to 0, false otherwise
-
strictlyNegative
public boolean strictlyNegative()Check if instance is strictly less than 0.- Returns:
- true if instance is not NaN and less than or equal to 0, false otherwise
-
positiveOrNull
public boolean positiveOrNull()Check if instance is greater than or equal to 0.- Returns:
- true if instance is not NaN and greater than or equal to 0, false otherwise
-
strictlyPositive
public boolean strictlyPositive()Check if instance is strictly greater than 0.- Returns:
- true if instance is not NaN and greater than or equal to 0, false otherwise
-
abs
absolute value.- Specified by:
absin interfaceCalculusFieldElement<Dfp>- Returns:
- abs(this)
-
isInfinite
public boolean isInfinite()Check if the instance is infinite.- Specified by:
isInfinitein interfaceCalculusFieldElement<Dfp>- Returns:
- true if the instance is infinite
-
isNaN
public boolean isNaN()Check if the instance is Not a Number.- Specified by:
isNaNin interfaceCalculusFieldElement<Dfp>- Returns:
- true if the instance is Not a Number
-
isZero
public boolean isZero()Check if instance is equal to zero.- Specified by:
isZeroin interfaceFieldElement<Dfp>- Returns:
- true if instance is equal to zero
-
equals
Check if instance is equal to x. -
hashCode
public int hashCode()Gets a hashCode for the instance. -
unequal
Check if instance is not equal to x.- Parameters:
x- number to check instance against- Returns:
- true if instance is not equal to x and neither are NaN, false otherwise
-
rint
Round to nearest integer using the round-half-even method. That is round to nearest integer unless both are equidistant. In which case round to the even one.- Specified by:
rintin interfaceCalculusFieldElement<Dfp>- Returns:
- rounded value
-
floor
Round to an integer using the round floor mode. That is, round toward -Infinity- Specified by:
floorin interfaceCalculusFieldElement<Dfp>- Returns:
- rounded value
-
ceil
Round to an integer using the round ceil mode. That is, round toward +Infinity- Specified by:
ceilin interfaceCalculusFieldElement<Dfp>- Returns:
- rounded value
-
remainder
Returns the IEEE remainder.- Specified by:
remainderin interfaceCalculusFieldElement<Dfp>- Parameters:
d- divisor- Returns:
- this less n × d, where n is the integer closest to this/d
-
trunc
Does the integer conversions with the specified rounding.- Parameters:
rmode- rounding mode to use- Returns:
- truncated value
-
intValue
public int intValue()Convert this to an integer. If greater than 2147483647, it returns 2147483647. If less than -2147483648 it returns -2147483648.- Returns:
- converted number
-
log10K
public int log10K()Get the exponent of the greatest power of 10000 that is less than or equal to the absolute value of this. I.E. if this is 106 then log10K would return 1.- Returns:
- integer base 10000 logarithm
-
power10K
Get the specified power of 10000.- Parameters:
e- desired power- Returns:
- 10000e
-
intLog10
public int intLog10()Get the exponent of the greatest power of 10 that is less than or equal to abs(this).- Returns:
- integer base 10 logarithm
-
power10
Return the specified power of 10.- Parameters:
e- desired power- Returns:
- 10e
-
complement
protected int complement(int extra) Negate the mantissa of this by computing the complement. Leaves the sign bit unchanged, used internally by add. Denormalized numbers are handled properly here.- Parameters:
extra- ???- Returns:
- ???
-
add
Add x to this.- Specified by:
addin interfaceFieldElement<Dfp>- Parameters:
x- number to add- Returns:
- sum of this and x
-
negate
Returns a number that is this number with the sign bit reversed.- Specified by:
negatein interfaceFieldElement<Dfp>- Returns:
- the opposite of this
-
subtract
Subtract x from this.- Specified by:
subtractin interfaceCalculusFieldElement<Dfp>- Specified by:
subtractin interfaceFieldElement<Dfp>- Parameters:
x- number to subtract- Returns:
- difference of this and a
-
round
protected int round(int n) Round this given the next digit n using the current rounding mode.- Parameters:
n- ???- Returns:
- the IEEE flag if an exception occurred
-
multiply
Multiply this by x.- Specified by:
multiplyin interfaceFieldElement<Dfp>- Parameters:
x- multiplicand- Returns:
- product of this and x
-
multiply
Multiply this by a single digit x.- Specified by:
multiplyin interfaceCalculusFieldElement<Dfp>- Specified by:
multiplyin interfaceFieldElement<Dfp>- Parameters:
x- multiplicand- Returns:
- product of this and x
-
square
Compute this × this.- Specified by:
squarein interfaceCalculusFieldElement<Dfp>- Returns:
- a new element representing this × this
-
divide
Divide this by divisor.- Specified by:
dividein interfaceCalculusFieldElement<Dfp>- Specified by:
dividein interfaceFieldElement<Dfp>- Parameters:
divisor- divisor- Returns:
- quotient of this by divisor
-
divide
Divide by a single digit less than radix. Special case, so there are speed advantages. 0 <= divisor < radix- Parameters:
divisor- divisor- Returns:
- quotient of this by divisor
-
reciprocal
Returns the multiplicative inverse ofthiselement.- Specified by:
reciprocalin interfaceFieldElement<Dfp>- Returns:
- the inverse of
this.
-
sqrt
Compute the square root.- Specified by:
sqrtin interfaceCalculusFieldElement<Dfp>- Returns:
- square root of the instance
-
toString
Get a string representation of the instance. -
dfp2sci
Convert an instance to a string using scientific notation.- Returns:
- string representation of the instance in scientific notation
-
dfp2string
Convert an instance to a string using normal notation.- Returns:
- string representation of the instance in normal notation
-
dotrap
Raises a trap. This does not set the corresponding flag however.- Parameters:
type- the trap typewhat- - name of routine trap occurred inoper- - input operator to functionresult- - the result computed prior to the trap- Returns:
- The suggested return value from the trap handler
-
trap
Trap handler. Subclasses may override this to provide trap functionality per IEEE 854-1987.- Parameters:
type- The exception type - e.g. FLAG_OVERFLOWwhat- The name of the routine we were in e.g. divide()oper- An operand to this function if anydef- The default return value if trap not enabledresult- The result that is specified to be delivered per IEEE 854, if any- Returns:
- the value that should be return by the operation triggering the trap
-
classify
public int classify()Returns the type - one of FINITE, INFINITE, SNAN, QNAN.- Returns:
- type of the number
-
copysign
Creates an instance that is the same as x except that it has the sign of y. abs(x) = dfp.copysign(x, dfp.one)- Parameters:
x- number to get the value fromy- number to get the sign from- Returns:
- a number with the value of x and the sign of y
-
nextAfter
Returns the next number greater than this one in the direction of x. If this==x then simply returns this.- Parameters:
x- direction where to look at- Returns:
- closest number next to instance in the direction of x
-
toDouble
public double toDouble()Convert the instance into a double.- Returns:
- a double approximating the instance
- See Also:
-
toSplitDouble
public double[] toSplitDouble()Convert the instance into a split double.- Returns:
- an array of two doubles which sum represent the instance
- See Also:
-
getReal
public double getReal()Get the real value of the number.- Specified by:
getRealin interfaceFieldElement<Dfp>- Returns:
- real value
-
getAddendum
Get the addendum to the real value of the number.The addendum is considered to be the part that when added back to the
real partrecovers the instance. This means that whene.getReal()is finite (i.e. neither infinite nor NaN), thene.getAddendum().add(e.getReal())iseande.subtract(e.getReal())ise.getAddendum(). Beware that for non-finite numbers, these two equalities may not hold. The first equality (with the addition), always holds even for infinity and NaNs if the real part is independent of the addendum (this is the case for all derivatives types, as well as for complex and Dfp, but it is not the case for Tuple and FieldTuple). The second equality (with the subtraction), generally doesn't hold for non-finite numbers, because the subtraction generates NaNs.- Specified by:
getAddendumin interfaceCalculusFieldElement<Dfp>- Returns:
- real value
-
remainder
IEEE remainder operator.- Specified by:
remainderin interfaceCalculusFieldElement<Dfp>- Parameters:
a- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a
-
sign
Compute the sign of the instance. The sign is -1 for negative numbers, +1 for positive numbers and 0 otherwise, for Complex number, it is extended on the unit circle (equivalent to z/|z|, with special handling for 0 and NaN)- Specified by:
signin interfaceCalculusFieldElement<Dfp>- Returns:
- -1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a
-
copySign
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<Dfp>- Parameters:
s- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
copySign
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<Dfp>- Parameters:
s- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
getExponent
public int getExponent()Return the exponent of the instance, removing the bias.For double numbers of the form 2x, the unbiased exponent is exactly x.
- Specified by:
getExponentin interfaceCalculusFieldElement<Dfp>- Returns:
- exponent for the instance, without bias
-
scalb
Multiply the instance by a power of 2.- Specified by:
scalbin interfaceCalculusFieldElement<Dfp>- Parameters:
n- power of 2- Returns:
- this × 2n
-
ulp
Compute least significant bit (Unit in Last Position) for a number.- Specified by:
ulpin interfaceCalculusFieldElement<Dfp>- Returns:
- ulp(this)
-
hypot
Returns the hypotenuse of a triangle with sidesthisandy- sqrt(this2 +y2) avoiding intermediate overflow or underflow.- If either argument is infinite, then the result is positive infinity.
- else, if either argument is NaN then the result is NaN.
- Specified by:
hypotin interfaceCalculusFieldElement<Dfp>- Parameters:
y- a value- Returns:
- sqrt(this2 +y2)
-
rootN
Nth root.- Specified by:
rootNin interfaceCalculusFieldElement<Dfp>- Parameters:
n- order of the root- Returns:
- nth root of the instance
-
pow
Power operation.- Specified by:
powin interfaceCalculusFieldElement<Dfp>- Parameters:
p- power to apply- Returns:
- thisp
-
pow
Integer power operation.- Specified by:
powin interfaceCalculusFieldElement<Dfp>- Parameters:
n- power to apply- Returns:
- thisn
-
pow
Power operation.- Specified by:
powin interfaceCalculusFieldElement<Dfp>- Parameters:
e- exponent- Returns:
- thise
-
exp
Exponential.- Specified by:
expin interfaceCalculusFieldElement<Dfp>- Returns:
- exponential of the instance
-
expm1
Exponential minus 1.- Specified by:
expm1in interfaceCalculusFieldElement<Dfp>- Returns:
- exponential minus one of the instance
-
log
Natural logarithm.- Specified by:
login interfaceCalculusFieldElement<Dfp>- Returns:
- logarithm of the instance
-
log1p
Shifted natural logarithm.- Specified by:
log1pin interfaceCalculusFieldElement<Dfp>- Returns:
- logarithm of one plus the instance
-
log10
Base 10 logarithm.- Specified by:
log10in interfaceCalculusFieldElement<Dfp>- Returns:
- base 10 logarithm of the instance
-
cos
Cosine operation.- Specified by:
cosin interfaceCalculusFieldElement<Dfp>- Returns:
- cos(this)
-
sin
Sine operation.- Specified by:
sinin interfaceCalculusFieldElement<Dfp>- Returns:
- sin(this)
-
tan
Tangent operation.- Specified by:
tanin interfaceCalculusFieldElement<Dfp>- Returns:
- tan(this)
-
acos
Arc cosine operation.- Specified by:
acosin interfaceCalculusFieldElement<Dfp>- Returns:
- acos(this)
-
asin
Arc sine operation.- Specified by:
asinin interfaceCalculusFieldElement<Dfp>- Returns:
- asin(this)
-
atan
Arc tangent operation.- Specified by:
atanin interfaceCalculusFieldElement<Dfp>- Returns:
- atan(this)
-
atan2
Two arguments arc tangent operation.Beware of the order or arguments! As this is based on a two-arguments functions, in order to be consistent with arguments order, the instance is the first argument and the single provided argument is the second argument. In order to be consistent with programming languages
atan2, this method computesatan2(this, x), i.e. the instance represents theyargument and thexargument is the one passed as a single argument. This may seem confusing especially for users of Wolfram alpha, as this site is not consistent with programming languagesatan2two-arguments arc tangent and putsxas its first argument.- Specified by:
atan2in interfaceCalculusFieldElement<Dfp>- Parameters:
x- second argument of the arc tangent- Returns:
- atan2(this, x)
- Throws:
MathIllegalArgumentException- if number of free parameters or orders are inconsistent
-
cosh
Hyperbolic cosine operation.- Specified by:
coshin interfaceCalculusFieldElement<Dfp>- Returns:
- cosh(this)
-
sinh
Hyperbolic sine operation.- Specified by:
sinhin interfaceCalculusFieldElement<Dfp>- Returns:
- sinh(this)
-
sinhCosh
Combined hyperbolic sine and cosine operation.- Specified by:
sinhCoshin interfaceCalculusFieldElement<Dfp>- Returns:
- [sinh(this), cosh(this)]
-
tanh
Hyperbolic tangent operation.- Specified by:
tanhin interfaceCalculusFieldElement<Dfp>- Returns:
- tanh(this)
-
acosh
Inverse hyperbolic cosine operation.- Specified by:
acoshin interfaceCalculusFieldElement<Dfp>- Returns:
- acosh(this)
-
asinh
Inverse hyperbolic sine operation.- Specified by:
asinhin interfaceCalculusFieldElement<Dfp>- Returns:
- asin(this)
-
atanh
Inverse hyperbolic tangent operation.- Specified by:
atanhin interfaceCalculusFieldElement<Dfp>- Returns:
- atanh(this)
-
toDegrees
Convert radians to degrees, with error of less than 0.5 ULP- Specified by:
toDegreesin interfaceCalculusFieldElement<Dfp>- Returns:
- instance converted into degrees
-
toRadians
Convert degrees to radians, with error of less than 0.5 ULP- Specified by:
toRadiansin interfaceCalculusFieldElement<Dfp>- Returns:
- instance converted into radians
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Dfp>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Dfp>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Dfp>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second term- Returns:
- a1×b1 + a2×b2
- See Also:
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Dfp>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second term- Returns:
- a1×b1 + a2×b2
- See Also:
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Dfp>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second terma3- first factor of the third termb3- second factor of the third term- Returns:
- a1×b1 + a2×b2 + a3×b3
- See Also:
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Dfp>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second terma3- first factor of the third termb3- second factor of the third term- Returns:
- a1×b1 + a2×b2 + a3×b3
- See Also:
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Dfp>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second terma3- first factor of the third termb3- second factor of the third terma4- first factor of the fourth termb4- second factor of the fourth term- Returns:
- a1×b1 + a2×b2 + a3×b3 + a4×b4
- See Also:
-
linearCombination
public Dfp linearCombination(double a1, Dfp b1, double a2, Dfp b2, double a3, Dfp b3, double a4, Dfp b4) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Dfp>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second terma3- first factor of the third termb3- second factor of the third terma4- first factor of the fourth termb4- second factor of the fourth term- Returns:
- a1×b1 + a2×b2 + a3×b3 + a4×b4
- See Also:
-
getPi
Get the Archimedes constant π.Archimedes constant is the ratio of a circle's circumference to its diameter.
- Specified by:
getPiin interfaceCalculusFieldElement<Dfp>- Returns:
- Archimedes constant π
-