1. 软件版本信息

  • Windows 10
  • Visual Studio 2015 Professional
  • SuperLU Package

2.  软件下载链接

SuperLU Introduction: SuperLU is a general purpose library for the direct solution of large, sparse, nonsymmetric systems of linear equations. The library is written in C and is callable from either C or Fortran program. It uses MPI, OpenMP and CUDA to support various forms of parallelism. It supports both real and complex datatypes, both single and double precision, and 64-bit integer indexing. The library routines performs an LU decomposition with partial pivoting and triangular system solves through forward and back substitution. The LU factorization routines can handle non-square matrices but the triangular solves are performed only for square matrices. The matrix columns may be preordered (before factorization) either through library or user supplied routines. This preordering for sparsity is completely separate from the factorization. Working precision iterative refinement subroutines are provided for improved backward stability. Routines are also provided to equilibrate the system, estimate the condition number, calculate the relative backward error, and estimate error bounds for the refined solutions.

The above intriduction is from the below link, which is also the download link.

下载链接:http://crd-legacy.lbl.gov/~xiaoye/SuperLU/

备用链接(百度网盘):https://pan.baidu.com/s/1xHAs-iT2pZPL6PLvIU-sqw 密码:o84i

3.  前期编译

编译以静态库方式,而非动态链接库或者exe可执行文件方式。为免混淆,请按如下方式创建静态链接库:

此外,以下两部分编译在本文中均以Release方式编译,编译请单击项目工程右键后点击生成即可。编译后所需重要文件在Release文件夹目录下,后缀名为“项目工程名+.lib后缀“。

3.1 第一部分

新建工程 “SuperLU”

3.2 第二部分

区别:第一个需要编译,第二个仅需在项目工程进行设置,请见如下:

3.2.1 采用SuperLU自带Basic Linear Algebra SubPrograms(BLAS)

新建工程 “SuperBLAS”

3.2.2 采用第三方BLAS库,如Intel MKL

设置Intel MKL请见我的博客之“C++ & Intel MKL 混合编程”,链接地址:https://blog.csdn.net/santorinisu/article/details/80274112

4. 代码

在调用之前,总结一下此前编译且对后面有重要影响的文件,具体如下:

编译文件SuperLU.lib, 编译文件SuperBLAS.lib, 和源文件夹SRC(用于编译获取SuperLU.lib的文件,来源于SuperLU Package文件目录下的SRC整个文件)。此三个文件用于4.3节中工程参数设置。为便于添加方便,本博客中新建名为“SuperLib”的文件夹,用于包含上述三个文件,最后一个是文件夹(SRC)。

4.1 图片形式

4.2 代码形式

代码来源于SuperLU Package.

#include "stdafx.h"
#include "slu_ddefs.h"void main(int argc, char *argv[])
{/** Purpose* =======** This is the small 5x5 example used in the Sections 2 and 3 of the* Users' Guide to illustrate how to call a SuperLU routine, and the* matrix data structures used by SuperLU.**/SuperMatrix A, L, U, B;double   *a, *rhs;double   s, u, p, e, r, l;int      *asub, *xa;int      *perm_r; /* row permutations from partial pivoting */int      *perm_c; /* column permutation vector */int      nrhs, info, i, m, n, nnz, permc_spec;superlu_options_t options;SuperLUStat_t stat;/* Initialize matrix A. */m = n = 5;nnz = 12;if (!(a = doubleMalloc(nnz))) ABORT("Malloc fails for a[].");if (!(asub = intMalloc(nnz))) ABORT("Malloc fails for asub[].");if (!(xa = intMalloc(n + 1))) ABORT("Malloc fails for xa[].");s = 19.0; u = 21.0; p = 16.0; e = 5.0; r = 18.0; l = 12.0;a[0] = s; a[1] = l; a[2] = l; a[3] = u; a[4] = l; a[5] = l;a[6] = u; a[7] = p; a[8] = u; a[9] = e; a[10] = u; a[11] = r;asub[0] = 0; asub[1] = 1; asub[2] = 4; asub[3] = 1;asub[4] = 2; asub[5] = 4; asub[6] = 0; asub[7] = 2;asub[8] = 0; asub[9] = 3; asub[10] = 3; asub[11] = 4;xa[0] = 0; xa[1] = 3; xa[2] = 6; xa[3] = 8; xa[4] = 10; xa[5] = 12;/* Create matrix A in the format expected by SuperLU. */dCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_D, SLU_GE);/* Create right-hand side matrix B. */nrhs = 1;if (!(rhs = doubleMalloc(m * nrhs))) ABORT("Malloc fails for rhs[].");for (i = 0; i < m; ++i) rhs[i] = 1.0;dCreate_Dense_Matrix(&B, m, nrhs, rhs, m, SLU_DN, SLU_D, SLU_GE);if (!(perm_r = intMalloc(m))) ABORT("Malloc fails for perm_r[].");if (!(perm_c = intMalloc(n))) ABORT("Malloc fails for perm_c[].");/* Set the default input options. */set_default_options(&options);options.ColPerm = NATURAL;/* Initialize the statistics variables. */StatInit(&stat);/* Solve the linear system. */dgssv(&options, &A, perm_c, perm_r, &L, &U, &B, &stat, &info);dPrint_CompCol_Matrix("A", &A);dPrint_CompCol_Matrix("U", &U);dPrint_SuperNode_Matrix("L", &L);print_int_vec("\nperm_r", m, perm_r);dPrint_Dense_Matrix("B", &B);/* De-allocate storage */SUPERLU_FREE(rhs);SUPERLU_FREE(perm_r);SUPERLU_FREE(perm_c);Destroy_CompCol_Matrix(&A);Destroy_SuperMatrix_Store(&B);Destroy_SuperNode_Matrix(&L);Destroy_CompCol_Matrix(&U);StatFree(&stat);getchar();
}

