In SATN-42 (Sharp APL Technical Notes), 1982-04-01,
Ken Iverson described several uses monads derived
from the dot operator.  Translated from APL into
J, these are:

+./ . *.
+ / . *.
<./ . +
>./ . +
<./ . *
>./ . *
<./ . >.
>./ . <.

Computation of f/ .g can be sped up for f and g
in domains which permit Gaussian elimination.
This has not been done in the current 
implementation.



----- Original Message -----
From: Ewart Shaw <[EMAIL PROTECTED]>
Date: Friday, December 1, 2006 8:09 am
Subject: [Jprogramming] monadic  ~:/ . *.

> The only common monadic uses of  .  seem to be
> 
>   determinant=: -/ . *
>   permanent=:   +/ . *
> 
> (see e.g.  .  from the J help vocabulary page).  However, I recently
> wanted to check that a set of n boolean vectors of length n are
> linearly independent over the finite field GF(2) (i.e. 0 & 1 multiply
> as normal, and addition is mod 2).  This can be verified by
> 
>   det2=: ~:/ . *.
> 
> which is 1 when the (n x n) argument y has linearly independent rows.
> At least I think it is!  Possible applications include binary codes
> and Zobrist hashing (using e.g. the first several columns as hash key
> and the remaining columns to disambiguate collisions).
> 
> Note that det2 is very slow on a 10x10 matrix or larger
> (like permanent, time is roughly proportional to !#y).
> 
> 
> NB.============================== J script 
> ==============================
> hashmat=: 3 : 0             NB. hack to give "random-looking"
> m=. m0=. ?. (2#y)$2         NB. invertible yxy matrix over GF(2)
> for_i. i. y do.
> if. -. (ii=. <i,i){m do.
>  m=. 1 ii}m
>  m0=. (-. ii{m0) ii} m0
> end.
> m=. m ~: (i{"1 m) *./ i{m
> end.
> m0
> )
> 
> det2=: ~:/ . *.             NB. Determinant for GF(2)
> 
> hammdist=: ([: +/ ~:)"1/~   NB. Hamming distance
> 
> NB.============================== example 
> ===============================
>   ] H8=: hashmat 8
> 1 1 0 1 1 1 0 0
> 0 1 0 1 0 0 1 0
> 0 0 1 0 1 1 1 0
> 0 0 0 1 1 1 0 1
> 1 0 0 1 1 0 1 0
> 1 0 0 0 0 0 0 1
> 0 0 1 0 0 1 0 0
> 1 0 0 1 0 1 0 0
>   det2 H8
> 1
>   hammdist H8
> 0 4 5 3 3 5 5 2
> 4 0 5 5 3 5 5 4
> 5 5 0 4 4 6 2 5
> 3 5 4 0 4 4 4 3
> 3 3 4 4 0 4 6 3
> 5 5 6 4 4 0 4 3
> 5 5 2 4 6 4 0 3
> 2 4 5 3 3 3 3 0
> 
> NB.============================== end 
> ===================================


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to