RFR: 8376040: Add prototype "textbook complex" class
Joe Darcy
darcy at openjdk.org
Thu Jan 22 05:51:52 UTC 2026
On Thu, 22 Jan 2026 00:35:05 GMT, Joe Darcy <darcy at openjdk.org> wrote:
> First cut at a version of complex numbers using the textbook algorithms for the arithmetic operations. This version is intended for prototyping and _not_ for production use.
Since the HTML markup in the javadoc for the arithmetic methods is hard to read, here is a copy and past of the rendered text:
public static ComplexTextbook add(ComplexTextbook addend, ComplexTextbook augend)
Addition operation, binary "+".
Implementation Requirements:
The computed sum is equivalent to (a + c) + i·(b + d).
public static ComplexTextbook subtract(ComplexTextbook minuend, ComplexTextbook subtrahend)
Subtraction operation, binary "-".
Implementation Requirements:
The computed difference is equivalent to (a − c) + i·(b − d).
public static ComplexTextbook multiply(ComplexTextbook multiplier, ComplexTextbook multiplicand)
Multiplication operation, "*".
API Note:
WARNING: while simple, the calculation technique used by this method is subject to spurious underflow and overflow as well as inaccurate component-wise results.
Implementation Requirements:
The computed product is calculated by (ac − bd) + i·(ad + bc)
public static ComplexTextbook divide(ComplexTextbook dividend, ComplexTextbook divisor)
Division operation, "/".
API Note:
TODO: Bad numerical things can happen warning...
Implementation Requirements:
The computed quotient is calculated by (ac + bd)/(c² + d²) + i*(bc − ad)/(c² + d²)
-------------
PR Comment: https://git.openjdk.org/valhalla/pull/1942#issuecomment-3782608915
More information about the valhalla-dev
mailing list