unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Christopher Dimech <dimech@gmx.com>
To: Shouran Ma <shouran.ma@gmail.com>
Cc: Emanuel Berg <incal@dataswamp.org>,
	emacs-devel@gnu.org, Sergey Kostyaev <sskostyaev@gmail.com>,
	Philip Kaludercic <philipk@posteo.net>
Subject: Re: Adding a generic mathematical library
Date: Sat, 27 Jul 2024 21:40:02 +0200	[thread overview]
Message-ID: <trinity-680b07e3-b4b2-4a40-9a7c-e914c2ac76ab-1722109202194@3c-app-mailcom-bs02> (raw)
In-Reply-To: <87o76ik616.fsf@gmail.com>


> Sent: Sunday, July 28, 2024 at 7:07 AM
> From: "Shouran Ma" <shouran.ma@gmail.com>
> To: "Emanuel Berg" <incal@dataswamp.org>
> Cc: emacs-devel@gnu.org, "Sergey Kostyaev" <sskostyaev@gmail.com>, "Philip Kaludercic" <philipk@posteo.net>
> Subject: Re: Adding a generic mathematical library
>
>
> > Sent: Saturday, July 27, 2024 at 16:57 +0200
> > From: "Shouran Ma" <shouran.ma@gmail.com>
> >
> > 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-Arrays-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) => cons
> - (setq x [1 2 3 4])   ; (type-of x) => 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.
>
> This is the dilemma during developing my own math libraries.
>
> 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.

An indexing task should never be a problem to the seasoned developer.
If they find it a nightmare, there is something missing with the developer.

Indexing in an everyday task in scientific programming.  One just has to focus
and think about what one is doing a little bit.

