mathed 0.2.0
Small math library for D
To use this package, put the following dependency into your project's dependencies section:
dub.json
dub.sdl
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
andnothrow
.
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 %sth element of matrix is %s", i, col);
}
// iteration by line and column numbers:
foreach (i, j, ref col; m)
{
writefln ("The element of %sth line, %sth 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:
 Oneletter 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 (onelined or onecolumned)
depends on VectorType (
horizontal
andvertical
). By default all vectors arehorizontal
.  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 (oneletter)
auto vec = Vector!(int, 2, "xy")(10, 20);
assert (vec.x == 10);
// Vector accessor (multiletter)
auto vec = Vector!(int, 2, "colrow")(10, 20);
assert (vec.col == 10);
// Convertion vector to matrix
auto vec = Vector!(int, 2, "colrow")(10, 20);
vec.toMatrix ();
assert (isMatrix!(typeof (vec)));
Current version
alpha: by now it provides only matrix and vector implementation.
 Registered by Vlad Rindevich
 Lodin/mathed
 github.com/Lodin/mathed
 BSL1.0
 Copyright © 2014, Vlad Rindevich
 Authors:
 Vlad Rindevich
 Dependencies:
 none
 Versions:

0.2.0 2014Oct20 0.1.0 2014Aug04 ~master 2014Oct21  Download Stats:


0 downloads today

0 downloads this week

0 downloads this month

258 downloads total
