Boost logo

Ublas :

Subject: Re: [ublas] FW: Help with Matrix Inversion
From: Romin Puri (rpuri6_at_[hidden])
Date: 2010-09-01 16:25:12


Hi Marco,

Thank you. You are correct again. I will get back to you later today

Best regards

Romin

-----Original Message-----
From: ublas-bounces_at_[hidden] [mailto:ublas-bounces_at_[hidden]]
On Behalf Of Marco Guazzone
Sent: Wednesday, September 01, 2010 5:51 AM
To: ublas mailing list
Subject: Re: [ublas] FW: Help with Matrix Inversion

On Wed, Sep 1, 2010 at 8:13 AM, Romin Puri <rpuri6_at_[hidden]> wrote:
>
> Hi Marco,
>
> Actually you did find the problem. Please look at output files
> InvMatrix5 and InvMatrix5a. The input matrix is the same for both. The
> right answer is in InvMatrix5, whereas InvMatrix5a contains NANs.
>
> If you rearrange main  so that Matrix5 and Matrix5a are inverted  one
> after the other - the resulting output files will be the same.
>
>
> I had noticed that problem happens if a  matrix of size greater than
> 30 is inverted. The memory corruption is subtle.  So I  included a
> 963x963  matrix because after an attempt to invert this, the memory is
> completely hosed. I am glad to see that you reproduced it on Linux as
> well. So the issue is cross platform.
>
>
> Please let me know if you would like me to resend the source and data
> files directly to you. Thank you so much for your help
>

Hi Romin,

I forgot to tell you that in your file mtest.cpp I've commented the
following lines:

        Matrix Matrix5a(5,5),InvMatrix5a(5,5);
        k = T.readcsv("a5.txt",Matrix5a);
        k = T.MatrixInvert(Matrix5a,InvMatrix5a,"InvMatrix5a");

since the file "a5.txt" was inexistent.
Now, I rerun all the tests by replacing "a5.txt" with "csv5.txr" (see the
attachment).
As before, all tests worked fine and this time the output files "InvMatrix5"
and "InvMatrix5a" are completely identical (I send you in a private
message).

Can you check your code and check that all input files are existent?
Maybe, this may be your problem.

Anyway, the code for computing the inverse looks good.
Moreover, I rerun the test for a second time with "valgrind" (ver.
3.5.0) in order to check for memory leaks (note: since valgrind
significantly slowed the execution, I had to skip inversion of matrix
963x963 because with that inversion after 4 hours the program was still
running).
This is the output of valgrind:

==22825==
==22825== FILE DESCRIPTORS: 3 open at exit.
==22825== Open file descriptor 2: /home/marco/tmp/ublas/inv/out
==22825== <inherited from parent>
==22825==
==22825== Open file descriptor 1: /home/marco/tmp/ublas/inv/out
==22825== <inherited from parent>
==22825==
==22825== Open file descriptor 0: /dev/pts/5
==22825== <inherited from parent>
==22825==
==22825==
==22825== HEAP SUMMARY:
==22825== in use at exit: 0 bytes in 0 blocks
==22825== total heap usage: 17,208 allocs, 17,208 frees, 781,059
bytes allocated
==22825==
==22825== All heap blocks were freed -- no leaks are possible

So, I suspect it is either a your system problem (maybe you have not enough
free memory) or it can be an issue related to Visual Studio.
In this case I cannot help you, but if you have the possibility to run Linux
(maybe with a Live CD) I can send you the executable.
If you try with a Linux Live CD, please use a recent Linux for 64bit system
since the executable has been compiled with GCC 4.4.4 under Fedora 13
x86_64.

Cheers,

-- Marco

