Symetric matrix power optimization

Hello,
I would like to calculate A^p where A is a symetric matrix. I know that I can use A^p but i would like to know is there is way to calculate only (n²+n)/2 coefficients and just paste the (n²-n)/2 last that are equals ? Or simply do this optimization for A*B where A and B are both symetrics ?
Thank you :)

4 comentarios

Bruno Luong
Bruno Luong el 29 de Abr. de 2021
What typical values of n and p ?
Damien GUILLOTIN
Damien GUILLOTIN el 29 de Abr. de 2021
From 1 to 1000 ^^'
Bruno Luong
Bruno Luong el 30 de Abr. de 2021
Editada: Bruno Luong el 30 de Abr. de 2021
"Or simply do this optimization for A*B where A and B are both symetrics ?"
How? For generic A and B symmetric the product is NOT symmetric. If you decide to access only the upper parts of A and B, you make memory access pattern more complex and inefficient for caching.
Damien GUILLOTIN
Damien GUILLOTIN el 30 de Abr. de 2021
Exact hehe ! When the words go faster than your maths... it happens ^^

Iniciar sesión para comentar.

 Respuesta aceptada

Bruno Luong
Bruno Luong el 30 de Abr. de 2021
Editada: Bruno Luong el 30 de Abr. de 2021
Youeu can edit MATLAB function mpower.m and try to the basic calculation (line 76 in my case)
D = D*D; % I assume p is integer in your case
With multiplicationfor triu elements then reflect.
However I would doubt you could beat MATLAB generic matrix product.

Más respuestas (1)

Jan
Jan el 29 de Abr. de 2021

0 votos

Are you using this already:
Do you have a C compiler such that you can try to modify the above solutions and call LAPACK:DSYMM instead of DGEMM?

2 comentarios

Damien GUILLOTIN
Damien GUILLOTIN el 29 de Abr. de 2021
First, thank you for your answer !
Then, the function you are proposing are still calculating all the terms (faster than the basic operation for sure) but I really want to exploit the symetric aspect of the matrix. (It is more I have to than I want to, you know, school projects)
I don't really understand what you meant at the end ^^'
Bruno Luong
Bruno Luong el 30 de Abr. de 2021
Editada: Bruno Luong el 30 de Abr. de 2021
I revisit mpower2 and all the speed up around 2010 when the FEX is publiseh becomes very little now wth R2021a.

Iniciar sesión para comentar.

Categorías

Preguntada:

el 29 de Abr. de 2021

Comentada:

el 30 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by