faster leftdivide given prior information

1 次查看(过去 30 天)
Hi,
Among other calculation in my code there is a part where i use :
c=A\b;
Where A is sparse diagonal matrix (~100k x 100k) .
I am not sure whether checking of the matrix A properties takes considerable time or not.
Given that i already know that A is diagonal, is it possible to speed up the computation and avoid checkups for choosing solver?
thanks in advance,
redi

采纳的回答

Steven Lord
Steven Lord 2019-12-16
The linsolve or decomposition functions may be of interest to you. decomposition may be particularly beneficial if you're solving multiple systems with the same A matrix.
Though if you're certain A is a diagonal matrix, I'd probably try calling diag then using element-wise division between b and that diagonal (or if possible skipping creating A altogether and just create its diagonal as a vector instead.)
  1 个评论
Christine Tobler
Christine Tobler 2019-12-17
Note linsolve only supports dense matrices, so wouldn't be ideal here. In general, decomposition can be used to skip some input checking in A\b. But I agree for a diagonal matrix, the cheapest will be to just compute the diagonal vector d (as a column vector, e.g. by call d = diag(A)) and call d.\b instead.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by