| Author |
Message |
kijjaz

Joined: Sep 20, 2004 Posts: 531 Location: bangkok, thailand
Audio files: 2
|
Posted: Sun May 25, 2008 12:50 pm Post subject:
2D Array: value assignment problem |
 |
|
I've got this code:
| Code: | (second/samp) $ int => int SampleRate;
float A[SampleRate, SampleRate];
for(int x; x < SampleRate; x++)
for(int y; y < SampleRate; y++)
{
(x $ float + y $ float) / SampleRate / 2 => A[x,y];
} |
i'm running on Ubuntu Linux 8.04, sample rate = 48000
other things work fine,
but with the above program it says:
| Code: |
chuck: chuck_type.cpp:3185: Chuck_Type* type_engine_check_exp_array(Chuck_Env*, a_Exp_Array_*): Assertion `array->indices->depth == depth' failed.
Aborted |
What did i do wrong? |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1583 Location: Florida, USA
Audio files: 59
|
Posted: Sun May 25, 2008 1:04 pm Post subject:
|
 |
|
kijjaz, the correct syntax for a 2D array is:
Also, you are defining an array with 2.3 trillion elements in it. When I fixed your code and ran it, my poor little Mac locked up and I had to reboot! Serves me right for not reading the code carefully, haha! _________________ EChucK: The synthesizer that got smashed into smithereens! |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6619 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sun May 25, 2008 1:34 pm Post subject:
|
 |
|
| Inventor wrote: | kijjaz, the correct syntax for a 2D array is:
|
Yes. You see that's wrong and I do as well, but I wonder why ChucK didn't complain. I can get this to run;
...and I have no idea at all what that would mean. That's not valid syntax, at least not valid in a documented way. I think this is a bug and should be on the WiKi.
| Quote: | | Also, you are defining an array with 2.3 trillion elements in it. When I fixed your code and ran it, my poor little Mac locked up and I had to reboot! Serves me right for not reading the code carefully, haha! |
Yeah, that raised a eyebrow here...
| Code: |
Math.pow(48000, 2) => float num_of_floats;
num_of_floats * 32 * 2 => float num_of_bits; //I think this is what double precision means
num_of_bits / 8 => float num_of_bytes;
num_of_bytes / 1024 => float num_of_KB;
num_of_KB / 1024 => float num_of_MB;
num_of_MB / 1024 => float num_of_Gig;
<<<num_of_Gig>>>; |
Unless I made some mistake that's slightly over 17 gigabyte. That's quite a array.... _________________ Modern technology offers an endless field day to any deviant strains in our personalities. --J.G.Ballard |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 531 Location: bangkok, thailand
Audio files: 2
|
Posted: Sun May 25, 2008 2:58 pm Post subject:
|
 |
|
hahahhahahhaahahaha oohh yes it's just wrong syntax.
that killed ChucK so should report as bug. lol.
This is nice. |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 531 Location: bangkok, thailand
Audio files: 2
|
Posted: Sun May 25, 2008 3:01 pm Post subject:
|
 |
|
| Code: | (second/samp) $ int => int SampleRate;
float A[SampleRate][SampleRate];
for(int x; x < SampleRate; x++)
for(int y; y < SampleRate; y++)
{
(x $ float + y $ float) / SampleRate / 2 => A[x][y];
} |
result:
(it hangs......) then
| Code: |
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted |
is it simply out of memory for usual allocation? |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6619 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sun May 25, 2008 3:24 pm Post subject:
|
 |
|
Yeah, unless my math is wrong that's a 17+ gigabyte array, I think we can safely assume that's the issue, yeah. I'm not sure a single process can address that much memory on a 32 bit OS and ChucK won't run in 64 bit, so....
This is probably a good thing because that loop over all the array entries would take a while.
Do I dare ask what you need a array that size for? Couldn't it be simplified just a little bit?
It's certainly a novel way of crashing!
:¬) _________________ Modern technology offers an endless field day to any deviant strains in our personalities. --J.G.Ballard |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 531 Location: bangkok, thailand
Audio files: 2
|
Posted: Sun May 25, 2008 9:25 pm Post subject:
|
 |
|
I was just wondering what I can do with a 2D delay line..
but i guess i should work with a smaller array
and use some optimization methods.
i'll try more hehe. |
|
|
Back to top
|
|
 |
|