LU decomposition: how can I get a unique solution?

View: New views
3 Messages — Rating Filter:   Alert me  

LU decomposition: how can I get a unique solution?

by Pietro.Mele :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a problem finding the LU decomposition of a matrix. I want to impose the L diagonal elements to be equal to 1. I included the code, and this is the (wrong?) result:

Initial matrix:
4 3
6 3

*** Expected result (found with pen and paper): ***

L matrix:
1    0
1.5  1

U matrix:
4   3
0  -1.5

Inverse matrix:
 -0.5  0.5
  1   -2/3

*** Matrices returned by ublas/lu.hpp: ***

lu_factorize A:
4   3/4
6   -3/2

L matrix:
1  0
6  1

U matrix:
4   3/4
0  -3/2

Inverse matrix:
 -0.5  0.5
  1   -2/3

So the inverse matrices are the same, but the L and U matrices used to find them are different (I got them from the lu factorized initial matrix). Who's right? Ublas or my pen?

With "ublas/lu.hpp" how can I specify the values of the diagonal elements needed to obtain a unique solution (i.e. unique L and U matrices)?

Thank you for any help.

Pietro


Boost 1.40.0
O.S.:  Linux (RedHat)
gcc:  3.4.6
kernel:  2.6.9-55.ELsmp

Tags: ublas, lu.hpp, lu decomposition, boost, matrix




Pietro Mele
CFD Software Developer
T. +44 1235 777700
F. +44 1235 764705
attwilliams.com
____________________

Williams Grand Prix Engineering Limited. Registered in England no. 1297497. VAT no. GB292559325. This email is confidential. If you are not the addressee, please contact us by reply.



_______________________________________________
ublas mailing list
ublas@...
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: lists@...

LUquestion.cpp (1K) Download Attachment

Re: LU decomposition: how can I get a unique solution?

by Paul C. Leopardi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Pietro,
If you multiply the L and U matrices obtained from ublas/lu.hpp, do you get
your original matrix? Octave gives me

octave:9> [1 0;6 1]*[4 3/4.0;0 -3/2.0]
ans =

    4.00000    0.75000
   24.00000    3.00000

octave:11> [1 0;1.5 1]*[4 3;0 -1.5]
ans =

   4   3
   6   3

Best, Paul
_______________________________________________
ublas mailing list
ublas@...
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: lists@...

Re: LU decomposition: how can I get a unique solution?

by Alfredo Correa-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Pietro,

this is because LU decomposition is not unique. ublas (or blas) makes
it unique by imposing that the diagonal or L are ones. You can do the
same in your manual calculation to make sure.


On Thu, Oct 15, 2009 at 4:38 AM,  <Pietro.Mele@...> wrote:

> I have a problem finding the LU decomposition of a matrix. I want to impose
> the L diagonal elements to be equal to 1. I included the code, and this is
> the (wrong?) result:
>
> Initial matrix:
> 4 3
> 6 3
>
> *** Expected result (found with pen and paper): ***
>
> L matrix:
> 1    0
> 1.5  1
>
> U matrix:
> 4   3
> 0  -1.5
>
> Inverse matrix:
>  -0.5  0.5
>   1   -2/3
>
> *** Matrices returned by ublas/lu.hpp: ***
>
> lu_factorize A:
> 4   3/4
> 6   -3/2
>
> L matrix:
> 1  0
> 6  1
>
> U matrix:
> 4   3/4
> 0  -3/2
>
> Inverse matrix:
>  -0.5  0.5
>   1   -2/3
>
> So the inverse matrices are the same, but the L and U matrices used to find
> them are different (I got them from the lu factorized initial matrix). Who's
> right? Ublas or my pen?
>
> With "ublas/lu.hpp" how can I specify the values of the diagonal elements
> needed to obtain a unique solution (i.e. unique L and U matrices)?
>
> Thank you for any help.
>
> Pietro
>
>
> Boost 1.40.0
> O.S.:  Linux (RedHat)
> gcc:  3.4.6
> kernel:  2.6.9-55.ELsmp
>
> Tags: ublas, lu.hpp, lu decomposition, boost, matrix
>
>
>
>
> Pietro Mele
> CFD Software Developer
> T. +44 1235 777700
> F. +44 1235 764705
> attwilliams.com
> ____________________
>
> Williams Grand Prix Engineering Limited. Registered in England no. 1297497.
> VAT no. GB292559325. This email is confidential. If you are not the
> addressee, please contact us by reply.
>
>
> _______________________________________________
> ublas mailing list
> ublas@...
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: correaa@...
>
_______________________________________________
ublas mailing list
ublas@...
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: lists@...