문제

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!

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.

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?

도움이 되었습니까?

해결책

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.

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      

In general, every time I need a BLAS or LAPACK routine, I look up the parameters on netlib.

EDIT: 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.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top