Ummm, since x is the name of the LEFT argument of a verb, I suspect
that you had a global value of x that caused the length error... Try
instead something like (getting rid of some redundant ()s:

  cnot_gate =: 3 : '(4 4 $ 1 0 0 0  0 1 0 0  0 0 0 1  0 0 1 0) +/ . * y'


At 23:25  -0400 2007/04/08, Pascal Heus wrote:
Hi:
I'm mostly new to J.
Why do I get a "length error" when I define a verb as shown below (the
dot product of a 4x4 matrix with a 4x1 column vector)

cnot_gate =: 3 : '(4 4 $ 1 0 0 0  0 1 0 0  0 0 0 1  0 0 1 0) (+/ . *) (x)'
and then executes
cnot_gate (,. 0 1 0 1)
|length error: cnot_gate
|   (4 4$1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0)    (+/ .*)(x)

The direct call works correctly
    (4 4 $ 1 0 0 0  0 1 0 0  0 0 0 1  0 0 1 0) (+/ . *) (,. 0 1 0 1)
0
1
1
0


thanks
Pascal

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

Reply via email to