问题描述
我一直在寻找有关blas的体面文档,但发现315页密集的材料无法使用ctrl-f.它提供了有关例程采用哪些输入参数的所有信息,但是有很多输入参数,我确实可以使用一些示例代码.我找不到任何东西.我知道必须有一些或没有人能够使用这些库!
I have been searching for decent documentation on blas, and I have found some 315 pages of dense material that ctrl-f does not work on. It provides all the information regarding what input arguments the routines take, but there are a LOT of input arguments and I could really use some example code. I am unable to locate any. I know there has to be some or no one would be able to use these libraries!
具体来说,我使用在Mac osx 10.5.8上通过macports安装的ATLAS,并且我使用了来自gcc 4.4的gfortran(也通过macports安装).我正在使用Fortran 90进行编码.我对Fortran还是很陌生,但是我在mathematica,matlab,perl和Shell脚本编写方面有相当丰富的经验.
Specifically, I use ATLAS installed via macports on a mac osx 10.5.8 and I use gfortran from gcc 4.4 (also installed via macports). I am coding in Fortran 90. I am still quite new to Fortran, but I have a fair amount of experience with mathematica, matlab, perl, and shell scripting.
我希望能够通过密集的对称(但不是埃尔米特式)复数矩阵来初始化密集的复数向量并对其进行乘积.矩阵的元素是通过索引的数学函数定义的-称为f(i,j).
I would like to be able to initialize and multiply a dense complex vector by a dense symmetric (but not hermitian) complex matrix. The elements of the matrix are defined through a mathematical function of the indices--call it f(i,j).
任何人都可以提供一些代码或某些代码的链接吗?
Could anyone provide some code or a link to some code?
推荐答案
从 http://www.netlib开始.org/blas/,您会看到您要查找的例程是zgemv,此处 http://www.netlib.org/blas/zgemv.f -这是一个复数('z')矩阵('m')向量('v')乘法.
Starting with http://www.netlib.org/blas/, you see that the routine you're looking for is zgemv, here http://www.netlib.org/blas/zgemv.f --- it's a complex ('z') matrix ('m') vector ('v') multiply.
如果向量只是普通数组,即它们在内存中是连续的,则INCX和INCY参数仅为1.就LDA参数而言,只需使其等于矩阵大小即可.其他参数很简单.例如:
If your vectors are just normal arrays, i.e. they are contiguous in memory, then INCX and INCY arguments are just 1. As far as LDA parameter is concerned, just keep it equal to the matrix size. Other parameters are straightforward. For example:
implicit none
integer, parameter :: N=2
complex*16, parameter :: imag1 = cmplx(0.d0, 1.d0)
complex*16 :: a(N,N), x(N), y(N)
complex*16 :: alpha, beta
a(:,:)=imag1;
x(:)=1.d0
y(:)=0.d0
alpha=1.d0; beta=0.d0
call zgemv('N',N,N,alpha,a,N,x,1,beta,y,1)
print*, y
end
通常,每次我需要BLAS或LAPACK例程时,都会在netlib上查找参数.
In general, every time I need a BLAS or LAPACK routine, I look up the parameters on netlib.
上面的代码没有使用矩阵对称的事实.如果需要,请查找zsymv
例程. (感谢@MRocklin.)
the code above doesn't use the fact that your matrix is symmetric. If you want that, then look up the zsymv
routine. (Thanks to @MRocklin.)
这篇关于在哪里可以找到BLAS示例代码(在Fortran中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!