声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2861|回复: 8

[近似分析] 求助:A为大型非对称矩阵时,AX=b的迭代算法

[复制链接]
发表于 2006-7-5 10:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我需要AX=B迭代求解过程只涉及A和向量乘积的计算,不破坏A的完整性,列如共厄梯度法CG和广义极小残差法GMRES.

现在我试过GMRES法中的一种,效果不是很好 ,系数矩阵A维数增大或者A中有一列的数比起A中其他数小几个数量级时根本算不对
不知道有没有做过这方面的人,给点建议或者推荐一种方法,谢谢

如有人清楚请加我QQ68836285或者发EMAIL   hao.19820125@163.com

[ 本帖最后由 咕噜噜 于 2007-6-15 08:52 编辑 ]

评分

1

查看全部评分

本帖被以下淘专辑推荐:

回复
分享到:

使用道具 举报

 楼主| 发表于 2006-7-6 16:51 | 显示全部楼层

帮忙呀

要是哪能找到GMRES的原程序及相关资料也好呀!

[ 本帖最后由 hao1982 于 2006-7-6 16:52 编辑 ]
发表于 2006-7-6 22:05 | 显示全部楼层

re:

(1) 将方程变换 A'*Ax=A'b;

    A‘*A 是对称的,可以用处理对称方程的方法求解
   但是这种处理可能增大方程的条件数

(2)用matlb中的GMRES。。。。。。help GMRES
 楼主| 发表于 2006-7-7 13:10 | 显示全部楼层

THANKS

发表于 2006-11-2 15:05 | 显示全部楼层
看看这个,在网上搜到的

  1. //*****************************************************************
  2. // Iterative template routine -- GMRES
  3. //
  4. // GMRES solves the unsymmetric linear system Ax = b using the
  5. // Generalized Minimum Residual method
  6. //
  7. // GMRES follows the algorithm described on p. 20 of the
  8. // SIAM Templates book.
  9. //
  10. // The return value indicates convergence within max_iter (input)
  11. // iterations (0), or no convergence within max_iter iterations (1).
  12. //
  13. // Upon successful return, output arguments have the following values:
  14. //  
  15. //        x  --  approximate solution to Ax = b
  16. // max_iter  --  the number of iterations performed before the
  17. //               tolerance was reached
  18. //      tol  --  the residual after the final iteration
  19. //  
  20. //*****************************************************************


  21. template < class Matrix, class Vector >
  22. void
  23. Update(Vector &x, int k, Matrix &h, Vector &s, Vector v[])
  24. {
  25.   Vector y(s);

  26.   // Backsolve:  
  27.   for (int i = k; i >= 0; i--) {
  28.     y(i) /= h(i,i);
  29.     for (int j = i - 1; j >= 0; j--)
  30.       y(j) -= h(j,i) * y(i);
  31.   }

  32.   for (int j = 0; j <= k; j++)
  33.     x += v[j] * y(j);
  34. }


  35. template < class Real >
  36. Real
  37. abs(Real x)
  38. {
  39.   return (x > 0 ? x : -x);
  40. }


  41. template < class Operator, class Vector, class Preconditioner,
  42.            class Matrix, class Real >
  43. int
  44. GMRES(const Operator &A, Vector &x, const Vector &b,
  45.       const Preconditioner &M, Matrix &H, int &m, int &max_iter,
  46.       Real &tol)
  47. {
  48.   Real resid;
  49.   int i, j = 1, k;
  50.   Vector s(m+1), cs(m+1), sn(m+1), w;
  51.   
  52.   Real normb = norm(M.solve(b));
  53.   Vector r = M.solve(b - A * x);
  54.   Real beta = norm(r);
  55.   
  56.   if (normb == 0.0)
  57.     normb = 1;
  58.   
  59.   if ((resid = norm(r) / normb) <= tol) {
  60.     tol = resid;
  61.     max_iter = 0;
  62.     return 0;
  63.   }

  64.   Vector *v = new Vector[m+1];

  65.   while (j <= max_iter) {
  66.     v[0] = r * (1.0 / beta);    // ??? r / beta
  67.     s = 0.0;
  68.     s(0) = beta;
  69.    
  70.     for (i = 0; i < m && j <= max_iter; i++, j++) {
  71.       w = M.solve(A * v[i]);
  72.       for (k = 0; k <= i; k++) {
  73.         H(k, i) = dot(w, v[k]);
  74.         w -= H(k, i) * v[k];
  75.       }
  76.       H(i+1, i) = norm(w);
  77.       v[i+1] = w * (1.0 / H(i+1, i)); // ??? w / H(i+1, i)

  78.       for (k = 0; k < i; k++)
  79.         ApplyPlaneRotation(H(k,i), H(k+1,i), cs(k), sn(k));
  80.       
  81.       GeneratePlaneRotation(H(i,i), H(i+1,i), cs(i), sn(i));
  82.       ApplyPlaneRotation(H(i,i), H(i+1,i), cs(i), sn(i));
  83.       ApplyPlaneRotation(s(i), s(i+1), cs(i), sn(i));
  84.       
  85.       if ((resid = abs(s(i+1)) / normb) < tol) {
  86.         Update(x, i, H, s, v);
  87.         tol = resid;
  88.         max_iter = j;
  89.         delete [] v;
  90.         return 0;
  91.       }
  92.     }
  93.     Update(x, m - 1, H, s, v);
  94.     r = M.solve(b - A * x);
  95.     beta = norm(r);
  96.     if ((resid = beta / normb) < tol) {
  97.       tol = resid;
  98.       max_iter = j;
  99.       delete [] v;
  100.       return 0;
  101.     }
  102.   }
  103.   
  104.   tol = resid;
  105.   delete [] v;
  106.   return 1;
  107. }


  108. #include <math.h>


  109. template<class Real>
  110. void GeneratePlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn)
  111. {
  112.   if (dy == 0.0) {
  113.     cs = 1.0;
  114.     sn = 0.0;
  115.   } else if (abs(dy) > abs(dx)) {
  116.     Real temp = dx / dy;
  117.     sn = 1.0 / sqrt( 1.0 + temp*temp );
  118.     cs = temp * sn;
  119.   } else {
  120.     Real temp = dy / dx;
  121.     cs = 1.0 / sqrt( 1.0 + temp*temp );
  122.     sn = temp * cs;
  123.   }
  124. }


  125. template<class Real>
  126. void ApplyPlaneRotation(Real &dx, Real &dy, Real &cs, Real &sn)
  127. {
  128.   Real temp  =  cs * dx + sn * dy;
  129.   dy = -sn * dx + cs * dy;
  130.   dx = temp;
  131. }