> Best regards
>
> Romin
> -----Original Message-----
> From: ublas-bounces_at_[hidden]
> [mailto:ublas-bounces_at_[hidden]]
> On Behalf Of Marco Guazzone
> Sent: Tuesday, August 31, 2010 1:27 PM
> To: ublas mailing list
> Subject: Re: [ublas] FW: Help with Matrix Inversion
>
> On Tue, Aug 31, 2010 at 8:41 PM, Romin Puri <rpuri6_at_[hidden]> wrote:
>>
>> Hi Marco,
>>
>> Could you please look at this
>
> Hi Romin,
>
> I've just tried with your files and "unfortunately" (for you) I didn't
> find any problem.
>
> I ran 3 tests:
>
> 1. Compiled with Boost dev version
> 2. Compiled with Boost 1.44 version
> 3. Compiled with Boost 1.43 version
>
> and all worked fine (I send you as a private message the output files).
> My testbed is:
> * OS: Linux Fedora 13 x86_64 with GCC 4.4.4
> * CPU: Intel Core 2 Duo T7500 (2.20GHz)
> * MEM: 2GB RAM
> Moreover I've compiled with the following flags:
>    -Wall -Wextra -g -O0 -ansi -pedantic just to make sure that the
> code is good enough for the "majority" of compilers.
>
> Each test took ~15 minutes at nearly 100% CPU, with a max RAM peak of
~36MB.
>
> So, I think your problem is a system (SW or HW) problem or maybe an
> old version of Boost.
>
>
>>
>> Thanks
>>
>> Romin
>>
>> -----Original Message-----
>> From: Romin Puri [mailto:rpuri6_at_[hidden]]
>> Sent: Monday, August 30, 2010 5:37 PM
>> To: 'ublas mailing list'
>> Subject: RE: [ublas] Help with Matrix Inversion
>>
>> Hi Marco,
>>
>> I think I have a serious memory corruption issue. Unfortunately I do
>> not have access to Purify or like otherwise I would have tracked it down.
>>
>> I am attaching test code for your preview along with data files
>>
>> 1. Each csv file is a hermitian matrix and is a subset of the next
>> larger one.
>> 2. I have included a 963x963 data file as the problem becomes more
>> pronounced after this inversion.
>>
>> Please let me know if you know any additional information. Your help
>> would be greatly appreciated. I am on boost release 1.43 and am still
>> using Visual Studio 2005 on Windows 7 32-bit ( We are a very poor
> startup).
>>
>> While it is very possible I am making a subtle mistake with my use of
>> boost, your inputs would be greatly appreciated.
>>
>>
>> Thank you very much for your help
>>
>> Best regards
>>
>> Romin
>>
>> -----Original Message-----
>> From: ublas-bounces_at_[hidden]
>> [mailto:ublas-bounces_at_[hidden]]
>> On Behalf Of Marco Guazzone
>> Sent: Friday, August 27, 2010 1:29 AM
>> To: ublas mailing list
>> Subject: Re: [ublas] Help with Matrix Inversion
>>
>> On Fri, Aug 27, 2010 at 4:32 AM, Romin Puri <rpuri6_at_[hidden]> wrote:
>>> I am using the code as outlined in this link
>>>
>>> http://savingyoutime.wordpress.com/2009/09/21/c-matrix-inversion-boo
>>> s
>>> t
>>> ublas/
>>>
>>> and trying out Hermition matricies of different sizes to get
>>> timings/memory requirements. The requirement is to solve a NxN where
>>> N =
>> 1000.
>>>
>>> While Matrix sizes upto N =30 work just fine, at N=50 I get this
>>> error. The data set is the same (truncated to ensure that Hermitian
>>> Matrix is of the desired size).
>>>
>>> Check failed in file c:\program
>>> files\boost\boost_1_43_0\boost\numeric\ublas\lu.hpp at line 294:
>>> detail::expression_type_check (prod
>>> (triangular_adaptor<const_matrix_type,
>>> upper> (m), e), cm2)
>>> internal logic "
>>>
>>> Any pointers would be most helpful.
>>>
>>
>> Hi,
>>
>> Don't know the cause of your problem, but if you submit a full
>> working
>> c++ test file I can give you a check.
>>
>
> Best,
>
> -- Marco