dnumeric 0.3.3

D Numeric Library with R syntax


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

dub.json
dub.sdl

DNumeric

D Numeric Library with R Syntax

Import

Add next line to your dub.json

"dnumeric": "~>0.3.0"

or dub.sdl

dependency "dnumeric" version="~>0.3.0"

Usage

import dnum.tensor;
import dnum.linalg;
import dnum.utils;

// Tensor Declaration
auto a = Tensor([1,2,3,4]); // Single row tensor
auto a = Tensor([1,2,3,4], Shape.Row) // Also row tensor
auto b = Tensor([1,2,3,4], Shape.Col); // Single column tensor
auto c = Tensor([[1,2],[3,4]]); // Two Dimensional Tensor

a.nrow.writeln; // The number of rows of a
b.ncol.writeln; // The number of cols of b
assert(a.nrow == b.ncol); // Same

a.transpose.writeln; // (== b)
c.transpose.writeln; // (== Tensor([[1,3],[2,4]]))

// Operation
-b.writeln; // Negation
(b + b).writeln; // Addition
(b - b).writeln; // Subtraction
(b * b).writeln; // Multiplication (component-wise)
(b / b).writeln; // Division
(b % b).writeln; // Matrix multiplication

// Linear Algebra
b.det.writeln; // Determinant (Using LU Decomposition)
b.inv.writeln; // Inverse (Using LU Decomposition)
b.lu[0].writeln; // LU Decomposition - L
b.lu[1].writeln; // LU Decomposition - U

// Utils
cbind(b, b).writeln; // Tensor([[1,2,1,2],[3,4,3,4]])
rbind(b, b).writeln; // Tensor([[1,2],[3,4],[1,2],[3,4]])
c.col(0).writeln; // Tensor([[1], [3]])
c.row(0).writeln; // Tensor([[1, 2]])
Authors:
  • Tae Geun Kim
Dependencies:
none
Versions:
0.3.3 2018-Aug-11
0.3.2 2018-Aug-11
0.3.1 2018-Aug-11
0.3.0 2018-Aug-11
0.2.6 2018-Aug-08
Show all 28 versions
Download Stats:
  • 1 downloads today

  • 5 downloads this week

  • 17 downloads this month

  • 24 downloads total

Score:
0.6
Short URL:
dnumeric.dub.pm