复制代码
发表于 2006-11-15 13:39 | 显示全部楼层
CG一般只用于对称正定的矩阵。GMRES理论上不依赖于矩阵的特性,但常常收敛很慢。这时需要高质量的预处理器,这方面的算法很多,可根据具体问题采用。
如果A是稀疏矩阵,A‘*A还会破坏稀疏性。
A的阶数有多大?
发表于 2006-11-16 07:00 | 显示全部楼层
原帖由 closest 于 2006-11-15 13:39 发表
CG一般只用于对称正定的矩阵。GMRES理论上不依赖于矩阵的特性,但常常收敛很慢。这时需要高质量的预处理器,这方面的算法很多,可根据具体问题采用。
如果A是稀疏矩阵,A‘*A还会破坏稀疏性。
A的阶数有多大?



能否介绍一下你说的高质量的预处理器?
发表于 2006-11-16 09:47 | 显示全部楼层
预处理算法至少有十几种,以Saad(迭代法权威)的一系列论文为代表,许多算法的复杂程度远超GMRES本身。这些算法更多的是基于一些假设和测试,理论上很难分析,也还没有通用的预处理器。对于具体的问题来说,有兴趣和时间的话可以逐个尝试这些算法,作一些改进也不是很难。
主要的问题在于对于很多矩阵,目前还没有可靠的预处理器。预处理器的表现往往两极化,对于某些矩阵收敛特别快,对于其它的矩阵则没什么作用.
发表于 2006-11-19 07:20 | 显示全部楼层
原帖由 closest 于 2006-11-16 09:47 发表
预处理算法至少有十几种,以Saad(迭代法权威)的一系列论文为代表,许多算法的复杂程度远超GMRES本身。这些算法更多的是基于一些假设和测试,理论上很难分析,也还没有通用的预处理器。对于具体的问题来说,有兴趣 ...


谢谢你的介绍,有时间我看看
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-6 08:33 , Processed in 0.057260 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表