Thank you for these remarks.

Yes, I realise that nested anonymous functions using "+->" now works
in the current svn.
As an aside, I did begin to appreciate the use of the #1 notation.

The ability to call Spad and Axiom functions from Lisp is very
interesting, as it would
allow the use of Lisp numerical code without hand-translating from
Lisp to Spad/Axiom.
I have shown an example on the Axiom wiki that makes Lisp functions
from interpreter
expressions and Spad functions (http://axiom-wiki.newsynthesis.org/
SandBoxNewtonsMethod);
the former case is a hack of the MakeUnaryCompiledFunction package by
Manuel Bronstein, while
the latter case uses the Lisp function:

)lisp (defun |lispFunctionFromSpad| (f dom args) (let ((spadf (|
getFunctionFromDomain| f (list
dom) args))) (lambda (x) (spadcall x spadf))))

which is as suggested by contrib/load-fricas.lisp.

Is there any way to use getFunctionFromDomain() (or a similar
function) to obtain a local mode map
from _within_ a Spad package. As pseudo-code, with pseudo-function
getFunctionFromLocalDomain():

-- lisp code for Newton's method (as an example of numerical Lisp
code)
)lisp (defun newton (f dfdx x0 &optional (tol 1.0d-10)) (let ((xt x0)
(fxt (funcall f x0))
(maxit 100) (iternum 0)) (loop (setf xt (- xt (/ fxt (funcall dfdx
xt)))) (setf fxt (funcall f
xt)) (if (< (abs fxt) tol) (return xt)) (incf iternum) (if (>= iternum
maxit) (error
"Maximum iterations exceeded.")))))

-- Spad code for the square root of 2 using Newton's method
)abbrev package TESTP TestPackage
R ==> DoubleFloat
TestPackage: with
    f:R -> R
    dfdx:R -> R
    root:R->R
  == add
    f(x) == x*x - 2.0::R
    dfdx(x) == 2.0::R*x
    root(x0) ==
        NEWTON(getFunctionFromLocalDomain(f,['DoubleFloat])$Lisp,
               getFunctionFromLocalDomain(dfdx,['DoubleFloat])$Lisp,
               x0)$Lisp

Note that I first coded Newton's method in Axiom and then back-
translated to Lisp :-)

With kind regards, Mark Clements.

On Apr 10, 6:53 am, Waldek Hebisch <[email protected]> wrote:
> Bill Page wrote:
>
> > Dear panAxiom Developers,
>
> > On the Axiom-Wiki website at
>
> >http://axiom-wiki.newsynthesis.org/SandBoxFisher
>
> > Mark Clements writes:
>
> > "How useful are the different CAS languages for implementing numerical
> > routines? Prompted by a comparison of R and C for implementing
> > Fisher's exact test for 2x2 tables
> > (http://fluff.info/blog/arch/00000172.htm), I thought that it would be
> > interesting to implement this particular test in Spad, Boot, Reduce
> > and Common Lisp (see below). Each set of code was required to
> > implement a univariate root finder and the hypergeometric distribution
> > to calculate the p-value under different alternatives, together with
> > the 95% confidence interval and the maximum likelihood estimator for
> > the odds ratio. The reference implementation is R, ...
>
> > As a caveat: I have little experience with these programs. Any changes
> > or improvements to the programs would be welcomed."
>
> > Thank you, Mark! I think this is a great contribution.
>
> > Of course any comparison like is inevitably biased by the previous
> > experience and skill of the programmer. I think Mark has done a pretty
> > good job of the coding but there are some obvious improvements and/or
> > changes in style that could be made. Besides Mark's original goal, I
> > think there are several ways in which a comparison like this might be
> > useful to others, not the least of which is to serve as a way of
> > learning more about the alternative of using of Boot and Lisp in
> > panAxiom. If you have some time available, I hope you will take Mark
> > up on his invitation to suggest changes or improvements to his
> > programs.
>
> Some remarks:
>
> - in current svn just using nested functions should work, no need
>   to use version with #1
> - while calling Spad from Lisp is a bit more complicated than Lisp
>   calls, it is not that hard, see contrib/load-fricas.lisp.
>   Similarly one can call Spad from Boot.
>
> --
>                               Waldek Hebisch
> [email protected]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to