def cubic(theta, d):
 theta = np.asarray(theta, dtype=np.float64)
 d = np.asarray(d, dtype=np.float64)
 if (d.ndim > 1):
  n_features = d.shape[1]
 else:
  n_features = 1
 lth = theta.size
 if (lth == 1):
  td = (np.abs(d) * theta)
 elif (lth != n_features):
  raise Exception(('Length of theta must be 1 or ' + str(n_features)))
 else:
  td = (np.abs(d) * theta.reshape(1, n_features))
 td[(td > 1.0)] = 1.0
 ss = (1.0 - ((td ** 2.0) * (3.0 - (2.0 * td))))
 r = np.prod(ss, 1)
 return r

def cubic ( theta , d ) : theta = np . asarray ( theta , dtype = np . float64 ) d = np . asarray ( d , dtype = np . float64 ) if ( d . ndim > 1 ) : n_features = d . shape [ 1 ] else : n_features = 1 lth = theta . size if ( lth == 1 ) : td = ( np . abs ( d ) * theta ) elif ( lth != n_features ) : raise Exception ( ( 'Length of theta must be 1 or ' + str ( n_features ) ) ) else : td = ( np . abs ( d ) * theta . reshape ( 1 , n_features ) ) td [ ( td > 1.0 ) ] = 1.0 ss = ( 1.0 - ( ( td ** 2.0 ) * ( 3.0 - ( 2.0 * td ) ) ) ) r = np . prod ( ss , 1 ) return r
a cubic b-spline .