在Julia中有效解决特定的线性系统 [英] Solve a particular linear system efficiently in julia

查看:91
本文介绍了在Julia中有效解决特定的线性系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我广泛使用julia的线性方程求解器res = X\b.由于参数变化,我必须在程序中使用数百万次.之所以可以,是因为我使用的尺寸较小(最大为30).现在,我想分析更大的系统,直到1000,线性求解器不再有效.

我认为可以解决这个问题.但是我必须说,有时我的X矩阵很稠密,有时很稀疏,所以我需要在两种情况下都能正常工作的东西.

b向量是一个全零的向量,除了一个条目始终为1(实际上始终为最后一个条目).而且,我不需要所有的res向量,只需它的第一个条目即可.

解决方案

如果您的问题属于(A - µI)x = b形式,其中µ是变量参数,而Ab是固定的,则可以工作对角化.

A = PDP°,其中表示P的倒数.然后(PDP° - µI)x = b可以转换为

(D - µI)P°x = P°b, 
P°x = P°b / (D - µI), 
x = P(P°b / (D - µI)).

(/操作表示将各个矢量元素除以标量Dr - µ.)

对角线化了A之后,为任何µ计算一个解决方案将减少为两个矩阵/矢量乘积,或者,如果还可以预先计算P°b,则为一个.

数值不稳定性将出现在特征值A附近.

I use extensively the julia's linear equation solver res = X\b. I have to use it millions of times in my program because of parameter variation. This was working ok because I was using small dimensions (up to 30). Now that I want to analyse bigger systems, up to 1000, the linear solver is no longer efficient.

I think there can be a work around. However I must say that sometimes my X matrix is dense, and sometimes is sparse, so I need something that works fine for both cases.

The b vector is a vector with all zeroes, except for one entry which is always 1 (actually it is always the last entry). Moreover, I don't need all the res vector, just the first entry of it.

解决方案

If your problem is of the form (A - µI)x = b, where µ is a variable parameter and A, b are fixed, you might work with diagonalization.

Let A = PDP° where denotes the inverse of P. Then (PDP° - µI)x = b can be transformed to

(D - µI)P°x = P°b, 
P°x = P°b / (D - µI), 
x = P(P°b / (D - µI)).

(the / operation denotes the division of the respective vector elements by the scalars Dr - µ.)

After you have diagonalized A, computing a solution for any µ reduces to two matrix/vector products, or a single one if you can also precompute P°b.

Numerical instability will show up in the vicinity of the Eigenvalues of A.

这篇关于在Julia中有效解决特定的线性系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