As Raul says, it’s not clear what you’re after. 

An interesting property is shown by:
   </.|.D. No. iPad spoils the display!
+---+---+-----------+-------+-----------+---+---+
|2.5|2 2|1.5 1.5 1.5|0 0 0 0|1.5 1.5 1.5|2 2|2.5|
+---+---+-----------+-------+-----------+---+---

I’m not aware of an inverse for </.   

Anyway, this function might generalise what you require:

Dn =: 3 : 0
n  =. y
D  =. 0$~ 2#n
ix =. n #.inv i.*:n
d  =. |-/"1 ix
v  =. (* * >: @ -:)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 rule for distance isn’t obvious. I assumed 1 + half 
the off-main diagonal distance,  but you could supply an arbitrary set as a 
left argument for a dyadic version.

So, for 5 by 5,
   Dn 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

Any help?

Mike

Sent from my iPad

> On 22 Oct 2019, at 17:35, [email protected] wrote:
> 
> 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 
> the matrix is symmetrical.
> 
> Can anyone suggest a more efficient way to create the 
> matrix.  Only (n * (n-1))%2 elements of D are unique. 
> Each unique elecment should be needed only once to build 
> the matrix.
> 
> Thanks,            Peter E.
> 
> 
> 
> -- 
> https://en.wikibooks.org/wiki/Medical_Machines
> Tel: +1 604 670 0140            Bcc: peter at easthope. ca
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to