electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
2D Array: value assignment problem
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Sun May 25, 2008 12:50 pm    Post subject: 2D Array: value assignment problem Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Sun May 25, 2008 1:04 pm    Post subject: Reply with quote  Mark this post and the followings unread

kijjaz, the correct syntax for a 2D array is:

Code:
a[10][10]


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!

_________________
For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6722
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun May 25, 2008 1:34 pm    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
kijjaz, the correct syntax for a 2D array is:

Code:
a[10][10]


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;

Code:
int foo[3, 4];


...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
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Sun May 25, 2008 2:58 pm    Post subject: Reply with quote  Mark this post and the followings unread

hahahhahahhaahahaha oohh yes it's just wrong syntax.
that killed ChucK so should report as bug. lol.

This is nice.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Sun May 25, 2008 3:01 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6722
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun May 25, 2008 3:24 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Sun May 25, 2008 9:25 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Top Selling Products! CLICK HERE!

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com