| 查看: 309 | 回复: 2 | |||
| 当前主题已经存档。 | |||
carveny金虫 (小有名气)
|
[交流]
[求助]求解三对角线方程组的C语言的源码
|
||
|
求解三对角线方程组的C语言的源码 很急,谢谢。 [ Last edited by csfn on 2008-12-29 at 20:12 ] |
» 猜你喜欢
导师想让我从独立一作变成了共一第一
已经有8人回复
博士读完未来一定会好吗
已经有23人回复
到新单位后,换了新的研究方向,没有团队,持续积累2区以上论文,能申请到面上吗
已经有11人回复
读博
已经有4人回复
JMPT 期刊投稿流程
已经有4人回复
心脉受损
已经有5人回复
Springer期刊投稿求助
已经有4人回复
小论文投稿
已经有3人回复
申请2026年博士
已经有6人回复
carveny
金虫 (小有名气)
- 应助: 0 (幼儿园)
- 金币: 1224.9
- 红花: 1
- 帖子: 251
- 在线: 21.7小时
- 虫号: 304891
- 注册: 2006-12-09
- 性别: GG
- 专业: 集成电路制造与封装
2楼2008-02-29 21:48:09
liverangel
木虫 (著名写手)
- 应助: 3 (幼儿园)
- 贵宾: 0.49
- 金币: 2101.3
- 散金: 2716
- 红花: 14
- 帖子: 1096
- 在线: 295小时
- 虫号: 74852
- 注册: 2005-06-14
- 性别: GG
- 专业: 金属材料的合金相、相变及
★ ★ ★ ★ ★ ★ ★ ★ ★ ★
carveny(金币+10,VIP+0):谢谢,太感谢了!
carveny(金币+10,VIP+0):谢谢,太感谢了!
|
#include "iostream.h" #include "math.h" void tridag(double a[],double b[], double c[],double r[], double u[], int n) { const int nmax = 100; double gam[100]; if (b[1] == 0.0) { return; } double bet = b[1]; u[1] = r[1] / bet; for (int j = 2; j<=n; j++) { gam[j] = c[j - 1] / bet; bet = b[j] - a[j] * gam[j]; if (bet == 0.0) { return; } u[j] = (r[j] - a[j] * u[j - 1]) / bet; } for (j = n - 1; j>=1; j--) { u[j] = u[j] - gam[j + 1] * u[j + 1]; } } void main() { //program d1r3 //driver program for routine tridag int i,j,l,n = 3; double a[4], b[4], c[4], r[4], u[4], a1[4][4], x[4]; //输入已知的方程组的系数矩阵 a1[1][1] = 1; a1[1][2] = 2; a1[1][3] = 0; a1[2][1] = 2; a1[2][2] = 2; a1[2][3] = 3; a1[3][1] = 0; a1[3][2] = 3; a1[3][3] = 3; //输入已知的方程组的右端向量 r[1] = 1; r[2] = 2; r[3] = 3; cout< cout< cout< cout< { a = a1[i - 1]; } for (i = 1; i<=n - 1; i++) { c = a1[i + 1]; } for (i = 1; i<=n; i++) { b = a1; } tridag(a, b, c, r, u, n); cout< cout< cout.width(10); cout< cout.width(10); cout< //将计算出的解乘以系数矩阵,以验证计算结果正确 for (l = 1; l<=n; l++) { x[l] = 0.0; for (j = 1; j<=n; j++) { x[l] = x[l] + a1[l][j] * u[j]; } } cout< cout< cout< cout< } |

3楼2008-03-01 01:52:37













回复此楼