freenode/#lisp - IRC Chatlog
Search
2:12:39
aeth
of course it's implementation-specific, but I don't see why implementations where that currently doesn't work can't add that trick
2:19:53
buffergn0me
Do you have any favorite libraries for array programming with Common Lisp? I have it in mind to play with https://github.com/phantomics/april when I have the time, but that goes way too far away from Lisp
2:20:09
aeth
buffergn0me: Oh, and I think another use of 0D arrays is to (near-)directly translate C code that uses (iirc, it has been a while) &foo
2:22:13
aeth
buffergn0me: I mostly write my own code, but it's mostly games/graphics-related so it has simplifying assumptions like 4x4 matrices.
2:23:41
aeth
The simplifying assumptions allow me to do things like compose functions that return multiple values with functions that set from multiple values, e.g. here: https://gitlab.com/zombie-raptor/zombie-raptor/blob/3f7549a14b0cbe558c97eb5e2c4ea7e02f3fcc7e/util/array.lisp
2:25:44
aeth
buffergn0me: With that, I can do things like this: (let ((m (make-array '(4 4) :element-type 'double-float :initial-element 0d0)) (v (make-array 4 :element-type 'double-float :initial-contents '(1d0 2d0 3d0 4d0)))) (setf (array-row-of-4 m 2) (array-of-4 v)) m)
2:31:27
aeth
Going too far beyond 4 I wouldn't want to do a complete loop unroll. Probably looping in 4's could work.
2:41:58
aeth
It's probably better to write an array-capable version of #'replace for larger, arbitrary things, actually.
3:01:08
verisimilitude
Displacement doesn't work as nicely as it could with n-dimensional arrays, though.
5:09:37
aeth
for 2D (probably the most common after 1D), just selecting a row and a start and an end works for most cases
6:43:18
karlosz
its wrong to assume that array elements are initialized to 0 without specfiying initial element or initial contents right?
6:45:41
beach
"If initial-element is not supplied, the consequences of later reading an uninitialized element of new-array are undefined unless either initial-contents is supplied or displaced-to is non-nil."
6:46:22
karlosz
right, i was beginning to self doubt myself because the sbcl internals make that assumption somewhere in make-hash-table
6:49:04
karlosz
an array is created but implicitly assumed to be initialized to zero which was causing problems for me