RFR: [type-classes] JDK-8376823: Add prototype polynomial class [v6]
Joe Darcy
darcy at openjdk.org
Mon Feb 2 22:03:33 UTC 2026
On Mon, 2 Feb 2026 21:35:03 GMT, Chen Liang <liach at openjdk.org> wrote:
> Good that we are encapsulating degree with methods; might add a comment to indicate this intention, like no direct access for lazy fields.
>
> Also, I noted we use (`this.`)`coeffs.length` a lot. How is it distinct from `deg()`? Hope we can clarify on that as well.
>
> Otherwise, looks nice in concept.
The notion of "degree" is a polynomial concept while the length of the backing array is an implementation artifact. With this data structure; degree is _almost_ length - 1. The exception is a zero polynomial, which needs special handling somehow since its degree is defined to not be 0 -- as would be the case for any other constant polynomial -- but -1 (or sometimes -infinity).
Writing this comment, this might tip my scales to internally use an empty array to special case zero. That way, the degree would be one less than the length is all cases.
-------------
PR Comment: https://git.openjdk.org/valhalla/pull/2004#issuecomment-3837572397
More information about the valhalla-dev
mailing list