Top Fields Constructors Methods
org.python.modules

public Class math

extends Object
implements ClassDictInit
Class Inheritance
All Implemented Interfaces
org.python.core.ClassDictInit
Imports
java.math.BigInteger, org.python.core.ClassDictInit, .Py, .PyException, .PyFloat, .PyInteger, .PyLong, .PyObject, .PyTuple, .__builtin__

Field Summary

Modifier and TypeField and Description
public static PyFloat
e

private static final double
private static final double
pack-priv static final double
private static final BigInteger
private static final BigInteger
private static final double
private static final double
private static final double
private static final double
private static final double
public static PyFloat
private static final double
private static final double

Constructor Summary

AccessConstructor and Description
public
math()

Method Summary

Modifier and TypeMethod and Description
public static double
acos(double v)

public static double

Returns:

x such that cosh x = y
acosh
(double y)

Compute cosh-1y.

private static double
applyLoggedBase(double loggedValue, PyObject base)

public static double
asin(double v)

public static double
asinh(double v)

public static double
atan(double v)

public static double
atan2(double v, double w)

public static double

Returns:

x such that tanh x = y
atanh
(double y)

Compute tanh-1y.

private static double
public static double
public static double
ceil(double v)

public static void
public static double
copysign(double v, double w)

public static double
cos(double v)

public static double
cosh(double v)

public static double
degrees(double v)

public static double
erf(double v)

public static double
erfc(double v)

private static double

Returns:

result if arg was infinite or result was not infinite
exceptInf
(double
to return (if we return)
result
,
double
to include in check
arg
)

Turn an infinite result into a thrown OverflowError, a math range error, if the original argument was not itself infinite.

private static double

Returns:

result if arg was NaN or result was not NaN
exceptNaN
(double
to return (if we return)
result
,
double
to include in check
arg
)

Turn a NaN result into a thrown ValueError, a math domain error, if the original argument was not itself NaN.

public static double
exp(double v)

public static double
expm1(double v)

public static double
fabs(double v)

public static PyLong
factorial(double v)

public static double
public static double
floor(double v)

public static double
fmod(double v, double w)

public static PyTuple
frexp(double x)

public static double
fsum(final PyObject iterable)

public static double
gamma(double v)

private static long
getLong(PyObject pyo)

convert a PyObject into a long between Long.MIN_VALUE and Long.MAX_VALUE

private static long
getLong(PyLong pyLong)

convert a PyLong into a long between Long.MIN_VALUE and Long.MAX_VALUE

public static double

Returns:

(x2 +y2)½
hypot
(double x, double y)

Returns (x2 +y2)½ without intermediate overflow or underflow.

public static boolean

Returns:

true if v is positive or negative infinity
isinf
(double v)

private static boolean
isIntegral(double v)

public static boolean
isnan(double v)

private static boolean
isninf(double v)

private static boolean
isOdd(double v)

private static boolean
ispinf(double v)

public static double
ldexp(double v, PyObject wObj)

public static double
lgamma(double v)

public static double
public static double
private static double
log(double v)

public static double
private static double
log10(double v)

public static double
log1p(double v)

pack-priv static PyException

Returns:

ValueError("math domain error")
mathDomainError
()

Returns a ValueError("math domain error"), ready to throw from the client code.

pack-priv static PyException

Returns:

OverflowError("math range error")
mathRangeError
()

Returns a OverflowError("math range error"), ready to throw from the client code.

public static PyTuple
modf(double v)

public static double
pow(double v, double w)

public static double
radians(double v)

public static double
public static double
sin(double v)

public static double
sinh(double v)

public static double
public static double
sqrt(double v)

public static double
tan(double v)

public static double
tanh(double v)

public static PyObject
trunc(PyObject number)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

eback to summary
public static PyFloat e
EIGHTback to summary
private static final double EIGHT
INFback to summary
private static final double INF
LN2back to summary
pack-priv static final double LN2
MAX_LONG_BIGINTEGERback to summary
private static final BigInteger MAX_LONG_BIGINTEGER
MIN_LONG_BIGINTEGERback to summary
private static final BigInteger MIN_LONG_BIGINTEGER
MINUS_ONEback to summary
private static final double MINUS_ONE
MINUS_ZEROback to summary
private static final double MINUS_ZERO
NANback to summary
private static final double NAN
NINFback to summary
private static final double NINF
ONEback to summary
private static final double ONE
piback to summary
public static PyFloat pi
TWOback to summary
private static final double TWO
ZEROback to summary
private static final double ZERO

Constructor Detail

mathback to summary
public math()

Method Detail

acosback to summary
public static double acos(double v)
acoshback to summary
public static double acosh(double y)

Compute cosh-1y.

Returns:double

x such that cosh x = y

