01 2013 档案
摘要:参考文献:科学计算中的偏微分方程有限差分法 张文生编著 高等教育出版社 (P153)求解的问题是:其精确解为:利用差分法,计算出的数值解写入到文件 outxyu.txt精确解写入到文件 outxyuj.txt残差再做处理一下。精确解:数值解:残差图:显示颜色带
阅读全文
摘要:主函数:View Code #include <stdio.h>#include "MyLib.h"#define C(i,j) C[i*36+j] //用一维数组空间来表示二维数组//int gaus(double a[],double b[],int n);int main(int argc,char *argv[]){ FILE *fptr1, *fptr2,*fptr3; int i,j; double a[36][36]; double b[36]; fptr1 = fopen("input1.txt", "r"
阅读全文
摘要:在 常用算法程序集(C语言描述)中有如下的传递方式:View Code int gaus(a,b,n) int n; double a[],b[]; { }这里a数组为一维数组在主程序中可以传递二维数组过来A[][]View Code double A[3][3];gaus(A,b,n)上述问题主要在VC6.0下编译通过 只能是C代码(直接改CPP不行)现在改为CPP程序View Code double A[][];double C[];for() for() { C[]=A[][];//强制转换}gaus(C,b,n);接口(头文件)中 定义View Code ...
阅读全文
摘要:转载至 http://wenku.baidu.com/view/d3adc6d03186bceb19e8bb6a.html在标准C中规定变量定义必须放在所有的执行语句之前!一旦在运行语句之间再有定义的话,会报错误!见以下式例:#include <stdio.h> int main() { char char1='A'; printf("大写字符=%c的ASCII码=%d\n",char1,char1); char char2=char1+32; printf("小写字符=%c的ASCII码=%d\n",char2,char2)
阅读全文
摘要:现在有一个程序 用于实现 从文件中读入数据文件 然后调入到主程序中,执行是需用到另外一个算法。在VC6.0 中,包含如下文件 6GAUS00.C 6GAUS.C input1.txt input2.txt此处不需要定义工程,直接运行6GAUS00.C 可直接出结果具体代码如下6GAUS00.CView Code #include <stdio.h>//#include <fstream> #include "6gaus.c" int main() { FILE *fptr1, *fptr2,*fptr3; int i,j; double a[36][
阅读全文
摘要:36阶的矩阵和向量,形式为Ax=b原始的数据:这是左端的系数矩阵AView Code 4 -2 0 0 0 0 -2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0-1 4 -1 0 0 0 0 -2 0 0 0 0 0 0 0 0...
阅读全文
摘要:参考文献:科学计算中的偏微分方程有限差分法B=[4 -2 0 0 0;-1 4 -1 0 0;0 -1 4 -1 0;0 0 -1 4 -1;0 0 0 -2 4];I=eye(5);Z=zeros(5);A=[B -2*I Z Z Z;-I B -I Z Z;Z -I B -I Z;Z Z -I B -I;Z Z Z -2*I B];为了保持形式上的对称,试着将A改写为A=[1.0/2*B -I Z Z Z;-I B -I Z Z;Z -I B -I Z;Z Z -I B -I;Z Z Z -1*I 1.0/2*B];
阅读全文
摘要:View Code function [x]=testRL(A,b)%%测试删除一行一列的结果%u=sin(3*pi*x+pi/4)*sin(2*pi*y+pi/4)delta_y=1.0/(sqrt(length(A))-1);for i=1:sqrt(length(A)):length(A) x(i)=sin(3*pi*0+pi/4)*sin(2*pi*delta_y*(i-1)+pi/4); for j=1:length(A) A(i,j)=0; end A(i,i)=1; b(i)=x(i);end% for i=1:length(...
阅读全文