Nice! This is a much more general solution.
On Tue, Nov 8, 2011 at 12:11 PM, Marshall Lochbaum <[email protected]> wrote: > If we look at the block matrices, what we want is a matrix product on > these, but with the operations of matrix addition and multiplication > instead of the regular + and * . Thus, we can replace + and * in +/ .* with > the corresponding +&.> and +/ .*&.> for boxed matrices, so > > mp =. +/ .* > blockmp =. +&.>/ . (+/ .*&.>) > > B=:A =: i.6 6 > B mp A > 330 345 360 375 390 405 > 870 921 972 1023 1074 1125 > 1410 1497 1584 1671 1758 1845 > 1950 2073 2196 2319 2442 2565 > 2490 2649 2808 2967 3126 3285 > 3030 3225 3420 3615 3810 4005 > tA =: (2 2,:2 2)<;._3 A > tB =: (2 2,:2 2)<;._3 B > tA blockmp tB > ┌─────────┬─────────┬─────────┐ > │330 345 │360 375 │ 390 405│ > │870 921 │972 1023 │1074 1125│ > ├─────────┼─────────┼─────────┤ > │1410 1497│1584 1671│1758 1845│ > │1950 2073│2196 2319│2442 2565│ > ├─────────┼─────────┼─────────┤ > │2490 2649│2808 2967│3126 3285│ > │3030 3225│3420 3615│3810 4005│ > └─────────┴─────────┴─────────┘ > tA =: (2 6,:2 6)<;._3 A > tB =: (6 2,:6 2)<;._3 B > tA blockmp tB > ┌─────────┬─────────┬─────────┐ > │330 345 │360 375 │ 390 405│ > │870 921 │972 1023 │1074 1125│ > ├─────────┼─────────┼─────────┤ > │1410 1497│1584 1671│1758 1845│ > │1950 2073│2196 2319│2442 2565│ > ├─────────┼─────────┼─────────┤ > │2490 2649│2808 2967│3126 3285│ > │3030 3225│3420 3615│3810 4005│ > └─────────┴─────────┴─────────┘ > tA =: (3 2,:3 2)<;._3 A > tB =: (2 3,:2 3)<;._3 B > tA blockmp tB > ┌──────────────┬──────────────┐ > │ 330 345 360│ 375 390 405│ > │ 870 921 972│1023 1074 1125│ > │1410 1497 1584│1671 1758 1845│ > ├──────────────┼──────────────┤ > │1950 2073 2196│2319 2442 2565│ > │2490 2649 2808│2967 3126 3285│ > │3030 3225 3420│3615 3810 4005│ > └──────────────┴──────────────┘ > > All give the same product. > > Marshall > > > On Mon, Nov 7, 2011 at 6:01 PM, Ric Sherlock <[email protected]> wrote: > >> Basically the ( , ) is getting around the issue that Raul has nicely >> described - we want to turn the shape of the boxes into a simple list >> >> u&v applies the verb v to x and y before running x u y >> i.e. x u&v y <==> (v x) u (v y) >> >> where u =: +/ .*&.>/ >> and v =: , >> >> The last ( / ) is the dyadic form - Table [1] and applies each cell of >> x to the whole of y >> An alternative formulation that does the same thing is: >> (,tA) +/ .*&.>"0 _ (,tB) >> >> [1] http://www.jsoftware.com/docs/help701/dictionary/d420.htm >> >> On Tue, Nov 8, 2011 at 11:17 AM, Jan Jacobs <[email protected]> >> wrote: >> > Wow, that is exactly what I wanted, it is "equivalent" with +/ . * >> > applied the unpartitioned matrices A and B. >> > Can you explain why you've added /&, ? >> > Thanks for the help! >> > >> > On Mon, Nov 7, 2011 at 9:50 PM, Ric Sherlock <[email protected]> wrote: >> >> or did you want >> >> tA +/ .*&.>/&, tB >> >> ┌─────────┬─────────┬─────────┐ >> >> │330 345 │360 375 │ 390 405│ >> >> │870 921 │972 1023 │1074 1125│ >> >> ├─────────┼─────────┼─────────┤ >> >> │1410 1497│1584 1671│1758 1845│ >> >> │1950 2073│2196 2319│2442 2565│ >> >> ├─────────┼─────────┼─────────┤ >> >> │2490 2649│2808 2967│3126 3285│ >> >> │3030 3225│3420 3615│3810 4005│ >> >> └─────────┴─────────┴─────────┘ >> >> >> >> >> >> On Tue, Nov 8, 2011 at 9:40 AM, Ric Sherlock <[email protected]> wrote: >> >>> (,tA) +/ .*&.> (,tB) >> >>> >> >>> On Tue, Nov 8, 2011 at 9:09 AM, Jan Jacobs <[email protected]> >> wrote: >> >>>> ls, >> >>>> for educational purposes I want to breakdown a CUDA matrix >> >>>> multiplication in smaller parts. >> >>>> What I do not understand is that for B=:A =: i.6 6 >> >>>> tA =: (2 2,:2 2)<;._3 A >> >>>> tB =: (2 2,:2 2)<;._3 B >> >>>> tA (+/ . *)&.> tB >> >>>> works fine, but >> >>>> tA =: (2 6,:2 6)<;._3 A >> >>>> tB =: (6 2,:6 2)<;._3 B >> >>>> tA (+/ . *)&.> tB >> >>>> does not: >> >>>> |length error >> >>>> | tA (+/ .*)"1&.>tB >> >>>> >> >>>> The shapes of the various boxes are as expected. >> >>>> What is going wrong? >> >>>> Thanks in advance for the help. >> >>>> Jan. >> >>>> >> >>>> >> >>>> -- >> >>>> Jan Jacobs >> >>>> Esdoornstraat 33 >> >>>> 5995AN Kessel >> >>>> W: www.sommaps.com >> >>>> T: +31 77 462 1887 >> >>>> M: +31 6 23 82 55 21 >> >>>> E: [email protected] >> >>>> ---------------------------------------------------------------------- >> >>>> For information about J forums see >> http://www.jsoftware.com/forums.htm >> >>>> >> >>> >> >> ---------------------------------------------------------------------- >> >> For information about J forums see http://www.jsoftware.com/forums.htm >> > >> > >> > >> > -- >> > Jan Jacobs >> > Esdoornstraat 33 >> > 5995AN Kessel >> > W: www.sommaps.com >> > T: +31 77 462 1887 >> > M: +31 6 23 82 55 21 >> > E: [email protected] >> > ---------------------------------------------------------------------- >> > For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
