-- PiecewiseCubic.mesa
-- Michael Plass 

PiecewiseCubic: CEDAR DEFINITIONS =
BEGIN

Handle: TYPE = LIST OF PieceRec; -- non-overlapping pieces in increasing order
PieceRec: TYPE = RECORD
       [domainStart, domainEnd: REAL,
	initValue, initSlope, finalSlope, finalValue: REAL];

Zero: PROCEDURE RETURNS [Handle];

Piece: PROCEDURE [domainStart, domainEnd: REAL,
		  initValue, initSlope, finalSlope, finalValue: REAL]
	RETURNS [Handle];

PieceProc: TYPE = PROCEDURE [p, q: PieceRec];

EnumerateCommonPieces: PROCEDURE [f: Handle, g: Handle, P: PieceProc] ;

Combine: PROCEDURE [a: REAL, f: Handle, b: REAL, g: Handle] RETURNS [Handle];
    -- calculates a*f + b*g

Eval: PROCEDURE [f: Handle, t: REAL] RETURNS [REAL];

EvalDeriv: PROCEDURE [f: Handle, t: REAL] RETURNS [REAL];

EvalDerivDeriv: PROCEDURE [f: Handle, t: REAL] RETURNS [REAL];

EvalAll: PROCEDURE [f: Handle, t: REAL] RETURNS [value,deriv,derivDeriv,derivDerivDeriv,domainStart,domainEnd: REAL];

END.