Solving linear equations with large times

I am new to using matlab. I have a simple linear equation of Ax=B in loops;
where A is a complex matrix (1000x1000), and A will be changed with the parameters f, delta_p and delta_dopp in my code, i.e. A=A(f, delta_p, delta_dopp); B is a simple invariant column matrix (1000x1).
Cause I need to solve the linear equation almost about ~10^6 times. And matirx A is changing inside the loops (f, delta_p, delta_dopp are cycle indicators). When I using x=A\B solving the eqution, it should take me a lot of time. For example, it takes me one hour running 5e4 times.
I hope that someone can suggest a faster and better method? (Especially for the x=A\B method).
This is distribution of matrix A:
Thanks a lot!

6 comentarios

KSSV
KSSV el 18 de Feb. de 2022
Have you checked the time taken by one step?
剑豪 戴
剑豪 戴 el 18 de Feb. de 2022
Editada: 剑豪 戴 el 18 de Feb. de 2022
It takes about 0.063 seconds in one step. I also need time to build the matrix A. x=A\B takes 0.03 seconds. And in my one hour example, the x=A\B should take 50 minutes (use profile getting)
KSSV
KSSV el 18 de Feb. de 2022
If you have GPU, you may try running on that. Read about gpuArray.
剑豪 戴
剑豪 戴 el 18 de Feb. de 2022
Editada: 剑豪 戴 el 18 de Feb. de 2022
ok, thanks! But I still have a question, I have tried gpu before. I need to use besselj function to build my matrix A. Can it work right if I use gpu? (for the besselj()).
Oh, I should see the MATLAB Functions with gpuArray Arguments. Or I should make a bessel function by myself
KSSV
KSSV el 18 de Feb. de 2022
剑豪 戴
剑豪 戴 el 18 de Feb. de 2022
Thanks a lot!

Iniciar sesión para comentar.

 Respuesta aceptada

Hiro Yoshino
Hiro Yoshino el 18 de Feb. de 2022

0 votos

It seems that your matrix is sparse - it would be worth while using some techniques for sparse matrix operetions where you can find methods for linear problems.

4 comentarios

剑豪 戴
剑豪 戴 el 18 de Feb. de 2022
Thanks!I will try it
剑豪 戴
剑豪 戴 el 19 de Feb. de 2022
When I use the sparse matrix, the time was shortened from one hour to 15 minutes. It' s very helpful. But there is another question. Through the Profiler, I found an assignment statement taking much time. It is in my getting matrix A function.
such like,
A(1:21, 1:21)=C(1:21,1:21)
Hopefully!
put in one lines before A = C as follows:
A = zeros(size(C));
剑豪 戴
剑豪 戴 el 20 de Feb. de 2022
Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear Algebra en Centro de ayuda y File Exchange.

Preguntada:

el 18 de Feb. de 2022

Comentada:

el 20 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by