Linear System Speed Up Ax=b

조회 수: 3 (최근 30일)
Taehun Kim
Taehun Kim 2021년 2월 7일
댓글: Taehun Kim 2021년 2월 10일
Dear All,
I have a linear solve embedded in the right hand side function of a large system of ODEs that I am trying to solve using ode45 or ode15s.
I see that the profiling result on my code indicates that most of my time is spent evaluating the linear solves...
I have a right hand side matrix b continuously changing at each time point. There are three types of linear solves that I am calling: (1) a constant tri-diagonal matrix of dimension nxn where n is around 1000, (2) an upper triangular matrix with the diagonal and a line above the diagonal filled with numbers but all others are zero, (3) a lower triangular matrix with the diagonal and a line below the diagonal filled with numbers buit all others are zero.
in each case, I am specifying an option to indicate if matrix is either upper or lower triangular matrix. Then, I am using linsolve... but the code is slow... Do you think there is a practical way to speed up the linear solve evaluation in the code? the coefficient matrices are so sparse in this case and I think that there may be ways that we can exploit this... But not sure what exactly to do...
Thank you so much! :)
  댓글 수: 2
Taehun Kim
Taehun Kim 2021년 2월 7일
Can I possibly write my own solver specific for the cases that I have?
Taehun Kim
Taehun Kim 2021년 2월 7일
Or any MATLAB built-in functions are available?

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2021년 2월 8일
the coefficient matrices are so sparse in this case and I think that there may be ways that we can exploit this
If those matrices are being held in sparse data form, then the sparsity should be exploited alread
  댓글 수: 1
Taehun Kim
Taehun Kim 2021년 2월 10일
Thanks for the comment Matt!
I am currently using linsolve and passing in an option saying my matrix is either an upper or a lower triangular matrix. It is however the case that we are unable to use sparse pattern matrix with linsolve...
So, I have switched back to the backslash solve and have profiled the code once again. For the linsolve with options for matrix pattern enabled, the code spent around 70 seconds solving the system of linear equations. In contrast, the backslash with sparse data spent only around 21 seconds solving the same system!
Thank you for your help in this matter! Saving as a sparse data indeed helped a lot! :)
Sincerely,
Taehun Kim

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by