guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matrix or array operations library


From: John Cowan
Subject: Re: Matrix or array operations library
Date: Fri, 28 Dec 2018 18:16:02 -0500

On Fri, Dec 28, 2018 at 4:34 PM Daniel Llorens <address@hidden>
wrote:

Of course all those other languages have extensive (and more or less
> consistent) array facilities, while base Guile only has make-shared-array
> (and transpose-array, for some reason).


If array objects don't have an offset (the index in the backing store of
the [0,0, ... 0] element), you can't do arbitrary translations,
unfortunately.  If Guile doesn't have that, it should.


> For what is worth I think the array type needs to be moved to Scheme, but
> this should be done in a backwards compatible way.


Layering a Guile compatibility mode over SRFI 122 might be a Good Thing.
Arrays there allow arbitrary affine transformations of the indices, provide
lazy elementwise mapping (you can get eager mapping by composing mapping
with copying), and have fast paths for arrays of up to 4 dimensions.
Read-only and read-write arrays defined by arbitrary getter and setter
functions are also provided, and work exactly like storage-based arrays.
SRFI 122's only major limitation, which IMO is not a serious one, is that
it doesn't handle 0-dimensional arrays (with one element) or degenerate
arrays with non-positive dimensional ranges (with zero elements).  The code
is in Gambit Scheme, but translating it to portable Scheme is an easy
matter (I just haven't gotten around to it).  The main Gambit-specific
dependency is define-macro (non-hygienic) macros, but nothing very bad is
done with them.

There is a post-SRFI fork at https://github.com/gambiteer/srfi-122/ which
will fairly soon become an updated SRFI.

-- 
John Cowan          http://vrici.lojban.org/~cowan        address@hidden
Yakka foob mog.  Grug pubbawup zink wattoom gazork.  Chumble spuzz.
    --Calvin, giving Newton's First Law "in his own words"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]