No more than 8 dimensions in Array! :-(
-
- Posts: 375
- Joined: Mar 15, 2015 12:41
No more than 8 dimensions in Array! :-(
Hello.
I need an array with 12 indexes but if I try to dim more than 8 its says "too many array dimensions" :-(
Any suggestion?
May be is possible, and may be faster, to directly place information in memory but not know how to do it.
Thanks in advance.
I need an array with 12 indexes but if I try to dim more than 8 its says "too many array dimensions" :-(
Any suggestion?
May be is possible, and may be faster, to directly place information in memory but not know how to do it.
Thanks in advance.
Last edited by Luis Babboni on Jul 06, 2015 22:14, edited 2 times in total.
-
- Posts: 556
- Joined: Mar 10, 2007 15:44
- Location: Ohio, USA
- Contact:
Re: No more than 8 indexes in Array! :-(
Dim A(11) As Integer
or
Dim A(1,2,3,4,5,6,7,8,9,10,11,12) As Integer
Which one, first one is 12 indexes and second is 12 dimensions?
or
Dim A(1,2,3,4,5,6,7,8,9,10,11,12) As Integer
Which one, first one is 12 indexes and second is 12 dimensions?
-
- Posts: 375
- Joined: Mar 15, 2015 12:41
Re: No more than 8 indexes in Array! :-(
Sorry, second one.bcohio2001 wrote:Dim A(11) As Integer
or
Dim A(1,2,3,4,5,6,7,8,9,10,11,12) As Integer
Which one, first one is 12 indexes and second is 12 dimensions?
I´m trying with Callocate, not sure if the correct option.
I tried Callocate and not Allocate cause I need the values not loaded with values remains as 0. I did the correct election?
Thanks.
PS: subject edited.
Re: No more than 8 dimensions in Array! :-(
You do realize that the array as you show in your example uses over 1.9Gb of memory?
-Vince
-Vince
Re: No more than 8 indexes in Array! :-(
It sounds to me like you are in need of nested types.Luis Babboni wrote:12 dimension arrray
It's not often you see more than 3 dim array. I can't imagine the use case for 12.
Could you elaborate a little on what you are using it for?
-
- Posts: 375
- Joined: Mar 15, 2015 12:41
Re: No more than 8 dimensions in Array! :-(
Do not scared me!! :-D The example is not mine array.vdecampo wrote:You do realize that the array as you show in your example uses over 1.9Gb of memory?
-Vince
Mine is A(9,3,3,3,2,9,3,3,3,2)* as integer that have, if i´m right, 9^2*3^6*2*2 bytes = 236,196 bytes = 230KB
I´m trying to make stats about combinations of amount of material in chess:
0 to 8 white pawns; 0 to 2 white knights; 0 to 2 white bishops; 0 to 2 white rooks and 0 to 1 white queen and the same for black pieces.
*In fact just 10 dimensiosn, not 12 as I thought first.
Re: No more than 8 dimensions in Array! :-(
To get 10 dimensions artificially I have created an array of one dimension to hold the values.
Up to 20 fake dimensions are coded for here.
I have used the 10 dimension sizes given:
Up to 20 fake dimensions are coded for here.
I have used the 10 dimension sizes given:
Code: Select all
'up to 20 fake dimensions
#define _r(n) (ub(n)-lb(n)+1)
#define d1(n1) (n1-lb(1))
#define d2(n1,n2) (_r(2)*d1(n1)+(n2-lb(2)))
#define d3(n1,n2,n3) (_r(3)*d2(n1,n2)+(n3-lb(3)))
#define d4(n1,n2,n3,n4) (_r(4)*d3(n1,n2,n3)+(n4-lb(4)))
#define d5(n1,n2,n3,n4,n5) (_r(5)*d4(n1,n2,n3,n4)+(n5-lb(5)))
#define d6(n1,n2,n3,n4,n5,n6) (_r(6)*d5(n1,n2,n3,n4,n5)+(n6-lb(6)))
#define d7(n1,n2,n3,n4,n5,n6,n7) (_r(7)*d6(n1,n2,n3,n4,n5,n6)+(n7-lb(7)))
#define d8(n1,n2,n3,n4,n5,n6,n7,n8) (_r(8)*d7(n1,n2,n3,n4,n5,n6,n7)+(n8-lb(8)))
#define d9(n1,n2,n3,n4,n5,n6,n7,n8,n9) (_r(9)*d8(n1,n2,n3,n4,n5,n6,n7,n8)+(n9-lb(9)))
#define d10(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10) (_r(10)*d9(n1,n2,n3,n4,n5,n6,n7,n8,n9)+(n10-lb(10)))
#define d11(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11) (_r(11)*d10(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10)+(n11-lb(11)))
#define d12(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12) (_r(12)*d11(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11)+(n12-lb(12)))
#define d13(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13) (_r(13)*d12(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12)+(n13-lb(13)))
#define d14(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14) (_r(14)*d13(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13)+(n14-lb(14)))
#define d15(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15) (_r(15)*d14(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14)+(n15-lb(15)))
#define d16(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16) (_r(16)*d15(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15)+(n16-lb(16)))
#define d17(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17) (_r(17)*d16(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16)+(n17-lb(17)))
#define d18(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18) (_r(18)*d17(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17)+(n18-lb(18)))
#define d19(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19) (_r(19)*d18(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18)+(n19-lb(19)))
#define d20(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20) (_r(20)*d19(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19)+(n20-lb(20)))
dim as integer d=10 'dimensions required
dim as ulongint lb(1 to d),ub(1 to d) 'lower and upper bound arrays defined here
'set up fake lower and upper bounds
''A(9,3,3,3,2,9,3,3,3,2) YOUR BOUNDS
for z as integer=1 to d
select case z
case 1,6: lb(z)=0:ub(z)=9
case 2,3,4,7,8,9: lb(z)=0:ub(z)=3
case 5,10: lb(z)=0:ub(z)=2
end select
next z
'use a real array to test method
print "Test against an array dim 7" 'fake versus real
dim as integer b(9,3,3,3,2,9,3) 'the first seven of Yours
print d7(9,3,3,3,2,9,3)
print @b(9,3,3,3,2,9,3)-@b(0,0,0,0,0,0,0)
print d7(0,0,0,0,0,0,0)
print "_______________________________"
print
var x=d10(9,3,3,3,2,9,3,3,3,2)'set up 10 fake dimensions
print "d10 = ";x
dim shared as integer a(0 to x)'get a single dimension array equivelant
dim as integer n1,n2,n3,n4,n5,n6,n7,n8,n9,n10
dim as integer counter
for n1=0 to 9
for n2=0 to 3
for n3=0 to 3
for n4=0 to 3
for n5=0 to 2
for n6=0 to 9
for n7=0 to 3
for n8=0 to 3
for n9=0 to 3
for n10=0 to 2
'get some values
a( d10(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10) )=counter
counter+=1
next:next:next:next:next:next:next:next:next:next
'alternative way to fill
for z as integer=0 to x
'a(z)=z
next z
'--------------------
print a(d10(9,3,3,3,2,9,3,3,3,2))'top value
print a(d10(3,0,3,2,1,2,3,2,1,0))'somewhere in the middle
print a(d10(0,0,0,0,0,0,0,0,0,0))'lowest value
sleep
Re: No more than 8 dimensions in Array! :-(
Close. I think it would be 236196 * sizeof(integer). So 1 or 2 MB depending on 32 or 64-bit.Luis Babboni wrote:Mine is A(9,3,3,3,2,9,3,3,3,2)* as integer that have, if i´m right, 9^2*3^6*2*2 bytes = 236,196 bytes = 230KB
Re: No more than 8 dimensions in Array! :-(
I calculate 839,608 x SizeOf(Integer) which is about 3.4 Mb.Luis Babboni wrote:Do not scared me!! :-D The example is not mine array.vdecampo wrote:You do realize that the array as you show in your example uses over 1.9Gb of memory?
-Vince
Mine is A(9,3,3,3,2,9,3,3,3,2)* as integer that have, if i´m right, 9^2*3^6*2*2 bytes = 236,196 bytes = 230KB
I´m trying to make stats about combinations of amount of material in chess:
0 to 8 white pawns; 0 to 2 white knights; 0 to 2 white bishops; 0 to 2 white rooks and 0 to 1 white queen and the same for black pieces.
*In fact just 10 dimensiosn, not 12 as I thought first.
-Vince
Re: No more than 8 dimensions in Array! :-(
OOPS.
I see that your actual dimension sizes are one less (0 to ...)
So caseih is correct.
I have re-done:
I see that your actual dimension sizes are one less (0 to ...)
So caseih is correct.
I have re-done:
Code: Select all
'up to 20 fake dimensions
#define _r(n) (ub(n)-lb(n)+1)
#define d1(n1) (n1-lb(1))
#define d2(n1,n2) (_r(2)*d1(n1)+(n2-lb(2)))
#define d3(n1,n2,n3) (_r(3)*d2(n1,n2)+(n3-lb(3)))
#define d4(n1,n2,n3,n4) (_r(4)*d3(n1,n2,n3)+(n4-lb(4)))
#define d5(n1,n2,n3,n4,n5) (_r(5)*d4(n1,n2,n3,n4)+(n5-lb(5)))
#define d6(n1,n2,n3,n4,n5,n6) (_r(6)*d5(n1,n2,n3,n4,n5)+(n6-lb(6)))
#define d7(n1,n2,n3,n4,n5,n6,n7) (_r(7)*d6(n1,n2,n3,n4,n5,n6)+(n7-lb(7)))
#define d8(n1,n2,n3,n4,n5,n6,n7,n8) (_r(8)*d7(n1,n2,n3,n4,n5,n6,n7)+(n8-lb(8)))
#define d9(n1,n2,n3,n4,n5,n6,n7,n8,n9) (_r(9)*d8(n1,n2,n3,n4,n5,n6,n7,n8)+(n9-lb(9)))
#define d10(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10) (_r(10)*d9(n1,n2,n3,n4,n5,n6,n7,n8,n9)+(n10-lb(10)))
#define d11(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11) (_r(11)*d10(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10)+(n11-lb(11)))
#define d12(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12) (_r(12)*d11(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11)+(n12-lb(12)))
#define d13(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13) (_r(13)*d12(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12)+(n13-lb(13)))
#define d14(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14) (_r(14)*d13(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13)+(n14-lb(14)))
#define d15(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15) (_r(15)*d14(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14)+(n15-lb(15)))
#define d16(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16) (_r(16)*d15(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15)+(n16-lb(16)))
#define d17(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17) (_r(17)*d16(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16)+(n17-lb(17)))
#define d18(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18) (_r(18)*d17(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17)+(n18-lb(18)))
#define d19(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19) (_r(19)*d18(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18)+(n19-lb(19)))
#define d20(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20) (_r(20)*d19(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19)+(n20-lb(20)))
dim as integer d=10 'dimensions required
dim as ulongint lb(1 to d),ub(1 to d) 'lower and upper bound arrays defined here
'set up fake lower and upper bounds
''A(8,2,2,2,1,8,2,2,2,1) YOUR BOUNDS
for z as integer=1 to d
select case z
case 1,6: lb(z)=0:ub(z)=8
case 2,3,4,7,8,9: lb(z)=0:ub(z)=2
case 5,10: lb(z)=0:ub(z)=1
end select
next z
'use a real array to test method
print "Test against an array dim 7" 'fake versus real
dim as integer b(8,2,2,2,1,8,2) 'the first seven of Yours
print d7(8,2,2,2,1,8,2)
print @b(8,2,2,2,1,8,2)-@b(0,0,0,0,0,0,0)
print d7(0,0,0,0,0,0,0)
print "_______________________________"
print
var x=d10(8,2,2,2,1,8,2,2,2,1)'set up 10 fake dimensions
print "d10 = ";x
print (X+1); " * sizeof(integer) would be memory used here"
dim shared as integer a(0 to x)'get a single dimension array equivelant
dim as integer n1,n2,n3,n4,n5,n6,n7,n8,n9,n10
dim as integer counter
for n1=0 to 8
for n2=0 to 2
for n3=0 to 2
for n4=0 to 2
for n5=0 to 1
for n6=0 to 8
for n7=0 to 2
for n8=0 to 2
for n9=0 to 2
for n10=0 to 1
'get some values
a( d10(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10) )=counter
counter+=1
next:next:next:next:next:next:next:next:next:next
'alternative way to fill
for z as integer=0 to x
'a(z)=z
next z
'--------------------
print a(d10(8,2,2,2,1,8,2,2,2,1))'top value
print a(d10(3,0,2,2,1,2,0,2,1,0))'somewhere in the middle
print a(d10(0,0,0,0,0,0,0,0,0,0))'lowest value
sleep
-
- Posts: 375
- Joined: Mar 15, 2015 12:41
Re: No more than 8 dimensions in Array! :-(
Sizeof(Integer) Good point!
I could define integer<x> with x=8;16;32 or 64, I´m right? That is 1, 2, 4, 8 bytes respectevely, isn´t it?
What about to use Callalocate?
If I´m right, value of A(2,3,4)= value allocated in origin of allocation + 2*3*4 or something similar.
Works?
Is faster than arrays, the same or slower?
I could define integer<x> with x=8;16;32 or 64, I´m right? That is 1, 2, 4, 8 bytes respectevely, isn´t it?
What about to use Callalocate?
If I´m right, value of A(2,3,4)= value allocated in origin of allocation + 2*3*4 or something similar.
Works?
Is faster than arrays, the same or slower?
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: No more than 8 dimensions in Array! :-(
A 32 bit variable claims 4 bytes of memory space, no matter if in an array or in an allocated memory block. Also an array is quite the fastest way to handle a big amount of data, combined with a convenient access management. I would strongly recommend to use an array. To save memory space, you could think about using a different data type ('Byte' or 'Short').
Regards
grindstone
Regards
grindstone
-
- Posts: 375
- Joined: Mar 15, 2015 12:41
Re: No more than 8 dimensions in Array! :-(
How to test it?grindstone wrote:A 32 bit variable claims 4 bytes of memory space, no matter if in an array or in an allocated memory block. Also an array is quite the fastest way to handle a big amount of data, combined with a convenient access management. I would strongly recommend to use an array. To save memory space, you could think about using a different data type ('Byte' or 'Short').
Regards
grindstone
Timer is too gross, measures time in seconds :-(
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: No more than 8 dimensions in Array! :-(
Are you coding in QBasic?
-
- Posts: 375
- Joined: Mar 15, 2015 12:41
Re: No more than 8 dimensions in Array! :-(
No, no, in FB.grindstone wrote:Are you coding in QBasic?