Hi Christoph, I won't comment on whether there are better ways to implement a matrix-vector multiply.
The immediate problem here is that the Region.product(...) operation doesn't combine the rank constraints of the two operands. In other words, it is currently defined as: abstract public global def product(that: Region): Region; whereas it should be: abstract public global def product(that: Region): Region(this.rank+that.rank); Unfortunately such arithmetic constraints will not be possible until X10 2.1, so for the time being, the rank constraint must be lost. For now, you could perform a cast to restore the lost rank constraint: val r = ( ([j..j] as Region(1)) * A.region.projection(1)) as Region(2); Once X10 2.1 is released, such a cast should no longer be required. I would also suggest that you drop the explicit type declarations for values, as discussed in Bard's earlier posting: http://sourceforge.net/mailarchive/message.php?msg_name=OF1917566B.E32908BD-ON852576A6.0007CA46-852576A6.000916B7%40us.ibm.com For example just write val r = ... instead of val r:Region = This will ensure that type information (including the rank constraint) is preserved as far as possible. Kind regards, Josh Christoph Pospiech wrote: > Hi, > > since two days I am fighting with X10 to formulate a simple matrix vector > multiply. Apparently I am thinking in the wrong direction. Perhaps someone > can > correct me here. > > My essential idea is the following. > > def ClassicMatrixMultiply() { > finish ateach (p in v2.dist() ) { > [... some code...] > v2(p) = ((A|d)*linev).reduce(double.+,0); > } > finish v = (v2 as Array[double](v.dist()) ); > } > > Here > - A is a distributed Array[double], a square matrix of size n*n, > - v an Array[double] of rank 1, (v.size == n), placed at Places.FIRST_PLACE, > - v2 an Array[double] of rank 1, distributed the same way as any column of A. > - all are var (not val or const). > > In clear text the line v2(p) should read "multiply the row of A that > corresponds to p with v. To make that happen, I tried to set up a > distribution > that describes the "row of A that corresponds to p". My following attempt > looks very clumsy and the X10 compiler doesn't compile it either. > (The following lines go into [... some code...] above). > > val j:Int = (p.coords())(0); > val r:Region = ( ([j..j] as Region(1)) > * A.region.projection(1)); > val d:Dist = A.dist().intersection(r); > val linev = (v as Array[double](d)); > > The compiler hick-ups on the expression A.dist().intersection(r). I frankly > don't understand, why. Both, A.dist() and r are having the same rank. > Shouldn't that suffice ? Any one any explanation ? > I would expect that there is a better way to do this. So I am happy with any > suggestions. > ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users