array-copy, array-stack, array-append: What should the defaults be?
Bradley Lucier 02 Oct 2021 18:42 UTC
On 9/25/21 9:23 AM, Alex Shinn wrote:
>> 3) (array-append k a1 a2 ...)
>>
>> 4) (array-laminate k a1 a2 ...)
> Both of these are provided by (chibi math linalg):
> https://github.com/ashinn/alschemist/blob/master/chibi/math/linalg.scm
> For consistency with numpy, laminate is called stack, and the axis
> refers to the result dimension so has the more natural domain [0,
> res-dim).
> They are fairly general and I agree should be in the base library
> rather than a linear algebra library.
I'm working to implement these as
(array-append [storage-class] k a1 a2 ...)
(array-stack [storage-class] k a1 a2 ...)
I'm leaning to say that if storage-class is not specified, then if a1 a2
... all have the same storage class, then that storage class is used,
otherwise generic-storage-class is used. The mutability and safety of
the result is determined by the settings of
(specialized-array-default-mutable?) and (specialized-array-default-safe?).
This led me to think again about
(array-copy array [storage-class [mutable? [safe?]]])
and the commit message of
https://github.com/gambiteer/srfi-179-followup/commit/f2de257e87f341dc1edff0e7b060394bd9960349
says that
1. If the first argument to array-copy is a specialized array, then the
values of omitted arguments storage-class, mutable?, and safe? are taken
from the first argument, not generic-storage-class,
(specialized-array-default-mutable?), and
(specialized-array-default-safe?), respectively.
So the new array is a true copy of the input specialized array.
Any thoughts about what the defaults should be?