luc comeau

Ranch Hand
+ Follow
since Jan 20, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by luc comeau

Ok so i have a situation where the array i need to create could be a maximum of 2^n size, but rarely does that happen. Usually it is around a third of that. So i guess my question is:Should i still just make an array of size 2^n, and intialize all elements(which i must do ) or should i just make it bigger each time i have to add something to it, since the number of elements rarely reaches the true size of it. i would have to do an array copy to copy the old array thus far into the new one, and i dont really know if i should do this or just make an array with an intial size of the mximum capacity at te beginning.

I know that your probably going to say use a vector, but my array is two dimensional, and the code im working with was someone elses which requires a 2d array and i dont want to go change all his work.
so based on that, which one is faster:intialze to max size...or to array copy and make a new one each time a new element is added?
14 years ago

Originally posted by Stefan Wagner:
The screensaver might be an issue, but are you sure it will have full use of cpu after toggling the screensaver off?
Sometimes systems are configured to run some tasks over night like indexing the filesystem for faster finding.

And might it be it is slowing down after a while?
Did you look at memory-consumption in the morning, especially usage of swap?



also the virus scan thing

These are good points i forgot to even think of.Yes the virus scan was runing at 3am , im guessing that would substantially slow things down.
As for the swapping, i didnt check that out. A process is running alot that notice called scan32.exe
no idea what that is, i can venture to guess, but im not really sure, its using 50-70% as we speak and has been for the better part of the morning, yet i see now alerts of any scanning going on.The only thing was windows update ran automatically today but thats over, so i dont know why that would still be it.
I figured there wouldnt be a whole lot of swapping going on since i gave the process high priorirty (windows) overnight, to eliminate that idea...well to some extent.
14 years ago
Hi guys im sorry f this is the wrong place to put this post but i couldnt find a better category then this.

I just had a question. I have a java program that takes sevral days to complete, due to the mass amount of data i have to generate with it. It seems that when i am at work running the program while doing other things on my pc, the program actually runs faster, then if i were to leave it overnight.

I figured it might slow down when my computer goes to screen saver, or when it finally goes to hibernate, so i shut both of those off and all the power saver options, and this didnt seem to help. Am i crazy for thinking it should run faster overnight when the java program has full use of the cpu? Is there anythig i can do to make it run faster at night when the pc isint being used at all?

-Luc
14 years ago
im thinking about doing somthing where, for each row, i look and see if there are any probs<0.5 if that number is less than 0.5 add it to an array for that row, if it is greater then 0.5, add the pos of the row to the array for the colum pos. At the end do a topological sort, check to see which array has no elements, then for that one go through the rest of the arrays and delete that one from the rest of them, loop through this until all are empty and i think i should come out with the correct ordering...hopefullly, asuming that my matrix is Asyclic directional not cyclic directional

Anyways im going to try my hand at programming this, ill keep a post of how its going maybe someone still has a better idea?
14 years ago
Hey people,

I am in a little situation here, and maybe its because im stressed but i cant think of a nice way to sort this 2d array i have.

Details: the 2d array is an array of probabilities between {0,1}.say i have the matrix,where the vertical axis is called y,horizontal called x.
\x
y| 0, 1, 1 , 1
0, 0, .8, 0.4
0, 0, 0 , 0.45
0, 0, 0 , 0
the probabilities are that yi is preffered over xj. example, the 0.8 is that
Prob(y1>x2)----prob that y1 preffered over x2 is 0.8.

now each row and column position corresponds to a unique offer thats why there are 0's in all positions where i=j.

So for this example there are 4 elements, i need to figure out the overall ordering of those elements based on these probabilities.I do a comparision where 0.5 is the cut off for saying something is preffered over the other.

So for this example obviusly we know that y0>x1, yo>x2, y0>x3 and y1>x2, y1!>x3...and so on.

I hope i haven't lost you yet, because my true question is i need an algorithm that, based on this array, will spit out the correct ordering at the end, based on all the conditions present in the matrix. Note that these matricies will be well formed so there will be no conflicts in the data.

The algorithm in this example should produce:0>3>1>2, based on the matrix values.
Im not sure whether to approach this with recursion and whther to sort inplace or what, its proving to be more difficult then i imagined. Please if you are at all confused, ask me questions its really not quite as difficult as i may have described it. bare bones its a sorting problem. Any help or tips on this would be great, thanks so much rancher's

