login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

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.

Aldor on MathAction

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.

fricas
(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>
fricas
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.
fricas
Compiling Lisp source code from file ./fact.lsp
   Issuing )library command for fact
fricas
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

fricas
)lib fact
fricas
Reading /var/aw/var/LatexWiki/fact.asy

Now we test it:

fricas
fact(11)

\label{eq1}39916800(1)
Type: PositiveInteger?
fricas
sqrt(fact(13))

\label{eq2}{1440}\ {\sqrt{3003}}(2)
Type: AlgebraicNumber?

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

aldor
#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)
aldor
   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

fricas
m := matrix[[1/2,1/3],[1/4,1/5]]

\label{eq3}\left[ 
\begin{array}{cc}
{\frac{1}{2}}&{\frac{1}{3}}
\
{\frac{1}{4}}&{\frac{1}{5}}
(3)
Type: Matrix(Fraction(Integer))
fricas
s := symmetricPart(m)$MatrixSymmetry(Fraction(Integer))

\label{eq4}\left[ 
\begin{array}{cc}
{\frac{1}{2}}&{\frac{7}{24}}
\
{\frac{7}{24}}&{\frac{1}{5}}
(4)
Type: Matrix(Fraction(Integer))
fricas
a := antisymmetricPart(m)$MatrixSymmetry(Fraction(Integer))

\label{eq5}\left[ 
\begin{array}{cc}
0 &{\frac{1}{24}}
\
-{\frac{1}{24}}& 0 
(5)
Type: Matrix(Fraction(Integer))

See also the more complex examples:

More Examples

Having put the following simple domain in a file test.as ::

aldor
#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 } }
aldor
   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

fricas
)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

fricas
fact(5)$Test

\label{eq6}120(6)
Type: PositiveInteger?

Known Problems

see Issue # 229




  Subject:   Be Bold !!
  ( 14 subscribers )  
Please rate this page: