Russel Winder <rus...@russel.org.uk> wrote on 11/03/2010 05:05:33 PM:
>
> I have a program that worked under 2.0.3 -- though it used some
> nastiness of the then Array.lift function which has now gone away (which
> is probably for the best). However it leaves me with a problem. The
> algorithm I have is basically a data parallel one so I need a parallel
> map. However I want the types in the source Array to be different from
> the types in the destination Array; basically my transform function is
> either:
>
> int -> double
>
> or
>
> ( int , int , double ) -> double
>
> Now I may be misreading the manual but it seems that the Array.map
> method requires the type of the source and destination to be the same.
> Is this right? If it is isn't it a bit limiting?
>
Hi,
We split Array into two classes: Array (an array that is local to a
single place) and DistArray (an array that is potentially distributed
across places).
The map methods on Array are fairly general.
public def map[U](dst:Array[U](region), op:(T)=>U):Array
[U](region){self==dst}
public def map[S,U](dst:Array[S](region), src:Array[U](region),
op:(T,U)=>S):Array[S](region)
They require the Arrays to be defined over the same region, but are
otherwise fairly general.
Unfortunately, the map function on DistArray didn't get updated to be
less restrictive in terms of the types involved. It still requires a
(T)=>T operation, not a (T)=>S. I don't think there is any good reason for
this, just that we were focusing on getting the Array API to be "right"
with the intention of then updating DistArray all at once to match the
improvements in the Array API and didn't do those updates in time for
2.1.0.
Sorry about that, we'll get the APIs of DistArray and Array in sync
for 2.1.1. You could probably do it with some minimal pain by either
modifying DistArray directly to fix its map method, or by making a
DistArray[Array[T]] and DistArray[Array[S]] and then writing an ateach that
uses the Array map function in each place on the elements of the DistArray
[Array]'s at that place. Not a pretty thing, but could be enough to get
you unblocked.
--dave
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users