On March 10, 2006 10:53 PM Donald J Bindner wrote:
I'm trying to learn a bit about compiling packages for Axiom, so
I chose a small task to cut my teeth on. I want to implement for
myself a simpler simpson()
function that does numerical
integration.
I've got a working package after browsing through numquad.spad
.
However the prototype for my function is:
simpson( Float->Float, Segment Float )
So I can perform calculations like:
simpson( x +-> 1/x, 1..2 )
However I'd like to use a syntax more similar to the way
integrate() works. I'd prefer to be able to execute:
simpson( 1/x, x=1..2 )
I've done a lot of browsing, but I can't figure out how this is
done.
I've tried to distill the core of my question into a small
example package. It contains two simple() functions. One works
fine, but the other won't compile. Suggestions would be welcome.
fricas
(1) -> <spad>
fricas
)abbrev package DONSIMP donSimple
--
-- Exports simple() function which takes 2 args,
-- Working behavior is: simple( x+->x^2, 1..2 ) = 3.0
-- Not working but intended behavior is:
-- simple( x^2, x=1..2 ) = 3.0
--
donSimple(): Exports == Implementation where
F ==> Float
SF ==> Segment F
EF ==> Expression F
SBF ==> SegmentBinding F
Exports ==> with
simple : (F->F,SF) -> F
simple : (EF,SBF) -> EF
Implementation ==> add
simple(func:F->F, sf:SF ) ==
a : F := low(sf)
b : F := high(sf)
func(b) - func(a)
simple(func:EF, sbf:SBF) ==
a : F := low(segment(sbf))
b : F := high(segment(sbf))
x : Symbol := variable(sbf)
eval(func, kernel(x), b::EF) - eval(func, kernel(x), a::EF)</spad>
fricas
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1943595969622990287-25px001.spad
using old system compiler.
DONSIMP abbreviates package donSimple
------------------------------------------------------------------------
initializing NRLIB DONSIMP for donSimple
compiling into NRLIB DONSIMP
compiling exported simple : (Float -> Float,Segment Float) -> Float
Time: 0 SEC.
compiling exported simple : (Expression Float,SegmentBinding Float) -> Expression Float
Time: 0.04 SEC.
(time taken in buildFunctor: 0)
;;; *** |donSimple| REDEFINED
;;; *** |donSimple| REDEFINED
Time: 0 SEC.
Cumulative Statistics for Constructor donSimple
Time: 0.05 seconds
finalizing NRLIB DONSIMP
Processing donSimple for Browser database:
--->-->donSimple(constructor): Not documented!!!!
--->-->donSimple((simple ((Float) (Mapping (Float) (Float)) (Segment (Float))))): Not documented!!!!
--->-->donSimple((simple ((Expression (Float)) (Expression (Float)) (SegmentBinding (Float))))): Not documented!!!!
--->-->donSimple(): Missing Description
; compiling file "/var/aw/var/LatexWiki/DONSIMP.NRLIB/DONSIMP.lsp" (written 07 APR 2024 06:19:18 AM):
; wrote /var/aw/var/LatexWiki/DONSIMP.NRLIB/DONSIMP.fasl
; compilation finished in 0:00:00.012
------------------------------------------------------------------------
donSimple is now explicitly exposed in frame initial
donSimple will be automatically loaded when needed from
/var/aw/var/LatexWiki/DONSIMP.NRLIB/DONSIMP
fricas
simple(1/x,x=2..3)
Type: Expression(Float)