Changes in / [d148fbc:c0c3393] in sasmodels
- Location:
- sasmodels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r303d8d6 r7ff3cf3 226 226 weights = np.array([1.0]) 227 227 details = kernel.info['mono_details'] 228 return kernel( pars, weights, details, cutoff)228 return kernel(details, pars, weights, cutoff) 229 229 else: 230 230 pairs = [get_weights(p, values) for p in kernel.info['parameters']] … … 232 232 details = generate.poly_details(kernel.info, weights, pars) 233 233 weights, pars = [np.hstack(v) for v in (weights, pars)] 234 return kernel( pars, weights, details, cutoff)234 return kernel(details, pars, weights, cutoff) 235 235 236 236 def call_ER_VR(model_info, vol_pars): -
sasmodels/generate.py
r4a72d1a r7ff3cf3 650 650 model_info['has_2d'] = par_type['orientation'] or par_type['magnetic'] 651 651 652 def mono_details(max_pd, npars): 652 def mono_details(model_info): 653 max_pd = model_info['max_pd'] 654 npars = len(model_info['parameters']) - 2 653 655 p = 5*max_pd 654 656 c = p + 3*npars 655 657 656 mono = np.zeros(c + 3, 'i')657 mono[0*max_pd:1*max_pd] = range(max_pd) # pd_par: arbitrary order; use first658 mono[1*max_pd:2*max_pd] = [1]*max_pd # pd_length: only one element659 mono[2*max_pd:3*max_pd] = range(2, max_pd+2) # pd_offset: skip scale and background660 mono[3*max_pd:4*max_pd] = [1]*max_pd # pd_stride: vectors of length 1661 mono[4*max_pd:5*max_pd] = [0]*max_pd # pd_isvol: doens't matter if no norm662 mono[p+0*npars:p+1*npars] = range(2, npars+2) # par_offset663 mono[p+1*npars:p+2*npars] = [0]*npars # no coordination664 # mono[p+npars] = 1 # par_coord[0] is coordinated with the first par?665 mono[p+2*npars:p+3*npars] = 0 # fast coord with 0666 mono[c] = 1 # fast_coord_count: one fast index667 mono[c+1] = -1 # theta_var: None668 mono[c+2] = 0 # fast_theta: False669 return mono670 671 def poly_details(model_info, weights, pars,constraints=None):658 details = np.zeros(c + 3, 'int32') 659 details[0*max_pd:1*max_pd] = range(max_pd) # pd_par: arbitrary order; use first 660 details[1*max_pd:2*max_pd] = [1]*max_pd # pd_length: only one element 661 details[2*max_pd:3*max_pd] = range(2, max_pd+2) # pd_offset: skip scale and background 662 details[3*max_pd:4*max_pd] = [1]*max_pd # pd_stride: vectors of length 1 663 details[4*max_pd:5*max_pd] = [0]*max_pd # pd_isvol: doens't matter if no norm 664 details[p+0*npars:p+1*npars] = range(2, npars+2) # par_offset 665 details[p+1*npars:p+2*npars] = [0]*npars # no coordination 666 #details[p+npars] = 1 # par_coord[0] is coordinated with the first par? 667 details[p+2*npars:p+3*npars] = 0 # fast coord with 0 668 details[c] = 1 # fast_coord_count: one fast index 669 details[c+1] = -1 # theta_var: None 670 details[c+2] = 0 # fast_theta: False 671 return details 672 673 def poly_details(model_info, weights, constraints=None): 672 674 if constraints is not None: 673 675 # Need to find the independently varying pars and sort them … … 676 678 # and weights, returning par blocks 677 679 raise ValueError("Can't handle constraints yet") 680 681 max_pd = model_info['max_pd'] 682 npars = len(model_info['parameters']) - 2 683 p = 5*max_pd 684 c = p + 3*npars 685 686 # Decreasing list of polydispersity lengths 687 # Note: the reversing view, x[::-1], does not require a copy 688 idx = np.argsort([len(w) for w in weights])[::-1] 689 details = np.zeros(c + 3, 'int32') 690 details[0*max_pd:1*max_pd] = idx[:max_pd] # pd_par: arbitrary order; use first 691 details[1*max_pd:2*max_pd] = [1]*max_pd # pd_length: only one element 692 details[2*max_pd:3*max_pd] = range(2, max_pd+2) # pd_offset: skip scale and background 693 details[3*max_pd:4*max_pd] = [1]*max_pd # pd_stride: vectors of length 1 694 details[4*max_pd:5*max_pd] = [0]*max_pd # pd_isvol: doens't matter if no norm 695 details[p+0*npars:p+1*npars] = range(2, npars+2) # par_offset 696 details[p+1*npars:p+2*npars] = [0]*npars # no coordination 697 #details[p+npars] = 1 # par_coord[0] is coordinated with the first par? 698 details[p+2*npars:p+3*npars] = 0 # fast coord with 0 699 details[c] = 1 # fast_coord_count: one fast index 700 details[c+1] = -1 # theta_var: None 701 details[c+2] = 0 # fast_theta: False 702 return details 703 704 678 705 679 706 raise ValueError("polydispersity not supported") … … 768 795 oldpars=getattr(kernel_module, 'oldpars', {}), 769 796 tests=getattr(kernel_module, 'tests', []), 770 mono_details = mono_details(MAX_PD, len(kernel_module.parameters))771 797 ) 772 798 process_parameters(model_info) … … 775 801 model_info.update((k, getattr(kernel_module, k, None)) for k in functions) 776 802 create_default_functions(model_info) 803 # Precalculate the monodisperse parameters 804 # TODO: make this a lazy evaluator 805 # make_model_info is called for every model on sasview startup 806 model_info['mono_details'] = mono_details(model_info) 777 807 return model_info 778 808 -
sasmodels/kernel_iq.c
re1bdc7e r7ff3cf3 50 50 ) 51 51 { 52 printf("aliasing\n");53 52 // Storage for the current parameter values. These will be updated as we 54 53 // walk the polydispersity cube. … … 56 55 double *pvec = (double *)(&local_pars); // Alias named parameters with a vector 57 56 58 printf("allocating\n");59 57 local int offset[NPARS-2]; 60 58 61 59 #if 1 // defined(USE_SHORTCUT_OPTIMIZATION) 62 printf("dereferencing %p as %d\n", problem, problem->pd_length[0]);63 60 if (problem->pd_length[0] == 1) { 64 61 // Shouldn't need to copy!! -
sasmodels/kerneldll.py
r4a72d1a r7ff3cf3 50 50 import tempfile 51 51 import ctypes as ct 52 from ctypes import c_void_p, c_int , c_longdouble, c_double, c_float52 from ctypes import c_void_p, c_int32, c_longdouble, c_double, c_float 53 53 54 54 import numpy as np … … 205 205 206 206 # int, int, int, int*, double*, double*, double*, double*, double*, double 207 argtypes = [c_int ]*3 + [c_void_p]*5 + [fp]207 argtypes = [c_int32]*3 + [c_void_p]*5 + [fp] 208 208 self.Iq = self.dll[generate.kernel_name(self.info, False)] 209 209 self.Iqxy = self.dll[generate.kernel_name(self.info, True)]
Note: See TracChangeset
for help on using the changeset viewer.