On Wed, Nov 16, 2011 at 02:08:45PM +0100, Waldek Hebisch wrote:
> Serge D. Mechveliani wrote:
> >
> > On Sat, Nov 12, 2011 at 10:06:23PM +0100, Ralf Hemmecke wrote:
> > > Instead of answering your questions in detail, how do you want to access
> > > the axiom library?
> >
> > For any occasion: this may will be only 20-30 concrete functions in
> > the Axiom library to which the interface is needed.
> > For example, about 95% constitute the functions such as
> > lc, lm, cont, coefficientToPolynomial, multiplyPolynomials ...
> > which are not needed, because DoCon has such of its own.
> > The interface is needed only to 20-30 concrete heavy-weight functions,
> > which set we call InterfFuncs =
> > {factorPolynomialOverInteger, factorPolynomialOverSuchAndSuchField,
> > solvePolynomialSystem, itergateSymbolically, sumSeries ...
> > }.
> [..]
>
> If you are satisfied with interfacing only to selected
> family of "heavy" functions, then you may consider
> socket interace: have FriCAS running as separate
> process and interchange data via sockets. You need
> to write routines to pack and unpack data on both
> sides of connection, but it is probably less work than
> other approaches.
I am thinking of this. I do not know what is a socket.
But let it be say, a file call.txt
The haskell function applies
factorPolynomialOverInteger f =
let
str = concat ["res = factorPolynomialOverInteger_axiom ",
show f, "; writeToFile \"result.txt\" res"
]
in putString "call.txt" str
(a contrived code, needs correction)
This puts the string printing of the Spad program
res = factorPolynomialOverInteger_axiom <f>;
writeToFile "result.txt" res
(a contrived code, needs correction) to the file call.txt.
The Axiom dialogue process is perpetually run and performs the command
loadFromFileAndEvaluate "call.txt"
When the end symbol of input appears in call.txt,
loadFromFileAndEvaluate starts, the input in str
(1) is parsed,
(2) compiled to Lisp (?),
(is the representation for f converted further than the Lisp data?)
(3) type-checked,
(4) interpreted,
but factorPolynomialOverInteger_axiom is applied as a binary,
because it is kept in the library as already compiled to binary,
the result res_lisp (Lisp representation for a list of polynomials)
is produced,
(5) the printing of res_lisp, with conversion to ..., it put to
result.txt
It this true? Please, comment this.
There are the following questions.
1. The client Haskell function may need to apply many times writing
to a file and reading from a file, and using the read value.
I never wrote such functions (which do not look functional) in
Haskell, except a trivial one "repeat input-evaluate-output".
May be, this can be arranged, may be by using the C interface ...
let us hope.
2. One needs to avoid parsing in Axiom and in Haskell, and to avoid
as much type check and compilation as possible.
For example, parsing
"factorPolynomialOverInteger_axiom (x^2 + x*y + y^3)"
and compiling to Lisp is, probably, much slower than its proper evaluation.
On the other hand, I believe, I know how to directly produce from Haskell
the Lisp data corresponding to f :: Pol Integer
(and for many other data too),
can write this conversion in Haskell (in both directions)
This needs to use a knowledge of how the data are represented in Axiom-Lisp
for each of the constructors
Vector, Matrix, Pol, Fraction, Residue, ... used in DoCon
I believe, this can be studied and used in conversion.
But how to put this Lisp data to the memory buffer for the call
evaluation at the Lisp data level in Axiom? Does such a buffer exist?
How to directly envocate the interpreter (Boot ?) with the Lisp data?
Will this save much of the performance cost?
Regards,
Sergei.
[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.