« first day (1451 days earlier)      last day (1206 days later) » 
01:00 - 22:0022:00 - 00:00

10:24 PM
is there a nice array based way, given a number n and an array of n elements, say n=6 and the array is a b c d e f to produce 6b-a 6c 6d 6e-f?
(bonus points if you figure out what I'm doing :) )
actually I think 6 might be a constant, so ignore what I said with n
 
ngn
10:36 PM
@rak1507 short or fast?
 
ideally, both! probably fast though
 
ngn
@rak1507 matrix multiplication
 
oh, I should've figured, I'm doing matrixy things atm
multiply what by what
 
ngn
@rak1507 the vector a b c d e f by the matrix i'm trying to construct right now
 
haha ok, I have barely done any linalg so I'm pretty rusty on my matrices, wish I could be of help
 
ngn
10:40 PM
@rak1507 an example would be nice
with specific values for a..f and the result
 
S ← ↑(1 ¯1)(¯1 2)(1 4)(4 3)(7 5) desired result ↑(¯7 13)(6 24)(17 13)
I have {(⍵⌷⍨⊂0,1-⍨≢⍵)-⍨@(0,3-⍨≢⍵)⊢6ׯ1↓1↓⍵} but that's quite clunky
 
ngn
@rak1507 i don't understand. where are a..f?
 
a = 1 ¯1, b = ¯1 2, etc
(I only found out they were 2d after I posted the question and read more, sorry)
 
ngn
only 5 of them?
 
oh yeah, oops, my bad, n=5 (not that n actually matters)
 
ngn
10:44 PM
(↑(¯1 6 0 0 0 0)(0 0 6 0 0 0)(0 0 0 6 0 0)(0 0 0 0 6 ¯1))+.×a b c d e f should work according to my calculations
 
whoa, it does, wizardry!
so my whole expression ends up being m⌹⍨SM+.×S
now I just need a nice way of calculating that matrix for any size
also a way of calculating the matrix 4 4 ⍴ 4 1 0 0 1 4 1 0 0 1 4 1 0 0 1 4 for any size
that pattern
 
ngn
@rak1507 ⋄n←4⋄{⌽⊖⍵,⌽n↑¯1}⍣2⊢6×=/↑⍳2⍴n
"6" should probably be n+2
 
6 is a constant I think
 
ngn
⋄n 1 0[2⌊|-/↑⍳2⍴n]
 
@ngn VALUE ERROR
 
ngn
10:53 PM
⋄⎕io←0⋄n←4⋄n 1 0[2⌊|-/↑⍳2⍴n]
 
@ngn
┌→──────┐
↓4 1 0 0│
│1 4 1 0│
│0 1 4 1│
│0 0 1 4│
└~──────┘
 
ngn
@rak1507 ^
 
genius! thank you
 
ngn
another way: ⋄⎕io←0⋄n←4⋄⌽↑n,/(⌽,1∘↓)n↑n 1
 
 @ngn
┌→──────┐
↓4 1 0 0│
│1 4 1 0│
│0 1 4 1│
│0 0 1 4│
└~──────┘
 
ngn
11:00 PM
ok, last one :) ⋄⎕io←0⋄n←4⋄n n⍴1,⍨n↑n 1
 
@ngn
┌→──────┐
↓4 1 0 0│
│1 4 1 0│
│0 1 4 1│
│0 0 1 4│
└~──────┘
 
 b←{n←2-⍨≢⍵
     CM←(⌽¯1↑⍨n),⍨(¯1↑⍨n),6×=/↑⍳2⍴n
     M←4 1 0[2⌊|-/↑⍳2⍴n]
     M⌹⍨CM+.×⍵
 }
seems to work :)
 
ngn
@rak1507 what does it do?
 
was reading about it and I saw something like 'this method may be hard because it involves solving linear equations' and I thought, not in APL!
 
ngn
"interpolation by relaxed cubic splines"
 
11:04 PM
yep
 
ngn
apl is essentially linear algebra turned into a programming language
just like lisp is λ-calculus turned into a programming language
 
yeah
I really need to up my linalg game
 
11:18 PM
@rak1507 If you want O(n) performance instead of O(n^2), you'll have to write a sparse diagonal matrix solver, which is fairly painful in APL.
 
that sounds scary, so I'll pass
I don't really care about performance, I just want to make something real, useful, and interesting, rather than a code golf challenge
Hm, I wonder if I should use complex numbers to represent points
then I could more easily have a 4 by 4 matrix of points
 
01:00 - 22:0022:00 - 00:00

« first day (1451 days earlier)      last day (1206 days later) »