|
|
last edited 11 months ago by test1 |
1 2 3 | ||
Editor: test1
Time: 2023/12/05 16:03:00 GMT+0 |
||
Note: |
changed: -option is needed to avoid failures due to mismatche autotools versions. option is needed to avoid failures due to mismatched autotools versions.
It is possible to use the Aldor compiler WebSite:www.aldor.org to compile functions which you then can use from FriCAS. Currently the following commands work and install Aldor in '/opt/aldor':
git clone https://github.com/aldorlang/aldor cd aldor/aldor ./configure --disable-maintainer-mode --prefix=/opt/aldor make > mlogg 2>&1 make install
Note: Newest Aldor is available only from Git repository. The --disable-maintainer-mode
option is needed to avoid failures due to mismatched autotools versions.
The FriCAS/Aldor interface is part of the current FriCAS source distribution. Ralf Hemmecke updated the work of Peter Broadbery and integrated it into FriCAS. In FriCAS you can now simply say:
./configure --enable-aldor && make && make install
which will compile a file libfricas.al and thus make it possible to use the Aldor compiler for FriCAS. Of course, you must have the latest aldor compiler installed.
If Aldor is installed in a nonstandard place then use --with-aldor-binary= option
. And
of course you can combine the above with other FriCAS configure options. So,
to build in directory fricas-build
parallel to source directory trunk
,
enablibg GMP support and using Aldor binary from /opt/aldor/bin/aldor
use:
../trunk/configure --enable-gmp --enable-aldor --with-aldor-binary=/opt/aldor/bin/aldor
Note: there were several changes in Aldor and FriCAS affecting the interface, older versions of Aldor do not work with newest FriCAS, older versions of FriCAS do not work with newest Aldor.
It is possible to use Aldor interface on MathAction including FriCASWiki. Instruction below describe how such usage is working.
This is a simple example of how to use Aldor on MathAction.
To compile an Aldor function, for example this non-recursive method to compute a factorial, in MathAction the Aldor code appears between \begin{aldor}[fact] ... \end{aldor} tags on the edit page.
(1) -> <aldor> #include "fricas.as"
fact(n: PositiveInteger): PositiveInteger == { n <= 1 => 1; res: PositiveInteger := 1; while n > 1 repeat { res := res * n; n := n-1; } res }</aldor>
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/fact.as using Aldor compiler and options -O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra Use the system command )set compiler args to change these options.
Compiling Lisp source code from file ./fact.lsp Issuing )library command for fact
Reading /var/aw/var/LatexWiki/fact.asy
The optional [name] parameter is used to name the compiled library
file which can be used later on another page in a )library
command.
Now call the function in FriCAS as you would any other. First get the library
)lib fact
Reading /var/aw/var/LatexWiki/fact.asy
Now we test it:
fact(11)
(1) |
sqrt(fact(13))
(2) |
If you care to, you can also look at the Aldor source generated lisp code and the final compiled result
Here is an example from WebSite:www.aldor.org/docs/HTML/chap18.html
#include "fricas.as" #pile
MatrixSymmetry(R:Field): with symmetricPart : Matrix R -> Matrix R ++ `symmetricPart(M)' returns a symmetric ++ matrix `S',computed as `(M + transpose M)/2'. ++ The difference `M - S' is antisymmetric.
antisymmetricPart : Matrix R -> Matrix R ++ `antisymmetricPart(M)' returns an antisymmetric ++ matrix `A',computed as `(M - transpose M)/2'. ++ The difference `M - A' is symmetric. == add import from R, Integer
symmetricPart(m: Matrix R): Matrix R == mt := transpose m inv(2::R) * (m + mt)
antisymmetricPart(m: Matrix R): Matrix R == mt := transpose m inv(2::R) * (m - mt)
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/9220782423898255697-25px004.as using Aldor compiler and options -O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra Use the system command )set compiler args to change these options. Compiling Lisp source code from file ./9220782423898255697-25px004.lsp Issuing )library command for 9220782423898255697-25px004 Reading /var/aw/var/LatexWiki/9220782423898255697-25px004.asy MatrixSymmetry is now explicitly exposed in frame initial MatrixSymmetry will be automatically loaded when needed from /var/aw/var/LatexWiki/9220782423898255697-25px004
m := matrix[[1/2,1/3], [1/4, 1/5]]
(3) |
s := symmetricPart(m)$MatrixSymmetry(Fraction(Integer))
(4) |
a := antisymmetricPart(m)$MatrixSymmetry(Fraction(Integer))
(5) |
See also the more complex examples:
Having put the following simple domain in a file test.as
::
#include "fricas.as"
Test: with { fact: PositiveInteger -> PositiveInteger } == add { fact(n: PositiveInteger): PositiveInteger == { n <= 1 => 1; res: PositiveInteger := 1; while n > 1 repeat { res := res * n; n := n-1; } res } }
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5434963794726606939-25px006.as using Aldor compiler and options -O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra Use the system command )set compiler args to change these options. Compiling Lisp source code from file ./5434963794726606939-25px006.lsp Issuing )library command for 5434963794726606939-25px006 Reading /var/aw/var/LatexWiki/5434963794726606939-25px006.asy Test is now explicitly exposed in frame initial Test will be automatically loaded when needed from /var/aw/var/LatexWiki/5434963794726606939-25px006
I compiled it with Aldor as above. In FriCAS you should do:
)co test.as
)sh Test
Test is a domain constructor. Abbreviation for Test is TEST This constructor is exposed in this frame. 1 Names for 1 Operations in this Domain. ------------------------------- Operations --------------------------------
fact : PositiveInteger -> PositiveInteger
fact(5)$Test
(6) |
Known Problems
see Issue # 229