4.3 工程参数设置

5. 结果显示

6. 重要链接

  • http://crd-legacy.lbl.gov/~xiaoye/SuperLU/faq.html#windows
  • https://blog.csdn.net/Sunshine_in_Moon/article/details/49661643
  • https://blog.csdn.net/gindar/article/details/8010794
  • http://crd-legacy.lbl.gov/~xiaoye/SuperLU/

C++ SuperLU 混合编程相关推荐

  1. 基于VS2017的C++ SuperLU混合编程

    一.SuperLU介绍 SuperLU:是一个通用库,用于直接求解大型稀疏非对称线性方程组.该库是用C编写的,可以从C或Fortran程序调用.它使用MPI.OpenMP和CUDA来支持各种形式的并行 ...

  2. matlab两个多项式相除,C++和MATLAB混合编程求解多项式系数(矩阵相除)

    摘要:MATLAB对于矩阵处理是非常高效的,而C++对于矩阵操作是非常麻烦的,因而可以采用C++与MATLAB混合编程求解矩阵问题. 主要思路就是,在MATLAB中编写函数脚本并使用C++编译为dll ...

  3. C和C++混合编程的Makefile的编写!

    在项目实践中,经常遇到C和C++混合编程的情况. 目前的业务需求是: c写的几个文件,和一个C++文件要整合为一个动态库,被C++调用.而这个动态库的生成过程中,会链接几个基础的开发库,比如libz, ...

  4. 怎样用matlab打开mw文,C# matlab混合编程 MWArray使用笔记

    C# matlab混合编程 徐凯Email:xukai19871105@http://www.doczj.com/doc/1a6e191fff00bed5b9f31dbf.html 这几天突然想搞一搞 ...

  5. matlab2014a + win764bit + vs2013混合编程(.m转成dll供C++调用)

    在matlab中可以通过mbuild工具将.m文件编译成dll文件供外部的C++程序调用,这样就可以实现matlab和C++混合编程的目的. 1. 使用matlab生成dll文件 1.1 首先需要带有 ...

  6. .Net(c#) 通过 Fortran 动态链接库,实现混合编程

    c# 与 Fortran 混合编程解决方案主要有两种: 1. 进程级的交互:在 Fortran 中编译为控制台程序,.Net 调用(System.Diagnostics.Process),然后使用 P ...

  7. c 与matlab混编,谈谈Matlab与C/C++或C#的互调用(混合编程)

    记得当初一个师姐问我知不知道如何在Matlab里调用C++的程序,还真把我问住了.因为我以前就知道C++调用Matlab的方法,这方面网上资料一大堆.没想到现在自己突发奇想又遇到另外一个问题,Matl ...

  8. Linux C++与Python混合编程(g++生成链接库与python调用)

    gcc/g++ 链接库的编译与链接 这一篇对动态链接库和静态链接库以及编译结果讲得很清楚,目前看到最好的. Linux下Python与C++混合编程

  9. 基于引擎的matlab+vc混合编程的配置

    前段时间在项目中做了一些关于基于引擎的vc+matlab混合编程的工作. 如果你是混合编程新手,我相信使用引擎的方式编程是比较简单快捷的一种方式. 当然这种方法也有其缺点,就是不能脱离matlab运行 ...

最新文章

  1. 共享之windows与Linux
  2. 计算机视觉开源库OpenCV之平滑、模糊和滤波
  3. 获取不到时间_一月自考成绩查询时间一出,看了文章这次稳过
  4. linux常见基础服务,常用的linux命令的基本使用(一)
  5. 富爸爸系列 -- 《财务自由》学习笔记之三
  6. dpkg:处理软件包 xxx (--configure)时出错
  7. 提高openfire最大连接数
  8. 八个常见CMD网络命令
  9. 二进制安装MySQL以及密码破解
  10. window VNC Viewer设置屏幕分配率
  11. Flutter时间转换工具类
  12. mac电脑解压缩报错:错误22 无效的参数
  13. 女生适合学数据分析吗?过来人告诉你
  14. 移动鼠标(动态)改变svg图标的颜色
  15. 需求工程:软件建模与分析 读书笔记二
  16. 显示网格(grid)
  17. 泰罗凹凸曼主题曲谐音
  18. 应广单片机002烧录器万能烧录方法
  19. matlab 2012a 自定义安装,Matlab 2012a安装方法
  20. 企业内部防泄密不完善造成重大损失案例(上)

热门文章

  1. 51蛋骗鸡数码管显示A-Z字母
  2. MacBook Pro 安装软件navicat15 , mac10.15安装navcat15
  3. 从你的全世界路过—一群程序员的稻城亚丁游记
  4. 电子琴节奏包制作_MIDI音乐制作基础必备
  5. 世界上最简单的会计书(现金流量表)
  6. mixamo骨骼_Mixamo——在线三维人物角色骨骼自动绑定,上千动作库直接生成人物动画...
  7. 模态逻辑(1)——从命题逻辑开始
  8. Python小游戏:猜大小
  9. 安兔兔苹果html5排行榜,iPhone8Plus最强?9月安兔兔手机性能排行榜出炉
  10. 数字图像处理——隐形眼镜缺陷检测算法