Luc
14 years ago
so make the upper bound 3/4 of my RAM? Im going to assume yes, what about the lower bound?

I wish the damm thing didn't take so long to complete its iteration before it tells me it runs out of memory!I'm so strap for time i really can't afford to goof around with guessing how much memory to give the heap, but i guess its my only option. Hopefully it works, thanks for your reply Ernest
-Luc
14 years ago
yes i replyed on one of them, seems that they are somewhat different in what hes asking in each, although they should still probably be in the same post.
14 years ago
maybe something along the lines of :
tokenize the incomming path name from the consol by "\", then take each token and build a String , go through each token and add a period to the end of it(except for th last token).

I'm not exactly sure if you can use a string as the "binary name", but im surethis could be done with something along these lines, assuming you already know where to load this binary name from?
-Luc
14 years ago
Hey guys and girls. I recently had a post asking about a way to export data from a java program to an excel spreadsheet, which i successfully learned how to do. Now though i am running into a problem with a java out of memory exception when i go to finally write the excel file to the hard drive.

In the API for JXL which can be found here

keep in mind that you would need to download it to view it.

Anyways in this tutorial

the first question in the FAQ section talks about this problem with running out of memory when trying to generate large spreadsheets, which is the problem im having. I am trying to generate a spreadsheet with dimensions:
(row)(column): (10000)x(70)
the 10000 rows are double values.

I guess what i dont know about is how much memory to allocate to this process?
NOTE that i ran the process and it took two full days just to complete the 10000 iterations to get my data, and i got the exception when it tryed to write the excel file.

the FAQ gives an example, but i dont want to give it too much memory infear of it crashing my system midway through the tests or anything.So does anyone have any idea of how i could come up with th right amount of memory to allocate for this process.

I'll paste the faq since it isnt long:


i hope this is enough information, any tips or help from the experts would be awesome! thanks
14 years ago
do you know how much the array has to grow by? Should it be specified in a parameter to the grow method...eg: public void grow(int growByThisMany)
or maybe...public void grow(int newSize), where newSize must be >=the old array size.

Also do you just have to initialize the rest of the new "grown" array elements to anything?Like did the question specify? I am just curous about these things.

Also if your not allowed to use the arrayCopy() method, you can just loop though each element in the old array, and add each element of the old one into a new one with the new specified size.

Let me know if your confused
14 years ago
could just do the good old fashion for loop, look at each element in the array and compare it to the key you are trying to find in that array.quick example.
say arr is an array of many strings
say key is the string which you are trying to find
for(int i=0;i<arr.length;i++){
if(arr[i].equals(key))
System.out.println("Found "+key+ " at pos: "+i);
}

something along those lines
14 years ago
Stab, if that is your real name...One thing you must realize that this is a forum to guide people in the right direction, not do their homework assignments.If you are in a java class at school, try reading some of the notes, im sure your instructor didn't assign you to write a program unless they taught you how. But, one tip i can give is that in assignment questions they often describe what "instance variables" are needed in the description of the problem itself, and are usually the nouns.These instance variables usually have private acess within a class, and are used to describe "features" of that class.
Anyways here are some links that could help you get started, but other then that you can always seacrh on google, im sure there are 1000000's of begginners java tutorials!good luck!
If you have any specific question im sure myself or anyone else will try to answer it for you.
tutorial 1
Tutorial 2
[ February 07, 2006: Message edited by: luc comeau ]
14 years ago
Maybe she just wants the class to get used to the idea of using streams, since they are used for alot of things in java. I think maybe by beginner she just meant that its concealing the "tuff" part of doing I/O. Just my opinion
-Luc
14 years ago
surprised stan didn't bust down on your fun name, never heard of anyone named "Fishy" before, although gwen paltro named her kid "Apple" and Frank zappa named his kid "Moon Unit"..so i guess nothing would surpirse me nowadays.
14 years ago
i agree that one of the offers[i] must be null, i just did a test to check out when u get a null pointer: either null.equals(string) or string.equals(null), and i got the null pointer at the prior, thus is must be a null offer.which i find extremly hard to believe.This is where i generate the offers array.



Ok so i see now thats where i could be getting the problem, god i hope its that simple, but ill never know unless i run another 6 hour test and it actually completes

It helps to put your thoughts out, i guess i'll try running another test, and see if that fixes the problem.Thanks for the tips though guys!

-Luc
14 years ago