in reply to Code fails without any reason?

I'm assuming you mean this line:
{ print "$i $c_IN $in_i\n"; # <----- $x[$i] = $actafer[$in_i][$i];
I have no idea. Try reducing the amount of pre-initialization you do.

Of course, that might require that you re-examine the algorithm and attempt to write it in Perl, not C-Perl. You're not taking advantage of Perl's capabilities, so it's going to waste (more) memory.

However, unless you're working with a small box, you shouldn't run out of memory without some loops and push or unshift or splice to make your arrays big. *shrugs*

In case you're wondering why this answer isn't that helpful ... I'm not going to parse and learn your code without you paying me. I'll help you after you explain what's going on. "Help!" doesn't cut it.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Code fails without any reason?
by Bluepixel (Beadle) on May 01, 2003 at 14:57 UTC
    for($i=0;$i<$c_IN;$i++) { print "$i $c_IN $in_i\n"; $x[$i] = $actafer[$in_i][$i]; if (not defined $x[$i]){die;} }
    The $i's are counter up to 34, as they should, then $i is reset to 0 (in the same loop) which causes $x[$i] = $actafer[$in_i][$i]; to fail. Output is:
    ........ 28 35 9 29 35 9 30 35 9 31 35 9 32 35 9 33 35 9 34 35 9 0 35 ARRAY(0xa04116c) Out of memory during "large" request for 1073745920 bytes, total sbrk( +) is 31744 0 bytes at neuronalnetwork.pl line 137.
    I was wondering why $i is reset to 0?
      Your problem may be related to $i being set to 0, but the actual issue is that $in_i is being assigned to an array reference. That is what's causing the memory issue.

      Check to see what you're doing in the error() function. :-)

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.