Skip to content

Instantly share code, notes, and snippets.

@mrocklin
Created October 24, 2012 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrocklin/3946486 to your computer and use it in GitHub Desktop.
Save mrocklin/3946486 to your computer and use it in GitHub Desktop.
Demonstrates the difference between TR and SY prefixed BLAS calls.
! Answers discussion in the following SO question
! http://stackoverflow.com/questions/4637888/where-can-i-find-blas-example-code-in-fortran/
! Author: Matthew Rocklin
! Disclaimer: This is my first Fortran program. Please do not judge.
implicit none
integer, parameter :: N=2
real*8 :: A(N,N), x(N), y(N)
real*8 :: alpha, beta
integer :: i, j
A(1,1) = 1
A(1,2) = 1
A(2,2) = 1
x(1) = 1
x(2) = 1
y(1) = 0
y(2) = 0
alpha = 1.d0
beta = 0.d0
call dsymv('U', N, alpha, A, N, x, 1, beta, y, 1)
call dtrmv('U','N', 'N', N, A, N, x, 1)
print*, x
print*, y
end
@mrocklin
Copy link
Author

Output

$ gfortran trsm.f90 -lblas
$ ./a.out 
   2.0000000000000000        1.0000000000000000     
   2.0000000000000000        2.0000000000000000     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment