| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
i am writing code which is already written in MATLAB in my code,,,, goal is to reduce the execution time ,,,,, In code there is a routine generating normal random numbers,,, which involve sqrt, log, sin, cos of floating pt. number,,,, which is taking large time ,,,,,, the same routine in MATLAB taking time 0.68 sec but my C program taking 3.45 sec ,,,,,
plz help me ,,,, by sugesting how can i resolve this problem.... there r 2 ideas in my mind 1. replace that peace code in assembly 2. do operations in binary mode but i don't know how i can do this,,,,,, plz help me ,,,, or suggest me any other idea,,,,,,,,,,,, thanks,, raghav |
|
#2
|
|||
|
|||
|
I'm not sure I understood your question, but basically what you do is you input a number then apply many mathematical operations to it to generate a random number?
In C++, there is a function in the library that does that for you. It is called rand(), and you can modify it to generate a different set of numbers at every execution of the program by using srand(). |
|
#3
|
|||
|
|||
|
raghvendrac,
Cannot optimize your code if you do not post it! It shouldnt be necessary to put assembly into your code... I'm not sure why your code is running so slowly, but if you did it properly, it should definitely be running faster than the matlab code. If you want some suggestions right now, you can make luts for sin, cosine and sqrt. Post the recursive function for your pseudo-random number generator, and your code so we can help you more. Also, I'm guessing you are trying to write your own pseudo-random number generator because you need some specific properties that rand() will not give you (as ahammad suggested). EZ-E |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Plz help me to make C code efficient |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|