Skip to content

Commit

Permalink
add dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
mateogianolio committed Aug 6, 2019
1 parent bc9835b commit df5e1fa
Show file tree
Hide file tree
Showing 293 changed files with 1,472 additions and 1,334 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
coverage
.DS_Store
built
benchmarks
Binary file removed benchmarks/Matrix/add.png
Binary file not shown.
Binary file removed benchmarks/Matrix/augment.png
Binary file not shown.
Binary file removed benchmarks/Matrix/binOp.png
Binary file not shown.
Binary file removed benchmarks/Matrix/det.png
Binary file not shown.
Binary file removed benchmarks/Matrix/determinant.png
Binary file not shown.
Binary file removed benchmarks/Matrix/diag.png
Binary file not shown.
Binary file removed benchmarks/Matrix/eig.png
Binary file not shown.
Binary file removed benchmarks/Matrix/gauss.png
Binary file not shown.
Binary file removed benchmarks/Matrix/inv.png
Binary file not shown.
Binary file removed benchmarks/Matrix/inverse.png
Binary file not shown.
Binary file removed benchmarks/Matrix/lu.png
Binary file not shown.
Binary file removed benchmarks/Matrix/lu_factor.png
Binary file not shown.
Binary file removed benchmarks/Matrix/magic.png
Binary file not shown.
Binary file removed benchmarks/Matrix/multiply.png
Binary file not shown.
Binary file removed benchmarks/Matrix/plu.png
Binary file not shown.
Binary file removed benchmarks/Matrix/product.png
Binary file not shown.
Binary file removed benchmarks/Matrix/rank.png
Binary file not shown.
Binary file removed benchmarks/Matrix/rowAdd.png
Binary file not shown.
Binary file removed benchmarks/Matrix/scale.png
Binary file not shown.
Binary file removed benchmarks/Matrix/solve.png
Binary file not shown.
Binary file removed benchmarks/Matrix/square.png
Binary file not shown.
Binary file removed benchmarks/Matrix/subtract.png
Binary file not shown.
Binary file removed benchmarks/Matrix/swap.png
Binary file not shown.
Binary file removed benchmarks/Matrix/toArray.png
Binary file not shown.
Binary file removed benchmarks/Matrix/toString.png
Binary file not shown.
Binary file removed benchmarks/Matrix/trace.png
Diff not rendered.
Binary file removed benchmarks/Matrix/transpose.png
Diff not rendered.
Binary file removed benchmarks/NDArray/abs.png
Diff not rendered.
Binary file removed benchmarks/NDArray/acos.png
Diff not rendered.
Binary file removed benchmarks/NDArray/acosh.png
Diff not rendered.
Binary file removed benchmarks/NDArray/add.png
Diff not rendered.
Binary file removed benchmarks/NDArray/asin.png
Diff not rendered.
Binary file removed benchmarks/NDArray/asinh.png
Diff not rendered.
Binary file removed benchmarks/NDArray/atan.png
Diff not rendered.
Binary file removed benchmarks/NDArray/atanh.png
Diff not rendered.
Binary file removed benchmarks/NDArray/binOp.png
Diff not rendered.
Binary file removed benchmarks/NDArray/cbrt.png
Diff not rendered.
Binary file removed benchmarks/NDArray/ceil.png
Diff not rendered.
Binary file removed benchmarks/NDArray/check.png
Diff not rendered.
Binary file removed benchmarks/NDArray/copy.png
Diff not rendered.
Binary file removed benchmarks/NDArray/cos.png
Diff not rendered.
Binary file removed benchmarks/NDArray/cosh.png
Diff not rendered.
Binary file removed benchmarks/NDArray/dot.png
Diff not rendered.
Binary file removed benchmarks/NDArray/each.png
Diff not rendered.
Binary file removed benchmarks/NDArray/equals.png
Diff not rendered.
Binary file removed benchmarks/NDArray/equidimensional.png
Diff not rendered.
Binary file removed benchmarks/NDArray/equilateral.png
Diff not rendered.
Binary file removed benchmarks/NDArray/exp.png
Diff not rendered.
Binary file removed benchmarks/NDArray/expm1.png
Diff not rendered.
Binary file removed benchmarks/NDArray/eye.png
Diff not rendered.
Binary file removed benchmarks/NDArray/fill.png
Diff not rendered.
Binary file removed benchmarks/NDArray/floor.png
Diff not rendered.
Binary file removed benchmarks/NDArray/fround.png
Diff not rendered.
Binary file removed benchmarks/NDArray/get.png
Diff not rendered.
Binary file removed benchmarks/NDArray/log.png
Diff not rendered.
Binary file removed benchmarks/NDArray/log10.png
Diff not rendered.
Binary file removed benchmarks/NDArray/log1p.png
Diff not rendered.
Binary file removed benchmarks/NDArray/log2.png
Diff not rendered.
Binary file removed benchmarks/NDArray/magnitude.png
Diff not rendered.
Binary file removed benchmarks/NDArray/map.png
Diff not rendered.
Binary file removed benchmarks/NDArray/max.png
Diff not rendered.
Binary file removed benchmarks/NDArray/min.png
Diff not rendered.
Binary file removed benchmarks/NDArray/norm.png
Diff not rendered.
Binary file removed benchmarks/NDArray/ones.png
Diff not rendered.
Binary file removed benchmarks/NDArray/pow.png
Diff not rendered.
Binary file removed benchmarks/NDArray/product.png
Diff not rendered.
Binary file removed benchmarks/NDArray/random.png
Diff not rendered.
Binary file removed benchmarks/NDArray/range.png
Diff not rendered.
Binary file removed benchmarks/NDArray/reduce.png
Diff not rendered.
Binary file removed benchmarks/NDArray/reshape.png
Diff not rendered.
Binary file removed benchmarks/NDArray/round.png
Diff not rendered.
Binary file removed benchmarks/NDArray/scale.png
Diff not rendered.
Binary file removed benchmarks/NDArray/set.png
Diff not rendered.
Binary file removed benchmarks/NDArray/sign.png
Diff not rendered.
Binary file removed benchmarks/NDArray/sin.png
Diff not rendered.
Binary file removed benchmarks/NDArray/sinh.png
Diff not rendered.
Binary file removed benchmarks/NDArray/sqrt.png
Diff not rendered.
Binary file removed benchmarks/NDArray/subtract.png
Diff not rendered.
Binary file removed benchmarks/NDArray/tan.png
Diff not rendered.
Binary file removed benchmarks/NDArray/tanh.png
Diff not rendered.
Binary file removed benchmarks/NDArray/trunc.png
Diff not rendered.
Binary file removed benchmarks/NDArray/zeros.png
Diff not rendered.
Binary file removed benchmarks/Vector/add.png
Diff not rendered.
Binary file removed benchmarks/Vector/angle.png
Diff not rendered.
Binary file removed benchmarks/Vector/binOp.png
Diff not rendered.
Binary file removed benchmarks/Vector/combine.png
Diff not rendered.
Binary file removed benchmarks/Vector/cross.png
Diff not rendered.
Binary file removed benchmarks/Vector/dot.png
Diff not rendered.
Binary file removed benchmarks/Vector/normalize.png
Diff not rendered.
Binary file removed benchmarks/Vector/project.png
Diff not rendered.
Binary file removed benchmarks/Vector/push.png
Diff not rendered.
Binary file removed benchmarks/Vector/scale.png
Diff not rendered.
Binary file removed benchmarks/Vector/subtract.png
Diff not rendered.
Binary file removed benchmarks/Vector/toArray.png
Diff not rendered.
Binary file removed benchmarks/Vector/toString.png
Diff not rendered.
2 changes: 1 addition & 1 deletion dist/vectorious.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Large diffs are not rendered by default.

