Search:

Type: Posts; User: myle

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Thread: Heapsort

    by myle
    Replies
    5
    Views
    2,700

    The best result till now is this:...

    The best result till now is this:
    http://en.wikibooks.org/wiki/Algorithm_implementation/Sorting/Heapsort

    Thanks for your replies though.
  2. Thread: Heapsort

    by myle
    Replies
    5
    Views
    2,700

    Heapsort

    Where can I found a good implementation of heapsort? (I don't care if it's C++ or C)
    Google didn't help me a lot. It would be ideal to find the implementation that is used by some efficient library,...
  3. Thread: Random number

    by myle
    Replies
    4
    Views
    2,149

    and keep in mind that the "random" numbers from...

    and keep in mind that the "random" numbers from the rand() follow a uniform distribution.
  4. Replies
    6
    Views
    1,581

    great tool.

    great tool.
  5. I would prefer: #include int...

    I would prefer:


    #include <stdlib.h>


    int main(int argc, char *argv[])
    {

    char *ptr;
  6. Replies
    5
    Views
    6,604

    I'll keep it in mind Elysia. Isn't there any...

    I'll keep it in mind Elysia.
    Isn't there any speed trade-off using these two statements instead of one?
  7. Replies
    5
    Views
    6,604

    Thanks Salem. Breaking it up into pieces helped...

    Thanks Salem. Breaking it up into pieces helped me to find the error.
    The fscanf() was reading the new line character and not the next line.
    The code which does the work is:


    fscanf(fp,...
  8. Replies
    5
    Views
    6,604

    Read from file a float

    The contents of the file are:

    dim 400
    epsilon 0.001
    ....

    the code is:


    // read the dimension of the table
  9. Replies
    1
    Views
    7,049

    valgrind error - still reachable

    I am not sure if this counts as an error in valgrind:


    Thread 3:
    ==16388== Invalid read of size 4
    ==16388== at 0x40151F3: (within /lib/ld-2.7.so)
    ==16388== by 0x4005C69: (within...
  10. Replies
    23
    Views
    29,641

    You can't use the & operator on doubles.

    You can't use the & operator on doubles.
  11. Replies
    23
    Views
    29,641

    An explanation here would be more useful than the...

    An explanation here would be more useful than the solution or at least a hint were I can find some more info. Furthemore, as it is, it doesn't compile on gcc.

    off topic:
    @cpjust: Doing something...
  12. Replies
    9
    Views
    7,435

    Problem solved. I have found the error. The...

    Problem solved.
    I have found the error. The swapping had been done fine. The problem was in the initialization of the two arrays. I wasn't careful with the values at the first and last row/column.
  13. Replies
    23
    Views
    29,641

    Indeed. You are right. Sometimes I am such an...

    Indeed. You are right. Sometimes I am such an idiot.
    My best try so far, still slower than the standard implementation:


    double inline absolute(double number)
    {
    //printf("&#37;f ", number);
    ...
  14. Replies
    23
    Views
    29,641

    Thanks! The solution is: double...

    Thanks!
    The solution is:


    double absolute(double number)
    {
    //printf("&#37;f ", number);
    unsigned long long* x = (unsigned long long*)&number;
    *x &= 0x7fffffffffffffff;
  15. Replies
    9
    Views
    7,435

    Each iteration alters the values of after and...

    Each iteration alters the values of after and only after, and then I calculate the maximum difference with the previous values. So, I don't care if it's not exactly the same (and it's not), I am...
  16. Replies
    9
    Views
    7,435

    What is the index error? Valgrind doesn't return...

    What is the index error?
    Valgrind doesn't return any warning for possible errors when I test my code.

    ...I print the results and are not the same. It's weird. I miss something.

    EDIT: You mean...
  17. Replies
    23
    Views
    29,641

    double absolute(double number) { printf("%f...

    double absolute(double number)
    {
    printf("%f ", number);
    unsigned long long* x = (unsigned long long*)&number;
    *x &= 0x7fffffff;

    number = *(double *)x;
    printf("%f \n",...
  18. Thread: New Memory

    by myle
    Replies
    16
    Views
    2,736

    If you don't have a license of a Windows 64bit...

    If you don't have a license of a Windows 64bit copy you can try for free a Linux distro.
  19. Replies
    23
    Views
    29,641

    So, the moral of this story is that there is no...

    So, the moral of this story is that there is no way to apply a mask on an double. Right?
    I tried to cast it and then use a mask but it doesn't work because some digits are truncated.
  20. Replies
    9
    Views
    7,435

    But as you can see, I don't use the elements of...

    But as you can see, I don't use the elements of the array after in the program. I merely write in the array after the results, so I don't care what were its previous values.
    What I am really...
  21. Replies
    6
    Views
    2,271

    Indeed. It seems like you are using one extra...

    Indeed. It seems like you are using one extra unnecessary loop.
  22. Replies
    9
    Views
    7,435

    for (k = 0; diff > epsilon && k

    for (k = 0; diff > epsilon && k <= 1000; k++)
    {
    diff = 0;
    // for each line in the array
    for (i = 1; i < n - 1; i++)
    {
    // for each column in the...
  23. Replies
    23
    Views
    29,641

    yes.

    yes.
  24. Thread: maths and c++

    by myle
    Replies
    11
    Views
    3,276

    If you don't like 19, you can try 31, 63 etc...

    If you don't like 19, you can try 31, 63 etc which are Mersenne Primes.
    ...To be on topic, programming needs maths if you want to understand some underlying concepts. But if you are not really...
  25. Replies
    23
    Views
    29,641

    Where can I find what exactly does? The best...

    Where can I find what exactly does?
    The best that I have found till now is:

    inline float
    fabs(float __x)
    { return __builtin_fabsf(__x); }

    inline long double
    fabs(long double __x)...
Results 1 to 25 of 52
Page 1 of 3 1 2 3