[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding a generic mathematical library
From: |
Christopher Dimech |
Subject: |
Re: Adding a generic mathematical library |
Date: |
Sun, 28 Jul 2024 15:56:54 +0200 |
Sent: Monday, July 29, 2024 at 1:34 AM
From: "Immanuel Litzroth" <immanuel.litzroth@gmail.com>
To: "Christopher Dimech" <dimech@gmx.com>
Cc: "Shouran Ma" <shouran.ma@gmail.com>, "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
> Indexing in an everyday task ...
Like writing?
Immanuel
Yes, like writing. Referring to elements within a collection (like arrays,
lists, or strings) using numerical indices, is a fundamental concept in
programming. Despite its simplicity, proper understanding and handling of
indexing are crucial for writing correct and efficient code. Indexing errors,
like off-by-one mistakes, are among the most common bugs in software
development.
It shows that developers do require a solid understanding as much as architects
and engineers. Handling indices correctly, including understanding when to
increment or decrement by one, is a critical skill. These seemingly trivial
issues can lead to significant bugs, from incorrect data processing to security
vulnerabilities.
The idea that anyone can code to a specific standard without foundational
knowledge is wrong. While many people can learn to write code at a basic
level, developing high-quality software requires a deeper understanding of
algorithms, data structures, software design, and debugging techniques.
In fields like architecture and engineering, professionals undergo rigorous
training to understand the principles and practices necessary to ensure safety,
functionality, and aesthetics in their work. This foundation is not present
in computing today.
But, Emanuel has mentioned a different problem, the unusual symbol vec that is
placed.
And that there is often complex mix of different ways to do things, all over
emacs,
making development very slow paced. It is the latter consideration that should
be improved.
On Sat, Jul 27, 2024 at 9:40 PM Christopher Dimech
<dimech@gmx.com[mailto:dimech@gmx.com]> wrote:
> Sent: Sunday, July 28, 2024 at 7:07 AM
> From: "Shouran Ma" <shouran.ma@gmail.com[mailto:shouran.ma@gmail.com]>
> To: "Emanuel Berg" <incal@dataswamp.org[mailto:incal@dataswamp.org]>
> Cc: emacs-devel@gnu.org[mailto:emacs-devel@gnu.org], "Sergey Kostyaev"
> <sskostyaev@gmail.com[mailto:sskostyaev@gmail.com]>, "Philip Kaludercic"
> <philipk@posteo.net[mailto: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[mailto: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[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[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[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[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[mailto: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
>
>
--
-- A man must either resolve to point out nothing new or to become a slave to
defend it. -- Sir Isaac Newton
- Re: Adding a generic mathematical library, (continued)
- Re: Adding a generic mathematical library, Shouran Ma, 2024/07/27
- Re: Adding a generic mathematical library, Christopher Dimech, 2024/07/27
- Re: Adding a generic mathematical library, Emanuel Berg, 2024/07/28
- Re: Adding a generic mathematical library, Christopher Dimech, 2024/07/28
- Re: Adding a generic mathematical library, Emanuel Berg, 2024/07/28
- Re: Adding a generic mathematical library, Christopher Dimech, 2024/07/28
- Re: Adding a generic mathematical library, Emanuel Berg, 2024/07/28
Re: Adding a generic mathematical library, Christopher Dimech, 2024/07/27
Re: Adding a generic mathematical library, Emanuel Berg, 2024/07/28