Hi Nilesh, browsing the list archive, I noticed nobody had yet answered this one - sorry for the silence!
The Array classes have been in a state of flux over recent months, with significant performance improvements and changes to the distributed object model for X10 2.1. Unfortunately, while this work has been occurring, some of the nice Region operations (union, intersection, complement) have been disabled. This means that it is currently more complicated to express the sort of Region manipulation you are describing. Once Region.union(...) has been restored, you might express the combination of two rectangular subregions of a matrix as: val rowOne = Region.make([i1..i1, 0..N-1]); val rowTwo = Region.make([i2..i2, 0..N-1]); val combined = rowOne || rowTwo; Note that in the above, the rows are still 2-D regions, in which the first dimension is of size 1. This is necessary to allow them to be combined in a 2-D union. For now, the subregions must be treated separately, 'pasting' them together using Point translations. The example below is a function to eliminate a selected row from a matrix, as might be done in calculating e.g. the Laplace expansion. def eliminateRow(source : DistArray[Double](2), row : Int) { val resultRegion = [source.region.min(0)..source.region.max(0)-1, source.region.min(1)..source.region.max(1)]; val result = DistArray.make[Double](source.dist | resultRegion); val rowsAbove = Region.make([source.region.min(0)..row-1, source.region.min(1)..source.region.max(1)]); val rowsBelow = Region.make([row+1..source.region.max(0), source.region.min(1)..source.region.max(1)]); finish ateach (p in result | rowsAbove) { result(p) = source(p); } // remaining rows must be shifted up by one val shift = Point.make(1, 0); finish ateach (p in result | (rowsBelow-shift)) { result(p) = at (source.dist(p+shift)) {source(p+shift)}; } return result; } Note that this could be simplified given certain assumptions about the distribution - for example, if the matrix were block distributed in dimension 1 (_not_ in dimension 0), the 'at (source.dist(p+shift))' would not be required. If the entire matrix were stored as an Array at a single place, data could be efficiently copied in bulk using Array.copy(...). I hope some of this is useful. Cheers, Josh Nilesh Mahajan wrote: > Hi, > > I was wondering if there is a way to combine two or more 1-dimensional > distributions to form a 2-D distribution. For example, I would like to > select arbitrary rows from a matrix and form a sub-matrix out of it. > The rows can be non-contiguous and I don't know them statically. > > Thanks, > Nilesh. > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > _______________________________________________ > X10-users mailing list > X10-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/x10-users > ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users