From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.devel Subject: Re: Adding a generic mathematical library Date: Sat, 27 Jul 2024 21:23:55 +0200 Message-ID: References: <87o76ik616.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6354"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emanuel Berg , emacs-devel@gnu.org, Sergey Kostyaev , Philip Kaludercic To: Shouran Ma Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 27 21:24:30 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sXn1p-0001WM-Jx for ged-emacs-devel@m.gmane-mx.org; Sat, 27 Jul 2024 21:24:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sXn1Y-0001EX-Mo; Sat, 27 Jul 2024 15:24:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sXn1W-0001EI-Qc for emacs-devel@gnu.org; Sat, 27 Jul 2024 15:24:10 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sXn1Q-0005Ec-DX for emacs-devel@gnu.org; Sat, 27 Jul 2024 15:24:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.com; s=s31663417; t=1722108235; x=1722713035; i=dimech@gmx.com; bh=oKSYo4dylA9LhLBKrwXXuTTd3/jGohnawHk0p09dNz8=; h=X-UI-Sender-Class:MIME-Version:Message-ID:From:To:Cc:Subject: Content-Type:Date:In-Reply-To:References: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=K06uqtoR7eN4aaWIPf6aMqvFyPzT0iPa4rbyK0gSkywNGbmu0QThgO/nbcLpPW2O zDTnnlnnEhJjZZN23RrhsngSvyBCLEARTXtNKhF6RvKYZWExy9O/JHZ9w3j72TjWA lhbnHHBfvrP/+n79TrBg6I1TJHTEc4aA9+CWRjEW/e5HUD5MpcEog5oFal1fVGZu0 W6blabfOP65cKv2wCIGOPGcHlENKzv/ws1ko93vKbp35gfKmgwtm1dmeMxT2d1+I9 aUzoLifFq4RQNw0KwYNi5/ofqrf9CoAHGjzgFXGfUrQ3/kklc4FyUC1L6+e6n2Y5d OjnQ2Im4pwMJJrj4UQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from [92.251.79.197] ([92.251.79.197]) by web-mail.gmx.net (3c-app-mailcom-bs02.server.lan [172.19.170.129]) (via HTTP); Sat, 27 Jul 2024 21:23:55 +0200 Importance: normal Sensitivity: Normal In-Reply-To: <87o76ik616.fsf@gmail.com> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:Y0tNzO0UPcQ5kkYdiY8jiGH8cRZ9ugxhpRpCuIBddYCj+yfdS7Edw0kzNPQAYd+aU80sw 5ifqUNtWj7zNw4YzcHqhu6gfNgau0WaSwZjLygBtJkKd7ERif1JVG/DgmHDuDpARrgS1lpJxa8AQ EBYwJJuJwIH1cF4Sk9KtePppwzMDCmRQbHi1oEABvZuFzHbhgUrs+YBcQK085yT19NC0J0egjZr2 rSp91yjddHmgysLq7kXsClqwKEWZxbSDjCXTolHxIiDgKj4auS+BfgOhBcBpX3X4S/FF0JYsa3E5 PM= UI-OutboundReport: notjunk:1;M01:P0:oIwVbDxHKQE=;Fmv8VtKzzqRoAPzxiSd1zPkSnEH yGQZmgx41EJRmjPPqteZHJTKz0nWlQqnqf7RCvJvdhVt5RdIUcM34xw29y1xb9Oblr42Z7Hh5 oGCcXIAE/HqgGWtPo+IXr6EBQi+keQPiz0k6gBdq4XYoc0DtjnhTWhTApcjAVMR0X3aER8bj6 1zTiAdWzIHxqbIWfEgZcfW+fZdeFrXpjtLs+9N9aMdFCCCzhUkjdh/lIvNviFXQUEo2eHsOMB ZzRRrTpuhnSUStqKtd25DEz4ktShFlNvcc08ZZJvZHJB1q3jKHLoxpvzDGonfyH6age1IcaGB p46a7024q9dYRYJL5lKJo4XXq1TG7cFDzhVfFZdqkp89FhMafVxB4ykGdyeCaPVv6lIvpios4 XXmC/mLfHuLKy3ltTLo76niHC7VHX0UNcT/YRJWgIbr1zox6YGdY5WOVOdRcIt9SmSthLt0Am PhvEKLOtkagyhtffEEmBrS7gVMWozLl0YnRCp4EhBg0AwAr2BhDGytDjlhhWYmoze/URazlAR TVCr0YX7VemtxbtEWX0yJOLao9Z1xUtMVFFf5Q+qdEnriQVAiCPFbOaeeUkqmMfPnS+4FIeBx /uT4zVYBGMnoCFTxgmlUZRX7VNI9I3AElSP7qSm/fD1ue8slz1qEb9UWWrSuam6S609ZMtkcA KbuO/FLKM9CzBzb4aMp0ltJmE5nvgNq1DvbbXNrXeQ== Received-SPF: pass client-ip=212.227.15.18; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:322142 Archived-At: > Sent: Sunday, July 28, 2024 at 7:07 AM > From: "Shouran Ma" > To: "Emanuel Berg" > Cc: emacs-devel@gnu.org, "Sergey Kostyaev" , "Phil= ip Kaludercic" > Subject: Re: Adding a generic mathematical library > > > > Sent: Saturday, July 27, 2024 at 16:57 +0200 > > From: "Shouran Ma" > > > > However, WE DON'T EVEN HAVE A UNIFIED WAY TO REPRESENTING A VECTOR. > > I need to elaborate this statement, otherwise it cause confusion to > others. > > Elisp provides "List" and "Vector" as an array of numbers: > https://www.gnu.org/software/emacs/manual/html_node/elisp/Sequences-Arra= ys-Vectors.html > > To express an array of numbers, a developer would either use two of them > - (setq x '(1 2 3 4)) ; (type-of x) =3D> cons > - (setq x [1 2 3 4]) ; (type-of x) =3D> vector > > "cons" (or "list") is the first thing that everybody would choose, for > example, in Sergey's elisa: > https://github.com/s-kostyaev/elisa/blob/main/elisa.el > In the function "elisa--distances", Sergey puts "head" and "(car tail)" > as arguments to "elisa-cosine-distance", this means Sergey uses > cons/list to organize array of numbers. > > However, Elisp also has "array" types: > https://www.gnu.org/software/emacs/manual/html_node/elisp/Arrays.html > > An array object has slots that hold a number of other Lisp objects, > > called the elements of the array. Any element of an array MAY BE > > ACCESSED IN CONSTANT TIME. In contrast, the time to access an element > > of a list is proportional to the position of that element in the list. > > cons/list is something like "linked list" which is not accessed in const > time, but vector support this, e.g. it takes more time to access the > last element if we use cons/list, but less time if use vector. > > However, Elisp provides too few functions on operating the vector type, > for example, to slice a vector like the way in python: array[2:4]. > > So my saying "don't even have a unified way to representing a vector", I > mean, to organize/represent a MATHEMATICAL vector > - I would prefer to choose the object that support const time access, > i.e. the BUILTIN vector type, over the cons/list. > - However, the BUILTIN vector type supports quite a few functions, which > forces me to change my mind to organize/represent the MATHEMATICAL > vectors by cons/list. You do not need a unified way to representing a vector. You only need the tool to work conveniently with vectors. Having two or three ways to do it, is not a bad thing, unless the number of ways are excessive. > This is the dilemma during developing my own math libraries. If you support both, there will be no dilemma. > Besides, in the Calc subroutine, the MATHEMATICAL vectors are > represented by cons/list in this way > (vec 3 5 2 1 0) ; not (3 5 2 1 0) or [3 5 2 1 0] > i.e. a symbol "vec" is placed at the beginning of the list, in order to > simplify the predication. But this leads to the indexing problem, that > elements are indexed since 1, not 0. Such an indexing scheme would cause > a nightmare to the developer who want to use our math subroutine to do > further development. > > In summary, if the builtin vector type is preferred way to represent the > MATHEMATICAL vector, we should first of all complete the fundamental > vector operations, like vector slicing etc. And of course, we should > take a look at how sbcl > https://git.code.sf.net/p/sbcl/sbcl > organize their vector and their vector functions. The focus for the builtin vector type should first be on the ways it is currently used. Support those first, then look at some other things that can be added. Making a complete thing could waste precious time for minimal return. Meaning, it is more important to support the evolution of the code through its design, than anything else. We have many implementers but very few focused designers. > From my side, I don't want to touch the vector things so far, but instea= d > the rational number (the bullet 2 & 3 in my previous mail). > > Finally, > > Sent: Saturday, July 27, 2024 at 17:49 +0200 > > From: "Emanuel Berg" > > > > However it used to be even worse, when we didn't even have clocks! > > If the "clock" you said is the clock to measure how long a function > runs, we have, it is "benchmark-run". > > > -- > Best Regards, > Shouran Ma > >