From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Re: Re: Matrix or array operations library Date: Wed, 26 Dec 2018 12:38:36 +0100 Message-ID: <0124a907-fd07-21dc-ba70-49a7ce4daf29@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1545824229 25468 195.159.176.226 (26 Dec 2018 11:37:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 26 Dec 2018 11:37:09 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Dec 26 12:37:05 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 1gc7Um-0006UQ-T9 for guile-user@m.gmane.org; Wed, 26 Dec 2018 12:37:05 +0100 Original-Received: from localhost ([127.0.0.1]:45709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gc7Wt-000625-8Z for guile-user@m.gmane.org; Wed, 26 Dec 2018 06:39:15 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gc7WL-00061n-BZ for guile-user@gnu.org; Wed, 26 Dec 2018 06:38:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gc7WJ-0001Lh-OL for guile-user@gnu.org; Wed, 26 Dec 2018 06:38:41 -0500 Original-Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:37173) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gc7WJ-0001Ki-F8 for guile-user@gnu.org; Wed, 26 Dec 2018 06:38:39 -0500 Original-Received: by mail-ed1-x532.google.com with SMTP id h15so13033915edb.4 for ; Wed, 26 Dec 2018 03:38:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=t0pkGyb1erJN8wAJCIaCs0CMDtk6xyI3GfttkaGXtrE=; b=Vzy+Eb5SHD5zsQX/Y9buwUq7ASFTvmvJ0CLB3MpbSTTvaUxFK3qBMHcaqzYdWUVW+j EK66lcYzUcVo+3P9Gom0uLDZZzsrp0K2EkY6vfMXuux2x/mbNbDUvpFP1OJihbQIQMVa EBPAoZHvMsGYNzirJTtsLhh6vDc9g3M3SrO+Q4RpmiPiISAZ99hB15kQKnwLvh1e0Hih PRCkZpFrgnCWcT1We4HK3S7AfoSh0eArfWqYhEeFvj/byILUzbk+a28JxJv+f9JZNf43 mu5MDbPsbA5gnm2L89JtOCRPYAKcb1X9eWMV/YGwnzXj7AbPVcbj0zyDUoaBby60cUzh WVog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=t0pkGyb1erJN8wAJCIaCs0CMDtk6xyI3GfttkaGXtrE=; b=dsB75sV1t4gaz09qLyot5oa0QGRLw2/btkVrXkUK54Pm8nQ+Cy1/k8xON54pXNsxvt 7MwzrGJH+Ue+7kfdeyUpoQh+sA2h7knPFLpqCc6I7nGkQ45gCQSHj46SZdC8W1pS0Z/3 NXHhUCNQm/tuTgclq+g4PKZZ4jVWCxW1ELm/jKhX0WoA76LI1ulHWIRBlyL404z86E5u MK9WnFcMMmco6klEtoJAjdaxaxaK3KO7g59k4kPamBRIK8FzrhPiWaZX7NzaFyd8cFNw HavUm0m9NmFY52lHb1V6CfdvyecK+7hBI9i5Klc3u2Mgli4axyS31pXKO0jPJAReunj5 QpkQ== X-Gm-Message-State: AA+aEWayjMYLLpR3W1OHqWjtSwZWGKqeEBUzAaPr4H3iP103Br+zeKaU doGmsgSs23ADghKXO1r+Ein6OtMA X-Google-Smtp-Source: AFSGD/UkjN9gumLszNm2YrX5L6MveztxrGycEQzIy3W/hsAv3RtOajEThoiM/J4xrnHR2XFl64GwMA== X-Received: by 2002:aa7:d29a:: with SMTP id w26mr15729757edq.30.1545824317974; Wed, 26 Dec 2018 03:38:37 -0800 (PST) Original-Received: from ?IPv6:2a02:8109:8b80:3950:c4cb:cbd1:3652:ebd? ([2a02:8109:8b80:3950:c4cb:cbd1:3652:ebd]) by smtp.googlemail.com with ESMTPSA id m14sm10502828edc.27.2018.12.26.03.38.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Dec 2018 03:38:37 -0800 (PST) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::532 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:15145 Archived-At: On 25.12.18 18:00, guile-user-request@gnu.org wrote: >> Hello Guile Users, >> >> Is there some library, that enables high performance matrix operations >> or even n-dimensional array operations? I am thinking of something like >> NumPy in the Python ecosystem. I think NumPy in turn also uses some >> lower level thing to do what it does. I think OpenBLAS or MKL, depending >> on the architecture. I wonder if there is any wrapper around OpenBLAS >> for Guile or something similar. >> >> I am writing a little code for matrix operations and currently I am >> using Guile arrays, as they are made of vectors and have constant access >> time, which is already great. My guess is, that this would be the right >> choice if using pure Guile. I am writing data abstraction procedures, so >> that later on I could exchange what is used to represent the data. >> >> Maybe, if there is something like NumPy or lower level, I should use >> that instead? (Would I have to learn how to use FFI first?) >> >> Or maybe Guile's implementation is already so fast, that it would not >> make that much difference to use a lower level thing? >> >> Currently I have only a little experimental program, started today, so >> no huge plan. OK, one can fantasize about stuff like Pandas data frames >> in Guile, but I have no illusion, that it is a work of a few days or >> even weeks. It would be nice to learn, how to use a low level thing or >> maybe even Pandas, if there are any such bindings for Guile. I could >> make the implementation use different representations, depending on a >> parameter or something like that. >> >> Regards, >> >> Zelphir >> > IMO, Guile probably needs something like ndarray, the base for numpy, > if matrix operations are going to go anywhere. > > As far as using blas or others, I have developed a package for helping > to use the FFI API for C libraries. It may be of interest to you. > > ffi-helper: https://www.nongnu.org/nyacc/ffi-help.html > > Matt Hi! Thanks for the link Matt. Now I have a bunch of questions :-) I started reading the guide you linked to. I've never done any FFI stuff in any programming language so far, so this is completely new territory for me. (Q1) Can you explain what the advantage of the method you linked to is, in comparison to doing something like https://www.gnu.org/software/guile/manual/html_node/Dynamic-FFI.html ? (Q2) What is that `guild` command in the guide? (sounds like guildhall another Guile project, but I forgot what that does) (Q3) How would I set everything up, so that I can follow the tutorial at https://www.nongnu.org/nyacc/ffi-help.html? iirc NYACC is a minimalistic compiler that was mentioned here on the mailing list several times in the context of bootstrapping Guile. (Q4) How is NYACC connected to doing FFI? (Q5) Do I need NYACC installed on my system to do the stuff in the tutorial you linked? I guess, since I don't know things about FFI in general (except that I somehow get to magically call functions of another programming language), things like NumPy are out of my league for now and I should start with simple learning examples, to get an understanding of how FFI usually works and what things one touches, when using FFI for a library in another language and how much understanding of how the library works one needs to have. With regard to NumPy, especially the stuff about the "strides" (whatever that is) in the data buffer of a NumPy array and how what changes when creating a view and changing indices (For example I cannot imagine a single reason, why the ordering of how one writes the indices would matter, except for human readability?) … If I need to keep track of that … Let's just say I dislike working on a low level with a lot of pointers, addresses and segfaults ; ) (Q6) Maybe I do not need to pay attention to how NumPy does things, except for procedure names, since NumPy handles it and I am just calling its procedures somehow? That's what I would be hoping for. Maybe those are a lot of questions and maybe most of them would be answered, if I ever did any FFI stuff before. If anyone knows a good tutorial on FFI in Guile that explains this stuff, that would be great too. Or maybe someone knows some easy-to-ffi library to try things with? Best regards, Zelphir