Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Stand-alone numeric code snippets
Python Java Scheme Haskell C# C++ Other
branch: master
Failed to load latest commit information.
ada
cpp add required includes for C++ test program
csharp
d
erlang format erlang results with sufficient precision and tighten up test t…
go call the 2-argument version of strings.Split
haskell
java add LogFactorial function to all languages
javascript add LogFactorial function to all languages
lua add lua implementation
pascal add pascal implementation
perl
php add LogFactorial function to all languages
python fix all line endings for consistency
ruby
scala
scheme
tcl
.gitignore add html generator and templates
README.md add links to readme
SConstruct Start adding scala support
function.template
gen.py
index.template
language.template
test.py

README.md

picomath

Picomath is a collection of small math functions inspired by John D. Cook's Stand-alone code for numerical computing. It is not compiled into a library in the usual sense (that is, something you can link to). Rather, the functions are presented as standalone snippets of code.

License

The picomath library is in the public domain. Do whatever you want with it, no strings attached. Use at your own risk.

Features

Picomath provides the following functions:

Languages

The functions are implemented in the following languages:

Usage

The picomath library is organised into subdirectories, with each language in a subdirectory. Each function (or group of interrelated functions such as Gamma and Log Gamma) are implemented in one source file. Each source file is designed with minimal dependencies, so it can be included directly into a project as is, or copy and pasted into other code.

Test Suite

The test suite consists of two parts:

  • an SConstruct file (for SCons, a command line build system) to build the test code as needed
  • a Python test.py driver at the top level, and a corresponding test.* for each language

To build the tests:

$ scons

To run the tests:

$ python test.py

The expected output is:

Checking ada... ok
Checking cpp... ok
Checking csharp... ok
Checking d... ok
Checking erlang... ok
Checking go... ok
Checking haskell... ok
Checking java... ok
Checking javascript... ok
Checking lua... ok
Checking pascal... ok
Checking perl... ok
Checking php... ok
Checking python... ok
Checking ruby... ok
Checking scheme... ok
Checking tcl... ok

The top level test.py runs each language-specific test.* in turn, communicating with the implementation using standard input and output. A simple text-based protocol is used to execute functions and return results.

About

  • John D. Cook is the original author of most of the functions themselves.
  • Greg Hewgill implemented the test framework and translated the functions to many of the included languages.
Something went wrong with that request. Please try again.