## 9 ways to program for Android devices using Android devices

March 26th, 2012

These days almost all of us are carrying around seriously capable little computers in the form of our mobile phones.  Although these devices have a similar amount of horsepower to supercomputers of old, most of us only use a fraction of their potential– after all, you don’t need a supercompter to send text messages, look at pictures of cats or throw birds at pigs.  I believe that the only way to fully unlock the true potential of these devices is to program them yourself.

From fully fledged applications to little snippets of code, I think that there’s something enormously satisfying about writing your own computer programs and it doesn’t have to be difficult to do so.  The following 9 apps will allow you to write programs for your Android mobile phone in a variety of languages including C, BASIC, Lisp and MATLAB m-code using only your Android phone. Although you’ll not be able to use them to write the next 3D blockbuster game, you will be able to solve some interesting problems, learn a trick or two and have a lot of fun.

C4droid – £0.95

With c4droid you get the ability to write, compile and run C and C++ programs using only your Android device.  That’s a lot of functionality for only 95p!

Out of the box C4droid only handles C programs, making use of a modified version of the Tiny C Compiler to do the compilation work.  The standard C library is provided by uClibc which is specially designed for use on embedded systems.

In order to run C++ programs you need to additionally install the free GCC plugin for C4droid — something that I personally haven’t done yet due to its large size.  One of the most common user-complaints appears to be ‘this app doens’t allow me to use iostream.h’ which essentially demonstrates that the installation instructions were not followed.  Since iostream.h is a C++ library, you’ll need to install and configure the GCC plugin to get access to it and full instructions on how to do this are given on c4droid’s Google Play page.

You only get access to the standard C library with C4droid which means that you can’t generate graphical output or interact with the phone’s hardware in any way (bluetooth, accelerometers, that sort of thing) but that doesn’t stop this from being an impressive piece of work.  Also, for an extra 95p you can run pascal programs using the Pascal plugin for C4droid.

C4droid is a superb app that will be invaluable for anyone learning C,C++ or Pascal or for those of us that simply like to fiddle about with these languages on the go.

Mintoris Basic – £3.77

At the risk of showing my age, I’ll tell you that I first learned how to program in BASIC (Beginners All-Purpose Symbolic Instruction Code) on the Sinclair ZX Spectrum and so I will always have a fondness for the language.  Mintoris Basic is a very fully featured implementation of the BASIC programming language and is significantly more powerful than the implementation I cut my teeth on back in the day.

As well as having all of the stuff you’d expect in a BASIC implementation (loops, strings, variables, functions, decisions, graphics etc), Mintoris also allows you to interact with some of your phone’s hardware including Bluetooth, battery level, GPS, and various sensors.  Furthermore, you can attach your programs to shortcuts and launch them from your home screens.  The level of functionality is so high that you can write some rather nifty apps with relatively little effort.

Frink – Free

Frink is a great language developed by Alan Eliasen that has been around since 2001.  Named after Professor Frink from The Simpsons, Frink runs on almost every device you can possibly imagine and has some very interesting features including interval arithmetic, tracking of units of measure throughout calculations, arbitrary precision numbers, regular expressions and graphics.

RFO BASIC! + SQL – Free

This implementation of BASIC is completely free and is described as a labour of love by the author, Paul Laughton.  Paul is my kind of geek since he is the curator of The Dr. Richard Feynman Observatory and author of Atari Basic and Apple DOS 3.1 among other things.

The feature list of RFO BASIC is impressive and includes Graphics (with Multi-touch), SQL, GPS, Device Sensors, Camera and loads more.  There’s a great forum with lots of very engaged developers who are writing some very nice programs.

There are two ways to deploy your programs–either as scripts that require RFO BASIC to be installed or as compiled,standalone programs that can even be added to Google Play (formerly known as the Android Market’).

These are two MATLAB clones for Android.  I’ve mentioned Addi before and they have both been covered over at Alasdair’s Musings so I won’t go into detail here other than to say that they are very cool!  Linear algebra, scripting and plotting on your phone!

tiny Lisp ISLisproid

Lisp is a very old programming language which first saw the light of day in 1958!  According to wikipedia, the only langauge older than Lisp that is still in common use is Fortran! With this app you can play with the language of the ancients on your super-modern smartphone.  This is a no-frills app..essentially little more than a command line shell and list interpreter but that is perhaps as it should be.

MathStudio – £12.99

I’ve been using MathStudio (formerly SpaceTime Mathematics) for quite a few years now on various operating systems and it’s great to finally have it on Android.  MathStudio is a fully featured computer algebra system for your mobile phone– think mini Mathematica or Maple and you are thinking along the right lines.  With this app you can write scripts that make use of advanced mathematical features,  2D and 3D graphics, animations and interactive demonstrations.

SigmaScript – Free

SigmaScript is a free implementatuion of the Lua scripting language for Android devices developed by Logimath.  You get an editor, scripting engine, small console output and a few simple code examples.  No graphics or anything fancy but a very nice way to play with an interesting language.

