From: Deb Gruner on
thank you everyone for trying to help me
to answer the last person's question
i'm converting the code to c++
and so far its alot easier for me to do using gauss jordan elimination as oposed to lu decomposition although neither are imposibble
i do know that the time difference for computation is from n^2 to n^3 difference between the two but im fine with that if the numbers still show the same

and then i started wondering how close either are to the numbers produced by matlab since i dont even know which method matlab is using to implement its inv function
From: Walter Roberson on
Deb Gruner wrote:
> thank you everyone for trying to help me to answer the last person's
> question i'm converting the code to c++
> and so far its alot easier for me to do using gauss jordan elimination
> as oposed to lu decomposition although neither are imposibble i do know
> that the time difference for computation is from n^2 to n^3 difference
> between the two but im fine with that if the numbers still show the same
> and then i started wondering how close either are to the numbers
> produced by matlab since i dont even know which method matlab is using
> to implement its inv function

As I quoted before from the inv reference page, it uses the LAPACK routines

DLANGE, DGETRF, DGECON, DGETRI

A moment's googling finds:

http://www.math.utah.edu/software/lapack/lapack-d/dgetri.html
NAME
DGETRI - compute the inverse of a matrix using the LU fac-
torization computed by DGETRF


If you are converting the code to C++ then you can make calls to LAPACK
yourself -- it is a standard library readily available.
From: Steve Amphlett on
Walter Roberson <roberson(a)hushmail.com> wrote in message <n6t3o.30544$xZ2.5377(a)newsfe07.iad>...
> Deb Gruner wrote:
> > thank you everyone for trying to help me to answer the last person's
> > question i'm converting the code to c++
> > and so far its alot easier for me to do using gauss jordan elimination
> > as oposed to lu decomposition although neither are imposibble i do know
> > that the time difference for computation is from n^2 to n^3 difference
> > between the two but im fine with that if the numbers still show the same
> > and then i started wondering how close either are to the numbers
> > produced by matlab since i dont even know which method matlab is using
> > to implement its inv function
>
> As I quoted before from the inv reference page, it uses the LAPACK routines
>
> DLANGE, DGETRF, DGECON, DGETRI
>
> A moment's googling finds:
>
> http://www.math.utah.edu/software/lapack/lapack-d/dgetri.html
> NAME
> DGETRI - compute the inverse of a matrix using the LU fac-
> torization computed by DGETRF
>
>
> If you are converting the code to C++ then you can make calls to LAPACK
> yourself -- it is a standard library readily available.

I did precisely this myself (Matlab -> C++) quite recently, using ZGETRF and ZGETRI (my Matrices are complex). You'll need to copy your data out of your C++ Matrix class into regular FORTRAN-style arrays before calling the LAPACK functions and then back into your C++ class(es) after. But the speedup is well worthwhile. My Matrix inversion went from a crippling bottle-neck to mere noise once I'd done this.
From: John D'Errico on
"Deb Gruner " <gsarah10(a)aol.com> wrote in message <i2ll8t$6l7$1(a)fred.mathworks.com>...
> thank you everyone for trying to help me
> to answer the last person's question
> i'm converting the code to c++
> and so far its alot easier for me to do using gauss jordan elimination as oposed to lu decomposition although neither are imposibble
> i do know that the time difference for computation is from n^2 to n^3 difference between the two but im fine with that if the numbers still show the same
>

No, you DON'T Know that one of these is an n^2
operation, because that simply is not true.

John
From: Penny Anderson on
"Steve Amphlett" <Firstname.Lastname(a)Where-I-Work.com> wrote in message <i2lqc1$6kf$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <n6t3o.30544$xZ2.5377(a)newsfe07.iad>...
> > Deb Gruner wrote:
> > > thank you everyone for trying to help me to answer the last person's
> > > question i'm converting the code to c++
> > > and so far its alot easier for me to do using gauss jordan elimination
> > > as oposed to lu decomposition although neither are imposibble i do know
> > > that the time difference for computation is from n^2 to n^3 difference
> > > between the two but im fine with that if the numbers still show the same
> > > and then i started wondering how close either are to the numbers
> > > produced by matlab since i dont even know which method matlab is using
> > > to implement its inv function
> >
> > As I quoted before from the inv reference page, it uses the LAPACK routines
> >
> > DLANGE, DGETRF, DGECON, DGETRI
> >
> > A moment's googling finds:
> >
> > http://www.math.utah.edu/software/lapack/lapack-d/dgetri.html
> > NAME
> > DGETRI - compute the inverse of a matrix using the LU fac-
> > torization computed by DGETRF
> >
> >
> > If you are converting the code to C++ then you can make calls to LAPACK
> > yourself -- it is a standard library readily available.
>
> I did precisely this myself (Matlab -> C++) quite recently, using ZGETRF and ZGETRI (my Matrices are complex). You'll need to copy your data out of your C++ Matrix class into regular FORTRAN-style arrays before calling the LAPACK functions and then back into your C++ class(es) after. But the speedup is well worthwhile. My Matrix inversion went from a crippling bottle-neck to mere noise once I'd done this.

Really? Translating your MATLAB code into C++ (calls into LAPACK) made the inv function go much faster? I find this hard to believe. In general those O(n^3) linear algebra routines perform pretty well in MATLAB. It's usually the other parts of the code around it that may be improved by a translation to C/C++.

Penny Anderson
MATLAB Math
MathWorks
First  |  Prev  | 
Pages: 1 2
Prev: Matlab GUI help
Next: file names