## Description

Small math library for D

## Package Information

Version | 0.2.0 (2014-Oct-20) |

Homepage | https://github.com/Lodin/mathed |

Repository | https://github.com/Lodin/mathed |

License | BSL-1.0 |

Copyright | Copyright © 2014, Vlad Rindevich |

Authors | Vlad Rindevich |

Registered by | Vlad Rindevich |

Dependencies | none |

## Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json

dub.sdl

## Readme

## mathed

This is a small math library written in D Programming Language.

### Features:

#### Matrix and vector

- All actions is checked at compile time. There are no exceptions.
- Matrix and vector structure contains only it's data, and nothing additional.
- Almost all actions is
`pure`

and`nothrow`

.

#### Matirx usage

- Creating matrix
- Matrix can be:
- added:
`m + m`

. - subtracted:
`m - m`

. - multiplied by number:
`m * 2`

. - divided by number:
`m / 2`

. - multiplied by another matrix:
`m * m`

. - transposed:
`m.t`

. - iterated by element number:
- iterated by line and column numbers:
- set in one action:
- If you need to check type of some variable to be a matrix, use
`isMatrix`

```
// Creating matrix
auto m = Matrix!(int, 3, 3)
(
3, -1, 6,
2, 1, 5,
-3, 1, 0
);
assert (m[0][2] == 6);
// Iteration by element number
foreach (i, ref col; m)
{
writefln ("The %s-th element of matrix is %s", i, col);
}
// iteration by line and column numbers:
foreach (i, j, ref col; m)
{
writefln ("The element of %s-th line, %s-th column of matrix is %s", i, j, col);
}
// Setting all matrix values in one action
m.set
(
3, -1, 6,
2, 1, 5,
-3, 1, 0
);
// Type checking
bool check = isMatrix!(typeof (m));
```

#### Vector usage

- Vector can have accessor - a named property method returning one of vector element. Accessor can be two types:
- One-letter accessor:
- Multiletter accessor. Accessor delimiter in the accessors string should
be
`|`

or`,`

. - Vector has the same actions as matrix, with some differences:
- Vector could not be iterated by line and column numbers (
`#8`

). - Vector can be converted to matrix. Matrix type (one-lined or one-columned)
depends on VectorType (
`horizontal`

and`vertical`

). By default all vectors are`horizontal`

. - If you need to check type of some variable to be a vector, use
`isVector`

.

```
// Creating simple vector
auto vec = Vector!(int, 2)(10, 20);
assert (vec[0] == 10);
// Vector accessor (one-letter)
auto vec = Vector!(int, 2, "xy")(10, 20);
assert (vec.x == 10);
// Vector accessor (multiletter)
auto vec = Vector!(int, 2, "col|row")(10, 20);
assert (vec.col == 10);
// Convertion vector to matrix
auto vec = Vector!(int, 2, "col|row")(10, 20);
vec.toMatrix ();
assert (isMatrix!(typeof (vec)));
```

#### Current version

**alpha**: by now it provides only matrix and vector implementation.

## Available versions

*0.2.0*0.1.0 ~master