# Difference between revisions of "Main Page"

(→Getting started) |
|||

(15 intermediate revisions by 3 users not shown) | |||

Line 1: | Line 1: | ||

− | + | **Previous documentation was lost, so current wiki is an old version that does not include installation and getting started information. Updated documentation will be made available asap. In the meantime, send any questions to adam dot p dot harrison at gmail dot com if you have any questions on how to get started** | |

− | + | ==Introduction== | |

− | + | Welcome to LibMIA. | |

− | + | ||

− | + | ||

− | + | ||

− | == | + | LibMIA is a software library designed to make manipulation of multi-indexed arrays (MIAs) easy. Technical computing packages, such as MATLAB, GNU Octave, and SciPy, support matrix algebra, making code look remarkably similar to what a scientist or practitioner would write on paper. However, matrices are not well-suited to work with and operate on MIAs, such as those found in digital imagery. What's needed is a formalism and supporting software designed for MIAs. |

− | + | ||

− | + | ==MIA Formalism== | |

+ | |||

+ | If you're familiar with Einstein notation, then you already know much of MIA formalism. The biggest difference is the use of only one index type. There are other important differences. | ||

+ | |||

+ | An inner product, <math>c</math>, between two arrays <math>a_{i}</math> and <math>b_{i}</math>, each of dimension <math>n</math>, is the summation of the products of all corresponding elements: | ||

+ | ;<math>\begin{align} | ||

+ | c=\sum_{i=1}^{n}a_{i}b_{i} \textrm{.} | ||

+ | \end{align}</math> | ||

+ | Index notation uses a repeated index to represent an inner product, where the dimensionality is understood from the context: | ||

+ | ;<math>\begin{align} | ||

+ | c=a_{i}b_{i} \textrm{.} | ||

+ | \end{align}</math> | ||

+ | Index notation also provides a concise convention for outer products. An outer product, <math>c_{ij}</math>, of <math>a_{i}</math> and <math>b_{j}</math>, with dimensions <math>\{m,n\}</math>, is defined as the ordered product of all possible combinations of elements within the two arrays. | ||

+ | ;<math>\begin{align} | ||

+ | c_{ij}=\left( | ||

+ | \begin{array}{cccc} | ||

+ | a_{1}b_{1} & a_{1}b_{2} & \ldots & a_{1}b_{n} \\ | ||

+ | a_{2}b_{1} & a_{2}b_{2} & \ldots & a_{2}b_{n} \\ | ||

+ | \vdots & \vdots & \ddots & \vdots \\ | ||

+ | a_{m}b_{1} & a_{m}b_{2} & \ldots & a_{m}b_{n} \\ | ||

+ | \end{array} | ||

+ | \right) | ||

+ | \textrm{.} | ||

+ | \end{align}</math> | ||

+ | Index notation simply uses differing indices to represent an outer product, where again the dimensionality is understood from the context: | ||

+ | ;<math>\begin{align} | ||

+ | c_{ij}=a_{i}b_{j} \textrm{.} | ||

+ | \end{align}</math> | ||

+ | MIA formalism supports another important product - the element-wise or ''inter'' product. Performed using two first-order MIAs, it is expressed using an underline: | ||

+ | ;<math>\begin{align} | ||

+ | c_{i}=a_{\underline{i}}b_{\underline{i}} \textrm{.} | ||

+ | \end{align}</math> | ||

+ | With the inter product defined, an MIA product can consist of any combination of <math>N</math>-order inner, inter, and outer products. | ||

+ | ;<math>\begin{align} | ||

+ | c_{lmji}=a_{\underline{i}jkl}b_{\underline{i}mj} | ||

+ | \end{align}</math> | ||

+ | Note that the order of indices do not have to be same on the left and right-hand sides of the expression. MIA formalism has other benefits, including the ability to represent addition and subtraction, MIA inversions. Inter products also allow ternary or higher inner products to be associated. | ||

+ | |||

+ | ==Using LibMIA== | ||

+ | |||

+ | <syntaxhighlight lang="Cpp"> | ||

