IRC channel logs

2023-04-11.log

back to list of logs

<dsmith>old, Goops was added to Guile later. I'm thinking those are two completely different mechanisms. Like array? is looking at the SCM directly, while is-a? is probing class inheritance trees.
<old>okay
<old>Well I think that GOOPS might actually slow down computation of tensors
<old>I'm passing through The Little Learner and implementing a tensors module in Guile based on array
<old>Dispatching with method would seem natural, but I think it's better to not actually
<sneek>Welcome back dsmith :D
<qookie>I'm looking at the VM details in the manual, and afaics the "Object File Format" section has a typo
<qookie>>‘.guile.docstrs.strtab’
<qookie>> Side table of frame maps, describing the set of live slots for ever
<qookie>I'm pretty sure that's not ".guile.docstrs.strtab", if I had to guess it's a copy-paste mistake from the entry above
<qookie>as such, anyone know what that is supposed to be?
<qookie>hm perhaps ".guile.frame-maps", although that's in a .go file compiled with Guile 2.2, not 3.0, so not sure if it's still the same
<daviid>old: #(1) is a <vector>
<daviid>old: (is-a? #2((ho ho ho) (ho ho ho)) <array>) => #t
<daviid>fwiw
<daviid>dsmith: when was goops added? it was in 1.6, that is afaicr :)
<dsmith>daviid, Sounds about right. It was an independent project before that. Yep, 1.6: https://www.gnu.org/software/guile/manual/html_node/A-Timeline-of-Selected-Guile-Releases.html
<daviid>dsmith: ok, but it exists/existed, afaict, ever since guile exists/existed - it was merged as a guile core module in 1.6, but 'nothing changed'
<dsmith>daviid, This is going back aways, and the memory is *really* scketchy, But *think* I remember that goops had to patch guile when it was separate.
<dsmith>Maybe it was a function that you called to integrate it into the types?
<daviid>the importat thing here is that the following is and never was changed: in goops, <vector> and <array> are distinct classes
<dsmith>Ahh. ok.
<daviid> i have no idea why (array? #(1)) => #t, since it is not an array, it is a vector :) but ...
<dsmith>So what *is* the difference between a vector and an array? I've never used them in any Scheme code, and I was always confused about how they are different.
<daviid>dsmith: 6.6.10 Vectors and 6.6.13 Arrays - implementation wise, arrays can be made of vectors, but from a goops and class pov in general, that doesn't make <array> a <vector> and vis-e-versa ... just wanted to 'help' wrt goops distinct classes with that respect, which is correct
<daviid>with the above said, i understnd in scheme, not goops, "The array procedures are all polymorphic, treating strings, uniform numeric vectors, bytevectors, bit vectors and ordinary vectors as one dimensional arrays." and
<daviid>"Arrays can be of rank 0, which could be interpreted as a scalar" - though (array? 1) => #f - you actually need to 'spell it as an array', that is #0(1) - (array? #0(1)) => #t
<daviid>ok, back to work :)
<old>Just weird to have the predicate array? match a vector
<old>but not GOOP
<old>dispatching is based on predicate
<old>anyway, not using goops so probleme solve
<old>that's sad because vector represent nicely what a tensor-1 is so it would've made thing easier
<lloda>arrays are multidimensional views on vector-like types. Additionally the array functions treat those vector-like types as rank 1 arrays.
<lloda>having (array? 1) => #t would be interesting but it'd make array? superfluous
<lloda>it could be convenient to have (array-ref 1) => 1
<lloda>in most array languages i think there's no difference between 1 and #0(1)
<lloda>there's some clunkiness about this in Guile
<minima>hi, i was looking into some guile library for data visualisation, e.g. something (roughly or partially) equivalent to python's matplotlib or some wrapper around the vega specification - from a quick web search, i gather that there's no established guile project in this space yet, is this correct or am i missing anything?
<pinoaffe>minima: there's nothing established as far as I know
<minima>something popped up re guile+gnuplot
<minima>pinoaffe: ok, thanks
<pinoaffe>IIRC skribilo (https://www.nongnu.org/skribilo/) has some basic graph support
<minima>super, thanks
<pinoaffe>and a couple of years ago, I did write some (hacky) code to visualize data by generating SVGs, but I can't seem to find said code
<pinoaffe>IIRC that code could do bar graphs, stacked bar graphs, and heatmaps on an SVG of the various countries of the globe, so fairly limited
<minima>pinoaffe: oh ok, that's a good start, but yeah, i might end up using python+matplotlib for this small task of mine then
<pinoaffe>oh and yet another option: there's a way to interact with gnupot from guile, though I haven't played with that too much
<minima>yes, i was reading about gnuplot - that makes sense too
<Zelphir_>Some time ago I watched some video about a data visualization library in Racket. Trying to find it.
<Zelphir_>Hm, maybe it was "Graphite" (https://invidious.baczek.me/watch?v=qSM-rbOkmn0) build on top of "Plot" of Racket, I think.
<lloda>i have a home cooked plotting library based on guile-cairo, but it isn't in a publishable state unfortunately. guile-cairo lets you write to svg or to a texture and it's fast enough to update live
<minima>hey thanks Zelphir_! very kind and helpful, i'll look that up
<lloda>the problem with using gnuplot from guile is that serializing & piping is very slow
<lloda>before i used guile-cairo i used to pipe to gnu plotutils and that was also super slow
<dsmith>sneek, botsnack
<sneek>:)
<mwette>gr-framework.org is a c library for plotting
<minima>thanks mwette i'm looking at it now
<old>minima: there's guile-charting that works great
<old>otherwise now I've shifed toward calling gnuplot directly
<old>lloda: I don't consider tensor-0 to be array. They are actually scalar. The original question was why (array? #(1)) => #t but not (is-a? #(1) <array>)
<old>to me this is inconsistent, but this is explained for historical reason apparently
<lloda>is-a? looks at the type tags, while array? is a works-as? kind of predicate
<lloda>since the array api is polymorphic
<lloda>you could have array? just look at the type, but that would have its own issues
<old>ideally, <vector> should inherit from <array>
<old>IMO, vector is just a special case of an array
<old>a rank-1 array
<lloda>you can have rank-1 arrays as it is
<old>sure, but not with the reader I think?
<old>Or maybe #1(1 2 3) is an array
<old>and #(1 2 3) is a vector
<lloda>it's important not to confuse the concept of rank-1 array or 'vector' with guile's 'vector' type which is not derived from array for very good reasons
<lloda>you can think of both of those as 1-arrays and as long as you use the array api everything works fine
<lloda>guile's 'vector' isn't derived from guile's 'array' because the guile's 'vector' is one of the possible containers used by guile's 'array' so that derivation would introduce a circularity which would be very cumbersome
<old>I see
<Zelphir_>Guile's arrays can use other containers than vectors? Does this mean, that for example I _could_ tell the array to use lists instead?
<lloda>if you use objects of different ranks then that's what the array api is for
<lloda>not lists. You can use vectors, bitvectors, strings, and all the srfi-4 type vectors
<lloda>you cannot use lists bc they don't have random access
<lloda>well to be clear you can't use lists because that hasn't been implemented. But it hasn't been implemented bc lists don't have random access so that makes the array api a very bad fit
<Zelphir_>Hm, not sure I am understanding it correctly. Do you happen to have any code examples or know any that makes use of other containers?
<old>Zelphir_: You can't access the Nth element in O(1) in a list
<old>in theory an array can be implemented with list, but that would the the slowest array on earth
<Zelphir_>OK I get that. Was just asking to facilitate my own understanding ; )
<old>I think it's also ppossible to use bytevectors as the container
<Zelphir_>So basically the array can use different representations, right? I still have array API/functions, but the underlying data structure can be changed?
<old>So okay in that sens, it make sens to not have Guile vector an array. I get the separation now
<old>Zelphir_: Right. That allows you to manipulate N-dimensions string whatevher that is ^^
<Zelphir_>Oha. Sounds amazing.
<lloda>Zelphir_: idk something like (make-shared-array "abcdefghi" (lambda (i j) (list (+ (* i 3) j))) 3 3)
<Zelphir_>Kind of makes me think about languages in which everything is a string (sh? TCL?).
<lloda>that gives #2a((#\a #\b #\c) (#\d #\e #\f) (#\g #\h #\i)) which is a 2-array based on a string
<lloda>the 'a' in #2a(...) means that the container for this array is a string
<Zelphir_>Whoot, I will need to look at that later!
<lloda>there's make-typed-array where you give the type directly.
<old>lloda: the documentation is not clear on that
<lloda>the default type is #t, then the container is a vector
<old>lik the type can be 'u8
<Zelphir_>I saw make-typed-array before, but I did not realize it works this way or is used this way. I thought it was merely about the type of the things inside the array, not about the representation of the array.
<old>would the type be 'string ?
<old>Zelphir_: I though that Guile was choosing the best container based on the type
<lloda>well the type is 'character' and the type tag is 'a' but the container is a string
<lloda>if you use a bytevector as a container, then the type is u8 and the type tag is 'u8'
<old>lloda: There's a section of the manual for that? I've not seen the 'a tag
<lloda> https://www.gnu.org/software/guile/manual/html_node/Array-Syntax.html
<lloda>'The <vectag> part is the tag for a uniform numeric vector, like u8, s16, etc, b for bitvectors, or a for strings. It is empty for ordinary vectors. '
<lloda>'The underlying storage vector is created according to type, which must be a symbol whose name is the ‘vectag’ of the array as explained above, or #t for ordinary, non-specialized arrays. '
<lloda>^ that's the doc for make-typed-array
<Zelphir_>But how does it know, how to "separate" the single elements (characters) of the string? I suppose that is why it needs to be implemented for types to work. So if one implemented a "way dividing into pieces" for another type, then that could be used as well?
<old>Yes but is there a list of available tag?
<old>I see that there's srfi-4 that define some
<lloda>the list above is exhaustive. It's either uniform numeric vector, or bitvector, or string, or ordinary vector.
<lloda>the uniform numeric vector tags are f32 f64 c32 c64 and (u/s)*(8/16/32/64)
<lloda>Zelphir_: all the array api does is convert index sets into a single index into the container
<lloda>the conversion has to be a linear function and the bounds of the array have to be rectangular, so it's far more limited than any 'way of dividing into pieces'
<lloda>but that's the way dense arrays work everywhere
<lloda>it's very possible that the doc is unclear. Probably I don't have the right perspective to realize that
<lloda>you can get at an array's container with shared-array-root, e.g.
<lloda>(bytevector? (shared-array-root (make-typed-array 'u8 0 3 3))) => #t
<Zelphir_>So basically, if I have a string container type, then an array-ref access will have the access time characteristics of a string-ref (plus a tiny bit of overhead for translating the indices to the index for the string). Correct?
<lloda>yes
<Zelphir_>Thanks for all the explanation. TIL something new about Guile's arrays.
<Zelphir_>Quite cool too!
<lloda>yw
<lloda>if you know about numpy for example, this is pretty much the same
<Zelphir_>I know numpy from usage, but not how it works inside ;)
<lloda>i c!
<minima>hey old, thanks, big thumbs up for guile-charting - it's pretty disappointing that i wasn't able to find it via my web search, the name is even... well, so obvious, anyway, thanks!
<Zelphir_>guile-charting seems to be available via GNU Guix as well.
<old>lloda: Numpy does a lot more no?
<old>Also I wonder what are the performance comparison between the two
<old>Both have a C backend so I assume similar performance
<old>minima: Sure! However, from my personal experience, I had to copy a lot of the procedures in my project to re-implement the chart to my sauce
<old>But I did publish my research paper with it. I should've added a 'Powered By Guile Charting' at the end
<Zelphir_>old: Probably cannot compare the 2 in terms of performance. Numpy I believe makes use of highly optimized linear algebra libs (when it can?). But lloda has a library to interface with BLAS and such, iirc and am not mixing people up : )
<minima>Zelphir_: indeed, that's also a great point
<lloda>old: yeah numpy does a ton more. I just meant that the basic array structure, a container + bounds + strides, that's the same
<old>Zelphir_: Which package on Guix? I don't see guile-blas or anything like that
<old>ah sure. It's basic linear interpolation
<minima>old: yeah, i might consider it (guile-charting) for some of my projects and then maybe settle for some other mainstream datavis lib for when things need to be made more approachable to colleagues
<old>eh wrong word here. Maybe more linear transformation
<old>minima: I ended up with gnuplot. I define the script in a `format #f' and pass the result to a `system*' call
<old>Not because I was not happy with charting, but I did not wanted to maintain the charting portion anymore in my project
<lloda>performance wise numpy is way faster because it does a lot of stuff in C or in libraries. While guile just doesn't do much at all. It's little more than the type
<old>I see
<lloda>i mean if you call to blas with guile arrays or in numpy, that's the speed of blas, so it'll be the same
<old>maybe it's time for guile to have its numλ
<lloda>my cblas bindings are https://github.com/lloda/guile-ffi-cblas but i'd prefer if people used https://github.com/lloda/guile-ffi-blis which is a nicer library
<Zelphir_>old: If I may: https://github.com/lloda/guile-ffi-blis and I had an example usage for it, very basic only: https://notabug.org/ZelphirKaltstahl/guile-math-examples/src/master/matrices You will have to have BLIS or so installed. I installed it using Guix apparently.
<old>or maybe a λtorch
<lloda>there are some libraries in that vein iirc
<lloda>aiscm?
<old>I saw that one yes
<old>i has binding for TensorFlow
<lloda>it reimplements the array type, which i think was unnecessary but oh well
<old>well if memory access is not fast as one would like idk
<old>maybe also it was not easy to interpolate the memory region associated with an array and pass it to TensorFlow
<lloda>i think the memory for all these types are the same
<lloda>the array type is just an indirection mechanism
<old>s/interpolate/isolate
<old>Apparently I have a a problem with using that word today
<old>I guess it's a big flat memory area
<lloda>yeah all the array container types are contiguous memory. There's an libguile interface for passing arrays to C and you just pass some pointers
<lloda>a libguile interface
<old>Yes I saw that one
<old>gotta lock the array though
<old>not sure if it's actual locking with Mutex though
<old>that would hit performance for read-access
<lloda>yeah if you make your own arrays in Scheme you don't need that. I've argued with the maintainers if that was necessary at all
<lloda>the _release thing
<old>yes
<lloda>it's not a lock, just a remember_upto_here kind of thing for the gc
<old>ah okay