1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Computational physics

  1. May 18, 2006 #1
    Hey,

    In doing a circuit simulation i want to allocate a matrix like this (c++)

    double S1store[3][steps+1]

    i get no compiling errors, but if i make steps greater then 28000 the program gives me a windows error and crashes, it runs fine on a unix system. is there a limit to the amount of data you can allocate at one time? (i have 1GB RAM 3.2 Ghz processor) i dont think that would fill up. Or do you think the compiler doesn't complie correctly when your matrix is that large?

    thanks for any help, i would have put this is programming but i know theres better programmers in physics lol
     
  2. jcsd
  3. May 18, 2006 #2
    There is a limit, it should be either 32768 or 65536 , not 28000. But I'll assume you went from 28000 to 35000 or something, and that's when it crashed. Try changing the steps to be of type "unsigned long int" instead of type "int" that should give you some more room. Unsigned tells the computer not to allow the int to store negative numbers, doubling the number of positive numbers it can hold. Long int tells it to allocate more bits to storage increasing the number of ints it can hold (but sometimes exactly how much it increases depends on the compiler / operating system, which is probably why this is working on *nix and not windows)

    ~Lyuokdea
     
  4. May 18, 2006 #3
    ya thanks alot its a segmentation fault good idea about the unsigned i already have the long int, i also reduced the matrix to three single arrays

    SnstoX[steps], SnstoY[steps],SnstoZ[steps], now im maxing out at around 149896 = steps. I'm thinking that the program is trying to "point" to memory spots already taken up in the program, as in SnstoX[1] could have the same mem spot as SnstoX[120000] and the computer is obviously segfaulting...im 99.5% positive im not accessing memory not allocated in the arrays...as in im not accessing SnstoX[steps] literally but SnstoX[steps-1] which is suposed to be the max, ill try the unsigned thing thanks if you got any more ideas that'd be helpful
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?