Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 239A2200CE7 for ; Sat, 16 Sep 2017 20:19:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 18C421609D5; Sat, 16 Sep 2017 18:19:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 35A911609CC for ; Sat, 16 Sep 2017 20:19:11 +0200 (CEST) Received: (qmail 38470 invoked by uid 500); 16 Sep 2017 18:19:10 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 38458 invoked by uid 99); 16 Sep 2017 18:19:09 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Sep 2017 18:19:09 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 53F971838B9 for ; Sat, 16 Sep 2017 18:19:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.479 X-Spam-Level: ** X-Spam-Status: No, score=2.479 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=decampo-org.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id KDvIqz2Mafqh for ; Sat, 16 Sep 2017 18:19:06 +0000 (UTC) Received: from mail-oi0-f51.google.com (mail-oi0-f51.google.com [209.85.218.51]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id C05B75F642 for ; Sat, 16 Sep 2017 18:19:05 +0000 (UTC) Received: by mail-oi0-f51.google.com with SMTP id y195so2107175oia.13 for ; Sat, 16 Sep 2017 11:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=decampo-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=NESfNZPywHaWDidDm+mByvQ2mcqqv3pXyaFz+5eDzrE=; b=mAkNs1WA33HIo6sD4fqxRErUAFtq8Ybhpugoqp8DYMFcQHN0tW9gGCBLJLDsgw9O/b L+5NoRTduNb84I38LS81HcfZsbEscU3v5dXo2zOuLH3HWHXgIVCihaSPmAVY99hBgnHm nZksl9jEFW1/H1zW/PLT0evCx+e7wBdZEONhu+wYi2vM1ED7PHxGyNbUalgLZbrDVrDt WPVVptqcGXECxsNft7R2YkZ/lA9Kb6DWfhD5Q51quJuIdw49F1o5Uab1VcYkYrFFkkcI OmWTUQnO5gEd4Z/4L60mYoT+RdrQRzpA7Uq2W07EycvwvMFEH5sIsrIz4zVnSBJHkyuN TOjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=NESfNZPywHaWDidDm+mByvQ2mcqqv3pXyaFz+5eDzrE=; b=l1fv7xJ8DmdNc2oRfI5hUeAxSXUWV6EdDFNReF5TofqaExfv95/inix1VKBS1NvZw/ 9BgaW5NaThOpROU8LXhKJCP8Tc2nDNhdZWhdegBib/vr3JDiFUIKxgJoqoScixMYh3T/ 6pCIVWOMue4Rq5fkZX/VLzpEuBlOeJ7Ui/DQ34qPmi4SB/8KhsZRCF19/yuvXqHvZxqK Z5HnIRMr3SeFTp3su6loF3IABCAqkTpzREVPhyBO6ObWSDrjllf7nUeE8Nm6d2I33psY mLPDMxK9ZM7T4OCbFlaKvyTV5I6BN0sOclsEHttr5u2JnDgSXEL/Eflhu+hX60iQHBhs GZjA== X-Gm-Message-State: AHPjjUjLVCahSGq6kcunqUOaptwTluCc7IDzkJ5he6b9vefOHh5TtjGS +JT9UhaDRbvTGdEWm6OUDK81BO8k/U/RBBxUwiIUTiTUqrU= X-Google-Smtp-Source: AOwi7QBkscE8orjJf6PoeLERfjnZ9zJ8ZgqYM9JrZr9C9GFEd+l+msVEIoHaDcPxsfv6rYuntYaMgVsyxwGusOJto34= X-Received: by 10.202.96.86 with SMTP id u83mr9358409oib.264.1505585944763; Sat, 16 Sep 2017 11:19:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.184.3 with HTTP; Sat, 16 Sep 2017 11:19:04 -0700 (PDT) X-Originating-IP: [72.228.81.86] In-Reply-To: <0ba285df6fd096adbf4be8529d1caaac@scarlet.be> References: <07a3cd49cfde1678a0623e7a4cf7da49@scarlet.be> <0ba285df6fd096adbf4be8529d1caaac@scarlet.be> From: Raymond DeCampo Date: Sat, 16 Sep 2017 14:19:04 -0400 Message-ID: Subject: Re: [Math][Numbers] Move Field, etc. to numbers? To: Commons Developers List Content-Type: multipart/alternative; boundary="001a113d12926b0c7e0559528bcb" archived-at: Sat, 16 Sep 2017 18:19:12 -0000 --001a113d12926b0c7e0559528bcb Content-Type: text/plain; charset="UTF-8" On Sat, Sep 16, 2017 at 1:34 PM, Gilles wrote: > On Sat, 16 Sep 2017 10:57:06 -0400, Raymond DeCampo wrote: > >> On Fri, Sep 15, 2017 at 9:59 PM, Gilles >> wrote: >> >> On Fri, 15 Sep 2017 17:30:26 -0400, Raymond DeCampo wrote: >>> >>> So I was trying to work through MATH-1416, which is to remove code from >>>> CM >>>> which has been moved to CN and I ran into a snag when trying to replace >>>> o.a.c.math4.f.BigFraction with the version from CN in >>>> the KolmogorovSmirnovTest class. This class uses o.a.c.m.f.BigFraction >>>> as >>>> an implementation of FieldElement which o.a.c.n.f.BigFraction is not >>>> since >>>> FieldElement is in CM and not in CN. >>>> >>>> I started down the road of creating an extension of >>>> o.a.c.numbers.f.BigFraction which implemented FieldElement, but that >>>> started to get sticky and complex and did not feel like the right >>>> answer. >>>> >>>> I seems like the right answer is to move Field, FieldElement and >>>> RealFieldElement into numbers and then BigFraction, Fraction, etc. can >>>> implement FieldElement again. This would mean no awkward bridge code to >>>> stuff o.a.c.numbers.f.BigFraction into a FieldElement implementation. >>>> >>>> Re terminology a field is an abstract system of numbers so I don't see >>>> an >>>> issue there. >>>> >>>> Following the existing convention I would create a commons-numbers-field >>>> submodule for the moved classes. >>>> >>>> Any objections? >>>> >>>> >>> Yes, at least three: >>> >>> 1. "Field" and "FieldElement" themselves look awkward. I've alway >>> had a bad feeling about them, although I never had the urge to >>> find a way to fix them (or convince myself that there was no >>> better implementation). >>> >>> >> This strikes me as the wrong time to try to refactor or replace them. >> > > Once "Commons Numbers" is released, it will be too late; refactoring > such a base class would entail a top-level package name change! > > > >> 2. The concept is fairly abstract (and indeed too "math-related"!). >>> >>> >> Putting aside the idea that something is too math-related for CM or CN, >> while the concept of a field is an abstract mathematical concept, it >> strikes me that the interfaces based on it are very useful from a CS point >> of view as well. >> >> The interfaces establish that a particular Number representation follows >> certain rules and implements certain operations. So if one develops an >> algorithm which restricts itself to these rules it may be applied to many >> different Number classes. >> >> > Of course, I agree with the above. > However there is a need to take various POV into account. > One of them is usefulness of an abstract concept in a "basic" > utility library like "Commons Numbers". "Numbers" utilities > are extracted from CM for a reason: because they are useful > on their own. > IIRC, there was a discussion whether we should go further than > "Field" in taking the mathematician's POV. The consensus was > "no" because there was no need in CM (and because CM was not > intended to be an implementation of any and all math concepts!). > > So from the POV of a "Commons Numbers" developer, what is the > added value of "Field"? > [IMO none at the moment (but that could change).] I'm not looking at it from the POV of a CN developer. I am looking at it from the POV of a CN user. I believe this is covered in the following paragraph you quoted. > > > Since Java is strongly typed and does not support duck typing without >> resorting to reflection gymnastics, there is currently no way to write an >> algorithm using e.g. the add() method which could be applied to >> o.a.c.n.f.Fraction and o.a.c.n.c.Complex without duplication, reflection >> or >> pointless wrapper extensions. >> > > All I say is that I'm not convinced that "Field" and > "FieldElement" as they are now, is the best way to allow > that in either "Commons Numbers" or CM. > > Have we explored other possible APIs? > E.g.: > ---- > interface Add { > T add(T other); > } > ---- > etc . > > Can we leverage something from Java 8? > > My feeling is that "Field" and "FieldElement" don't > look right... But I could be wrong. That they are > in CM is not a convincing argument. > > 3. There is a single identified need, in "KolmogorovSmirnovTest"; >>> and it is internal to it. >>> >>> Thus, I'd be wary to pollute "Numbers" with what seems an ad-hoc >>> API that has a single CM class as the only target. >>> >>> >> From what I have seen Field and FieldElement are used extensively in CM >> and >> hardly seem like an ad-hoc API. I suspect this will be the tip of the >> proverbial rabbit hole to mix a few metaphors. >> > > I meant "ad-hoc" as the thing needed to make "BigFraction" work > in "KolmogorovSmirnovTest". And at the same time, I question > the design of that "KolmogorovSmirnovTest" class and the > usefulness of the "Field"-related computations (as part of a > library mainly based on the "double" data type). > > Recall that we are in that position because many codes are > not supported. > My rationale is that since we don't understand the details > of why "Filed" is used in "KolmogorovSmirnovTest", we should > not impose that API on "Commons Numbers". > > Since "Field" is used by CM, it should stay there until we > can see the added value. [At that time we can add interfaces > to the API, hopefully without breaking compatibility.] > > >>> I'd much prefer that we create a "FieldElement" implementation >>> that is a bridge to "BigFraction" (from "Numbers") and make the >>> necessary changes in "KolmogorovSmirnovTest". >>> I've done it (mostly: class renames are in order that can be done >>> once "BigFraction" is deleted from CM); if you file report in JIRA, >>> I'll attach the files to it, for you to review. >>> [Admittingly, code in "KolmogorovSmirnovTest" will become slightly >>> more convoluted because of the bridge; however IMHO the whole class >>> could welcome a thorough cleanup...] >>> Until issue (1) above is solved, we should even make the bridge >>> utilities internal to "KolmogorovSmirnovTest". >>> >>> >>> Unless I have misunderstood, issue (1) appears to be that you do not like >> the Field and FieldElement interfaces. I haven't a clue how to go about >> resolving that. >> > > I cringe on > * the name (Are we sure that any class implementing the API would > define a field?) > * the use of reflection > * the use of wildcard > * the use of "on-demand" loading > > Again, perhaps there is no way around. > But no documentation justifies those choices. > > >> I don't have time to go spelunking into the KolmogorovSmirnovTest now, I >> was looking for something I could knock off without a big time commitment >> to help get CN ready for release. So I will skip the removal of >> BigFraction for now. >> > > I don't understand this line of reasoning. > I made the changes already, and "KolmogorovSmirnovTest" still > passes all its unit tests. Is there another place in CM > where the "Field" nature of "BigFraction" is needed? > If not, it can be replaced by its "Numbers" equivalent. > I.e. you could > 1. do most of what you intended, > 2. open a JIRA issue about "KolmogorovSmirnovTest" > which I'll try to fix as I proposed. > > WDYT? > > To be blunt I don't agree with the approach so I am not about to devote time and effort to supporting it. I'm also not particularly interested in arguing about it. So I have completed the portions where we have agreement and left the rest. Summarizing the other issues I found while trying to eliminate BigFraction, Fraction and Complex from CM: I found nine test classes which use FractionField, those would need to be rewritten. I imagine they could use a different Field implementation without a great deal of difficulty. I also found a couple of public methods in MatrixUtils that I imagine will need to be deleted. I don't think they would be missed but OTOH they were added because somebody wanted them. What you do propose to do about the ComplexField, FractionField and BigFractionField classes? These were part of the CM API in the last release are is the plan to just drop them? --001a113d12926b0c7e0559528bcb--