## Carnival of Mathematics – The Next Generation

March 20th, 2012

For the last two years or so I have been doing the administration for The Carnival of Mathematics (CoM) and have had a lot of fun doing so.  I first took over for carnival 59 (written by Jason Dyer and hosted over at NumberWarrior) and did the admin right up until number 84 which was published back in December 2011 by Guillermo Bautista (see here and here for some history).

Recently, however, I have struggled to find the time to give the CoM the attention it deserves and so it is time to hand over the baton.  Thankfully, some very able hands have taken it from me and I am happy to announce that Peter Rowlett, Katie Steckles and Christian Perfect will be taking care of business from now on.  Submissions for Carnival 85 are already open.

I’ll still be around, blogging as usual here at WalkingRandomly and hosting the occasional Carnival myself but the carnival is now being cared for by the next generation.  Submit something and give them a great welcome.

## A bug in Mathematica’s CUDADot in version 8.0.1

March 14th, 2012

After writing my recent article on GPU accelerated Matrix-Matrix multiplication using Maple, I thought that I’d try the same thing in Mathematica.  However, I instantly hit a problem on my 64bit Windows 7 machine running version 8.0.1 of Mathematica.

In[1]:= a = RandomReal[1, {2, 2}]
Out[1]= {{0.363441, 0.528656}, {0.208881, 0.510232}}

In[2]:= b = RandomReal[1, {2, 2}]
Out[2]= {{0.33536, 0.77615}, {0.537533, 0.788522}}

In[3]:= Dot[a, b]
Out[3]= {{0.406054, 0.698942}, {0.344317, 0.564452}}

Out[5]= {{0.741414, 1.47509}, {0.881849, 1.35297}}`

In short, CUDADot gives the wrong result for floating point numbers (on my machine at least).  An upgrade to version 8.0.4 fixed the problem

## A Month of Math Software – February 2012

March 2nd, 2012

Welcome to the latest edition of A Month of Math Software which includes information on a new language for scientific computing, statistics software education in New Zealand as well as the usual mix of mathematical and scientific software releases from the worlds of commercial and free software.

If you’d like something added to next month’s edition then contact me (it’s free).  If you want to see old editions then take a look at the MMS archive.

A new language for scientific computing

• Julia is a “new high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical computing environment.”  I haven’t tried it yet but it looks great and includes a Just In Time compiler (JIT) to help boost performance.

Have you test driven Julia?  Let me know what you think in the comments.

Learn statistics with the free GenStat for teaching and Learning (GTL)

• Mathcad Prime 2.0 has been released and has lots of new improvements.  I’ve never been a fan of Mathcad and Prime 1.0 was a big disappointment for me but many people seem to like it.  Let me know if you are one of them.

Attack of the clones

• A major new release of the free MATLAB clone, Octave, has is now available.  Version 3.6.1 has lots of new goodies and you can read all about them in the 3.6.1 NEWS file.
• Version 13.7 of the MATLAB-like Euler Math Toolbox is now available.  See the change log for the improvements.
• Version 0.92 of the popular Mathcad clone, Smath studio, was released in February.

Number theory

• A new version of PARI/GP is now available for download.  From the software’s website: “PARI/GP is a widely used computer algebra system designed for fast computations in number theory (factorizations, algebraic number theory, elliptic curves…), but also contains a large number of other useful functions to compute with mathematical entities such as matrices, polynomials, power series, algebraic numbers etc., and a lot of transcendental functions.”  Head over to the changelog to see what’s new.

Perl and Python

• If you like to work with the Perl programming language then you should take a look at the Perl Data Language (PDL).  A new version was released in February– version 2.4.10— which includes automatic multi-thread support among other things.
• If you prefer Python, you’ll probably like to know that version 0.10.1 of scipy, the scientific library for python, has been released.

Math software on tablets

• The Mathematica kernel is now running on iPad!
• GeoGebra is a superb piece of free software for mathematics learning and teaching.  Thanks to the release of the beta version of GeoGebraWeb, you can now experience some of the GeogGebra goodness on Tablets and Chromebooks.  This forum post gives the details.

Finite Elements

• February saw the release of two new C++ libraries: ViennaMath and ViennaFEM.  The author of the libraries writes “The symbolic math kernel library ViennaMath (http://viennamath.sourceforge.net/) written in C++ allows for both runtime and compiletime evaluation, differentiation, integration, and substitution of simple mathematical expressions. In short, ViennaMath offers some of the advantages of full-fledged computer algebra systems such as Mathematica or Maple directly within C++. The symbolic math kernel is intended to be used for numerical applications and is included in the new finite element library ViennaFEM (http://viennafem.sourceforge.net/), which allows for the specification of either the strong or the weak formulation of the underlying PDE directly in code. Even though ViennaFEM is still in alpha-state, the first release already supports grids in 1d, 2d (triangular,quadrilateral) and 3d (tetrahedral, hexahedral).”

From the blogs