From: Jaison on 24 Jun 2010 12:55 My problem involves solving the matrix exponential for a VERY large sparse matrix. A colleague suggested that I try putting my matrices in the sparse format. As a test, I recorded the time it took for expm() to compute the matrix exponential for 20 randomly generated, 1000x1000 sparse matrices passed to expm() in both full and sparse formats. Surprisingly, I found that expm() ran slower when given a full matrix. On average, computing the matrix exponential took about 20 sec given a sparse matrix and about 0.9 sec given a full matrix. Does anyone know if expm() is optimized for matrices in the sparse format? Jaison
From: Bobby Cheng on 24 Jun 2010 14:30 The main work horse in expm are matrix multiply. So as long as you have a good matrix multiply, it is pretty optimized. In recent revision of MATLAB, expm has used a better algorithm to save the number of matrix multiply. The new implentation is in MATLAB language. So if you do >> edit expm You should see the implementation of expm. Having said that, the matrix exponential of a sparse matrix is usually fully. So you won't go very far unless your matrix has very special structure. In this case, you can probably do better by exploiting the structure of the matrix and you can use expm.m as a starting point. How are you going to use the result? There are research out there to do expm(A)*b without forming the matrix exponential. It is something that you may want to think about. Regards, ---Bob. "Jaison " <jaison.novick.ctr(a)nrl.navy.mil> wrote in message news:i002ln$aus$1(a)fred.mathworks.com... > My problem involves solving the matrix exponential for a VERY large sparse > matrix. A colleague suggested that I try putting my matrices in the > sparse format. As a test, I recorded the time it took for expm() to > compute the matrix exponential for 20 randomly generated, 1000x1000 sparse > matrices passed to expm() in both full and sparse formats. Surprisingly, > I found that expm() ran slower when given a full matrix. On average, > computing the matrix exponential took about 20 sec given a sparse matrix > and about 0.9 sec given a full matrix. > > Does anyone know if expm() is optimized for matrices in the sparse format? > > Jaison >
From: Jaison on 25 Jun 2010 12:59 Yeah, I read through Higham's paper on using pade approximations to compute the matrix exponential so I thought it would take less time to compute the matrix exponential given a matrix in the sparse format. I was trying to avoid having to dig through expm's m-file since this isn't exactly my area of expertise! The matrix I'm working with indeed has a special structure. I used forward differences to discretize a partial differential equation and if I had used central differences, my matrix would be pentadiagonal. The forward difference operation shifts two of the diagonals to the upper right so it does have a special structure which I may be able to exploit. Yeah, I've found a few other alternatives that I'm going to try out (like expokit) before I try modifying expm. Thanks for the feedback! Jaison "Bobby Cheng" <bcheng(a)mathworks.com> wrote in message <i0088b$j85$1(a)fred.mathworks.com>... > The main work horse in expm are matrix multiply. So as long as you have a > good matrix multiply, it is pretty optimized. > > In recent revision of MATLAB, expm has used a better algorithm to save the > number of matrix multiply. The new implentation is in MATLAB language. So if > you do > > >> edit expm > > You should see the implementation of expm. Having said that, the matrix > exponential of a sparse matrix is usually fully. So you won't go very far > unless your matrix has very special structure. In this case, you can > probably do better by exploiting the structure of the matrix and you can use > expm.m as a starting point. > > How are you going to use the result? > > There are research out there to do expm(A)*b without forming the matrix > exponential. It is something that you may want to think about. > > Regards, > ---Bob. > > "Jaison " <jaison.novick.ctr(a)nrl.navy.mil> wrote in message > news:i002ln$aus$1(a)fred.mathworks.com... > > My problem involves solving the matrix exponential for a VERY large sparse > > matrix. A colleague suggested that I try putting my matrices in the > > sparse format. As a test, I recorded the time it took for expm() to > > compute the matrix exponential for 20 randomly generated, 1000x1000 sparse > > matrices passed to expm() in both full and sparse formats. Surprisingly, > > I found that expm() ran slower when given a full matrix. On average, > > computing the matrix exponential took about 20 sec given a sparse matrix > > and about 0.9 sec given a full matrix. > > > > Does anyone know if expm() is optimized for matrices in the sparse format? > > > > Jaison > > >
From: Bobby Cheng on 25 Jun 2010 22:54 Forgot to mention this, there are less robust and often slower algorithms in expmdemo1.m and friends. ---Bob. "Jaison " <jaison.novick.ctr(a)nrl.navy.mil> wrote in message news:i02n8r$j5f$1(a)fred.mathworks.com... > Yeah, I read through Higham's paper on using pade approximations to > compute the matrix exponential so I thought it would take less time to > compute the matrix exponential given a matrix in the sparse format. I was > trying to avoid having to dig through expm's m-file since this isn't > exactly my area of expertise! > > The matrix I'm working with indeed has a special structure. I used > forward differences to discretize a partial differential equation and if I > had used central differences, my matrix would be pentadiagonal. The > forward difference operation shifts two of the diagonals to the upper > right so it does have a special structure which I may be able to exploit. > > Yeah, I've found a few other alternatives that I'm going to try out (like > expokit) before I try modifying expm. > > Thanks for the feedback! > > Jaison > "Bobby Cheng" <bcheng(a)mathworks.com> wrote in message > <i0088b$j85$1(a)fred.mathworks.com>... >> The main work horse in expm are matrix multiply. So as long as you have a >> good matrix multiply, it is pretty optimized. >> >> In recent revision of MATLAB, expm has used a better algorithm to save >> the number of matrix multiply. The new implentation is in MATLAB >> language. So if you do >> >> >> edit expm >> >> You should see the implementation of expm. Having said that, the matrix >> exponential of a sparse matrix is usually fully. So you won't go very far >> unless your matrix has very special structure. In this case, you can >> probably do better by exploiting the structure of the matrix and you can >> use expm.m as a starting point. >> >> How are you going to use the result? >> >> There are research out there to do expm(A)*b without forming the matrix >> exponential. It is something that you may want to think about. >> >> Regards, >> ---Bob. >> >> "Jaison " <jaison.novick.ctr(a)nrl.navy.mil> wrote in message >> news:i002ln$aus$1(a)fred.mathworks.com... >> > My problem involves solving the matrix exponential for a VERY large >> > sparse matrix. A colleague suggested that I try putting my matrices in >> > the sparse format. As a test, I recorded the time it took for expm() >> > to compute the matrix exponential for 20 randomly generated, 1000x1000 >> > sparse matrices passed to expm() in both full and sparse formats. >> > Surprisingly, I found that expm() ran slower when given a full matrix. >> > On average, computing the matrix exponential took about 20 sec given a >> > sparse matrix and about 0.9 sec given a full matrix. >> > >> > Does anyone know if expm() is optimized for matrices in the sparse >> > format? >> > >> > Jaison >> > >> >
|
Pages: 1 Prev: Undefined function or method Next: Invoking a pushbutton - without pushing it... |