Christoph Pospiech <christoph.pospi...@de.ibm.com> wrote on 06/07/2010 
03:50:37 PM:

> On Thursday 03 June 2010, Igor Peshansky wrote:
> > Christoph Pospiech <christoph.pospi...@de.ibm.com> wrote on 06/03/2010 

> > 
> > > On Wednesday 02 June 2010 11:41:04 pm Yoav Zibin wrote:
> > > > The definition of reduce is:
> > > > def reduce(op:(T,T)=>T, unit:T):T
> > > > 
> > > > You pass it a function with a guard:
> > > > ArrayD_add(s1:Array[Double],
> > > >             s2:Array[Double])
> > > >     *{s1.region() == s2.region(), s1.rail(), s2.rail()}*: 
> > > >  Array[Double]
> > > > 
> > > > remove the guard, and it should fit.
> > > > 
> > >
> > > 
> > > Is there a type cast for function types ? Something along the lines
> > > ArrayD_add as op:(T,T)=>T ?
> > > 
> > > Otherwise, I have to find a guard-free implementation for 
ArrayD_add...
> > 
> > You can always wrap it in a closure that casts appropriately, namely:
> > 
> > (x:Array[Double],y:Array[Double])=>ArrayD_add(x as 
Array[Double]{rail}, y 
> > as Array[Double]{rail&&region==x.region})
> > 
> > HTH,
> >         Igor
> > 
> 
> Igor,
> 
> thank you for your helpful answer.
> 
> I was bold enough to plug your suggestion directly into the call to 
reduce, 
> namely:
> 
>    v = v_dst.reduce(
>             (x:Array[Double],y:Array[Double])
>             =>ArrayD_add(x as Array[Double]{rail},
>                   y as Array[Double]{rail&&region==x.region}),
>                   v);
> 
> X10DT complains as follows.
> 
> Multiple messages at this line.
>    -Method reduce((x:x10.lang.Double, y:x10.lang.Double)=> T, T) in 
> x10.array.DistArray
>     [x10.array.Array[x10.lang.Double]{self.region.rank==1}]
> {self==matmul#this.v_dst, 
>     matmul#this.v_dst.dist.region.rank==1} cannot be called with 
arguments 
> ((x:x10.lang.Double, 
>     y:x10.lang.Double)=> x10.array.Array[x10.lang.Double], 
> x10.array.Array[x10.lang.Double]
>     {self==matmul#this.v, matmul#this.v.region.rank==1}); Invalid 
Parameter. 
> expected type: 
>     (x:x10.lang.Double, y:x10.lang.Double)=> 
x10.array.Array[x10.lang.Double]
> {self.region.rank==1} 
>     found: (x:x10.lang.Double, y:x10.lang.Double)=> 
> x10.array.Array[x10.lang.Double]
>    -Method reduce((x:x10.lang.Double, y:x10.lang.Double)=> T, T) in 
> x10.array.DistArray
>     [x10.array.Array[x10.lang.Double]{self.region.rank==1}]
> {self==matmul#this.v_dst, 
>     matmul#this.v_dst.dist.region.rank==1} cannot be called with 
arguments 
> ((x:x10.lang.Double, 
>     y:x10.lang.Double)=> x10.array.Array[x10.lang.Double], 
> x10.array.Array[x10.lang.Double]
>     {self==matmul#this.v, matmul#this.v.region.rank==1}); Invalid 
Parameter. 
> expected type: 
>     (x:x10.lang.Double, y:x10.lang.Double)=> 
x10.array.Array[x10.lang.Double]
> {self.region.rank==1} 
>     found: (x:x10.lang.Double, y:x10.lang.Double)=> 
> x10.array.Array[x10.lang.Double]
> 
> Am I correct that I disposed too many guards now, i.e. 
{self.region.rank==1} 
> is missing ? And why does it expect 
> 
> x:x10.lang.Double, y:x10.lang.Double) => [...]
> 
> rather than
> 
> x:Array[Double],y:Array[Double])   => [...] 
> 
>      ?

I think this is a bug either in the typesystem or in the printing of a
generic type (i.e., it gets confused about what T is).

Based on the error message, however, looks like your T is defined to be
"x10.array.Array[x10.lang.Double]{self.region.rank==1}", a.k.a.
"Array[Double](1)" (not sure how it got that -- maybe by inferring the
generic type from a method invocation?).

So, since reduce() expects a function with type (T,T)=>T, your closure
must have the type 
"(Array[Double](1),Array[Double](1))=>Array[Double](1)".
Maybe that will placate the typechecker.
        Igor
-- 
Igor Peshansky  (note the spelling change!)
IBM T.J. Watson Research Center
X10: Parallel Productivity and Performance (http://x10-lang.org/)
XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/)
"I hear and I forget.  I see and I remember.  I do and I understand" -- 
Confucius


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to