Giter Club home page Giter Club logo

math's Introduction

Math – a namespace of mathematical functions and libraries for Dyalog APL

This repository contains a Math namespace for Dyalog APL with functions for finding eigenvalues, eigenvectors and discrete Fourier transforms.

These functions are implemented as calls into shared libraries. Source code and build scripts for the libraries are included.

Using the namespace

Download an appropriate Math-*.zip from the releases page and extract the files somewhere on your computer.

In order for Windows to find the DLLs you'll have to put them:

  • in the current directory (this might be determined by the properties of the shortcut you use to start Dyalog), or
  • in the directory containing the Dyalog executable dyalog.exe, or
  • somewhere on your %PATH%.

The functions in this namespace include complex arithmetic. Dyalog represents complex numbers a+bi as aJb.

Eigen

Monadic function Eigen takes an n×n real or complex matrix and returns an (n+1)×n result of Eigen: Values⍪⍉↑Vectors:

┌───┬───┬───┬───┐
│  v a l u e s  │  ── Eigen values
├───┼───┼───┼───┤
│ v │ v │ v │ v │  ┐
├ e ┼ e ┼ e ┼ e ┤  │
│ c │ c │ c │ c │  │
├ t ┼ t ┼ t ┼ t ┤  ├─ Eigen vectors.
│ o │ o │ o │ o │  │
├ r ┼ r ┼ r ┼ r ┤  │
│   │   │   │   │  ┘
└───┴───┴───┴───┘

Eigen has been constructed from LAPACK (Linear Algebra Package) double- precision C functions which are available as source code from www.netlib.org/lapack

LAPACK.DLL contains these C functions. They can all be called individually through ⎕NA. You need to examining each function's parameters in the corresponding *.C file (downloaded from the internet) in order to correctly specify their result and argument types.

For example, look at the ⎕NA call for dgeev_ in Eigen. Compare this with the parameters specified in file DGEEV.C . All the other double-precision real and complex LAPACK functions can be called in this way using ⎕NA.

Trace the following line in order to see Eigen in action:

  test.eigen    ⍝ run and trace 10 times

Domino

Domino is a cover function for APL's primitive function. It has been included for backwards compatibility with the Math workspace which was supplied with previous versions of Dyalog APL.

Trace the following line in order to see Domino in action:

  test.domino   ⍝ run and trace

Fourier

Fourier takes a real or complex array right argument. The left argument signifies:

1: Fourier Transform (default).
¯1: Inverse Fourier Transform.

Fourier has been constructed from FFTW (the Fastest Fourier Transform in the World). The FFTW source code of C functions is available from www.fftw.org

The FFTW.DLL contains all these functions. They can be called individually through ⎕NA after examining each function's parameters in the FFTW documentation.

Check that

  {⍵=¯1 Fourier Fourier ⍵}↓?((5?5),2)⍴100

Trace the following line in order to see Fourier in action:

  test.fourier   ⍝ run and trace

Note that C cover functions dft and idft have been added to the DLL.

These functions are:

// dft.c discrete fourier transform

#include <fftw.h>

void dft(int *rank, const int *shape, double *data)
{
   fftwnd_plan plan;
   plan = fftwnd_create_plan(*rank, shape, FFTW_FORWARD, FFTW_IN_PLACE);
   fftwnd_one(plan, (void*)data, 0);
   fftwnd_destroy_plan(plan);
}

// idft.c inverse discrete fourier transform

#include <fftw.h>

void idft(int *rank, const int *shape, double *data)
{
   fftwnd_plan plan;
   plan = fftwnd_create_plan(*rank, shape, FFTW_BACKWARD, FFTW_IN_PLACE);
   fftwnd_one(plan, (void*)data, 0);
   fftwnd_destroy_plan(plan);
}

To see an example of these functions, type:

      test.eigen ⋄ test.domino ⋄ test.fourier

Building the libraries

The supported build configurations are:

  • Linux (x86 and x86-64)
  • Cross-compiling from Linux to Windows (x86 and x86-64)

To build natively:

  • install some 32- and 64-bit Fortran compilers with sudo apt-get install gfortran-multilib
  • cd into the root of the repository
  • type make -f Makefile.linux to make Math-linux.zip

To cross-compile (tested on Ubuntu 17.04):

  • install some cross-compilers with sudo apt-get install gfortran-mingw-w64
  • cd into the root of the repository
  • type make -f Makefile.windows to make Math-windows.zip

math's People

Contributors

abrudz avatar bpbecker avatar jayfoad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

math's Issues

Add LibPath for shared library initialization

Currently you need to put the shared libraries in one of a few specific places, some of which require administrator access. We should add an optional LibPath variable to the Math namespace. If specified, this is where Math will look first for the shared libraries.

Ideally I'd like to see the following search hierarchy implemented:

  • LibPath, if non-empty
  • the directory with the dyalog executable
  • the current directory
  • the Windows\System directory (Windows only)
  • the Windows\ directory (Windows only)
  • a directory in the operating system's PATH
  • the directory where Math.dyalog was loaded from (if available)
  • the directory of the current workspace (if applicable)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.