universal linear algebra api based on m4 michael fiero isaac asiamah
TRANSCRIPT
Presentation Overview
• APIs• M4• Linear Algebra• Project Purpose• User Analysis• Feasability Study• Project Content• How It Works• Documentation• Conclusion
APIs
• API – Application Programming Interface• Collection of Functions and Data Structures• “Black Box”• This project is an open API
M4
• Macro Processing Language• Common Uses:
– Text Replacement Tool– As a Preprocessor– Generation of Higher Level Language Code
M4 Macros
• Macros may be either built-in or user defined• Some built in macros:
– define, undefine – defines or undefines a macro name– pushdef, popdef – similar, but use stack– changequote, changecom – change default quotes
and comments– incr, decr – increment and decrement an integer– eval – evaluates an argument as an arithmetic
expression
Defining Macros
• A macro has the form:– define (name,[expansion])
• Calling the macro requires only the name of the macro as it was defined.
• Example: define (`foo’,`Hello World!’)
=>
foo
=> Hello World!
Invoking M4
• M4 is by default included in most UNIX development environments.
• Terminal command line:– m4 [option…][file…]
• Examples of Commands:– --help, --version, --interactive
Files and M4
• M4 can take files as input– m4 myfile.m4
• Can also generate files– m4 myfile.m4 > myoutput.txt
• This is how this particular project generates APIs– m4 pyapi.m4 > linear.py
Linear Algebra
• The study of:– Vectors– Vector Spaces– Linear Transformations– Systems of Linear Equations
• Uses in Computer Science :– Graphics– Modern Math Analysis– Economics
Project Purpose
• Linear is very useful in computer science• APIs tend to be language specific• This API can be set up for use with:
– C– C++– Java– Perl– Python
User Needs
• A universal API that performs linear algebra operations and is based on M4
• Adequate documentation for using and adding functions
• M4 based test suite
Feasibility Study
• Challenges:– Becoming well acquainted with:
• M4• Perl• Python
– Creating a working API with a clear and logical structure
Feasibility Study
• There are currently Linear Algebra APIs in existence.
• However, they are language specific• The most common ones seem to be written for
Java• There are also some written for C, C++, and Perl
Included Functionality
• The final project includes an m4 API for all of the target languages.
• There is a simple setup script which will be easy to use
• It also includes a detailed documentation for how to use the functions.
• A test suite has been provided as well.
Some Included Functions
• Some of the functions included are:– Vector Normalization– Dot Product– Matrix Multiplication– Transpose of a Matrix– Square and Symmetrical Matrices– Determinant of a Matrix
How It Works
• The program contains:– M4 code for the generation of files which can be
included in your program• C and C++ - #include <linear.h>• Java – import linear.*;• Python – import linear• Perl – require “linear.pl”;
– Setup script written in bash,which calls M4 for the user to generate the necessary file
Using the Functions
• Using the functions is a matter of simply calling them based on the syntax of the language being written– C, C++, Java - function(arg1,arg2);– Python - linear.function(arg1,arg2)– Perl – function(arg1,arg2);
• Very simple, and familiar use
Adding Functions
• Adding functions requires knowledge of M4 and of each specific language
• All of the languages are similar, so adding functions is very easy
• This API is open, so it is free for anyone to add their own functions
Included Documentation
• The documentation includes:– User’s setup guide– Function documentation
• Similar to Sun’s Java Documentation – Guide to adding files– Reference Guide
Conclusion
• A good start to creating:– Universal API for C family languages
• Comprehensive linear algebra functions• Clear documentation• Ability to add functions
References
• http://www.gnu.org/software/m4/• http://www.comp.leeds.ac.uk/Perl/start.html• http://docs.python.org/tut/• http://www.bernstein-plussons.com/.dowling/POCSF06/Project2.htm
l• http://en.wikipedia.org/