626 changes: 316 additions & 310 deletions docs/classes/matrix.html

Large diffs are not rendered by default.

487 changes: 244 additions & 243 deletions docs/classes/ndarray.html

Large diffs are not rendered by default.

560 changes: 283 additions & 277 deletions docs/classes/vector.html

Large diffs are not rendered by default.

537 changes: 289 additions & 248 deletions docs/index.html

Large diffs are not rendered by default.

54 changes: 30 additions & 24 deletions docs/interfaces/indarray.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ <h2>Index</h2>
<h3>Properties</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="indarray.html#data" class="tsd-kind-icon">data</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="indarray.html#dtype" class="tsd-kind-icon">dtype</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="indarray.html#length" class="tsd-kind-icon">length</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="indarray.html#shape" class="tsd-kind-icon">shape</a></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="indarray.html#type" class="tsd-kind-icon">type</a></li>
</ul>
</section>
</div>
Expand All @@ -106,37 +106,37 @@ <h3>data</h3>
<div class="tsd-signature tsd-kind-icon">data<span class="tsd-signature-symbol">:</span> <a href="../index.html#typedarray" class="tsd-signature-type">TypedArray</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/mateogianolio/vectorious/blob/4969c7c/src/types.ts#L24">types.ts:24</a></li>
<li>Defined in <a href="https://github.com/mateogianolio/vectorious/blob/bc9835b/src/types.ts#L37">types.ts:37</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="length" class="tsd-anchor"></a>
<h3>length</h3>
<div class="tsd-signature tsd-kind-icon">length<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<a name="dtype" class="tsd-anchor"></a>
<h3>dtype</h3>
<div class="tsd-signature tsd-kind-icon">dtype<span class="tsd-signature-symbol">:</span> <a href="../index.html#dtype" class="tsd-signature-type">DType</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/mateogianolio/vectorious/blob/4969c7c/src/types.ts#L25">types.ts:25</a></li>
<li>Defined in <a href="https://github.com/mateogianolio/vectorious/blob/bc9835b/src/types.ts#L38">types.ts:38</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="shape" class="tsd-anchor"></a>
<h3>shape</h3>
<div class="tsd-signature tsd-kind-icon">shape<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></div>
<a name="length" class="tsd-anchor"></a>
<h3>length</h3>
<div class="tsd-signature tsd-kind-icon">length<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/mateogianolio/vectorious/blob/4969c7c/src/types.ts#L26">types.ts:26</a></li>
<li>Defined in <a href="https://github.com/mateogianolio/vectorious/blob/bc9835b/src/types.ts#L39">types.ts:39</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
<a name="type" class="tsd-anchor"></a>
<h3>type</h3>
<div class="tsd-signature tsd-kind-icon">type<span class="tsd-signature-symbol">:</span> <a href="../index.html#typedarrayconstructor" class="tsd-signature-type">TypedArrayConstructor</a></div>
<a name="shape" class="tsd-anchor"></a>
<h3>shape</h3>
<div class="tsd-signature tsd-kind-icon">shape<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/mateogianolio/vectorious/blob/4969c7c/src/types.ts#L27">types.ts:27</a></li>
<li>Defined in <a href="https://github.com/mateogianolio/vectorious/blob/bc9835b/src/types.ts#L40">types.ts:40</a></li>
</ul>
</aside>
</section>
Expand Down Expand Up @@ -170,18 +170,21 @@ <h3>type</h3>
<a href="indarray.html#data" class="tsd-kind-icon">data</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="indarray.html#length" class="tsd-kind-icon">length</a>
<a href="indarray.html#dtype" class="tsd-kind-icon">dtype</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="indarray.html#shape" class="tsd-kind-icon">shape</a>
<a href="indarray.html#length" class="tsd-kind-icon">length</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-interface">
<a href="indarray.html#type" class="tsd-kind-icon">type</a>
<a href="indarray.html#shape" class="tsd-kind-icon">shape</a>
</li>
</ul>
</li>
</ul>
<ul class="after-current">
<li class=" tsd-kind-type-alias">
<a href="../index.html#dtype" class="tsd-kind-icon">DType</a>
</li>
<li class=" tsd-kind-type-alias">
<a href="../index.html#typedarray" class="tsd-kind-icon">Typed<wbr>Array</a>
</li>
Expand Down Expand Up @@ -216,7 +219,16 @@ <h3>type</h3>
<a href="../index.html#flatten" class="tsd-kind-icon">flatten</a>
</li>
<li class=" tsd-kind-function">
<a href="../index.html#istypedarray" class="tsd-kind-icon">is<wbr>Typed<wbr>Array</a>
<a href="../index.html#get_dtype" class="tsd-kind-icon">get_<wbr>dtype</a>
</li>
<li class=" tsd-kind-function">
<a href="../index.html#get_shape" class="tsd-kind-icon">get_<wbr>shape</a>
</li>
<li class=" tsd-kind-function">
<a href="../index.html#get_type" class="tsd-kind-icon">get_<wbr>type</a>
</li>
<li class=" tsd-kind-function">
<a href="../index.html#is_typed_array" class="tsd-kind-icon">is_<wbr>typed_<wbr>array</a>
</li>
<li class=" tsd-kind-function tsd-is-not-exported">
<a href="../index.html#magichelper" class="tsd-kind-icon">magic<wbr>Helper</a>
Expand All @@ -230,12 +242,6 @@ <h3>type</h3>
<li class=" tsd-kind-function tsd-has-type-parameter tsd-is-not-exported">
<a href="../index.html#rotate" class="tsd-kind-icon">rotate</a>
</li>
<li class=" tsd-kind-function">
<a href="../index.html#shape" class="tsd-kind-icon">shape</a>
</li>
<li class=" tsd-kind-function">
<a href="../index.html#type" class="tsd-kind-icon">type</a>
</li>
</ul>
</nav>
</div>
Expand Down
Binary file removed docs/media/Matrix/add.png
Diff not rendered.
Binary file modified docs/media/Matrix/augment.png
Binary file removed docs/media/Matrix/binOp.png
Diff not rendered.
Binary file modified docs/media/Matrix/det.png
Binary file removed docs/media/Matrix/determinant.png
Diff not rendered.
Binary file modified docs/media/Matrix/diag.png
Binary file modified docs/media/Matrix/eig.png
Binary file modified docs/media/Matrix/gauss.png
Binary file modified docs/media/Matrix/inv.png
Binary file removed docs/media/Matrix/inverse.png
Diff not rendered.
Binary file modified docs/media/Matrix/lu.png
Binary file modified docs/media/Matrix/lu_factor.png
Binary file modified docs/media/Matrix/magic.png
Binary file modified docs/media/Matrix/multiply.png
Binary file removed docs/media/Matrix/plu.png
Diff not rendered.
Binary file removed docs/media/Matrix/product.png
Diff not rendered.
Binary file modified docs/media/Matrix/rank.png
Binary file modified docs/media/Matrix/rowAdd.png
Binary file removed docs/media/Matrix/scale.png
Diff not rendered.
Binary file modified docs/media/Matrix/solve.png
Binary file modified docs/media/Matrix/square.png
Binary file removed docs/media/Matrix/subtract.png
Diff not rendered.
Binary file modified docs/media/Matrix/toArray.png
Binary file modified docs/media/Matrix/toString.png
Binary file modified docs/media/Matrix/trace.png
Binary file modified docs/media/Matrix/transpose.png
Binary file modified docs/media/NDArray/abs.png
Binary file modified docs/media/NDArray/acos.png
Binary file modified docs/media/NDArray/acosh.png
Binary file modified docs/media/NDArray/add.png
Binary file modified docs/media/NDArray/asin.png
Binary file modified docs/media/NDArray/asinh.png
Binary file modified docs/media/NDArray/atan.png
Binary file modified docs/media/NDArray/atanh.png
Binary file modified docs/media/NDArray/binOp.png
Binary file modified docs/media/NDArray/cbrt.png
Binary file modified docs/media/NDArray/ceil.png
Binary file modified docs/media/NDArray/copy.png
Binary file modified docs/media/NDArray/cos.png
Binary file modified docs/media/NDArray/cosh.png
Binary file modified docs/media/NDArray/dot.png
Binary file modified docs/media/NDArray/each.png
Binary file modified docs/media/NDArray/exp.png
Binary file modified docs/media/NDArray/expm1.png
Binary file modified docs/media/NDArray/eye.png
Binary file modified docs/media/NDArray/fill.png
Binary file modified docs/media/NDArray/floor.png
Binary file modified docs/media/NDArray/fround.png
Binary file modified docs/media/NDArray/log.png
Binary file modified docs/media/NDArray/log10.png
Binary file modified docs/media/NDArray/log1p.png
Binary file modified docs/media/NDArray/log2.png
Binary file removed docs/media/NDArray/magnitude.png
Diff not rendered.
Binary file modified docs/media/NDArray/map.png
Binary file modified docs/media/NDArray/max.png
Binary file modified docs/media/NDArray/norm.png
Binary file modified docs/media/NDArray/ones.png
Binary file modified docs/media/NDArray/pow.png
Binary file modified docs/media/NDArray/product.png
Binary file modified docs/media/NDArray/random.png
Binary file modified docs/media/NDArray/reshape.png
Binary file modified docs/media/NDArray/round.png
Binary file modified docs/media/NDArray/scale.png
Binary file modified docs/media/NDArray/set.png
Binary file modified docs/media/NDArray/sign.png
Binary file modified docs/media/NDArray/sin.png
Binary file modified docs/media/NDArray/sinh.png
Binary file modified docs/media/NDArray/sqrt.png
Binary file modified docs/media/NDArray/subtract.png
Binary file modified docs/media/NDArray/tan.png
Binary file modified docs/media/NDArray/tanh.png
Binary file modified docs/media/NDArray/trunc.png
Binary file modified docs/media/NDArray/zeros.png
Binary file removed docs/media/Vector/add.png
Diff not rendered.
Binary file modified docs/media/Vector/angle.png
Binary file removed docs/media/Vector/binOp.png
Diff not rendered.
Binary file modified docs/media/Vector/combine.png
Binary file modified docs/media/Vector/cross.png
Binary file removed docs/media/Vector/dot.png
Diff not rendered.
Binary file modified docs/media/Vector/normalize.png
Binary file modified docs/media/Vector/project.png
Binary file removed docs/media/Vector/scale.png
Diff not rendered.
Binary file removed docs/media/Vector/subtract.png
Diff not rendered.
Binary file modified docs/media/Vector/toArray.png
Binary file modified docs/media/Vector/toString.png
3 changes: 1 addition & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
typedoc = require('gulp-typedoc');

