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: Matt Wette
Subject: Re: Matrix or array operations library
Date: Thu, 27 Dec 2018 06:20:10 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

On 12/26/18 3:38 AM, Zelphir Kaltstahl wrote:
On 25.12.18 18:00, address@hidden 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






reply via email to

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