+ | DenseMIA<double,3> a(4,6,5); //Could also be sparse | ||

+ | DenseMIA<double,3> b(4,2,6); DenseMIA<double,3> c; | ||

+ | PRODIND i; PRODIND j; //returns ProdIndex<id,false> | ||

+ | PRODIND k; PRODIND l; | ||

+ | c(j,l,k)=a(i,!k,l)*b(i,j,!k); //will compile | ||

+ | c(j,l,k)=a(i,k,l)*b(i,j,!k); //will cause compilation error | ||

+ | </syntaxhighlight> |

## Latest revision as of 00:02, 5 March 2015

- Previous documentation was lost, so current wiki is an old version that does not include installation and getting started information. Updated documentation will be made available asap. In the meantime, send any questions to adam dot p dot harrison at gmail dot com if you have any questions on how to get started**

## Introduction

Welcome to LibMIA.

LibMIA is a software library designed to make manipulation of multi-indexed arrays (MIAs) easy. Technical computing packages, such as MATLAB, GNU Octave, and SciPy, support matrix algebra, making code look remarkably similar to what a scientist or practitioner would write on paper. However, matrices are not well-suited to work with and operate on MIAs, such as those found in digital imagery. What's needed is a formalism and supporting software designed for MIAs.

## MIA Formalism

If you're familiar with Einstein notation, then you already know much of MIA formalism. The biggest difference is the use of only one index type. There are other important differences.

An inner product, <math>c</math>, between two arrays <math>a_{i}</math> and <math>b_{i}</math>, each of dimension <math>n</math>, is the summation of the products of all corresponding elements:

- <math>\begin{align}

c=\sum_{i=1}^{n}a_{i}b_{i} \textrm{.}

\end{align}</math> Index notation uses a repeated index to represent an inner product, where the dimensionality is understood from the context:

- <math>\begin{align}

c=a_{i}b_{i} \textrm{.}

\end{align}</math> Index notation also provides a concise convention for outer products. An outer product, <math>c_{ij}</math>, of <math>a_{i}</math> and <math>b_{j}</math>, with dimensions <math>\{m,n\}</math>, is defined as the ordered product of all possible combinations of elements within the two arrays.

- <math>\begin{align}

c_{ij}=\left( \begin{array}{cccc} a_{1}b_{1} & a_{1}b_{2} & \ldots & a_{1}b_{n} \\ a_{2}b_{1} & a_{2}b_{2} & \ldots & a_{2}b_{n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m}b_{1} & a_{m}b_{2} & \ldots & a_{m}b_{n} \\ \end{array} \right) \textrm{.}

\end{align}</math> Index notation simply uses differing indices to represent an outer product, where again the dimensionality is understood from the context:

- <math>\begin{align}

c_{ij}=a_{i}b_{j} \textrm{.}

\end{align}</math>
MIA formalism supports another important product - the element-wise or *inter* product. Performed using two first-order MIAs, it is expressed using an underline:

- <math>\begin{align}

c_{i}=a_{\underline{i}}b_{\underline{i}} \textrm{.}

\end{align}</math> With the inter product defined, an MIA product can consist of any combination of <math>N</math>-order inner, inter, and outer products.

- <math>\begin{align}

c_{lmji}=a_{\underline{i}jkl}b_{\underline{i}mj} \end{align}</math> Note that the order of indices do not have to be same on the left and right-hand sides of the expression. MIA formalism has other benefits, including the ability to represent addition and subtraction, MIA inversions. Inter products also allow ternary or higher inner products to be associated.

## Using LibMIA

<syntaxhighlight lang="Cpp"> DenseMIA<double,3> a(4,6,5); //Could also be sparse DenseMIA<double,3> b(4,2,6); DenseMIA<double,3> c; PRODIND i; PRODIND j; //returns ProdIndex<id,false> PRODIND k; PRODIND l; c(j,l,k)=a(i,!k,l)*b(i,j,!k); //will compile c(j,l,k)=a(i,k,l)*b(i,j,!k); //will cause compilation error </syntaxhighlight>