Thanks for the response Igor!

Well the compiler did not complain for
val mat : Array[Int]([1..MAX, 1..MAX]->here, ((i, j):Point) => 0);

I tried different versions of the array definition but could not get it working.

1. I typed in your version: val mat = new Array[Int]([1..MAX,
1..MAX]->here, ((i, j):Point)=>0);
It says the Array constructor cannot be invoked with given arguments.
Looks like the Array constructor expects a region as its first
argument. I encountered the same problem with the make method.

2. So I tried
val mat = new Array[Int]([1..MAX, 1..MAX], ((i, j):Point)=>0);
which works but then the for loop which iterates over this array
throws an ArrayIndexOutOfBoundsException.

I am using X10DT installed on Eclipse-Ganymede, 32-bit Windows Vista platform.

Eclipse-Galileo on 32-bit Linux complains when I try to install X10DT
update there.

Thanks,
Nilesh.


On Tue, Aug 17, 2010 at 5:05 PM, Igor Peshansky <ig...@us.ibm.com> wrote:
> Nilesh Mahajan <nnmah...@umail.iu.edu> wrote on 08/17/2010 04:32:29 PM:
>
>> Hi,
>>
>> I am trying to set elements of a 2D Int array and am facing some
>> problems. Can somebody please help?
>>
>> Code snippet:
>>
>> const MAX 10000;
>> const MAXPERROW 100;
>>
>> val mat : Array[Int]([1..MAX, 1..MAX]->here, ((i, j):Point) => 0);
>
> This is not syntactically valid X10.  You must've said something like
>
> val mat: Array[Int] = new Array[Int]([1..MAX, 1..MAX]->here, ((i,
> j):Point)=>0);
>
> instead.  Also note that this code will probably not work in the later
> versions of X10, as you now need to specify the parameter type of the
> closure more precisely, i.e., "((i, j):Point(2))=>0".
>
>> for (var i:Int = 0; i < MAX; i++) {
>>     var numCols:Int = new Random().nextInt(MAXPERROW);
>>     for (var j:Int = 0; j < numCols; j++) {
>>         var ColIndex:Int = new Random().nextInt(MAX);
>>         mat.set(1, i, colIndex);
>>     }
>> }
>>
>>
>> the 'mat.set' line throws an error which says (among other things):
>> Call Invalid; calling method does not entail the method guard.
>
> This means that the typechecker was not able to prove that the mat
> array is 2-dimensional.  That's why I suspect you have specified the
> explicit type on the declaration of "val mat".  Either change that type
> to Array(2), or omit the type altogether (i.e., write
>
> val mat = new Array[Int]([1..MAX, 1..MAX]->here, ((i, j):Point)=>0);
>
> ) and let the typechecker infer it for you.
>
>> P.S. Is there a way to search the user archives?
>
> There's Google, which lets you restrict the URLs of the pages you
> search.  Note that there are two sets of archives for the x10-users
> list outside of Sourceforge that may work better with Google
> searching, or even offer their own search capabilities:
>
> http://www.mail-archive.com/x10-users@lists.sourceforge.net/
> http://blog.gmane.org/gmane.comp.lang.x10.user or
> http://news.gmane.org/gmane.comp.lang.x10.user
>
> Hope this helps,
>        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
>
>
> ------------------------------------------------------------------------------
> 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
>

------------------------------------------------------------------------------
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

Reply via email to