Package analysis.C2Functions


Detailed Description

A group of classes which make it easy to manipulate smooth functions, including cubic splines.

Version:
Id
C2Functions.py,v 1.66 2007/11/21 16:18:00 mendenhall Exp

C2Functions know how to keep track of the first and second derivatives of functions, and to use this information in, for example, C2Function.find_root() and C2Function.partial_integrals() to allow much more efficient solutions to problems for which the general solution may be expensive.

The two primary classes are C2Function which represents an unevaluated function and its derivatives, and InterpolatingFunction which represent a cubic spline of provided data.

C2Functions can be combined with unary operators (nested/composed functions) or binary operators (+-*/ etc.)

Note that if SciPy is available, the C2Functions package will adopt useful bits from it to speed things up, but is otherwise not dependent on it.

Developed by Marcus H. Mendenhall, Vanderbilt University Keck Free Electron Laser Center, Nashville, TN USA

email: mendenhall@users.sourceforge.net

Work supported by the US DoD MFEL program under grant FA9550-04-1-0045


Classes

class  C2Exception
 Our own exception class. More...
class  RangeError
 Raised if an abscissa is out of range. More...
class  C2NakedFunction
 Raised if the base class C2Function is called without a valid value_with_derivatives(). More...
class  C2Function
 Provides support for the entire C2Function hierarchy. More...
class  C2ScaledFunction
 Create a function which is a simple scalar multiple of the parent. More...
class  C2Constant
 Create a function which is a constant. More...
class  _fC2sin
 Create a function which is the sine. Use the singleton C2Functions.C2sin to access this. More...
class  _fC2cos
 Create a function which is the cosine. Use the singleton C2Functions.C2cos to access this. More...
class  _fC2log
 Create a function which is the natural log. Use the singleton C2Functions.C2log to access this. More...
class  _fC2exp
 Create a function which is the e^x. Use the singleton C2Functions.C2exp to access this. More...
class  _fC2sqrt
 Create a function which is the square root. Use the singleton C2Functions.C2sqrt to access this. More...
class  C2ScaledRecip
 Create a function which is the scale /x. Use the singleton C2Functions.C2recip to access this as 1/x. More...
class  _fC2identity
 Create a function which is x. Use the singleton C2Functions.C2identity to access this. More...
class  C2Linear
 Create a function which is (x - x0)*slope + y0. More...
class  C2Quadratic
 Create a function which is a *(x - x0)**2 + b *(x - x0) + c. More...
class  C2PowerLaw
 Create a function which is ax**b. More...
class  C2Polynomial
 Create a function which is c0 + c1 (x-x0) + c2 (x-x0)^2 + ... More...
class  C2ComposedFunction
 create a composed function outer(inner(...)). The functions can either be unbound class names or class instances More...
class  C2BinaryFunction
 abstract class to create a binary function f (operator) g More...
class  C2Sum
 class to create function f + g More...
class  C2Diff
 class to create function f - g More...
class  C2Product
 class to create function f * g More...
class  C2Ratio
 class to create function f / g More...
class  C2Power
 class to create function f ** g with optimization if g is a constant More...
class  InterpolatingFunction
 the parent class for various interpolators. Does untransformed cubic splines by default. More...
class  LogLinInterpolatingFunction
 An InterpolatingFunction which stores log(x) vs. y. More...
class  LinLogInterpolatingFunction
 An InterpolatingFunction which stores x vs. log(y). More...
class  LogLogInterpolatingFunction
 An InterpolatingFunction which stores log(x) vs. log(y). More...
class  AccumulatedHistogram
class  LogLogAccumulatedHistogram
class  InverseIntegratedDensity
class  LinLogInverseIntegratedDensity
class  C2InverseFunction
class  C2ConnectorFunction
class  C2LHopitalRatio

Functions

def native
def _spline
 solve for the spline coefficients y''
def _spline_extension
 compute the correct coefficients and insert them to allow spline extrapolation
def _splint
 compute the interpolated value for a set of spline coefficients and either a scalar x or an array of x values
def _identity
def _one
def _zero
def _recip
def _mrecip2
def _myexp
def _mylog
def LinearInterpolatingGrid
 legacy...
def LogLogInterpolatingGrid
 legacy...
def as
def bessj
def bessj_adaptive

Variables

string _rcsid = "$Id: C2Functions.py,v 1.66 2007/11/21 16:18:00 mendenhall Exp $"
 _numeric_float = _numeric.float64
tuple C2sin = _fC2sin()
 a pre-constructed singleton
tuple C2cos = _fC2cos()
 a pre-constructed singleton
tuple C2log = _fC2log()
 a pre-constructed singleton
tuple C2exp = _fC2exp()
 a pre-constructed singleton
tuple C2sqrt = _fC2sqrt()
 a pre-constructed singleton
tuple C2recip = C2ScaledRecip()
 a pre-constructed singleton for 1/x
tuple C2identity = _fC2identity()
 a pre-constructed singleton identity
 _has_linalg = True
 LogConversions = _mylog,_recip,_mrecip2,_myexp
tuple ag = ag1LinearInterpolatingGrid(1, 1.0,4)
tuple ag13 = (ag1*ag1)
tuple fn = C2sin(C2sqrt(ag1*ag1*ag1))
tuple x1 = fn.find_root(0.0, 1.35128, 0.1, 0.995, trace=True)
float x = 0.1
tuple sna = C2sin(C2PowerLaw(1,2))
tuple xg = _numeric.array(range(sample), _numeric_float)
tuple partials = sna.partial_integrals(xg)
tuple sumsum = sum(partials)
tuple yg = sna(xg)
tuple simp = sum(sna.partial_integrals(xg, derivs=1))
float exact = 0.804776489343756110
int pc = 3
tuple b = math.exp(lv)
tuple np = int(pc*b)
tuple g = _numeric.array(range(np), _numeric_float)
tuple v0 = C2recip.partial_integrals(g, allow_recursion=False)
 n0 = C2recip.total_func_evals
tuple v1
 n1 = C2recip.total_func_evals
tuple v2
 n2 = C2recip.total_func_evals
tuple v3
 n3 = C2recip.total_func_evals
tuple yy = _numeric.exp(-xg[:-1]*xg[:-1])
tuple ah = AccumulatedHistogram(xg[::-1], yy[::-1], normalize=True)
tuple ahi = AccumulatedHistogram(xg, yy, normalize=True, inverse_function=True)
tuple xv = _numeric.array([1.5**(0.1*i) for i in range(100)])
tuple yv = _numeric.array([x**(-4)+0.25*x**(-3) for x in xv])
tuple f
tuple f0 = C2PowerLaw(1., -4)
tuple pp = f0.partial_integrals(_numeric.array(range(11), _numeric_float)*0.1 + 20)
list energies = [float(2**(0.5*n)) for n in range(41)]
list spect = [10000.0/(e*e) for e in energies]
list e0 = energies[-1]
list e1 = energies[0]
tuple pf = LinLogInverseIntegratedDensity(energies[::-1], spect[::-1])
tuple r = (0.025*i)
tuple mma = (e0*e1)
tuple grid = (0., 3., 6., 9., 12.)
tuple v = fn.GetSamplingGrid(xmin,xmax)
tuple sn = fn.NormalizedFunction(0., math.pi)
tuple gn = fn.SquareNormalizedFunction(0., 4.0*math.pi)
 fn2 = fn*fn
 gn2 = gn*gn
tuple myexp = _fC2exp()
tuple a = C2InverseFunction(myexp)


Generated on Wed Nov 21 10:18:31 2007 for analysis by  doxygen 1.5.4