Debugging QuantLib::Matrix with msvc

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging QuantLib::Matrix with msvc

Kim Kuen Tang
Hi all,

debugging QuantLib::Matrix with msvc is not possible. The debugger just
shows the raw pointer to that matrix.
And you can get around this limitation by modifying the autoexp.dat file
which can be found in

    %VSINSTALLDIR%\Common7\Packages\Debugger\autoexp.dat.
You just need to add these lines


;------------------------------------------------------------------------------
;  QuantLib::Matrix
;------------------------------------------------------------------------------
QuantLib::Matrix{

   children

   (

      #(

         [Matrix]: [$c.data_,!],

         rows: $c.rows_,

         cols: $c.columns_,

         #array(

            expr: ($c.data_.px)[$i],

            size: ((unsigned int*)(&($c.rows_)))[$r],

            rank: 2

         )

      )

   )



   preview

   (

      #(

         "[",

         $c.rows_ ,

         ",",

         $c.columns_,

         "](",



         #array

         (

            expr : [($c.data_.px)[$i],g],

            size : $c.rows_ * $c.columns_

         ) ,

         ")"

      )

   )

}

to get the values inside of the arrays.

Back up autoesp.dat before proceeding.
Best regards,
Kim Tang



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Debugging QuantLib::Matrix with msvc

Luigi Ballabio
On Sun, 2009-08-16 at 22:47 +0200, Kim Kuen Tang wrote:
> debugging QuantLib::Matrix with msvc is not possible. The debugger just
> shows the raw pointer to that matrix.
> And you can get around this limitation by modifying the autoexp.dat file

Kim,
        it seems that the indices are flipped when the values are displayed:
see the attached screenshot, where I just set M[0][0], M[0][1] and
M[0][2] and the debugger displays the values for M[0][0], M[1][0] and
M[2][0].

Luigi




--

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.
-- Brian W. Kernighan


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

debug.png (33K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Debugging QuantLib::Matrix with msvc

Kim Kuen Tang
Hi Luigi,

sorry for the delay. I was on vacancy.

Luigi Ballabio schrieb:

> On Sun, 2009-08-16 at 22:47 +0200, Kim Kuen Tang wrote:
>  
>> debugging QuantLib::Matrix with msvc is not possible. The debugger just
>> shows the raw pointer to that matrix.
>> And you can get around this limitation by modifying the autoexp.dat file
>>    
>
> Kim,
> it seems that the indices are flipped when the values are displayed:
>  
Yes, this is true. The problem is somewhat related in the way how the
debugger works in visual studio.
In MSVC the first entry in a matrix represents the columns, whereas in
QuantLib it represents the rows. This is the reason why the values are
flipped.

Best reagrds,
Kim

> see the attached screenshot, where I just set M[0][0], M[0][1] and
> M[0][2] and the debugger displays the values for M[0][0], M[1][0] and
> M[2][0].
>
> Luigi
>
>
>
>
>  
>
> ------------------------------------------------------------------------
>
>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Debugging QuantLib::Matrix with msvc

Kim Kuen Tang
Hi all,

the bug is fixed by doing some division and modulus on the index.
Here is the code:

;------------------------------------------------------------------------------
;  QuantLib::Matrix
;------------------------------------------------------------------------------
QuantLib::Matrix{
   children
   (
      #(
         [shared_ptr]: [$c.data_,!],
         rows: $c.rows_,
         columns: $c.columns_,
         #array(
            rank: 2,
            base: 0,
            expr: ($c.data_.px)[($i % $c.rows_)*$c.columns_+ (($i- $i %
$c.rows_)/$c.rows_) ],
            size: ($r==1)*$c.rows_+($r==0)*$c.columns_
         )
      )
   )

   preview
   (
      #(
         "[",
         $c.rows_ ,
         ",",
         $c.columns_,
         "](",

         #array
         (
            expr : [($c.data_.px)[$i],g],
            size : $c.rows_ * $c.columns_
         ) ,
         ")"
      )
   )
}

Best regards,
Kim

Kim Kuen Tang schrieb:

> Hi Luigi,
>
> sorry for the delay. I was on vacancy.
>
> Luigi Ballabio schrieb:
>  
>> On Sun, 2009-08-16 at 22:47 +0200, Kim Kuen Tang wrote:
>>  
>>    
>>> debugging QuantLib::Matrix with msvc is not possible. The debugger just
>>> shows the raw pointer to that matrix.
>>> And you can get around this limitation by modifying the autoexp.dat file
>>>    
>>>      
>> Kim,
>> it seems that the indices are flipped when the values are displayed:
>>  
>>    
> Yes, this is true. The problem is somewhat related in the way how the
> debugger works in visual studio.
> In MSVC the first entry in a matrix represents the columns, whereas in
> QuantLib it represents the rows. This is the reason why the values are
> flipped.
>
> Best reagrds,
> Kim
>  
>> see the attached screenshot, where I just set M[0][0], M[0][1] and
>> M[0][2] and the debugger displays the values for M[0][0], M[1][0] and
>> M[2][0].
>>
>> Luigi
>>
>>
>>
>>
>>  
>>
>> ------------------------------------------------------------------------
>>
>>
>>    
>
>
>
>  


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users