Package jline.api.lqn
Class LqnNlpComplex
java.lang.Object
jline.api.lqn.LqnNlpComplex
An immutable complex scalar for the COMPLEX-STEP derivatives of the NLP program.
The program differentiates its rate functions and its fork closure by complex
step: f(x + ih) has imaginary part h*f'(x) + O(h^3), which is exact to machine
precision for an analytic f. Only the handful of operations the program and the
queue-dependent rate grammar (LqnLld) need are here, written so that an
argument with a zero imaginary part goes through exactly the real arithmetic
(python's complex arithmetic, which this mirrors, has the same property).
cplx records whether the value is of COMPLEX TYPE in python's sense:
once a complex operand enters an expression the result stays complex even if its
imaginary part happens to cancel, and a few operations (python's max,
min, math.*) refuse a complex argument whatever its value.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabs()The modulus, a REAL number: python's abs of a complex is a float.add(LqnNlpComplex b) cos()div(LqnNlpComplex b) Division as CPython's_Py_c_quot: scaled by the larger component of the divisor, so a real divisor divides exactly.exp()booleanlog()Principal logarithm; a negative real argument gives NaN, as numpy's real log does.mul(double s) mul(LqnNlpComplex b) neg()static LqnNlpComplexof(double re, double im) A complex number, complex-typed whatever its imaginary part.pow(LqnNlpComplex y) Python's**.static LqnNlpComplexreal(double x) A real number.sin()sqrt()Principal square root; a negative real argument gives NaN, as numpy's real sqrt does.sub(LqnNlpComplex b) tanh()toString()
-
Field Details
-
re
public final double re -
im
public final double im -
cplx
public final boolean cplx
-
-
Constructor Details
-
LqnNlpComplex
public LqnNlpComplex(double re, double im, boolean cplx)
-
-
Method Details
-
real
A real number. -
of
A complex number, complex-typed whatever its imaginary part. -
isComplex
public boolean isComplex() -
add
-
sub
-
neg
-
mul
-
mul
-
div
Division as CPython's_Py_c_quot: scaled by the larger component of the divisor, so a real divisor divides exactly.- Throws:
ArithmeticException- on a zero divisor, as python raises ZeroDivisionError
-
exp
-
log
Principal logarithm; a negative real argument gives NaN, as numpy's real log does. -
sqrt
Principal square root; a negative real argument gives NaN, as numpy's real sqrt does. -
sin
-
cos
-
tanh
-
abs
The modulus, a REAL number: python's abs of a complex is a float. -
pow
Python's**. Two reals take the real power, except that a negative base under a fractional exponent turns complex as python's does. A complex operand with an integral real exponent of modulus at most 100 is raised by repeated multiplication (CPython'sc_powi); anything else is exp(y*log(x)). -
toString
-