Rather than "assigning " indices, use the actual node positions and what
is done to make a suntraction (or other) table, which is the same proplem.
In the case of all nodes being on a line at positions 0 1.5 2 2.5 3 the
matrix would be given by
dij=: |@ -/~ 0 1.5 2 2.5 3
0 1.5 2 2.5 3
1.5
I am a loss as to the actual location of the points in space. However,
if the points are all on a plane, the positions can be expressed as
complex numbers. I so the following (useful. in power line analysis)
dij=: |@ -/~
dij 0 1 1.5 0j1.5 1j2
0 1 1.5 1.5 2.23607
1 0 0.5 1.80278 2
1.5 0.5 0
Using the utilities below you could do the following:
makeSym > vec2LowerTri 0 1.5 0 2 1.5 0 2.5 2 1.5 0
0 1.5 2 2.5
1.5 0 1.5 2
2 1.5 0 1.5
2.5 2 1.5 0
NB.*zeroTri a Zeros triangular items of matrix determined by verb to left
NB. EG: < zeroTri mat NB. zeros lower-tri items of mat
NB. EG:
Sure, ...
The , , ,: approach is cleaner than the > ; ; ; approach (and it's
generically useful both for symmetric numeric matrices and for
constructing constant matrices).
Meanwhile, the -: trick is clever and concise (but not generic).
Thanks,
--
Raul
On Wed, Oct 23, 2019 at 5:23 AM 'Mike D
Or:
(+|:)-:0,3 0,4 3,:5 4 3 0
?
This generalises the lean but ad hoc expression:
-:@(+|:)@:(|.@(,\.))@:({. 3+i.@-@<: ) 5. NB. eg for 5 x 5
0 1.5 2 2.5 3
1.5 0 1.5 2 2.5
2 1.5 0 1.5 2
2.5 2 1.5 0 1.5
3 2.5 2 1.5 0
... the 3+ bit could be generalised with a bit more
Wow!
> On Oct 22, 2019, at 4:00 PM, Raul Miller wrote:
>
> Probably worth noting also that I could have instead said:
>
> D=: (+|:)>0;1.5;2 1.5;2.5 2 1.5 0
>
> This is actually one character shorter than my previous expression...
>
> Thanks,
>
> --
> Raul
>
>> On Tue, Oct 22, 2019 at 2
Probably worth noting also that I could have instead said:
D=: (+|:)>0;1.5;2 1.5;2.5 2 1.5 0
This is actually one character shorter than my previous expression...
Thanks,
--
Raul
On Tue, Oct 22, 2019 at 2:29 PM wrote:
>
> From: Raul Miller
> Date: Tue, 22 Oct 2019 13:29:19 -0400
> >
From: Raul Miller
Date: Tue, 22 Oct 2019 13:29:19 -0400
> What do you mean by "more efficient"? (What resource is constrained?)
I listed all 16 elements of the matrix. It being symmetrical with 0s
on the diagonal, only 6 elements should be needed. Rather than "more
efficient", better word
As Raul says, it’s not clear what you’re after.
An interesting property is shown by:
: @ -:)d
v (<"1 ix) } D
)
Yes, we could avoid doubly setting the main diagonal, and could just set the
upper or lower triangle followed by adding the transpose, at the expense of
complicating the code. The
This seems like an underspecified problem.
What do you mean by "more efficient"? (What resource is constrained?)
For example, are you looking for code golf [source code is the
limiting resource] on this specific matrix?
Are you trying to save memory? Are you trying to save time?
These days, a m
Given a fully connected graph of n nodes.
The nodes are assigned indices i.n arbitrarily.
D is a distance matrix. Eg.
n =. 4
] D =. 4 4 $ 0 1.5 2 2.5 1.5 0 1.5 2 2 1.5 0 1.5 2.5 2 1.5 0
I'm not claiming this matrix fits in Euclidean geometry.
Nevertheless each element on the diagonal is 0 and
11 matches
Mail list logo