COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Maximum index for arrays?

• Follow

```Hi guys,

Thanks for helping me for the past few weeks. I've managed to get
CUBLAS and other CUDA programs working in IDL. What I have now for you
guys is this.

Here is the code

N = 181
N2 = N^2
a  = fltarr(N2, 141)
help,a

A                     FLOAT         = Array[32761, 141]

N = 182
N2 = N^2
a = fltarr(N2, 141)
% Array dimensions must be greater than 0
% Execution halted at: TEST                      5 /home/hpr/test.pro
%                   \$MAIN\$
IDL>

How big can the index go? Its because I need N = 100 to 1000

Regards
Zaki
```
 0
Reply hotplainrice (15) 9/15/2008 6:08:23 AM

```On Sep 14, 8:08=A0pm, "hotplainr...@gmail.com" <hotplainr...@gmail.com>
wrote:
> Hi guys,
>
> Thanks for helping me for the past few weeks. I've managed to get
> CUBLAS and other CUDA programs working in IDL. What I have now for you
> guys is this.
>
> Here is the code
>
> N =3D 181
> N2 =3D N^2
> a =A0=3D fltarr(N2, 141)
> help,a
>
> A =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FLOAT =A0 =A0 =A0 =A0 =3D Array=
[32761, 141]
>
> N =3D 182
> N2 =3D N^2
> a =3D fltarr(N2, 141)
> % Array dimensions must be greater than 0
> % Execution halted at: TEST =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A05 =
/home/hpr/test.pro
> % =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \$MAIN\$
> IDL>
>
> How big can the index go? Its because I need N =3D 100 to 1000
>
> Regards
> Zaki

The problem is that the line
N =3D 182
sets N to a 16-bit signed integer (max size 32767-ish). When you
square it (33124), it overflows and becomes negative (-32412). Use
something like
N=3D182L (long integer with max size about 2 billion) or
N=3D2. (floating point)

As long as you have the RAM, arrays can have millions or billions (i
think) of elements, so you'll be fine.

chris
```
 0
Reply beaumont (75) 9/15/2008 8:53:26 AM

```On Sep 15, 6:53=A0pm, Chris <beaum...@ifa.hawaii.edu> wrote:
> On Sep 14, 8:08=A0pm, "hotplainr...@gmail.com" <hotplainr...@gmail.com>
> wrote:
>
>
>
> > Hi guys,
>
> > Thanks for helping me for the past few weeks. I've managed to get
> > CUBLAS and other CUDA programs working in IDL. What I have now for you
> > guys is this.
>
> > Here is the code
>
> > N =3D 181
> > N2 =3D N^2
> > a =A0=3D fltarr(N2, 141)
> > help,a
>
> > A =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FLOAT =A0 =A0 =A0 =A0 =3D Arr=
ay[32761, 141]
>
> > N =3D 182
> > N2 =3D N^2
> > a =3D fltarr(N2, 141)
> > % Array dimensions must be greater than 0
> > % Execution halted at: TEST =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
5 /home/hpr/test.pro
> > % =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \$MAIN\$
> > IDL>
>
> > How big can the index go? Its because I need N =3D 100 to 1000
>
> > Regards
> > Zaki
>
> The problem is that the line
> N =3D 182
> sets N to a 16-bit signed integer (max size 32767-ish). When you
> square it (33124), it overflows and becomes negative (-32412). Use
> something like
> N=3D182L (long integer with max size about 2 billion) or
> N=3D2. (floating point)
>
> As long as you have the RAM, arrays can have millions or billions (i
> think) of elements, so you'll be fine.
>
> chris

Thanks chris, that resolved the problem.
```
 0
Reply hotplainrice (15) 9/15/2008 10:15:07 AM

```
hotplainrice@gmail.com wrote:
> Hi guys,
>
> Thanks for helping me for the past few weeks. I've managed to get
> CUBLAS and other CUDA programs working in IDL. What I have now for you
> guys is this.
>
> Here is the code
>
> N = 181
> N2 = N^2
> a  = fltarr(N2, 141)
> help,a
>
> A                     FLOAT         = Array[32761, 141]
>
> N = 182
> N2 = N^2
> a = fltarr(N2, 141)
> % Array dimensions must be greater than 0
> % Execution halted at: TEST                      5 /home/hpr/test.pro
> %                   \$MAIN\$
> IDL>
>
> How big can the index go? Its because I need N = 100 to 1000

Just for the records, IDL 32-bit can have arrays with a maximum of
2^31/N elements, where N is the size in byte of one element (i.e. 1
for bytes,
2 for int, 4 for long int and floats, etc. etc.).

On the orther hand, IDL 64 bits can (in principle) allocate arrays so
large that you won't be able to store them anyway (at least for the
next
few years or so)

Cheers,
Paolo

>
> Regards
> Zaki
```
 0
Reply pgrigis1 (374) 9/15/2008 1:38:08 PM

3 Replies
49 Views

5/23/2013 3:36:35 PM