Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/ellipsoid.py

    r2d81cfe r0168844  
    125125import numpy as np 
    126126from numpy import inf, sin, cos, pi 
     127 
     128try: 
     129    from numpy import cbrt 
     130except ImportError: 
     131    def cbrt(x): return x ** (1.0/3.0) 
    127132 
    128133name = "ellipsoid" 
     
    170175    idx = radius_polar < radius_equatorial 
    171176    ee[idx] = (radius_equatorial[idx] ** 2 - radius_polar[idx] ** 2) / radius_equatorial[idx] ** 2 
    172     idx = radius_polar == radius_equatorial 
    173     ee[idx] = 2 * radius_polar[idx] 
    174     valid = (radius_polar * radius_equatorial != 0) 
     177    valid = (radius_polar * radius_equatorial != 0) & (radius_polar != radius_equatorial) 
    175178    bd = 1.0 - ee[valid] 
    176179    e1 = np.sqrt(ee[valid]) 
     
    179182    b2 = 1.0 + bd / 2 / e1 * np.log(bL) 
    180183    delta = 0.75 * b1 * b2 
    181  
    182     ddd = np.zeros_like(radius_polar) 
    183     ddd[valid] = 2.0 * (delta + 1.0) * radius_polar * radius_equatorial ** 2 
    184     return 0.5 * ddd ** (1.0 / 3.0) 
     184    ddd = 2.0 * (delta + 1.0) * (radius_polar * radius_equatorial**2)[valid] 
     185 
     186    r = np.zeros_like(radius_polar) 
     187    r[valid] = 0.5 * cbrt(ddd) 
     188    idx = radius_polar == radius_equatorial 
     189    r[idx] = radius_polar[idx] 
     190    return r 
    185191 
    186192def random(): 
Note: See TracChangeset for help on using the changeset viewer.