Hi,
You need to specify the rank/dimension of  a_prefix_sum here :

val a_prefix_sum = new Array[Int](a.region, (Point)=>0);
... a_prefix_sum([i-1]);  ...

So you need to write that:
public static def computeSum(a:Array[Int]*(1)*)



On Mon, Jul 19, 2010 at 5:03 PM, Dave Hudak <dhu...@osc.edu> wrote:

> Hi All,
>
> I hope I am doing something easy to correct.  I am trying to move some code
> to compute the prefix sum of an integer array into its own method.  I'm
> using 2.0.4.
>
> I get the following error:
>
> dhu...@oscnet166 24%> x10c++ -x10rt mpi -o PrefixSum PrefixSum.x10
> /Users/dhudak/osc/research/x10/tutorial/examples/PrefixSum.x10:34: Method
> or static constructor not found for given matcher.
>         Matcher: a_prefix_sum(x10.lang.ValRail[x10.lang.Int
> ]{self.length==1})
> 1 error.
>
> ...which corresponds to the statement in the else clause of the computeSum
> method
> >                       a_prefix_sum(p) = a(p) + a_prefix_sum([i-1]);
>
> Below is the entire code for reference.
>
> Thanks,
> Dave
>
> /*
>  * PrefixSum
>  * Sequential implementation
>  * Dave Hudak
>  * Ohio Supercomputer Center
>  */
>
> public class PrefixSum {
>    public static def str[T](a:Array[T]):String
>    {
>        var s : String = "";
>            //var is mutable
>                var first : Boolean = true;
>                     //var declaration must include type
>                for (point in a) {
>                        if (first) {
>                                first = false;
>                        }
>                        else {
>                                s += ", ";
>                        }
>                        s += a(point).toString();
>                     //works because toString is global
>                }
>                return s;
>    }
>
>    public static def computeSum(a:Array[Int]):Array[Int]{self.region ==
> a.region}
>    {
>          val a_prefix_sum = new Array[Int](a.region, (Point)=>0);
>          for (p in a_prefix_sum) {
>                val (i) = p;
>                if (i == 1) {
>                        a_prefix_sum(p) = a(p);
>                }
>                else {
>                        a_prefix_sum(p) = a(p) + a_prefix_sum([i-1]);
>                }
>          }
>          return a_prefix_sum;
>     }
>
>    public static def main(args: Rail[String]!): Void {
>          val ARRAY_SIZE = 10;
>                    //values are like constants (immutable)
>          val r1 = [1..ARRAY_SIZE];
>                     //define a range
>          val a1 = new Array[Int](r1, (Point)=>0);
>    //create an array of all zeroes
>          Console.OUT.println("a1(1) = " + a1([1]));
>  //index arrays using parens around points
>          for (p in a1) {
>                val (i) = p;
>                            //fetch the subscript of the point
>                a1(p) = i;
>                                    //assign it to the array value
>          }
>          val a1_string = str(a1);
>          Console.OUT.println(a1_string);
>          val a1_prefix_sum = computeSum(a1);
>          val a1_prefix_sum_string = str(a1_prefix_sum);
>          Console.OUT.println(a1_prefix_sum_string);
>    }
> }
> ---
> David E. Hudak, Ph.D.          dhu...@osc.edu
> Program Director, HPC Engineering
> Ohio Supercomputer Center
> http://www.osc.edu
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to