00001 """/*! 00002 @page ExampleSet2 Integrate a new Linear Operator 00003 00004 This examples is for a SLIMpy user who is familiar with the SLIMpy 00005 vector and linear operator API. 00006 In this example I will go through the steps to create a new linear operator in SLIMpy. 00007 00008 \par Learing objectives: 00009 - Add a new Linear Operator to SLIMpy 00010 - Gain more understanding about SLIMpy's AST 00011 00012 00013 \par Inputs: 00014 - None so far 00015 \par Python Modules: 00016 - new_fft_slimpy.py contains a slimpy fft linear operator 00017 - new_fft_rsf_integration.py contains the rsf definition of the fft operator 00018 00019 \par Outputs: 00020 - None so far 00021 \par Prerequisite: 00022 - SLIMpy and ContribSLIMpy 00023 - Madagascar 00024 - SCons 00025 00026 @section Walkthrough 00027 There are two parts to createing a linear operator in SLIMpy: 00028 - A Python class that represents the operator in SLIMpy, found in new_fft_slimpy.py 00029 - A Python class that defines how a plugin may use the operator, found in new_fft_rsf_integration.py 00030 00031 In this example the operator class will be an fft transfrom and the plugin definition will be RSF. 00032 We need to import both of those python modules to get a working linear operator in RSF. if we neglected to 00033 import new_fft_rsf_integration.py the code would give us an error when it tries to execute the fft1X executable 00034 which does not exist. Since fft1X is not defined in SLIMpy's RSF plugin, SLIMpy uses its best 00035 guess on how to use fft1X with RSF. 00036 00037 Try it yourself in interactive python mode with the fft1X do not import new_fft_rsf_integration. You will 00038 see that fft1X is a fully formed linear operotor. Without the rsf information SLIMpy will not give you error 00039 checking when the operator is created or applied, and the domain is known but the range is not. the range of the 00040 operator will become an instance of the voidSpace class. 00041 */""" 00042 00043 import new_fft_rsf_integration 00044 from new_fft_slimpy import fft1X 00045 from slimproj import * 00046 00047 from rsfproj import * 00048 00049 @slim_builder_simple 00050 def new_fft_bldr( vectors ): 00051 """ 00052 use our new fft operator 00053 """ 00054 z = vectors[0] 00055 00056 00057 F = fft1X( z.space, sym=True, opt=False ) 00058 00059 x = F*z 00060 00061 print x 00062 print repr(x.space) 00063 import pdb 00064 pdb.set_trace() 00065 nrm = x.norm( 1 ) 00066 00067 tmp = x - nrm 00068 00069 res = F.adj( ) * tmp 00070 00071 return res 00072 00073 Flow( 'newfoo', None, 'sfsigmoid n1=128 n2=128' ) 00074 00075 new_fft_bldr( 'res', 'newfoo' ) 00076