A while ago I was looking for a matrix spasity viewer outside Matlab. Furthermore, the result in eps format will be a help.
The following example code write the spasity pattern to an eps file - some usefull tipps on eps/ps can be found at: PS-FORMAT
program drspy
implicit none
integer,dimension(50,50) :: a
integer :: i,j,m,n
m = size(a,1)
n = size(a,2)
a = 0
do j=1,n
do i=1,j
a(i,j) = 1;
enddo
enddo
call spy(a,m,n)
end program drspy
subroutine spy(a,m,n)
implicit none
integer,dimension(m,n) :: a
real,parameter :: cell_size=10.0
real,parameter :: font_size=0.8*cell_size
real,parameter :: r= 0.35*font_size
integer,parameter :: io=33
real :: x_lo,x_hi,y_lo,y_hi
real :: scale,x,y
integer :: m,n,i,j
x_lo = 0;
y_lo = 0;
x_hi = n*cell_size;
y_hi = m*cell_size;
open(io,file='spy.ps');
write(io,'(A)') '%!PS-Adobe-1.0'
if (cell_size*real(n) > 595.0) then
scale = 595.0/(cell_size*real(n));
write(io,'(A,4I5)') '%%BoundingBox:',0,0,595,595
write(io,'(2F13.6,A)') 0.0,0.0,'translate'
write(io,'(2F13.6,A)') scale,scale,'scale'
else
write(io,'(A,4F13.6)') '%%BoundingBox',x_lo,y_lo,x_hi,y_hi
endif
write(io,'(2F13.6,2x,A)') x_lo,y_lo,'newpath moveto'
write(io,'(2F13.6,2x,A)') x_hi,y_lo,'lineto'
write(io,'(2F13.6,2x,A)') x_hi,y_hi,'lineto'
write(io,'(2F13.6,2x,A)') x_lo,y_hi,'lineto'
write(io,'(2F13.6,2x,A)') x_lo,y_lo,'lineto'
write(io,'(A)') 'stroke'
do j=1,n
do i=1,m
if (a(i,j) > 0) then
x = x_lo + (real(j) - 0.5)*cell_size;
y = y_hi - (real(i) - 0.5)*cell_size;
write(io,'(3F13.6,2I5,2x,A)') x,y,r,0,360,'arc closepath'
write(io,'(A)') 'gsave fill grestore'
write(io,'(A)') 'stroke'
endif
enddo
enddo
write(io,'(A)') 'showpage'
write(io,'(A)') '%%EOF'
close(io);
return
end subroutine spy
[URL=http://imageshack.us/photo/my-images/38/spyfx.jpg/]
[/URL]
[/URL]
[/URL]