up [pdf]
from rsf.proj import *


### Float Test #####

Flow('mat0',None,
     '''
     echo
     1 1 1 0
     1 2 0 0
     1 3 1 0
     1 4 0 1
     1 5 1 1
     in=$TARGET
     data_format=ascii_float
     n1=4
     n2=5
     ''')
Flow('mat','mat0','dd form=native')

Flow('y0',None,
     '''
     echo 3 3 5 7 9
     in=$TARGET
     data_format=ascii_float
     n1=5
     ''')
Flow('y','y0','dd form=native')

Flow('x0',None,'spike n1=4')

Flow('x','y mat x0',
     'conjgrad matmult mat=${SOURCES[1]} mod=${SOURCES[2]} niter=6')

Result('x','graph symbol=* wanttitle=n wantaxis1=n symbolsz=10')

### Complex Test #####

Flow('cmat0',None,
     '''
     echo
     10 0i 1  1i 1  2i 1 3i
     1 -1i 9  0i 2  1i 2 2i
     1 -2i 2 -1i 8  0i 3 1i
     1 -3i 2 -2i 3 -1i 7 0i
     in=$TARGET
     data_format=ascii_complex
     n1=4
     n2=4
     ''')
Flow('cmat','cmat0','dd form=native')

Flow('cy0',None,
     '''
     echo
     27  27i
     39  -9i
     45   9i
     44 -32i
     in=$TARGET
     data_format=ascii_complex
     n1=4
     ''')
Flow('cy','cy0','dd form=native')

Flow('cx','cy cmat',
     'cconjgrad cmatmult mat=${SOURCES[1]} mod=${SOURCES[0]} niter=6')

Result('cx','graph symbol=* wanttitle=n symbolsz=10')

End()

sfdd
sfspike
sfconjgrad
sfmatmult
sfgraph
sfcconjgrad
sfcmatmult