Changeset 48fbd50 in sasmodels for sasmodels/kerneldll.py


Ignore:
Timestamp:
Mar 21, 2016 6:02:51 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
25b30fd, 3a45c2c
Parents:
88aa3ee
Message:

twiddle with kernel interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kerneldll.py

    r445d1c0 r48fbd50  
    218218        self.dll = None 
    219219 
    220     def __call__(self, q_vectors): 
     220    def make_kernel(self, q_vectors): 
    221221        q_input = PyInput(q_vectors, self.dtype) 
    222222        if self.dll is None: self._load_dll() 
     
    251251    """ 
    252252    def __init__(self, kernel, model_info, q_input): 
     253        self.kernel = kernel 
    253254        self.info = model_info 
    254255        self.q_input = q_input 
    255256        self.dtype = q_input.dtype 
    256         self.kernel = kernel 
    257         self.res = np.empty(q_input.nq+3, q_input.dtype) 
    258257        self.dim = '2d' if q_input.is_2d else '1d' 
    259  
    260         # In dll kernel, but not in opencl kernel 
    261         self.p_res = self.res.ctypes.data 
     258        self.result = np.empty(q_input.nq+3, q_input.dtype) 
    262259 
    263260    def __call__(self, details, weights, values, cutoff): 
     
    265262                else np.float64 if self.q_input.dtype == generate.F64 
    266263                else np.float128) 
    267         if details.dtype != np.int32 or weights.dtype != real or values.dtype != real: 
    268             raise TypeError("numeric type does not match the kernel type") 
    269         #details = np.asarray(details, dtype='int32') 
    270         #weights = np.asarray(weights, dtype=real) 
    271         #values = np.asarray(values, dtype=real) 
    272         #TODO: How can I access max_pd and is this the way to do it? 
    273         #max_pd = model_info['max_pd'] 
    274         max_pd = 1 
     264        assert details.dtype == np.int32 
     265        assert weights.dtype == real and values.dtype == real 
     266 
     267        max_pd = self.info['max_pd'] 
     268        start, stop = 0, details[4*max_pd-1] 
    275269        args = [ 
    276270            self.q_input.nq, # nq 
    277             #TODO: pd_start will need to be changed 
    278             0, # pd_start 
    279             details[3*max_pd:4*max_pd], # pd_stop pd_stride[MAX_PD] 
     271            start, # pd_start 
     272            stop, # pd_stop pd_stride[MAX_PD] 
    280273            details.ctypes.data, # problem 
    281274            weights.ctypes.data,  # weights 
    282275            values.ctypes.data,  #pars 
    283             self.q_input.q_pointers[0], #q 
    284             self.p_res,   # results 
     276            self.q_input.q.ctypes.data, #q 
     277            self.result.ctypes.data,   # results 
    285278            real(cutoff), # cutoff 
    286279            ] 
    287280        self.kernel(*args) 
    288         return self.res[:-3] 
     281        return self.result[:-3] 
    289282 
    290283    def release(self): 
Note: See TracChangeset for help on using the changeset viewer.