gulp.task('clean', function () {
return del(['built', 'dist', 'docs']);
return del(['built', 'dist']);
});

gulp.task('docs', function () {
Expand All @@ -24,7 +24,6 @@
out: 'docs/',
name: 'Vectorious',
readme: 'none',
media: 'benchmarks',
}))
});

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "A high performance linear algebra library.",
"main": "built/index.js",
"scripts": {
"test:node": "nyc mocha -r ts-node/register/transpile-only src/**/*.spec.ts",
"test:node": "nyc mocha -r ts-node/register/transpile-only 'src/**/*.spec.ts'",
"test:single": "mocha -r ts-node/register/transpile-only",
"test:browser": "mochify --plugin tsify src/**/*.spec.ts",
"test:browser": "mochify --plugin tsify 'src/**/*.spec.ts'",
"test": "npm run test:node && npm run test:browser",
"lint": "tslint -p . -c tslint.json 'src/*.ts'",
"benchmark": "for file in $(ls src/**/*.bench.ts); do ts-node --transpile-only $file; done",
Expand All @@ -33,8 +33,8 @@
"coverage/**",
"src/**/*.spec.ts",
"src/**/*.bench.ts",
"src/util.ts",
"src/bench.ts"
"src/bench.ts",
"src/types.ts"
],
"reporter": [
"lcov"
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/augment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import { Matrix } from './';

describe('augment', () => {
describe('(Matrix) augment', () => {
it('should return current matrix when combined with empty matrix', () => {
const x: Matrix = new Matrix([[1, 2], [3, 4]]);

Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/det.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {

import { Matrix } from './';

describe('det', () => {
describe('(Matrix) det', () => {
it('should throw error if matrix is not square', () => {
const x: Matrix = new Matrix([[0, 0]]);
throws(() => { x.det(); }, Error);
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/diagonal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {

import { Matrix } from './';

describe('diagonal', () => {
describe('(Matrix) diagonal', () => {
it('should work as expected', () => {
const x: Matrix = new Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);

Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/eig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import { Matrix } from './';

describe('eig', () => {
describe('(Matrix) eig', () => {
it('should throw error if matrix is not square', () => {
const x: Matrix = new Matrix([[1, 2]]);

Expand Down
12 changes: 7 additions & 5 deletions src/Matrix/eig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { get_type } from '../util';

import { Matrix } from './';

let nlapack: any;
Expand Down Expand Up @@ -30,9 +32,9 @@ Matrix.prototype.eig = function<T extends Matrix>(this: T): [T, T] {
const [n] = this.shape;

try {
if (!(this.data instanceof Float64Array) || !(this.data instanceof Float32Array)) {
this.type = Float32Array;
this.data = Float32Array.from(this.data);
if (!['float32', 'float64'].includes(this.dtype)) {
this.dtype = 'float32';
this.data = get_type(this.dtype).from(this.data);
}

const jobvl: typeof nlapack.MatrixEigenvector = nlapack.NoEigenvector;
Expand All @@ -44,11 +46,11 @@ Matrix.prototype.eig = function<T extends Matrix>(this: T): [T, T] {
const vl: T = Matrix.zeros(n, n);
const vr: T = Matrix.zeros(n, n);

if (this.data instanceof Float64Array) {
if (this.dtype === 'float64') {
nlapack.dgeev(jobvl, jobvr, n, this.data, n, wr.data, wi.data, vl.data, n, vr.data, n);
}

if (this.data instanceof Float32Array) {
if (this.dtype === 'float32') {
nlapack.sgeev(jobvl, jobvr, n, this.data, n, wr.data, wi.data, vl.data, n, vr.data, n);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/gauss.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {

import { Matrix } from './';

describe('gauss', () => {
describe('(Matrix) gauss', () => {
it('should work as expected', () => {
const x: Matrix = new Matrix([[1, 2, 3], [3, 4, 5]]);
const y: Matrix = new Matrix([[1, 0, -1], [-0, 1, 2]]);
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/inv.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import { Matrix } from './';

describe('inv', () => {
describe('(Matrix) inv', () => {
it('should throw error if matrix is not square', () => {
const x: Matrix = new Matrix([[1, 2]]);

Expand Down
12 changes: 7 additions & 5 deletions src/Matrix/inv.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { get_type } from '../util';

import { Matrix } from './';

let nlapack: any;
Expand All @@ -13,16 +15,16 @@ Matrix.prototype.inv = function<T extends Matrix>(this: T): T {
const [n] = this.shape;

try {
if (!(this.data instanceof Float64Array) || !(this.data instanceof Float32Array)) {
this.type = Float32Array;
this.data = Float32Array.from(this.data);
if (!['float32', 'float64'].includes(this.dtype)) {
this.dtype = 'float32';
this.data = get_type(this.dtype).from(this.data);
}

const ipiv: Int32Array = new Int32Array(n);
if (this.data instanceof Float64Array) {
if (this.dtype === 'float64') {
nlapack.dgetrf(n, n, this.data, n, ipiv);
nlapack.dgetri(n, this.data, n, ipiv);
} else if (this.data instanceof Float32Array) {
} else if (this.dtype === 'float32') {
nlapack.sgetrf(n, n, this.data, n, ipiv);
nlapack.sgetri(n, this.data, n, ipiv);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/lu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {

import { Matrix } from './';

describe('lu', () => {
describe('(Matrix) lu', () => {
it('should work as expected', () => {
const x: Matrix = new Matrix([[1, 3, 5], [2, 4, 7], [1, 1, 0]]);
const ys: Matrix[] = [
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/lu_factor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {

import { Matrix } from './';

describe('lu_factor', () => {
describe('(Matrix) lu_factor', () => {
it('should work as expected', () => {
const x: Matrix = new Matrix([[1, 3, 5], [2, 4, 7], [1, 1, 0]]);
const y: Matrix = new Matrix([[2, 4, 7], [0.5, 1, 1.5], [0.5, -1, -2]]);
Expand Down
12 changes: 7 additions & 5 deletions src/Matrix/lu_factor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { get_type } from '../util';

import { Matrix } from './';

let nlapack: any;
Expand All @@ -12,14 +14,14 @@ Matrix.prototype.lu_factor = function<T extends Matrix>(this: T): [T, Int32Array
const ipiv: Int32Array = new Int32Array(n);

try {
if (!(this.data instanceof Float64Array) || !(this.data instanceof Float32Array)) {
this.type = Float32Array;
this.data = Float32Array.from(this.data);
if (!['float32', 'float64'].includes(this.dtype)) {
this.dtype = 'float32';
this.data = get_type(this.dtype).from(this.data);
}

if (this.data instanceof Float64Array) {
if (this.dtype === 'float64') {
nlapack.dgetrf(n, n, this.data, n, ipiv);
} else if (this.data instanceof Float32Array) {
} else if (this.dtype === 'float32') {
nlapack.sgetrf(n, n, this.data, n, ipiv);
}
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/magic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import { Matrix } from './';

describe('magic', () => {
describe('(Matrix) magic', () => {
it('should throw error if invalid size', () => {
throws(() => { Matrix.magic(-1); }, Error);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/multiply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import { Matrix } from './';

describe('multiply', () => {
describe('(Matrix) multiply', () => {
it('should throw error if sizes do not match', () => {
const x: Matrix = new Matrix([[1, 2], [3, 4]]);
const y: Matrix = new Matrix([[1, 2]]);
Expand Down
12 changes: 7 additions & 5 deletions src/Matrix/multiply.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { get_type } from '../util';

import { Matrix } from './';

let nblas: any;
Expand All @@ -18,14 +20,14 @@ Matrix.prototype.multiply = function<T extends Matrix>(this: T, x: T): T {
const y: Matrix = new Matrix(r1, c2);

try {
if (!(this.data instanceof Float64Array) || !(this.data instanceof Float32Array)) {
this.type = Float32Array;
this.data = Float32Array.from(this.data);
if (!['float32', 'float64'].includes(this.dtype)) {
this.dtype = 'float32';
this.data = get_type(this.dtype).from(this.data);
}

if (this.data instanceof Float64Array) {
if (this.dtype === 'float64') {
nblas.dgemm(nblas.NoTrans, nblas.NoTrans, r1, c2, c1, 1, this.data, c1, x.data, c2, 0, y.data, c2);
} else if (this.data instanceof Float32Array) {
} else if (this.dtype === 'float32') {
nblas.sgemm(nblas.NoTrans, nblas.NoTrans, r1, c2, c1, 1, this.data, c1, x.data, c2, 0, y.data, c2);
}
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/rank.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import { Matrix } from './';

describe('rank', () => {
describe('(Matrix) rank', () => {
it('should work as expected', () => {
const x: Matrix = new Matrix([[1, 2, 1], [-2, -3, 1], [3, 5, 0]]);
const y: Matrix = new Matrix([[1, 1, 1], [2, 2, 2], [3, 3, 3]]);
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/rowAdd.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {

import { Matrix } from './';

describe('rowAdd', () => {
describe('(Matrix) rowAdd', () => {
it('should work as expected', () => {
const x: Matrix = new Matrix([[1, 2], [3, 4]]);
const y: Matrix = new Matrix([[31, 42], [3, 4]]);
Expand Down
2 changes: 1 addition & 1 deletion src/Matrix/solve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {

import { Matrix } from './';

describe('solve', () => {
describe('(Matrix) solve', () => {
it('should work as expected', () => {
const x: Matrix = new Matrix([[1, 3, 5], [2, 4, 7], [1, 1, 0]]);
const y: Matrix = new Matrix([[1], [3], [5]]);
Expand Down
Loading

0 comments on commit df5e1fa

Please sign in to comment.