In validate.ijs find ismatrix. (Or change = to <:)

   ismatrix=: 2 = [EMAIL PROTECTED]
   ]`(+/)@.ismatrix i. 2 5
5 7 9 11 13
   ]`(+/)@.ismatrix i.  5
0 1 2 3 4
   ]`(+/)@.ismatrix   5
5


On Mon, 18 Feb 2008, Leigh J. Halliwell wrote:

+ Dear J Forum:
+
+ I am applying +/ to arrays that can be of either rank 1 or rank 2.  The
+ following approach works fine for rank 2:
+
+ +/ i. 2 5
+ 5 7 9 11 13
+
+ But for a rank 1 array, I want just the array itself.  I can do that with
+ +/"_1:
+
+ +/"_1 i.  5
+ 0 1 2 3 4
+
+ However +/"_1 i.2  5 collapses along the wrong axis:
+
+ +/"_1 i.2  5
+ 10 35
+
+ Please show me an efficient summation operator that will leave untouched
+ rank 1 arrays, but will perform +/ on rank 2 arrays.  Preferably I will not
+ have to add a leading axis to the rank 1 arrays.  Thank you
+
+ Sincerely,
+
+ Leigh

(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to