计算方式方程组a.pptVIP

  • 1
  • 0
  • 约2.32千字
  • 约 12页
  • 2019-04-28 发布于福建
  • 举报
计算方式方程组a

第二章 解线性方程组的直接法 /* Direct Method for Solving Linear Systems */ 求解 克莱姆法则 /* Cramer’s Rule */ 2.1 高斯消元法 /* Gaussian Elimination */ 2.1 Gaussian Elimination 例 求解以下方程组: 解:采用增广矩阵/* augmented matrix */描述求解过程: 思路 首先将A化为上三角阵 /* upper-triangular matrix */,再回代求解 /* backward substitution */。 = 消元 记 其中 Step 1:设 ,计算因子 将增广矩阵第 i 行 ? mi1 ? 第1行,得到 2.1 Gaussian Elimination 第k步消元: 2.1 Gaussian Elimination 共进行 ? 步 n ? 1 回代 2.1 Gaussian Elimination 2.1.2程序设计 /* Progran Design */ 使用一维和二维数组。 What if ? No unique solution exists. What if ? 2.1 Gaussian Elimination 小主元 /* Small pivot element */ 可能导致计算失败。 2.1.3 选主元消去法 /* Pivoting Strategies */ 例:单精度解方程组 /* 精确解为 和 */ 8个 8个 用Gaussian Elimination计算: 8个 2.1 Gaussian Elimination ? 对策 ? 列主元消去法 /* Partial Pivoting, or maximal column pivoting */ 在每一步消元之前,针对所有的     ,选其中绝对值最大者作为主元素,即除数,把它所在的方程换到第k行,再按高斯法消元。 2.1 Gaussian Elimination ?程序设计 如何与高斯消去法衔接? 2.1 Gaussian Elimination ? 全主元消去法 /* Complete Pivoting */   在第k步消元前,对       的全体进行选主元,选绝对值最大者为主元,再经过换行与换列,把它换到第k行、第k列作除数。 ? 程序设计由同学们自己完成 2.1 Gaussian Elimination 2.1 Gaussian Elimination – Amount of Computation Lab 05. Matrix Inversion Use Gauss-Jordan Method with Partial Pivoting to find the inverse of a given matrix. Input There are several sets of inputs. For each set: The 1st line contains an integer 100 ? n ? 0 which is the size of a matrix. n = ?1 signals the end of file. The 2nd line contains n?n real numbers which are the entries of the matrix. The numbers are separated by spaces or new lines. Output Each entry of the inverse matrix is to be printed as in the C fprintf: fprintf(outfile, %16.8e?, a ); /* here ? represents a space*/ 2.1 Gaussian Elimination – Amount of Computation The entries of an n?n matrix are to be printed in the following format: If the matrix is not invertable, print the message “The?matrix?is? singular.\n”. The outputs of two test

文档评论(0)

1亿VIP精品文档

相关文档