安装Armadillo 进行矩阵计算(Install Armadillo on Windows for Visual Studio)
2013-08-19 21:14
417 查看
Armadillo是一个C++开发的线性代数库,可以方便的把用 Matlab 开发的算法移植到 C++。只需要头文件就可以使用,也可以选用高效的 LAPACK 和 BLAS 进行加速。安装过程如下:
1、去
Download 下载 Source Code,解压到任意目录,比如 X:\Armadillo,将 \include 目录添加到 visual studio 包含文件目录中,VS2008 是在 “工具->选项->VC++目录->包含文件” 这里设置,其它版本类似。
2、修改 X:\Armadillo\include\armadillo_bits\config.hpp 文件,取消掉下面两行的注释
#define ARMA_USE_LAPACK
#define ARMA_USE_BLAS
取消注释表示使用 LAPACK 和 BLAS 进行更高效的计算,否则使用内建的函数进行计算,这样可能会带来一定性能的下降。
3、安装 LAPACK 和 BLAS,去http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html 下载blas.lib,libf2c.lib,lapack.lib三个库,并在编译环境的额外依赖库中添加这三个库。(blasd.lib,libf2cd.lib,lapackd.lib
是 debug 版本的库,调试程序的时候可以使用)。同步骤 1 将存放 .lib 文件的路径添加到 visual studio 的库文件路径中。
4、在项目属性中的链接器中添加
blas.lib,libf2c.lib,lapack.lib
5、Okay,写个 Demo 测试一下
运行结果:
A =
0.0125 5.8501 8.2284 7.1050 0.9140
5.6359 4.7987 7.4660 5.1353 3.6445
1.9330 3.5029 1.7411 3.0399 1.4731
8.0874 8.9596 8.5894 0.1498 1.6590
B =
9.8853 0.0891 6.0176 4.5079 7.8332
4.4569 3.7788 6.0717 3.5212 8.0261
1.1908 5.3166 1.6623 0.5704 5.1988
0.0467 5.7118 6.6305 6.0768 3.0195
A .* B =
0.1237 0.5213 49.5155 32.0286 7.1598
25.1186 18.1335 45.3313 18.0827 29.2511
2.3019 18.6237 2.8943 1.7340 7.6585
0.3776 51.1760 56.9518 0.9106 5.0093
请按任意键继续. . .
1、去
Download 下载 Source Code,解压到任意目录,比如 X:\Armadillo,将 \include 目录添加到 visual studio 包含文件目录中,VS2008 是在 “工具->选项->VC++目录->包含文件” 这里设置,其它版本类似。
2、修改 X:\Armadillo\include\armadillo_bits\config.hpp 文件,取消掉下面两行的注释
#define ARMA_USE_LAPACK
#define ARMA_USE_BLAS
取消注释表示使用 LAPACK 和 BLAS 进行更高效的计算,否则使用内建的函数进行计算,这样可能会带来一定性能的下降。
3、安装 LAPACK 和 BLAS,去http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html 下载blas.lib,libf2c.lib,lapack.lib三个库,并在编译环境的额外依赖库中添加这三个库。(blasd.lib,libf2cd.lib,lapackd.lib
是 debug 版本的库,调试程序的时候可以使用)。同步骤 1 将存放 .lib 文件的路径添加到 visual studio 的库文件路径中。
4、在项目属性中的链接器中添加
blas.lib,libf2c.lib,lapack.lib
5、Okay,写个 Demo 测试一下
#include <iostream> #include <armadillo> int main() { arma::mat A = arma::randu<arma::mat>(4, 5) * 10; arma::mat B = arma::randu<arma::mat>(4, 5) * 10; arma::mat C = A % B; A.print("A = \n"); B.print("B = \n"); C.print("A .* B = \n"); return 0; }
运行结果:
A =
0.0125 5.8501 8.2284 7.1050 0.9140
5.6359 4.7987 7.4660 5.1353 3.6445
1.9330 3.5029 1.7411 3.0399 1.4731
8.0874 8.9596 8.5894 0.1498 1.6590
B =
9.8853 0.0891 6.0176 4.5079 7.8332
4.4569 3.7788 6.0717 3.5212 8.0261
1.1908 5.3166 1.6623 0.5704 5.1988
0.0467 5.7118 6.6305 6.0768 3.0195
A .* B =
0.1237 0.5213 49.5155 32.0286 7.1598
25.1186 18.1335 45.3313 18.0827 29.2511
2.3019 18.6237 2.8943 1.7340 7.6585
0.3776 51.1760 56.9518 0.9106 5.0093
请按任意键继续. . .
相关文章推荐
- 安装Armadillo 进行矩阵计算(Install Armadillo on Windows for Visual Studio)
- 安装Visual Studio Tools for Office以针对SharePoint工作流项目模板进行开发
- 谁说用Azure就一定要Vista/Win7?Window2003/xp下安装 Windows Azure Tools for Microsoft Visual Studio
- Install boost on Windows for Visual C++
- Installing C++ Boost on Microsoft Windows for Visual Studio .NET 2003/2005/Orcas
- 安装Microsoft Visual Studio 2005 Extensions for Windows Workflow Foundation的工具箱控件丢失问题解决~~
- Installing C++ Boost on Microsoft Windows for Visual Studio .NET 2003/2005/Orcas
- InstallShield Limited Edition for Visual Studio 2013 图文教程打包安装包
- VS2013打包安装(InstallShield Limited Edition for Visual Studio 2013 )
- Visual studio Express 2012 for windows phone 试用 (一) 安装 推荐
- Step by Step Setup Git Server on Windows with CopSSH + msysGit and Integrate Git with Visual Studio
- 使用 WebSphere Studio Application Developer 开发 Java 程序: 与 VisualAge for Java 进行比较
- 安装Blend+SketchFlow Preview for Visual Studio 2012出现错误
- CodeRush for Visual Studio .NET v.3.0.1 (Beta) released on 4 Dec 2007
- How to install Windows on your Mac for free
- InstallShield Limited Edition for Visual Studio 2013 图文教程(教你如何打包.NET程序)
- [转载]UnityVS(Visual Studio Tools For Unity)的安装与使用
- How to debug test code on Windows Mobile Emulator with Visual Studio
- HOWTO install and setup Android NDK for Windows(Android NDK 开发环境安装和配置)
- windows下安装Pylons python web 开发框架(Pylons install on windows)