filling and assigning Alex Shinn (06 May 2021 14:32 UTC)
Re: filling and assigning Bradley Lucier (06 May 2021 16:35 UTC)
Re: filling and assigning Alex Shinn (07 May 2021 02:29 UTC)
Re: filling and assigning Bradley Lucier (07 May 2021 11:18 UTC)
Re: filling and assigning Marc Nieper-Wi├čkirchen (07 May 2021 11:53 UTC)
Re: filling and assigning Alex Shinn (07 May 2021 13:38 UTC)

Re: filling and assigning Alex Shinn 07 May 2021 02:29 UTC

On Fri, May 7, 2021 at 1:35 AM Bradley Lucier <xxxxxx@math.purdue.edu> wrote:
>
> On 5/6/21 10:32 AM, Alex Shinn wrote:
> > Storage classes require a constructor which can take any
> > initial value, but there is no way to override the default from
> > the storage class.  It would be nice to have a way to do this.
> > Otherwise an array-fill! would help, though be less efficient.
>
> Yes, I see that an initial-value argument to make-specialized-array
> would be helpful.  Or perhaps a more low-level constructor for
> specialized arrays.
>
> array-copy can be helpful here:
>
> (array-copy
>    (make-array interval
>                (lambda (i) initial-value))
>    result-storage-class)

Yes, that's a nice shorthand, but I was more concerned about performance.

> > I was caught by this implementing a new utility,
> > array-concatenate.  Trying to rely on high-level operations,
> > a clean way to implement this is to construct the destination
> > which is the sum of the two input domains along a dimension,
> > then array-assign! each input to its array-extracted offset
> > within the destination.  But these elements will not be
> > adjacent.
> >
> > Without being able to use array-assign! and without interval
> > cursors, the implementation of concatenate is quite difficult.
>
> You see how to do it, you just have to translate each argument array to
> match the domain of the array-extract'ed subarray of the result.

Ah, right, that's a usable workaround.  But I was curious about the
motivation of the restriction.  It seems an implicit translation is more
natural than an implicit reshape.

--
Alex