Nice!
I get a slight improvement in time and space by putting
ta =: [: }: [: {."1 (2 -/\ ])^:a:
in
etca =: {.&.:(ta :.ta)
but this doesn't anonymise the involution verb.
This does that trick - but doesn't improve performance -
etcb =: ({. ([: {."1 (2 -/\ ])^:a:))^:2
In your example it's like doing
21 {. t 21 {. t 0 1 4
- so this anonymisation comes at the cost of unnecessarily
repeating the take ({.)
I don't yet see how to unsquare the matrix. With your
current approach, space becomes a problem for
LHS > something over 8000.
hilsener,
Mike
Bo Jacoby wrote:
> Hello my friends
>
> A program for polynomial extrapolation can be written
>
> etc=.{.&.:(t :.t=.[: {."1 (2-/\])^:([: i. #))
>
> For example, the first 21 square numbers are extrapolated from 3 square
> numbers like this.
>
> 21 etc 0 1 4
> 0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400
>
> My first question is this: Can the program be written without naming the
> intermediate verb (t) ?
>
> Note that t is an involution:
> t t 0 1 4
> 0 1 4
> and the etc program just pads zeroes
> 21 {. t 0 1 4
> 0 _1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> before transforming back.
> t 21 {. t 0 1 4
> 0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400
>
> The transformation (t) creates a space-consuming intermediate matrix
> (2-/\])^:([: i. #) 1 4 9
> 1 4 9
> _3 _5 0
> 2 0 0
> where only the first row is input and only the first column is output. I want
> to compute in-place to save space:
> 1, 4 9 --> 1 _3, _5 --> 1 _3 2
> My second question: How is that done?
>
> Venlig hilsen, Bo
>
>
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm