« first day (1226 days earlier)      last day (1421 days later) » 
06:00 - 18:0018:00 - 00:00

6:49 AM
@Adám Just finished Circular on APL wiki. This completes the list of scalar functions on the wiki.
 
@Bubbler Yeah, I'm just looking through them now. Amazing job!
 
Actually the latest Cultivation helped a lot, because otherwise I wouldn't have thought of ¯9 ¯11+.○ and such.
 
Great, I'm happy it was useful even for someone more experienced like you. Btw, you didn't correct the wrong formula for ¯4○?
 
I left it as is because it is still correct for implementations without complex numbers (and it is easier to read and catch the pattern).
 
Ah, now I see you did mention it. My bad.
 
7:00 AM
I noticed that the APL syntax highlighter treats double quotes just like single quotes (string literal delimiter). Is it intended?
 
It is valid in some dialects.
@DudeMan Hi there. Interested in APL?
 
Oh, OK then.
 
 
2 hours later…
@Bubbler Yes, fixed.
 
9:06 AM
@Adám I was just checking the chats. I did not even know about APL before. Well now if someone ask about APL i can say it is A Programming Language.:)
 
@DudeMan I'll be happy to give you a quick intro. It is especially nice for people who otherwise don't like programming (languages).
 
It will be nice, and I do like programming.
 
Do you have time now?
 
Yeah plenty of time due to lock down, but not a speedy net :(
 
No problem. Can I ask you what your background/experience is, especially when it comes to mathmatics and programming?
 
9:14 AM
I think I know little bit of mathematics, Basic Algebra, some calculus(but been a long time) and some probability.
I know c programming and some python
 
Great. No linear algebra?
 
Yeah I know Linear algebra, Although I have to tell I'm pretty slow doing maths
 
Don't worry, I won't ask you to compute things. That's what the computer is for!
 
Okay
 
OK, so being that you are used to C and Python, let's start by discarding the notion that APL is a programming language (yes, despite the name), and instead look at it as an alternative (and better than the traditional) mathematical notation. It just happens to be rigorous enough to be machine executable, as opposed to the traditional mathematical notation (TMN).
APL was created by a mathematician (who was very fond of matrices and linear algebra) and so it borrows the most basic syntax and vocabulary from TMN.
E.g. to multiply and divide, you use A×B and A÷B.
 
9:21 AM
ok
 
Subtraction and negation are of course A-B and -B, but I mention this because of a very special relationship APL has with this particular TMN feature.
 
A÷B but we don't have the division symbol in keyboard
 
RGS
@DudeMan (trust me, that won't be a problem :P)
 
@DudeMan True, but there are many simple solutions to that. For now, I suggest you use this.
Continuing with the - symbol in TMN: It can be used in an infix manner (between two arguments) and also (with a different but related meaning) in a prefix manner (to the left of a single argument), so too can and must all APL functions be used in one or both of these manners. This is a universal rule.
 
ok got it
 
9:29 AM
Now, one could look at the prefix - as being just like the infix - but with a default left argument of 0. Many APL functions have this kind of relationship between their monadic (that's what we call the prefix form) and the dyadic (the infix form) definitions. Another example of this in TMN is which has an implicit "2" on its left when used without a number on the left.
Now, can you guess what the "default left argument" of ÷ is?
 
0 i think
 
@DudeMan That would be an option, but it wouldn't be very useful, as 0 divided by anything (except possibly 0) gives 0. It'd be a constant function. Any other ideas?
 
I don't know, I can't think about any useful number.
 
I'll give it away: 1. That makes monadic ÷ the reciprocal function.
 
Ow got it.. can tell me where reciprocal function used
 
9:36 AM
> The total resistance of resistors connected in parallel is the reciprocal of the sum of the reciprocals of the individual resistors.
Just an example. It comes up fairly often. E.g. the k-th root is the same as raising to the power of the reciprocal of k.
 
@Adám oh thanks please continue explaining..
 
Now, for a little about arrays. Since you're familiar with C, you know that arrays can be seen as multi-dimensional collections where you can index each dimension separately. (Under the covers, this translates to a shape-radix conversion to a linear index into the flat data.)
 
yeah
 
In APL, the basic (and in fact only) form of data is the orthogonal array. Every array has a shape which is a list of all the lengths along all the axes.
It follows from this that a single atomic value (a scalar), which doesn't have any axes, is an array with 0 dimensions, and so its shape is the empty list.
 
so every data is a multidimensional array
 
9:43 AM
Yes. And higher-dimensional arrays can be seen as collections of lower-dimensional arrays.
 
ok
 
So vectors (1D arrays) consist of 0 or more scalars (0D arrays) and matrices consist of 0 or more vectors, and 3D blocks of data consist 0 or more of matrices, etc. etc.
In general, you can expect APL to be very consistent in its treatment of data, and if you write nice code, it is likely to automatically work on higher dimensions.
Enough theory. Let's see some code.
 
wait let me read this, I want to understand it before diving into code
 
Sure, take your time.
 
Every array has a shape which is a list of all the lengths along all the axes.
I did not get this part
Can please explain how the single valued scalars are stored using multidimensional array
 
9:51 AM
I should have given a practical example. A 3 row 4 column matrix has the shape [3,4] and the list [2,7,1] has the shape [3], and the number 42 has the shape [].
Internally, every array is stored as its rank (number of dimensions) followed by its shape followed by the flat data.
So 42 is stored as 0,0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,42
 
Ok got it thanks
 
APL likes to keep things clean, with as little visual noise as possible. While a number is a number (we'll get back to that), you can create a list (vector) simply by putting elements next to each other.
So while I wrote Python/JSON before for the list [2,7,1], in APL you'd simply write 2 7 1.
 
why 42 has a shape 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 should not it be just 0
 
Sure, but it is practical to reserve a fixed number of bytes for the shape, so the actual data always begins with the same offset relative to the beginning of the pocket.
 
ohh it was the binary representation ok
 
9:58 AM
(There are many implementations of APL, and some do have a variable shape area, which also allows them to have arrays of any number of dimensions.)
 
okay let us code then
 
Having used C and Python, there's a good chance you've written a loop or two in the past. APL tends to do that for you, so you can add two vectors with 3 1 4 + 2 7 1 and get 5 8 5
Traditionally, APL is used in a REPL, where the prompt is six spaces and the results are flush left, so I'll show examples like this:
      3 1 4 + 2 7 1
5 8 5
@DenizGenç Welcome. Interested in APL?
So + adds the corresponding elements from its left and right arguments.
 
okay
 
Similarly, if one argument is a scalar, and one is a non-scalar, the scalar gets mapped to all the scalars in the other argument:
      1 + 6 1 8
7 2 9
This applies to all arithmetic functions, and even to all functions you define in terms of those.
@DudeMan Are you familiar with the ∑ and ∏ of TMN?
 
Yes
 
10:07 AM
Now really what they do is to reduce a list of values into a single value by applying + and × between successive terms, respectively, right?
 
yeah like a loop for adding or multiplying each elements in a array
 
Exactly. However, the symbols ∑ and ∏ are not very suggestive of their relationships to + and × (other than being the Greek equivalent of the English initials of the words Sum and Product — pretty far out, if you ask me).
APL uses a simple general notation which also avoids having to write all kinds of stuff below and above the big symbol: +/ is sum and ×/ is product.
You can read that as plus reduce or plus over the elements of.
 
ok
 
These, themselves being functions, and taking only one argument (the array to be added/summed), of course go on the left of the argument:
      +/3 1 4
8
      ×/3 1 4
12
 
ok but where can I execute these
 
10:14 AM
E.g. on TryAPL.
APL has a lot of built-in functions, and as you can write your own functions too, it'd be impossible to maintain a hierarchy for the order of operations.
 
ow so what is the order of operation
 
Instead, APL generalises the rule that a monadic function takes its argument on its right: All functions take everything on their right as their right argument.
Think of it like this: You're used to seeing f(g(h(x))). Simply remove the parentheses: f g h x.
As you can see, it is quite natural for the rightmost function to be applied first, then working the way to the left.
 
yeah
 
However, when we read such an expression, we read from the left: f of g of h of x
Though I've stated it here, you'll likely often get it wrong in the beginning, but it doesn't take very long to get used to it.
I'll teach you one more built-in APL function, and then it is time for exercises!
 
@Adám So if I try 10*5-7 it will first do 5-7
 
10:21 AM
That's correct. (Also * is not multiplication!)
 
ok
 
It is extremely common to need the natural numbers, i.e. the integers. For that, APL uses a monadic Greek iota (like letter I as in Integers) symbol :
      ⍳10
1 2 3 4 5 6 7 8 9 10
Exercise: Write an APL expression that computes the sum of the first 100 integers.
 
Ok let me try
×/⍳100
 
That's the product, but you get the idea.
 
RGS
@Adám (to be really correct, you'd have to say where you want to start, as the integers go from ¯∞ to ∞)
 
10:26 AM
oh sorry I was wondering why I getting such a large number
 
@RGS Yeah, I should have said the first 100 natural numbers.
 
+/⍳100
 
Yes. Good. Now do it in C. No, just kidding.
 
@Adám it is simple in C too
 
@user232736 Hej v0y73k. If you want to participate here, just tell me so by email: adam@ with the same domain as www.dyalog.com
@DudeMan Btw, APL uses parentheses just like TMN, for when you need to override the order.
 
10:30 AM
oh okay
 
Exercise: Sum of the first 17 squared natural numbers.
 
+/⍳17*2
 
13 mins ago, by Adám
Though I've stated it here, you'll likely often get it wrong in the beginning, but it doesn't take very long to get used to it.
 
:(
 
Think about what sees as its argument; everything to its right. so you're getting +/⍳289
 
10:36 AM
how can I access each element in the array
@Adám ok
 
@DudeMan You don't need to. Remember APL's auto-mapping!
 
Ok let me try
 
Take your time. No rush at all.
 
+/(⍳17)*2
is it the correct solution
 
Yes. Very good.
Exercise: Sum of first 100 even natural numbers (i.e. all the even numbers from 2 until and including 200).
 
10:42 AM
Thanks
Is not it same as previous one +/(⍳100)*2
 
You'd need to use × instead of *, yes, but can you find a way to remove the parenthesis?
 
oh sorry used c syntax again
 
No problem. I understood.
 
If we remove the parenthesis it will be sum from 1 to 200 wouldn't it
 
Yes, so how else could you write this without the parenthesis?
 
10:52 AM
Uh couldn't find another way
 
I'll give you a hint: × is commutative. a×b is the same as b×a.
 
+/2×⍳100
Ok that was simple
 
Spot on! Do you have time/energy/interest for more?
In APL, you can often use the rigid order of execution to simplify expressions by swapping arguments.
 
Yeah you explained that solid
Sorry man now I have to leave. But was nice learning
I will be joining this chat in future, thanks for teaching me APL
 
No problem. Just ping me when you want more.
 
10:59 AM
sure
 
 
3 hours later…
1:48 PM
@DudeMan I first got really interested in APL from this short, 8 minute video that piece-by-piece writes the Game of Life in APL! If you'd like to see what it looks like when APL is used to solve 'real' problems, I highly recommend it for a quick taste :) Game of Life in APL (REPL) in just 8 minutes
@Adám Would be super useful to be able to do that, as I currently use dzaima's pastebin, which doesn't allow further execution/experimentation! How did you link to TryAPL with specific stuff already inside?
@DudeMan Also, if the video intrigues you, TryAPL will walk you through creating the Game of Life the same way, with explanations at each step. That way you can experiment and play with what's happening as you build it up! (Navigate to "Learn">"Interesting Explorations" ) Game of Life Walkthrough in APL, Experiment in REPL
 
RGS
@Adám in this video @AviF.S. linked, the person doing the screencast goes through quite some trouble only to reproduce the behaviour of ({+/+⌿⍵}⌺3 3) ; how recent is ⌺??
 
@RGS Haha, good idea to edit & ping Adám re: stencil! I do remember that it's new, but I've no idea how new!
@RGS Had you not had the opportunity to see it before? If not, John Scholes also has similarly formatted: Sudoku Solver & Depth-First Search -⊖⊃⊖-
 
2:23 PM
@AviF.S. Just enter what you want, then hover over the input expression to reveal the permalink icon. Copy the link location or click it to open a new window.
 
@Adám Interesting, I'd never noticed. Thanks!
But then how do you permalink multiple expressions?
 
@AviF.S. I copy the parameters from one permalink and join with another permalink using &.
 
@Adám My goodness! Do you know the encoding system? That never would've occurred to me, thanks!
 
@AviF.S. It is just normal URL.
 
RGS
re: stencil usage - using ⌺ isn't the same as doing all those rotations the person in the video does; as he mentions, he is implementing GoL in a torus and using ⌺ implements it in a restrict rectangle
 
2:27 PM
@AviF.S. There's also a wiki page on it.
 
@Adám Oh... well I guess I haven't learned URL/URI encoding, will look it up, as I suppose that's what TIO uses then!
 
@RGS Ah good point! Though I still expect it was before ⌺ was implemented! Plus, the torus part seemed like an afterthought/note about how he implemented it!
Not like he was writing the code to purposefully do it on a torus, just the way the code he wrote turned out
 
RGS
@AviF.S. yeah maybe, though I do think GoL in a torus is quite elegant
 
@AviF.S. You don't need to know the encoding. You just need to know that parameters are given as url?name=value&name2=value2&…
 
2:30 PM
@RGS Definitely!
 
RGS
@ngn thanks!
 
@Adám Ah, well I didn't even know that. Thanks!!
 
@RGS We're currently discussing extending to be able to specify edge handling. While various image processing libraries mention all sorts of methods, I've not found anyone who gave them a systematic treatment. However, I came up with a classification system I think is pretty neat.
 
RGS
@Adám I'd be pleased to have a look at such classification
I've done a bit of image processing and the tiny bit I did was enough to notice there really are dozens of ways of handling edges
 
Do you have a few minutes? I can explain it.
 
RGS
2:33 PM
@Adám sure
chat or zoom?
or the 8x8 thingy
 
Chat is fine.
 
RGS
alright, bring it on :D
 
The first thing is to generalise dimensionality. We can define edge handling in terms of a 1D world, and then expand that to multi-dimensional worlds.
So, what I've found is that we need a world vector of size 5:
    1 2 3 4 5
Let's draw the edges:
   |1 2 3 4 5|
 
RGS
in this 1d world the edges are 0d things: the first and last points; feels pretty standard so far :)
 
No, the edges are just before the 1st and just after the last element.
Now there are five basic ways to deal with the edge which I call (since "the community" doesn't have a standard nomenclature): Zero, Replicate, Reverse, Mirror, Wrap
Zero pads with 0s (or the appropriate fill) forever:
0 0|1 2 3 4 5|0 0
Replicate keeps going with the first/last element:
1 1|1 2 3 4 5|5 5
Reverse runs the original data in reverse on the other side of the edge:
2 1|1 2 3 4 5|5 4
Mirror mirrors in the first/last element:
3 2|1 2 3 4 5|4 3
 
RGS
2:40 PM
@Adám ah
 
And wrap is pretty obvious:
4 5|1 2 3 4 5|1 2
 
RGS
Alright; these seem sensible.
I wonder how some of these generalise at "corners" in higher Ds
 
Now look at the leftmost column when we've gone 2 steps beyond the edge.
0 1 2 3 4
That's the classification without involving ambiguous English.
 
RGS
@Adám heh
clever
 
@RGS There's really no issue. Just rotate 90 deg around the original 1, and extend the new rows with the same rule.
 
RGS
2:45 PM
@Adám I didn't understand the instructions but I doodled in my notebook and in 2D it becomes obvious what goes in the corners
 
Yup.
There's one more twist to this: There's the concept of twisting the world when you go over the edge. The allows life on Möbius strips etc.
 
RGS
@Adám wrapping to different edges, is that what you mean?
 
So my classification adds the sign. -4 means you wrap to the flipped edge.
 
RGS
@Adám ah ok
 
Now we extend to nD. The world can be described as an n-element vector of integers in the range -4…4.
 
RGS
2:47 PM
@Adám wdym..?
I need a moment; what does the ¯ do in the systems 0 to 3..?
 
@RGS For example, and infinite "dead" world is a 0 0 world, a torus is a 4 4 world.
An infinite cylinder is a 0 4 world.
 
RGS
@Adám (would a mobius strip be smth like 0 ¯4?)
 
@RGS Yes.
So my idea for extending is to give it a left argument with n element according to this system, just like it currently takes an n column vector or matrix as right operand which determines the cell size and optionally step size.
 
RGS
@Adám I can see it happening
 
So, what do you think of the Brudzewsky classification of orthogonal worlds?
 
RGS
2:52 PM
but ⌺ already takes a left operand. would it then become smth like classification (func⌺cellSize) arg?
 
@RGS Yes, I did say left argument, which currently isn't used/allowed.
 
RGS
@Adám yup, I noticed; just making sure I got it right
@Adám before answering this question let me ask smth else; what do the systems ¯1 ¯2 and ¯3 mean..?
are they the same as their positive counterparts?
 
No, they also twist. I'll illustrate.
 
RGS
@Adám please
 
Here's a 2D world extended left and right according to rule -1:
21 21| 1  2  3  4  5|25 25
16 16| 6  7  8  9 10|20 20
11 11|11 12 13 14 15|15 15
 6  6|16 17 18 19 20|10 10
 1  1|21 22 23 24 25| 5  5
 
RGS
2:57 PM
but this becomes annoying in the corners; with rule 1 we get this:
1 1|1 2|2 2
1 1|1 2|2 2
-----------
1 1|1 2|2 2
3 3|3 4|4 4
-----------
...
so it extends really nicely into the top-left corner
 
Announcement: BAA AGM about to begin.
 
RGS
but rule ¯1 gives
? ?|2 1|2 2
? ?|2 1|2 2
-----------
3 3|1 2|2 2
1 1|3 4|4 4
-----------
...
(just to clarify, I'm taking the 2 2⍴⍳4 as the original matrix)
 
@Adám it wouldn't have occurred to me that TryAPL would allow multiple equal key arguments there though
 
@dzaima Right, it deconstructs the URL "manually".
 
RGS
? ?|2 1|...
? ?|2 1|
-----------
3 3|1 2|...
1 1|3 4|
-----------
...
@RGS ^ correction, the right-hand side wasn't adapted from 1 to ¯1
 
3:23 PM
@RGS This, no?
25 25| 5  4  3  2  1|21 21
25 25| 5  4  3  2  1|21 21
-----+--------------+-----
21 21| 1  2  3  4  5|25 25
16 16| 6  7  8  9 10|20 20
11 11|11 12 13 14 15|15 15
 6  6|16 17 18 19 20|10 10
 1  1|21 22 23 24 25| 5  5
-----+--------------+-----
 5  5|25 24 23 22 21| 1  1
 5  5|25 24 23 22 21| 1  1
 
RGS
@Adám Doesn't sound too reasonable... the 25 on the top-left doesn't show nor in the left-middle panel nor in the center-up panel
 
@RGS It has to flip both horizontally and vertically, no?
@RGS Think of it. In the top left, you want something that's adjacent to both 21 and 5. That's 25 from the bottom right corner.
 
RGS
3:44 PM
@Adám the only reason why I don't like this ¯1 is the following:
when you cross an edge, from that point onward you only find elements that were next to the edge and this happens if you go from centre to left or centre up
 
Btw, this is ¯1 ¯1
 
RGS
but going centre -> left-up the 25 that pops up isn't really connected to the numbers left-centre or centre-up... but maybe it doesn't have to..?
 
@user91994 Hi there. If you want to participate here, email adam@ with the same domain as www.dyalog.com.
 
RGS
from my point of view -- that I'm not sure I was able to put across yet -- systems 2, 3 and 4 reuse all elements from the original matrix
while system 0 doesn't care about the numbers in the original matrix and system 1 only cares about what is really close to the edge we just crossed...
that is why I feel the 25 there is awkward, because it seems to violate this feeling of the continuation being local
 
@RGS But this isn't 1 1, this is ¯1 ¯1, and ¯1 is not continuous.
 
RGS
3:51 PM
@Adám I know this isn't 1 1, 1 1 just generalizes beautifully and I have nothing against it
@Adám what do you mean by "¯1 is not continuous"?
 
@RGS If you take an actual image, you'll see a "line" at the edge with ¯1 ¯1 (as will you with 4 4).
 
RGS
@Adám so are you saying ¯1 ¯1 is not continuous or are you saying ¯1 is not continuous..?
 
Neither is.
 
RGS
I don't understand that :/ 1 1 1 1|1 2 3 4 5|... seems rather continuous
 
Sure, but that's not really ¯1 since 1=¯1 for 1D worlds.
Hard to chat while participating in the BAA meeting. I've confused matters a bit. ¯1 is continuous for 1D worlds because it is exactly the same as 1.
However, ¯1 for a 2D world is not continuous.
 
4:08 PM
There -- my first BAA AGM.
 
@xpqz Congrats. My second, I think.
@RGS Makes sense?
 
RGS
@Adám sure, I guess. There is no harm in defining things like that, I just voiced my this-doesnt-look-that-nice feeling
 
In any case, you'd be hard pressed to even visualise what a ¯1 ¯1 world looks like!
 
RGS
@Adám and so in nD each element in this n vector just specifies the edge handling along each axis?
@Adám for sure!
 
@RGS Yes, but actually, it is a bit more complex than that when it comes to because it allows omitting trailing axes, and then it doesn't move in that dimension:
      ⊢⌺3⊢3 4⍴⍳12
0  0  0  0
1  2  3  4
5  6  7  8

1  2  3  4
5  6  7  8
9 10 11 12

5  6  7  8
9 10 11 12
0  0  0  0
This would be equivalent to a specification of 0 for 2D world.
 
RGS
4:20 PM
so with your spec can't you just omit trailing axes as well..?
 
Yes, exactly so. The specification just has to match the right operand.
 
RGS
yeah makes sense. if you don't try to cross some edges there's no point in telling ⌺ how to cross them
 
So an alternative syntax would be to add a 3rd row to the right operand.
However, I have a second agenda on making the derived function dyadic, and that is changing how the left argument to the left operand is supplied.
 
RGS
@Adám what if I don't care about step and only about shape/spec?
 
@RGS Then just fill the row with 1s.
 
RGS
4:24 PM
@Adám what does this mean?
currently does the left operand take a left arg...?
 
Currently, we feed a left argument to the left operand which is an appropriate left argument to to discard the added padding along each padded dimension. However, there is no left argument to which simultaneously drops from both left and right side.
E.g. what is X such that X↓'--abc-' gives 'abc'?
 
RGS
@Adám yeah I understood, thanks :D
 
This prevents from accepting a world where the windows size is more than one bigger than the world size.
 
RGS
@Adám but do you ever pad on both sides..?
 
Yes, if the window is large, which is definitely possible with a heavy blur applied to a small image.
 
RGS
4:27 PM
@Adám isn't it the callers responsibility to ensure the windows make sense for the arguments?
 
Often, you don't even use the left argument, so it seems a bit silly to have to pad and chop (and the computation of how much to pad is non-trivial) if it is only to enable to generate a left argument you won't use.
So my idea is that the dyadic form instead gives a left argument which is a vector of masks, one per dimension, with 1s for original data.
Alternatively, we could detect the cases where we can't give a left argument, and then not error, until the left argument is requested, at which point we VALUE ERROR.
Each possibility has upsides and downsides.
The vector of masks is more versatile, but unfortunately, doesn't allow a vector of masks to be applied along a number of leading dimensions, though it could be extended to accept this.
Going for the VALUE ERROR allows putting the edge spec into the right operand, which is more consistent, and frees the left argument to specify something else. What might that be?
One thing that is pretty annoying is trying to use to chop a matrix into a block matrix.
@RGS Here's a challenge for you: Given a matrix with sides divisible by three, chop it into 3-by-3 submatrices. E.g.
      (your_function) 9 12⍴⍳81
┌────────┬────────┬────────┬────────┐
│ 1  2  3│ 4  5  6│ 7  8  9│10 11 12│
│13 14 15│16 17 18│19 20 21│22 23 24│
│25 26 27│28 29 30│31 32 33│34 35 36│
├────────┼────────┼────────┼────────┤
│37 38 39│40 41 42│43 44 45│46 47 48│
│49 50 51│52 53 54│55 56 57│58 59 60│
│61 62 63│64 65 66│67 68 69│70 71 72│
├────────┼────────┼────────┼────────┤
│73 74 75│76 77 78│79 80 81│ 1  2  3│
│ 4  5  6│ 7  8  9│10 11 12│13 14 15│
│16 17 18│19 20 21│22 23 24│25 26 27│
└────────┴────────┴────────┴────────┘
You might try:
      {⊂⍵}⌺(2 2⍴3)⊢9 12⍴⍳81
┌───────┬────────┬────────┬────────┐
│0  0  0│ 0  0  0│ 0  0  0│ 0  0  0│
│0  1  2│ 3  4  5│ 6  7  8│ 9 10 11│
│0 13 14│15 16 17│18 19 20│21 22 23│
├───────┼────────┼────────┼────────┤
│0 25 26│27 28 29│30 31 32│33 34 35│
│0 37 38│39 40 41│42 43 44│45 46 47│
│0 49 50│51 52 53│54 55 56│57 58 59│
├───────┼────────┼────────┼────────┤
│0 61 62│63 64 65│66 67 68│69 70 71│
│0 73 74│75 76 77│78 79 80│81  1  2│
│0  4  5│ 6  7  8│ 9 10 11│12 13 14│
└───────┴────────┴────────┴────────┘
Close, but no cigar.
 
RGS
5:09 PM
@Adám 3 4⍴(,1 4 7∘.,1 4 7 10)(⊃⌷)¨⊂({⊂⍵}⌺3 3)9 12⍴⍳81
that's just me picking the correct submatrices out of the whole stencil, the 3 4⍴ and the (1 4 7 ∘., 1 4 7 10) depend on the input matrix obv
@Adám I don't get this; you are talking about the left argument that goes into the left operand, correct? why don't you give it a boolean array with the same shape as the right argument, with 1s in positions that correspond to original data?
@Adám this feels awkward
 
5:38 PM
@RGS You could do that too, but there's a lot of duplicated info then, and you still can't easily use that to remove padding.
@RGS Right, but how do you automate finding those numbers?
@RGS Very inefficient.
 
RGS
@Adám yes
 
@RGS Yup, hence my alternative.
 
RGS
@Adám working on that
 
@RGS Don't. Instead, pad so that you get one "layer" of all-padding subarrays you can discard.
 
RGS
@Adám You mean in the beginning and end?
 
5:42 PM
@RGS At least at the beginning.
 
RGS
@Adám but then you still have to remove intermediate overlapping submatrices
 
@RGS No, increase the step-size to 3 like I did.
 
RGS
@Adám ah, changing the step size -.- of course
 
(to randomly pop in, my opinion on is for it to not do any padding for the borders, leaving that to the user, which should be trivial in most cases. Not an option for Dyalog, but if i get to it, that's how i'd implement mine)
 
RGS
@Adám smth like this?
BlockUp ← {
    ⍝ Takes an array as right argument and a vector as left argument.
    ⍝ ⍺ must have as many elements as ⍵ has dimensions.
    ⍝ Splits ⍵ in sub-arrays of lengths given by ⍺.
    ⍝ Assumes i⊃⍺ divides i⊃⍴⍵
    w ← ⍵↑⍨ -(⍴⍵)+2×⌈2÷⍨¯1+⍺
    1 1↓({⊂⍵}⌺(↑2⌿⊂⍺))w
}
 
5:53 PM
1 1↓{⊂⍵}⌺(2 2⍴3)⊢(0⍪0,⊢)⍣2⊢9 12⍴⍳81 ?
 
RGS
woops, I tried writing everything in general and then the final step only works for matrices, not for nD arrays
BlockUp ← {
    ⍝ Takes an array as right argument and a vector as left argument.
    ⍝ ⍺ must have as many elements as ⍵ has dimensions.
    ⍝ Splits ⍵ in sub-arrays of lengths given by ⍺.
    ⍝ Assumes i⊃⍺ divides i⊃⍴⍵
    w ← ⍵↑⍨ -(⍴⍵)+ 2× ⌈2÷⍨¯1+⍺
    (⍺>1)↓({⊂⍵}⌺(↑2/⊂⍺))w
}
 
06:00 - 18:0018:00 - 00:00

« first day (1226 days earlier)      last day (1421 days later) »