摘要: 参考文献:UMFPACK Version 5.2.0 User Guide (P23)5.12 Larger examplesFull examples of all user-callable UMFPACK routines are available in four stand-alone C mainprograms, umfpack * demo.c(在5.2版本中为umfpack_di_demo.c 搜索的时候*代表umfpacK后面任意字符). Another example is the UMFPACK mexFunction, umfpackmex.c(在5.2版本中没有发现 阅读全文
posted @ 2013-03-10 11:11 liang_l 阅读(792) 评论(0) 推荐(0) 编辑
摘要: 测试平台:VS2008新建工程-添加源文件和头文件main函数#include<iostream>#include"callumfpack.h"using namespace std;//int print(int **A)int main(){ //int A[2][2]={0}; //printf("%d ",A[1][1]); /*int **A=new int *[2]; for(int i=0;i<2;i++) A[i]=new int [2]; for(int i=0;i<2;i++) for(int j=0;j< 阅读全文
posted @ 2013-02-26 23:20 liang_l 阅读(1212) 评论(0) 推荐(0) 编辑
摘要: int main(){ int n=3;int m=3; int **A=new int *[n]; for(int i=0;i<n;i++) A[i]=new int [m];//动态生成矩阵A com( A ); //调用函数com return 0;}int com(int **A){ printf("%d\n",A[2][2]);return 0;} 通过上面几条核心代码实现二维数组的传递 阅读全文
posted @ 2013-02-26 23:01 liang_l 阅读(2084) 评论(0) 推荐(0) 编辑
摘要: 在之前版本 改写UMFPACK算例中的压缩方式(动态) 中Ai Ax采用的是vector类型,现在修改为int和double,牺牲内存空间View Code //Data:2013-2-24//修改了Ai Ax的类型 利用最大维数n*n来保存,可以调用正确结果 不过不知系统随机分配的值 函数没有用#include <stdio.h>#include <math.h>#include "umfpack.h"#pragma comment(lib,"../lib/libamd.lib")#pragma comment(lib,&quo 阅读全文
posted @ 2013-02-25 14:17 liang_l 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 在上篇博文基础上修改,使之A能动态View Code /* -------------------------------------------------------------------------- *//* UMFPACK Copyright (c) Timothy A. Davis, CISE, *//* Univ. of Florida. All Rights Reserved. See ../Doc/License for License. *//* web: http://www.cise.ufl.edu/r... 阅读全文
posted @ 2013-02-24 13:49 liang_l 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 在UMFPACK的官方文档 UMFPACK Version 5.2.0 User Guide中的5.3节中的例子稀疏矩阵A和右端向量b 为 A=[2 3 0 0 0;3 0 4 0 6 ;0 -1 -3 2 0;0 0 1 0 0;0 4 2 0 1]b=[8.,45.,-3.,3.,19.] 其解为x=[1 2 3 4 5]'这个算例的源代码为View Code 1 #include <stdio.h> 2 #include "umfpack.h" 3 int n = 5 ; 4 int Ap [ ] = {0, 2, 5, 9, 10, ... 阅读全文
posted @ 2013-02-24 00:17 liang_l 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 采用压缩稀疏行格式(CSR)存储核心代码段1 for (i=0; i<M; i++) 2 { 3 t = 0.0; 4 for (j=row_start[i]; j<row_start[i+1]; j++) { 5 t += val[j] * x[col_idx[j]]; 6 } 7 y[i]=t; //y[i]存储积的第i行8 } 阅读全文
posted @ 2013-02-23 15:50 liang_l 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 参考文献:科学计算中的偏微分方程有限差分法 张文生编著 高等教育出版社 (P153)求解的问题是:其精确解为:利用差分法,计算出的数值解写入到文件 outxyu.txt精确解写入到文件 outxyuj.txt残差再做处理一下。精确解:数值解:残差图:显示颜色带 阅读全文
posted @ 2013-01-26 22:03 liang_l 阅读(1436) 评论(0) 推荐(0) 编辑
摘要: 主函数: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" 阅读全文
posted @ 2013-01-16 21:03 liang_l 阅读(1292) 评论(0) 推荐(0) 编辑
摘要: 在 常用算法程序集(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 ... 阅读全文
posted @ 2013-01-16 17:02 liang_l 阅读(390) 评论(0) 推荐(1) 编辑