From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: Matrix or array operations library Date: Thu, 27 Dec 2018 06:20:10 -0800 Message-ID: References: <0124a907-fd07-21dc-ba70-49a7ce4daf29@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1545920318 13786 195.159.176.226 (27 Dec 2018 14:18:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 27 Dec 2018 14:18:38 +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 Thu Dec 27 15:18:34 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 1gcWUc-0003T0-1W for guile-user@m.gmane.org; Thu, 27 Dec 2018 15:18:34 +0100 Original-Received: from localhost ([127.0.0.1]:53154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcWWi-0008Jz-8g for guile-user@m.gmane.org; Thu, 27 Dec 2018 09:20:44 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcWWE-0008Jt-Cd for guile-user@gnu.org; Thu, 27 Dec 2018 09:20:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gcWW8-000476-Jg for guile-user@gnu.org; Thu, 27 Dec 2018 09:20:14 -0500 Original-Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:38551) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gcWW8-00045h-DE for guile-user@gnu.org; Thu, 27 Dec 2018 09:20:08 -0500 Original-Received: by mail-pl1-x62d.google.com with SMTP id e5so8837123plb.5 for ; Thu, 27 Dec 2018 06:20:08 -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-transfer-encoding:content-language; bh=5hfE6gJoD0plt0ow4eKJaxeGM9krvPob+xIXeg9Y8xw=; b=LB90b2VNoAs8HHpCXUuBA4fApKcw9CPohO+/kMpTCp6TVuECL1z7404tWWMUVychPr Fi3kCVG+5UlC584zQ7AcLWRLlLzFd1cPDmozhe8Te1UGmOqXwreEAxr5ZZVqMjSImeBs JOjU7K+ZGuGSoTWow8p1PaYAX0s5Rxh0oHd3BxND2oriLJYjmmrSWTfUZ4krSW9cJA3y Nf7XQUpOHy52W+g7aoQOEyEqrCNODIymC65NJsltONTdiFgXqqxi6bTb6+jmB1aPdlw1 ufchDZJVePa9U/Ci3hso9im56kXlF70DtsokJ272HwxPt1wnoHuiJ7IK++jG/LM5kN41 zYpw== 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-transfer-encoding :content-language; bh=5hfE6gJoD0plt0ow4eKJaxeGM9krvPob+xIXeg9Y8xw=; b=AKB399f9PGF6ycTyZkzJo04LZ4lsf+rVZikB33VRmIoTabLWDukQLK4YMc/ebalbeK yHZabfh0TmfWH57IJ1rst9H1zDtsXvp0dVxrh66vVtPn423grCNAaIgI6VzalTXexxpX nuzxHNP9uzdY6qZO/I+tLUl+UUVM+smvxsd6aW7S57KMLjTVO9IQcoRQWZx5HQHKFPsB 0YuSBrOA408Oyhq7Tpk+e5OarqtblQnsi8mI38E3Q7oXk4YgTyTyiSuKS+irHCzQ7dUo PpLCLVevpw7Nuahwlm9tVe1OUTu0KZpiRzJkG+BOg8o4u/SztI4EvSaeQHeUIqW3LpKw eIxg== X-Gm-Message-State: AJcUukfqz/D9962gWYRCPIQkJr78gqPBqITHmfmxOKkk3UtT56SVwYZU vV91bueiM0DEskpxd942vGF7m6uH X-Google-Smtp-Source: ALg8bN4KzYUA0JKwguHPj/YTOUwq9CH9muByNIQ0PmzDmrA9dblEU8tJcr+rDNHtSnbaYz3KQt0fhg== X-Received: by 2002:a17:902:9a02:: with SMTP id v2mr24371661plp.180.1545920406582; Thu, 27 Dec 2018 06:20:06 -0800 (PST) Original-Received: from [192.168.1.48] (172-222-202-134.dhcp.chtrptr.net. [172.222.202.134]) by smtp.gmail.com with ESMTPSA id j9sm48489352pfi.86.2018.12.27.06.20.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 06:20:05 -0800 (PST) In-Reply-To: <0124a907-fd07-21dc-ba70-49a7ce4daf29@gmail.com> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::62d 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:15153 Archived-At: On 12/26/18 3:38 AM, Zelphir Kaltstahl wrote: > On 25.12.18 18:00, guile-user-request@gnu.org wrote: >> 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 ? The advantage of the FFI Helper is time. It takes minutes to generate a ffi-module and seconds to compile to Guile Scheme. It takes significantly more time to code by hand. While coding by hand gets you something that is probably more palatable, using the FH can cover more ground. > (Q2) What is that `guild` command in the guide? (sounds like guildhall > another Guile project, but I forgot what that does) "guild" is the Guile compiler. Try "guild compile foo.scm". > (Q3) How would I set everything up, so that I can follow the tutorial at > https://www.nongnu.org/nyacc/ffi-help.html? download and read the README * the tarball repository: https://download.savannah.gnu.org/releases/nyacc/ * the git repository: git://git.savannah.nongnu.org/nyacc.git > 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? It takes a decent C parser to read the include files. > (Q5) Do I need NYACC installed on my system to do the stuff in the > tutorial you linked? Yes > 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. I'm not sure what you are asking. If you want to work now in Guile try some of the other packages offered. To implement numpy would take some work and I think the concept could go farther in Guile (e.g., some sort of lazy eval scheme that can optimize evaluation of multi-operand expressions, who knows). > 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 > >