| 1 2 3 4 5 6 7 8 9 10 11 | ||
|
Editor: hemmecke
Time: 2008/08/04 08:47:38 GMT-7 |
||
| Note: | ||
It is possible to use the Aldor compiler WebSite:www.aldor.org to compile functions which you then can use Axiom. For details see:
Support for domains and packages is now in the testing stage. The Axiom/Aldor interface works with the open source version of Axiom (as of Patch-44) by Peter Broadbery. Thanks Peter! But note that the Aldor interface itself is not part of the current Axiom source distribution.
There is currently (August 2008) a branch in the FriCAS repository aldor-interface which builds an Aldor interface if at configure time the aldor binaries and some library (libfoam.al) are available. It works by:
./configure && make && make install
There is just one issue left that is connected to either the Aldor compiler or FriCAS. See Issues and links therein for more details.
A new version of Axiom based on axiom--main--1--Patch-44 and Peter's interface has been installed on MathAction including AxiomWiki. So you can use Aldor on this website.
For details about how to install the Axiom/Aldor interface, see
below. Note: As of Patch-46, the aldor.diff patches have been
included in the Axiom source distribution, but all other steps in
building Axiom with Aldor still apply.
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.
#include "axiom.as"
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/zope2/var/LatexWiki/fact.as using AXIOM-XL compiler and
options
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
Use the system command )set compiler args to change these
options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4:
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15:
import { true: %, false: % } from Boolean;
..................................^
[L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17:
string: Literal -> %;
........................^.......^
[L17 C25] #5 (Error) No meaning for identifier `Literal'.
[L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18:
} from String;
.......^
[L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/zope2/var/LatexWiki/fact.as", line 3:
fact(n: PositiveInteger): PositiveInteger == {
.....^..^
[L3 C6] #10 (Error) There are no suitable meanings for the operator `->'.
[L3 C9] #9 (Error) No meaning for identifier `PositiveInteger'.
[L3 C9] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.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 Axiom as you would any other. First get the library
)lib fact
Reading /var/zope2/var/LatexWiki/fact.asy
Now we test it:
fact(11)
>> System error: Cannot open the file /usr/local/lib/fricas/target/x86_64-unknown- linux/aldor/lib/runtime.
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 "axiom.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/zope2/var/LatexWiki/2504912445765138530-25px004.as using
AXIOM-XL compiler and options
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
Use the system command )set compiler args to change these
options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4:
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15:
import { true: %, false: % } from Boolean;
..................................^
[L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17:
string: Literal -> %;
........................^.......^
[L17 C25] #5 (Error) No meaning for identifier `Literal'.
[L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18:
} from String;
.......^
[L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/zope2/var/LatexWiki/2504912445765138530-25px004.as", line 4:
MatrixSymmetry(R:Field): with
.................^
[L4 C18] #9 (Error) No meaning for identifier `Field'.
"/var/zope2/var/LatexWiki/2504912445765138530-25px004.as", line 5:
symmetricPart : Matrix R -> Matrix R
.................................^..^
[L5 C34] #11 (Error) There are no suitable meanings for the operator `->'.
[L5 C37] #10 (Error) There are no suitable meanings for the operator `Matrix'.
[L5 C37] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.m := matrix[[1/2,1/3],[1/4,1/5]]
| (1) |
s := symmetricPart m
There are no library operations named symmetricPart Use HyperDoc Browse or issue )what op symmetricPart to learn if there is any operation containing " symmetricPart " in its name.
Cannot find a definition or applicable library operation named symmetricPart with argument type(s) Matrix(Fraction(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. a := antisymmetricPart m
There are no library operations named antisymmetricPart Use HyperDoc Browse or issue )what op antisymmetricPart to learn if there is any operation containing " antisymmetricPart " in its name.
Cannot find a definition or applicable library operation named antisymmetricPart with argument type(s) Matrix(Fraction(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.
See also the more complex examples:
(preliminary instructions)
We plan to (re-)integrate the linkage of Axiom with the Aldor as an optional part of the Axiom build in the next release of Axiom 3 beta. Until then to build Axiom with Aldor support you must do the following:
http://groups.google.at/group/fricas-devel/msg/86285212496f3545
If not, then upgrade your version of make or linux first:
$ make --version
GNU Make 3.80
Warning: GNU Make 3.81beta4, which seems to be the default on Kubuntu,
does not work!
WebSite:java.sun.com/j2se/1.5.0/download.jsp
It may be necessary to adjust symbolic links or the PATH to point to the correct version of java:
$ ls -l `which java`
lrwxrwxrwx 1 root root 30 Jun 3 22:00 /usr/bin/java -> /usr/java/jre1.5.0_06/bin/java
$ javac -version
$ javac 1.5.0_06
Be sure to set ALDORROOT and the PATH to Aldor properly for your system.
src_aldor2.tgz (Use Save as in your browser, in order to save a gzipped archive. Some browsers automatically unzip the file and store only a tar archive with extension .tgz.)
$ cd src
$ tar xzvf ~/src_aldor2.tgz
If your browser has already unzipped the archive, then leave out the z in the tar argument.
Issue the following commands:
$ cd aldor
$ document Makefile.pamphlet
$ make
make stops with an error message. The next two steps correct the problem:
$ touch ../../int/aldor/dep_spad.stamp
$ document Make.functions.pamphlet
newer Axiom+Aldor combinations seem to have an additional problem, which is avoided by commenting out (using the "#" character) line 70 (the @false statement) in src/aldor/libaxiom.mk (Note that this is not a real fix, it just lets the build continue.) Also look at a discussion in the mailing list
Now complete build of the Aldor interface:
$ make 2>&1 | tee aldor.log
The build might take up to 2 hours or some machines. There is some problem with the latex build in the Silver branch. So if you happen to see that your compilation stops, then just press ENTER twice.
into aldor/1.0.2/linux/include/ of your aldor (binary) distribution.
Congratulations! Now you should be able to compile Aldor files in Axiom.
fact.as
)co fact.as
fact(5)
Having put the following simple domain in a file test.as ::
#include "axiom.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/zope2/var/LatexWiki/4005392542604933580-25px006.as using
AXIOM-XL compiler and options
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
Use the system command )set compiler args to change these
options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4:
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15:
import { true: %, false: % } from Boolean;
..................................^
[L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17:
string: Literal -> %;
........................^.......^
[L17 C25] #5 (Error) No meaning for identifier `Literal'.
[L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18:
} from String;
.......^
[L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/zope2/var/LatexWiki/4005392542604933580-25px006.as", line 3:
Test: with { fact: PositiveInteger -> PositiveInteger }
...................^...............^..^
[L3 C20] #9 (Error) No meaning for identifier `PositiveInteger'.
[L3 C36] #10 (Error) There are no suitable meanings for the operator `->'.
[L3 C39] #11 (Error) No meaning for identifier `PositiveInteger'.
"/var/zope2/var/LatexWiki/4005392542604933580-25px006.as", line 4:
== add { fact(n: PositiveInteger): PositiveInteger ==
.....................^
[L4 C22] #12 (Error) No meaning for identifier `PositiveInteger'.
[L4 C22] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.I compiled it with Aldor as above. In Axiom you should do:
)co test.as
)sh Test
The )show system command is used to display information about types or partial types. For example, )show Integer will show information about Integer .
Test is not the name of a known type constructor. If you want to see information about any operations named Test , issue )display operations Test
fact(5)$Test
Test is not a valid type.
Known Problems
see Issue #219
Here is a precomputed libaxiom.al that has been produced with src_aldor2.tgz and FriCAS (rev 286).