freenode/#lisp - IRC Chatlog
Search
19:08:35
anamorphic
Hi, Is this the most effective way to convert a sequence of any kind of numbers to a one-dimensional array of double-floats? (let ((x-array (make-array length-x :element-type 'double-float))) (map-into x-array #'(lambda (value) (coerce value 'double-float)) x-sequence) ...)?
19:25:22
aeth
anamorphic: you might want to use the type (simple-array double-float (*)) instead of (vector double-float) in case the latter doesn't make it a simple-array
19:26:12
aeth
if it's simple, that means there's no fill-pointer and it's not adjustable (and maybe a few other things) so it's faster.
19:27:48
aeth
A vector is a 1D array. A simple-vector is a simple T vector. A simple-array is a simple array. There is no specialized simple-vector. There are specialized vectors, apparently, since pfdietz just defined one. This is a flaw in the standard imo
19:28:40
aeth
9 times out of 10 your simple-array is going to be a 1D array (i.e. a vector) but you have to use the more verbose multi-dimensional array syntax to talk about it
19:29:16
aeth
Usually you get around this by defining your own easier-to-type type if your code is filled with it.
19:40:52
aeth
(If simple-vector worked like everything else you could just say (simple-vector double-float) instead of (simple-array double-float (*)) since the size would be an optional argument at the end. But you can't.)
19:47:36
anamorphic
Yeah had noticed that about simple-vector. Is it a historical thing that it doesn't have a type specializer?
19:54:06
White_Flame
but yeah, I've been bitten by that as well in utf-8 and byte buffer conversions. One library uses simple-vector, the other uses simple-array, and they are not interchangeable; you need to copy the data to an object of the other type in order to bridge them
20:08:25
oni-on-ion
https://sirherrbatka.github.io/blog/2018/10/11/cl-data-structure-ranges-are-pretty-cool/
20:27:11
XachX
the 403 in that case really means "no object is here but i don't want to tell you that"
20:27:11
shelvick
Oh? interesting... I was doing something through qlot which has worked before up until maybe an hour ago
20:27:50
XachX
shelvick: https://beta.quicklisp.org/dist/quicklisp/2018-08-31/distinfo.txt is the normal pattern
20:30:54
aeth
If you use a simple-vector for octets then everything's 4x larger in memory (if 64 bit) and the compiler loses any chance at knowing what type it is when AREFing
20:43:10
aeth
(Oh, and the GC has to iterate through the T vector to see if anything's a pointer, doesn't it?)
22:16:51
White_Flame
oh, regarding the above discussion, the binary type mismatch was simple-array of bytes, vs vector of bytes
22:17:24
White_Flame
sb-ext:octets-to-string for example requires a specialized (vector (unsigned-byte 8))