applyLoggedBaseback to summary
private static double applyLoggedBase(double loggedValue, PyObject base)
asinback to summary
public static double asin(double v)
asinhback to summary
public static double asinh(double v)
atanback to summary
public static double atan(double v)
atan2back to summary
public static double atan2(double v, double w)
atanhback to summary
public static double atanh(double y)

Compute tanh-1y.

Returns:double

x such that tanh x = y

calculateLongLogback to summary
private static double calculateLongLog(PyLong v)
ceilback to summary
public static double ceil(PyObject v)
ceilback to summary
public static double ceil(double v)
classDictInitback to summary
public static void classDictInit(PyObject dict)
copysignback to summary
public static double copysign(double v, double w)
cosback to summary
public static double cos(double v)
coshback to summary
public static double cosh(double v)
degreesback to summary
public static double degrees(double v)
erfback to summary
public static double erf(double v)
erfcback to summary
public static double erfc(double v)
exceptInfback to summary
private static double exceptInf(double result, double arg)

Turn an infinite result into a thrown OverflowError, a math range error, if the original argument was not itself infinite. Use as:

public static double cosh(double v) { return exceptInf( Math.cosh(v), v); }
Note that the original function argument is also supplied to this method. Most Java math library methods do exactly what we need for Python, but some return an infinity when Python should raise OverflowError. This is a brief way to change that.
Parameters
result:double

to return (if we return)

arg:double

to include in check

Returns:double

result if arg was infinite or result was not infinite

Exceptions
PyException:
ValueError if result was infinite and arg was not infinite

exceptNaNback to summary
private static double exceptNaN(double result, double arg) throws PyException

Turn a NaN result into a thrown ValueError, a math domain error, if the original argument was not itself NaN. Use as:

public static double asin(double v) { return exceptNaN(Math.asin(v), v); }
Note that the original function argument is also supplied to this method. Most Java math library methods do exactly what we need for Python, but some return NaN when Python should raise ValueError. This is a brief way to change that.
Parameters
result:double

to return (if we return)

arg:double

to include in check

Returns:double

result if arg was NaN or result was not NaN

Exceptions
PyException:
ValueError if result was NaN and arg was not NaN

expback to summary
public static double exp(double v)
expm1back to summary
public static double expm1(double v)
fabsback to summary
public static double fabs(double v)
factorialback to summary
public static PyLong factorial(double v)
floorback to summary
public static double floor(PyObject v)
floorback to summary
public static double floor(double v)
fmodback to summary
public static double fmod(double v, double w)
frexpback to summary
public static PyTuple frexp(double x)
fsumback to summary
public static double fsum(final PyObject iterable)
gammaback to summary
public static double gamma(double v)
getLongback to summary
private static long getLong(PyObject pyo)

convert a PyObject into a long between Long.MIN_VALUE and Long.MAX_VALUE

getLongback to summary
private static long getLong(PyLong pyLong)

convert a PyLong into a long between Long.MIN_VALUE and Long.MAX_VALUE

hypotback to summary
public static double hypot(double x, double y)

Returns (x2 +y2)½ without intermediate overflow or underflow. If either argument is infinite, the result is infinite, but overflow during the calculation is detected as an error.

Returns:double

(x2 +y2)½

isinfback to summary
public static boolean isinf(double v)
Returns:boolean

true if v is positive or negative infinity

isIntegralback to summary
private static boolean isIntegral(double v)
isnanback to summary
public static boolean isnan(double v)
isninfback to summary
private static boolean isninf(double v)
isOddback to summary
private static boolean isOdd(double v)
ispinfback to summary
private static boolean ispinf(double v)
ldexpback to summary
public static double ldexp(double v, PyObject wObj)
lgammaback to summary
public static double lgamma(double v)
logback to summary
public static double log(PyObject v)
logback to summary
public static double log(PyObject v, PyObject base)
logback to summary
private static double log(double v)
log10back to summary
public static double log10(PyObject v)
log10back to summary
private static double log10(double v)
log1pback to summary
public static double log1p(double v)
mathDomainErrorback to summary
pack-priv static PyException mathDomainError()

Returns a ValueError("math domain error"), ready to throw from the client code.

Returns:PyException

ValueError("math domain error")

mathRangeErrorback to summary
pack-priv static PyException mathRangeError()

Returns a OverflowError("math range error"), ready to throw from the client code.

Returns:PyException

OverflowError("math range error")

modfback to summary
public static PyTuple modf(double v)
powback to summary
public static double pow(double v, double w)
radiansback to summary
public static double radians(double v)
sinback to summary
public static double sin(PyObject v)
sinback to summary
public static double sin(double v)
sinhback to summary
public static double sinh(double v)
sqrtback to summary
public static double sqrt(PyObject v)
sqrtback to summary
public static double sqrt(double v)
tanback to summary
public static double tan(double v)
tanhback to summary
public static double tanh(double v)
truncback to summary
public static PyObject trunc(PyObject number)