> 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.
>
> From my side, I don't want to touch the vector things so far, but instead
> the rational number (the bullet 2 & 3 in my previous mail).
>
> Finally,
> > Sent: Saturday, July 27, 2024 at 17:49 +0200
> > From: "Emanuel Berg" <incal@dataswamp.org>
> >
> > 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
>
>



  parent reply	other threads:[~2024-07-27 19:40 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-27 19:07 Adding a generic mathematical library Shouran Ma
2024-07-27 19:23 ` Christopher Dimech
2024-07-28  0:29   ` Emanuel Berg
2024-07-28 10:58     ` Christopher Dimech
2024-07-28 11:39       ` Emanuel Berg
2024-07-28 12:28         ` Christopher Dimech
2024-07-28 13:02           ` Emanuel Berg
2024-07-30  2:53     ` Richard Stallman
2024-07-30  3:53       ` Emanuel Berg
2024-07-30  6:26       ` Christopher Dimech
2024-07-30  7:20         ` Emanuel Berg
2024-07-30 11:30           ` Christopher Dimech
2024-07-30 22:56             ` Emanuel Berg
2024-07-31 16:00               ` Michael Heerdegen via Emacs development discussions.
2024-07-31 21:15                 ` Emanuel Berg
2024-08-01  6:05                   ` Eli Zaretskii
2024-08-01  6:42                     ` Emanuel Berg
2024-07-31 21:26                 ` Emanuel Berg
2024-07-27 19:40 ` Christopher Dimech [this message]
2024-07-28  0:24   ` Emanuel Berg
2024-07-28 13:34   ` Immanuel Litzroth
2024-07-28 13:56     ` Christopher Dimech
2024-07-28 14:07       ` Emanuel Berg
2024-07-28 10:46 ` Emanuel Berg
  -- strict thread matches above, loose matches on Subject: below --
2024-07-27 14:57 Shouran Ma
2024-07-27 15:49 ` Emanuel Berg
2024-07-23 20:00 Kepa
2024-07-25  4:19 ` Emanuel Berg
2024-07-25 11:32   ` Christopher Dimech
2024-07-25 14:20     ` Stefan Kangas
2024-07-25 15:16       ` T.V Raman
2024-07-25 15:34       ` Christopher Dimech
2024-07-25 17:12         ` Emanuel Berg
2024-07-25 17:25       ` Emanuel Berg
2024-07-25 14:24     ` Emanuel Berg
2024-07-25 15:49       ` Christopher Dimech
2024-07-25 17:23         ` Emanuel Berg
2024-07-12 16:47 Add elisa to GNU ELPA Sergey Kostyaev
2024-07-16 12:54 ` Philip Kaludercic
2024-07-16 13:57   ` Sergey Kostyaev
2024-07-16 16:04     ` Philip Kaludercic
2024-07-16 16:41       ` Sergey Kostyaev
2024-07-16 17:02         ` Philip Kaludercic
2024-07-16 17:47           ` Adding a generic mathematical library Philip Kaludercic
2024-07-16 22:06             ` Emanuel Berg
2024-07-17  2:54               ` Christopher Dimech
2024-07-17  5:58                 ` Emanuel Berg
2024-07-19 16:16               ` Richard Stallman
2024-07-19 17:38                 ` Christopher Dimech
2024-07-21  5:20                   ` Emanuel Berg
2024-07-20 12:45                 ` Max Nikulin
2024-07-20 13:53                   ` Christopher Dimech
2024-07-21  5:19                 ` Emanuel Berg
2024-07-21  6:15                   ` Emanuel Berg
2024-07-21  7:40                     ` Emanuel Berg
2024-07-21  8:45                       ` Emanuel Berg
2024-07-21  8:29                     ` Emanuel Berg
2024-07-21  7:27                   ` Christopher Dimech
2024-07-21  8:03                     ` Emanuel Berg
2024-07-21  9:14                       ` Christopher Dimech
2024-07-21  9:48                         ` Emanuel Berg
2024-07-21 11:20                           ` Emanuel Berg
2024-07-21 11:53                             ` Christopher Dimech
2024-07-21 12:10                               ` Emanuel Berg
2024-07-21 12:27                                 ` Emanuel Berg
2024-07-21 12:46                                   ` Emanuel Berg
2024-07-21 13:03                                   ` Christopher Dimech
2024-07-21 13:17                                     ` Emanuel Berg
2024-07-21 14:33                                       ` Eli Zaretskii
2024-07-21 14:41                                         ` Christopher Dimech
2024-07-21 14:49                                           ` Eli Zaretskii
2024-07-21 14:58                                             ` Christopher Dimech
2024-07-21 15:02                                               ` Eli Zaretskii
2024-07-21 15:18                                                 ` Christopher Dimech
2024-07-21 13:18                                     ` Christopher Dimech
2024-07-21 13:26                                       ` Emanuel Berg
2024-07-21 14:35                                         ` Christopher Dimech
2024-07-21 19:28                                           ` Emanuel Berg
2024-07-21 19:33                                           ` Emanuel Berg
2024-07-21 19:51                                           ` Emanuel Berg
2024-07-21 20:01                                           ` Emanuel Berg
2024-07-21 20:17                                           ` Emanuel Berg
2024-07-21 12:41                                 ` Christopher Dimech
2024-07-21 13:13                                   ` Emanuel Berg
2024-07-21 13:41                                   ` Emanuel Berg
2024-07-21 12:20                               ` Emanuel Berg
2024-07-21 12:04                             ` Emanuel Berg
2024-07-17  7:09             ` Michael Heerdegen via Emacs development discussions.
2024-07-17  7:54               ` Philip Kaludercic
2024-07-17  7:56               ` Michael Heerdegen via Emacs development discussions.
2024-07-18  6:07                 ` Emanuel Berg
2024-07-18  6:45                   ` Christopher Dimech
2024-07-18  7:12                     ` Emanuel Berg
2024-07-18  7:49                       ` Christopher Dimech
2024-07-21  4:56                         ` Emanuel Berg
2024-07-18  7:29                   ` Eli Zaretskii
2024-07-18  7:57                     ` Emanuel Berg
2024-07-18  9:03                       ` Eli Zaretskii
2024-07-21  4:52                         ` Emanuel Berg
2024-07-18  8:15                     ` Emanuel Berg
2024-07-18  9:04                       ` Eli Zaretskii
2024-07-18  9:13                       ` Christopher Dimech
2024-07-21  4:59                         ` Emanuel Berg
2024-07-19 13:22                       ` Emanuel Berg
2024-07-19 16:12                         ` Christopher Dimech
2024-07-19 16:15                           ` Stefan Kangas
2024-07-19 16:29                             ` Christopher Dimech
2024-07-19 16:16               ` Richard Stallman
2024-07-19 18:00                 ` Christopher Dimech

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=trinity-680b07e3-b4b2-4a40-9a7c-e914c2ac76ab-1722109202194@3c-app-mailcom-bs02 \
    --to=dimech@gmx.com \
    --cc=emacs-devel@gnu.org \
    --cc=incal@dataswamp.org \
    --cc=philipk@posteo.net \
    --cc=shouran.ma@gmail.com \
    --cc=sskostyaev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).