Win7系统Visual Studio下的armadillo环境配置
来源:互联网 发布:linux root用户 编辑:程序博客网 时间:2024/05/16 18:32
Armadillo 环境配置
Armadillo是一款对于C++的线性代数库,可以进行矩阵运算,在MATLAB转C/C++时可以更加方便。下面是armadillo的安装和配置。
首先,下载armadillo,地址(http://arma.sourceforge.net/)。
这里选择稳定版本armadillo-8.100.1,解压,将其中的include文件夹复制到指定的文件夹下。(这里将其拷贝至D:/Armadillo)
修改D:\Armadillo\include\armadillo_bits中的config.hpp
取消以下两句中的注释符号,如上图所示。
#define ARMA_USE_LAPACK
#define ARMA_USE_BLAS
这样表示使用LAPACK和BLAS两个库。1
BLAS的官方文档介绍:
The BLAS (Basic Linear Algebra Subprograms)are routines that provide standard building blocks for performing basic vectorand matrix operations. The Level 1 BLAS perform scalar, vector andvector-vector operations, the Level 2 BLAS perform matrix-vector operations,and the Level 3 BLAS perform matrix-matrix operations. Because the BLAS areefficient, portable, and widely available, they are commonly used in thedevelopment of high quality linear algebra software, LAPACK for example.
LAPACK的官方文档介绍:
LAPACK is written in Fortran 90 and providesroutines for solving systems of simultaneous linear equations, least-squaressolutions of linear systems of equations, eigenvalue problems, and singularvalue problems. The associated matrix factorizations (LU, Cholesky, QR, SVD,Schur, generalized Schur) are also provided, as are related computations suchas reordering of the Schur factorizations and estimating condition numbers.Dense and banded matrices are handled, but not general sparse matrices. In allareas, similar functionality is provided for real and complex matrices, in bothsingle and double precision.
需要下载LAPACK和BLAS两个库,实际上armadillo自带这两个库,在.\armadillo-8.100.1\examples\lib_win64中,但是是64位,因此需要下载32位的这两个库。
下载完成后,在visual studio中配好lib目录,include目录,附加依赖项。(配置方法类似上文opencv库的配法)。运行程序,出错。报错如下:
提示没有lapack32位的动态链接库dll文件。下载lapack_win32_MTd.dll和blas_win32_MTd.dll以及不带d的版本(release版)的dll,拷贝至指定目录,此处是Windows中的SysWOW64。再运行程序,点击生成解决方案,查看结果。
例程:
#include<opencv2/opencv.hpp>#include <armadillo>#include <iostream>using namespace cv;using namespace arma;using namespace std;int main(){ arma::matA = arma::randu<mat>(5,5); cout<<"A= "<<A<<endl; cout<<"det(A)= "<<arma::det(A)<<endl; cv::Matimg = cv::imread("test.jpg",1); cv::Matgrey; cv::cvtColor(img,grey, CV_BGR2GRAY); cv::Matsobelx; cv::Sobel(grey,sobelx, CV_32F, 1, 0); double minVal, maxVal; cv::minMaxLoc(sobelx,&minVal, &maxVal); //find minimum and maximum intensities cv::Matdraw; sobelx.convertTo(draw,CV_8U, 255.0/(maxVal - minVal), -minVal * 255.0/(maxVal - minVal)); cv::namedWindow("src",CV_WINDOW_AUTOSIZE); cv::imshow("src",img); cv::namedWindow("dst",CV_WINDOW_AUTOSIZE); cv::imshow("dst",draw); cv::waitKey(); return 0; }
该例程即再上文中测试opencv的基础上,include进armadillo,并且using namespace arma;注意,由于armadillo和opencv中都有Mat类型,因此同时usingnamespace cv 和arma会出现冲突,因此需要域运算符。
结果如下(只显示console中的结果):
成功啦~哈哈哈
附录:MATLAB和armadillo的转换关系
Reference:
http://arma.sourceforge.net/docs.htmlhttp://www.netlib.org/blas/http://www.netlib.org/lapack/
- 【注:LAPACK是LinearAlgebra PACKage的缩写,由其官方文档(如下)可以看出,LAPACK可以解决线性方程,最小二乘法,特征值分解,以及各类矩阵分解,如LU,QR,Cholesky,svd等。而BLAS是Basic Linear Algebra Subprograms的缩写,可以看出,BLAS提供较为底层的矢量和矩阵运算,Level1标量,矢量,矢量-矢量,Level2 矢量-矩阵,Level3 矩阵-矩阵,LAPACK也是基于BLAS】 ↩
- Win7系统Visual Studio下的armadillo环境配置
- Win7系统Visual Studio下的openCV环境配置
- Armadillo 在Windows 环境下的配置
- Win7 +CUDA5.0 + Visual Studio 2010 的环境配置
- win7+vs2010+armadillo, armadillo的安装与配置
- Visual Studio 2013+ Armadillo win32和x64平台下配置步骤
- windows7系统上Visual Studio Ultimate 2013环境下Zeromq的安装配置
- OpenCV 3.3使用CMake 3.9.2和Visual Studio 2017配置win7 32位系统的开发环境
- windows环境下配置Visual Studio的cl编译器
- Visual Studio下OpenCV最完美的环境配置方法
- Visual Studio下OpenCV最完美的环境配置方法
- Win7/Win8 64位系统下为Visual Studio 2013配置OpenCV 2.4.9
- Win7/Win8 64位系统下为Visual Studio 2013配置OpenCV 2.4.9
- win7系统下Microsoft visual studio 2013+opencv2.4.13配置及运行
- win7 Visual Studio 2010 配置opencv 2.4.5 开发环境
- 新手一步一步OpenCV+Win7+Visual Studio 2013环境配置
- win7 64bit visual studio 2013环境 PCL 的安装与配置
- Win7系统Visual Studio 2013配置OpenCV3.1图文详解
- 安装Eclipse中报Java was started but returned exit code = 13 OR 提示查看日志log错误的方法
- 怎么给TFS添加新用户,并授予某项目权限
- Two Sum
- LWC 58:724. Find Pivot Index
- 原来这些网站功能这么强?做梦都没想到那些软件都不是他的对手!
- Win7系统Visual Studio下的armadillo环境配置
- golang基础-模板渲染(终端、浏览器)、渲染输出文件、自定义io.Writer渲染
- 整理烂笔记本的笔记
- 关于项目中图片缓存的问题
- android中通过代码实现文件权限修改
- 程序员25部iPhoneX求婚,告诉你有多豪
- faster rcnn在自己的数据集上训练
- NYOJ G : 你说啥,又让我做A+B?
- iOS开发-NSOperation和NSOperationQueue的使用