From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Daniel Llorens Newsgroups: gmane.lisp.guile.user Subject: Re: Matrix or array operations library Date: Sat, 29 Dec 2018 01:17:37 +0100 Message-ID: <2D1247B3-4B56-45C3-9AC4-5EA5E1B0858B@bluewin.ch> References: <1C6C55C9-24B1-4952-BC1A-18CF80749565@bluewin.ch> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1546042978 20246 195.159.176.226 (29 Dec 2018 00:22:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 29 Dec 2018 00:22:58 +0000 (UTC) Cc: guile-user , Matt Wette To: John Cowan Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Dec 29 01:22:54 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gd2Ox-000590-Ja for guile-user@m.gmane.org; Sat, 29 Dec 2018 01:22:51 +0100 Original-Received: from localhost ([127.0.0.1]:33934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gd2R4-0005oB-4W for guile-user@m.gmane.org; Fri, 28 Dec 2018 19:25:02 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gd2Ph-0004on-E2 for guile-user@gnu.org; Fri, 28 Dec 2018 19:23:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gd2Jw-0004fO-Bq for guile-user@gnu.org; Fri, 28 Dec 2018 19:17:43 -0500 Original-Received: from vimdzmsp-sfwd04.bluewin.ch ([195.186.227.132]:52202) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gd2Jw-0004YU-1l for guile-user@gnu.org; Fri, 28 Dec 2018 19:17:40 -0500 Original-Received: from 4box.home ([100.91.106.162]) by vimdzmsp-sfwd04.bluewin.ch Swisscom AG with SMTP id d2JtgXbSghKo0d2JtgQXn2; Sat, 29 Dec 2018 01:17:37 +0100 X-Bluewin-Spam-Analysis: v=2.1 cv=TL+IMwRa c=1 sm=1 tr=0 a=E/cB+Ag6Owp6h9AtTK67vw==:117 a=E/cB+Ag6Owp6h9AtTK67vw==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=2tsvuTQuAAAA:8 a=cVraocY-AAAA:20 a=8YJikuA2AAAA:8 a=4YSMtcsalHV38brjrucA:9 a=CjuIK1q_8ugA:10 a=GGm_g7KM3N1HjSb0:21 a=_W_S_7VecoQA:10 a=w1QI8THEI4iyJQ0oNEIE:22 a=iwh3BSu4myUNQlX_M7KP:22 X-Bluewin-Spam-Score: 0.00 X-FXIT-IP: IPv4[100.91.106.162] Epoch[1546042657] X-Bluewin-AuthAs: dll@bluewin.ch In-Reply-To: X-Mailer: Apple Mail (2.3445.102.3) X-CMAE-Envelope: MS4wfMzvJhWzuVlKFa/a+E+QWsCQCfmYNMXm1g0abEy5oT8Z6oeQF4gZXMWlcjWx0Qse01oCa9Y465viSoSXEyUF4EGmJvvOvtHVeokJvOzDUNhs0mwDBYep otRC0+6/K84Z2ar9XpxAcY7fK/l/x0HcGXxSBy3Qya89F6l1TOA2JV4CeeKvkOw9L6uwiQAKWE82YDl6NbJk82hN9+la7tsy6K2fxa5E8jGiktBEEI8eyicQ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 195.186.227.132 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15168 Archived-At: > On 29 Dec 2018, at 00:16, John Cowan wrote: > 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. It does; I just forgot to mention it. make-shared-array accepts any = affine function of indices. There's even a function to get at the offset = directly (shared-array-offset). All this is in the manual and has been = in Guile for a long time. > 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. Rank 0 arrays and empty arrays happen all the time if you work with = arrays. I think it would be annoying to have to look out for special = cases. To be honest I find it strange that SRFI-122 doesn't support those you = since you shouldn't need to do anything special (Guile supports them for = free, other than a special case in the read syntax iirc).=20 Guile only has the type and a few low level functions. My library = guile-ploy provides arbitrary arity and arbitrary rank rank extension on = top of Guile, plus a bunch of array functions, including full APL-style = slicing. Still no lazy mapping, that would be nice to have. You probably = want operator overloading as well. One thing that is needed is a linear range generator of some kind, like = a:b in Python. It's not enough to provide a procedure for this, since = the slicing function must be able to recognize this linear range in = order to avoid copying. For instance x[a:b], should produce another = array with different strides, not a copy and not a lazy map either. In = guile-ploy this is written (from x (range a b)), where (range a b) is a = special type. In guile-newra this linear range is one of the basic = vector types (along with vectors, bytevectors, and srfi-4 vectors). Does = srfi-122 provide something like this? I suppose if you have lazy maps = the linear range can be done with those and then the slicing function = can be written to recognize it. I shall try and have a look. Daniel > There is a post-SRFI fork at https://github.com/gambiteer/srfi-122/ = which will fairly soon become = an updated SRFI. >=20 > --=20 > John Cowan http://vrici.lojban.org/~cowan = cowan@ccil.org = > Yakka foob mog. Grug pubbawup zink wattoom gazork. Chumble spuzz. > --Calvin, giving Newton's First Law "in his own words" >=20