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: Sun, 28 Jul 2024 15:56:54 +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="18114"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Shouran Ma , Emanuel Berg , emacs-devel@gnu.org, Sergey Kostyaev , Philip Kaludercic To: Immanuel Litzroth Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jul 28 15:57:34 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 1sY4P0-0004X4-6A for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Jul 2024 15:57:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sY4OU-0001rj-Ue; Sun, 28 Jul 2024 09:57:02 -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 1sY4OT-0001rD-7R for emacs-devel@gnu.org; Sun, 28 Jul 2024 09:57:01 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sY4OQ-0005hS-Ss for emacs-devel@gnu.org; Sun, 28 Jul 2024 09:57:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.com; s=s31663417; t=1722175014; x=1722779814; i=dimech@gmx.com; bh=L5R32bIotDcJ5Wjst+6GouKDPFjbbsMWGR06snYv4eI=; 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=cgAHA5BQdSb3BYDugUaO+h6EZbKjaOZViWe+EhL717wRzYWxgT2YzVsFFLsPVMK8 TQaIvJ3YVChxPCXdJvnsFGBFvUHT7nkjLtemdEBJ2cqHxClsaB5HqJKYpTiuKSpw5 n1VQZqFYP2g6Lc44QMTT+dUMtaM2tkaB5oBB/Zzh/KBEmV3iYz8WqWCrExCIIgZC8 1m+gemdKMVPNMledyp2NXCB9IrC+eRibfuZDY9OCY+Hxp6ttWnNZw+ZjFplbNuk1w Bayy9tARleyPudThznovCgnIN7jCcay8FB8wHBE44qgBu/RNrM2k/nMG+bTC7LyGj 6FYkMqgORlfxtUOUwA== 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-bs05.server.lan [172.19.170.173]) (via HTTP); Sun, 28 Jul 2024 15:56:54 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:HbgthHTKH+7fy6Mno0mN1WbCmDr8cUfT1yYCP9q5zEgOtAAJABlBljqO7tODNr7iP9aKY 5KcZbdLyB94feqnkYWOv7Q1XRv2gT68DdM+HfpUime0mlLpoHp2m6RtJcG2QRd8Q5aLGczT2ohbj 2iGH/+S/eBjv5ZMFKRWNM/FbTYhWmmpCifOXi8G2vP7j7yRYa0DNRSyo6X0DYvgRR30NHsV1IGoK SXlMbtlTnDuso86hcvZTUhwiWNFJR+95XrmBe1cXLwrkuf4EqgpHOQso5dRNBk4Ew2eQ8Sz6hl6n Ms= UI-OutboundReport: notjunk:1;M01:P0:uSo99G7wc+Q=;WAKH0g6dgt3uZdMeypOrTNQX/40 SkRGxULn0fRmucgxyGN5PfqrUhl0SJqDTSW3dJQrpKmj94OtpPqu4P+aDm4UgQ+UYOilnZ0Gl BIUR88ltj++HVP1qaLhjhkuhQjn0+k0JFXP9FQxBZue/oOAbP5TAPX5L6BOmzqotIhdVdBnP7 KAUczsuhuAa6gB2WrjuGq2YyHqQuSX4s8q6urH8xUOsmWzIxOhXIlt5tbfXR4fvu/alCJ13mA XXj1kVnRlQG0ENFcXltm+9wMQN59G6d3p0rT+0oFD5uVOppteWC8SobM1qVNtHxTMEbCWOEpJ WCrlY30p1jLl7fWlfTsRJOEGY1fE5rVHIbNNxWrkzJEiN5/yuhdMVxG7x/NocFT+mh/SfdtC4 FpfZzJt++dIDBh+A9muhnL7TGXDFcZHKsEbJvC8YoPVRJ3K0vvouGojHJiRJiPaXqZJwawAT9 oF5gC9w9pPZTyg04D39eqPchJ0xbNBQLZ5Nk6G/VOQNBRk9VX/iOc7cg9aap5fJXuVSiGd1Kq f2y91nUhEjPkAK8hHX2qf1CzGeWBhJ9W1x6Uk1iv3mU78pDosVL4HWlwmT+maXNlqKagGorKP ve+MXf/HJHy9KnV/thjkKHF4UknHBopBK8+vBnOR0L6v46kCZE75TtmvcjvUmd+Qbt81GbrJo esUC/yeM32phLL/ZKSkNYx2WkWdgUegRcah+wpfNUA== Received-SPF: pass client-ip=212.227.15.15; 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_H2=-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:322163 Archived-At: Sent:=C2=A0Monday, July 29, 2024 at 1:34 AM From:=C2=A0"Immanuel Litzroth" To:=C2=A0"Christopher Dimech" Cc:=C2=A0"Shouran Ma" , "Emanuel Berg" , emacs-devel@gnu=2Eorg, "Sergey Kostyaev" , "Philip Kaludercic" Subject:=C2=A0Re: Adding a generic mathematical library > Indexing in an everyday task =2E=2E=2E Like writing? Immanuel=C2=A0 Yes, like writing=2E Referring to elements within a collection (like arra= ys,=20 lists, or strings) using numerical indices, is a fundamental concept in=20 programming=2E Despite its simplicity, proper understanding and handling = of=20 indexing are crucial for writing correct and efficient code=2E Indexing er= rors,=20 like off-by-one mistakes, are among the most common bugs in software devel= opment=2E It shows that developers do require a solid understanding as much as archi= tects and engineers=2E Handling indices correctly, including understanding when= to=20 increment or decrement by one, is a critical skill=2E These seemingly tri= vial=20 issues can lead to significant bugs, from incorrect data processing to sec= urity=20 vulnerabilities=2E The idea that anyone can code to a specific standard without foundational= =20 knowledge is wrong=2E While many people can learn to write code at a basi= c=20 level, developing high-quality software requires a deeper understanding of= =20 algorithms, data structures, software design, and debugging techniques=2E In fields like architecture and engineering, professionals undergo rigorou= s=20 training to understand the principles and practices necessary to ensure sa= fety,=20 functionality, and aesthetics in their work=2E This foundation is not pre= sent=20 in computing today=2E But, Emanuel has mentioned a different problem, the unusual symbol vec tha= t is placed=2E And that there is often complex mix of different ways to do things, all ov= er emacs, making development very slow paced=2E It is the latter consideration that= should be improved=2E On Sat, Jul 27, 2024 at 9:40=E2=80=AFPM Christopher Dimech wrote: > Sent: Sunday, July 28, 2024 at 7:07 AM > From: "Shouran Ma" > To: "Emanuel Berg" > Cc: emacs-devel@gnu=2Eorg[mailto:emacs-devel@gnu=2Eorg], "Sergey Kostyae= v" , "Philip Kaluder= cic" > 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=2E > > I need to elaborate this statement, otherwise it cause confusion to > others=2E > > Elisp provides "List" and "Vector" as an array of numbers: > https://www=2Egnu=2Eorg/software/emacs/manual/html_node/elisp/Sequences-= Arrays-Vectors=2Ehtml[https://www=2Egnu=2Eorg/software/emacs/manual/html_no= de/elisp/Sequences-Arrays-Vectors=2Ehtml] > > To express an array of numbers, a developer would either use two of them > - (setq x '(1 2 3 4))=C2=A0 ; (type-of x) =3D> cons > - (setq x [1 2 3 4])=C2=A0 =C2=A0; (type-of x) =3D> vector > > "cons" (or "list") is the first thing that everybody would choose, for > example, in Sergey's elisa: > https://github=2Ecom/s-kostyaev/elisa/blob/main/elisa=2Eel[https://githu= b=2Ecom/s-kostyaev/elisa/blob/main/elisa=2Eel] > 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=2E > > However, Elisp also has "array" types: > https://www=2Egnu=2Eorg/software/emacs/manual/html_node/elisp/Arrays=2Eh= tml[https://www=2Egnu=2Eorg/software/emacs/manual/html_node/elisp/Arrays=2E= html] > > An array object has slots that hold a number of other Lisp objects, > > called the elements of the array=2E Any element of an array MAY BE > > ACCESSED IN CONSTANT TIME=2E In contrast, the time to access an elemen= t > > of a list is proportional to the position of that element in the list= =2E > > cons/list is something like "linked list" which is not accessed in const > time, but vector support this, e=2Eg=2E it takes more time to access the > last element if we use cons/list, but less time if use vector=2E > > 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]=2E > > 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=2Ee=2E the BUILTIN vector type, over the cons/list=2E > - 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=2E > > This is the dilemma during developing my own math libraries=2E > > Besides, in the Calc subroutine, the MATHEMATICAL vectors are > represented by cons/list in this way > (vec 3 5 2 1 0)=C2=A0 ; not (3 5 2 1 0) or [3 5 2 1 0] > i=2Ee=2E a symbol "vec" is placed at the beginning of the list, in order= to > simplify the predication=2E But this leads to the indexing problem, that > elements are indexed since 1, not 0=2E Such an indexing scheme would cau= se > a nightmare to the developer who want to use our math subroutine to do > further development=2E An indexing task should never be a problem to the seasoned developer=2E If they find it a nightmare, there is something missing with the developer= =2E Indexing in an everyday task in scientific programming=2E=C2=A0 One just h= as to focus and think about what one is doing a little bit=2E > 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=2E And of course, we should > take a look at how sbcl > https://git=2Ecode=2Esf=2Enet/p/sbcl/sbcl[https://git=2Ecode=2Esf=2Enet/= p/sbcl/sbcl] > organize their vector and their vector functions=2E > > 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)=2E > > 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"=2E > > > -- > Best Regards, > Shouran Ma > > =C2=A0=C2=A0 =C2=A0-- -- A man must either resolve to point out nothing new or to become a slave= to defend it=2E -- Sir Isaac Newton