Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
poopiehead
Oct 6, 2004

Since you've already done some C, I'll recommend The C Programming Language. A lot of it will just be review, but it makes some things you might have a foggy understanding more precise and it's actually incredibly concise and accessible.

Depending on where you're going with CS, Mythical Man Month, Extreme Programming Explained, and Pragmatic Programmer are pretty great reads more focused on programming as a profession/art than CS theory. Probably want to wait a year or two for these or at least re-read in a few years though, not because they're hard(they're not), but because more experience puts them into context.

Adbot
ADBOT LOVES YOU

poopiehead
Oct 6, 2004

hey wiz posted:

If he used an on change event, why not deselect all other check boxes before selecting the current one?

Along the same lines.... Why a checkbox and not a radio box?

no need to write code to enforce rules that the browser will enforce for free

poopiehead
Oct 6, 2004

Just pull in the profile page and search for the string in what you get back. Haven't done php in a long time but I think you can use fopen. The url to use is like

http://forums.somethingawful.com/member.php?action=getinfo&username=poopiehead

poopiehead
Oct 6, 2004

clay posted:

I'm loading the netflix dataset to memory. Right now I have it load the entire dataset into memory each pass which is pretty silly and takes about 4 minutes. I want to mmap it all once so I can just load the mmaped file.

Are you trying to load multiple times in the same process or running multiple processes. If it's the former, just allocate the array as an int** and pass it around.

code:
int **ary = malloc(sizeof(int*)*1000); 
for (i; i < 1000; ++i) { 
  // this seems weird, does this array hold the size that you need to allocate 
  // or the numder of ints?
  ary[i] = malloc(other_ary[i]); 
}
If it's the latter, you probably should wait for someone that knows C much better than me to answer, but this would be how I'd try to get it into a bunch of memory. You need a block of memory big enough to hold the array of int* and the data that they point to. So find out how big it needs to be, allocate the space and build up your int*[]. I suspect this depends on assumptions that I'm not allowed to make though. Memory alignment probably gets in the way.....

code:
int size = sizeof(int*)*1000; 
for (i; i < 1000; ++i) { 
  size += other_ary[i];
}

int **ary = malloc(size); // or mmap equivalent
int * data = (int*)(ary + 1000);
for (i; i < 1000; ++i) { 
  ary[i] = data;
  data += other_ar[i];
}
edit: this is why I shouldn't attempt to answer C questions. fixed a bug in the second code block.

poopiehead fucked around with this message at 12:21 on May 5, 2008

poopiehead
Oct 6, 2004

heres a really lovely way that would probably work. But I know for sure there's a much easier way to do it, Just don't know linux well enough. the syntax is close but definitely wrong, but until someone answers for real, that should work

code:
for i in 1 to 100000
  if [ -f input.000$i] 
  then
    ./program < input.000$i > output.000$i
  fi
  if [ -f input.00$i] 
  then
    ./program < input.00$i > output.00$i
  fi
  if [ -f input.0$i] 
  then
    ./program < input.0$i > output.0$i
  fi
  if [ -f input.$i] 
  then
    ./program < input.$i > output.$i
  fi
next
another option would be to iterate all the files that ls returns. again pseudo shell.

code:
for f in `ls input.*`
  output=`echo $f | sed -e "s/input/output/g"`
  ./program <$f >$output 
next

poopiehead fucked around with this message at 02:02 on May 13, 2008

poopiehead
Oct 6, 2004

I wrote a quick version in C# and I get 12s,1s,0.5s for the three different algorithms(I forget the number of iterations), so your algorithms are correct.

Your problem may be that you're just doing a lot of work in each iteration of your loop. If you loop through half as many times but do twice as much work then you don't get a speedup. You should try to avoid recomputing values that won't change like sqrt(inp) and count*6 every time through the loop. Also your third case in the inner loop causes an extra count*6 and an extra comparison. Last, you should minimize IO while doing a timing test because it can mess with the results.

poopiehead
Oct 6, 2004

How can you make a program that runs in eclipse but doesn't run on the command line? Or do you just mean that you, personally, had to know how to build and run it?

Adbot
ADBOT LOVES YOU

poopiehead
Oct 6, 2004

edit: I meant to post this in the Java thread...

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply