Results 1 to 7 of 7

Thread: Stupid bugs and strange code

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Delphius's Avatar
    Join Date
    Jul 2013
    Location
    Salta, Argentina
    Posts
    9
    So far I think the most stupid mistake I made was to confuse the iteration of a matrix row by row with as column by column.

    Was a few months. It had to implement the Jacobi algorithm to compute eigenvalues ​​and eigenvectors of symmetric matrices.
    To verify that the calculations were done correctly I assessed that satisfy A * V = Lambda * V and V is orthonormal.

    I Had two algorithms: one as a control and the other with some improvements but in essence were almost identical. For some reason the control worked perfectly, but the other told me that no tests passed and the results differed in some decimals.

    I examined the code of Jacobi line by line looking for the culprit and everything was in order . I had even come to think that I was altering some compiler directive or changed the data type ... And nothing ... everything was OK.


    I was two weeks sitting in front of the monitor ... The error was that when submitting data did eigenvectors of rows and columns as it should not. All for a variable and a cycle.
    Since then I have stuck a post-it on my monitor that reminds me not confuse rows and columns.

    Regards,
    P.S: Sorry for my poor English.

  2. #2
    Not pascal related but anyway just few days ago when working on my script compiler in C++ i had to write some stuff into compiled script. When i solve programming problems i often make small test apps and test the piece of code before copying to big project.

    The test app wrote the data to file without problems, just the way i needed.
    Then i just copy/pasted the code to my compiler source, which already has tons of .h / .cpp files and hundreds / thousands of lines, it just wrote the data partially, only first 2 bytes. The total was around 6000 bytes.

    I tested many times this in my test app, with minimal code, looked what im doing etc, everything was correct. It was just very very weird. I couldnt understand how that can be. Just copy paste, small piece of code. Works in test app, but in compiler just 2 bytes.
    This piece of code was almost at the end of main.cpp where all the writing is done.

    And then i accidentally scrolled down near to the end of main.cpp and found that i had a piece of code in there (just a for loop) that filled all these 6000 bytes with 0. Except the 2 bytes, that was "header".

    Removed that and all started to work. Because my old laptop screen is pretty small and i work with 1024x768, i dont see all of the code, i have to scroll a lot. Same with my PC monitor, very old and small.

    So this code was outside of the view and did his job, directly i wrote the filled structs to file, it just replaced all data in them with 0.

    Im planning to buy some 21" LCD, i never had such one but i would like to have it.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •