diff --git a/.eslintrc b/.eslintrc index 62c05ad..f281ce1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -35,7 +35,6 @@ "no-alert": 0 }, "env": { - "browser": true, "node": true } } \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 918f47c..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "examples/ml_lab"] - path = examples/ml_lab - url = ../ml_lab.git diff --git a/documentation/docs/AFArray.md b/documentation/docs/AFArray.md deleted file mode 100644 index 7d63502..0000000 --- a/documentation/docs/AFArray.md +++ /dev/null @@ -1,391 +0,0 @@ -# AFArray class - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__array__mat.htm) - -## TOC - - - - -- [Staitc methods](#staitc-methods) - - [AFArray.create()](#afarraycreate) -- [constructor](#constructor) -- [Methods](#methods) - - [elements()](#elements) - - [host()](#host) - - [copyToHost()](#copytohost) - - [scalar()](#scalar) - - [value()](#value) - - [write()](#write) - - [type()](#type) - - [dims()](#dims) - - [numdims()](#numdims) - - [numDims()](#numdims) - - [bytes()](#bytes) - - [as()](#as) - - [copy()](#copy) - - [isempty(), isscalar(), isvector(), isrow(), iscolumn(), iscomplex(), isreal(), isdouble(), issingle(), isrealfloating(), isfloating(), isinteger(), isbool()](#isempty-isscalar-isvector-isrow-iscolumn-iscomplex-isreal-isdouble-issingle-isrealfloating-isfloating-isinteger-isbool) - - [eval()](#eval) -- [Indexing Operations](#indexing-operations) - - [at()](#at) - - [row(), rows()](#row-rows) - - [col(), cols()](#col-cols) - - [slice(), slices()](#slice-slices) -- [Assignment Operators](#assignment-operators) -- [Arithmetic Operators](#arithmetic-operators) -- [Logical Operators](#logical-operators) - - - -## Staitc methods - -### AFArray.create() - -asynchronous, counterparts: `createAsync`, `createSync` - -Creates an AFArray instance of the specified dimensions, and copies data from the location specified by the buffer. Data can be reside on the host or on the device, the `source` argument specifies its location. - -- `create(dim0, type, buffer, source, callback)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#ga8c330c41d6e06b0dea9377ef02762c6f) -- `create(dim0, dim1, type, buffer, source, callback)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#gaa2ebe6a7b991fbe6231321138e79121c) -- `create(dim0, dim1, dim2, type, buffer, source, callback)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#gabd3d95b130bdb2d7e713414687e6b15a) -- `create(dim0, dim1, dim2, dim3, type, buffer, source, callback)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#gaaa8fab98447367bc4eaf3d7bc61d8ff5) -- `create(dims, buffer, source, callback)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#ga1144078b1596e7d29f57b1a0a1c9b1a8) - -**Arguments:** - -- **dim0 .. dim3: Number** - size of the dimension -- **dims: Array|[Dim4](Dim4)** - specifies sizes of the dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) -- **buffer: Buffer** - data to copy to the device, or device pointer created by the `alloc` method. -- **source: value of [source](enums/#source)** - can be one of the values of source object (eg. `source.host`) - -**Result**: the created AFArray instance. - -## constructor - -Arrays could be created as empty ones or by having a specified dimensions and element type. - -- `new AFArray()`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#ga9cbcfcbf0173e1edaf4094bb36b34b31) -- `new AFArray(dim0, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#ga73cb9e2360cecbc511b87abf76b6d631) -- `new AFArray(dim0, dim1, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#ga1f0b51e20111680c7fe3c74d54c982dd) -- `new AFArray(dim0, dim1, dim2, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#ga69c9fa684e0b0beaf657ac1dc03afa56) -- `new AFArray(dim0, dim1, dim2, dim3, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#ga6bc7bac9bb52349c198fa0861b5004b7) -- `new AFArray(dims, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__construct__mat.htm#ga5686344bf8a49be5286892998d309619) - -**Arguments:** - -- **dim0 .. dim3: Number** - size of the dimension -- **dims: Array|[Dim4](Dim4)** - specifies sizes of the dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) - -**Remarks:** - -In Fire.js `type` argument is **not optional**. - -## Methods - -### elements() - -Get the number of elements in array. - -- `elements()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#gaf343b49d35978f4b617a65b83a7affb4) - -**Result:** Number - -### host() - -Copy array data to host. - -asynchronous, counterparts: `hostAsync`, `hostSync` - -- `host(callback)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#gad65cdb27b05827c55d4e2f59f6bbf2b4) -- `host(buffer, callback)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#ga67d1d90fb9f4423a68333104230d930d) - -**Arguments:** - -- **buffer: Buffer** - to hold array's values, must be atleast the size of the array. - -**Result:** if buffer is not specified, then it will be created and returned, otherwise the result is `undefined` - -### copyToHost() - -alias of [host](#host) - -### scalar() - -asynchronous, counterparts: `scalarAsync`, `scalarSync` - -Get scalar value from the array (if its size is larger than one in any dimensions it gives the first value). - -- `scalar(callback)` - -**Result: Boolean|Number|String|[Complex](Complex)** value in the array, type depends on the array's type. - -### value() - -alias of [scalar()](#scalar) - -### write() - -Perform deep copy from host/device pointer to an existing array. - -- `write(buffer, bytesToCopy, source, callback)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#gaa70b253da2d32394c521a815f7627116) - -**Arguments:** - -- **buffer: Buffer** - data to copy to the array, or device pointer created by the `alloc` method. -- **bytesToCopy**: bytes to copy -- **source: value of [source](enums/#source)** - can be one of the values of source object (eg. `source.host`) - -### type() - -- `type()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#ga0844daa9b8cc7b7912e89a3d8ddf1a4b) - -**Result:** array's element type, can be one of the values of **[dType](enums/#dtype)** object - -### dims() - -- `dims()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#gaf056729e3ff924f5c1d41e0a8db3ce1b) -- `dims(n)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#ga30abc2404f8202bb6ac736282a9d18b7) - -**Result:** -- of `dims()`: array's dimensions info in a **[Dim4](Dim4)** object instance -- of `dims(n)`: size of the specified dimension - -### numdims() - -- `numdims()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#ga269a19b0320a93f19314d4903045b067) - -**Result:** number of dimensions of the array - -### numDims() - -alias of [numdims](#numdims) - -### bytes() - -- `bytes()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#gae9a95268261b397cae87b47a59b7e3cb) - -**Result:** size of the array in bytes - -### as() - -Converts the array into another type. - -- `as(type)` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#ga28967fdd5fff8001f4ef6181d9b186fb) - -**Arguments:** - -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) - -**Result:** AFArray instance holding reference the converted array - -### copy())` - -- `copy()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#gad79c786c646fe05a18e208eabf4dae94) - -**Result:** new AFArray instance holding a deep copy of the array - -### isempty(), isscalar(), isvector(), isrow(), iscolumn(), iscomplex(), isreal(), isdouble(), issingle(), isrealfloating(), isfloating(), isinteger(), isbool() - -aliases respectively: `isEmpty`, `isScalar`, `isVector`, `isRow`, `isColumn`, `isComplex`, `isReal`, `isDouble`, `isSingle`, `isRealFloating`, `isFloating`, `isInteger`, `isBool` - -- `is`() [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#gabe874940ae5ed8c40a8f99913982e657) - -**Result:** actual type info (Boolean) - -### eval() - -- `eval()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__method__mat.htm#ga01195c59132e1b0af7655075ba770581) - -Evaluate any JIT expressions to generate data for the array. - -## Indexing Operations - -### at() - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__array__mem__operator__paren.htm) - -- `at(s0)` -- `at(s0, s1)` -- `at(s0, s1, s2)` -- `at(s0, s1, s2, s3)` -- `at(def)` - -**Arguments**: - -- **s0 .. s3: null|String|Number|[Seq](Seq)|AFArray** - - **null:** means `"span"` - - **String:** can be `"span"` - - **Number:** element's index, or -1 which means the last element - - **[Seq](Seq):** sequence of values - - **AFArray:** array holding the index value -- **def**: [Row](Row)|[Rows](Rows)|[Col](Col)|[Cols](Cols)|[Slice](Slice)|[Slices](Slice) - - [Row](Row): specified row - - [Rows](Rows): specified rows - - [Col](Col): specified column - - [Cols](Cols): specified columns - - [Slice](Slice): specified slice - - [Slices](Slices): specified slices - -**Result:** AFArray instance holding reference to the the specified region of the original array - -### row(), rows() - -Gets a reference of a row in a 2D AFArray. - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__array__mem__row.htm) - -- `row(index)` -- `rows(firstIndex, lastIndex)` - -**Arguments**: - -- **index, fistIndex, lastIndex: Number** - a row index or a range of row indices - -**Result:** AFArray instance holding reference to the specified region of the original 2D array - -### col(), cols() - -Gets a reference of a column in a 2D AFArray. - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__array__mem__col.htm) - -- `col(index)` -- `cols(firstIndex, lastIndex)` - -**Arguments**: - -- **index, fistIndex, lastIndex: Number** - a column index or a range of column indices - -**Result:** AFArray instance holding reference to the specified region of the original 2D array - -### slice(), slices() - -Gets a reference of a matrix in a 3D AFArray. - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__array__mem__slice.htm) - -- `slice(index)` -- `slices(firstIndex, lastIndex)` - -**Arguments**: - -- **index, fistIndex, lastIndex: Number** - a matrix index or a range of matrix indices - -**Result:** AFArray instance holding reference to the specified region of the original 3D array - -## Assignment Operators - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__index__mat.htm) - -- `assign(other)` operator = -- `set(other)` operator = (alias of assign) -- `addAssign(other)` operator += -- `subAssign(other)` operator -= -- `mulAssign(other)` operator *= -- `divAssign(other)` operator /= -- `assign(s0, other)` operator = -- `set(s0, other)` operator = (alias of assign) -- `addAssign(s0, other)` operator += -- `subAssign(s0, other)` operator -= -- `mulAssign(s0, other)` operator *= -- `divAssign(s0, other)` operator /= -- `assign(s0, s1, other)` operator = -- `set(s0, s1, other)` operator = (alias of assign) -- `addAssign(s0, s1, other)` operator += -- `subAssign(s0, s1, other)` operator -= -- `mulAssign(s0, s1, other)` operator *= -- `divAssign(s0, s1, other)` operator /= -- `assign(s0, s1, s2, other)` operator = -- `set(s0, s1, s2, other)` operator = (alias of assign) -- `addAssign(s0, s1, s2, other)` operator += -- `subAssign(s0, s1, s2, other)` operator -= -- `mulAssign(s0, s1, s2, other)` operator *= -- `divAssign(s0, s1, s2, other)` operator /= -- `assign(s0, s1, s2, s3, other)` operator = -- `set(s0, s1, s2, s3, other)` operator = (alias of assign) -- `addAssign(s0, s1, s2, s3, other)` operator += -- `subAssign(s0, s1, s2, s3, other)` operator -= -- `mulAssign(s0, s1, s2, s3, other)` operator *= -- `divAssign(s0, s1, s2, s3, other)` operator /= -- `assign(def, other)` operator = -- `set(def, other)` operator = (alias of assign) -- `addAssign(def, other)` operator += -- `subAssign(def, other)` operator -= -- `mulAssign(def, other)` operator *= -- `divAssign(def, other)` operator /= - -**Arguments**: - -- **s0 .. s3: null|String|Number|[Seq](Seq)|AFArray** lhs index - - **null:** means `"span"` - - **String:** can be `"span"` - - **Number:** element's index, or -1 which means the last element - - **[Seq](Seq):** sequence of values - - **AFArray:** array holding the index value -- **def**: [Row](Row)|[Rows](Rows)|[Col](Col)|[Cols](Cols)|[Slice](Slice)|[Slices](Slice) - - [Row](Row): specified row - - [Rows](Rows): specified rows - - [Col](Col): specified column - - [Cols](Cols): specified columns - - [Slice](Slice): specified slice - - [Slices](Slices): specified slices -- **other: AFArray|Number|[Complex](Complex)|String** - - **AFArray:** rhs array - - **Number:** rhs number - - **[Complex](Complex):** rhs complex value - - **String:**: rhs number value (to workaround JavaScript inability to hold int64 values) - -**Result:** assignee AFArray instance - -## Arithmetic Operators - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__arith__mat.htm) - -- `add(other)` operator + -- `sub(other)` operator - -- `mul(other)` operator * -- `div(other)` operator / -- `bitshiftl(other)` operator << -- `bitShiftL(other)` operator << (alias of bitshiftl) -- `bitshiftr(other)` operator << -- `bitShiftR(other)` operator << (alias of bitshiftr) - -**Arguments**: - -- **other: AFArray|Number|[Complex](Complex)|String** - - **AFArray:** rhs array - - **Number:** rhs number - - **[Complex](Complex):** rhs complex value - - **String:**: rhs number value (to workaround JavaScript inability to hold int64 values) - -**Result:** AFArray instance holding the operation's result - -## Logical Operators - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__logic__mat.htm) - -- `neg()` operator - -- `not()` operator ! -- `lt(other)` operator < -- `gt(other)` operator > -- `le(other)` operator <= -- `ge(other)` operator >= -- `eq(other)` operator == -- `neq(other)` operator != -- `and(other)` operator && -- `or(other)` operator || -- `bitAnd(other)` operator & -- `bitOr(other)` operator | -- `bitXor(other)` operator ^ - -**Arguments**: - -- **other: AFArray|Number|[Complex](Complex)|String** - - **AFArray:** rhs array - - **Number:** rhs number - - **[Complex](Complex):** rhs complex value - - **String:**: rhs number value (to workaround JavaScript inability to hold int64 values) - -**Result:** AFArray instance holding the operation's result \ No newline at end of file diff --git a/documentation/docs/Col.md b/documentation/docs/Col.md deleted file mode 100644 index a88bc15..0000000 --- a/documentation/docs/Col.md +++ /dev/null @@ -1,15 +0,0 @@ -# Col class - -## constructor - -- `new Col(index)` - -**Arguments**: - -- **index: Number** - column index - -## Properties - -### index - -**Value:** column index \ No newline at end of file diff --git a/documentation/docs/Cols.md b/documentation/docs/Cols.md deleted file mode 100644 index 7456588..0000000 --- a/documentation/docs/Cols.md +++ /dev/null @@ -1,20 +0,0 @@ -# Cols class - -## constructor - -- `new Cols(firstIndex, lastIndex)` - -**Arguments**: - -- **firstIndex: Number** - first col index -- **lastIndex: Number** - last col index - -## Properties - -### firstIndex - -**Value:** first col index - -### lastIndex - -**Value:** last col index \ No newline at end of file diff --git a/documentation/docs/Complex.md b/documentation/docs/Complex.md deleted file mode 100644 index 5d40bb9..0000000 --- a/documentation/docs/Complex.md +++ /dev/null @@ -1,20 +0,0 @@ -# Complex class - -## constructor - -- `new Complex(real, imag)` - -**Arguments**: - -- **real: Number** - real part of the value -- **imag: Number** - imaginary part of the value - -## Properties - -### real - -**Value:** real part of the value - -### imag - -**Value:** imaginary part of the value \ No newline at end of file diff --git a/documentation/docs/Dim4.md b/documentation/docs/Dim4.md deleted file mode 100644 index a4e4e5d..0000000 --- a/documentation/docs/Dim4.md +++ /dev/null @@ -1,27 +0,0 @@ -# Dim4 class - -## constructors - -- `new Dim4(dimArray)` -- `new Dim4(dim0, dim1, dim2, dim3)` - -**Arguments**: - -- **dimArray: Array** - array holding dimension sizes, eg.: [1, 2], [1, 5, 6], [4, 5, 1, 1] -- **dim0 .. dim3: Number** - size of the dimension, default is 1 - -## Properties - -### values - -**Value:** **Array** containing the dimension sizes, eg.: two dimensions = `[2, 3, 1, 1]`, four dimensions = `[2, 3, 4, 5]` - -### ndims - -alias: `nDims` - -**Value:** number of dimensions - -### elements - -**Value:** number of elements (dim0 * dim1 * dim2 * dim3) \ No newline at end of file diff --git a/documentation/docs/Row.md b/documentation/docs/Row.md deleted file mode 100644 index 0b5a520..0000000 --- a/documentation/docs/Row.md +++ /dev/null @@ -1,15 +0,0 @@ -# Row class - -## constructor - -- `new Row(index)` - -**Arguments**: - -- **index: Number** - row index - -## Properties - -### index - -**Value:** row index \ No newline at end of file diff --git a/documentation/docs/Rows.md b/documentation/docs/Rows.md deleted file mode 100644 index aedc7c5..0000000 --- a/documentation/docs/Rows.md +++ /dev/null @@ -1,20 +0,0 @@ -# Rows class - -## constructor - -- `new Rows(firstIndex, lastIndex)` - -**Arguments**: - -- **firstIndex: Number** - first row index -- **lastIndex: Number** - last row index - -## Properties - -### firstIndex - -**Value:** first row index - -### lastIndex - -**Value:** last row index \ No newline at end of file diff --git a/documentation/docs/Seq.md b/documentation/docs/Seq.md deleted file mode 100644 index a147346..0000000 --- a/documentation/docs/Seq.md +++ /dev/null @@ -1,26 +0,0 @@ -# Seq class - -## constructors - -- `new Seq(begin, end)` -- `new Seq(begin, end, step)` - -**Arguments**: - -- **begin: Number** - begin of sequence values -- **end: Number** - end of sequence values -- **step: Number** - step size (default is 1) - -## Properties - -### begin - -**Value:** begin of sequence values - -### end - -**Value:** end of sequence values - -### step - -**Value:** step size \ No newline at end of file diff --git a/documentation/docs/Slice.md b/documentation/docs/Slice.md deleted file mode 100644 index 637838e..0000000 --- a/documentation/docs/Slice.md +++ /dev/null @@ -1,15 +0,0 @@ -# Slice class - -## constructor - -- `new Slice(index)` - -**Arguments**: - -- **index: Number** - slice index - -## Properties - -### index - -**Value:** slice index \ No newline at end of file diff --git a/documentation/docs/Slices.md b/documentation/docs/Slices.md deleted file mode 100644 index f7beece..0000000 --- a/documentation/docs/Slices.md +++ /dev/null @@ -1,20 +0,0 @@ -# Slices class - -## constructor - -- `new Slices(firstIndex, lastIndex)` - -**Arguments**: - -- **firstIndex: Number** - first slice index -- **lastIndex: Number** - last slice index - -## Properties - -### firstIndex - -**Value:** first slice index - -### lastIndex - -**Value:** last slice index \ No newline at end of file diff --git a/documentation/docs/create.md b/documentation/docs/create.md deleted file mode 100644 index d0f8287..0000000 --- a/documentation/docs/create.md +++ /dev/null @@ -1,151 +0,0 @@ -# Functions to create arrays - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__mat.htm) - -## TOC - - - - -- [randu()](#randu) -- [randU()](#randu) -- [randn()](#randn) -- [randN()](#randn) -- [identity()](#identity) -- [range()](#range) -- [iota()](#iota) -- [diag()](#diag) -- [constant()](#constant) - - - -## randu() - -Create a random array sampled from uniform distribution. - -- `randu(dim0, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randu.htm#gab3e2105aec551cb0bbcf104d437c0481) -- `randu(dim0, dim1, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randu.htm#ga9a08025609da7db72c3a22493f85a171) -- `randu(dim0, dim1, dim2, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randu.htm#gae0d335466e5f5a1cb821dc241804923b) -- `randu(dim0, dim1, dim2, dim3, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randu.htm#gac05c5b2de1cfc2d763b7d2943e9deee3) -- `randu(dims, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randu.htm#ga15a5110a447509cab9589b2ad56c5e55) - -**Arguments:** - -- **dim0 .. dim3: Number** - size of the dimension -- **dims: Array|[Dim4](Dim4)** - specifies sizes of the dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) - -**Result**: the created AFArray instance. - -## randU() - -alias of [randu()](#randu) - -## randn() - -Create a random array sampled from normal distribution. - -- `randn(dim0, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randn.htm#ga5d7b55d3d0f34d71f30a70ed7a2d928d) -- `randn(dim0, dim1, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randn.htm#ga5fe422f8cf2acc3c6f782f9148360f6c) -- `randn(dim0, dim1, dim2, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randn.htm#ga150fb95ddda0e37e8961254ca7afc8e5) -- `randn(dim0, dim1, dim2, dim3, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randn.htm#ga9bc154f0bf07116ad208b2da4b71c3d8) -- `randn(dims, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__randn.htm#gae8aa1f5ec310aeb9e4cbd19d63998349) - -**Arguments:** - -- **dim0 .. dim3: Number** - size of the dimension -- **dims: Array|[Dim4](Dim4)** - specifies sizes of the dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) - -**Result**: the created AFArray instance. - -## randN() - -alias of [randn()](#randn) - -## identity() - -Create an identity matrix (array with diagonal values 1). - -- `identity(dim0, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__identity.htm#ga3f69c0a0ab7ba0c8c1ee3223772234b8) -- `identity(dim0, dim1, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__identity.htm#gaff9da6e4b83772359d748a4df66ec571) -- `identity(dim0, dim1, dim2, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__identity.htm#ga405b89c8f04901d58287fd6a8f5612c3) -- `identity(dim0, dim1, dim2, dim3, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__identity.htm#ga8e6605d76748c5fff365830e1a153132) -- `identity(dims, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__identity.htm#gafd8247e22fdb50218926d5d9391fa678) - -**Arguments:** - -- **dim0 .. dim3: Number** - size of the dimension -- **dims: Array|[Dim4](Dim4)** - specifies sizes of the dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) - -**Result**: the created AFArray instance. - -## range() - -Creates an array with [0, n] values along the seqDim which is tiled across other dimensions. - -- `range(dim0, seqDim, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__range.htm#ga1e2ae1f90d99f42854a19877261ac455) -- `range(dim0, dim1, seqDim, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__range.htm#ga1e2ae1f90d99f42854a19877261ac455) -- `range(dim0, dim1, dim2, seqDim, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__range.htm#ga1e2ae1f90d99f42854a19877261ac455) -- `range(dim0, dim1, dim2, dim3, seqDim, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__range.htm#ga1e2ae1f90d99f42854a19877261ac455) -- `range(dims, seqDim, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__range.htm#ga3789475e962b4c31e07c1c3bdab8498b) - -**Arguments:** - -- **dim0 .. dim3: Number** - size of the dimension -- **dims: Array|[Dim4](Dim4)** - specifies sizes of the dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **seqDim: Number** - dimension along which [0, dim[seqDim] - 1] is generated, default is -1, which means the last specified dimension -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) - -**Result**: the created AFArray instance. - -## iota() - -Create an sequence [0, dims.elements - 1] and modify to specified dimensions dims and then tile it according to tileDims. - -- `iota(dims, tileDims, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__iota.htm#ga8f7c55a54d1f93e55340f59b61662f29) - -**Arguments:** - -- **dims: Array|[Dim4](Dim4)** - specifies sizes of the dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **tileDims: Array|[Dim4](Dim4)** - specifies the tiling dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) - -**Result**: the created AFArray instance. - -## diag() - -Extract diagonal from a matrix when `extract` is set to `true`. - -Create a diagonal marix from input array when `extract` is set to `false`. - -- `diag(in, num, extract)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__data__func__diag.htm#ga0cf9ea583e513631ed0226aa08ff60da) - -**Arguments:** - -- **in: AFArray** - input array -- **num: Number** - diagonal index -- **extract: Boolean** - when true returns an array containing diagonal of tha matrix and when false returns a matrix with in as diagonal - -## constant() - -Create an array filled with the specified value. - -- `constant(value, dim0, type)` -- `constant(value, dim0, dim1, type)` -- `constant(value, dim0, dim1, dim2, type)` -- `constant(value, dim0, dim1, dim2, dim3, type)` -- `constant(value, dims, type)` - -**Arguments:** - -- **value: Number|[Complex](Complex)|String** - - **Number:** number - - **[Complex](Complex):** complex value - - **String:**: number value (to workaround JavaScript inability to hold int64 values) -- **dim0 .. dim3: Number** - size of the dimension -- **dims: Array|[Dim4](Dim4)** - specifies sizes of the dimensions, eg: `[2, 1, 1]` or `new Dim4(3, 4)` -- **type: value of [dType](enums/#dtype)** - can be one of the values of dType object (eg. `dType.f32`) - -**Result**: the created AFArray instance. \ No newline at end of file diff --git a/documentation/docs/devices.md b/documentation/docs/devices.md deleted file mode 100644 index 8c7be1c..0000000 --- a/documentation/docs/devices.md +++ /dev/null @@ -1,144 +0,0 @@ -# Platform and Device managing - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__mat.htm) - - - - - -- [Selecting Platform](#selecting-platform) -- [getDeviceCount()](#getdevicecount) -- [getDevices()](#getdevices) -- [getDevice()](#getdevice) -- [setDevice()](#setdevice) -- [deviceInfo()](#deviceinfo) -- [isDoubleAvailable()](#isdoubleavailable) -- [sync()](#sync) -- [wait()](#wait) -- [alloc()](#alloc) -- [pinned()](#pinned) - - - -## Selecting Platform - -Fire.js platform can be selected by calling the root function with the appropriate platform ID as an argument. - -Supported platform IDs: - -- `CPU` (cpu fallback) -- `OpenCL` -- `CUDA` - -**Example:** - -```js -var af = require("arrayfire-js"); -var cpuPlatform = af("CPU"); -``` - -## getDeviceCount() - -Gets the number of devices on the given platform. - -- `getDeviceCount()`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__func__count.htm) - -**Result: Number** - number of devices - -**Example:** - -```js -var af = require("arrayfire-js"); -var cpuPlatform = af("CPU"); -var deviceCount = cpuPlatform.getDeviceCount(); -``` - -## getDevices() - -Gets available device descriptors on the given platform. - -- `getDevices()` - -**Result: Array** - array of [device descriptors](#deviceinfo) - -## getDevice() - -Get the current device ID. - -- `getDevice()`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__func__get.htm) - -**Result: Number** - current device ID - -## setDevice() - -Change current device to specified device. - -- `setDevice(id)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__func__set.htm) - -## deviceInfo() - -Get the current device's descriptor. - -- `deviceInfo()`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__func__prop.htm) - -**Result: object** - fields - -- **name: String** - device's vendor specified name -- **platform: String** - ID of the platform (CPU, OpenCL, CUDA) -- **toolkit: String** - device's vendor specified platform name -- **compute: String** - device's vendor specified version -- **isDoubleAvailable: Boolean** - is double precision supported - -## isDoubleAvailable() - -Check if double precision support is available for specified device. - -- `isDoubleAvailable(deviceID)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__func__dbl.htm) - -**Argments:** - -- **deviceID: Number** - device's ID - -**Result: Booean** - is double precision supported - -## sync() - -asynchronous, counterparts: `syncAsync`, `syncSync` - -Waits until all operations on device are finished. - -- `sync()`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__func__sync.htm) - -## wait() - -alias of [sync()](#sync) - -## alloc() - -Allocates memory on the device. - -- `alloc(elements, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__func__alloc.htm) - -**Arguments:** - -- **elements: Number** - number of elements to allocate -- **type: value of [dType](enums/#dtype)** - type of the elements, can be one of the values of dType object (eg. `dType.f32`) - -**Result: Buffer** - device memory pointer - -**Remarks:** Deallocation is handled by the GC automatically - -## pinned() - -Allocates pinned memory on the host by using ArrayFire's memory manager. - -- `pinned(elements, type)`: [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__device__func__pinned.htm) - -**Arguments:** - -- **elements: Number** - number of elements to allocate -- **type: value of [dType](enums/#dtype)** - type of the elements, can be one of the values of dType object (eg. `dType.f32`) - -**Result: Buffer** - memory pointer - -**Remarks:** Deallocation is handled by the GC automatically \ No newline at end of file diff --git a/documentation/docs/enums.md b/documentation/docs/enums.md deleted file mode 100644 index bec10c9..0000000 --- a/documentation/docs/enums.md +++ /dev/null @@ -1,219 +0,0 @@ -# Static Objects - -They are accessible from the main Fire.js context object, eg.: - -```js -var af = require("arrayfire-js")("CPU"); - -// dType: -var dType = af.dType; -``` - -## TOC - - - - - -- [dType](#dtype) -- [source](#source) -- [matchType](#matchtype) -- [borderType](#bordertype) -- [connectivity](#connectivity) -- [convDomain](#convdomain) -- [convMode](#convmode) -- [cSpace](#cspace) -- [interpType](#interptype) -- [matProp](#matprop) -- [normType](#normtype) - - - -## dType - -alias: `dtype` - -```js -{ - f32: 0, // float - c32: 1, // complex of float - f64: 2, // double - c64: 3, // complex of double - b8: 4, // boolean (8 bits) - s32: 5, // int - u32: 6, // uint - u8: 7, // byte - s64: 8, // int64 - u64: 9 // uint64 -} -``` - -## source - -```js -{ - device: 0, - host: 1, - // ArrayFire convention compatible aliases: - afDevice: 0, - afHost: 1 -} -``` - -## matchType - -```js -{ - SAD: 0, // Match based on Sum of Absolute Differences (SAD) - zSAD: 1, // Match based on Zero mean SAD. - lSAD: 2, // Match based on Locally scaled SAD. - SSD: 3, // Match based on Sum of Squared Differences (SSD) - zSSD: 4, // Match based on Zero mean SSD. - lSSD: 5, // Match based on Locally scaled SSD. - NCC: 6, // Match based on Normalized Cross Correlation (NCC) - zNCC: 7, // Match based on Zero mean NCC. - SHD: 8, // Match based on Sum of Hamming Distances (SHD) - // ArrayFire convention compatible aliases: - AF_SAD: 0, - AF_ZSAD: 1, - AF_LSAD: 2, - AF_SSD: 3, - AF_ZSSD: 4, - AF_LSSD: 5, - AF_NCC: 6, - AF_ZNCC: 7, - AF_SHD: 8 -} -``` - -## borderType - -```js -{ - padZero: 0, - padSym: 1, - // ArrayFire convention compatible aliases: - AF_PAD_ZERO: 0, - AF_PAD_SYM: 1 -} -``` - -## connectivity - -```js -{ - connectivity4: 4, - connectivity8: 8, - // ArrayFire convention compatible aliases: - AF_CONNECTIVITY_4: 4, - AF_CONNECTIVITY_8: 8 -} -``` - -## convDomain - -```js -{ - auto: 0, ///< ArrayFire automatically picks the right convolution algorithm - spatial: 1, ///< Perform convolution in spatial domain - freq: 2, ///< Perform convolution in frequency domain - // ArrayFire convention compatible aliases: - AF_CONV_AUTO: 0, ///< ArrayFire automatically picks the right convolution algorithm - AF_CONV_SPATIAL: 1, ///< Perform convolution in spatial domain - AF_CONV_FREQ: 2 ///< Perform convolution in frequency domain -} -``` - -## convMode - -```js -{ - /// - /// Output of the convolution is the same size as input - /// - default: 0, - /// - /// Output of the convolution is signal_len + filter_len - 1 - /// - expand: 1, - // ArrayFire convention compatible aliases: - AF_CONV_DEFAULT: 0, - AF_CONV_EXPAND: 1 -} -``` - -## cSpace - -```js -{ - Gray: 0, ///< Grayscale - RGB: 1, ///< 3-channel RGB - HSV: 2, ///< 3-channel HSV - // ArrayFire convention compatible aliases: - AF_GRAY: 0, ///< Grayscale - AF_RGB: 1, ///< 3-channel RGB - AF_HSV: 2 ///< 3-channel HSV -} -``` - -## interpType - -```js -{ - nearest: 0, ///< Nearest Interpolation - linear: 1, ///< Linear Interpolation - bilinerar : 2, ///< Bilinear Interpolation - cubic: 3, ///< Cubic Interpolation, - // ArrayFire convention compatible aliases: - AF_INTERP_NEAREST: 0, ///< Nearest Interpolation - AF_INTERP_LINEAR: 1, ///< Linear Interpolation - AF_INTERP_BILINEAR : 2, ///< Bilinear Interpolation - AF_INTERP_CUBIC: 3 ///< Cubic Interpolation -} -``` - -## matProp - -```js -{ - none : 0, ///< Default - trans : 1, ///< Data needs to be transposed - cTrans : 2, ///< Data needs to be conjugate tansposed - upper : 32, ///< Matrix is upper triangular - lower : 64, ///< Matrix is lower triangular - diagUnit : 128, ///< Matrix diagonal contains unitary values - sym : 512, ///< Matrix is symmetric - posDef : 1024, ///< Matrix is positive definite - orthog : 2048, ///< Matrix is orthogonal - triDiag : 4096, ///< Matrix is tri diagonal - blockDiag : 8192, ///< Matrix is block diagonal - // ArrayFire convention compatible aliases: - AF_MAT_NONE : 0, ///< Default - AF_MAT_TRANS : 1, ///< Data needs to be transposed - AF_MAT_CTRANS : 2, ///< Data needs to be conjugate tansposed - AF_MAT_UPPER : 32, ///< Matrix is upper triangular - AF_MAT_LOWER : 64, ///< Matrix is lower triangular - AF_MAT_DIAG_UNIT : 128, ///< Matrix diagonal contains unitary values - AF_MAT_SYM : 512, ///< Matrix is symmetric - AF_MAT_POSDEF : 1024, ///< Matrix is positive definite - AF_MAT_ORTHOG : 2048, ///< Matrix is orthogonal - AF_MAT_TRI_DIAG : 4096, ///< Matrix is tri diagonal - AF_MAT_BLOCK_DIAG : 8192 ///< Matrix is block diagonal -} -``` - -## normType - -```js -{ - nearest: 0, ///< Nearest Interpolation - linear: 1, ///< Linear Interpolation - bilinerar : 2, ///< Bilinear Interpolation - cubic: 3, ///< Cubic Interpolation, - // ArrayFire convention compatible aliases: - AF_INTERP_NEAREST: 0, ///< Nearest Interpolation - AF_INTERP_LINEAR: 1, ///< Linear Interpolation - AF_INTERP_BILINEAR : 2, ///< Bilinear Interpolation - AF_INTERP_CUBIC: 3 ///< Cubic Interpolation -} -``` \ No newline at end of file diff --git a/documentation/docs/helpers.md b/documentation/docs/helpers.md deleted file mode 100644 index 67054fa..0000000 --- a/documentation/docs/helpers.md +++ /dev/null @@ -1,44 +0,0 @@ -# Helper function for arrays - -[-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__helper__mat.htm) - -## TOC - - - - - -- [iszero()](#iszero) -- [isZero()](#iszero) -- [isInf()](#isinf) -- [isNaN()](#isnan) - - - -## iszero() - -Check if values are zero. - -- `iszero()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__arith__func__iszero.htm) - -**Result: AFArray:** containing 1's where input is zero, and 0 otherwise. - -## isZero() - -alias of [iszero()](#iszero) - -## isInf() - -Check if values are infinite. - -- `isInf()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__arith__func__isinf.htm) - -**Result: AFArray:** containing 1's where input is infinity, and 0 otherwise. - -## isNaN() - -Check if values are Nan. - -- `isNaN()` [-> ArrayFire Documentation](http://www.arrayfire.com/docs/group__arith__func__isnan.htm) - -**Result: AFArray:** containing 1's where input is NaN, and 0 otherwise. \ No newline at end of file diff --git a/documentation/docs/index.md b/documentation/docs/index.md deleted file mode 100644 index 95366e0..0000000 --- a/documentation/docs/index.md +++ /dev/null @@ -1,92 +0,0 @@ -# About ArrayFire - -*"ArrayFire is a high performance software library for parallel computing with an easy-to-use API. Its array based function set makes parallel programming more accessible."* - -You can read its introduction [int its documentation's index page](http://www.arrayfire.com/docs/index.htm). It's basically a math accelerator C++ library supporting CPU and GPU based backends on Windows, Linux and Mac. And it's just **awesome**. It's extremely simple to write the most complex mathematical, statistical, logical computations, image transformations and computer vision algorigthms with it, just a few lines of code. It has excellent batching capability that takes simple operations, make a big computation from them, and runs all at once on the GPU device. - -# About ArrayFire.js - -ArrayFire.js is the Node.js bindings for ArrayFire, it uses [CMake.js](https://github.com/unbornchikken/cmake-js) as of its build system. It takes Node.js' insane level of productivity and mix that with ArrayFire's insane level of performance and simplicity. You'll get something like Matlab just in familiar JavaScript with performance of level of x100 (with a good GPU). - -Install instructions can be found in the [project's readme at Github](https://github.com/arrayfire/arrayfire-js#install). - -## (How To) Use ES6 Generators - -The original ArrayFire library contains a lot of functions that blocks. They are often run at O(n) atleast on CPU backend, or do some blocking initialization work on first call on OpenCL/CUDA platforms. Because of this those functions are wrapped asynchronously, and can be called with traditional Node.js callbacks, eg.: - -```js -fire.srqt(input, function(err, output) { - if (err) { - // crash :) - } - else { - // continue work .. - } -}); -``` - -Yeah, this is annoying and ugly compared to the original (blocking) C++ code. The good news is that can be improved by using ES6 generators. Each asynchronous ArrayFire.js method has two counterparts. One synchronous, ends with `"Sync"` (eg. `sqrtSync`). Those are just for supporting REPL prototyping scenarios, not intended to use in production code, because those blocks the event loop and uses spin locks. The other is an asynchronous version that returns a [Bluebird promise](https://www.npmjs.com/package/bluebird), ends with `"Async"` (eg. `sqrtAsync`). Wrap an [ES6 generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) by a [coroutine](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisecoroutinegeneratorfunction-generatorfunction---function), and you can yield those promises from there: - -```js -let async = Bluebird.coroutine; - -let f = async(function*() { - let values = yield fire.sqrtAsync(input); - let output = yield fire.sqrtAsync(input); -}); -``` - -And voila, you can write asynchronous code that looks like synchronous. It's exactly the same thing those [async/await features](https://msdn.microsoft.com/en-us/library/hh191443.aspx) that C# guys have! (Of course you can use some other coroutine library, like [co](https://www.npmjs.com/package/co).) - -To run ES6 code you can use io.js that supports it inherently. Or use Node.js 0.12+ with --harmony flag. Or you can go with older Node.js versions with Gulp and Traceur modules. - -Even you can use feature detection and can write code that can run on each platform choosing ES5 or ES6 code paths depending of the actual runtime. ArrayFire.js uses that method too. It has been developed in ES6, and uses [Gulp/Traceur](https://github.com/arrayfire/arrayfire-js/blob/master/gulpfile.js) and [feature detection](https://github.com/arrayfire/arrayfire-js/blob/master/lib/index.js#L19) to fallback to manually compiled ES5 code on older runtimes. If you need further information about this topic, please open up an issue on Github, and I'll help you out with this there. - -## API - -In ArrayFire.js all ArrayFire types and functions are ported with respect of the original C++ syntax. There are some exceptions when it was neccessary. Many methods have an alias to provide them a counterpart using Node.js (camelCased) conventions. - -All asynchronous methods have promise based and synhronous counterparts as mentioned in the previous topic with `Async` and `Sync` endings rescpectively. This methods have the same signature like the originals, except the callback at the last argument. - -## Small Example - -Port of the PI calculator from [ArrayFire documentation](http://www.arrayfire.com/docs/index.htm): - -**C++** - -```C++ -// sample 40 million points on the GPU -array x = randu(20e6), y = randu(20e6); -array dist = sqrt(x * x + y * y); - -// pi is ratio of how many fell in the unit circle -float num_inside = sum(dist < 1); -float pi = 4.0 * num_inside / 20e6; -af_print(pi); -``` - -**JavaScript** - -```js -const numberOfPoints = 20000000; - -// ... - -let x = af.randu(numberOfPoints, af.dtype.f32); -let y = af.randu(numberOfPoints, af.dtype.f32); -let dist = af.sqrt(x.mul(x).add(y.mul(y))); -let numInside = yield af.sumAsync(dist.lt(1)); -let piVal = (4.0 * numInside) / numberOfPoints; - -console.log(`PI = ${piVal}`); -``` - -It's included in the [examples folder](https://github.com/arrayfire/arrayfire-js/blob/master/examples/es6/bechmarks/pi.js). To run on: - -- io.js, enter: `iojs examples/es6/bechmarks/pi.js` -- Node.js 0.12 or above, enter: `node --harmony examples/es6/bechmarks/pi.js` -- Node.js below 0.12, enter: `node examples/es5/bechmarks/pi.js` - -## License - -[New BSD](https://github.com/arrayfire/arrayfire-js/blob/master/LICENSE) \ No newline at end of file diff --git a/documentation/mkdocs.yml b/documentation/mkdocs.yml deleted file mode 100644 index 8df6db0..0000000 --- a/documentation/mkdocs.yml +++ /dev/null @@ -1,21 +0,0 @@ -site_name: ArrayFire.js Documentation -pages: -- Home: index.md -- Classes: - - AFArray: AFArray.md - - Dim4: Dim4.md - - Seq: Seq.md - - Complex: Complex.md - - Row: Row.md - - Rows: Rows.md - - Col: Col.md - - Cols: Cols.md - - Slice: Slice.md - - Slices: Slices.md -- Functions: - - Platform and Device managing: devices.md - - Functions to create arrays: create.md - - Helper function for arrays: helpers.md -- Enums: enums.md -theme: united -repo_url: https://github.com/arrayfire/arrayfire_js \ No newline at end of file diff --git a/examples/es5/bechmarks/pi.js b/examples/es5/bechmarks/pi.js deleted file mode 100644 index b97beea..0000000 --- a/examples/es5/bechmarks/pi.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var common = require("../common"); - -var numberOfPoints = 20000000; - -var pi = async(regeneratorRuntime.mark(function _callee(af, deviceInfo) { - var AFArray, x, y, dist, numInside, piVal; - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - AFArray = af.AFArray; - - console.log("Calculating pi on device:\n"); - common.printDeviceInfo(deviceInfo); - console.log(""); - - x = af.randu(numberOfPoints, af.dtype.f32); - y = af.randu(numberOfPoints, af.dtype.f32); - dist = af.sqrt(x.mul(x).add(y.mul(y))); - _context.next = 9; - return af.sumAsync(dist.lt(1)); - - case 9: - numInside = _context.sent; - piVal = 4.0 * numInside / numberOfPoints; - - console.log("PI = " + piVal); - - case 12: - case "end": - return _context.stop(); - } - } - }, _callee, this); -})); - -common.runOnAllPlatforms(pi, "pi example"); -//# sourceMappingURL=pi.js.map diff --git a/examples/es5/bechmarks/pi.js.map b/examples/es5/bechmarks/pi.js.map deleted file mode 100644 index 0a29baf..0000000 --- a/examples/es5/bechmarks/pi.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["bechmarks/pi.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AACb,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC;AAC/B,IAAI,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;;AAElC,IAAM,cAAc,GAAG,QAAQ,CAAC;;AAEhC,IAAI,EAAE,GAAG,KAAK,yBAAC,iBAAU,EAAE,EAAE,UAAU;QAC/B,OAAO,EAMP,CAAC,EACD,CAAC,EACD,IAAI,EACJ,SAAS,EACT,KAAK;;;;;AAVL,2BAAO,GAAG,EAAE,CAAC,OAAO;;AAExB,2BAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAC3C,0BAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AACnC,2BAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;;AAEZ,qBAAC,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;AAC1C,qBAAC,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;AAC1C,wBAAI,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;;2BACpB,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;;;AAAzC,6BAAS;AACT,yBAAK,GAAG,AAAC,GAAG,GAAI,SAAS,GAAI,cAAc;;AAE/C,2BAAO,CAAC,GAAG,WAAS,KAAK,CAAG,CAAC;;;;;;;;CAChC,EAAC,CAAC;;AAEH,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC","file":"bechmarks/pi.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet common = require(\"../common\");\r\n\r\nconst numberOfPoints = 20000000;\r\n\r\nlet pi = async(function*(af, deviceInfo) {\r\n let AFArray = af.AFArray;\r\n\r\n console.log(\"Calculating pi on device:\\n\");\r\n common.printDeviceInfo(deviceInfo);\r\n console.log(\"\");\r\n\r\n let x = af.randu(numberOfPoints, af.dtype.f32);\r\n let y = af.randu(numberOfPoints, af.dtype.f32);\r\n let dist = af.sqrt(x.mul(x).add(y.mul(y)));\r\n let numInside = yield af.sumAsync(dist.lt(1));\r\n let piVal = (4.0 * numInside) / numberOfPoints;\r\n\r\n console.log(`PI = ${piVal}`);\r\n});\r\n\r\ncommon.runOnAllPlatforms(pi, \"pi example\");\r\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/examples/es5/common/index.js b/examples/es5/common/index.js deleted file mode 100644 index 673659b..0000000 --- a/examples/es5/common/index.js +++ /dev/null @@ -1,277 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var af = require("../../.."); -var util = require("util"); -var now = require("performance-now"); -var _ = require("lodash"); - -var runOnDevices = async(regeneratorRuntime.mark(function _callee(platformID, f, onID) { - var afOfPlatform, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, deviceInfo, start, end; - - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - afOfPlatform = af(platformID); - _iteratorNormalCompletion = true; - _didIteratorError = false; - _iteratorError = undefined; - _context.prev = 4; - _iterator = afOfPlatform.getDevices()[Symbol.iterator](); - - case 6: - if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { - _context.next = 18; - break; - } - - deviceInfo = _step.value; - - if (!(_.isUndefined(onID) || onID === deviceInfo.id)) { - _context.next = 15; - break; - } - - afOfPlatform.setDevice(deviceInfo.id); - start = now(); - _context.next = 13; - return f(afOfPlatform, deviceInfo); - - case 13: - end = now(); - - console.log("\n-- took " + ((end - start) / 1000).toFixed(10) + " seconds\n"); - - case 15: - _iteratorNormalCompletion = true; - _context.next = 6; - break; - - case 18: - _context.next = 24; - break; - - case 20: - _context.prev = 20; - _context.t0 = _context["catch"](4); - _didIteratorError = true; - _iteratorError = _context.t0; - - case 24: - _context.prev = 24; - _context.prev = 25; - - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - - case 27: - _context.prev = 27; - - if (!_didIteratorError) { - _context.next = 30; - break; - } - - throw _iteratorError; - - case 30: - return _context.finish(27); - - case 31: - return _context.finish(24); - - case 32: - case "end": - return _context.stop(); - } - } - }, _callee, this, [[4, 20, 24, 32], [25,, 27, 31]]); -})); - -var runOnAllPlatforms = async(regeneratorRuntime.mark(function _callee2(f, name) { - var platfroms, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, id; - - return regeneratorRuntime.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - platfroms = af.supportedPlatforms(); - - console.log("Running " + name + " on all supported platfroms: " + platfroms.join(", ") + "\n"); - _context2.prev = 2; - _iteratorNormalCompletion2 = true; - _didIteratorError2 = false; - _iteratorError2 = undefined; - _context2.prev = 6; - _iterator2 = platfroms[Symbol.iterator](); - - case 8: - if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) { - _context2.next = 15; - break; - } - - id = _step2.value; - _context2.next = 12; - return runOnDevices(id, f); - - case 12: - _iteratorNormalCompletion2 = true; - _context2.next = 8; - break; - - case 15: - _context2.next = 21; - break; - - case 17: - _context2.prev = 17; - _context2.t0 = _context2["catch"](6); - _didIteratorError2 = true; - _iteratorError2 = _context2.t0; - - case 21: - _context2.prev = 21; - _context2.prev = 22; - - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - - case 24: - _context2.prev = 24; - - if (!_didIteratorError2) { - _context2.next = 27; - break; - } - - throw _iteratorError2; - - case 27: - return _context2.finish(24); - - case 28: - return _context2.finish(21); - - case 29: - _context2.next = 34; - break; - - case 31: - _context2.prev = 31; - _context2.t1 = _context2["catch"](2); - - console.error(_context2.t1.stack); - - case 34: - case "end": - return _context2.stop(); - } - } - }, _callee2, this, [[2, 31], [6, 17, 21, 29], [22,, 24, 28]]); -})); - -var runOnBestDevice = async(regeneratorRuntime.mark(function _callee3(f, name) { - var platfroms, order; - return regeneratorRuntime.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - platfroms = af.supportedPlatforms(); - order = ["CUDA", "OpenCL", "CPU"]; - - console.log("Running " + name + " on best available device.\n"); - _context3.prev = 3; - - if (!_(platfroms).contains(order[0])) { - _context3.next = 9; - break; - } - - _context3.next = 7; - return runOnDevices(order[0], f, 0); - - case 7: - _context3.next = 16; - break; - - case 9: - if (!_(platfroms).contains(order[1])) { - _context3.next = 14; - break; - } - - _context3.next = 12; - return runOnDevices(order[1], f, 0); - - case 12: - _context3.next = 16; - break; - - case 14: - _context3.next = 16; - return runOnDevices(order[2], f, 0); - - case 16: - _context3.next = 21; - break; - - case 18: - _context3.prev = 18; - _context3.t0 = _context3["catch"](3); - - console.error(_context3.t0.stack); - - case 21: - case "end": - return _context3.stop(); - } - } - }, _callee3, this, [[3, 18]]); -})); - -var printDeviceInfo = function printDeviceInfo(deviceInfo) { - console.log("ID: " + deviceInfo.id + "\nName: " + deviceInfo.name + "\nPlatform: " + deviceInfo.platform + "\nToolkit: " + deviceInfo.toolkit + "\nCompute: " + deviceInfo.compute); -}; - -module.exports = { - runOnAllPlatforms: runOnAllPlatforms, - runOnBestDevice: runOnBestDevice, - printDeviceInfo: printDeviceInfo -}; -//# sourceMappingURL=index.js.map diff --git a/examples/es5/common/index.js.map b/examples/es5/common/index.js.map deleted file mode 100644 index a8fa1b7..0000000 --- a/examples/es5/common/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["common/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AACb,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,KAAK,GAAG,QAAQ,C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mBAAe,EAAE,eAAe;AAChC,mBAAe,EAAE,eAAe;CACnC,CAAC","file":"common/index.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet af = require(\"../../..\");\r\nlet util = require(\"util\");\r\nlet now = require(\"performance-now\");\r\nlet _ = require(\"lodash\");\r\n\r\nlet runOnDevices = async(function*(platformID, f, onID) {\r\n let afOfPlatform = af(platformID);\r\n for (let deviceInfo of afOfPlatform.getDevices()) {\r\n if (_.isUndefined(onID) || onID === deviceInfo.id) {\r\n afOfPlatform.setDevice(deviceInfo.id);\r\n const start = now();\r\n yield f(afOfPlatform, deviceInfo);\r\n const end = now();\r\n console.log(`\\n-- took ${((end - start) / 1000).toFixed(10)} seconds\\n`);\r\n }\r\n }\r\n});\r\n\r\nlet runOnAllPlatforms = async(function*(f, name) {\r\n let platfroms = af.supportedPlatforms();\r\n console.log(`Running ${name} on all supported platfroms: ${platfroms.join(\", \")}\\n`);\r\n try {\r\n for (let id of platfroms) {\r\n yield runOnDevices(id, f);\r\n }\r\n }\r\n catch (e) {\r\n console.error(e.stack);\r\n }\r\n});\r\n\r\nlet runOnBestDevice = async(function*(f, name) {\r\n let platfroms = af.supportedPlatforms();\r\n let order = [\"CUDA\", \"OpenCL\", \"CPU\"];\r\n console.log(`Running ${name} on best available device.\\n`);\r\n try {\r\n if (_(platfroms).contains(order[0])) {\r\n yield runOnDevices(order[0], f, 0);\r\n }\r\n else if (_(platfroms).contains(order[1])) {\r\n yield runOnDevices(order[1], f, 0);\r\n }\r\n else {\r\n yield runOnDevices(order[2], f, 0);\r\n }\r\n }\r\n catch (e) {\r\n console.error(e.stack);\r\n }\r\n});\r\n\r\nlet printDeviceInfo = function (deviceInfo) {\r\n console.log(`ID: ${deviceInfo.id}\\nName: ${deviceInfo.name}\\nPlatform: ${deviceInfo.platform}\\nToolkit: ${deviceInfo.toolkit}\\nCompute: ${deviceInfo.compute}`);\r\n};\r\n\r\nmodule.exports = {\r\n runOnAllPlatforms: runOnAllPlatforms,\r\n runOnBestDevice: runOnBestDevice,\r\n printDeviceInfo: printDeviceInfo\r\n};\r\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/examples/es5/machine-learning/ann.js b/examples/es5/machine-learning/ann.js deleted file mode 100644 index 0ae610b..0000000 --- a/examples/es5/machine-learning/ann.js +++ /dev/null @@ -1,151 +0,0 @@ -"use strict"; - -var _ = require("lodash"); -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var debug = require("debug")("af:ann"); -var now = require("performance-now"); - -function ANN(af, layers, range) { - range = range || 0.05; - this.af = af; - this.numLayers = layers.length; - this.signal = []; - this.weights = []; - for (var i = 0; i < this.numLayers; i++) { - this.signal.push(new af.AFArray()); - if (i < this.numLayers - 1) { - var w = af.randu(layers[i] + 1, layers[i + 1], af.dType.f32).mul(range).sub(range / 2); - this.weights.push(w); - } - } -} - -var proto = ANN.prototype; - -proto.deriv = function (out) { - return out.rhsSub(1).mul(out); -}; - -proto.addBias = function (input) { - return this.af.join(1, this.af.constant(1, input.dims(0), this.af.dType.f32), input); -}; - -proto._calculateError = function (out, pred) { - var dif = out.sub(pred); - var sq = dif.mul(dif); - return Math.sqrt(this.af.sum(sq)) / sq.elements(); -}; - -proto.forwardPropagate = function (input) { - var _this = this; - - this.signal[0].set(input); - - var _loop = function _loop(i) { - var self = _this; - _this.af.scope(function () { - var inVec = self.addBias(self.signal[i]); - var outVec = self.af.matMul(inVec, self.weights[i]); - self.signal[i + 1].set(self.af.sigmoid(outVec)); - }); - }; - - for (var i = 0; i < this.numLayers - 1; i++) { - _loop(i); - } -}; - -proto.backPropagate = function (target, alpha) { - var self = this; - var af = self.af; - var Seq = self.af.Seq; - - // Get error for output layer - af.scope(function () { - var outVec = self.signal[self.numLayers - 1]; - var err = outVec.sub(target); - var m = target.dims(0); - - var _loop2 = function _loop2(i) { - af.scope(function () { - var inVec = self.addBias(self.signal[i]); - var delta = af.transpose(self.deriv(outVec).mul(err)); - - // Adjust weights - var grad = af.matMul(delta, inVec).mul(alpha).neg().div(m); - self.weights[i].addAssign(af.transpose(grad)); - - // Input to current layer is output of previous - outVec = self.signal[i]; - err.set(self.af.matMulTT(delta, self.weights[i])); - - // Remove the error of bias and propagate backward - err.set(err.at(af.span, new Seq(1, outVec.dims(1)))); - }); - }; - - for (var i = self.numLayers - 2; i >= 0; i--) { - _loop2(i); - } - }); -}; - -proto.predict = function (input) { - this.forwardPropagate(input); - return this.signal[this.numLayers - 1].copy(); -}; - -proto.train = function (input, target, options) { - var self = this; - var af = self.af; - var Seq = self.af.Seq; - - var numSamples = input.dims(0); - var numBatches = numSamples / options.batchSize; - - var err = 0; - - for (var i = 0; i < options.maxEpochs; i++) { - var start = now(); - - var _loop3 = function _loop3(j) { - af.scope(function () { - var startPos = j * options.batchSize; - var endPos = startPos + options.batchSize - 1; - - var x = input.at(new Seq(startPos, endPos), af.span); - var y = target.at(new Seq(startPos, endPos), af.span); - - self.forwardPropagate(x); - self.backPropagate(y, options.alpha); - }); - }; - - for (var j = 0; j < numBatches - 1; j++) { - _loop3(j); - } - - af.scope(function () { - // Validate with last batch - var startPos = (numBatches - 1) * options.batchSize; - var endPos = numSamples - 1; - var outVec = self.predict(input.at(new Seq(startPos, endPos), af.span)); - err = self._calculateError(outVec, target.at(new Seq(startPos, endPos), af.span)); - }); - - var end = now(); - console.log("Epoch: " + (i + 1) + ", Error: " + err.toFixed(6) + ", Duration: " + ((end - start) / 1000).toFixed(4) + " seconds"); - - // Check if convergence criteria has been met - if (err < options.maxError) { - console.log("Converged on Epoch: " + (i + 1)); - break; - } - } - - return err; -}; - -module.exports = ANN; -//# sourceMappingURL=ann.js.map diff --git a/examples/es5/machine-learning/ann.js.map b/examples/es5/machine-learning/ann.js.map deleted file mode 100644 index c86e089..0000000 --- a/examples/es5/machine-learning/ann.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["machine-learning/ann.js"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,S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CAAA,iBAAY,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAe,CAAC,CAAC,GAAG,GAAG,KAAK,CAAA,GAAI,IAAI,CAAA,CAAE,OAAO,CAAC,CAAC,CAAC,cAAW;;;AAAC,AAGjH,YAAI,GAAG,GAAG,OAAO,CAAC,QAAQ,EAAE;AACxB,mBAAO,CAAC,GAAG,2BAAwB,CAAC,GAAG,CAAC,CAAA,CAAG,CAAC;AAC5C,kBAAM;SACT;KACJ;;AAED,WAAO,GAAG,CAAC;CACd,CAAC;;AAEF,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC","file":"machine-learning/ann.js","sourcesContent":["\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet debug = require(\"debug\")(\"af:ann\");\r\nlet now = require(\"performance-now\");\r\n\r\nfunction ANN(af, layers, range) {\r\n range = range || 0.05;\r\n this.af = af;\r\n this.numLayers = layers.length;\r\n this.signal = [];\r\n this.weights = [];\r\n for (let i = 0; i < this.numLayers; i++) {\r\n this.signal.push(new af.AFArray());\r\n if (i < this.numLayers - 1) {\r\n let w = af.randu(layers[i] + 1, layers[i + 1], af.dType.f32).mul(range).sub(range / 2);\r\n this.weights.push(w);\r\n }\r\n }\r\n}\r\n\r\nlet proto = ANN.prototype;\r\n\r\nproto.deriv = function (out) {\r\n return out.rhsSub(1).mul(out);\r\n};\r\n\r\nproto.addBias = function (input) {\r\n return this.af.join(1, this.af.constant(1, input.dims(0), this.af.dType.f32), input);\r\n};\r\n\r\nproto._calculateError = function(out, pred) {\r\n let dif = out.sub(pred);\r\n let sq = dif.mul(dif);\r\n return Math.sqrt(this.af.sum(sq)) / sq.elements();\r\n};\r\n\r\nproto.forwardPropagate = function (input) {\r\n this.signal[0].set(input);\r\n for (let i = 0; i < this.numLayers - 1; i++) {\r\n let self = this;\r\n this.af.scope(function() {\r\n let inVec = self.addBias(self.signal[i]);\r\n let outVec = self.af.matMul(inVec, self.weights[i]);\r\n self.signal[i + 1].set(self.af.sigmoid(outVec));\r\n });\r\n }\r\n};\r\n\r\nproto.backPropagate = function (target, alpha) {\r\n let self = this;\r\n let af = self.af;\r\n let Seq = self.af.Seq;\r\n\r\n // Get error for output layer\r\n af.scope(function() {\r\n let outVec = self.signal[self.numLayers - 1];\r\n let err = outVec.sub(target);\r\n let m = target.dims(0);\r\n\r\n for (let i = self.numLayers - 2; i >= 0; i--) {\r\n af.scope(function() {\r\n let inVec = self.addBias(self.signal[i]);\r\n let delta = af.transpose(self.deriv(outVec).mul(err));\r\n\r\n // Adjust weights\r\n let grad = af.matMul(delta, inVec).mul(alpha).neg().div(m);\r\n self.weights[i].addAssign(af.transpose(grad));\r\n\r\n // Input to current layer is output of previous\r\n outVec = self.signal[i];\r\n err.set(self.af.matMulTT(delta, self.weights[i]));\r\n\r\n // Remove the error of bias and propagate backward\r\n err.set(err.at(af.span, new Seq(1, outVec.dims(1))));\r\n });\r\n }\r\n });\r\n};\r\n\r\nproto.predict = function (input) {\r\n this.forwardPropagate(input);\r\n return this.signal[this.numLayers - 1].copy();\r\n};\r\n\r\nproto.train = function(input, target, options) {\r\n let self = this;\r\n let af = self.af;\r\n let Seq = self.af.Seq;\r\n\r\n let numSamples = input.dims(0);\r\n let numBatches = numSamples / options.batchSize;\r\n\r\n let err = 0;\r\n\r\n for (let i = 0; i < options.maxEpochs; i++) {\r\n const start = now();\r\n for (let j = 0; j < numBatches - 1; j++) {\r\n af.scope(() => {\r\n let startPos = j * options.batchSize;\r\n let endPos = startPos + options.batchSize - 1;\r\n\r\n let x = input.at(new Seq(startPos, endPos), af.span);\r\n let y = target.at(new Seq(startPos, endPos), af.span);\r\n\r\n self.forwardPropagate(x);\r\n self.backPropagate(y, options.alpha);\r\n });\r\n }\r\n\r\n af.scope(() => {\r\n // Validate with last batch\r\n let startPos = (numBatches - 1) * options.batchSize;\r\n let endPos = numSamples - 1;\r\n let outVec = self.predict(input.at(new Seq(startPos, endPos), af.span));\r\n err = self._calculateError(outVec, target.at(new Seq(startPos, endPos), af.span));\r\n });\r\n\r\n const end = now();\r\n console.log(`Epoch: ${i + 1}, Error: ${err.toFixed(6)}, Duration: ${((end - start) / 1000).toFixed(4)} seconds`);\r\n\r\n // Check if convergence criteria has been met\r\n if (err < options.maxError) {\r\n console.log(`Converged on Epoch: ${i + 1}`);\r\n break;\r\n }\r\n }\r\n\r\n return err;\r\n};\r\n\r\nmodule.exports = ANN;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/examples/es5/machine-learning/mnist.js b/examples/es5/machine-learning/mnist.js deleted file mode 100644 index 3ea282c..0000000 --- a/examples/es5/machine-learning/mnist.js +++ /dev/null @@ -1,247 +0,0 @@ -"use strict"; - -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var fs = Bluebird.promisifyAll(require("fs-extra")); -var ref = require("ref"); -var float = ref.types.float; -var uint = ref.types.uint; -var debug = require("debug")("af:mnist"); -var _ = require("lodash"); -var assert = require("better-assert"); -var path = require("path"); - -var readData = async(regeneratorRuntime.mark(function _callee(f, data) { - var bytesRead; - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _context.next = 2; - return fs.readAsync(f, data, 0, data.length, null); - - case 2: - bytesRead = _context.sent; - - if (!(bytesRead !== data.length)) { - _context.next = 5; - break; - } - - throw new Error("File reading error!"); - - case 5: - case "end": - return _context.stop(); - } - } - }, _callee, this); -})); - -var readIdx = async(regeneratorRuntime.mark(function _callee2(path, type) { - var file, d, numDims, elem, dims, i, dim, bdata, data, byte; - return regeneratorRuntime.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - _context2.next = 2; - return fs.openAsync(path, "r"); - - case 2: - file = _context2.sent; - _context2.prev = 3; - d = new Buffer(4); - _context2.next = 7; - return readData(file, d); - - case 7: - if (!(d[2] != 8)) { - _context2.next = 9; - break; - } - - throw new Error("Unsupported data type"); - - case 9: - numDims = d[3]; - - // Read the dimensions - - elem = 1; - dims = []; - i = 0; - - case 13: - if (!(i < numDims)) { - _context2.next = 22; - break; - } - - _context2.next = 16; - return readData(file, d); - - case 16: - dim = d.readUInt32BE(); - - elem *= dim; - dims.push(dim); - - case 19: - i++; - _context2.next = 13; - break; - - case 22: - - // Read the data - bdata = new Buffer(elem); - _context2.next = 25; - return readData(file, bdata); - - case 25: - data = new Buffer(bdata.length * type.size); - - for (i = 0; i < bdata.length; i++) { - byte = bdata[i]; - - type.set(data, i * type.size, byte); - } - - return _context2.abrupt("return", { - numDims: numDims, - dims: dims, - data: data - }); - - case 28: - _context2.prev = 28; - _context2.next = 31; - return fs.closeAsync(file); - - case 31: - return _context2.finish(28); - - case 32: - case "end": - return _context2.stop(); - } - } - }, _callee2, this, [[3,, 28, 32]]); -})); - -var mnist = { - setup: async(regeneratorRuntime.mark(function _callee3(af, expandLabels, frac) { - var dataRoot, AFArray, Dim4, imageData, labelData, rIDims, images, r, cond, trainIndices, testIndices, trainImages, testImages, numClasses, numTrain, numTest, trainLabels, testLabels, hTrainIdx, hTestIdx, _i, idx, label, _i2, labels; - - return regeneratorRuntime.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - frac = Math.min(frac || 1.0, 0.8); - dataRoot = path.resolve(path.join(__dirname, "../../ml_lab/data/mnist")); - AFArray = af.AFArray; - Dim4 = af.Dim4; - _context3.next = 6; - return readIdx(path.join(dataRoot, "images-subset"), float); - - case 6: - imageData = _context3.sent; - _context3.next = 9; - return readIdx(path.join(dataRoot, "labels-subset"), uint); - - case 9: - labelData = _context3.sent; - rIDims = new Dim4(_(imageData.dims).reverse().value()); - _context3.next = 13; - return AFArray.createAsync(rIDims, af.dType.f32, imageData.data); - - case 13: - images = _context3.sent; - r = af.randu(10000, af.dType.f32); - cond = r.lt(frac); - trainIndices = af.where(cond); - testIndices = af.where(cond.not()); - trainImages = af.lookup(images, trainIndices, 2).div(255); - testImages = af.lookup(images, testIndices, 2).div(255); - numClasses = 10; - numTrain = trainImages.dims(2); - numTest = testImages.dims(2); - - debug("Training sample count: " + numTrain); - debug("Test sample count: " + numTest); - - trainLabels = undefined; - testLabels = undefined; - - if (!expandLabels) { - _context3.next = 42; - break; - } - - trainLabels = af.constant(0, numClasses, numTrain, af.dType.f32); - testLabels = af.constant(0, numClasses, numTest, af.dType.f32); - - assert(trainIndices.type() === af.dType.u32); - assert(testIndices.type() === af.dType.u32); - - _context3.next = 34; - return trainIndices.hostAsync(); - - case 34: - hTrainIdx = _context3.sent; - _context3.next = 37; - return testIndices.hostAsync(); - - case 37: - hTestIdx = _context3.sent; - - for (_i = 0; _i < numTrain; _i++) { - idx = uint.get(hTrainIdx, _i * uint.size); - label = uint.get(labelData.data, idx * uint.size); - - assert(label >= 0 && label <= 9); - trainLabels.set(label, _i, 1); - } - - for (_i2 = 0; _i2 < numTest; _i2++) { - idx = uint.get(hTestIdx, _i2 * uint.size); - label = uint.get(labelData.data, idx * uint.size); - - assert(label >= 0 && label <= 9); - testLabels.set(label, _i2, 1); - } - _context3.next = 47; - break; - - case 42: - _context3.next = 44; - return AFArray.createAsync(labelData.dims[0], af.dType.u32, labelData.data); - - case 44: - labels = _context3.sent; - - trainLabels = labels.at(trainIndices); - testLabels = labels.at(testIndices); - - case 47: - return _context3.abrupt("return", { - numClasses: numClasses, - numTrain: numTrain, - numTest: numTest, - trainImages: trainImages, - testImages: testImages, - trainLabels: trainLabels, - testLabels: testLabels - }); - - case 48: - case "end": - return _context3.stop(); - } - } - }, _callee3, this); - })) -}; - -module.exports = mnist; -//# sourceMappingURL=mnist.js.map diff --git a/examples/es5/machine-learning/mnist.js.map b/examples/es5/machine-learning/mnist.js.map deleted file mode 100644 index af2062a..0000000 --- a/examples/es5/machine-learning/mnist.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["machine-learning/mnist.js"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,IAAI,QAAQ,GAAG,OAA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"use strict\";\r\n\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet fs = Bluebird.promisifyAll(require(\"fs-extra\"));\r\nlet ref = require(\"ref\");\r\nlet float = ref.types.float;\r\nlet uint = ref.types.uint;\r\nlet debug = require(\"debug\")(\"af:mnist\");\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\nlet path = require(\"path\");\r\n\r\nlet readData = async(function*(f, data) {\r\n let bytesRead = yield fs.readAsync(f, data, 0, data.length, null);\r\n if (bytesRead !== data.length) {\r\n throw new Error(\"File reading error!\");\r\n }\r\n});\r\n\r\nlet readIdx = async(function*(path, type) {\r\n let file = yield fs.openAsync(path, \"r\");\r\n try {\r\n let d = new Buffer(4);\r\n\r\n yield readData(file, d);\r\n\r\n if (d[2] != 8) {\r\n throw new Error(\"Unsupported data type\");\r\n }\r\n\r\n const numDims = d[3];\r\n\r\n // Read the dimensions\r\n let elem = 1;\r\n let dims = [];\r\n for (let i = 0; i < numDims; i++) {\r\n yield readData(file, d);\r\n let dim = d.readUInt32BE();\r\n elem *= dim;\r\n dims.push(dim);\r\n }\r\n\r\n // Read the data\r\n let bdata = new Buffer(elem);\r\n yield readData(file, bdata);\r\n let data = new Buffer(bdata.length * type.size);\r\n for (let i = 0; i < bdata.length; i++) {\r\n let byte = bdata[i];\r\n type.set(data, i * type.size, byte);\r\n }\r\n\r\n return {\r\n numDims: numDims,\r\n dims: dims,\r\n data: data\r\n };\r\n }\r\n finally {\r\n yield fs.closeAsync(file);\r\n }\r\n});\r\n\r\nlet mnist = {\r\n setup: async(function*(af, expandLabels, frac) {\r\n frac = Math.min(frac || 1.0, 0.8);\r\n let dataRoot = path.resolve(path.join(__dirname, \"../../ml_lab/data/mnist\"));\r\n let AFArray = af.AFArray;\r\n let Dim4 = af.Dim4;\r\n\r\n let imageData = yield readIdx(path.join(dataRoot, \"images-subset\"), float);\r\n let labelData = yield readIdx(path.join(dataRoot, \"labels-subset\"), uint);\r\n\r\n let rIDims = new Dim4(_(imageData.dims).reverse().value());\r\n let images = yield AFArray.createAsync(rIDims, af.dType.f32, imageData.data);\r\n\r\n let r = af.randu(10000, af.dType.f32);\r\n let cond = r.lt(frac);\r\n let trainIndices = af.where(cond);\r\n let testIndices = af.where(cond.not());\r\n\r\n let trainImages = af.lookup(images, trainIndices, 2).div(255);\r\n let testImages = af.lookup(images, testIndices, 2).div(255);\r\n\r\n let numClasses = 10;\r\n let numTrain = trainImages.dims(2);\r\n let numTest = testImages.dims(2);\r\n\r\n debug(`Training sample count: ${numTrain}`);\r\n debug(`Test sample count: ${numTest}`);\r\n\r\n let trainLabels;\r\n let testLabels;\r\n\r\n if (expandLabels) {\r\n trainLabels = af.constant(0, numClasses, numTrain, af.dType.f32);\r\n testLabels = af.constant(0, numClasses, numTest, af.dType.f32);\r\n\r\n assert(trainIndices.type() === af.dType.u32);\r\n assert(testIndices.type() === af.dType.u32);\r\n\r\n let hTrainIdx = yield trainIndices.hostAsync();\r\n let hTestIdx = yield testIndices.hostAsync();\r\n\r\n for (let i = 0; i < numTrain; i++) {\r\n let idx = uint.get(hTrainIdx, i * uint.size);\r\n let label = uint.get(labelData.data, idx * uint.size);\r\n assert(label >= 0 && label <= 9);\r\n trainLabels.set(label, i, 1);\r\n }\r\n\r\n for (let i = 0; i < numTest; i++) {\r\n let idx = uint.get(hTestIdx, i * uint.size);\r\n let label = uint.get(labelData.data, idx * uint.size);\r\n assert(label >= 0 && label <= 9);\r\n testLabels.set(label, i, 1);\r\n }\r\n }\r\n else {\r\n let labels = yield AFArray.createAsync(labelData.dims[0], af.dType.u32, labelData.data);\r\n trainLabels = labels.at(trainIndices);\r\n testLabels = labels.at(testIndices);\r\n }\r\n\r\n return {\r\n numClasses: numClasses,\r\n numTrain: numTrain,\r\n numTest: numTest,\r\n trainImages: trainImages,\r\n testImages: testImages,\r\n trainLabels: trainLabels,\r\n testLabels: testLabels\r\n };\r\n })\r\n};\r\n\r\nmodule.exports = mnist;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/examples/es5/machine-learning/neuralNetwork.js b/examples/es5/machine-learning/neuralNetwork.js deleted file mode 100644 index 8a37427..0000000 --- a/examples/es5/machine-learning/neuralNetwork.js +++ /dev/null @@ -1,80 +0,0 @@ -"use strict"; - -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var common = require("../common"); -var mnist = require("./mnist"); -var ANN = require("./ann"); -var now = require("performance-now"); - -var accuracy = function accuracy(af, predicted, target) { - var pMax = af.findMaxAt(predicted, 1); - var tMax = af.findMaxAt(target, 1); - return 100 * af.count(pMax.index.eq(tMax.index)) / tMax.index.elements(); -}; - -var annDemo = async(regeneratorRuntime.mark(function _callee(af, deviceInfo) { - var data, featureSize, trainFeats, testFeats, trainTarget, testTarget, network, start, end, trainOutput, testOutput; - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - console.log("Running ANN Demo on device:\n"); - common.printDeviceInfo(deviceInfo); - console.log(""); - - console.log("Setting up training data."); - _context.next = 6; - return mnist.setup(af, true, 0.6); - - case 6: - data = _context.sent; - featureSize = data.trainImages.elements() / data.numTrain; - - // Reshape images into feature vectors - - trainFeats = af.transpose(af.modDims(data.trainImages, featureSize, data.numTrain)); - testFeats = af.transpose(af.modDims(data.testImages, featureSize, data.numTest)); - trainTarget = af.transpose(data.trainLabels); - testTarget = af.transpose(data.testLabels); - network = new ANN(af, [trainFeats.dims(1), 100, 50, data.numClasses]); - - // Train network - - start = now(); - - network.train(trainFeats, trainTarget, { - alpha: 1.0, - maxEpochs: 300, - batchSize: 100, - maxError: 0.0001 - }); - _context.next = 17; - return af.waitAsync(); - - case 17: - end = now(); - - // Run the trained network and test accuracy. - - trainOutput = network.predict(trainFeats); - testOutput = network.predict(testFeats); - - console.log("Training set:"); - console.log("Accuracy on training data: " + accuracy(af, trainOutput, trainTarget).toFixed(2)); - - console.log("Test set:"); - console.log("Accuracy on testing data: " + accuracy(af, testOutput, testTarget).toFixed(2)); - - console.log("Training time: " + ((end - start) / 1000).toFixed(10) + " seconds\n"); - - case 25: - case "end": - return _context.stop(); - } - } - }, _callee, this); -})); - -common.runOnBestDevice(annDemo, "ANN Demo"); -//# sourceMappingURL=neuralNetwork.js.map diff --git a/examples/es5/machine-learning/neuralNetwork.js.map b/examples/es5/machine-learning/neuralNetwork.js.map deleted file mode 100644 index d416389..0000000 --- a/examples/es5/machine-learning/neuralNetwork.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["machine-learning/neuralNetwork.js"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC;AAC/B,IAAI,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAClC,IAAI,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAC/B,IAAI,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC3B,IAAI,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;;AAErC,IAAI,QAAQ,GAAG,SAAX,QAAQ,CAAY,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;AAC3C,QAAI,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AACtC,QAAI,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACnC,WAAO,AAAC,GAAG,GAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,AAAC,GAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;CAChF,CAAC;;AAEF,IAAI,OAAO,GAAG,KAAK,yBAAC,iBAAU,EAAE,EAAE,UAAU;QAMpC,IAAI,EAEJ,WAAW,EAGX,UAAU,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,CAAC;;2BACI,EAAE,CAAC,SAAS,EAAE;;;AACd,uBAAG,GAAG,GAAG,EAAE;;;;AAGb,+BAAW,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;AACzC,8BAAU,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;;AAE3C,2BAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC7B,2BAAO,CAAC,GAAG,iCAA+B,AAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,WAAW,CAAC,CAAE,OAAO,CAAC,CAAC,CAAC,CAAG,CAAC;;AAEjG,2BAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACzB,2BAAO,CAAC,GAAG,iCAA+B,AAAC,QAAQ,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,CAAE,OAAO,CAAC,CAAC,CAAC,CAAG,CAAC;;AAE/F,2BAAO,CAAC,GAAG,qBAAmB,CAAC,CAAC,GAAG,GAAG,KAAK,CAAA,GAAI,IAAI,CAAA,CAAE,OAAO,CAAC,EAAE,CAAC,gBAAa,CAAC;;;;;;;;CACjF,EAAC,CAAC;;AAEH,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC","file":"machine-learning/neuralNetwork.js","sourcesContent":["\"use strict\";\r\n\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet common = require(\"../common\");\r\nlet mnist = require(\"./mnist\");\r\nlet ANN = require(\"./ann\");\r\nlet now = require(\"performance-now\");\r\n\r\nlet accuracy = function(af, predicted, target) {\r\n let pMax = af.findMaxAt(predicted, 1);\r\n let tMax = af.findMaxAt(target, 1);\r\n return (100 * (af.count(pMax.index.eq(tMax.index)))) / tMax.index.elements();\r\n};\r\n\r\nlet annDemo = async(function*(af, deviceInfo) {\r\n console.log(\"Running ANN Demo on device:\\n\");\r\n common.printDeviceInfo(deviceInfo);\r\n console.log(\"\");\r\n\r\n console.log(\"Setting up training data.\");\r\n let data = yield mnist.setup(af, true, 0.6);\r\n\r\n let featureSize = data.trainImages.elements() / data.numTrain;\r\n\r\n // Reshape images into feature vectors\r\n let trainFeats = af.transpose(af.modDims(data.trainImages, featureSize, data.numTrain));\r\n let testFeats = af.transpose(af.modDims(data.testImages, featureSize, data.numTest));\r\n\r\n let trainTarget = af.transpose(data.trainLabels);\r\n let testTarget = af.transpose(data.testLabels);\r\n\r\n let network = new ANN(af, [trainFeats.dims(1), 100, 50, data.numClasses]);\r\n\r\n // Train network\r\n const start = now();\r\n network.train(\r\n trainFeats,\r\n trainTarget,\r\n {\r\n alpha: 1.0,\r\n maxEpochs: 300,\r\n batchSize: 100,\r\n maxError: 0.0001\r\n }\r\n );\r\n yield af.waitAsync();\r\n const end = now();\r\n\r\n // Run the trained network and test accuracy.\r\n let trainOutput = network.predict(trainFeats);\r\n let testOutput = network.predict(testFeats);\r\n\r\n console.log(\"Training set:\");\r\n console.log(`Accuracy on training data: ${(accuracy(af, trainOutput, trainTarget)).toFixed(2)}`);\r\n\r\n console.log(\"Test set:\");\r\n console.log(`Accuracy on testing data: ${(accuracy(af, testOutput, testTarget)).toFixed(2)}`);\r\n\r\n console.log(`Training time: ${((end - start) / 1000).toFixed(10)} seconds\\n`);\r\n});\r\n\r\ncommon.runOnBestDevice(annDemo, \"ANN Demo\");"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/examples/es6/bechmarks/pi.js b/examples/es6/bechmarks/pi.js deleted file mode 100644 index c2f5407..0000000 --- a/examples/es6/bechmarks/pi.js +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let common = require("../common"); - -const numberOfPoints = 20000000; - -let pi = async(function*(af, deviceInfo) { - let AFArray = af.AFArray; - - console.log("Calculating pi on device:\n"); - common.printDeviceInfo(deviceInfo); - console.log(""); - - let x = af.randu(numberOfPoints, af.dtype.f32); - let y = af.randu(numberOfPoints, af.dtype.f32); - let dist = af.sqrt(x.mul(x).add(y.mul(y))); - let numInside = yield af.sumAsync(dist.lt(1)); - let piVal = (4.0 * numInside) / numberOfPoints; - - console.log(`PI = ${piVal}`); -}); - -common.runOnAllPlatforms(pi, "pi example"); diff --git a/examples/es6/common/index.js b/examples/es6/common/index.js deleted file mode 100644 index ff49174..0000000 --- a/examples/es6/common/index.js +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let af = require("../../.."); -let util = require("util"); -let now = require("performance-now"); -let _ = require("lodash"); - -let runOnDevices = async(function*(platformID, f, onID) { - let afOfPlatform = af(platformID); - for (let deviceInfo of afOfPlatform.getDevices()) { - if (_.isUndefined(onID) || onID === deviceInfo.id) { - afOfPlatform.setDevice(deviceInfo.id); - const start = now(); - yield f(afOfPlatform, deviceInfo); - const end = now(); - console.log(`\n-- took ${((end - start) / 1000).toFixed(10)} seconds\n`); - } - } -}); - -let runOnAllPlatforms = async(function*(f, name) { - let platfroms = af.supportedPlatforms(); - console.log(`Running ${name} on all supported platfroms: ${platfroms.join(", ")}\n`); - try { - for (let id of platfroms) { - yield runOnDevices(id, f); - } - } - catch (e) { - console.error(e.stack); - } -}); - -let runOnBestDevice = async(function*(f, name) { - let platfroms = af.supportedPlatforms(); - let order = ["CUDA", "OpenCL", "CPU"]; - console.log(`Running ${name} on best available device.\n`); - try { - if (_(platfroms).contains(order[0])) { - yield runOnDevices(order[0], f, 0); - } - else if (_(platfroms).contains(order[1])) { - yield runOnDevices(order[1], f, 0); - } - else { - yield runOnDevices(order[2], f, 0); - } - } - catch (e) { - console.error(e.stack); - } -}); - -let printDeviceInfo = function (deviceInfo) { - console.log(`ID: ${deviceInfo.id}\nName: ${deviceInfo.name}\nPlatform: ${deviceInfo.platform}\nToolkit: ${deviceInfo.toolkit}\nCompute: ${deviceInfo.compute}`); -}; - -module.exports = { - runOnAllPlatforms: runOnAllPlatforms, - runOnBestDevice: runOnBestDevice, - printDeviceInfo: printDeviceInfo -}; diff --git a/examples/es6/machine-learning/ann.js b/examples/es6/machine-learning/ann.js deleted file mode 100644 index 7a43599..0000000 --- a/examples/es6/machine-learning/ann.js +++ /dev/null @@ -1,140 +0,0 @@ -"use strict"; - -let _ = require("lodash"); -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let debug = require("debug")("af:ann"); -let now = require("performance-now"); - -function ANN(af, layers, range) { - range = range || 0.05; - this.af = af; - this.numLayers = layers.length; - this.signal = []; - this.weights = []; - for (let i = 0; i < this.numLayers; i++) { - this.signal.push(new af.AFArray()); - if (i < this.numLayers - 1) { - let w = af.randu(layers[i] + 1, layers[i + 1], af.dType.f32).mul(range).sub(range / 2); - this.weights.push(w); - } - } -} - -let proto = ANN.prototype; - -proto.deriv = function (out) { - return out.rhsSub(1).mul(out); -}; - -proto.addBias = function (input) { - return this.af.join(1, this.af.constant(1, input.dims(0), this.af.dType.f32), input); -}; - -proto._calculateError = function(out, pred) { - let dif = out.sub(pred); - let sq = dif.mul(dif); - return Math.sqrt(this.af.sum(sq)) / sq.elements(); -}; - -proto.forwardPropagate = function (input) { - this.signal[0].set(input); - for (let i = 0; i < this.numLayers - 1; i++) { - let self = this; - this.af.scope(function() { - let inVec = self.addBias(self.signal[i]); - let outVec = self.af.matMul(inVec, self.weights[i]); - self.signal[i + 1].set(self.af.sigmoid(outVec)); - }); - } -}; - -proto.backPropagate = function (target, alpha) { - let self = this; - let af = self.af; - let Seq = self.af.Seq; - - // Get error for output layer - af.scope(function() { - let outVec = self.signal[self.numLayers - 1]; - let err = outVec.sub(target); - let m = target.dims(0); - - for (let i = self.numLayers - 2; i >= 0; i--) { - af.scope(function() { - let inVec = self.addBias(self.signal[i]); - let delta = af.transpose(self.deriv(outVec).mul(err)); - - // Adjust weights - let grad = af.matMul(delta, inVec).mul(alpha).neg().div(m); - self.weights[i].addAssign(af.transpose(grad)); - - // Input to current layer is output of previous - outVec = self.signal[i]; - err.set(self.af.matMulTT(delta, self.weights[i])); - - // Remove the error of bias and propagate backward - err.set(err.at(af.span, new Seq(1, outVec.dims(1)))); - }); - } - }); -}; - -proto.predict = function (input) { - this.forwardPropagate(input); - return this.signal[this.numLayers - 1].copy(); -}; - -proto.train = function(input, target, options) { - let self = this; - let af = self.af; - let Seq = self.af.Seq; - - let numSamples = input.dims(0); - let numBatches = numSamples / options.batchSize; - - let err = 0; - let allTime = 0; - - for (let i = 0; i < options.maxEpochs; i++) { - const start = now(); - for (let j = 0; j < numBatches - 1; j++) { - af.scope(() => { - let startPos = j * options.batchSize; - let endPos = startPos + options.batchSize - 1; - - let x = input.at(new Seq(startPos, endPos), af.span); - let y = target.at(new Seq(startPos, endPos), af.span); - - self.forwardPropagate(x); - self.backPropagate(y, options.alpha); - }); - } - - af.scope(() => { - // Validate with last batch - let startPos = (numBatches - 1) * options.batchSize; - let endPos = numSamples - 1; - let outVec = self.predict(input.at(new Seq(startPos, endPos), af.span)); - err = self._calculateError(outVec, target.at(new Seq(startPos, endPos), af.span)); - }); - - const end = now(); - allTime += (end - start) / 1000; - - if ((i + 1) % 10 === 0) { - console.log(`Epoch: ${i + 1}, Error: ${err.toFixed(6)}, Duration: ${(allTime / 10).toFixed(6)} seconds`); - allTime = 0; - } - - // Check if convergence criteria has been met - if (err < options.maxError) { - console.log(`Converged on Epoch: ${i + 1}`); - break; - } - } - - return err; -}; - -module.exports = ANN; diff --git a/examples/es6/machine-learning/mnist.js b/examples/es6/machine-learning/mnist.js deleted file mode 100644 index c8f67c9..0000000 --- a/examples/es6/machine-learning/mnist.js +++ /dev/null @@ -1,137 +0,0 @@ -"use strict"; - -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let fs = Bluebird.promisifyAll(require("fs-extra")); -let ref = require("ref"); -let float = ref.types.float; -let uint = ref.types.uint; -let debug = require("debug")("af:mnist"); -let _ = require("lodash"); -let assert = require("better-assert"); -let path = require("path"); - -let readData = async(function*(f, data) { - let bytesRead = yield fs.readAsync(f, data, 0, data.length, null); - if (bytesRead !== data.length) { - throw new Error("File reading error!"); - } -}); - -let readIdx = async(function*(path, type) { - let file = yield fs.openAsync(path, "r"); - try { - let d = new Buffer(4); - - yield readData(file, d); - - if (d[2] != 8) { - throw new Error("Unsupported data type"); - } - - const numDims = d[3]; - - // Read the dimensions - let elem = 1; - let dims = []; - for (let i = 0; i < numDims; i++) { - yield readData(file, d); - let dim = d.readUInt32BE(); - elem *= dim; - dims.push(dim); - } - - // Read the data - let bdata = new Buffer(elem); - yield readData(file, bdata); - let data = new Buffer(bdata.length * type.size); - for (let i = 0; i < bdata.length; i++) { - let byte = bdata[i]; - type.set(data, i * type.size, byte); - } - - return { - numDims: numDims, - dims: dims, - data: data - }; - } - finally { - yield fs.closeAsync(file); - } -}); - -let mnist = { - setup: async(function*(af, expandLabels, frac) { - frac = Math.min(frac || 1.0, 0.8); - let dataRoot = path.resolve(path.join(__dirname, "../../ml_lab/data/mnist")); - let AFArray = af.AFArray; - let Dim4 = af.Dim4; - - let imageData = yield readIdx(path.join(dataRoot, "images-subset"), float); - let labelData = yield readIdx(path.join(dataRoot, "labels-subset"), uint); - - let rIDims = new Dim4(_(imageData.dims).reverse().value()); - let images = yield AFArray.createAsync(rIDims, af.dType.f32, imageData.data); - - let r = af.randu(10000, af.dType.f32); - let cond = r.lt(frac); - let trainIndices = af.where(cond); - let testIndices = af.where(cond.not()); - - let trainImages = af.lookup(images, trainIndices, 2).div(255); - let testImages = af.lookup(images, testIndices, 2).div(255); - - let numClasses = 10; - let numTrain = trainImages.dims(2); - let numTest = testImages.dims(2); - - debug(`Training sample count: ${numTrain}`); - debug(`Test sample count: ${numTest}`); - - let trainLabels; - let testLabels; - - if (expandLabels) { - trainLabels = af.constant(0, numClasses, numTrain, af.dType.f32); - testLabels = af.constant(0, numClasses, numTest, af.dType.f32); - - assert(trainIndices.type() === af.dType.u32); - assert(testIndices.type() === af.dType.u32); - - let hTrainIdx = yield trainIndices.hostAsync(); - let hTestIdx = yield testIndices.hostAsync(); - - for (let i = 0; i < numTrain; i++) { - let idx = uint.get(hTrainIdx, i * uint.size); - let label = uint.get(labelData.data, idx * uint.size); - assert(label >= 0 && label <= 9); - trainLabels.set(label, i, 1); - } - - for (let i = 0; i < numTest; i++) { - let idx = uint.get(hTestIdx, i * uint.size); - let label = uint.get(labelData.data, idx * uint.size); - assert(label >= 0 && label <= 9); - testLabels.set(label, i, 1); - } - } - else { - let labels = yield AFArray.createAsync(labelData.dims[0], af.dType.u32, labelData.data); - trainLabels = labels.at(trainIndices); - testLabels = labels.at(testIndices); - } - - return { - numClasses: numClasses, - numTrain: numTrain, - numTest: numTest, - trainImages: trainImages, - testImages: testImages, - trainLabels: trainLabels, - testLabels: testLabels - }; - }) -}; - -module.exports = mnist; \ No newline at end of file diff --git a/examples/es6/machine-learning/neuralNetwork.js b/examples/es6/machine-learning/neuralNetwork.js deleted file mode 100644 index 59f3a7a..0000000 --- a/examples/es6/machine-learning/neuralNetwork.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; - -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let common = require("../common"); -let mnist = require("./mnist"); -let ANN = require("./ann"); -let now = require("performance-now"); - -let accuracy = function(af, predicted, target) { - let pMax = af.findMaxAt(predicted, 1); - let tMax = af.findMaxAt(target, 1); - return (100 * (af.count(pMax.index.eq(tMax.index)))) / tMax.index.elements(); -}; - -let annDemo = async(function*(af, deviceInfo) { - console.log("Running ANN Demo on device:\n"); - common.printDeviceInfo(deviceInfo); - console.log(""); - - console.log("Setting up training data."); - let data = yield mnist.setup(af, true, 0.6); - - let featureSize = data.trainImages.elements() / data.numTrain; - - // Reshape images into feature vectors - let trainFeats = af.transpose(af.modDims(data.trainImages, featureSize, data.numTrain)); - let testFeats = af.transpose(af.modDims(data.testImages, featureSize, data.numTest)); - - let trainTarget = af.transpose(data.trainLabels); - let testTarget = af.transpose(data.testLabels); - - let network = new ANN(af, [trainFeats.dims(1), 100, 50, data.numClasses]); - - // Train network - const start = now(); - network.train( - trainFeats, - trainTarget, - { - alpha: 1.0, - maxEpochs: 300, - batchSize: 100, - maxError: 0.0001 - } - ); - yield af.waitAsync(); - const end = now(); - - // Run the trained network and test accuracy. - let trainOutput = network.predict(trainFeats); - let testOutput = network.predict(testFeats); - - console.log("Training set:"); - console.log(`Accuracy on training data: ${(accuracy(af, trainOutput, trainTarget)).toFixed(2)}`); - - console.log("Test set:"); - console.log(`Accuracy on testing data: ${(accuracy(af, testOutput, testTarget)).toFixed(2)}`); - - console.log(`Training time: ${((end - start) / 1000).toFixed(10)} seconds\n`); -}); - -common.runOnBestDevice(annDemo, "ANN Demo"); \ No newline at end of file diff --git a/examples/ml_lab b/examples/ml_lab deleted file mode 160000 index 1cef0b2..0000000 --- a/examples/ml_lab +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1cef0b2287e4d6656f6f5750179d74f5cd880442 diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index e5f5e3d..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -let gulp = require("gulp"); -let babel = require("gulp-babel"); -let gulpSequence = require("gulp-sequence"); -let exec = require("child_process").exec; -let sourcemaps = require("gulp-sourcemaps"); - -gulp.task("compile-test", function () { - return gulp.src("tests/es6/**/*.js", {base: "tests/es6"}) - .pipe(sourcemaps.init()) - .pipe(babel({ - presets: ['es2015'] - })) - .pipe(sourcemaps.write(".")) - .pipe(gulp.dest("tests/es5")); -}); - -gulp.task("compile-lib", function () { - return gulp.src("lib/es6/**/*.js", {base: "lib/es6"}) - .pipe(sourcemaps.init()) - .pipe(babel({ - presets: ['es2015'] - })) - .pipe(sourcemaps.write(".")) - .pipe(gulp.dest("lib/es5")); -}); - -gulp.task("compile-examples", function () { - return gulp.src("examples/es6/**/*.js", {base: "examples/es6"}) - .pipe(sourcemaps.init()) - .pipe(babel({ - presets: ['es2015'] - })) - .pipe(sourcemaps.write(".")) - .pipe(gulp.dest("examples/es5")); -}); - -gulp.task("compile", gulpSequence(["compile-test", "compile-lib", "compile-examples"])); - -gulp.task("default", gulpSequence("compile")); - -gulp.task("npm-publish", function (done) { - exec("npm publish").on("close", function(e) { - if (e) { - done(new Error("Cannot publish to the npm. Exit code: " + e + ".")); - } - else { - done(); - } - }); -}); - -gulp.task("publish", gulpSequence("compile", "npm-publish")); \ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json deleted file mode 100644 index 56705ea..0000000 --- a/jsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "target": "ES6", - "module": "commonjs" - } -} \ No newline at end of file diff --git a/lib/es5/borderType.js b/lib/es5/borderType.js deleted file mode 100644 index e3a09e2..0000000 --- a/lib/es5/borderType.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var borderType = module.exports = { - padZero: 0, - padSym: 1, - AF_PAD_ZERO: 0, - AF_PAD_SYM: 1 -}; -//# sourceMappingURL=borderType.js.map diff --git a/lib/es5/borderType.js.map b/lib/es5/borderType.js.map deleted file mode 100644 index d91100e..0000000 --- a/lib/es5/borderType.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["borderType.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,UAAU,GAAG,MAAM,CAAC,OAAO,GAAG;AAC9B,SAAO,EAAE,CAAC;AACV,QAAM,EAAE,CAAC;AACT,aAAW,EAAE,CAAC;AACd,YAAU,EAAE,CAAC;CAChB,CAAC","file":"borderType.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet borderType = module.exports = {\r\n padZero: 0,\r\n padSym: 1,\r\n AF_PAD_ZERO: 0,\r\n AF_PAD_SYM: 1\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/cSpace.js b/lib/es5/cSpace.js deleted file mode 100644 index 62f3f4d..0000000 --- a/lib/es5/cSpace.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var cSpace = module.exports = { - Gray: 0, ///< Grayscale - RGB: 1, ///< 3-channel RGB - HSV: 2, ///< 3-channel HSV - AF_GRAY: 0, ///< Grayscale - AF_RGB: 1, ///< 3-channel RGB - AF_HSV: 2 ///< 3-channel HSV -}; -//# sourceMappingURL=cSpace.js.map diff --git a/lib/es5/cSpace.js.map b/lib/es5/cSpace.js.map deleted file mode 100644 index 74cf4d2..0000000 --- a/lib/es5/cSpace.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["cSpace.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,MAAM,GAAG,MAAM,CAAC,OAAO,GAAG;AAC1B,MAAI,EAAE,CAAC;AACP,KAAG,EAAE,CAAC;AACN,KAAG,EAAE,CAAC;AACN,SAAO,EAAE,CAAC;AACV,QAAM,EAAE,CAAC;AACT,QAAM,EAAE,CAAC;AAAA,CACZ,CAAC","file":"cSpace.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet cSpace = module.exports = {\r\n Gray: 0, ///< Grayscale\r\n RGB: 1, ///< 3-channel RGB\r\n HSV: 2, ///< 3-channel HSV\r\n AF_GRAY: 0, ///< Grayscale\r\n AF_RGB: 1, ///< 3-channel RGB\r\n AF_HSV: 2 ///< 3-channel HSV\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/col.js b/lib/es5/col.js deleted file mode 100644 index 04ebbea..0000000 --- a/lib/es5/col.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); - -function Col(index) { - assert(_.isNumber(index)); - - this.index = index; -} - -module.exports = Col; -//# sourceMappingURL=col.js.map diff --git a/lib/es5/col.js.map b/lib/es5/col.js.map deleted file mode 100644 index acaa97b..0000000 --- a/lib/es5/col.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["col.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;;AAEtC,SAAS,GAAG,CAAC,KAAK,EAAE;AAChB,QAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;;AAE1B,MAAI,CAAC,KAAK,GAAG,KAAK,CAAC;CACtB;;AAED,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC","file":"col.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\n\r\nfunction Col(index) {\r\n assert(_.isNumber(index));\r\n\r\n this.index = index;\r\n}\r\n\r\nmodule.exports = Col;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/cols.js b/lib/es5/cols.js deleted file mode 100644 index 33a2c35..0000000 --- a/lib/es5/cols.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); - -function Cols(firstIndex, lastIndex) { - assert(_.isNumber(firstIndex)); - assert(_.isNumber(lastIndex)); - - this.firstIndex = firstIndex; - this.lastIndex = lastIndex; -} - -module.exports = Cols; -//# sourceMappingURL=cols.js.map diff --git a/lib/es5/cols.js.map b/lib/es5/cols.js.map deleted file mode 100644 index d380aac..0000000 --- a/lib/es5/cols.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["cols.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;;AAEtC,SAAS,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE;AACjC,QAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AAC/B,QAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;;AAE9B,MAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AAC7B,MAAI,CAAC,SAAS,GAAG,SAAS,CAAC;CAC9B;;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC","file":"cols.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\n\r\nfunction Cols(firstIndex, lastIndex) {\r\n assert(_.isNumber(firstIndex));\r\n assert(_.isNumber(lastIndex));\r\n\r\n this.firstIndex = firstIndex;\r\n this.lastIndex = lastIndex;\r\n}\r\n\r\nmodule.exports = Cols;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/complex.js b/lib/es5/complex.js deleted file mode 100644 index d8beae8..0000000 --- a/lib/es5/complex.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); - -function Complex(real, imag) { - assert(_.isNumber(real)); - assert(_.isNumber(imag)); - - this.real = real; - this.imag = imag; -} - -module.exports = Complex; -//# sourceMappingURL=complex.js.map diff --git a/lib/es5/complex.js.map b/lib/es5/complex.js.map deleted file mode 100644 index 6849a23..0000000 --- a/lib/es5/complex.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["complex.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;;AAEtC,SAAS,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE;AACzB,QAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACzB,QAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEzB,MAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjB,MAAI,CAAC,IAAI,GAAG,IAAI,CAAC;CACpB;;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC","file":"complex.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\n\r\nfunction Complex(real, imag) {\r\n assert(_.isNumber(real));\r\n assert(_.isNumber(imag));\r\n\r\n this.real = real;\r\n this.imag = imag;\r\n}\r\n\r\nmodule.exports = Complex;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/connectivity.js b/lib/es5/connectivity.js deleted file mode 100644 index 3b9bcce..0000000 --- a/lib/es5/connectivity.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var connectivity = module.exports = { - connectivity4: 4, - connectivity8: 8, - AF_CONNECTIVITY_4: 4, - AF_CONNECTIVITY_8: 8 -}; -//# sourceMappingURL=connectivity.js.map diff --git a/lib/es5/connectivity.js.map b/lib/es5/connectivity.js.map deleted file mode 100644 index ca48d12..0000000 --- a/lib/es5/connectivity.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["connectivity.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,YAAY,GAAG,MAAM,CAAC,OAAO,GAAG;AAChC,eAAa,EAAE,CAAC;AAChB,eAAa,EAAE,CAAC;AAChB,mBAAiB,EAAE,CAAC;AACpB,mBAAiB,EAAE,CAAC;CACvB,CAAC","file":"connectivity.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet connectivity = module.exports = {\r\n connectivity4: 4,\r\n connectivity8: 8,\r\n AF_CONNECTIVITY_4: 4,\r\n AF_CONNECTIVITY_8: 8\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/convDomain.js b/lib/es5/convDomain.js deleted file mode 100644 index 4b7fb44..0000000 --- a/lib/es5/convDomain.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var convDomain = module.exports = { - auto: 0, ///< ArrayFire automatically picks the right convolution algorithm - spatial: 1, ///< Perform convolution in spatial domain - freq: 2, ///< Perform convolution in frequency domain - AF_CONV_AUTO: 0, ///< ArrayFire automatically picks the right convolution algorithm - AF_CONV_SPATIAL: 1, ///< Perform convolution in spatial domain - AF_CONV_FREQ: 2 ///< Perform convolution in frequency domain -}; -//# sourceMappingURL=convDomain.js.map diff --git a/lib/es5/convDomain.js.map b/lib/es5/convDomain.js.map deleted file mode 100644 index 773626a..0000000 --- a/lib/es5/convDomain.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["convDomain.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,UAAU,GAAG,MAAM,CAAC,OAAO,GAAG;AAC9B,MAAI,EAAE,CAAC;AACP,SAAO,EAAE,CAAC;AACV,MAAI,EAAE,CAAC;AACP,cAAY,EAAE,CAAC;AACf,iBAAe,EAAE,CAAC;AAClB,cAAY,EAAE,CAAC;AAAA,CAClB,CAAC","file":"convDomain.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet convDomain = module.exports = {\r\n auto: 0, ///< ArrayFire automatically picks the right convolution algorithm\r\n spatial: 1, ///< Perform convolution in spatial domain\r\n freq: 2, ///< Perform convolution in frequency domain\r\n AF_CONV_AUTO: 0, ///< ArrayFire automatically picks the right convolution algorithm\r\n AF_CONV_SPATIAL: 1, ///< Perform convolution in spatial domain\r\n AF_CONV_FREQ: 2 ///< Perform convolution in frequency domain\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/convMode.js b/lib/es5/convMode.js deleted file mode 100644 index a450cdb..0000000 --- a/lib/es5/convMode.js +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var convMode = module.exports = { - /// - /// Output of the convolution is the same size as input - /// - default: 0, - - /// - /// Output of the convolution is signal_len + filter_len - 1 - /// - expand: 1, - /// - /// Output of the convolution is the same size as input - /// - AF_CONV_DEFAULT: 0, - - /// - /// Output of the convolution is signal_len + filter_len - 1 - /// - AF_CONV_EXPAND: 1 -}; -//# sourceMappingURL=convMode.js.map diff --git a/lib/es5/convMode.js.map b/lib/es5/convMode.js.map deleted file mode 100644 index 661e405..0000000 --- a/lib/es5/convMode.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["convMode.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,QAAQ,GAAG,MAAM,CAAC,OAAO,GAAG;;;;AAI5B,WAAO,EAAE,CAAC;;;;;AAKV,UAAM,EAAE,CAAC;;;;AAIT,mBAAe,EAAE,CAAC;;;;;AAKlB,kBAAc,EAAE,CAAC;CACpB,CAAC","file":"convMode.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet convMode = module.exports = {\r\n ///\r\n /// Output of the convolution is the same size as input\r\n ///\r\n default: 0,\r\n\r\n ///\r\n /// Output of the convolution is signal_len + filter_len - 1\r\n ///\r\n expand: 1,\r\n ///\r\n /// Output of the convolution is the same size as input\r\n ///\r\n AF_CONV_DEFAULT: 0,\r\n\r\n ///\r\n /// Output of the convolution is signal_len + filter_len - 1\r\n ///\r\n AF_CONV_EXPAND: 1\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/dim4.js b/lib/es5/dim4.js deleted file mode 100644 index 0734729..0000000 --- a/lib/es5/dim4.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); - -function Dim4(dim0, dim1, dim2, dim3) { - if (_.isArray(dim0)) { - return new Dim4(dim0[0], dim0[1], dim0[2], dim0[3]); - } - this.values = []; - if (_.isNumber(dim0)) { - this.values.push(dim0); - } else { - this.values.push(1); - } - if (_.isNumber(dim1)) { - this.values.push(dim1); - } else { - this.values.push(1); - } - if (_.isNumber(dim2)) { - this.values.push(dim2); - } else { - this.values.push(1); - } - if (_.isNumber(dim3)) { - this.values.push(dim3); - } else { - this.values.push(1); - } - var index = undefined; - for (index = 3; index >= 0; index--) { - if (this.values[index] !== 1) { - break; - } - } - this.ndims = this.nDims = index + 1; - this.elements = this.values[0] * this.values[1] * this.values[2] * this.values[3]; -} - -module.exports = Dim4; -//# sourceMappingURL=dim4.js.map diff --git a/lib/es5/dim4.js.map b/lib/es5/dim4.js.map deleted file mode 100644 index 8e5d96a..0000000 --- a/lib/es5/dim4.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["dim4.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;;AAEtC,SAAS,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;AAClC,QAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACjB,eAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAA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IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CACrF;;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC","file":"dim4.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\n\r\nfunction Dim4(dim0, dim1, dim2, dim3) {\r\n if (_.isArray(dim0)) {\r\n return new Dim4(dim0[0], dim0[1], dim0[2], dim0[3]);\r\n }\r\n this.values = [];\r\n if (_.isNumber(dim0)) { this.values.push(dim0) } else { this.values.push(1); }\r\n if (_.isNumber(dim1)) { this.values.push(dim1) } else { this.values.push(1); }\r\n if (_.isNumber(dim2)) { this.values.push(dim2) } else { this.values.push(1); }\r\n if (_.isNumber(dim3)) { this.values.push(dim3) } else { this.values.push(1); }\r\n let index;\r\n for (index = 3; index >= 0; index--) {\r\n if (this.values[index] !== 1) {\r\n break;\r\n }\r\n }\r\n this.ndims = this.nDims = index + 1;\r\n this.elements = this.values[0] * this.values[1] * this.values[2] * this.values[3];\r\n}\r\n\r\nmodule.exports = Dim4;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/doc/afArray.js b/lib/es5/doc/afArray.js deleted file mode 100644 index cbc8d8b..0000000 --- a/lib/es5/doc/afArray.js +++ /dev/null @@ -1,308 +0,0 @@ -"use strict"; - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var AFArray = (function () { - function AFArray() { - _classCallCheck(this, AFArray); - } - - _createClass(AFArray, [{ - key: "free", - value: function free() {} - }, { - key: "elements", - value: function elements() {} - }, { - key: "host", - value: function host() {} - }, { - key: "copyToHost", - value: function copyToHost() {} - }, { - key: "scalar", - value: function scalar() {} - }, { - key: "value", - value: function value() {} - }, { - key: "write", - value: function write() {} - }, { - key: "type", - value: function type() {} - }, { - key: "dims", - value: function dims() {} - }, { - key: "numdims", - value: function numdims() {} - }, { - key: "numDims", - value: function numDims() {} - }, { - key: "bytes", - value: function bytes() {} - }, { - key: "copy", - value: function copy() {} - }, { - key: "isempty", - value: function isempty() {} - }, { - key: "isEmpty", - value: function isEmpty() {} - }, { - key: "isscalar", - value: function isscalar() {} - }, { - key: "isScalar", - value: function isScalar() {} - }, { - key: "isvector", - value: function isvector() {} - }, { - key: "isVector", - value: function isVector() {} - }, { - key: "isrow", - value: function isrow() {} - }, { - key: "isRow", - value: function isRow() {} - }, { - key: "iscolumn", - value: function iscolumn() {} - }, { - key: "isColumn", - value: function isColumn() {} - }, { - key: "iscomplex", - value: function iscomplex() {} - }, { - key: "isComplex", - value: function isComplex() {} - }, { - key: "isreal", - value: function isreal() {} - }, { - key: "isReal", - value: function isReal() {} - }, { - key: "isdouble", - value: function isdouble() {} - }, { - key: "isDouble", - value: function isDouble() {} - }, { - key: "issingle", - value: function issingle() {} - }, { - key: "isSingle", - value: function isSingle() {} - }, { - key: "isrealfloating", - value: function isrealfloating() {} - }, { - key: "isRealFloating", - value: function isRealFloating() {} - }, { - key: "isfloating", - value: function isfloating() {} - }, { - key: "isFloating", - value: function isFloating() {} - }, { - key: "isinteger", - value: function isinteger() {} - }, { - key: "isInteger", - value: function isInteger() {} - }, { - key: "isbool", - value: function isbool() {} - }, { - key: "isBool", - value: function isBool() {} - }, { - key: "afEval", - value: function afEval() {} - }, { - key: "at", - value: function at() {} - }, { - key: "row", - value: function row() {} - }, { - key: "col", - value: function col() {} - }, { - key: "slice", - value: function slice() {} - }, { - key: "rows", - value: function rows() {} - }, { - key: "cols", - value: function cols() {} - }, { - key: "slices", - value: function slices() {} - }, { - key: "as", - value: function as() {} - }, { - key: "assign", - value: function assign() {} - }, { - key: "set", - value: function set() {} - }, { - key: "add", - value: function add() {} - }, { - key: "addAssign", - value: function addAssign() {} - }, { - key: "sub", - value: function sub() {} - }, { - key: "subAssign", - value: function subAssign() {} - }, { - key: "mul", - value: function mul() {} - }, { - key: "mulAssign", - value: function mulAssign() {} - }, { - key: "div", - value: function div() {} - }, { - key: "divAssign", - value: function divAssign() {} - }, { - key: "bitshiftl", - value: function bitshiftl() {} - }, { - key: "bitShiftL", - value: function bitShiftL() {} - }, { - key: "bitshiftr", - value: function bitshiftr() {} - }, { - key: "bitShiftR", - value: function bitShiftR() {} - }, { - key: "lt", - value: function lt() {} - }, { - key: "gt", - value: function gt() {} - }, { - key: "le", - value: function le() {} - }, { - key: "ge", - value: function ge() {} - }, { - key: "eq", - value: function eq() {} - }, { - key: "neq", - value: function neq() {} - }, { - key: "and", - value: function and() {} - }, { - key: "or", - value: function or() {} - }, { - key: "bitAnd", - value: function bitAnd() {} - }, { - key: "bitOr", - value: function bitOr() {} - }, { - key: "bitXor", - value: function bitXor() {} - }, { - key: "rhsAdd", - value: function rhsAdd() {} - }, { - key: "rhsSub", - value: function rhsSub() {} - }, { - key: "rhsMul", - value: function rhsMul() {} - }, { - key: "rhsDiv", - value: function rhsDiv() {} - }, { - key: "rhsBitshiftl", - value: function rhsBitshiftl() {} - }, { - key: "rhsBitShiftL", - value: function rhsBitShiftL() {} - }, { - key: "rhsBitshiftr", - value: function rhsBitshiftr() {} - }, { - key: "rhsBitShiftR", - value: function rhsBitShiftR() {} - }, { - key: "rhsLt", - value: function rhsLt() {} - }, { - key: "rhsGt", - value: function rhsGt() {} - }, { - key: "rhsLe", - value: function rhsLe() {} - }, { - key: "rhsGe", - value: function rhsGe() {} - }, { - key: "rhsEq", - value: function rhsEq() {} - }, { - key: "rhsNeq", - value: function rhsNeq() {} - }, { - key: "rhsAnd", - value: function rhsAnd() {} - }, { - key: "rhsOr", - value: function rhsOr() {} - }, { - key: "rhsBitAnd", - value: function rhsBitAnd() {} - }, { - key: "rhsBitOr", - value: function rhsBitOr() {} - }, { - key: "rhsBitXor", - value: function rhsBitXor() {} - }, { - key: "neg", - value: function neg() {} - }, { - key: "not", - value: function not() {} - }, { - key: "T", - value: function T() {} - }, { - key: "H", - value: function H() {} - }]); - - return AFArray; -})(); - -AFArray.create = function () {}; - -module.exports = AFArray; -//# sourceMappingURL=afArray.js.map diff --git a/lib/es5/doc/afArray.js.map b/lib/es5/doc/afArray.js.map deleted file mode 100644 index 0f4e907..0000000 --- a/lib/es5/doc/afArray.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["doc/afArray.js"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;IAEP,OAAO;AACT,aADE,OAAO,GACK;8BADZ,OAAO;KAER;;iBAFC,OAAO;;+BAIF,EACN;;;mCAEU,EACV;;;+BAEM,EACN;;;qCAEY,EACZ;;;iCAEQ,EACR;;;gCAEO,EACP;;;gCAEO,EACP;;;+BAEM,EACN;;;+BAEM,EACN;;;kCAES,EACT;;;kCAES,EACT;;;gCAEO,EACP;;;+BAEM,EACN;;;kCAES,EACT;;;kCAES,EACT;;;mCAEU,EACV;;;mCAEU,EACV;;;mCAEU,EACV;;;mCAEU,EACV;;;gCAEO,EACP;;;gCAEO,EACP;;;mCAEU,EACV;;;mCAEU,EACV;;;oCAEW,EACX;;;oCAEW,EACX;;;iCAEQ,EACR;;;iCAEQ,EACR;;;mCAEU,EACV;;;mCAEU,EACV;;;mCAEU,EACV;;;mCAEU,EACV;;;yCAEgB,EAChB;;;yCAEgB,EAChB;;;qCAEY,EACZ;;;qCAEY,EACZ;;;oCAEW,EACX;;;oCAEW,EACX;;;iCAEQ,EACR;;;iCAEQ,EACR;;;iCAEQ,EACR;;;6BAEI,EACJ;;;8BAEK,EACL;;;8BAEK,EACL;;;gCAEO,EACP;;;+BAEM,EACN;;;+BAEM,EACN;;;iCAEQ,EACR;;;6BAEI,EACJ;;;iCAEQ,EACR;;;8BAEK,EACL;;;8BAEK,EACL;;;oCAEW,EACX;;;8BAEK,EACL;;;oCAEW,EACX;;;8BAEK,EACL;;;oCAEW,EACX;;;8BAEK,EACL;;;oCAEW,EACX;;;oCAEW,EACX;;;oCAEW,EACX;;;oCAEW,EACX;;;oCAEW,EACX;;;6BAEI,EACJ;;;6BAEI,EACJ;;;6BAEI,EACJ;;;6BAEI,EACJ;;;6BAEI,EACJ;;;8BAEK,EACL;;;8BAEK,EACL;;;6BAEI,EACJ;;;iCAEQ,EACR;;;gCAEO,EACP;;;iCAEQ,EACR;;;iCAEQ,EACR;;;iCAEQ,EACR;;;iCAEQ,EACR;;;iCAEQ,EACR;;;uCAEc,EACd;;;uCAEc,EACd;;;uCAEc,EACd;;;uCAEc,EACd;;;gCAEO,EACP;;;gCAEO,EACP;;;gCAEO,EACP;;;gCAEO,EACP;;;gCAEO,EACP;;;iCAEQ,EACR;;;iCAEQ,EACR;;;gCAEO,EACP;;;oCAEW,EACX;;;mCAEU,EACV;;;oCAEW,EACX;;;8BAEK,EACL;;;8BAEK,EACL;;;4BAEG,EACH;;;4BAEG,EACH;;;WAlSC,OAAO;;;AAqSb,OAAO,CAAC,MAAM,GAAG,YAAW,EAC3B,CAAC;;AAEF,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC","file":"doc/afArray.js","sourcesContent":["\"use strict\";\r\n\r\nclass AFArray {\r\n constructor() {\r\n }\r\n\r\n free() {\r\n }\r\n\r\n elements() {\r\n }\r\n\r\n host() {\r\n }\r\n\r\n copyToHost() {\r\n }\r\n\r\n scalar() {\r\n }\r\n\r\n value() {\r\n }\r\n\r\n write() {\r\n }\r\n\r\n type() {\r\n }\r\n\r\n dims() {\r\n }\r\n\r\n numdims() {\r\n }\r\n\r\n numDims() {\r\n }\r\n\r\n bytes() {\r\n }\r\n\r\n copy() {\r\n }\r\n\r\n isempty() {\r\n }\r\n\r\n isEmpty() {\r\n }\r\n\r\n isscalar() {\r\n }\r\n\r\n isScalar() {\r\n }\r\n\r\n isvector() {\r\n }\r\n\r\n isVector() {\r\n }\r\n\r\n isrow() {\r\n }\r\n\r\n isRow() {\r\n }\r\n\r\n iscolumn() {\r\n }\r\n\r\n isColumn() {\r\n }\r\n\r\n iscomplex() {\r\n }\r\n\r\n isComplex() {\r\n }\r\n\r\n isreal() {\r\n }\r\n\r\n isReal() {\r\n }\r\n\r\n isdouble() {\r\n }\r\n\r\n isDouble() {\r\n }\r\n\r\n issingle() {\r\n }\r\n\r\n isSingle() {\r\n }\r\n\r\n isrealfloating() {\r\n }\r\n\r\n isRealFloating() {\r\n }\r\n\r\n isfloating() {\r\n }\r\n\r\n isFloating() {\r\n }\r\n\r\n isinteger() {\r\n }\r\n\r\n isInteger() {\r\n }\r\n\r\n isbool() {\r\n }\r\n\r\n isBool() {\r\n }\r\n\r\n afEval() {\r\n }\r\n\r\n at() {\r\n }\r\n\r\n row() {\r\n }\r\n\r\n col() {\r\n }\r\n\r\n slice() {\r\n }\r\n\r\n rows() {\r\n }\r\n\r\n cols() {\r\n }\r\n\r\n slices() {\r\n }\r\n\r\n as() {\r\n }\r\n\r\n assign() {\r\n }\r\n\r\n set() {\r\n }\r\n\r\n add() {\r\n }\r\n\r\n addAssign() {\r\n }\r\n\r\n sub() {\r\n }\r\n\r\n subAssign() {\r\n }\r\n\r\n mul() {\r\n }\r\n\r\n mulAssign() {\r\n }\r\n\r\n div() {\r\n }\r\n\r\n divAssign() {\r\n }\r\n\r\n bitshiftl() {\r\n }\r\n\r\n bitShiftL() {\r\n }\r\n\r\n bitshiftr() {\r\n }\r\n\r\n bitShiftR() {\r\n }\r\n\r\n lt() {\r\n }\r\n\r\n gt() {\r\n }\r\n\r\n le() {\r\n }\r\n\r\n ge() {\r\n }\r\n\r\n eq() {\r\n }\r\n\r\n neq() {\r\n }\r\n\r\n and() {\r\n }\r\n\r\n or() {\r\n }\r\n\r\n bitAnd() {\r\n }\r\n\r\n bitOr() {\r\n }\r\n\r\n bitXor() {\r\n }\r\n\r\n rhsAdd() {\r\n }\r\n\r\n rhsSub() {\r\n }\r\n\r\n rhsMul() {\r\n }\r\n\r\n rhsDiv() {\r\n }\r\n\r\n rhsBitshiftl() {\r\n }\r\n\r\n rhsBitShiftL() {\r\n }\r\n\r\n rhsBitshiftr() {\r\n }\r\n\r\n rhsBitShiftR() {\r\n }\r\n\r\n rhsLt() {\r\n }\r\n\r\n rhsGt() {\r\n }\r\n\r\n rhsLe() {\r\n }\r\n\r\n rhsGe() {\r\n }\r\n\r\n rhsEq() {\r\n }\r\n\r\n rhsNeq() {\r\n }\r\n\r\n rhsAnd() {\r\n }\r\n\r\n rhsOr() {\r\n }\r\n\r\n rhsBitAnd() {\r\n }\r\n\r\n rhsBitOr() {\r\n }\r\n\r\n rhsBitXor() {\r\n }\r\n\r\n neg() {\r\n }\r\n\r\n not() {\r\n }\r\n\r\n T() {\r\n }\r\n\r\n H() {\r\n }\r\n}\r\n\r\nAFArray.create = function() {\r\n};\r\n\r\nmodule.exports = AFArray;\r\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/dtype.js b/lib/es5/dtype.js deleted file mode 100644 index 43e0ec7..0000000 --- a/lib/es5/dtype.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var dType = module.exports = { - f32: 0, - c32: 1, - f64: 2, - c64: 3, - b8: 4, - s32: 5, - u32: 6, - u8: 7, - s64: 8, - u64: 9 -}; -//# sourceMappingURL=dtype.js.map diff --git a/lib/es5/dtype.js.map b/lib/es5/dtype.js.map deleted file mode 100644 index 58e17a2..0000000 --- a/lib/es5/dtype.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["dtype.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,GAAG;AACzB,KAAG,EAAE,CAAC;AACN,KAAG,EAAE,CAAC;AACN,KAAG,EAAE,CAAC;AACN,KAAG,EAAE,CAAC;AACN,IAAE,EAAE,CAAC;AACL,KAAG,EAAE,CAAC;AACN,KAAG,EAAE,CAAC;AACN,IAAE,EAAE,CAAC;AACL,KAAG,EAAE,CAAC;AACN,KAAG,EAAE,CAAC;CACT,CAAC","file":"dtype.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet dType = module.exports = {\r\n f32: 0,\r\n c32: 1,\r\n f64: 2,\r\n c64: 3,\r\n b8: 4,\r\n s32: 5,\r\n u32: 6,\r\n u8: 7,\r\n s64: 8,\r\n u64: 9\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/ext.js b/lib/es5/ext.js deleted file mode 100644 index c8d5964..0000000 --- a/lib/es5/ext.js +++ /dev/null @@ -1,156 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var Bluebird = require("bluebird"); -var _ = require("lodash"); -var async = Bluebird.coroutine; - -var retryCount = 5; -var gcTime = 1000; - -function synchronify(af, f) { - return function () { - var err; - var res; - var done; - var cb = function cb(e, r) { - err = e; - res = r; - done = true; - }; - - var args = _.toArray(arguments).concat(cb); - f.apply(this, args); - while (!done) { - af._doEvents(); - }return res; - }; -} - -function installAsyncAndSync(af, obj, name) { - if (_.isUndefined(name)) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = _.keys(obj)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var key = _step.value; - - installAsyncAndSync(af, obj, key); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - return; - } - - if (name !== "AFArray") { - var f = obj[name]; - if (_.isFunction(f)) { - if (!_.isFunction(obj[name + "Async"])) { - obj[name + "Async"] = Bluebird.promisify(f); - } - if (!_.isFunction(obj[name + "Sync"])) { - obj[name + "Sync"] = synchronify(af, f); - } - } - } -} - -function ext(af) { - installAsyncAndSync(af, af); - installAsyncAndSync(af, af.AFArray); - installAsyncAndSync(af, af.AFArray.prototype); - - var scope = af.AFArray.scope = require("./scope"); - - _.extend(af, { - end: -1, - span: null, - all: -1, - dtype: require("./dtype"), - dType: require("./dtype"), - source: require("./source"), - matchType: require("./matchType"), - cSpace: require("./cSpace"), - CSpace: require("./cSpace"), - connectivity: require("./connectivity"), - borderType: require("./borderType"), - interpType: require("./interpType"), - matProp: require("./matProp"), - normType: require("./normType"), - convMode: require("./convMode"), - convDomain: require("./convDomain"), - Dim4: require("./dim4"), - Seq: require("./seq"), - Complex: require("./complex"), - Row: require("./row"), - Col: require("./col"), - Rows: require("./rows"), - Cols: require("./cols"), - getDevices: function getDevices() { - var current = this.getDevice(); - try { - var count = this.getDeviceCount(); - var result = []; - for (var i = 0; i < count; i++) { - this.setDevice(i); - var info = this.deviceInfo(); - info.id = i; - result.push(info); - } - return result; - } finally { - this.setDevice(current); - } - }, - gfor: require("./makeGfor")(af), - scope: scope - }); -} - -module.exports = ext; -//# sourceMappingURL=ext.js.map diff --git a/lib/es5/ext.js.map b/lib/es5/ext.js.map deleted file mode 100644 index 1e80d20..0000000 --- a/lib/es5/ext.js.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AE,CAAC;AAC/B,aAAK,EAAE,KAAK;KACf,CAAC,CAAC;CACN;;AAED,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC","file":"ext.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet Bluebird = require(\"bluebird\");\r\nlet _ = require(\"lodash\");\r\nlet async = Bluebird.coroutine;\r\n\r\nconst retryCount = 5;\r\nconst gcTime = 1000;\r\n\r\nfunction synchronify(af, f) {\r\n return function () {\r\n var err;\r\n var res;\r\n var done;\r\n let cb = function (e, r) {\r\n err = e;\r\n res = r;\r\n done = true;\r\n };\r\n\r\n let args = _.toArray(arguments).concat(cb);\r\n f.apply(this, args);\r\n while (!done) af._doEvents();\r\n\r\n return res;\r\n };\r\n}\r\n\r\nfunction installAsyncAndSync(af, obj, name) {\r\n if (_.isUndefined(name)) {\r\n for (let key of _.keys(obj)) {\r\n installAsyncAndSync(af, obj, key);\r\n }\r\n return;\r\n }\r\n\r\n if (name !== \"AFArray\") {\r\n let f = obj[name];\r\n if (_.isFunction(f)) {\r\n if (!_.isFunction(obj[name + \"Async\"])) {\r\n obj[name + \"Async\"] = Bluebird.promisify(f);\r\n }\r\n if (!_.isFunction(obj[name + \"Sync\"])) {\r\n obj[name + \"Sync\"] = synchronify(af, f);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction ext(af) {\r\n installAsyncAndSync(af, af);\r\n installAsyncAndSync(af, af.AFArray);\r\n installAsyncAndSync(af, af.AFArray.prototype);\r\n\r\n let scope = af.AFArray.scope = require(\"./scope\");\r\n\r\n _.extend(af, {\r\n end: -1,\r\n span: null,\r\n all: -1,\r\n dtype: require(\"./dtype\"),\r\n dType: require(\"./dtype\"),\r\n source: require(\"./source\"),\r\n matchType: require(\"./matchType\"),\r\n cSpace: require(\"./cSpace\"),\r\n CSpace: require(\"./cSpace\"),\r\n connectivity: require(\"./connectivity\"),\r\n borderType: require(\"./borderType\"),\r\n interpType: require(\"./interpType\"),\r\n matProp: require(\"./matProp\"),\r\n normType: require(\"./normType\"),\r\n convMode: require(\"./convMode\"),\r\n convDomain: require(\"./convDomain\"),\r\n Dim4: require(\"./dim4\"),\r\n Seq: require(\"./seq\"),\r\n Complex: require(\"./complex\"),\r\n Row: require(\"./row\"),\r\n Col: require(\"./col\"),\r\n Rows: require(\"./rows\"),\r\n Cols: require(\"./cols\"),\r\n getDevices: function () {\r\n let current = this.getDevice();\r\n try {\r\n let count = this.getDeviceCount();\r\n let result = [];\r\n for (let i = 0; i < count; i++) {\r\n this.setDevice(i);\r\n let info = this.deviceInfo();\r\n info.id = i;\r\n result.push(info);\r\n }\r\n return result;\r\n }\r\n finally {\r\n this.setDevice(current);\r\n }\r\n },\r\n gfor: require(\"./makeGfor\")(af),\r\n scope: scope\r\n });\r\n}\r\n\r\nmodule.exports = ext;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/index.js b/lib/es5/index.js deleted file mode 100644 index cb7989d..0000000 --- a/lib/es5/index.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var _ = require("lodash"); -var ext = require("./ext"); -var Bluebird = require("bluebird"); -var debug = require("debug")("af"); - -var cpuDriver = null; -var cudaDriver = null; -var openCLDriver = null; - -var entry = module.exports = function (id) { - var did = _.isString(id) ? id.trim().toLowerCase() : null; - did = did || "cpu"; - function createAF() { - switch (did) { - case "cpu": - return cpuDriver || (cpuDriver = require("bindings")("arrayfire_js_CPU")); - case "cuda": - return cudaDriver || (cudaDriver = require("bindings")("arrayfire_js_CUDA")); - case "opencl": - return openCLDriver || (openCLDriver = require("bindings")("arrayfire_js_OpenCL")); - default: - throw new Error("Platform '" + id + "' is not supported."); - } - } - var af = createAF(); - if (!af.__extended) { - ext(af); - af.__extended = true; - } - return af; -}; - -entry.supportedPlatforms = function () { - var platforms = []; - var _arr = ["CPU", "CUDA", "OpenCL"]; - for (var _i = 0; _i < _arr.length; _i++) { - var id = _arr[_i]; - try { - var fire = entry(id); - platforms.push(id); - } catch (e) { - debug("Cannot create ArrayFire binding of platform %s, because of error:\n%s", id, e.stack); - } - } - return platforms; -}; -//# sourceMappingURL=index.js.map diff --git a/lib/es5/index.js.map b/lib/es5/index.js.map deleted file mode 100644 index 9b58d76..0000000 --- a/lib/es5/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC3B,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;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,EAAE,MAAM,EAAE,QAAQ,CAAC;AAAxC,6CAA0C;AAArC,YAAI,EAAE,WAAA,CAAA;AACP,YAAI;AACA,gBAAI,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;AACrB,qBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACtB,CACD,OAAM,CAAC,EAAE;AACL,iBAAK,CAAC,uEAAuE,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC/F;KACJ;AACD,WAAO,SAAS,CAAC;CACpB,CAAC","file":"index.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet ext = require(\"./ext\");\r\nlet Bluebird = require(\"bluebird\");\r\nlet debug = require(\"debug\")(\"af\");\r\n\r\nlet cpuDriver = null;\r\nlet cudaDriver = null;\r\nlet openCLDriver = null;\r\n\r\nlet entry = module.exports = function(id) {\r\n let did = _.isString(id) ? id.trim().toLowerCase() : null;\r\n did = did || \"cpu\";\r\n function createAF() {\r\n switch (did) {\r\n case \"cpu\":\r\n return cpuDriver || (cpuDriver = require(\"bindings\")(\"arrayfire_js_CPU\"));\r\n case \"cuda\":\r\n return cudaDriver || (cudaDriver = require(\"bindings\")(\"arrayfire_js_CUDA\"));\r\n case \"opencl\":\r\n return openCLDriver || (openCLDriver = require(\"bindings\")(\"arrayfire_js_OpenCL\"));\r\n default:\r\n throw new Error(\"Platform '\" + id + \"' is not supported.\");\r\n }\r\n }\r\n let af = createAF();\r\n if (!af.__extended) {\r\n ext(af);\r\n af.__extended = true;\r\n }\r\n return af;\r\n};\r\n\r\nentry.supportedPlatforms = function() {\r\n let platforms = [];\r\n for (let id of [\"CPU\", \"CUDA\", \"OpenCL\"]) {\r\n try {\r\n let fire = entry(id);\r\n platforms.push(id);\r\n }\r\n catch(e) {\r\n debug(\"Cannot create ArrayFire binding of platform %s, because of error:\\n%s\", id, e.stack);\r\n }\r\n }\r\n return platforms;\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/interpType.js b/lib/es5/interpType.js deleted file mode 100644 index ce69197..0000000 --- a/lib/es5/interpType.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var interpType = module.exports = { - nearest: 0, ///< Nearest Interpolation - linear: 1, ///< Linear Interpolation - bilinerar: 2, ///< Bilinear Interpolation - cubic: 3, ///< Cubic Interpolation, - AF_INTERP_NEAREST: 0, ///< Nearest Interpolation - AF_INTERP_LINEAR: 1, ///< Linear Interpolation - AF_INTERP_BILINEAR: 2, ///< Bilinear Interpolation - AF_INTERP_CUBIC: 3 ///< Cubic Interpolation -}; -//# sourceMappingURL=interpType.js.map diff --git a/lib/es5/interpType.js.map b/lib/es5/interpType.js.map deleted file mode 100644 index d082e8b..0000000 --- a/lib/es5/interpType.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["interpType.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,UAAU,GAAG,MAAM,CAAC,OAAO,GAAG;AAC9B,SAAO,EAAE,CAAC;AACV,QAAM,EAAE,CAAC;AACT,WAAS,EAAG,CAAC;AACb,OAAK,EAAE,CAAC;AACR,mBAAiB,EAAE,CAAC;AACpB,kBAAgB,EAAE,CAAC;AACnB,oBAAkB,EAAG,CAAC;AACtB,iBAAe,EAAE,CAAC;AAAA,CACrB,CAAC","file":"interpType.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet interpType = module.exports = {\r\n nearest: 0, ///< Nearest Interpolation\r\n linear: 1, ///< Linear Interpolation\r\n bilinerar : 2, ///< Bilinear Interpolation\r\n cubic: 3, ///< Cubic Interpolation,\r\n AF_INTERP_NEAREST: 0, ///< Nearest Interpolation\r\n AF_INTERP_LINEAR: 1, ///< Linear Interpolation\r\n AF_INTERP_BILINEAR : 2, ///< Bilinear Interpolation\r\n AF_INTERP_CUBIC: 3 ///< Cubic Interpolation\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/iterpType.js b/lib/es5/iterpType.js deleted file mode 100644 index 020a9f6..0000000 --- a/lib/es5/iterpType.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -"use strict"; -var interpType = module.exports = { - nearest: 0, - linear: 1, - bilinerar: 2, - cubic: 3, - AF_INTERP_NEAREST: 0, - AF_INTERP_LINEAR: 1, - AF_INTERP_BILINEAR: 2, - AF_INTERP_CUBIC: 3 -}; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIml0ZXJwVHlwZS5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUErQkE7QUFBQSxXQUFXLENBQUM7QUFFWixBQUFJLEVBQUEsQ0FBQSxVQUFTLEVBQUksQ0FBQSxNQUFLLFFBQVEsRUFBSTtBQUM5QixRQUFNLENBQUcsRUFBQTtBQUNULE9BQUssQ0FBRyxFQUF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EIEFORCBPTlxuQU5ZIFRIRU9SWSBPRiBMSUFCSUxJVFksIFdIRVRIRVIgSU4gQ09OVFJBQ1QsIFNUUklDVCBMSUFCSUxJVFksIE9SIFRPUlRcbihJTkNMVURJTkcgTkVHTElHRU5DRSBPUiBPVEhFUldJU0UpIEFSSVNJTkcgSU4gQU5ZIFdBWSBPVVQgT0YgVEhFIFVTRSBPRiBUSElTXG5TT0ZUV0FSRSwgRVZFTiBJRiBBRFZJU0VEIE9GIFRIRSBQT1NTSUJJTElUWSBPRiBTVUNIIERBTUFHRS5cbiovXG5cblwidXNlIHN0cmljdFwiO1xuXG5sZXQgaW50ZXJwVHlwZSA9IG1vZHVsZS5leHBvcnRzID0ge1xuICAgIG5lYXJlc3Q6IDAsICAvLy88IE5lYXJlc3QgSW50ZXJwb2xhdGlvblxuICAgIGxpbmVhcjogMSwgICAvLy88IExpbmVhciBJbnRlcnBvbGF0aW9uXG4gICAgYmlsaW5lcmFyIDogMiwgLy8vPCBCaWxpbmVhciBJbnRlcnBvbGF0aW9uXG4gICAgY3ViaWM6IDMsICAgIC8vLzwgQ3ViaWMgSW50ZXJwb2xhdGlvbixcbiAgICBBRl9JTlRFUlBfTkVBUkVTVDogMCwgIC8vLzwgTmVhcmVzdCBJbnRlcnBvbGF0aW9uXG4gICAgQUZfSU5URVJQX0xJTkVBUjogMSwgICAvLy88IExpbmVhciBJbnRlcnBvbGF0aW9uXG4gICAgQUZfSU5URVJQX0JJTElORUFSIDogMiwgLy8vPCBCaWxpbmVhciBJbnRlcnBvbGF0aW9uXG4gICAgQUZfSU5URVJQX0NVQklDOiAzICAgICAvLy88IEN1YmljIEludGVycG9sYXRpb25cbn07Il19 diff --git a/lib/es5/makeGfor.js b/lib/es5/makeGfor.js deleted file mode 100644 index efd4c04..0000000 --- a/lib/es5/makeGfor.js +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright (c) 2014-2015, ArrayFire - Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); -var Seq = require("./seq"); - -function makeGfor(af) { - return function gfor() { - var fPos = -1; - for (var i = 0; i < arguments.length; i++) { - if (_.isFunction(arguments[i])) { - fPos = i; - break; - } - } - if (fPos === -1) { - throw new Error("Body function argument expected."); - } - if (fPos === 0) { - throw new Error("Seq arguments expected."); - } - var thisArg = arguments[fPos]; - if (arguments.length > fPos + 1 && _.isObject(fPos + 1)) { - thisArg = arguments[fPos + 1]; - } - var seq = undefined; - if (fPos === 1) { - seq = new Seq(arguments[0]); - } else if (fPos === 2) { - seq = new Seq(arguments[0], arguments[1]); - } else { - throw new Error("Invalid number of Seq arguments."); - } - seq.isGFor = true; - af._gforToggle(); - try { - arguments[fPos].call(thisArg, seq); - } finally { - af._gforToggle(); - } - }; -} - -module.exports = makeGfor; -//# sourceMappingURL=makeGfor.js.map diff --git a/lib/es5/makeGfor.js.map b/lib/es5/makeGfor.js.map deleted file mode 100644 index 51f9e19..0000000 --- a/lib/es5/makeGfor.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["makeGfor.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACtC,IAAI,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;;AAE3B,SAAS,QAAQ,CAAC,EAAE,EAAE;AAClB,WAAO,SAAS,IAAI,GAAG;AACnB,YAAI,IAAI,GAAG,CAAC,CAAC,CAAC;AACd,aAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,gBAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;AAC5B,oBAAI,GAAG,CAAC,CAAC;AACT,sBAAM;aACT;SACJ;AACD,YAAI,IAAI,KAAK,CAAC,CAAC,EAAE;AACb,kBAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACvD;AACD,YAAI,IAAI,KAAK,CAAC,EAAE;AACZ,kBAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC9C;AACD,YAAI,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAC9B,YAAI,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE;AACrD,mBAAO,GAAG,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;SACjC;AACD,YAAI,GAAG,YAAA,CAAC;AACR,YAAI,IAAI,KAAK,CAAC,EAAE;AACZ,eAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/B,MACI,IAAI,IAAI,KAAK,CAAC,EAAE;AACjB,eAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;SAC7C,MACI;AACD,kBAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACvD;AACD,WAAG,CAAC,MAAM,GAAG,IAAI,CAAC;AAClB,UAAE,CAAC,WAAW,EAAE,CAAC;AACjB,YAAI;AACA,qBAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;SACtC,SACO;AACJ,cAAE,CAAC,WAAW,EAAE,CAAC;SACpB;KACJ,CAAC;CACL;;AAED,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC","file":"makeGfor.js","sourcesContent":["/*\r\n Copyright (c) 2014-2015, ArrayFire\r\n Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\n All rights reserved.\r\n\r\n Redistribution and use in source and binary forms, with or without modification,\r\n are permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\nlet Seq = require(\"./seq\");\r\n\r\nfunction makeGfor(af) {\r\n return function gfor() {\r\n let fPos = -1;\r\n for(let i = 0; i < arguments.length; i++) {\r\n if (_.isFunction(arguments[i])) {\r\n fPos = i;\r\n break;\r\n }\r\n }\r\n if (fPos === -1) {\r\n throw new Error(\"Body function argument expected.\");\r\n }\r\n if (fPos === 0) {\r\n throw new Error(\"Seq arguments expected.\");\r\n }\r\n let thisArg = arguments[fPos];\r\n if (arguments.length > fPos + 1 && _.isObject(fPos + 1)) {\r\n thisArg = arguments[fPos + 1];\r\n }\r\n let seq;\r\n if (fPos === 1) {\r\n seq = new Seq(arguments[0]);\r\n }\r\n else if (fPos === 2) {\r\n seq = new Seq(arguments[0], arguments[1]);\r\n }\r\n else {\r\n throw new Error(\"Invalid number of Seq arguments.\");\r\n }\r\n seq.isGFor = true;\r\n af._gforToggle();\r\n try {\r\n arguments[fPos].call(thisArg, seq);\r\n }\r\n finally {\r\n af._gforToggle();\r\n }\r\n };\r\n}\r\n\r\nmodule.exports = makeGfor;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/matProp.js b/lib/es5/matProp.js deleted file mode 100644 index 7d94218..0000000 --- a/lib/es5/matProp.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var matProp = module.exports = { - none: 0, ///< Default - trans: 1, ///< Data needs to be transposed - cTrans: 2, ///< Data needs to be conjugate tansposed - upper: 32, ///< Matrix is upper triangular - lower: 64, ///< Matrix is lower triangular - diagUnit: 128, ///< Matrix diagonal contains unitary values - sym: 512, ///< Matrix is symmetric - posDef: 1024, ///< Matrix is positive definite - orthog: 2048, ///< Matrix is orthogonal - triDiag: 4096, ///< Matrix is tri diagonal - blockDiag: 8192, ///< Matrix is block diagonal - AF_MAT_NONE: 0, ///< Default - AF_MAT_TRANS: 1, ///< Data needs to be transposed - AF_MAT_CTRANS: 2, ///< Data needs to be conjugate tansposed - AF_MAT_UPPER: 32, ///< Matrix is upper triangular - AF_MAT_LOWER: 64, ///< Matrix is lower triangular - AF_MAT_DIAG_UNIT: 128, ///< Matrix diagonal contains unitary values - AF_MAT_SYM: 512, ///< Matrix is symmetric - AF_MAT_POSDEF: 1024, ///< Matrix is positive definite - AF_MAT_ORTHOG: 2048, ///< Matrix is orthogonal - AF_MAT_TRI_DIAG: 4096, ///< Matrix is tri diagonal - AF_MAT_BLOCK_DIAG: 8192 ///< Matrix is block diagonal -}; -//# sourceMappingURL=matProp.js.map diff --git a/lib/es5/matProp.js.map b/lib/es5/matProp.js.map deleted file mode 100644 index 5ac1789..0000000 --- a/lib/es5/matProp.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["matProp.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,OAAO,GAAG,MAAM,CAAC,OAAO,GAAG;AAC3B,MAAI,EAAS,CAAC;AACd,OAAK,EAAQ,CAAC;AACd,QAAM,EAAO,CAAC;AACd,OAAK,EAAQ,EAAE;AACf,OAAK,EAAQ,EAAE;AACf,UAAQ,EAAK,GAAG;AAChB,KAAG,EAAU,GAAG;AAChB,QAAM,EAAO,IAAI;AACjB,QAAM,EAAO,IAAI;AACjB,SAAO,EAAM,IAAI;AACjB,WAAS,EAAI,IAAI;AACjB,aAAW,EAAS,CAAC;AACrB,cAAY,EAAQ,CAAC;AACrB,eAAa,EAAO,CAAC;AACrB,cAAY,EAAQ,EAAE;AACtB,cAAY,EAAQ,EAAE;AACtB,kBAAgB,EAAI,GAAG;AACvB,YAAU,EAAU,GAAG;AACvB,eAAa,EAAO,IAAI;AACxB,eAAa,EAAO,IAAI;AACxB,iBAAe,EAAK,IAAI;AACxB,mBAAiB,EAAG,IAAI;AAAA,CAC3B,CAAC","file":"matProp.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet matProp = module.exports = {\r\n none : 0, ///< Default\r\n trans : 1, ///< Data needs to be transposed\r\n cTrans : 2, ///< Data needs to be conjugate tansposed\r\n upper : 32, ///< Matrix is upper triangular\r\n lower : 64, ///< Matrix is lower triangular\r\n diagUnit : 128, ///< Matrix diagonal contains unitary values\r\n sym : 512, ///< Matrix is symmetric\r\n posDef : 1024, ///< Matrix is positive definite\r\n orthog : 2048, ///< Matrix is orthogonal\r\n triDiag : 4096, ///< Matrix is tri diagonal\r\n blockDiag : 8192, ///< Matrix is block diagonal\r\n AF_MAT_NONE : 0, ///< Default\r\n AF_MAT_TRANS : 1, ///< Data needs to be transposed\r\n AF_MAT_CTRANS : 2, ///< Data needs to be conjugate tansposed\r\n AF_MAT_UPPER : 32, ///< Matrix is upper triangular\r\n AF_MAT_LOWER : 64, ///< Matrix is lower triangular\r\n AF_MAT_DIAG_UNIT : 128, ///< Matrix diagonal contains unitary values\r\n AF_MAT_SYM : 512, ///< Matrix is symmetric\r\n AF_MAT_POSDEF : 1024, ///< Matrix is positive definite\r\n AF_MAT_ORTHOG : 2048, ///< Matrix is orthogonal\r\n AF_MAT_TRI_DIAG : 4096, ///< Matrix is tri diagonal\r\n AF_MAT_BLOCK_DIAG : 8192 ///< Matrix is block diagonal\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/matchType.js b/lib/es5/matchType.js deleted file mode 100644 index 6444be1..0000000 --- a/lib/es5/matchType.js +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var matchType = module.exports = { - SAD: 0, - zSAD: 1, - lSAD: 2, - SSD: 3, - zSSD: 4, - lSSD: 5, - NCC: 6, - zNCC: 7, - SHD: 8, - AF_SAD: 0, - AF_ZSAD: 1, - AF_LSAD: 2, - AF_SSD: 3, - AF_ZSSD: 4, - AF_LSSD: 5, - AF_NCC: 6, - AF_ZNCC: 7, - AF_SHD: 8 -}; -//# sourceMappingURL=matchType.js.map diff --git a/lib/es5/matchType.js.map b/lib/es5/matchType.js.map deleted file mode 100644 index 7e0546c..0000000 --- a/lib/es5/matchType.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["matchType.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,SAAS,GAAG,MAAM,CAAC,OAAO,GAAG;AAC7B,KAAG,EAAE,CAAC;AACN,MAAI,EAAE,CAAC;AACP,MAAI,EAAE,CAAC;AACP,KAAG,EAAE,CAAC;AACN,MAAI,EAAE,CAAC;AACP,MAAI,EAAE,CAAC;AACP,KAAG,EAAE,CAAC;AACN,MAAI,EAAE,CAAC;AACP,KAAG,EAAE,CAAC;AACN,QAAM,EAAE,CAAC;AACT,SAAO,EAAE,CAAC;AACV,SAAO,EAAE,CAAC;AACV,QAAM,EAAE,CAAC;AACT,SAAO,EAAE,CAAC;AACV,SAAO,EAAE,CAAC;AACV,QAAM,EAAE,CAAC;AACT,SAAO,EAAE,CAAC;AACV,QAAM,EAAE,CAAC;CACZ,CAAC","file":"matchType.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet matchType = module.exports = {\r\n SAD: 0,\r\n zSAD: 1,\r\n lSAD: 2,\r\n SSD: 3,\r\n zSSD: 4,\r\n lSSD: 5,\r\n NCC: 6,\r\n zNCC: 7,\r\n SHD: 8,\r\n AF_SAD: 0,\r\n AF_ZSAD: 1,\r\n AF_LSAD: 2,\r\n AF_SSD: 3,\r\n AF_ZSSD: 4,\r\n AF_LSSD: 5,\r\n AF_NCC: 6,\r\n AF_ZNCC: 7,\r\n AF_SHD: 8\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/normType.js b/lib/es5/normType.js deleted file mode 100644 index 77ba4eb..0000000 --- a/lib/es5/normType.js +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var normType = module.exports = { - vector1: 1, ///< treats the input as a vector and returns the sum of absolute values - vectorInf: 2, ///< treats the input as a vector and returns the max of absolute values - vector2: 3, ///< treats the input as a vector and returns euclidean norm - vectorP: 4, ///< treats the input as a vector and returns the p-norm - matrix1: 5, ///< return the max of column sums - matrixInf: 6, ///< return the max of row sums - matrix2: 7, ///< returns the max singular value). Currently NOT SUPPORTED - matrixLPq: 8, ///< returns Lpq-norm - euclid: 3, ///< The default. Same as vector2 - AF_NORM_VECTOR_1: 1, ///< treats the input as a vector and returns the sum of absolute values - AF_NORM_VECTOR_INF: 2, ///< treats the input as a vector and returns the max of absolute values - AF_NORM_VECTOR_2: 3, ///< treats the input as a vector and returns euclidean norm - AF_NORM_VECTOR_P: 4, ///< treats the input as a vector and returns the p-norm - AF_NORM_MATRIX_1: 5, ///< return the max of column sums - AF_NORM_MATRIX_INF: 6, ///< return the max of row sums - AF_NORM_MATRIX_2: 7, ///< returns the max singular value). Currently NOT SUPPORTED - AF_NORM_MATRIX_L_PQ: 8, ///< returns Lpq-norm - AF_NORM_EUCLID: 3 ///< The default. Same as AF_NORM_VECTOR_2 -}; -//# sourceMappingURL=normType.js.map diff --git a/lib/es5/normType.js.map b/lib/es5/normType.js.map deleted file mode 100644 index 9e1f255..0000000 --- a/lib/es5/normType.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["normType.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,QAAQ,GAAG,MAAM,CAAC,OAAO,GAAG;AAC5B,SAAO,EAAE,CAAC;AACV,WAAS,EAAE,CAAC;AACZ,SAAO,EAAE,CAAC;AACV,SAAO,EAAE,CAAC;AACV,SAAO,EAAE,CAAC;AACV,WAAS,EAAE,CAAC;AACZ,SAAO,EAAE,CAAC;AACV,WAAS,EAAE,CAAC;AACZ,QAAM,EAAE,CAAC;AACT,kBAAgB,EAAE,CAAC;AACnB,oBAAkB,EAAE,CAAC;AACrB,kBAAgB,EAAE,CAAC;AACnB,kBAAgB,EAAE,CAAC;AACnB,kBAAgB,EAAE,CAAC;AACnB,oBAAkB,EAAE,CAAC;AACrB,kBAAgB,EAAE,CAAC;AACnB,qBAAmB,EAAE,CAAC;AACtB,gBAAc,EAAE,CAAC;AAAA,CACpB,CAAC","file":"normType.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet normType = module.exports = {\r\n vector1: 1, ///< treats the input as a vector and returns the sum of absolute values\r\n vectorInf: 2, ///< treats the input as a vector and returns the max of absolute values\r\n vector2: 3, ///< treats the input as a vector and returns euclidean norm\r\n vectorP: 4, ///< treats the input as a vector and returns the p-norm\r\n matrix1: 5, ///< return the max of column sums\r\n matrixInf: 6, ///< return the max of row sums\r\n matrix2: 7, ///< returns the max singular value). Currently NOT SUPPORTED\r\n matrixLPq: 8, ///< returns Lpq-norm\r\n euclid: 3, ///< The default. Same as vector2\r\n AF_NORM_VECTOR_1: 1, ///< treats the input as a vector and returns the sum of absolute values\r\n AF_NORM_VECTOR_INF: 2, ///< treats the input as a vector and returns the max of absolute values\r\n AF_NORM_VECTOR_2: 3, ///< treats the input as a vector and returns euclidean norm\r\n AF_NORM_VECTOR_P: 4, ///< treats the input as a vector and returns the p-norm\r\n AF_NORM_MATRIX_1: 5, ///< return the max of column sums\r\n AF_NORM_MATRIX_INF: 6, ///< return the max of row sums\r\n AF_NORM_MATRIX_2: 7, ///< returns the max singular value). Currently NOT SUPPORTED\r\n AF_NORM_MATRIX_L_PQ: 8, ///< returns Lpq-norm\r\n AF_NORM_EUCLID: 3 ///< The default. Same as AF_NORM_VECTOR_2\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/row.js b/lib/es5/row.js deleted file mode 100644 index cf03613..0000000 --- a/lib/es5/row.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); - -function Row(index) { - assert(_.isNumber(index)); - - this.index = index; -} - -module.exports = Row; -//# sourceMappingURL=row.js.map diff --git a/lib/es5/row.js.map b/lib/es5/row.js.map deleted file mode 100644 index 8121f8b..0000000 --- a/lib/es5/row.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["row.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;;AAEtC,SAAS,GAAG,CAAC,KAAK,EAAE;AAChB,QAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;;AAE1B,MAAI,CAAC,KAAK,GAAG,KAAK,CAAC;CACtB;;AAED,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC","file":"row.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\n\r\nfunction Row(index) {\r\n assert(_.isNumber(index));\r\n\r\n this.index = index;\r\n}\r\n\r\nmodule.exports = Row;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/rows.js b/lib/es5/rows.js deleted file mode 100644 index 1f1034a..0000000 --- a/lib/es5/rows.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); - -function Rows(firstIndex, lastIndex) { - assert(_.isNumber(firstIndex)); - assert(_.isNumber(lastIndex)); - - this.firstIndex = firstIndex; - this.lastIndex = lastIndex; -} - -module.exports = Rows; -//# sourceMappingURL=rows.js.map diff --git a/lib/es5/rows.js.map b/lib/es5/rows.js.map deleted file mode 100644 index 40d6cfd..0000000 --- a/lib/es5/rows.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["rows.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;;AAEtC,SAAS,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE;AACjC,QAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AAC/B,QAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;;AAE9B,MAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AAC7B,MAAI,CAAC,SAAS,GAAG,SAAS,CAAC;CAC9B;;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC","file":"rows.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\n\r\nfunction Rows(firstIndex, lastIndex) {\r\n assert(_.isNumber(firstIndex));\r\n assert(_.isNumber(lastIndex));\r\n\r\n this.firstIndex = firstIndex;\r\n this.lastIndex = lastIndex;\r\n}\r\n\r\nmodule.exports = Rows;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/scope.js b/lib/es5/scope.js deleted file mode 100644 index fcf3d04..0000000 --- a/lib/es5/scope.js +++ /dev/null @@ -1,76 +0,0 @@ -"use strict"; - -var Bluebird = require("bluebird"); -var _ = require("lodash"); - -var temporaries = []; - -function scope(f) { - if (_.isFunction(f)) { - scope.begin(); - try { - return f.call(scope, scope); - } finally { - scope.end(); - } - } -} - -scope.begin = function () { - temporaries.push(new Set()); - return scope; -}; - -scope.end = function () { - if (temporaries.length) { - var set = temporaries[temporaries.length - 1]; - temporaries.length--; - free(set); - } - return scope; -}; - -scope.register = function (array) { - if (temporaries.length && _.isObject(array) && _.isFunction(array.free)) { - var set = temporaries[temporaries.length - 1]; - set.add(array); - } -}; - -scope.result = function (array) { - if (temporaries.length && _.isObject(array)) { - var set = temporaries[temporaries.length - 1]; - set.delete(array); - } - return array; -}; - -function free(arrays) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = arrays.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var array = _step.value; - - array.free(); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } -} - -module.exports = scope; -//# sourceMappingURL=scope.js.map diff --git a/lib/es5/scope.js.map b/lib/es5/scope.js.map deleted file mode 100644 index daa46ff..0000000 --- a/lib/es5/scope.js.map +++ /dev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K,CAAC,MAAM,GAAG,UAAS,KAAK,EAAE;AAC3B,QAAI,WAAW,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACzC,YAAI,GAAG,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,WAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KACrB;AACD,WAAO,KAAK,CAAC;CAChB,CAAC;;AAEF,SAAS,IAAI,CAAC,MAAM,EAAE;;;;;;AAClB,6BAAkB,MAAM,CAAC,MAAM,EAAE,8HAAE;gBAA1B,KAAK;;AACV,iBAAK,CAAC,IAAI,EAAE,CAAC;SAChB;;;;;;;;;;;;;;;CACJ;;AAED,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC","file":"scope.js","sourcesContent":["\"use strict\";\r\nlet Bluebird = require(\"bluebird\");\r\nlet _ = require(\"lodash\");\r\n\r\nlet temporaries = [];\r\n\r\nfunction scope(f) {\r\n if (_.isFunction(f)) {\r\n scope.begin();\r\n try {\r\n return f.call(scope, scope);\r\n }\r\n finally {\r\n scope.end();\r\n }\r\n }\r\n}\r\n\r\nscope.begin = function() {\r\n temporaries.push(new Set());\r\n return scope;\r\n};\r\n\r\nscope.end = function() {\r\n if (temporaries.length) {\r\n let set = temporaries[temporaries.length - 1];\r\n temporaries.length--;\r\n free(set);\r\n }\r\n return scope;\r\n};\r\n\r\nscope.register = function(array) {\r\n if (temporaries.length && _.isObject(array) && _.isFunction(array.free)) {\r\n let set = temporaries[temporaries.length - 1];\r\n set.add(array);\r\n }\r\n};\r\n\r\nscope.result = function(array) {\r\n if (temporaries.length && _.isObject(array)) {\r\n let set = temporaries[temporaries.length - 1];\r\n set.delete(array);\r\n }\r\n return array;\r\n};\r\n\r\nfunction free(arrays) {\r\n for (let array of arrays.values()) {\r\n array.free();\r\n }\r\n}\r\n\r\nmodule.exports = scope;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/seq.js b/lib/es5/seq.js deleted file mode 100644 index f8c72da..0000000 --- a/lib/es5/seq.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); - -function Seq(begin, end, step) { - assert(_.isNumber(begin)); - if (_.isUndefined(end)) { - end = begin - 1; - begin = 0; - } else { - assert(_.isNumber(end)); - } - step = step || 1; - assert(_.isNumber(step)); - - this.begin = begin; - this.end = end; - this.step = step; - - this.isGFor = false; -} - -module.exports = Seq; -//# sourceMappingURL=seq.js.map diff --git a/lib/es5/seq.js.map b/lib/es5/seq.js.map deleted file mode 100644 index d952a27..0000000 --- a/lib/es5/seq.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["seq.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;;AAEtC,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE;AAC3B,UAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1B,QAAI,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;AACpB,WAAG,GAAG,KAAK,GAAG,CAAC,CAAC;AAChB,aAAK,GAAG,CAAC,CAAC;KACb,MACI;AACD,cAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;KAC3B;AACD,QAAI,GAAG,IAAI,IAAI,CAAC,CAAC;AACjB,UAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEzB,QAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACnB,QAAI,CAAC,GAAG,GAAG,GAAG,CAAC;AACf,QAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;AAEjB,QAAI,CAAC,MAAM,GAAG,KAAK,CAAC;CACvB;;AAED,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC","file":"seq.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\n\r\nfunction Seq(begin, end, step) {\r\n assert(_.isNumber(begin));\r\n if (_.isUndefined(end)) {\r\n end = begin - 1;\r\n begin = 0;\r\n }\r\n else {\r\n assert(_.isNumber(end));\r\n }\r\n step = step || 1;\r\n assert(_.isNumber(step));\r\n\r\n this.begin = begin;\r\n this.end = end;\r\n this.step = step;\r\n\r\n this.isGFor = false;\r\n}\r\n\r\nmodule.exports = Seq;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es5/source.js b/lib/es5/source.js deleted file mode 100644 index 2e905eb..0000000 --- a/lib/es5/source.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -var source = module.exports = { - device: 0, - host: 1, - afDevice: 0, - afHost: 1 -}; -//# sourceMappingURL=source.js.map diff --git a/lib/es5/source.js.map b/lib/es5/source.js.map deleted file mode 100644 index f93081c..0000000 --- a/lib/es5/source.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["source.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,MAAM,GAAG,MAAM,CAAC,OAAO,GAAG;AAC1B,QAAM,EAAE,CAAC;AACT,MAAI,EAAE,CAAC;AACP,UAAQ,EAAE,CAAC;AACX,QAAM,EAAE,CAAC;CACZ,CAAC","file":"source.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n\r\nlet source = module.exports = {\r\n device: 0,\r\n host: 1,\r\n afDevice: 0,\r\n afHost: 1\r\n};"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/es6/borderType.js b/lib/es6/borderType.js deleted file mode 100644 index 7191b12..0000000 --- a/lib/es6/borderType.js +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let borderType = module.exports = { - padZero: 0, - padSym: 1, - AF_PAD_ZERO: 0, - AF_PAD_SYM: 1 -}; \ No newline at end of file diff --git a/lib/es6/cSpace.js b/lib/es6/cSpace.js deleted file mode 100644 index 9d084c6..0000000 --- a/lib/es6/cSpace.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let cSpace = module.exports = { - Gray: 0, ///< Grayscale - RGB: 1, ///< 3-channel RGB - HSV: 2, ///< 3-channel HSV - AF_GRAY: 0, ///< Grayscale - AF_RGB: 1, ///< 3-channel RGB - AF_HSV: 2 ///< 3-channel HSV -}; \ No newline at end of file diff --git a/lib/es6/col.js b/lib/es6/col.js deleted file mode 100644 index 0cb218c..0000000 --- a/lib/es6/col.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let _ = require("lodash"); -let assert = require("better-assert"); - -function Col(index) { - assert(_.isNumber(index)); - - this.index = index; -} - -module.exports = Col; \ No newline at end of file diff --git a/lib/es6/cols.js b/lib/es6/cols.js deleted file mode 100644 index bcbcc0c..0000000 --- a/lib/es6/cols.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let _ = require("lodash"); -let assert = require("better-assert"); - -function Cols(firstIndex, lastIndex) { - assert(_.isNumber(firstIndex)); - assert(_.isNumber(lastIndex)); - - this.firstIndex = firstIndex; - this.lastIndex = lastIndex; -} - -module.exports = Cols; \ No newline at end of file diff --git a/lib/es6/complex.js b/lib/es6/complex.js deleted file mode 100644 index 7f91ddc..0000000 --- a/lib/es6/complex.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let _ = require("lodash"); -let assert = require("better-assert"); - -function Complex(real, imag) { - assert(_.isNumber(real)); - assert(_.isNumber(imag)); - - this.real = real; - this.imag = imag; -} - -module.exports = Complex; \ No newline at end of file diff --git a/lib/es6/connectivity.js b/lib/es6/connectivity.js deleted file mode 100644 index 9703d22..0000000 --- a/lib/es6/connectivity.js +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let connectivity = module.exports = { - connectivity4: 4, - connectivity8: 8, - AF_CONNECTIVITY_4: 4, - AF_CONNECTIVITY_8: 8 -}; \ No newline at end of file diff --git a/lib/es6/convDomain.js b/lib/es6/convDomain.js deleted file mode 100644 index 115e79c..0000000 --- a/lib/es6/convDomain.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let convDomain = module.exports = { - auto: 0, ///< ArrayFire automatically picks the right convolution algorithm - spatial: 1, ///< Perform convolution in spatial domain - freq: 2, ///< Perform convolution in frequency domain - AF_CONV_AUTO: 0, ///< ArrayFire automatically picks the right convolution algorithm - AF_CONV_SPATIAL: 1, ///< Perform convolution in spatial domain - AF_CONV_FREQ: 2 ///< Perform convolution in frequency domain -}; \ No newline at end of file diff --git a/lib/es6/convMode.js b/lib/es6/convMode.js deleted file mode 100644 index d6142fb..0000000 --- a/lib/es6/convMode.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let convMode = module.exports = { - /// - /// Output of the convolution is the same size as input - /// - default: 0, - - /// - /// Output of the convolution is signal_len + filter_len - 1 - /// - expand: 1, - /// - /// Output of the convolution is the same size as input - /// - AF_CONV_DEFAULT: 0, - - /// - /// Output of the convolution is signal_len + filter_len - 1 - /// - AF_CONV_EXPAND: 1 -}; \ No newline at end of file diff --git a/lib/es6/dim4.js b/lib/es6/dim4.js deleted file mode 100644 index 324dd82..0000000 --- a/lib/es6/dim4.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let _ = require("lodash"); -let assert = require("better-assert"); - -function Dim4(dim0, dim1, dim2, dim3) { - if (_.isArray(dim0)) { - return new Dim4(dim0[0], dim0[1], dim0[2], dim0[3]); - } - this.values = []; - if (_.isNumber(dim0)) { this.values.push(dim0) } else { this.values.push(1); } - if (_.isNumber(dim1)) { this.values.push(dim1) } else { this.values.push(1); } - if (_.isNumber(dim2)) { this.values.push(dim2) } else { this.values.push(1); } - if (_.isNumber(dim3)) { this.values.push(dim3) } else { this.values.push(1); } - let index; - for (index = 3; index >= 0; index--) { - if (this.values[index] !== 1) { - break; - } - } - this.ndims = this.nDims = index + 1; - this.elements = this.values[0] * this.values[1] * this.values[2] * this.values[3]; -} - -module.exports = Dim4; \ No newline at end of file diff --git a/lib/es6/doc/afArray.js b/lib/es6/doc/afArray.js deleted file mode 100644 index 66e0237..0000000 --- a/lib/es6/doc/afArray.js +++ /dev/null @@ -1,299 +0,0 @@ -"use strict"; - -class AFArray { - constructor() { - } - - free() { - } - - elements() { - } - - host() { - } - - copyToHost() { - } - - scalar() { - } - - value() { - } - - write() { - } - - type() { - } - - dims() { - } - - numdims() { - } - - numDims() { - } - - bytes() { - } - - copy() { - } - - isempty() { - } - - isEmpty() { - } - - isscalar() { - } - - isScalar() { - } - - isvector() { - } - - isVector() { - } - - isrow() { - } - - isRow() { - } - - iscolumn() { - } - - isColumn() { - } - - iscomplex() { - } - - isComplex() { - } - - isreal() { - } - - isReal() { - } - - isdouble() { - } - - isDouble() { - } - - issingle() { - } - - isSingle() { - } - - isrealfloating() { - } - - isRealFloating() { - } - - isfloating() { - } - - isFloating() { - } - - isinteger() { - } - - isInteger() { - } - - isbool() { - } - - isBool() { - } - - afEval() { - } - - at() { - } - - row() { - } - - col() { - } - - slice() { - } - - rows() { - } - - cols() { - } - - slices() { - } - - as() { - } - - assign() { - } - - set() { - } - - add() { - } - - addAssign() { - } - - sub() { - } - - subAssign() { - } - - mul() { - } - - mulAssign() { - } - - div() { - } - - divAssign() { - } - - bitshiftl() { - } - - bitShiftL() { - } - - bitshiftr() { - } - - bitShiftR() { - } - - lt() { - } - - gt() { - } - - le() { - } - - ge() { - } - - eq() { - } - - neq() { - } - - and() { - } - - or() { - } - - bitAnd() { - } - - bitOr() { - } - - bitXor() { - } - - rhsAdd() { - } - - rhsSub() { - } - - rhsMul() { - } - - rhsDiv() { - } - - rhsBitshiftl() { - } - - rhsBitShiftL() { - } - - rhsBitshiftr() { - } - - rhsBitShiftR() { - } - - rhsLt() { - } - - rhsGt() { - } - - rhsLe() { - } - - rhsGe() { - } - - rhsEq() { - } - - rhsNeq() { - } - - rhsAnd() { - } - - rhsOr() { - } - - rhsBitAnd() { - } - - rhsBitOr() { - } - - rhsBitXor() { - } - - neg() { - } - - not() { - } - - T() { - } - - H() { - } -} - -AFArray.create = function() { -}; - -module.exports = AFArray; diff --git a/lib/es6/dtype.js b/lib/es6/dtype.js deleted file mode 100644 index 2ddffa7..0000000 --- a/lib/es6/dtype.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let dType = module.exports = { - f32: 0, - c32: 1, - f64: 2, - c64: 3, - b8: 4, - s32: 5, - u32: 6, - u8: 7, - s64: 8, - u64: 9 -}; \ No newline at end of file diff --git a/lib/es6/ext.js b/lib/es6/ext.js deleted file mode 100644 index fc0fb75..0000000 --- a/lib/es6/ext.js +++ /dev/null @@ -1,134 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let Bluebird = require("bluebird"); -let _ = require("lodash"); -let async = Bluebird.coroutine; - -const retryCount = 5; -const gcTime = 1000; - -function synchronify(af, f) { - return function () { - var err; - var res; - var done; - let cb = function (e, r) { - err = e; - res = r; - done = true; - }; - - let args = _.toArray(arguments).concat(cb); - f.apply(this, args); - while (!done) af._doEvents(); - - return res; - }; -} - -function installAsyncAndSync(af, obj, name) { - if (_.isUndefined(name)) { - for (let key of _.keys(obj)) { - installAsyncAndSync(af, obj, key); - } - return; - } - - if (name !== "AFArray") { - let f = obj[name]; - if (_.isFunction(f)) { - if (!_.isFunction(obj[name + "Async"])) { - obj[name + "Async"] = Bluebird.promisify(f); - } - if (!_.isFunction(obj[name + "Sync"])) { - obj[name + "Sync"] = synchronify(af, f); - } - } - } -} - -function ext(af) { - installAsyncAndSync(af, af); - installAsyncAndSync(af, af.AFArray); - installAsyncAndSync(af, af.AFArray.prototype); - - let scope = af.AFArray.scope = require("./scope"); - - _.extend(af, { - end: -1, - span: null, - all: -1, - dtype: require("./dtype"), - dType: require("./dtype"), - source: require("./source"), - matchType: require("./matchType"), - cSpace: require("./cSpace"), - CSpace: require("./cSpace"), - connectivity: require("./connectivity"), - borderType: require("./borderType"), - interpType: require("./interpType"), - matProp: require("./matProp"), - normType: require("./normType"), - convMode: require("./convMode"), - convDomain: require("./convDomain"), - Dim4: require("./dim4"), - Seq: require("./seq"), - Complex: require("./complex"), - Row: require("./row"), - Col: require("./col"), - Rows: require("./rows"), - Cols: require("./cols"), - getDevices: function () { - let current = this.getDevice(); - try { - let count = this.getDeviceCount(); - let result = []; - for (let i = 0; i < count; i++) { - this.setDevice(i); - let info = this.deviceInfo(); - info.id = i; - result.push(info); - } - return result; - } - finally { - this.setDevice(current); - } - }, - gfor: require("./makeGfor")(af), - scope: scope - }); -} - -module.exports = ext; \ No newline at end of file diff --git a/lib/es6/index.js b/lib/es6/index.js deleted file mode 100644 index 66c143b..0000000 --- a/lib/es6/index.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let _ = require("lodash"); -let ext = require("./ext"); -let Bluebird = require("bluebird"); -let debug = require("debug")("af"); - -let cpuDriver = null; -let cudaDriver = null; -let openCLDriver = null; - -let entry = module.exports = function(id) { - let did = _.isString(id) ? id.trim().toLowerCase() : null; - did = did || "cpu"; - function createAF() { - switch (did) { - case "cpu": - return cpuDriver || (cpuDriver = require("bindings")("arrayfire_js_CPU")); - case "cuda": - return cudaDriver || (cudaDriver = require("bindings")("arrayfire_js_CUDA")); - case "opencl": - return openCLDriver || (openCLDriver = require("bindings")("arrayfire_js_OpenCL")); - default: - throw new Error("Platform '" + id + "' is not supported."); - } - } - let af = createAF(); - if (!af.__extended) { - ext(af); - af.__extended = true; - } - return af; -}; - -entry.supportedPlatforms = function() { - let platforms = []; - for (let id of ["CPU", "CUDA", "OpenCL"]) { - try { - let fire = entry(id); - platforms.push(id); - } - catch(e) { - debug("Cannot create ArrayFire binding of platform %s, because of error:\n%s", id, e.stack); - } - } - return platforms; -}; \ No newline at end of file diff --git a/lib/es6/interpType.js b/lib/es6/interpType.js deleted file mode 100644 index cb59772..0000000 --- a/lib/es6/interpType.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let interpType = module.exports = { - nearest: 0, ///< Nearest Interpolation - linear: 1, ///< Linear Interpolation - bilinerar : 2, ///< Bilinear Interpolation - cubic: 3, ///< Cubic Interpolation, - AF_INTERP_NEAREST: 0, ///< Nearest Interpolation - AF_INTERP_LINEAR: 1, ///< Linear Interpolation - AF_INTERP_BILINEAR : 2, ///< Bilinear Interpolation - AF_INTERP_CUBIC: 3 ///< Cubic Interpolation -}; \ No newline at end of file diff --git a/lib/es6/makeGfor.js b/lib/es6/makeGfor.js deleted file mode 100644 index 89fce9e..0000000 --- a/lib/es6/makeGfor.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (c) 2014-2015, ArrayFire - Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -let _ = require("lodash"); -let assert = require("better-assert"); -let Seq = require("./seq"); - -function makeGfor(af) { - return function gfor() { - let fPos = -1; - for(let i = 0; i < arguments.length; i++) { - if (_.isFunction(arguments[i])) { - fPos = i; - break; - } - } - if (fPos === -1) { - throw new Error("Body function argument expected."); - } - if (fPos === 0) { - throw new Error("Seq arguments expected."); - } - let thisArg = arguments[fPos]; - if (arguments.length > fPos + 1 && _.isObject(fPos + 1)) { - thisArg = arguments[fPos + 1]; - } - let seq; - if (fPos === 1) { - seq = new Seq(arguments[0]); - } - else if (fPos === 2) { - seq = new Seq(arguments[0], arguments[1]); - } - else { - throw new Error("Invalid number of Seq arguments."); - } - seq.isGFor = true; - af._gforToggle(); - try { - arguments[fPos].call(thisArg, seq); - } - finally { - af._gforToggle(); - } - }; -} - -module.exports = makeGfor; \ No newline at end of file diff --git a/lib/es6/matProp.js b/lib/es6/matProp.js deleted file mode 100644 index 6e555da..0000000 --- a/lib/es6/matProp.js +++ /dev/null @@ -1,57 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let matProp = module.exports = { - none : 0, ///< Default - trans : 1, ///< Data needs to be transposed - cTrans : 2, ///< Data needs to be conjugate tansposed - upper : 32, ///< Matrix is upper triangular - lower : 64, ///< Matrix is lower triangular - diagUnit : 128, ///< Matrix diagonal contains unitary values - sym : 512, ///< Matrix is symmetric - posDef : 1024, ///< Matrix is positive definite - orthog : 2048, ///< Matrix is orthogonal - triDiag : 4096, ///< Matrix is tri diagonal - blockDiag : 8192, ///< Matrix is block diagonal - AF_MAT_NONE : 0, ///< Default - AF_MAT_TRANS : 1, ///< Data needs to be transposed - AF_MAT_CTRANS : 2, ///< Data needs to be conjugate tansposed - AF_MAT_UPPER : 32, ///< Matrix is upper triangular - AF_MAT_LOWER : 64, ///< Matrix is lower triangular - AF_MAT_DIAG_UNIT : 128, ///< Matrix diagonal contains unitary values - AF_MAT_SYM : 512, ///< Matrix is symmetric - AF_MAT_POSDEF : 1024, ///< Matrix is positive definite - AF_MAT_ORTHOG : 2048, ///< Matrix is orthogonal - AF_MAT_TRI_DIAG : 4096, ///< Matrix is tri diagonal - AF_MAT_BLOCK_DIAG : 8192 ///< Matrix is block diagonal -}; \ No newline at end of file diff --git a/lib/es6/matchType.js b/lib/es6/matchType.js deleted file mode 100644 index 0868d3d..0000000 --- a/lib/es6/matchType.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let matchType = module.exports = { - SAD: 0, - zSAD: 1, - lSAD: 2, - SSD: 3, - zSSD: 4, - lSSD: 5, - NCC: 6, - zNCC: 7, - SHD: 8, - AF_SAD: 0, - AF_ZSAD: 1, - AF_LSAD: 2, - AF_SSD: 3, - AF_ZSSD: 4, - AF_LSSD: 5, - AF_NCC: 6, - AF_ZNCC: 7, - AF_SHD: 8 -}; \ No newline at end of file diff --git a/lib/es6/normType.js b/lib/es6/normType.js deleted file mode 100644 index 12265fd..0000000 --- a/lib/es6/normType.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let normType = module.exports = { - vector1: 1, ///< treats the input as a vector and returns the sum of absolute values - vectorInf: 2, ///< treats the input as a vector and returns the max of absolute values - vector2: 3, ///< treats the input as a vector and returns euclidean norm - vectorP: 4, ///< treats the input as a vector and returns the p-norm - matrix1: 5, ///< return the max of column sums - matrixInf: 6, ///< return the max of row sums - matrix2: 7, ///< returns the max singular value). Currently NOT SUPPORTED - matrixLPq: 8, ///< returns Lpq-norm - euclid: 3, ///< The default. Same as vector2 - AF_NORM_VECTOR_1: 1, ///< treats the input as a vector and returns the sum of absolute values - AF_NORM_VECTOR_INF: 2, ///< treats the input as a vector and returns the max of absolute values - AF_NORM_VECTOR_2: 3, ///< treats the input as a vector and returns euclidean norm - AF_NORM_VECTOR_P: 4, ///< treats the input as a vector and returns the p-norm - AF_NORM_MATRIX_1: 5, ///< return the max of column sums - AF_NORM_MATRIX_INF: 6, ///< return the max of row sums - AF_NORM_MATRIX_2: 7, ///< returns the max singular value). Currently NOT SUPPORTED - AF_NORM_MATRIX_L_PQ: 8, ///< returns Lpq-norm - AF_NORM_EUCLID: 3 ///< The default. Same as AF_NORM_VECTOR_2 -}; \ No newline at end of file diff --git a/lib/es6/row.js b/lib/es6/row.js deleted file mode 100644 index 87bdf0c..0000000 --- a/lib/es6/row.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let _ = require("lodash"); -let assert = require("better-assert"); - -function Row(index) { - assert(_.isNumber(index)); - - this.index = index; -} - -module.exports = Row; \ No newline at end of file diff --git a/lib/es6/rows.js b/lib/es6/rows.js deleted file mode 100644 index 8001a04..0000000 --- a/lib/es6/rows.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let _ = require("lodash"); -let assert = require("better-assert"); - -function Rows(firstIndex, lastIndex) { - assert(_.isNumber(firstIndex)); - assert(_.isNumber(lastIndex)); - - this.firstIndex = firstIndex; - this.lastIndex = lastIndex; -} - -module.exports = Rows; \ No newline at end of file diff --git a/lib/es6/scope.js b/lib/es6/scope.js deleted file mode 100644 index a004c24..0000000 --- a/lib/es6/scope.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -let Bluebird = require("bluebird"); -let _ = require("lodash"); - -let temporaries = []; - -function scope(f) { - if (_.isFunction(f)) { - scope.begin(); - try { - return f.call(scope, scope); - } - finally { - scope.end(); - } - } -} - -scope.begin = function() { - temporaries.push(new Set()); - return scope; -}; - -scope.end = function() { - if (temporaries.length) { - let set = temporaries[temporaries.length - 1]; - temporaries.length--; - free(set); - } - return scope; -}; - -scope.register = function(array) { - if (temporaries.length && _.isObject(array) && _.isFunction(array.free)) { - let set = temporaries[temporaries.length - 1]; - set.add(array); - } -}; - -scope.result = function(array) { - if (temporaries.length && _.isObject(array)) { - let set = temporaries[temporaries.length - 1]; - set.delete(array); - } - return array; -}; - -function free(arrays) { - for (let array of arrays.values()) { - array.free(); - } -} - -module.exports = scope; \ No newline at end of file diff --git a/lib/es6/seq.js b/lib/es6/seq.js deleted file mode 100644 index 348cf11..0000000 --- a/lib/es6/seq.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let _ = require("lodash"); -let assert = require("better-assert"); - -function Seq(begin, end, step) { - assert(_.isNumber(begin)); - if (_.isUndefined(end)) { - end = begin - 1; - begin = 0; - } - else { - assert(_.isNumber(end)); - } - step = step || 1; - assert(_.isNumber(step)); - - this.begin = begin; - this.end = end; - this.step = step; - - this.isGFor = false; -} - -module.exports = Seq; \ No newline at end of file diff --git a/lib/es6/source.js b/lib/es6/source.js deleted file mode 100644 index 61d7200..0000000 --- a/lib/es6/source.js +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; - -let source = module.exports = { - device: 0, - host: 1, - afDevice: 0, - afHost: 1 -}; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 2248102..0000000 --- a/lib/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -var es6 = true; -try { - eval("(() => {})()"); -} catch (err) { - es6 = false; -} - -var es = es6 ? "es6" : "es5"; - -if (!es6) { - require("babel-polyfill"); -} - -module.exports = require("./" + es); \ No newline at end of file diff --git a/src/arrayhelperfunctions.cpp b/src/arrayhelperfunctions.cpp deleted file mode 100644 index d839352..0000000 --- a/src/arrayhelperfunctions.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "arrayhelperfunctions.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" - -using namespace v8; -using namespace std; -using namespace node; - -AF_ARR(IsZero, iszero) -AF_ARR(IsInf, isInf) -AF_ARR(IsNaN, isNaN) - -NAN_METHOD(Print) -{ - try - { - ARGS_LEN(1); - Guard guard; - af_print(*ArrayWrapper::GetArrayAt(info, 0)); - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH; -} - -NAN_MODULE_INIT(InitArrayHelperFunctions) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("iszero").ToLocalChecked(), - Nan::New(IsZero)->GetFunction()); - - Nan::Set(target, Nan::New("isZero").ToLocalChecked(), - Nan::New(IsZero)->GetFunction()); - - Nan::Set(target, Nan::New("isInf").ToLocalChecked(), - Nan::New(IsInf)->GetFunction()); - - Nan::Set(target, Nan::New("isNaN").ToLocalChecked(), - Nan::New(IsNaN)->GetFunction()); - - Nan::Set(target, Nan::New("print").ToLocalChecked(), - Nan::New(Print)->GetFunction()); -} diff --git a/src/arrayhelperfunctions.h b/src/arrayhelperfunctions.h deleted file mode 100644 index d3bd679..0000000 --- a/src/arrayhelperfunctions.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_ARRAYHELPERFUNCTIONS_H -#define ARRAYFIRE_ARRAYHELPERFUNCTIONS_H - -#include - -NAN_MODULE_INIT(InitArrayHelperFunctions); - -#endif // ARRAYFIRE_ARRAYHELPERFUNCTIONS_H - diff --git a/src/arraywrapper.cpp b/src/arraywrapper.cpp deleted file mode 100644 index c4e5f77..0000000 --- a/src/arraywrapper.cpp +++ /dev/null @@ -1,1720 +0,0 @@ - -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -* Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "arraywrapper.h" -#include "helpers.h" -#include "guard.h" -#include "worker.h" -#include "errors.h" -#include "symbols.h" - -using namespace v8; -using namespace std; -using namespace node; - -Nan::Persistent ArrayWrapper::constructor; - -int GetMemSize(const af::array* array) -{ - // Make GC aware of device memory. - // Event it's VRAM this should keep the usage on low (few hundred megabytes), - // so we won't triggrer out of memory errors. - return static_cast(sizeof(af::array)) + static_cast(sizeof(ArrayWrapper)) + static_cast(array->bytes()); -} - -ArrayWrapper::ArrayWrapper(af::array* array) : - _array(array) -{ - assert(array); - Nan::AdjustExternalMemory(GetMemSize(array)); -} - -ArrayWrapper::~ArrayWrapper() -{ - Free(); -} - -void ArrayWrapper::Free() -{ - if (_array) - { - Nan::AdjustExternalMemory(-GetMemSize(_array)); - delete _array; - _array = nullptr; - } -} - -NAN_MODULE_INIT(ArrayWrapper::Init) -{ - Nan::HandleScope scope; - - auto tmpl = Nan::New(New); - tmpl->SetClassName(Nan::New("AFArray").ToLocalChecked()); - - int noOfMethods = 21; - tmpl->InstanceTemplate()->SetInternalFieldCount(noOfMethods); - Nan::SetPrototypeTemplate(tmpl, Nan::New("free").ToLocalChecked(), Nan::New(V8Free), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("elements").ToLocalChecked(), Nan::New(Elements), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("host").ToLocalChecked(), Nan::New(Host), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("copyToHost").ToLocalChecked(), Nan::New(Host), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("scalar").ToLocalChecked(), Nan::New(Scalar), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("value").ToLocalChecked(), Nan::New(Scalar), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("write").ToLocalChecked(), Nan::New(Write), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("type").ToLocalChecked(), Nan::New(Type), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("dims").ToLocalChecked(), Nan::New(Dims), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("numdims").ToLocalChecked(), Nan::New(NumDims), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("numDims").ToLocalChecked(), Nan::New(NumDims), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("bytes").ToLocalChecked(), Nan::New(Bytes), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("copy").ToLocalChecked(), Nan::New(Copy), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isempty").ToLocalChecked(), Nan::New(IsEmpty), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isEmpty").ToLocalChecked(), Nan::New(IsEmpty), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isscalar").ToLocalChecked(), Nan::New(IsScalar), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isScalar").ToLocalChecked(), Nan::New(IsScalar), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isvector").ToLocalChecked(), Nan::New(IsVector), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isVector").ToLocalChecked(), Nan::New(IsVector), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isrow").ToLocalChecked(), Nan::New(IsRow), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isRow").ToLocalChecked(), Nan::New(IsRow), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("iscolumn").ToLocalChecked(), Nan::New(IsColumn), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isColumn").ToLocalChecked(), Nan::New(IsColumn), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("iscomplex").ToLocalChecked(), Nan::New(IsComplex), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isComplex").ToLocalChecked(), Nan::New(IsComplex), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isreal").ToLocalChecked(), Nan::New(IsReal), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isReal").ToLocalChecked(), Nan::New(IsReal), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isdouble").ToLocalChecked(), Nan::New(IsDouble), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isDouble").ToLocalChecked(), Nan::New(IsDouble), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("issingle").ToLocalChecked(), Nan::New(IsSingle), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isSingle").ToLocalChecked(), Nan::New(IsSingle), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isrealfloating").ToLocalChecked(), Nan::New(IsRealFloating), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isRealFloating").ToLocalChecked(), Nan::New(IsRealFloating), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isfloating").ToLocalChecked(), Nan::New(IsFloating), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isFloating").ToLocalChecked(), Nan::New(IsFloating), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isinteger").ToLocalChecked(), Nan::New(IsInteger), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isInteger").ToLocalChecked(), Nan::New(IsInteger), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isbool").ToLocalChecked(), Nan::New(IsBool), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("isBool").ToLocalChecked(), Nan::New(IsBool), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("afEval").ToLocalChecked(), Nan::New(Eval), v8::None); - - Nan::SetPrototypeTemplate(tmpl, Nan::New("at").ToLocalChecked(), Nan::New(At), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("row").ToLocalChecked(), Nan::New(Row), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("col").ToLocalChecked(), Nan::New(Col), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("slice").ToLocalChecked(), Nan::New(Slice), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rows").ToLocalChecked(), Nan::New(Rows), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("cols").ToLocalChecked(), Nan::New(Cols), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("slices").ToLocalChecked(), Nan::New(Slices), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("as").ToLocalChecked(), Nan::New(As), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("assign").ToLocalChecked(), Nan::New(Assign), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("set").ToLocalChecked(), Nan::New(Assign), v8::None); - - Nan::SetPrototypeTemplate(tmpl, Nan::New("add").ToLocalChecked(), Nan::New(Add), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("addAssign").ToLocalChecked(), Nan::New(AddAssign), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("sub").ToLocalChecked(), Nan::New(Sub), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("subAssign").ToLocalChecked(), Nan::New(SubAssign), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("mul").ToLocalChecked(), Nan::New(Mul), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("mulAssign").ToLocalChecked(), Nan::New(MulAssign), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("div").ToLocalChecked(), Nan::New(Div), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("divAssign").ToLocalChecked(), Nan::New(DivAssign), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("bitshiftl").ToLocalChecked(), Nan::New(BitShiftL), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("bitShiftL").ToLocalChecked(), Nan::New(BitShiftL), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("bitshiftr").ToLocalChecked(), Nan::New(BitShiftR), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("bitShiftR").ToLocalChecked(), Nan::New(BitShiftR), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("lt").ToLocalChecked(), Nan::New(Lt), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("gt").ToLocalChecked(), Nan::New(Gt), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("le").ToLocalChecked(), Nan::New(Le), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("ge").ToLocalChecked(), Nan::New(Ge), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("eq").ToLocalChecked(), Nan::New(Eq), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("neq").ToLocalChecked(), Nan::New(Neq), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("and").ToLocalChecked(), Nan::New(And), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("or").ToLocalChecked(), Nan::New(Or), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("bitAnd").ToLocalChecked(), Nan::New(BitAnd), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("bitOr").ToLocalChecked(), Nan::New(BitOr), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("bitXor").ToLocalChecked(), Nan::New(BitXor), v8::None); - - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsAdd").ToLocalChecked(), Nan::New(RhsAdd), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsSub").ToLocalChecked(), Nan::New(RhsSub), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsMul").ToLocalChecked(), Nan::New(RhsMul), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsDiv").ToLocalChecked(), Nan::New(RhsDiv), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsBitshiftl").ToLocalChecked(), Nan::New(RhsBitShiftL), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsBitShiftL").ToLocalChecked(), Nan::New(RhsBitShiftL), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsBitshiftr").ToLocalChecked(), Nan::New(RhsBitShiftR), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsBitShiftR").ToLocalChecked(), Nan::New(RhsBitShiftR), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsLt").ToLocalChecked(), Nan::New(RhsLt), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsGt").ToLocalChecked(), Nan::New(RhsGt), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsLe").ToLocalChecked(), Nan::New(RhsLe), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsGe").ToLocalChecked(), Nan::New(RhsGe), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsEq").ToLocalChecked(), Nan::New(RhsEq), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsNeq").ToLocalChecked(), Nan::New(RhsNeq), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsAnd").ToLocalChecked(), Nan::New(RhsAnd), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsOr").ToLocalChecked(), Nan::New(RhsOr), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsBitAnd").ToLocalChecked(), Nan::New(RhsBitAnd), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsBitOr").ToLocalChecked(), Nan::New(RhsBitOr), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("rhsBitXor").ToLocalChecked(), Nan::New(RhsBitXor), v8::None); - - Nan::SetPrototypeTemplate(tmpl, Nan::New("neg").ToLocalChecked(), Nan::New(Neg), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("not").ToLocalChecked(), Nan::New(Not), v8::None); - - Nan::SetPrototypeTemplate(tmpl, Nan::New("T").ToLocalChecked(), Nan::New(AFT), v8::None); - Nan::SetPrototypeTemplate(tmpl, Nan::New("S").ToLocalChecked(), Nan::New(AFH), v8::None); - - auto f = tmpl->GetFunction(); - f->Set(Nan::New("create").ToLocalChecked(), Nan::New(Create)->GetFunction()); - constructor.Reset(f); - Nan::Set(target, Nan::New("AFArray").ToLocalChecked(), f); -} - -v8::Local ArrayWrapper::New(const af::array& array) -{ - return New(new af::array(array)); -} - -v8::Local ArrayWrapper::New(af::array* array) -{ - Nan::EscapableHandleScope scope; - assert(array); - Local info[] = { WrapPointer(array) }; - auto c = Nan::New(constructor); - auto inst = c->NewInstance(1, info); - assert(ObjectWrap::Unwrap(inst)->_array == array); - return scope.Escape(inst); -} - -void ArrayWrapper::NewAsync(const Nan::FunctionCallbackInfo& info, const std::function& arrayFactory) -{ - if (info.Length() >= 1 && info[info.Length() - 1]->IsFunction()) - { - auto callback = new Nan::Callback(info[info.Length() - 1].As()); - auto worker = new Worker(callback, arrayFactory, [](Worker* w, af::array* a){ return ArrayWrapper::New(a); }); - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - else - { - NAN_THROW("Last argument have to be a callback!"); - } -} - -af::array* ArrayWrapper::GetArray(v8::Local value) -{ - auto array = TryGetArray(value); - if (array) return array; - ARRAYFIRE_THROW("Argument is not an AFArray instance or wrapped array has been destroyed by calling its free() method."); -} - -af::array* ArrayWrapper::TryGetArray(v8::Local value) -{ - try - { - if (value->IsObject()) - { - auto obj = value.As(); - if (obj->GetConstructorName()->Equals(Nan::New(Symbols::AFArrayClass))) - { - auto wrapper = ObjectWrap::Unwrap(value.As()); - return wrapper->_array; - } - } - } - catch (...) - { - } - return nullptr; -} - -af::array* ArrayWrapper::GetArray(v8::Local value) -{ - auto array = TryGetArray(value); - if (array) return array; - ARRAYFIRE_THROW("Argument is not an AFArray instance or wrapped array has been destroyed by calling its free() method."); -} - -af::array* ArrayWrapper::TryGetArray(v8::Local value) -{ - try - { - auto wrapper = ObjectWrap::Unwrap(value.As()); - if (wrapper) return wrapper->_array; - } - catch (...) - { - } - return nullptr; -} - -af::array* ArrayWrapper::GetArrayAt(const Nan::FunctionCallbackInfo& info, int index) -{ - auto array = TryGetArrayAt(info, index); - if (array) return array; - stringstream ss; - ss << "Argument at position " << to_string(index) << ". is not an AFArray instance."; - ARRAYFIRE_THROW(ss.str().c_str()); -} - -af::array* ArrayWrapper::TryGetArrayAt(const Nan::FunctionCallbackInfo& info, int index) -{ - if (index < info.Length()) - { - return TryGetArray(info[index]); - } - return nullptr; -} - -void ArrayWrapper::New(const Nan::FunctionCallbackInfo& info) -{ - try - { - ArrayWrapper* instance = nullptr; - try - { - if (info.Length() == 0) - { - Guard guard; - instance = new ArrayWrapper(new af::array()); - } - else if (info.Length() == 1) - { - if (Buffer::HasInstance(info[0])) - { - instance = new ArrayWrapper(reinterpret_cast(Buffer::Data(info[0]))); - } - } - else - { - Guard guard; - auto arr = TryGetArrayAt(info, 0); - if (arr) - { - auto dims = ToDim4(info[1]); - instance = new ArrayWrapper(new af::array(*arr, dims)); - } - else - { - auto dimAndType = ParseDimAndTypeArgs(info); - instance = new ArrayWrapper(new af::array(dimAndType.first, dimAndType.second)); - } - } - } - catch (...) - { - delete instance; - throw; - } - - if (!instance) - { - return NAN_THROW("Invalid arguments."); - } - - instance->Wrap(info.Holder()); - RegisterInTmp(info.Holder()); - info.GetReturnValue().Set(info.Holder()); - } - ARRAYFIRE_CATCH -} - -template -af::array* ArrayWrapper::CreateArray(void* ptr, af_source src, const af::dim4& dim4) -{ - Guard guard; - return new af::array(dim4, (T*)ptr, src); -} - -NAN_METHOD(ArrayWrapper::V8Free) -{ - auto self = ObjectWrap::Unwrap(info.This()); - self->Free(); - info.GetReturnValue().SetUndefined(); -} - -NAN_METHOD(ArrayWrapper::Create) -{ - try - { - int buffIdx = -1; - function factory; - - for (int i = 0; i < info.Length(); i++) - { - if (Buffer::HasInstance(info[i])) - { - buffIdx = i; - break; - } - } - - if (buffIdx == -1) - { - return NAN_THROW("Buffer argument expected."); - } - else if (buffIdx + 1 < info.Length()) - { - // Copy / wrap ptr - // info: dim0..dimn, dtype, ptr[, source] - af_source src = afHost; - if (buffIdx + 1 < info.Length() && info[buffIdx + 1]->IsNumber()) - { - src = (af_source)(info[buffIdx + 2]->Int32Value()); - } - auto buffObj = info[buffIdx]->ToObject(); - char* ptr = Buffer::Data(buffObj); - auto dimAndType = ParseDimAndTypeArgs(info, buffIdx); - switch (dimAndType.second) - { - case f32: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - case f64: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - case s32: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - case u32: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - case u8: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first ); }; - break; - case c32: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - case c64: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - case b8: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - case s64: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - case u64: - factory = [=]() { return CreateArray(ptr, src, dimAndType.first); }; - break; - default: - assert(false); - } - } - - if (!factory) - { - return NAN_THROW_INVALID_ARGS(); - } - - auto conv = [](Worker* w, af::array* a) - { - return New(a); - }; - auto worker = new Worker(GetCallback(info), move(factory), move(conv)); - worker->SaveToPersistent("data", info[buffIdx]->ToObject()); - - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH -} - -void ArrayWrapper::RegisterInTmp(v8::Local instance) -{ - Local args[] = { instance }; - auto scope = Nan::New(constructor)->Get(Nan::New("scope").ToLocalChecked()).As(); - auto reg = scope->Get(Nan::New("register").ToLocalChecked()); - auto regF = reg.As().As(); - regF->Call(scope, 1, args); -} - -NAN_METHOD(ArrayWrapper::Elements) -{ - try - { - Guard guard; - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->elements())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::Host) -{ - try - { - ARGS_LEN(1) - - char* buffData; - auto pArray = GetArray(info.This()); - - if (Buffer::HasInstance(info[0])) - { - buffData = Buffer::Data(info[0]); - - if (Buffer::Length(info[0]) < pArray->bytes()) - { - return NAN_THROW("Buffer is too small to hold values."); - } - - af::array array(*pArray); - auto exec = [=]() - { - Guard guard; - array.host(buffData); - }; - auto worker = new Worker(GetCallback(info), move(exec)); - worker->SaveToPersistent("data", info[0]->ToObject()); - - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - else - { - size_t size = pArray->elements() * GetDTypeInfo(pArray->type()).second; - buffData = new char[size]; - try - { - af::array array(*pArray); - auto exec = [=]() - { - Guard guard; - array.host(buffData); - return buffData; - }; - auto conv = [=](Worker* w, char* data) - { - Nan::EscapableHandleScope scope; - return scope.Escape(Nan::NewBuffer(data, size, [](char* data, void* hint) { delete[] data; }, nullptr).ToLocalChecked()); - }; - auto worker = new Worker(GetCallback(info), move(exec), move(conv)); - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - catch (...) - { - delete[] buffData; - throw; - } - } - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::Scalar) -{ - try - { - Guard guard; - auto pArray = GetArray(info.This()); - switch (pArray->type()) - { - case f32: - info.GetReturnValue().Set(Nan::New(pArray->scalar())); - break; - case f64: - info.GetReturnValue().Set(Nan::New(pArray->scalar())); - break; - case s32: - info.GetReturnValue().Set(Nan::New(pArray->scalar())); - break; - case u32: - info.GetReturnValue().Set(Nan::New(pArray->scalar())); - break; - case u8: - info.GetReturnValue().Set(Nan::New(pArray->scalar())); - break; - case b8: - info.GetReturnValue().Set(Nan::New(pArray->scalar())); - break; - case c32: - info.GetReturnValue().Set(ToV8Complex(pArray->scalar())); - break; - case c64: - info.GetReturnValue().Set(ToV8Complex(pArray->scalar())); - break; - case s64: - info.GetReturnValue().Set(Nan::New(to_string(pArray->scalar()).c_str()).ToLocalChecked()); - break; - case u64: - info.GetReturnValue().Set(Nan::New(to_string(pArray->scalar()).c_str()).ToLocalChecked()); - break; - default: - NAN_THROW_INVALID_ARGS(); - } - } - ARRAYFIRE_CATCH -} - - -NAN_METHOD(ArrayWrapper::Write) -{ - try - { - ARGS_LEN(3) - - char* buffData; - auto pArray = GetArray(info.This()); - - if (Buffer::HasInstance(info[0])) - { - buffData = Buffer::Data(info[0]); - } - else - { - return NAN_THROW("First argument is no a Buffer."); - } - - unsigned bytes = info[1]->Uint32Value(); - af_source src = afHost; - if (info.Length() > 3) - { - src = (af_source)(info[2]->Int32Value()); - } - - af::array array(*pArray); - auto exec = [=]() - { - Guard guard; - af_write_array(array.get(), buffData, bytes, src); - }; - auto worker = new Worker(GetCallback(info), move(exec)); - worker->SaveToPersistent("data", info[0]->ToObject()); - - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::Type) -{ - try - { - info.GetReturnValue().Set(GetArray(info.This())->type()); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::Dims) -{ - try - { - auto pArray = GetArray(info.This()); - if (!info.Length()) - { - auto dims = pArray->dims(); - auto jsDims = Nan::New(); - jsDims->Set(Nan::New(Symbols::Elements), Nan::New(dims.elements())); - jsDims->Set(Nan::New(Symbols::Ndims), Nan::New(dims.ndims())); - jsDims->Set(Nan::New(Symbols::NDims), Nan::New(dims.ndims())); - auto pDims = Nan::New(4); - pDims->Set(0, Nan::New(dims[0])); - pDims->Set(1, Nan::New(dims[1])); - pDims->Set(2, Nan::New(dims[2])); - pDims->Set(3, Nan::New(dims[3])); - jsDims->Set(Nan::New(Symbols::Values), pDims); - - info.GetReturnValue().Set(jsDims); - } - else - { - info.GetReturnValue().Set(Nan::New(pArray->dims(info[0]->Uint32Value()))); - } - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::NumDims) -{ - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->numdims())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::Bytes) -{ - try - { - info.GetReturnValue().Set(Nan::New((unsigned)GetArray(info.This())->bytes())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::Copy) -{ - try - { - Guard guard; - info.GetReturnValue().Set(New(GetArray(info.This())->copy())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsEmpty) -{ - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isempty())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsScalar) -{ - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isscalar())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsVector) -{ - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isvector())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsRow) -{ - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isrow())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsColumn) -{ - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->iscolumn())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsComplex) -{ - - - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->iscomplex())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsReal) -{ - - - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isreal())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsDouble) -{ - - - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isdouble())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsSingle) -{ - - - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->issingle())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsRealFloating) -{ - - - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isrealfloating())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsFloating) -{ - - - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isfloating())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsInteger) -{ - - - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->isinteger())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::IsBool) -{ - - - try - { - info.GetReturnValue().Set(Nan::New(GetArray(info.This())->type() == b8)); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::Eval) -{ - - - try - { - Guard guard; - GetArray(info.This())->eval(); - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::At) -{ - // Aka "indexing" - - - try - { - ARGS_LEN(1) - - Guard guard; - - if (info.Length() == 1) - { - auto ri = ToRegionIndex(info[0]); - switch (get<0>(ri)) - { - case Region::Row: - info.GetReturnValue().Set(New(GetArray(info.This())->row(get<1>(ri)))); - break; - case Region::Rows: - info.GetReturnValue().Set(New(GetArray(info.This())->rows(get<1>(ri), get<2>(ri)))); - break; - case Region::Col: - info.GetReturnValue().Set(New(GetArray(info.This())->col(get<1>(ri)))); - break; - case Region::Cols: - info.GetReturnValue().Set(New(GetArray(info.This())->cols(get<1>(ri), get<2>(ri)))); - break; - case Region::Slice: - info.GetReturnValue().Set(New(GetArray(info.This())->slice(get<1>(ri)))); - break; - case Region::Slices: - info.GetReturnValue().Set(New(GetArray(info.This())->slices(get<1>(ri), get<2>(ri)))); - break; - default: - info.GetReturnValue().Set(New(GetArray(info.This())->operator()(ToIndex(info[0])))); - break; - } - } - else if (info.Length() == 2) - { - info.GetReturnValue().Set(New(GetArray(info.This())->operator()(ToIndex(info[0]), ToIndex(info[1])))); - } - else if (info.Length() == 3) - { - info.GetReturnValue().Set(New(GetArray(info.This())->operator()(ToIndex(info[0]), ToIndex(info[1]), ToIndex(info[2])))); - } - else - { - info.GetReturnValue().Set(New(GetArray(info.This())->operator()(ToIndex(info[0]), ToIndex(info[1]), ToIndex(info[2]), ToIndex(info[3])))); - } - } - ARRAYFIRE_CATCH -} - -#define AFARRAY_IMPL_IDX1(F, f)\ -NAN_METHOD(ArrayWrapper::F)\ -{\ - \ - try\ - {\ - ARGS_LEN(1)\ - Guard guard;\ - auto pArray = GetArray(info.This());\ - info.GetReturnValue().Set(New(pArray->f(info[0]->Int32Value())));\ - }\ - ARRAYFIRE_CATCH\ -} - -AFARRAY_IMPL_IDX1(Row, row) -AFARRAY_IMPL_IDX1(Col, col) -AFARRAY_IMPL_IDX1(Slice, slice) -#undef AFARRAY_IMPL_IDX1 - -#define AFARRAY_IMPL_IDX2(F, f)\ -NAN_METHOD(ArrayWrapper::F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2);\ - Guard guard;\ - auto pArray = GetArray(info.This());\ - info.GetReturnValue().Set(New(pArray->f(info[0]->Int32Value(), info[1]->Int32Value())));\ - }\ - ARRAYFIRE_CATCH\ -} - -AFARRAY_IMPL_IDX2(Rows, rows) -AFARRAY_IMPL_IDX2(Cols, cols) -AFARRAY_IMPL_IDX2(Slices, slices) -#undef AFARRAY_IMPL_IDX2 - -NAN_METHOD(ArrayWrapper::As) -{ - - try - { - ARGS_LEN(1); - af::dtype type = GetDTypeInfo(info[0]->Uint32Value()).first; - Guard guard; - info.GetReturnValue().Set(New(GetArray(info.This())->as(type))); - } - ARRAYFIRE_CATCH -} - -#define AFARRAY_IMPL_ASSIGN(F, Op)\ -NAN_METHOD(ArrayWrapper::F)\ -{\ - \ - \ - try\ - {\ - auto pArray = GetArray(info.This());\ - auto& array = *pArray;\ - bool isDouble = NeedsDouble(array);\ - ARGS_LEN(1)\ - if (info.Length() == 1)\ - {\ - auto value = info[0];\ - auto pOtherArray = TryGetArray(value);\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array Op v;\ - }\ - else\ - {\ - array Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - else if (info.Length() == 2)\ - {\ - auto regIdx = ToRegionIndex(info[0]);\ - auto reg = get<0>(regIdx);\ - auto value = info[1];\ - auto pOtherArray = TryGetArray(value);\ - switch(reg)\ - {\ - case Region::None:\ - {\ - auto idx0 = ToIndex(info[0]);\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array(idx0) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array(idx0) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array(idx0) Op v;\ - }\ - else\ - {\ - array(idx0) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array(idx0) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array(idx0) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array(idx0) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - break;\ - case Region::Row:\ - {\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array.row(get<1>(regIdx)) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array.row(get<1>(regIdx)) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array.row(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - array.row(get<1>(regIdx)) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array.row(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array.row(get<1>(regIdx)) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array.row(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - break;\ - case Region::Rows:\ - {\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array.rows(get<1>(regIdx), get<2>(regIdx)) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array.rows(get<1>(regIdx), get<2>(regIdx)) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array.rows(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - array.rows(get<1>(regIdx), get<2>(regIdx)) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array.rows(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array.rows(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array.rows(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - break;\ - case Region::Col:\ - {\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array.col(get<1>(regIdx)) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array.col(get<1>(regIdx)) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array.col(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - array.col(get<1>(regIdx)) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array.col(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array.col(get<1>(regIdx)) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array.col(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - break;\ - case Region::Cols:\ - {\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array.cols(get<1>(regIdx), get<2>(regIdx)) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array.cols(get<1>(regIdx), get<2>(regIdx)) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array.cols(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - array.cols(get<1>(regIdx), get<2>(regIdx)) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array.cols(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array.cols(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array.cols(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - break;\ - case Region::Slice:\ - {\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array.slice(get<1>(regIdx)) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array.slice(get<1>(regIdx)) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array.slice(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - array.slice(get<1>(regIdx)) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array.slice(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array.slice(get<1>(regIdx)) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array.slice(get<1>(regIdx)) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - break;\ - case Region::Slices:\ - {\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array.slices(get<1>(regIdx), get<2>(regIdx)) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array.slices(get<1>(regIdx), get<2>(regIdx)) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array.slices(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - array.slices(get<1>(regIdx), get<2>(regIdx)) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array.slices(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array.slices(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array.slices(get<1>(regIdx), get<2>(regIdx)) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - break;\ - }\ - }\ - else if (info.Length() == 3)\ - {\ - auto idx0 = ToIndex(info[0]);\ - auto idx1 = ToIndex(info[1]);\ - auto value = info[2];\ - auto pOtherArray = TryGetArray(value);\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array(idx0, idx1) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array(idx0, idx1) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array(idx0, idx1) Op v;\ - }\ - else\ - {\ - array(idx0, idx1) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array(idx0, idx1) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array(idx0, idx1) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array(idx0, idx1) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - else if (info.Length() == 4)\ - {\ - auto idx0 = ToIndex(info[0]);\ - auto idx1 = ToIndex(info[1]);\ - auto idx2 = ToIndex(info[2]);\ - auto value = info[3];\ - auto pOtherArray = TryGetArray(value);\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array(idx0, idx1, idx2) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array(idx0, idx1, idx2) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array(idx0, idx1, idx2) Op v;\ - }\ - else\ - {\ - array(idx0, idx1, idx2) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array(idx0, idx1, idx2) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array(idx0, idx1, idx2) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array(idx0, idx1, idx2) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - else\ - {\ - auto idx0 = ToIndex(info[0]);\ - auto idx1 = ToIndex(info[1]);\ - auto idx2 = ToIndex(info[2]);\ - auto idx3 = ToIndex(info[3]);\ - auto value = info[4];\ - auto pOtherArray = TryGetArray(value);\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - array(idx0, idx1, idx2, idx3) Op otherArray;\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - array(idx0, idx1, idx2, idx3) Op value->Int32Value();\ - }\ - else if (isDouble)\ - {\ - array(idx0, idx1, idx2, idx3) Op v;\ - }\ - else\ - {\ - array(idx0, idx1, idx2, idx3) Op (float)v;\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - array(idx0, idx1, idx2, idx3) Op v;\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - array(idx0, idx1, idx2, idx3) Op v;\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - long long v = strtoll(*str, nullptr, 10);\ - array(idx0, idx1, idx2, idx3) Op v;\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - }\ - \ - info.GetReturnValue().Set(info.This());\ - }\ - ARRAYFIRE_CATCH\ -} - -AFARRAY_IMPL_ASSIGN(Assign, =) -AFARRAY_IMPL_ASSIGN(AddAssign, +=) -AFARRAY_IMPL_ASSIGN(SubAssign, -=) -AFARRAY_IMPL_ASSIGN(MulAssign, *=) -AFARRAY_IMPL_ASSIGN(DivAssign, /=) -#undef AFARRAY_IMPL_ASSIGN - -#define AFARRAY_IMPL_BINOP(F, Op)\ -NAN_METHOD(ArrayWrapper::F)\ -{\ - \ - \ - try\ - {\ - auto& array = *GetArray(info.This());\ - bool isDouble = NeedsDouble(array);\ - ARGS_LEN(1)\ - auto value = info[0];\ - auto pOtherArray = TryGetArray(value);\ - af::array* result = nullptr;\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - result = new af::array(array Op otherArray);\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - result = new af::array(array Op value->Int32Value());\ - }\ - else if (isDouble)\ - {\ - result = new af::array(array Op v);\ - }\ - else\ - {\ - result = new af::array(array Op (float)v);\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - result = new af::array(array Op v);\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - result = new af::array(array Op v);\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - intl v = strtoll(*str, nullptr, 10);\ - result = new af::array(array Op v);\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - \ - info.GetReturnValue().Set(New(result));\ - }\ - ARRAYFIRE_CATCH\ -} - -AFARRAY_IMPL_BINOP(Add, +) -AFARRAY_IMPL_BINOP(Sub, -) -AFARRAY_IMPL_BINOP(Mul, *) -AFARRAY_IMPL_BINOP(Div, /) -AFARRAY_IMPL_BINOP(BitShiftL, <<) -AFARRAY_IMPL_BINOP(BitShiftR, >>) - -AFARRAY_IMPL_BINOP(Lt, <) -AFARRAY_IMPL_BINOP(Gt, >) -AFARRAY_IMPL_BINOP(Le, <=) -AFARRAY_IMPL_BINOP(Ge, >=) -AFARRAY_IMPL_BINOP(Eq, ==) -AFARRAY_IMPL_BINOP(Neq, !=) -AFARRAY_IMPL_BINOP(And, &&) -AFARRAY_IMPL_BINOP(Or, ||) -AFARRAY_IMPL_BINOP(BitAnd, &) -AFARRAY_IMPL_BINOP(BitOr, |) -AFARRAY_IMPL_BINOP(BitXor, ^) -#undef AFARRAY_IMPL_BINOP - -#define AFARRAY_IMPL_BINOP(F, Op)\ -NAN_METHOD(ArrayWrapper::F)\ -{\ - \ - \ - try\ - {\ - auto& array = *GetArray(info.This());\ - bool isDouble = NeedsDouble(array);\ - ARGS_LEN(1)\ - auto value = info[0];\ - auto pOtherArray = TryGetArray(value);\ - af::array* result = nullptr;\ - Guard guard;\ - if (pOtherArray)\ - {\ - auto& otherArray = *pOtherArray;\ - result = new af::array(otherArray Op array);\ - }\ - else if (value->IsNumber())\ - {\ - double v = value->NumberValue();\ - if (floor(v) == v)\ - {\ - result = new af::array(value->Int32Value() Op array);\ - }\ - else if (isDouble)\ - {\ - result = new af::array(v Op array);\ - }\ - else\ - {\ - result = new af::array((float)v Op array);\ - }\ - }\ - else if (value->IsObject())\ - {\ - if (isDouble)\ - {\ - auto v = ToDComplex(value);\ - result = new af::array(v Op array);\ - }\ - else\ - {\ - auto v = ToFComplex(value);\ - result = new af::array(v Op array);\ - }\ - }\ - else if (value->IsString())\ - {\ - String::Utf8Value str(value);\ - intl v = strtoll(*str, nullptr, 10);\ - result = new af::array(v Op array);\ - }\ - else\ - {\ - return NAN_THROW_INVALID_ARGS();\ - }\ - \ - info.GetReturnValue().Set(New(result));\ - }\ - ARRAYFIRE_CATCH\ -} - -AFARRAY_IMPL_BINOP(RhsAdd, +) -AFARRAY_IMPL_BINOP(RhsSub, -) -AFARRAY_IMPL_BINOP(RhsMul, *) -AFARRAY_IMPL_BINOP(RhsDiv, /) -AFARRAY_IMPL_BINOP(RhsBitShiftL, <<) -AFARRAY_IMPL_BINOP(RhsBitShiftR, >>) - -AFARRAY_IMPL_BINOP(RhsLt, <) -AFARRAY_IMPL_BINOP(RhsGt, >) -AFARRAY_IMPL_BINOP(RhsLe, <=) -AFARRAY_IMPL_BINOP(RhsGe, >=) -AFARRAY_IMPL_BINOP(RhsEq, ==) -AFARRAY_IMPL_BINOP(RhsNeq, !=) -AFARRAY_IMPL_BINOP(RhsAnd, &&) -AFARRAY_IMPL_BINOP(RhsOr, ||) -AFARRAY_IMPL_BINOP(RhsBitAnd, &) -AFARRAY_IMPL_BINOP(RhsBitOr, |) -AFARRAY_IMPL_BINOP(RhsBitXor, ^) -#undef AFARRAY_IMPL_BINOP - -#define AFARRAY_IMPL_UNOP(F, Op)\ -NAN_METHOD(ArrayWrapper::F)\ -{\ - \ - \ - try\ - {\ - auto& array = *GetArray(info.This());\ - Guard guard;\ - info.GetReturnValue().Set(New(array.operator Op()));\ - }\ - ARRAYFIRE_CATCH\ -} - -AFARRAY_IMPL_UNOP(Neg, -) -AFARRAY_IMPL_UNOP(Not, !) -#undef AFARRAY_IMPL_UNOP - -NAN_METHOD(ArrayWrapper::AFT) -{ - try - { - Guard guard; - info.GetReturnValue().Set(New(GetArray(info.This())->T())); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(ArrayWrapper::AFH) -{ - try - { - Guard guard; - info.GetReturnValue().Set(New(GetArray(info.This())->H())); - } - ARRAYFIRE_CATCH -} \ No newline at end of file diff --git a/src/arraywrapper.h b/src/arraywrapper.h deleted file mode 100644 index 1eabf6a..0000000 --- a/src/arraywrapper.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAY_ARRAYFIRE_JS_ARRAYWRAPPER_H -#define ARRAY_ARRAYFIRE_JS_ARRAYWRAPPER_H - -#include -#include -#include - -struct ArrayWrapper : public node::ObjectWrap -{ - ArrayWrapper(const ArrayWrapper&) = delete; - void Free(); - ~ArrayWrapper(); - - static NAN_MODULE_INIT(Init); - - static v8::Local New(af::array* array); - static v8::Local New(const af::array& array); - - static void NewAsync(const Nan::FunctionCallbackInfo& info, const std::function& arrayFactory); - - static af::array* GetArray(v8::Local value); - static af::array* TryGetArray(v8::Local value); - static af::array* GetArray(v8::Local value); - static af::array* TryGetArray(v8::Local value); - static af::array* GetArrayAt(const Nan::FunctionCallbackInfo& info, int index); - static af::array* TryGetArrayAt(const Nan::FunctionCallbackInfo& info, int index); - - static void RegisterInTmp(v8::Local instance); - - static NAN_METHOD(V8Free); - static NAN_METHOD(Create); - static NAN_METHOD(Elements); - static NAN_METHOD(Host); - static NAN_METHOD(Scalar); - static NAN_METHOD(Write); - static NAN_METHOD(Type); - static NAN_METHOD(Dims); - static NAN_METHOD(NumDims); - static NAN_METHOD(Bytes); - static NAN_METHOD(Copy); - static NAN_METHOD(IsEmpty); - static NAN_METHOD(IsScalar); - static NAN_METHOD(IsVector); - static NAN_METHOD(IsRow); - static NAN_METHOD(IsColumn); - static NAN_METHOD(IsComplex); - static NAN_METHOD(IsReal); - static NAN_METHOD(IsDouble); - static NAN_METHOD(IsSingle); - static NAN_METHOD(IsRealFloating); - static NAN_METHOD(IsFloating); - static NAN_METHOD(IsInteger); - static NAN_METHOD(IsBool); - static NAN_METHOD(Eval); - static NAN_METHOD(At); - static NAN_METHOD(Row); - static NAN_METHOD(Col); - static NAN_METHOD(Slice); - static NAN_METHOD(Rows); - static NAN_METHOD(Cols); - static NAN_METHOD(Slices); - static NAN_METHOD(As); - - static NAN_METHOD(Assign); - static NAN_METHOD(AddAssign); - static NAN_METHOD(SubAssign); - static NAN_METHOD(MulAssign); - static NAN_METHOD(DivAssign); - - static NAN_METHOD(Div); - static NAN_METHOD(Mul); - static NAN_METHOD(Sub); - static NAN_METHOD(Add); - static NAN_METHOD(BitShiftL); - static NAN_METHOD(BitShiftR); - static NAN_METHOD(Lt); - static NAN_METHOD(Gt); - static NAN_METHOD(Le); - static NAN_METHOD(Ge); - static NAN_METHOD(Eq); - static NAN_METHOD(Neq); - static NAN_METHOD(And); - static NAN_METHOD(Or); - static NAN_METHOD(BitAnd); - static NAN_METHOD(BitOr); - static NAN_METHOD(BitXor); - - static NAN_METHOD(RhsDiv); - static NAN_METHOD(RhsMul); - static NAN_METHOD(RhsSub); - static NAN_METHOD(RhsAdd); - static NAN_METHOD(RhsBitShiftL); - static NAN_METHOD(RhsBitShiftR); - static NAN_METHOD(RhsLt); - static NAN_METHOD(RhsGt); - static NAN_METHOD(RhsLe); - static NAN_METHOD(RhsGe); - static NAN_METHOD(RhsEq); - static NAN_METHOD(RhsNeq); - static NAN_METHOD(RhsAnd); - static NAN_METHOD(RhsOr); - static NAN_METHOD(RhsBitAnd); - static NAN_METHOD(RhsBitOr); - static NAN_METHOD(RhsBitXor); - - static NAN_METHOD(Not); - static NAN_METHOD(Neg); - - static NAN_METHOD(AFT); - static NAN_METHOD(AFH); - -private: - explicit ArrayWrapper(af::array* array); - - template - static af::array* CreateArray(void* ptr, af_source src, const af::dim4& dim4); - static void New(const Nan::FunctionCallbackInfo& info); - - static Nan::Persistent constructor; - - af::array* _array; -}; - -#endif // ARRAY_ARRAYFIRE_JS_ARRAYWRAPPER_H diff --git a/src/computervision.cpp b/src/computervision.cpp deleted file mode 100644 index 7a79fa2..0000000 --- a/src/computervision.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "computervision.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" - -using namespace v8; -using namespace std; -using namespace node; - -NAN_METHOD(Orb) -{ - - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - float fastThr=20.f; - unsigned maxFeat=400; - float sclFctr=1.5f; - unsigned levels=4; - bool blurImg=false; - if (info.Length() > 1) - { - fastThr = info[1]->NumberValue(); - } - if (info.Length() > 2) - { - maxFeat = info[2]->Uint32Value(); - } - if (info.Length() > 3) - { - sclFctr = info[3]->NumberValue(); - } - if (info.Length() > 4) - { - levels = info[4]->Uint32Value(); - } - if (info.Length() > 5) - { - blurImg = info[5]->BooleanValue(); - } - Guard guard; - af::features rf; - af::array ra; - af::orb(rf, ra, *pArray, fastThr, maxFeat, sclFctr, levels, blurImg); - auto result = Nan::New(); - result->Set(Nan::New(Symbols::Feat), ToV8Features(rf)); - result->Set(Nan::New(Symbols::Desc), ArrayWrapper::New(ra)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Fast) -{ - - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - float thr=20.0f; - unsigned arcLength=9; - bool nonMax=true; - float featureRatio=0.05f; - unsigned edge=3; - if (info.Length() > 1) - { - thr = info[1]->NumberValue(); - } - if (info.Length() > 2) - { - arcLength = info[2]->Uint32Value(); - } - if (info.Length() > 3) - { - nonMax = info[3]->BooleanValue(); - } - if (info.Length() > 4) - { - featureRatio = info[4]->NumberValue(); - } - if (info.Length() > 5) - { - edge = info[5]->Uint32Value(); - } - Guard guard; - af::features rf; - af::fast(*pArray, thr, arcLength, nonMax, featureRatio, edge); - info.GetReturnValue().Set(ToV8Features(rf)); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(HammingMatcher) -{ - - try - { - ARGS_LEN(2); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - dim_t distDim = 0; - unsigned nDist = 1; - if (info.Length() > 2) - { - distDim = (dim_t)(info[2]->Uint32Value()); - } - if (info.Length() > 3) - { - nDist = info[3]->Uint32Value(); - } - Guard guard; - std::pair r; - af::hammingMatcher(r.first, r.second, *pArray1, *pArray2, distDim, nDist); - auto result = Nan::New(); - result->Set(Nan::New(Symbols::Idx), ArrayWrapper::New(r.first)); - result->Set(Nan::New(Symbols::Dist), ArrayWrapper::New(r.second)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(MatchTemplate) -{ - - try - { - ARGS_LEN(2); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - af::matchType mType = AF_SAD; - if (info.Length() > 2) - { - mType = (af::matchType)(info[2]->Uint32Value()); - } - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::matchTemplate(*pArray1, *pArray2, mType))); - } - ARRAYFIRE_CATCH -} - -NAN_MODULE_INIT(InitComputerVision) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("orb").ToLocalChecked(), Nan::New(Orb)->GetFunction()); - Nan::Set(target, Nan::New("fast").ToLocalChecked(), Nan::New(Fast)->GetFunction()); - Nan::Set(target, Nan::New("hammingMatcher").ToLocalChecked(), Nan::New(HammingMatcher)->GetFunction()); - Nan::Set(target, Nan::New("matchTemplate").ToLocalChecked(), Nan::New(MatchTemplate)->GetFunction()); -} diff --git a/src/computervision.h b/src/computervision.h deleted file mode 100644 index 2f3f83f..0000000 --- a/src/computervision.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_COMPUTERVISION_H -#define ARRAYFIRE_COMPUTERVISION_H - -#include - -NAN_MODULE_INIT(InitComputerVision); - -#endif // ARRAYFIRE_COMPUTERVISION_H - diff --git a/src/createarray.cpp b/src/createarray.cpp deleted file mode 100644 index 240740f..0000000 --- a/src/createarray.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "createarray.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" - -using namespace v8; -using namespace std; -using namespace node; - -NAN_METHOD(RandU) -{ - - - try - { - ARGS_LEN(2); - auto dimAndType = ParseDimAndTypeArgs(info); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::randu(dimAndType.first, dimAndType.second))); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(RandN) -{ - - - try - { - ARGS_LEN(2); - auto dimAndType = ParseDimAndTypeArgs(info); - if (dimAndType.second == f32 || dimAndType.second == f64) - { - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::randn(dimAndType.first, dimAndType.second))); - return; - } - return NAN_THROW_INVALID_DTYPE(); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Identity) -{ - - - try - { - ARGS_LEN(2); - auto dimAndType = ParseDimAndTypeArgs(info); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::identity(dimAndType.first, dimAndType.second))); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Range) -{ - - - try - { - ARGS_LEN(3); - auto dimAndType = ParseDimAndTypeArgs(info, -1, 1); - af_dtype seqDim = (af_dtype)info[info.Length() - 2]->Uint32Value(); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::range(dimAndType.first, seqDim, dimAndType.second))); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Iota) -{ - - - try - { - ARGS_LEN(3); - auto dims = ToDim4(info[0]); - auto titleDims = ToDim4(info[1]); - auto type = GetDTypeInfo(info[3]->Uint32Value()); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::iota(dims, titleDims, type.first))); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Diag) -{ - - - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - int num = 0; - bool extract = true; - if (info.Length() > 1) - { - num = info[1]->Int32Value(); - } - if (info.Length() > 2) - { - extract = info[2]->BooleanValue(); - } - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::diag(*pArray, num, extract))); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Constant) -{ - - - // Notice: In v8 we can go for double, complex, and int64 as a string, because v8 numbers are doubles. - - try - { - ARGS_LEN(3); - auto dimAndType = ParseDimAndTypeArgs(info, -1, 0, 1); - auto value = info[0]; - Guard guard; - if (value->IsNumber()) - { - double v = value->NumberValue(); - switch (dimAndType.second) - { - case f32: - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(v, dimAndType.first, dimAndType.second))); - return; - case f64: - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(v, dimAndType.first, dimAndType.second))); - return; - case s32: - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(v, dimAndType.first, dimAndType.second))); - return; - case u32: - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(v, dimAndType.first, dimAndType.second))); - return; - case u8: - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(v, dimAndType.first, dimAndType.second))); - return; - case b8: - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(v, dimAndType.first, dimAndType.second))); - return; - default: - break; - } - } - else if (value->IsObject()) - { - switch (dimAndType.second) - { - case c32: - { - auto cv = ToFComplex(value.As()); - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(cv, dimAndType.first, dimAndType.second))); - return; - } - case c64: - { - auto cv = ToDComplex(value.As()); - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(cv, dimAndType.first, dimAndType.second))); - return; - } - default: - break; - } - } - else if (value->IsString()) - { - String::Utf8Value str(value); - switch (dimAndType.second) - { - case s64: - { - long long val = strtoll(*str, nullptr, 10); - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(val, dimAndType.first, dimAndType.second))); - return; - } - case u64: - { - unsigned long long val = strtoll(*str, nullptr, 10); - info.GetReturnValue().Set(ArrayWrapper::New(af::constant(val, dimAndType.first, dimAndType.second))); - return; - } - default: - break; - } - } - else - { - ARRAYFIRE_THROW("Argument at position 0 is not a constant."); - } - ARRAYFIRE_THROW("Type is unknown."); - } - ARRAYFIRE_CATCH -} - -AF_ARR_BOOL(Lower, lower, false) -AF_ARR_BOOL(Upper, upper, false) - -NAN_METHOD(GetSeed) -{ - - try - { - info.GetReturnValue().Set(Nan::New(to_string(af::getSeed()).c_str()).ToLocalChecked()); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(SetSeed) -{ - - try - { - ARGS_LEN(1); - if (info[0]->IsNumber()) - { - long long seed = info[0]->NumberValue(); - af::setSeed(seed); - } - else if (info[0]->IsString()) - { - String::Utf8Value str(info[0]); - long long seed = strtoll(*str, nullptr, 10); - af::setSeed(seed); - } - else - { - return NAN_THROW_INVALID_ARGS(); - } - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH; -} - -AF_ARR_ARR_DIM(Lookup, lookup) - -NAN_MODULE_INIT(InitCreateArray) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("randu").ToLocalChecked(), Nan::New(RandU)->GetFunction()); - Nan::Set(target, Nan::New("randU").ToLocalChecked(), Nan::New(RandU)->GetFunction()); - Nan::Set(target, Nan::New("randn").ToLocalChecked(), Nan::New(RandN)->GetFunction()); - Nan::Set(target, Nan::New("randN").ToLocalChecked(), Nan::New(RandN)->GetFunction()); - Nan::Set(target, Nan::New("identity").ToLocalChecked(), Nan::New(Identity)->GetFunction()); - Nan::Set(target, Nan::New("range").ToLocalChecked(), Nan::New(Range)->GetFunction()); - Nan::Set(target, Nan::New("iota").ToLocalChecked(), Nan::New(Iota)->GetFunction()); - Nan::Set(target, Nan::New("diag").ToLocalChecked(), Nan::New(Diag)->GetFunction()); - Nan::Set(target, Nan::New("constant").ToLocalChecked(), Nan::New(Constant)->GetFunction()); - Nan::Set(target, Nan::New("lower").ToLocalChecked(), Nan::New(Lower)->GetFunction()); - Nan::Set(target, Nan::New("upper").ToLocalChecked(), Nan::New(Upper)->GetFunction()); - Nan::Set(target, Nan::New("getSeed").ToLocalChecked(), Nan::New(GetSeed)->GetFunction()); - Nan::Set(target, Nan::New("setSeed").ToLocalChecked(), Nan::New(SetSeed)->GetFunction()); - Nan::Set(target, Nan::New("lookup").ToLocalChecked(), Nan::New(Lookup)->GetFunction()); -} diff --git a/src/createarray.h b/src/createarray.h deleted file mode 100644 index 6551032..0000000 --- a/src/createarray.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_JS_CREATEARRAY -#define ARRAYFIRE_JS_CREATEARRAY - -#include - -NAN_MODULE_INIT(InitCreateArray); - -#endif // ARRAYFIRE_JS_CREATEARRAY - diff --git a/src/device.cpp b/src/device.cpp deleted file mode 100644 index 57d6aa6..0000000 --- a/src/device.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "device.h" -#include "guard.h" -#include "worker.h" -#include "helpers.h" -#include "errors.h" -#include "symbols.h" - -using namespace v8; -using namespace std; -using namespace node; - - -NAN_METHOD(GetDeviceCount) -{ - - try - { - Guard guard; -#ifdef CPU - info.GetReturnValue().Set(Nan::New(1)); -#else - info.GetReturnValue().Set(Nan::New(af::getDeviceCount())); -#endif - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(GetDevice) -{ - try - { - Guard guard; - - -#ifdef CPU - info.GetReturnValue().Set(Nan::New(0)); -#else - info.GetReturnValue().Set(Nan::New(af::getDevice())); -#endif - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(SetDevice) -{ - - - try - { - Guard guard; - -#ifndef CPU - af::setDevice(info[0]->Uint32Value()); -#endif - - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(DeviceInfo) -{ - - - try - { - Guard guard; - - bool IsDoubleAvailable = af::isDoubleAvailable(af::getDevice()); - auto infoObj = Nan::New(); - -#ifdef CPU - infoObj->Set(Nan::New(Symbols::Name), Nan::New(Symbols::Cpu)); - infoObj->Set(Nan::New(Symbols::Platform), Nan::New(Symbols::Cpu)); - infoObj->Set(Nan::New(Symbols::Toolkit), Nan::New(Symbols::Cpu)); - infoObj->Set(Nan::New(Symbols::Compute), Nan::New(Symbols::Cpu)); - infoObj->Set(Nan::New(Symbols::IsDoubleAvailable), Nan::New(IsDoubleAvailable)); -#else - char name[256], platform[256], toolkit[256], compute[256]; - af::deviceInfo(name, platform, toolkit, compute); - infoObj->Set(Nan::New(Symbols::Name), Nan::New(name).ToLocalChecked()); - infoObj->Set(Nan::New(Symbols::Platform), Nan::New(platform).ToLocalChecked()); - infoObj->Set(Nan::New(Symbols::Toolkit), Nan::New(toolkit).ToLocalChecked()); - infoObj->Set(Nan::New(Symbols::Compute), Nan::New(compute).ToLocalChecked()); - infoObj->Set(Nan::New(Symbols::IsDoubleAvailable), Nan::New(IsDoubleAvailable)); -#endif - - info.GetReturnValue().Set(infoObj); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(IsDoubleAvailable) -{ - - - try - { - Guard guard; - - info.GetReturnValue().Set(Nan::New(af::isDoubleAvailable(info[0]->Uint32Value()))); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Sync) -{ - - - try - { - int device = -1; - Nan::Callback *callback = nullptr; - - if (info.Length() > 0) - { - int idx = 0; - if (info[idx]->IsNumber()) - { - device = info[idx++]->Int32Value(); -#ifdef CPU - if (device > 1 || device < -1) - { - return Nan::ThrowRangeError("Device is out of range."); - } -#else - if (device >= af::getDeviceCount() || device < -1) - { - return Nan::ThrowRangeError("Device is out of range."); - } -#endif - } - if (idx < info.Length() && info[idx]->IsFunction()) - { - callback = new Nan::Callback(info[idx].As()); - } - } - - auto exec = [=]() - { - Guard guard; - af::sync(device); - }; - - Nan::AsyncQueueWorker(new Worker(callback, move(exec))); - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH -} - -pair getAllocPars(unsigned elements, unsigned udtype) -{ - auto dtypeInfo = GetDTypeInfo(udtype); - unsigned sizeOf = dtypeInfo.second; - af::dtype dtype = dtypeInfo.first; - unsigned size = sizeOf * elements; - return move(make_pair(dtype, size)); -} - -NAN_METHOD(Alloc) -{ - - - try - { - unsigned elements = info[0]->Uint32Value(); - unsigned udtype = info[1]->Uint32Value(); - auto allocPars = getAllocPars(elements, udtype); - - Guard guard; - char* ptr = (char*)af::alloc(elements, allocPars.first); - auto gcCallback = [](char* data, void* hint) - { - Guard guard; - af::free(data); - Nan::AdjustExternalMemory(static_cast(reinterpret_cast(hint))); - }; - size_t size = elements + 100; - Nan::AdjustExternalMemory(static_cast(size)); - info.GetReturnValue().Set(Nan::NewBuffer(ptr, 0, gcCallback, reinterpret_cast(size)).ToLocalChecked()); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Pinned) -{ - - - try - { - unsigned elements = info[0]->Uint32Value(); - unsigned udtype = info[1]->Uint32Value(); - auto allocPars = getAllocPars(elements, udtype); - - Guard guard; - char* ptr = (char*)af::pinned(elements, allocPars.first); - auto gcCallback = [](char* data, void* hint) - { - Guard guard; - af::freePinned(data); - Nan::AdjustExternalMemory(static_cast(reinterpret_cast(hint))); - }; - size_t size = elements + 100; - Nan::AdjustExternalMemory(static_cast(size)); - info.GetReturnValue().Set(Nan::NewBuffer(ptr, allocPars.second, gcCallback, reinterpret_cast(size)).ToLocalChecked()); - } - ARRAYFIRE_CATCH -} - -NAN_MODULE_INIT(InitDevice) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("getDeviceCount").ToLocalChecked(), Nan::New(GetDeviceCount)->GetFunction()); - Nan::Set(target, Nan::New("getDevice").ToLocalChecked(), Nan::New(GetDevice)->GetFunction()); - Nan::Set(target, Nan::New("setDevice").ToLocalChecked(), Nan::New(SetDevice)->GetFunction()); - Nan::Set(target, Nan::New("deviceInfo").ToLocalChecked(), Nan::New(DeviceInfo)->GetFunction()); - Nan::Set(target, Nan::New("isDoubleAvailable").ToLocalChecked(), Nan::New(IsDoubleAvailable)->GetFunction()); - Nan::Set(target, Nan::New("sync").ToLocalChecked(), Nan::New(Sync)->GetFunction()); - Nan::Set(target, Nan::New("wait").ToLocalChecked(), Nan::New(Sync)->GetFunction()); - Nan::Set(target, Nan::New("alloc").ToLocalChecked(), Nan::New(Alloc)->GetFunction()); - Nan::Set(target, Nan::New("pinned").ToLocalChecked(), Nan::New(Pinned)->GetFunction()); -} diff --git a/src/device.h b/src/device.h deleted file mode 100644 index c4e9236..0000000 --- a/src/device.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAY_ARRAYFIRE_JS_DEVICE_H -#define ARRAY_ARRAYFIRE_JS_DEVICE_H - -#include - -NAN_MODULE_INIT(InitDevice); - -#endif diff --git a/src/errors.h b/src/errors.h deleted file mode 100644 index eaa158d..0000000 --- a/src/errors.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_ERRORS_H -#define ARRAYFIRE_ERRORS_H - -#include -#include -#include - -struct fire_error : public std::runtime_error -{ - fire_error(const char* what): runtime_error(what) {} -}; - -inline void _NanThrow(const char* what, const char* file, int line) -{ - using namespace std; - stringstream s; - s << what << " in '" << file << "' at " << line << "."; - Nan::ThrowError(s.str().c_str()); -} - -#define NAN_THROW(what) _NanThrow(what, __FILE__, __LINE__) - -#define NAN_THROW_INVALID_ARGS() NAN_THROW("Invalid arguments.") -#define NAN_THROW_INVALID_NO_OF_ARGS() NAN_THROW("Invalid number of arguments.") -#define NAN_THROW_CB_EXPECTED() NAN_THROW("Callback argument expected.") -#define NAN_THROW_INVALID_DTYPE() NAN_THROW("Invalid dtype argument!") - -#define ARRAYFIRE_THROW(what) \ -{\ - std::stringstream s;\ - s << what << " in '" << __FILE__ << "' at " << __LINE__ << ".";\ - throw fire_error(s.str().c_str());\ -} - -#define ARRAYFIRE_THROW_ARG_IS_NOT_AN_OBJ() ARRAYFIRE_THROW("Argument is not an object."); -#define ARRAYFIRE_THROW_ARG_IS_NOT_A_DIM4() ARRAYFIRE_THROW("Argument is not a Dim4 object."); -#define ARRAYFIRE_THROW_ARG_IS_NOT_A_CPLX() ARRAYFIRE_THROW("Argument is not a Complex object."); -#define ARRAYFIRE_THROW_ARG_IS_NOT_A_SEQ() ARRAYFIRE_THROW("Argument is not a Seq object."); -#define ARRAYFIRE_THROW_ARG_IS_NOT_AN_INDEX() ARRAYFIRE_THROW("Argument is not an Index."); -#define ARRAYFIRE_THROW_CB_EXPECTED() ARRAYFIRE_THROW("Callback argument expected."); - -#define ARRAYFIRE_CATCH \ - catch(fire_error &ex) { return Nan::ThrowError(ex.what()); } \ - catch(af::exception &ex) { return NAN_THROW(ex.what()); } \ - catch(std::exception &ex) { return NAN_THROW(ex.what()); } \ - catch(...) { return NAN_THROW("Unknown error!"); } - -#endif // ARRAYFIRE_ERRORS_H - diff --git a/src/ext.h b/src/ext.h deleted file mode 100644 index 7bb8b81..0000000 --- a/src/ext.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAY_ARRAYFIRE_JS_EXT_H -#define ARRAY_ARRAYFIRE_JS_EXT_H - -#ifdef WIN32 -#define _WINSOCKAPI_ -#define NOMINMAX -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/src/fire.cpp b/src/fire.cpp deleted file mode 100644 index a16a53d..0000000 --- a/src/fire.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "fire.h" -#include "device.h" -#include "arraywrapper.h" -#include "createarray.h" -#include "moveandreorderarray.h" -#include "arrayhelperfunctions.h" -#include "mathfunctions.h" -#include "vectoralgorithms.h" -#include "statistics.h" -#include "symbols.h" -#include "computervision.h" -#include "imageprocessing.h" -#include "linearalgebra.h" -#include "signalprocessing.h" -#include "errors.h" - -using namespace v8; -using namespace std; - -NAN_METHOD(_DoEvents) -{ - - uv_run(uv_default_loop(), UV_RUN_ONCE); - info.GetReturnValue().SetUndefined(); -} - -NAN_METHOD(_GforToggle) -{ - - af::gforToggle(); - info.GetReturnValue().SetUndefined(); -} - -NAN_METHOD(GC) -{ - - unsigned ms = info.Length() ? info[0]->Uint32Value() : 1000; - Nan::IdleNotification(ms); - try - { - af::sync(); - } - ARRAYFIRE_CATCH - info.GetReturnValue().SetUndefined(); -} - -NAN_MODULE_INIT(Init) -{ - Nan::HandleScope scope; - - Symbols::Init(); - InitDevice(target); - ArrayWrapper::Init(target); - InitCreateArray(target); - InitMoveAndReorderArray(target); - InitArrayHelperFunctions(target); - InitMathFunctions(target); - InitVectorAlgorithms(target); - InitStatistics(target); - InitComputerVision(target); - InitImageProcessing(target); - InitLinearAlgebra(target); - InitSignalProcessing(target); - - // Helpers: - Nan::Set(target, Nan::New("_doEvents").ToLocalChecked(), - Nan::New(_DoEvents)->GetFunction()); - - Nan::Set(target, Nan::New("_gforToggle").ToLocalChecked(), - Nan::New(_GforToggle)->GetFunction()); - - Nan::Set(target, Nan::New("gc").ToLocalChecked(), - Nan::New(::GC)->GetFunction()); -} diff --git a/src/fire.h b/src/fire.h deleted file mode 100644 index c60754a..0000000 --- a/src/fire.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAY_ARRAYFIRE_JS_INIT_H -#define ARRAY_ARRAYFIRE_JS_INIT_H - -#include - -NAN_MODULE_INIT(Init); - -#endif diff --git a/src/guard.cpp b/src/guard.cpp deleted file mode 100644 index a9daa89..0000000 --- a/src/guard.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "guard.h" - -uv_mutex_t Guard::lock; - -bool Guard::isInitialized(Guard::Initialize()); - -Guard::Guard() -{ - uv_mutex_lock(&Guard::lock); -} - -Guard::~Guard() -{ - uv_mutex_unlock(&Guard::lock); -} - -bool Guard::Initialize() -{ - uv_mutex_init(&Guard::lock); - return true; -} diff --git a/src/guard.h b/src/guard.h deleted file mode 100644 index 18b4ba3..0000000 --- a/src/guard.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_JS_GUARD_H -#define ARRAYFIRE_JS_GUARD_H - -#include - -struct Guard -{ - Guard(); - Guard(const Guard&) = delete; - Guard(Guard&&) = delete; - ~Guard(); -private: - static uv_mutex_t lock; - static bool isInitialized; - static bool Initialize(); -}; - -#endif // ARRAYFIRE_JS_GUARD_H diff --git a/src/helpers.cpp b/src/helpers.cpp deleted file mode 100644 index c95697a..0000000 --- a/src/helpers.cpp +++ /dev/null @@ -1,416 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "helpers.h" -#include "errors.h" -#include "arraywrapper.h" -#include "symbols.h" - -using namespace std; -using namespace v8; -using namespace node; - -pair GetDTypeInfo(unsigned udtype) -{ - unsigned sizeOf; - af::dtype dtype; - switch (udtype) - { - case 0: - dtype = f32; - sizeOf = 32 / 8; - break; - case 1: - dtype = c32; - sizeOf = 32 / 8; - break; - case 2: - dtype = f64; - sizeOf = 64 / 8; - break; - case 3: - dtype = c64; - sizeOf = 64 / 8; - break; - case 4: - dtype = b8; - sizeOf = 8 / 8; - break; - case 5: - dtype = s32; - sizeOf = 32 / 8; - break; - case 6: - dtype = u32; - sizeOf = 32 / 8; - break; - case 7: - dtype = u8; - sizeOf = 8 / 8; - break; - case 8: - dtype = s64; - sizeOf = 64 / 8; - break; - case 9: - dtype = u64; - sizeOf = 64 / 8; - break; - default: - ARRAYFIRE_THROW("DType is out of range."); - } - return move(make_pair(dtype, sizeOf)); -} - -std::pair GetDTypeInfo(v8::Local value) -{ - if (value->IsNumber()) - { - return GetDTypeInfo(value->Uint32Value()); - } - ARRAYFIRE_THROW("Value is not a number."); -} - -string ErrToString(af_err err) -{ - switch (err) - { - case AF_ERR_INTERNAL: - return "Internal error (AF_ERR_INTERNAL)."; - break; - case AF_ERR_NO_MEM: - return "Not enough memory error (AF_ERR_NO_MEM)."; - break; - case AF_ERR_DRIVER: - return "Driver error (AF_ERR_DRIVER)."; - break; - case AF_ERR_RUNTIME: - return "Runtime error (AF_ERR_RUNTIME)."; - break; - case AF_ERR_INVALID_ARRAY: - return "Invalid array error (AF_ERR_INVALID_ARRAY)."; - break; - case AF_ERR_ARG: - return "Argument error (AF_ERR_ARG)."; - break; - case AF_ERR_SIZE: - return "Size error (AF_ERR_SIZE)."; - break; - case AF_ERR_DIFF_TYPE: - return "Diff type error (AF_ERR_DIFF_TYPE)."; - break; - case AF_ERR_NOT_SUPPORTED: - return "Operation is not supported (AF_ERR_NOT_SUPPORTED)."; - break; - case AF_ERR_NOT_CONFIGURED: - return "Not configured error (AF_ERR_NOT_CONFIGURED)."; - break; - default: - return "Uknown ArrayFire error (AF_ERR_UNKNOWN)."; - }; -} - -v8::Local WrapPointer(void* ptr) -{ - Nan::EscapableHandleScope scope; - return scope.Escape(Nan::NewBuffer((char*)ptr, 0, [](char*v1, void*v2) {}, nullptr).ToLocalChecked()); -} - -af::dim4 ToDim4(v8::Local obj) -{ - Local dims; - if (obj->IsArray()) - { - dims = obj.As(); - } - else - { - auto member = obj->Get(Nan::New(Symbols::Values)); - if (member->IsArray()) - { - dims = member.As(); - } - else - { - ARRAYFIRE_THROW_ARG_IS_NOT_A_DIM4(); - } - } - int dim0 = 1; - int dim1 = 1; - int dim2 = 1; - int dim3 = 1; - if (dims->Length() > 0) - { - dim0 = dims->Get(0)->Uint32Value(); - } - if (dims->Length() > 1) - { - dim1 = dims->Get(1)->Uint32Value(); - } - if (dims->Length() > 2) - { - dim2 = dims->Get(2)->Uint32Value(); - } - if (dims->Length() > 3) - { - dim3 = dims->Get(3)->Uint32Value(); - } - return move(af::dim4(dim0, dim1, dim2, dim3)); -} - -af::dim4 ToDim4(v8::Local value) -{ - if (value->IsObject()) - { - return ToDim4(value.As()); - } - ARRAYFIRE_THROW_ARG_IS_NOT_AN_OBJ(); -} - -af::seq ToSeq(v8::Local obj) -{ - auto begin = obj->Get(Nan::New(Symbols::Begin)); - auto end = obj->Get(Nan::New(Symbols::End)); - auto step = obj->Get(Nan::New(Symbols::Step)); - auto isGFor = obj->Get(Nan::New(Symbols::IsGFor)); - if (begin->IsNumber() && end->IsNumber()) - { - double stepValue = 1; - if (step->IsNumber()) - { - stepValue = step->NumberValue(); - } - bool isGForValue = false; - if (isGFor->IsBoolean()) - { - isGForValue = isGFor->BooleanValue(); - } - if (isGForValue) - { - return move(af::seq(af::seq(begin->NumberValue(), end->NumberValue(), stepValue), isGForValue)); - } - return move(af::seq(begin->NumberValue(), end->NumberValue(), stepValue)); - } - ARRAYFIRE_THROW_ARG_IS_NOT_A_SEQ(); -} - -af::seq ToSeq(v8::Local value) -{ - if (value->IsObject()) - { - return ToSeq(value.As()); - } - ARRAYFIRE_THROW_ARG_IS_NOT_AN_OBJ(); -} - -af::index ToIndex(v8::Local value) -{ - if (value->IsNull()) - { - return af::span; - } - if (value->IsNumber()) - { - return af::index(value->Int32Value()); - } - if (value->IsString()) - { - String::Utf8Value str(value); - if (strcmp(*str, "span") == 0) - { - return af::span; - } - else if (strcmp(*str, "end") == 0) - { - return af::end; - } - } - if (value->IsObject()) - { - auto pArray = ArrayWrapper::TryGetArray(value); - if (pArray) - { - return af::index(*pArray); - } - return ToSeq(value.As()); - } - ARRAYFIRE_THROW_ARG_IS_NOT_AN_INDEX(); -} - -af::af_cdouble ToDComplex(v8::Local obj) -{ - auto imag = obj->Get(Nan::New(Symbols::Imag)); - auto real = obj->Get(Nan::New(Symbols::Real)); - if (imag->IsNumber() && real->IsNumber()) - { - return { real->NumberValue(), imag->NumberValue() }; - } - ARRAYFIRE_THROW_ARG_IS_NOT_A_CPLX(); -} - -af::af_cdouble ToDComplex(v8::Local value) -{ - if (value->IsObject()) - { - return ToDComplex(value.As()); - } - ARRAYFIRE_THROW_ARG_IS_NOT_AN_OBJ(); -} - -af::af_cfloat ToFComplex(v8::Local obj) -{ - auto imag = obj->Get(Nan::New(Symbols::Imag)); - auto real = obj->Get(Nan::New(Symbols::Real)); - if (imag->IsNumber() && real->IsNumber()) - { - return { (float)real->NumberValue(), (float)imag->NumberValue() }; - } - ARRAYFIRE_THROW_ARG_IS_NOT_A_CPLX(); -} - -af::af_cfloat ToFComplex(v8::Local value) -{ - if (value->IsObject()) - { - return ToFComplex(value.As()); - } - ARRAYFIRE_THROW_ARG_IS_NOT_AN_OBJ(); -} - -v8::Local ToV8Complex(const af::af_cdouble& value) -{ - auto obj = Nan::New(); - obj->Set(Nan::New(Symbols::Imag), Nan::New(value.imag)); - obj->Set(Nan::New(Symbols::Real), Nan::New(value.real)); - return obj; -} - -v8::Local ToV8Complex(const af::af_cfloat& value) -{ - auto obj = Nan::New(); - obj->Set(Nan::New(Symbols::Imag), Nan::New(value.imag)); - obj->Set(Nan::New(Symbols::Real), Nan::New(value.real)); - return obj; -} - -std::pair ParseDimAndTypeArgs(const Nan::FunctionCallbackInfo& info, int assumedArgsLength, int argsFollowingDims, int dimsStartAt) -{ - if (assumedArgsLength == -1) - { - assumedArgsLength = info.Length(); - if (info[assumedArgsLength - 1]->IsFunction()) - { - // Async - assumedArgsLength--; - } - } - af::dim4 dims(1, 1, 1, 1); - bool any = false; - for (int idx = dimsStartAt; idx < ((assumedArgsLength - 1) - argsFollowingDims); idx++) - { - int dimIdx = idx - dimsStartAt; - assert(dimIdx < 4); - any = true; - if (dimIdx == 0 && info[idx]->IsObject()) - { - dims = move(ToDim4(info[idx].As())); - break; - } - dims[dimIdx] = info[idx]->Int32Value(); - } - if (any) - { - af::dtype type = GetDTypeInfo(info[assumedArgsLength - 1 + dimsStartAt]->Uint32Value()).first; - return move(make_pair(move(dims), type)); - } - ARRAYFIRE_THROW("Cannot extract dimensions and dtype from argumens."); -} - -Nan::Callback* GetCallback(const Nan::FunctionCallbackInfo& info) -{ - if (info.Length() && info[info.Length() - 1]->IsFunction()) - { - return new Nan::Callback(info[info.Length() - 1].As()); - } - ARRAYFIRE_THROW_CB_EXPECTED(); -} - -v8::Local ToV8Features(const af::features& feat) -{ - auto obj = Nan::New(); - obj->Set(Nan::New(Symbols::NumFeatures), Nan::New((unsigned)feat.getNumFeatures())); - obj->Set(Nan::New(Symbols::X), ArrayWrapper::New(feat.getX())); - obj->Set(Nan::New(Symbols::Y), ArrayWrapper::New(feat.getY())); - obj->Set(Nan::New(Symbols::Score), ArrayWrapper::New(feat.getScore())); - obj->Set(Nan::New(Symbols::Orientation), ArrayWrapper::New(feat.getOrientation())); - obj->Set(Nan::New(Symbols::Size), ArrayWrapper::New(feat.getSize())); - return obj; -} - -RegionIndex ToRegionIndex(v8::Local obj) -{ - auto cn = obj->GetConstructorName(); - if (cn->Equals(Nan::New(Symbols::RowClass))) - { - return make_tuple(Region::Row, obj->Get(Nan::New(Symbols::Index))->Uint32Value(), (unsigned)0); - } - else if (cn->Equals(Nan::New(Symbols::RowsClass))) - { - return make_tuple(Region::Rows, obj->Get(Nan::New(Symbols::FirstIndex))->Uint32Value(), obj->Get(Nan::New(Symbols::LastIndex))->Uint32Value()); - } - else if (cn->Equals(Nan::New(Symbols::ColClass))) - { - return make_tuple(Region::Col, obj->Get(Nan::New(Symbols::Index))->Uint32Value(), (unsigned)0); - } - else if (cn->Equals(Nan::New(Symbols::ColsClass))) - { - return make_tuple(Region::Cols, obj->Get(Nan::New(Symbols::FirstIndex))->Uint32Value(), obj->Get(Nan::New(Symbols::LastIndex))->Uint32Value()); - } - else if (cn->Equals(Nan::New(Symbols::SliceClass))) - { - return make_tuple(Region::Slice, obj->Get(Nan::New(Symbols::Index))->Uint32Value(), (unsigned)0); - } - else if (cn->Equals(Nan::New(Symbols::SlicesClass))) - { - return make_tuple(Region::Slices, obj->Get(Nan::New(Symbols::FirstIndex))->Uint32Value(), obj->Get(Nan::New(Symbols::LastIndex))->Uint32Value()); - } - return make_tuple(Region::None, (unsigned)0, (unsigned)0); -} - -RegionIndex ToRegionIndex(v8::Local value) -{ - if (value->IsObject()) - { - return ToRegionIndex(value.As()); - } - return make_tuple(Region::None, (unsigned)0, (unsigned)0); -} diff --git a/src/helpers.h b/src/helpers.h deleted file mode 100644 index 3fe0a5d..0000000 --- a/src/helpers.h +++ /dev/null @@ -1,449 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_JS_HELPERS_H -#define ARRAYFIRE_JS_HELPERS_H - -#include -#include -#include -#include -#include -#include "symbols.h" - -enum class Region -{ - None, Row, Rows, Col, Cols, Slice, Slices -}; - -typedef std::tuple RegionIndex; - -std::pair GetDTypeInfo(unsigned udtype); - -std::pair GetDTypeInfo(v8::Local value); - -std::string ErrToString(af_err); - -v8::Local WrapPointer(void* ptr); - -af::dim4 ToDim4(v8::Local obj); - -af::dim4 ToDim4(v8::Local value); - -af::seq ToSeq(v8::Local obj); - -af::seq ToSeq(v8::Local value); - -af::index ToIndex(v8::Local value); - -af::af_cdouble ToDComplex(v8::Local obj); - -af::af_cdouble ToDComplex(v8::Local value); - -af::af_cfloat ToFComplex(v8::Local obj); - -af::af_cfloat ToFComplex(v8::Local value); - -v8::Local ToV8Complex(const af::af_cdouble& value); - -v8::Local ToV8Complex(const af::af_cfloat& value); - -v8::Local ToV8Features(const af::features& feat); - -std::pair ParseDimAndTypeArgs(const Nan::FunctionCallbackInfo& info, int assumedArgsLength = -1, int argsFollowingDims = 0, int dimsStartAt = 0); - -Nan::Callback* GetCallback(const Nan::FunctionCallbackInfo& info); - -inline bool NeedsDouble(const af::array& array) { return array.type() == f64 || array.type() == c64 || array.type() == s64 || array.type() == u64; } - -inline bool NeedsDouble(const af::array::array_proxy& arrayProxy) { return arrayProxy.type() == f64 || arrayProxy.type() == c64 || arrayProxy.type() == s64 || arrayProxy.type() == u64; } - -RegionIndex ToRegionIndex(v8::Local obj); - -RegionIndex ToRegionIndex(v8::Local value); - -#define ARGS_LEN(n) if (info.Length() < n) return NAN_THROW_INVALID_NO_OF_ARGS(); - -#define AF_ARR(F, f)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(1);\ - \ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0))));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_DIM(F, f)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(1);\ - \ - int dim = 0;\ - if (info.Length() > 1) dim = info[1]->Int32Value();\ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0), dim)));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_BOOL(F, f, defV)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(1);\ - \ - bool v = defV;\ - if (info.Length() > 1) v = info[1]->BooleanValue();\ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0), v)));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_VOID_ARR_BOOL(F, f, defV)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(1);\ - \ - bool v = defV;\ - if (info.Length() > 1) v = info[1]->BooleanValue();\ - Guard guard;\ - af::f(*ArrayWrapper::GetArrayAt(info, 0), v);\ - info.GetReturnValue().SetUndefined();\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_FLOAT_FLOAT_FLOAT(F, f, defV1, defV2, defV3)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(1);\ - \ - float v1 = defV1;\ - float v2 = defV2;\ - float v3 = defV3;\ - if (info.Length() > 1) v1 = info[1]->NumberValue();\ - if (info.Length() > 2) v1 = info[2]->NumberValue();\ - if (info.Length() > 3) v1 = info[3]->NumberValue();\ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0), v1, v2, v3)));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_ARR(F, f)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(2);\ - \ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0), *ArrayWrapper::GetArrayAt(info, 1))));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_ARR_ARR(F, f)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(3);\ - \ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0), *ArrayWrapper::GetArrayAt(info, 1), *ArrayWrapper::GetArrayAt(info, 2))));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_ARR_ARR_ARR(F, f)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(4);\ - \ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0), *ArrayWrapper::GetArrayAt(info, 1), *ArrayWrapper::GetArrayAt(info, 2), *ArrayWrapper::GetArrayAt(info, 3))));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_ARR_DIM(F, f)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(2);\ - \ - int dim = 0;\ - if (info.Length() > 2) dim = info[2]->Int32Value();\ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0), *ArrayWrapper::GetArrayAt(info, 1), dim)));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_ARR_BOOL(F, f, defV)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(2);\ - \ - bool v = defV;\ - if (info.Length() > 2) v = info[2]->BooleanValue();\ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*ArrayWrapper::GetArrayAt(info, 0), *ArrayWrapper::GetArrayAt(info, 1), v)));\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ARR_DOUBLE_COMB(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2)\ - \ - auto pArray1 = ArrayWrapper::TryGetArrayAt(info, 0);\ - auto pArray2 = ArrayWrapper::TryGetArrayAt(info, 1);\ - Guard guard;\ - if (pArray1)\ - {\ - if (pArray2)\ - {\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*pArray1, *pArray2)));\ - return;\ - }\ - else if (info[1]->IsNumber())\ - {\ - double d = info[1]->NumberValue();\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*pArray1, d)));\ - return;\ - }\ - }\ - else if (info[0]->IsNumber())\ - {\ - double d = info[0]->NumberValue();\ - if (pArray2)\ - {\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(d, *pArray2)));\ - return;\ - }\ - }\ - \ - NAN_THROW_INVALID_ARGS();\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ALGO_V1(F, f)\ -NAN_METHOD(F)\ -{\ - try\ - {\ - ARGS_LEN(1);\ - Guard guard;\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - if (info.Length() > 1)\ - {\ - int dim = info[1]->Int32Value();\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*pArray, dim)));\ - }\ - else\ - {\ - if (NeedsDouble(*pArray))\ - info.GetReturnValue().Set(af::f(*pArray));\ - else\ - info.GetReturnValue().Set(af::f(*pArray));\ - }\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_ALGO_V2(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(1);\ - Guard guard;\ - \ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - if (info.Length() > 1)\ - {\ - int dim = info[1]->Int32Value();\ - af::array v;\ - af::array at;\ - af::f(v, at, *pArray, dim);\ - auto obj = Nan::New();\ - obj->Set(Nan::New(Symbols::Value), ArrayWrapper::New(v));\ - obj->Set(Nan::New(Symbols::Index), ArrayWrapper::New(at));\ - info.GetReturnValue().Set(obj);\ - }\ - else\ - {\ - if (NeedsDouble(*pArray))\ - {\ - double v;\ - unsigned at;\ - af::f(&v, &at, *pArray);\ - auto obj = Nan::New();\ - obj->Set(Nan::New(Symbols::Value), Nan::New(v));\ - obj->Set(Nan::New(Symbols::Index), Nan::New(at));\ - info.GetReturnValue().Set(obj);\ - }\ - else\ - {\ - float v;\ - unsigned at;\ - af::f(&v, &at, *pArray);\ - auto obj = Nan::New();\ - obj->Set(Nan::New(Symbols::Value), Nan::New(v));\ - obj->Set(Nan::New(Symbols::Index), Nan::New(at));\ - info.GetReturnValue().Set(obj);\ - }\ - }\ - }\ - ARRAYFIRE_CATCH\ -} - -// weighted mean like stuff: -#define AF_ALGO_V3(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2);\ - Guard guard;\ - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0);\ - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1);\ - if (info.Length() > 2)\ - {\ - int dim = info[2]->Int32Value();\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*pArray1, *pArray2, dim)));\ - }\ - else\ - {\ - if (NeedsDouble(*pArray1))\ - {\ - info.GetReturnValue().Set(af::f(*pArray1, *pArray2));\ - }\ - else\ - {\ - info.GetReturnValue().Set(af::f(*pArray1, *pArray2));\ - }\ - }\ - }\ - ARRAYFIRE_CATCH\ -} - -#define AF_XYZW(F, f, iy, iz, iw)\ -NAN_METHOD(F)\ -{\ - \ - \ - try\ - {\ - ARGS_LEN(3);\ - \ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - unsigned x, y, z, w;\ - if (info[1]->IsObject())\ - {\ - auto dim = ToDim4(info[1].As());\ - x = dim[0];\ - y = dim[1];\ - z = dim[2];\ - w = dim[3];\ - }\ - else\ - {\ - x = info[1]->Uint32Value();\ - y = iy;\ - z = iz;\ - w = iw;\ - if (info.Length() > 2)\ - {\ - y = info[2]->Uint32Value();\ - }\ - if (info.Length() > 3)\ - {\ - z = info[3]->Uint32Value();\ - }\ - if (info.Length() > 4)\ - {\ - w = info[4]->Uint32Value();\ - }\ - }\ - Guard guard;\ - info.GetReturnValue().Set(ArrayWrapper::New(af::f(*pArray, x, y, z, w)));\ - }\ - ARRAYFIRE_CATCH\ -} - -#endif // ARRAYFIRE_JS_HELPERS_H diff --git a/src/imageprocessing.cpp b/src/imageprocessing.cpp deleted file mode 100644 index 6e9fd2d..0000000 --- a/src/imageprocessing.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "imageprocessing.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" -#include "worker.h" - -using namespace v8; -using namespace std; -using namespace node; - -NAN_METHOD(LoadImage) -{ - - try - { - ARGS_LEN(2); - String::Utf8Value str(info[0]); - string fn(*str); - bool isColor = false; - if (info.Length() > 1) - { - isColor = info[1]->BooleanValue(); - } - ArrayWrapper::NewAsync( - info, - [=](){ Guard guard; return new af::array(af::loadImage(fn.c_str(), isColor)); }); - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(SaveImage) -{ - - try - { - ARGS_LEN(3); - String::Utf8Value str(info[0]); - string fn(*str); - auto array = *ArrayWrapper::GetArrayAt(info, 1); - auto exec = [=]() - { - Guard guard; - af::saveImage(fn.c_str(), array); - }; - auto worker = new Worker(GetCallback(info), move(exec)); - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(ColorSpace) -{ - - try - { - ARGS_LEN(3); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - auto to = (af::CSpace)info[1]->Uint32Value(); - auto from = (af::CSpace)info[2]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::colorSpace(*pArray, to, from)); - } - ARRAYFIRE_CATCH; -} - -AF_ARR_FLOAT_FLOAT_FLOAT(Gray2RGB, gray2rgb, 1.0f, 1.0f, 1.0f) -AF_ARR_FLOAT_FLOAT_FLOAT(RGB2Gray, rgb2gray, 0.2126f, 0.7152f, 0.0722f) -AF_ARR(HSV2RGB, hsv2rgb) -AF_ARR(RGB2HSV, rgb2hsv) - -NAN_METHOD(Regions) -{ - - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - af::connectivity conn = AF_CONNECTIVITY_4; - af::dtype dtype = f32; - if (info.Length() > 1) conn = (af::connectivity)info[1]->Uint32Value(); - if (info.Length() > 2) dtype = GetDTypeInfo(info[2]).first; - Guard guard; - ArrayWrapper::New(af::regions(*pArray, conn, dtype)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Bilateral) -{ - - try - { - ARGS_LEN(3); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - float spatialSigma = info[1]->NumberValue(); - float chromaticSigma = info[2]->NumberValue(); - bool isColor = false; - if (info.Length() > 3) isColor = info[3]->BooleanValue(); - Guard guard; - ArrayWrapper::New(af::bilateral(*pArray, spatialSigma, chromaticSigma, isColor)); - } - ARRAYFIRE_CATCH; -} - -#define ARRAYFIRE_FILT_METHOD(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(1);\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - dim_t windLength = 3;\ - dim_t windWidth = 3;\ - af::borderType edgePad = AF_PAD_ZERO;\ - if (info.Length() > 1) windLength = info[1]->Uint32Value();\ - if (info.Length() > 2) windWidth = info[2]->Uint32Value();\ - if (info.Length() > 3) edgePad = (af::borderType)info[3]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, windLength, windWidth, edgePad));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAYFIRE_FILT_METHOD(MaxFilt, maxfilt) -ARRAYFIRE_FILT_METHOD(MinFilt, minfilt) -ARRAYFIRE_FILT_METHOD(MedFilt, medfilt) -#undef ARRAYFIRE_FILT_METHOD - -NAN_METHOD(MeanShift) -{ - - try - { - ARGS_LEN(4); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - float spatialSigma = info[1]->NumberValue(); - float chromaticSigma = info[2]->NumberValue(); - unsigned iter = info[3]->Uint32Value(); - bool isColor = false; - if (info.Length() > 4) isColor = info[4]->BooleanValue(); - Guard guard; - ArrayWrapper::New(af::meanShift(*pArray, spatialSigma, chromaticSigma, iter, isColor)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Sobel) -{ - - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - unsigned kerSize = 3; - if (info.Length() > 1) kerSize = info[1]->Uint32Value(); - Guard guard; - af::array dx, dy; - af::sobel(dx, dy, *pArray, kerSize); - auto result = Nan::New(); - result->Set(Nan::New(Symbols::DX), ArrayWrapper::New(dx)); - result->Set(Nan::New(Symbols::DY), ArrayWrapper::New(dy)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH; -} - -AF_ARR_ARR(HistEqual, histEqual) - -NAN_METHOD(Histogram) -{ - - try - { - ARGS_LEN(2); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - unsigned nbins = info[1]->Uint32Value(); - double minval = numeric_limits::min(); - double maxval = numeric_limits::max(); - if (info.Length() > 2) minval = info[2]->NumberValue(); - if (info.Length() > 3) maxval = info[3]->NumberValue(); - Guard guard; - ArrayWrapper::New(af::histogram(*pArray, nbins, minval, maxval)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Resize) -{ - - try - { - ARGS_LEN(2); - auto pIn = ArrayWrapper::TryGetArrayAt(info, 0); - af::interpType method = AF_INTERP_NEAREST; - if (pIn) - { - dim_t odim0 = info[1]->Uint32Value(); - dim_t odim1 = info[2]->Uint32Value(); - if (info.Length() > 3) method = (af::interpType)info[3]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::resize(*pIn, odim0, odim1, method)); - } - else - { - pIn = ArrayWrapper::TryGetArrayAt(info, 1); - if (pIn) - { - float scale = info[0]->NumberValue(); - if (info.Length() > 2) method = (af::interpType)info[2]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::resize(scale, *pIn, method)); - } - else - { - float scale0 = info[0]->NumberValue(); - float scale1 = info[1]->NumberValue(); - pIn = ArrayWrapper::GetArrayAt(info, 2); - if (info.Length() > 3) method = (af::interpType)info[3]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::resize(scale0, scale1, *pIn, method)); - } - } - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Rotate) -{ - - try - { - ARGS_LEN(2); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - float theta = info[1]->NumberValue(); - bool crop = true; - af::interpType method = AF_INTERP_NEAREST; - if (info.Length() > 2) crop = info[2]->BooleanValue(); - if (info.Length() > 3) method = (af::interpType)info[3]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::rotate(*pArray, theta, crop, method)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Scale) -{ - - try - { - ARGS_LEN(3); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - float scale0 = info[1]->NumberValue(); - float scale1 = info[2]->NumberValue(); - dim_t odim0 = 0; - dim_t odim1 = 0; - af::interpType method = AF_INTERP_NEAREST; - if (info.Length() > 3) odim0 = info[3]->Uint32Value(); - if (info.Length() > 4) odim1 = info[4]->Uint32Value(); - if (info.Length() > 5) method = (af::interpType)info[5]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::scale(*pArray, scale0, scale1, odim0, odim1, method)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Skew) -{ - - try - { - ARGS_LEN(3); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - float skew0 = info[1]->NumberValue(); - float skew1 = info[2]->NumberValue(); - dim_t odim0 = 0; - dim_t odim1 = 0; - bool inverse = true; - af::interpType method = AF_INTERP_NEAREST; - if (info.Length() > 3) odim0 = info[3]->Uint32Value(); - if (info.Length() > 4) odim1 = info[4]->Uint32Value(); - if (info.Length() > 5) inverse = info[5]->BooleanValue(); - if (info.Length() > 6) method = (af::interpType)info[6]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::skew(*pArray, skew0, skew1, odim0, odim1, inverse, method)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Transform) -{ - - try - { - ARGS_LEN(2); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - dim_t odim0 = 0; - dim_t odim1 = 0; - bool inverse = true; - af::interpType method = AF_INTERP_NEAREST; - if (info.Length() > 2) odim0 = info[2]->Uint32Value(); - if (info.Length() > 3) odim1 = info[3]->Uint32Value(); - if (info.Length() > 4) inverse = info[4]->BooleanValue(); - if (info.Length() > 5) method = (af::interpType)info[5]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::transform(*pArray1, *pArray2, odim0, odim1, method, inverse)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Translate) -{ - - try - { - ARGS_LEN(3); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - float trans0 = info[1]->NumberValue(); - float trans1 = info[2]->NumberValue(); - dim_t odim0 = 0; - dim_t odim1 = 0; - af::interpType method = AF_INTERP_NEAREST; - if (info.Length() > 3) odim0 = info[3]->Uint32Value(); - if (info.Length() > 4) odim1 = info[4]->Uint32Value(); - if (info.Length() > 5) method = (af::interpType)info[5]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::translate(*pArray, trans0, trans1, odim0, odim1, method)); - } - ARRAYFIRE_CATCH; -} - -AF_ARR_ARR(Dilate, dilate) -AF_ARR_ARR(Dilate3, dilate3) -AF_ARR_ARR(Erode, erode) -AF_ARR_ARR(Erode3, erode3) - -NAN_METHOD(GaussianKernel) -{ - - try - { - ARGS_LEN(2); - int rows = info[0]->Int32Value(); - int cols = info[1]->Int32Value(); - double sigR = 0; - double sigC = 0; - if (info.Length() > 2) sigR = info[2]->NumberValue(); - if (info.Length() > 3) sigC = info[3]->NumberValue(); - Guard guard; - ArrayWrapper::New(af::gaussianKernel(rows, cols, sigR, sigC)); - } - ARRAYFIRE_CATCH; -} - -NAN_MODULE_INIT(InitImageProcessing) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("loadImage").ToLocalChecked(), Nan::New(LoadImage)->GetFunction()); - Nan::Set(target, Nan::New("saveImage").ToLocalChecked(), Nan::New(SaveImage)->GetFunction()); - Nan::Set(target, Nan::New("colorSpace").ToLocalChecked(), Nan::New(ColorSpace)->GetFunction()); - Nan::Set(target, Nan::New("gray2rgb").ToLocalChecked(), Nan::New(Gray2RGB)->GetFunction()); - Nan::Set(target, Nan::New("rgb2gray").ToLocalChecked(), Nan::New(RGB2Gray)->GetFunction()); - Nan::Set(target, Nan::New("hsv2rgb").ToLocalChecked(), Nan::New(HSV2RGB)->GetFunction()); - Nan::Set(target, Nan::New("rgb2hsv").ToLocalChecked(), Nan::New(RGB2HSV)->GetFunction()); - Nan::Set(target, Nan::New("regions").ToLocalChecked(), Nan::New(Regions)->GetFunction()); - Nan::Set(target, Nan::New("bilateral").ToLocalChecked(), Nan::New(Bilateral)->GetFunction()); - Nan::Set(target, Nan::New("maxfilt").ToLocalChecked(), Nan::New(MaxFilt)->GetFunction()); - Nan::Set(target, Nan::New("maxFilt").ToLocalChecked(), Nan::New(MaxFilt)->GetFunction()); - Nan::Set(target, Nan::New("minfilt").ToLocalChecked(), Nan::New(MinFilt)->GetFunction()); - Nan::Set(target, Nan::New("minFilt").ToLocalChecked(), Nan::New(MinFilt)->GetFunction()); - Nan::Set(target, Nan::New("medfilt").ToLocalChecked(), Nan::New(MedFilt)->GetFunction()); - Nan::Set(target, Nan::New("medFilt").ToLocalChecked(), Nan::New(MedFilt)->GetFunction()); - Nan::Set(target, Nan::New("meanShift").ToLocalChecked(), Nan::New(MeanShift)->GetFunction()); - Nan::Set(target, Nan::New("sobel").ToLocalChecked(), Nan::New(Sobel)->GetFunction()); - Nan::Set(target, Nan::New("histEqual").ToLocalChecked(), Nan::New(HistEqual)->GetFunction()); - Nan::Set(target, Nan::New("histogram").ToLocalChecked(), Nan::New(Histogram)->GetFunction()); - Nan::Set(target, Nan::New("resize").ToLocalChecked(), Nan::New(Resize)->GetFunction()); - Nan::Set(target, Nan::New("rotate").ToLocalChecked(), Nan::New(Rotate)->GetFunction()); - Nan::Set(target, Nan::New("scale").ToLocalChecked(), Nan::New(Scale)->GetFunction()); - Nan::Set(target, Nan::New("skew").ToLocalChecked(), Nan::New(Skew)->GetFunction()); - Nan::Set(target, Nan::New("transform").ToLocalChecked(), Nan::New(Transform)->GetFunction()); - Nan::Set(target, Nan::New("translate").ToLocalChecked(), Nan::New(Translate)->GetFunction()); - Nan::Set(target, Nan::New("dilate").ToLocalChecked(), Nan::New(Dilate)->GetFunction()); - Nan::Set(target, Nan::New("dilate3").ToLocalChecked(), Nan::New(Dilate3)->GetFunction()); - Nan::Set(target, Nan::New("erode").ToLocalChecked(), Nan::New(Erode)->GetFunction()); - Nan::Set(target, Nan::New("erode3").ToLocalChecked(), Nan::New(Erode3)->GetFunction()); - Nan::Set(target, Nan::New("gaussianKernel").ToLocalChecked(), Nan::New(GaussianKernel)->GetFunction()); -} diff --git a/src/imageprocessing.h b/src/imageprocessing.h deleted file mode 100644 index 4c88c96..0000000 --- a/src/imageprocessing.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_JS_IMAGEPROCESSING_H -#define ARRAYFIRE_JS_IMAGEPROCESSING_H - -#include - -NAN_MODULE_INIT(InitImageProcessing); - -#endif // ARRAYFIRE_JS_IMAGEPROCESSING_H - diff --git a/src/init/init_CPU.cpp b/src/init/init_CPU.cpp deleted file mode 100644 index bbca9e1..0000000 --- a/src/init/init_CPU.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "../fire.h" - -NODE_MODULE(fire_js_CPU, Init) diff --git a/src/init/init_CUDA.cpp b/src/init/init_CUDA.cpp deleted file mode 100644 index 5e0c640..0000000 --- a/src/init/init_CUDA.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "../fire.h" - -NODE_MODULE(fire_js_CUDA, Init) diff --git a/src/init/init_OpenCL.cpp b/src/init/init_OpenCL.cpp deleted file mode 100644 index 0f48dca..0000000 --- a/src/init/init_OpenCL.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "../fire.h" - -NODE_MODULE(fire_js_OpenCL, Init) diff --git a/src/linearalgebra.cpp b/src/linearalgebra.cpp deleted file mode 100644 index 071050b..0000000 --- a/src/linearalgebra.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "linearalgebra.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" -#include "worker.h" - -using namespace v8; -using namespace std; -using namespace node; - -NAN_METHOD(Dot) -{ - - try - { - ARGS_LEN(2); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - af::matProp optLhs = AF_MAT_NONE; - af::matProp optRhs = AF_MAT_NONE; - if (info.Length() > 2) optLhs = (af::matProp)info[2]->Uint32Value(); - if (info.Length() > 3) optRhs = (af::matProp)info[3]->Uint32Value(); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::dot(*pArray1, *pArray2, optLhs, optRhs))); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(MatMul) -{ - - try - { - ARGS_LEN(2); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - auto pArray3 = (info.Length() > 2) ? ArrayWrapper::TryGetArrayAt(info, 2) : nullptr; - if (pArray3 == nullptr) - { - af::matProp optLhs = AF_MAT_NONE; - af::matProp optRhs = AF_MAT_NONE; - if (info.Length() > 2) optLhs = (af::matProp)info[2]->Uint32Value(); - if (info.Length() > 3) optRhs = (af::matProp)info[3]->Uint32Value(); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::matmul(*pArray1, *pArray2, optLhs, optRhs))); - } - else - { - auto pArray4 = (info.Length() > 3) ? ArrayWrapper::TryGetArrayAt(info, 3) : nullptr; - if (pArray4 == nullptr) - { - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::matmul(*pArray1, *pArray2, *pArray3))); - } - else - { - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::matmul(*pArray1, *pArray2, *pArray3, *pArray4))); - } - } - } - ARRAYFIRE_CATCH; -} - - -AF_ARR_ARR(MatMulNT, matmulNT) -AF_ARR_ARR(MatMulTN, matmulTN) -AF_ARR_ARR(MatMulTT, matmulTT) - -AF_ARR_BOOL(Transpose, transpose, false) -AF_VOID_ARR_BOOL(TransposeInPlace, transposeInPlace, false) - -NAN_METHOD(Solve) -{ - try - { - ARGS_LEN(2); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - af::matProp options = AF_MAT_NONE; - if (info.Length() > 2) options = (af::matProp)info[2]->Uint32Value(); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::solve(*pArray1, *pArray2, options))); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(SolveLU) -{ - try - { - ARGS_LEN(3); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - auto pArray3 = ArrayWrapper::GetArrayAt(info, 2); - af::matProp options = AF_MAT_NONE; - if (info.Length() > 3) options = (af::matProp)info[3]->Uint32Value(); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::solveLU(*pArray1, *pArray2, *pArray3, options))); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Cholesky) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - bool isUpper = true; - if (info.Length() > 1) isUpper = info[1]->BooleanValue(); - Guard(); - af::array out; - int r = af::cholesky(out, *pArray, isUpper); - auto result = Nan::New(); - result->Set(Nan::New(Symbols::Result), ArrayWrapper::New(out)); - result->Set(Nan::New(Symbols::FailedAtRank), Nan::New(r)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(CholeskyInPlace) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - bool isUpper = true; - if (info.Length() > 1) isUpper = info[1]->BooleanValue(); - Guard(); - af::array out; - int r = af::choleskyInPlace(*pArray, isUpper); - info.GetReturnValue().Set(r); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(LuPacked) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - bool isLapackPiv = true; - if (info.Length() > 1) isLapackPiv = info[1]->BooleanValue(); - Guard guard; - af::array out, pivot; - af::lu(out, pivot, (const af::array&)*pArray, isLapackPiv); - auto result = Nan::New(); - result->Set(Nan::New(Symbols::Result), ArrayWrapper::New(out)); - result->Set(Nan::New(Symbols::Pivot), ArrayWrapper::New(pivot)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Lu) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - Guard guard; - af::array lower, upper, pivot; - af::lu(lower, upper, pivot, *pArray); - auto result = Nan::New(); - result->Set(Nan::New(Symbols::Lower), ArrayWrapper::New(lower)); - result->Set(Nan::New(Symbols::Upper), ArrayWrapper::New(upper)); - result->Set(Nan::New(Symbols::Pivot), ArrayWrapper::New(pivot)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(LuInPlace) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - bool isLapackPiv = true; - if (info.Length() > 1) isLapackPiv = info[1]->BooleanValue(); - Guard guard; - af::array pivot; - af::luInPlace(pivot, *pArray, isLapackPiv); - info.GetReturnValue().Set(ArrayWrapper::New(pivot)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(QrPacked) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - Guard guard; - af::array out, tau; - af::qr(out, tau, *pArray); - auto result = Nan::New(); - result->Set(Nan::New(Symbols::Result), ArrayWrapper::New(out)); - result->Set(Nan::New(Symbols::Tau), ArrayWrapper::New(tau)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Qr) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - Guard guard; - af::array q, r, tau; - af::qr(q, r, tau, *pArray); - auto result = Nan::New(); - result->Set(Nan::New(Symbols::Q), ArrayWrapper::New(q)); - result->Set(Nan::New(Symbols::R), ArrayWrapper::New(r)); - result->Set(Nan::New(Symbols::Tau), ArrayWrapper::New(tau)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(QrInPlace) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - Guard guard; - af::array tau; - af::qrInPlace(tau, *pArray); - info.GetReturnValue().Set(ArrayWrapper::New(tau)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Det) -{ - try - { - ARGS_LEN(1); - - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - Guard guard; - if (NeedsDouble(*pArray)) - { - info.GetReturnValue().Set(ArrayWrapper::New(af::det(*pArray))); - } - else - { - info.GetReturnValue().Set(ArrayWrapper::New(af::det(*pArray))); - } - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Inverse) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - af::matProp options = AF_MAT_NONE; - if (info.Length() > 1) options = (af::matProp)info[1]->Uint32Value(); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::inverse(*pArray, options))); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Norm) -{ - - try - { - ARGS_LEN(1); - - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - af::normType type = AF_NORM_EUCLID; - double p = 1; - double q = 1; - if (info.Length() > 1) type = (af::normType)info[1]->Uint32Value(); - if (info.Length() > 2) p = info[2]->NumberValue(); - if (info.Length() > 3) q = info[3]->NumberValue(); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::norm(*pArray, type, p, q))); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Rank) -{ - - try - { - ARGS_LEN(1); - - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - double tol = 1E-5; - if (info.Length() > 1) tol = info[1]->NumberValue(); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::rank(*pArray, tol))); - } - ARRAYFIRE_CATCH -} - -NAN_MODULE_INIT(InitLinearAlgebra) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("dot").ToLocalChecked(), Nan::New(Dot)->GetFunction()); - Nan::Set(target, Nan::New("matMul").ToLocalChecked(), Nan::New(MatMul)->GetFunction()); - Nan::Set(target, Nan::New("matMulNT").ToLocalChecked(), Nan::New(MatMulNT)->GetFunction()); - Nan::Set(target, Nan::New("matMulTN").ToLocalChecked(), Nan::New(MatMulTN)->GetFunction()); - Nan::Set(target, Nan::New("matMulTT").ToLocalChecked(), Nan::New(MatMulTT)->GetFunction()); - Nan::Set(target, Nan::New("transpose").ToLocalChecked(), Nan::New(Transpose)->GetFunction()); - Nan::Set(target, Nan::New("transposeInPlace").ToLocalChecked(), Nan::New(TransposeInPlace)->GetFunction()); - Nan::Set(target, Nan::New("solve").ToLocalChecked(), Nan::New(Solve)->GetFunction()); - Nan::Set(target, Nan::New("solveLU").ToLocalChecked(), Nan::New(SolveLU)->GetFunction()); - Nan::Set(target, Nan::New("cholesky").ToLocalChecked(), Nan::New(Cholesky)->GetFunction()); - Nan::Set(target, Nan::New("choleskyInPlace").ToLocalChecked(), Nan::New(CholeskyInPlace)->GetFunction()); - Nan::Set(target, Nan::New("luPacked").ToLocalChecked(), Nan::New(LuPacked)->GetFunction()); - Nan::Set(target, Nan::New("lu").ToLocalChecked(), Nan::New(Lu)->GetFunction()); - Nan::Set(target, Nan::New("luInPlace").ToLocalChecked(), Nan::New(LuInPlace)->GetFunction()); - Nan::Set(target, Nan::New("qrPacked").ToLocalChecked(), Nan::New(QrPacked)->GetFunction()); - Nan::Set(target, Nan::New("qr").ToLocalChecked(), Nan::New(Qr)->GetFunction()); - Nan::Set(target, Nan::New("qrInPlace").ToLocalChecked(), Nan::New(QrInPlace)->GetFunction()); - Nan::Set(target, Nan::New("det").ToLocalChecked(), Nan::New(Det)->GetFunction()); - Nan::Set(target, Nan::New("inverse").ToLocalChecked(), Nan::New(Inverse)->GetFunction()); - Nan::Set(target, Nan::New("norm").ToLocalChecked(), Nan::New(Norm)->GetFunction()); - Nan::Set(target, Nan::New("rank").ToLocalChecked(), Nan::New(Rank)->GetFunction()); -} diff --git a/src/linearalgebra.h b/src/linearalgebra.h deleted file mode 100644 index 0fd0ac4..0000000 --- a/src/linearalgebra.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_JS_LINEARALGEBRA -#define ARRAYFIRE_JS_LINEARALGEBRA - -#include - -NAN_MODULE_INIT(InitLinearAlgebra); - -#endif // ARRAYFIRE_JS_LINEARALGEBRA - diff --git a/src/mathfunctions.cpp b/src/mathfunctions.cpp deleted file mode 100644 index 8bad4b0..0000000 --- a/src/mathfunctions.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "mathfunctions.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" - -using namespace v8; -using namespace std; -using namespace node; - -AF_ARR(Abs, abs) -AF_ARR(Arg, arg) -AF_ARR(Ceil, ceil) -AF_ARR(Floor, floor) -AF_ARR_DOUBLE_COMB(Hypot, hypot) -AF_ARR_DOUBLE_COMB(Max, max) -AF_ARR_DOUBLE_COMB(Min, min) -AF_ARR_DOUBLE_COMB(Mod, mod) -AF_ARR(Round, round) -AF_ARR(Sign, sign) -AF_ARR(Trunc, trunc) -AF_ARR_DOUBLE_COMB(Rem, rem) - -AF_ARR(ACos, acos) -AF_ARR(ASin, asin) -AF_ARR(ATan, atan) -AF_ARR_DOUBLE_COMB(ATan2, atan2) -AF_ARR(Cos, cos) -AF_ARR(Sin, sin) -AF_ARR(Tan, tan) - -AF_ARR(Cbrt, cbrt) -AF_ARR(Erf, erf) -AF_ARR(Erfc, erfc) -AF_ARR(Exp, exp) -AF_ARR(ExpM1, expm1) -AF_ARR(Factorial, factorial) -AF_ARR(LGamma, lgamma) -AF_ARR(TGamma, tgamma) -AF_ARR(Log, log) -AF_ARR(Log10, log10) -AF_ARR(Log1P, log1p) -AF_ARR_ARR(Pow, pow) -AF_ARR(Pow2, pow2) -AF_ARR_DOUBLE_COMB(Root, root) -AF_ARR(Sqrt, sqrt) -AF_ARR(Sigmoid, sigmoid) - -AF_ARR(ACosH, acosh) -AF_ARR(ASinH, asinh) -AF_ARR(ATanH, atanh) -AF_ARR(CosH, cosh) -AF_ARR(SinH, sinh) -AF_ARR(TanH, tanh) - -AF_ARR(Complex, complex) -AF_ARR(Conjg, conjg) -AF_ARR(Imag, imag) -AF_ARR(Real, real) - -NAN_MODULE_INIT(InitMathFunctions) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("abs").ToLocalChecked(), - Nan::New(Abs)->GetFunction()); - - Nan::Set(target, Nan::New("arg").ToLocalChecked(), - Nan::New(Arg)->GetFunction()); - - Nan::Set(target, Nan::New("ceil").ToLocalChecked(), - Nan::New(Ceil)->GetFunction()); - - Nan::Set(target, Nan::New("floor").ToLocalChecked(), - Nan::New(Floor)->GetFunction()); - - Nan::Set(target, Nan::New("hypot").ToLocalChecked(), Nan::New(Hypot)->GetFunction()); - Nan::Set(target, Nan::New("max").ToLocalChecked(), Nan::New(Max)->GetFunction()); - Nan::Set(target, Nan::New("min").ToLocalChecked(), Nan::New(Min)->GetFunction()); - Nan::Set(target, Nan::New("mod").ToLocalChecked(), Nan::New(Mod)->GetFunction()); - Nan::Set(target, Nan::New("round").ToLocalChecked(), Nan::New(Round)->GetFunction()); - Nan::Set(target, Nan::New("sign").ToLocalChecked(), Nan::New(Sign)->GetFunction()); - Nan::Set(target, Nan::New("trunc").ToLocalChecked(), Nan::New(Trunc)->GetFunction()); - Nan::Set(target, Nan::New("rem").ToLocalChecked(), Nan::New(Rem)->GetFunction()); - - Nan::Set(target, Nan::New("acos").ToLocalChecked(), Nan::New(ACos)->GetFunction()); - Nan::Set(target, Nan::New("aCos").ToLocalChecked(), Nan::New(ACos)->GetFunction()); - Nan::Set(target, Nan::New("asin").ToLocalChecked(), Nan::New(ASin)->GetFunction()); - Nan::Set(target, Nan::New("aSin").ToLocalChecked(), Nan::New(ASin)->GetFunction()); - Nan::Set(target, Nan::New("atan").ToLocalChecked(), Nan::New(ATan)->GetFunction()); - Nan::Set(target, Nan::New("aTan").ToLocalChecked(), Nan::New(ATan)->GetFunction()); - Nan::Set(target, Nan::New("atan2").ToLocalChecked(), Nan::New(ATan2)->GetFunction()); - Nan::Set(target, Nan::New("aTan2").ToLocalChecked(), Nan::New(ATan2)->GetFunction()); - Nan::Set(target, Nan::New("cos").ToLocalChecked(), Nan::New(Cos)->GetFunction()); - Nan::Set(target, Nan::New("sin").ToLocalChecked(), Nan::New(Sin)->GetFunction()); - Nan::Set(target, Nan::New("tan").ToLocalChecked(), Nan::New(Tan)->GetFunction()); - - Nan::Set(target, Nan::New("cbrt").ToLocalChecked(), Nan::New(Cbrt)->GetFunction()); - Nan::Set(target, Nan::New("erf").ToLocalChecked(), Nan::New(Erf)->GetFunction()); - Nan::Set(target, Nan::New("erfc").ToLocalChecked(), Nan::New(Erfc)->GetFunction()); - Nan::Set(target, Nan::New("exp").ToLocalChecked(), Nan::New(Exp)->GetFunction()); - Nan::Set(target, Nan::New("expm1").ToLocalChecked(), Nan::New(ExpM1)->GetFunction()); - Nan::Set(target, Nan::New("expM1").ToLocalChecked(), Nan::New(ExpM1)->GetFunction()); - Nan::Set(target, Nan::New("factorial").ToLocalChecked(), Nan::New(Factorial)->GetFunction()); - Nan::Set(target, Nan::New("lgamma").ToLocalChecked(), Nan::New(LGamma)->GetFunction()); - Nan::Set(target, Nan::New("lGamma").ToLocalChecked(), Nan::New(LGamma)->GetFunction()); - Nan::Set(target, Nan::New("tgamma").ToLocalChecked(), Nan::New(TGamma)->GetFunction()); - Nan::Set(target, Nan::New("tGamma").ToLocalChecked(), Nan::New(TGamma)->GetFunction()); - Nan::Set(target, Nan::New("log").ToLocalChecked(), Nan::New(Log)->GetFunction()); - Nan::Set(target, Nan::New("log10").ToLocalChecked(), Nan::New(Log10)->GetFunction()); - Nan::Set(target, Nan::New("log1p").ToLocalChecked(), Nan::New(Log1P)->GetFunction()); - Nan::Set(target, Nan::New("log1P").ToLocalChecked(), Nan::New(Log1P)->GetFunction()); - Nan::Set(target, Nan::New("pow").ToLocalChecked(), Nan::New(Pow)->GetFunction()); - Nan::Set(target, Nan::New("pow2").ToLocalChecked(), Nan::New(Pow2)->GetFunction()); - Nan::Set(target, Nan::New("root").ToLocalChecked(), Nan::New(Root)->GetFunction()); - Nan::Set(target, Nan::New("sqrt").ToLocalChecked(), Nan::New(Sqrt)->GetFunction()); - - Nan::Set(target, Nan::New("acosh").ToLocalChecked(), Nan::New(ACosH)->GetFunction()); - Nan::Set(target, Nan::New("aCosH").ToLocalChecked(), Nan::New(ACosH)->GetFunction()); - Nan::Set(target, Nan::New("asinh").ToLocalChecked(), Nan::New(ASinH)->GetFunction()); - Nan::Set(target, Nan::New("aSinH").ToLocalChecked(), Nan::New(ASinH)->GetFunction()); - Nan::Set(target, Nan::New("atanh").ToLocalChecked(), Nan::New(ATanH)->GetFunction()); - Nan::Set(target, Nan::New("aTanH").ToLocalChecked(), Nan::New(ATanH)->GetFunction()); - - Nan::Set(target, Nan::New("cosh").ToLocalChecked(), Nan::New(CosH)->GetFunction()); - Nan::Set(target, Nan::New("CosH").ToLocalChecked(), Nan::New(CosH)->GetFunction()); - Nan::Set(target, Nan::New("sinh").ToLocalChecked(), Nan::New(SinH)->GetFunction()); - Nan::Set(target, Nan::New("SinH").ToLocalChecked(), Nan::New(SinH)->GetFunction()); - Nan::Set(target, Nan::New("tanh").ToLocalChecked(), Nan::New(TanH)->GetFunction()); - Nan::Set(target, Nan::New("TanH").ToLocalChecked(), Nan::New(TanH)->GetFunction()); - - Nan::Set(target, Nan::New("complex").ToLocalChecked(), Nan::New(Complex)->GetFunction()); - Nan::Set(target, Nan::New("conjg").ToLocalChecked(), Nan::New(Conjg)->GetFunction()); - Nan::Set(target, Nan::New("imag").ToLocalChecked(), Nan::New(Imag)->GetFunction()); - Nan::Set(target, Nan::New("real").ToLocalChecked(), Nan::New(Real)->GetFunction()); - - Nan::Set(target, Nan::New("sigmoid").ToLocalChecked(), Nan::New(Sigmoid)->GetFunction()); -} diff --git a/src/mathfunctions.h b/src/mathfunctions.h deleted file mode 100644 index efc6709..0000000 --- a/src/mathfunctions.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_MATHFUNCTIONS_H -#define ARRAYFIRE_MATHFUNCTIONS_H - -#include - -NAN_MODULE_INIT(InitMathFunctions); - -#endif // METHFUNCTIONS - diff --git a/src/moveandreorderarray.cpp b/src/moveandreorderarray.cpp deleted file mode 100644 index c206552..0000000 --- a/src/moveandreorderarray.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "moveandreorderarray.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" - -using namespace v8; -using namespace std; -using namespace node; - -NAN_METHOD(Join) -{ - try - { - ARGS_LEN(3); - - af::dtype dim = GetDTypeInfo(info[0]).first; - auto pArray1 = ArrayWrapper::GetArrayAt(info, 1); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 2); - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::join(dim, *pArray1, *pArray2)));; - } - ARRAYFIRE_CATCH -} - -AF_XYZW(Tile, tile, 1, 1, 1) - -AF_XYZW(Reorder, reorder, 1, 2, 3) - -AF_XYZW(Shift, shift, 0, 0, 0) - -AF_XYZW(ModDims, moddims, 1, 1, 1) - -AF_ARR(Flat, flat) - -NAN_METHOD(Flip) -{ - try - { - ARGS_LEN(2); - - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - af::dtype dim = GetDTypeInfo(info[1]).first; - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::flip(*pArray, dim)));; - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(Select) -{ - try - { - ARGS_LEN(3); - - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - auto pArray1 = ArrayWrapper::TryGetArrayAt(info, 1); - auto pArray2 = ArrayWrapper::TryGetArrayAt(info, 2); - Guard guard; - if (pArray1 && pArray2) - { - info.GetReturnValue().Set(ArrayWrapper::New(af::select(*pArray, *pArray1, *pArray2))); - } - else if (pArray1 && info[2]->IsNumber()) - { - info.GetReturnValue().Set(ArrayWrapper::New(af::select(*pArray, *pArray1, info[2]->NumberValue()))); - } - else if (pArray2 && info[1]->IsNumber()) - { - info.GetReturnValue().Set(ArrayWrapper::New(af::select(*pArray, info[1]->NumberValue(), *pArray2))); - } - else - { - NAN_THROW_INVALID_ARGS(); - } - } - ARRAYFIRE_CATCH -} - -NAN_MODULE_INIT(InitMoveAndReorderArray) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("join").ToLocalChecked(), - Nan::New(Join)->GetFunction()); - - Nan::Set(target, Nan::New("tile").ToLocalChecked(), - Nan::New(Tile)->GetFunction()); - - Nan::Set(target, Nan::New("reorder").ToLocalChecked(), - Nan::New(Reorder)->GetFunction()); - - Nan::Set(target, Nan::New("shift").ToLocalChecked(), - Nan::New(Shift)->GetFunction()); - - Nan::Set(target, Nan::New("moddims").ToLocalChecked(), - Nan::New(ModDims)->GetFunction()); - - Nan::Set(target, Nan::New("modDims").ToLocalChecked(), - Nan::New(ModDims)->GetFunction()); - - Nan::Set(target, Nan::New("flat").ToLocalChecked(), - Nan::New(Flat)->GetFunction()); - - Nan::Set(target, Nan::New("flip").ToLocalChecked(), - Nan::New(Flip)->GetFunction()); - - Nan::Set(target, Nan::New("select").ToLocalChecked(), - Nan::New(Select)->GetFunction()); -} diff --git a/src/moveandreorderarray.h b/src/moveandreorderarray.h deleted file mode 100644 index 333c500..0000000 --- a/src/moveandreorderarray.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_MOVEANDREORDERARRAY_H -#define ARRAYFIRE_MOVEANDREORDERARRAY_H - -#include - -NAN_MODULE_INIT(InitMoveAndReorderArray); - -#endif // ARRAYFIRE_MOVEANDREORDERARRAY_H - diff --git a/src/signalprocessing.cpp b/src/signalprocessing.cpp deleted file mode 100644 index 170cfce..0000000 --- a/src/signalprocessing.cpp +++ /dev/null @@ -1,348 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "computervision.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" - -using namespace v8; -using namespace std; -using namespace node; - -NAN_METHOD(ConvolveSeparable) -{ - - try - { - ARGS_LEN(3); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - auto pArray3 = ArrayWrapper::GetArrayAt(info, 2); - af::convMode mode = AF_CONV_DEFAULT; - if (info.Length() > 3) mode = (af::convMode)info[3]->Uint32Value(); - Guard guard; - ArrayWrapper::New(af::convolve(*pArray1, *pArray2, *pArray3, mode)); - } - ARRAYFIRE_CATCH; -} - -#define ARRAYFIRE_CONVOLVE(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2);\ - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0);\ - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1);\ - af::convMode mode = AF_CONV_DEFAULT;\ - af::convDomain domain = AF_CONV_AUTO;\ - if (info.Length() > 2) mode = (af::convMode)info[2]->Uint32Value();\ - if (info.Length() > 3) domain = (af::convDomain)info[3]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray1, *pArray2, mode, domain));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAYFIRE_CONVOLVE(Convolve, convolve) -ARRAYFIRE_CONVOLVE(Convolve1, convolve1) -ARRAYFIRE_CONVOLVE(Convolve2, convolve2) -ARRAYFIRE_CONVOLVE(Convolve3, convolve3) - -#undef ARRAYFIRE_CONVOLVE -#define ARRAYFIRE_CONVOLVE(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2);\ - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0);\ - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1);\ - af::convMode mode = AF_CONV_DEFAULT;\ - if (info.Length() > 2) mode = (af::convMode)info[2]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray1, *pArray2, mode));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAYFIRE_CONVOLVE(FFTConvolve, fftConvolve) -ARRAYFIRE_CONVOLVE(FFTConvolve2, fftConvolve2) -ARRAYFIRE_CONVOLVE(FFTConvolve3, fftConvolve3) -#undef ARRAYFIRE_CONVOLVE - -#define ARRAY_FIRE_FFTNORM(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2);\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - double factor = info[1]->NumberValue();\ - dim_t odim0 = 0;\ - if (info.Length() > 2) odim0 = info[2]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, factor, odim0));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAY_FIRE_FFTNORM(FFTNorm, fftNorm) -ARRAY_FIRE_FFTNORM(IFFTNorm, ifftNorm) -#undef ARRAY_FIRE_FFTNORM - -#define ARRAY_FIRE_FFT(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2);\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - dim_t odim0 = 0;\ - if (info.Length() > 1) odim0 = info[1]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, odim0));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAY_FIRE_FFT(FFT, fft) -ARRAY_FIRE_FFT(IFFT, ifft) -#undef ARRAY_FIRE_FFT - -#define ARRAYFIRE_DFT(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(1);\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - if (info.Length() == 1)\ - {\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray));\ - }\ - else if (info.Length() == 2)\ - {\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, ToDim4(info[1])));\ - }\ - else if (info.Length() == 3)\ - {\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, info[1]->NumberValue(), ToDim4(info[2])));\ - }\ - else \ - {\ - NAN_THROW_INVALID_NO_OF_ARGS();\ - }\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAYFIRE_DFT(DFT, dft) -ARRAYFIRE_DFT(IDFT, idft) -#undef ARRAYFIRE_DFT - -#define ARRAYFIRE_FFT2(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(1);\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - dim_t dim0 = 0;\ - dim_t dim1 = 0;\ - if (info.Length() > 1) dim0 = info[1]->Uint32Value();\ - if (info.Length() > 2) dim1 = info[2]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, dim0, dim1));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAYFIRE_FFT2(FFT2, fft2) -ARRAYFIRE_FFT2(IFFT2, ifft2) -#undef ARRAYFIRE_FFT2 - -#define ARRAYFIRE_FFT3(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(1);\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - dim_t dim0 = 0;\ - dim_t dim1 = 0;\ - dim_t dim2 = 0;\ - if (info.Length() > 1) dim0 = info[1]->Uint32Value();\ - if (info.Length() > 2) dim1 = info[2]->Uint32Value();\ - if (info.Length() > 3) dim2 = info[3]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, dim0, dim1, dim2));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAYFIRE_FFT3(FFT3, fft3) -ARRAYFIRE_FFT3(IFFT3, ifft3) -#undef ARRAYFIRE_FFT3 - -#define ARRAYFIRE_FFT2NORM(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2);\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - double factor = info[1]->NumberValue();\ - dim_t dim0 = 0;\ - dim_t dim1 = 0;\ - if (info.Length() > 2) dim0 = info[2]->Uint32Value();\ - if (info.Length() > 3) dim1 = info[3]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, factor, dim0, dim1));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAYFIRE_FFT2NORM(FFT2Norm, fft2Norm) -ARRAYFIRE_FFT2NORM(IFFT2Norm, ifft2Norm) -#undef ARRAYFIRE_FFT2NORM - -#define ARRAYFIRE_FFT3NORM(F, f)\ -NAN_METHOD(F)\ -{\ - \ - try\ - {\ - ARGS_LEN(2);\ - auto pArray = ArrayWrapper::GetArrayAt(info, 0);\ - double factor = info[1]->NumberValue();\ - dim_t dim0 = 0;\ - dim_t dim1 = 0;\ - dim_t dim2 = 0;\ - if (info.Length() > 2) dim0 = info[2]->Uint32Value();\ - if (info.Length() > 3) dim1 = info[3]->Uint32Value();\ - if (info.Length() > 4) dim2 = info[4]->Uint32Value();\ - Guard guard;\ - ArrayWrapper::New(af::f(*pArray, factor, dim0, dim1, dim2));\ - }\ - ARRAYFIRE_CATCH;\ -} - -ARRAYFIRE_FFT3NORM(FFT3Norm, fft3Norm) -ARRAYFIRE_FFT3NORM(IFFT3Norm, ifft3Norm) -#undef ARRAYFIRE_FFT3NORM - - -AF_ARR_ARR(FIR, fir) -AF_ARR_ARR_ARR(IIR, iir) - -NAN_METHOD(Approx1) -{ - - try - { - ARGS_LEN(2); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - af::interpType method = AF_INTERP_LINEAR; - float offGrid = 0.0f; - if (info.Length() > 2) method = (af::interpType)info[2]->Uint32Value(); - if (info.Length() > 3) offGrid = info[3]->NumberValue(); - Guard guard; - ArrayWrapper::New(af::approx1(*pArray1, *pArray2, method, offGrid)); - } - ARRAYFIRE_CATCH; -} - -NAN_METHOD(Approx2) -{ - - try - { - ARGS_LEN(3); - auto pArray1 = ArrayWrapper::GetArrayAt(info, 0); - auto pArray2 = ArrayWrapper::GetArrayAt(info, 1); - auto pArray3 = ArrayWrapper::GetArrayAt(info, 2); - af::interpType method = AF_INTERP_LINEAR; - float offGrid = 0.0f; - if (info.Length() > 3) method = (af::interpType)info[3]->Uint32Value(); - if (info.Length() > 4) offGrid = info[4]->NumberValue(); - Guard guard; - ArrayWrapper::New(af::approx2(*pArray1, *pArray2, *pArray3, method, offGrid)); - } - ARRAYFIRE_CATCH; -} - -NAN_MODULE_INIT(InitSignalProcessing) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("convolveSeparable").ToLocalChecked(), Nan::New(ConvolveSeparable)->GetFunction()); - Nan::Set(target, Nan::New("convolve").ToLocalChecked(), Nan::New(Convolve)->GetFunction()); - Nan::Set(target, Nan::New("convolve1").ToLocalChecked(), Nan::New(Convolve1)->GetFunction()); - Nan::Set(target, Nan::New("convolve2").ToLocalChecked(), Nan::New(Convolve2)->GetFunction()); - Nan::Set(target, Nan::New("convolve3").ToLocalChecked(), Nan::New(Convolve3)->GetFunction()); - Nan::Set(target, Nan::New("fftConvolve").ToLocalChecked(), Nan::New(FFTConvolve)->GetFunction()); - Nan::Set(target, Nan::New("fftConvolve2").ToLocalChecked(), Nan::New(FFTConvolve2)->GetFunction()); - Nan::Set(target, Nan::New("fftConvolve3").ToLocalChecked(), Nan::New(FFTConvolve3)->GetFunction()); - Nan::Set(target, Nan::New("fftNorm").ToLocalChecked(), Nan::New(FFTNorm)->GetFunction()); - Nan::Set(target, Nan::New("iFFTNorm").ToLocalChecked(), Nan::New(IFFTNorm)->GetFunction()); - Nan::Set(target, Nan::New("fft").ToLocalChecked(), Nan::New(FFT)->GetFunction()); - Nan::Set(target, Nan::New("iFFT").ToLocalChecked(), Nan::New(IFFT)->GetFunction()); - Nan::Set(target, Nan::New("dFT").ToLocalChecked(), Nan::New(DFT)->GetFunction()); - Nan::Set(target, Nan::New("iDFT").ToLocalChecked(), Nan::New(IDFT)->GetFunction()); - Nan::Set(target, Nan::New("fft2").ToLocalChecked(), Nan::New(FFT2)->GetFunction()); - Nan::Set(target, Nan::New("iFFT2").ToLocalChecked(), Nan::New(IFFT2)->GetFunction()); - Nan::Set(target, Nan::New("fft3").ToLocalChecked(), Nan::New(FFT3)->GetFunction()); - Nan::Set(target, Nan::New("iFFT3").ToLocalChecked(), Nan::New(IFFT3)->GetFunction()); - Nan::Set(target, Nan::New("fft2Norm").ToLocalChecked(), Nan::New(FFT2Norm)->GetFunction()); - Nan::Set(target, Nan::New("iFFT2Norm").ToLocalChecked(), Nan::New(IFFT2Norm)->GetFunction()); - Nan::Set(target, Nan::New("fft3Norm").ToLocalChecked(), Nan::New(FFT3Norm)->GetFunction()); - Nan::Set(target, Nan::New("iFFT3Norm").ToLocalChecked(), Nan::New(IFFT3Norm)->GetFunction()); - Nan::Set(target, Nan::New("fir").ToLocalChecked(), Nan::New(FIR)->GetFunction()); - Nan::Set(target, Nan::New("iir").ToLocalChecked(), Nan::New(IIR)->GetFunction()); - Nan::Set(target, Nan::New("approx1").ToLocalChecked(), Nan::New(Approx1)->GetFunction()); - Nan::Set(target, Nan::New("approx2").ToLocalChecked(), Nan::New(Approx2)->GetFunction()); -} diff --git a/src/signalprocessing.h b/src/signalprocessing.h deleted file mode 100644 index 9f5bb7d..0000000 --- a/src/signalprocessing.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_SIGNALPROCESSING_H -#define ARRAYFIRE_SIGNALPROCESSING_H - -#include - -NAN_MODULE_INIT(InitSignalProcessing); - -#endif // ARRAYFIRE_SIGNALPROCESSING_H - diff --git a/src/statistics.cpp b/src/statistics.cpp deleted file mode 100644 index 3f66f0f..0000000 --- a/src/statistics.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "mathfunctions.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" -#include "worker.h" - -using namespace v8; -using namespace std; -using namespace node; - -AF_ARR_ARR_BOOL(Cov, cov, false) -AF_ALGO_V1(Mean, mean) -AF_ALGO_V3(WeightedMean, mean) -AF_ALGO_V1(Median, median) -AF_ALGO_V1(StDev, stdev) - -NAN_METHOD(Var) -{ - - try - { - ARGS_LEN(3); - - auto array = *ArrayWrapper::GetArrayAt(info, 0); - bool biased = info[1]->BooleanValue(); - if (info.Length() > 3) - { - int dim = info[2]->Int32Value(); - return ArrayWrapper::NewAsync(info, [=]() { Guard guard; return new af::array(af::var(array, biased, dim)); }); - } - else - { - if (NeedsDouble(array)) - { - auto exec = [=]() { Guard guard; return af::var(array, biased); }; - auto worker = new Worker(GetCallback(info), std::move(exec)); - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - else - { - auto exec = [=]() { Guard guard; return af::var(array, biased); }; - auto worker = new Worker(GetCallback(info), std::move(exec)); - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - } - } - ARRAYFIRE_CATCH -} - -AF_ALGO_V3(WeightedVar, var) - -NAN_METHOD(CorrCoef) -{ - - try - { - ARGS_LEN(3); - - auto array1 = *ArrayWrapper::GetArrayAt(info, 0); - auto array2 = *ArrayWrapper::GetArrayAt(info, 1); - if (NeedsDouble(array1)) - { - auto exec = [=]() { Guard guard; return af::corrcoef(array1, array2); }; - auto worker = new Worker(GetCallback(info), std::move(exec)); - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - else - { - auto exec = [=]() { Guard guard; return af::corrcoef(array1, array2); }; - auto worker = new Worker(GetCallback(info), std::move(exec)); - Nan::AsyncQueueWorker(worker); - info.GetReturnValue().SetUndefined(); - } - } - ARRAYFIRE_CATCH -} - -NAN_MODULE_INIT(InitStatistics) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("cov").ToLocalChecked(), Nan::New(Cov)->GetFunction()); - Nan::Set(target, Nan::New("mean").ToLocalChecked(), Nan::New(Mean)->GetFunction()); - Nan::Set(target, Nan::New("weightedMean").ToLocalChecked(), Nan::New(Mean)->GetFunction()); - Nan::Set(target, Nan::New("median").ToLocalChecked(), Nan::New(Median)->GetFunction()); - Nan::Set(target, Nan::New("stdev").ToLocalChecked(), Nan::New(StDev)->GetFunction()); - Nan::Set(target, Nan::New("stDev").ToLocalChecked(), Nan::New(StDev)->GetFunction()); - Nan::Set(target, Nan::New("stdDev").ToLocalChecked(), Nan::New(StDev)->GetFunction()); - Nan::Set(target, Nan::New("var").ToLocalChecked(), Nan::New(Var)->GetFunction()); - Nan::Set(target, Nan::New("weightedVar").ToLocalChecked(), Nan::New(WeightedVar)->GetFunction()); - Nan::Set(target, Nan::New("corrcoef").ToLocalChecked(), Nan::New(CorrCoef)->GetFunction()); - Nan::Set(target, Nan::New("corrCoef").ToLocalChecked(), Nan::New(CorrCoef)->GetFunction()); -} diff --git a/src/statistics.h b/src/statistics.h deleted file mode 100644 index 91551e1..0000000 --- a/src/statistics.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_STATISTICS_H -#define ARRAYFIRE_STATISTICS_H - -#include - -NAN_MODULE_INIT(InitStatistics); - -#endif // ARRAYFIRE_STATISTICS_H - diff --git a/src/symbols.cpp b/src/symbols.cpp deleted file mode 100644 index 13bb4a5..0000000 --- a/src/symbols.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* -Copyright (c) 2014-2015->Reset(ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms->Reset(with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice->Reset(this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice->Reset(this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES->Reset(INCLUDING->Reset(BUT NOT LIMITED TO->Reset(THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT->Reset(INDIRECT->Reset(INCIDENTAL->Reset(SPECIAL->Reset(EXEMPLARY->Reset(OR CONSEQUENTIAL DAMAGES -(INCLUDING->Reset(BUT NOT LIMITED TO->Reset(PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE->Reset(DATA->Reset(OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY->Reset(WHETHER IN CONTRACT->Reset(STRICT LIABILITY->Reset(OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE->Reset(EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "symbols.h" - -using namespace v8; -using namespace std; -using namespace node; - -Nan::Persistent Symbols::Dims; -Nan::Persistent Symbols::Begin; -Nan::Persistent Symbols::End; -Nan::Persistent Symbols::Step; -Nan::Persistent Symbols::IsGFor; -Nan::Persistent Symbols::Imag; -Nan::Persistent Symbols::Real; -Nan::Persistent Symbols::Elements; -Nan::Persistent Symbols::Ndims; -Nan::Persistent Symbols::NDims; -Nan::Persistent Symbols::Name; -Nan::Persistent Symbols::Platform; -Nan::Persistent Symbols::Toolkit; -Nan::Persistent Symbols::Compute; -Nan::Persistent Symbols::IsDoubleAvailable; -Nan::Persistent Symbols::Cpu; -Nan::Persistent Symbols::Index; -Nan::Persistent Symbols::Value; -Nan::Persistent Symbols::Keys; -Nan::Persistent Symbols::Values; -Nan::Persistent Symbols::Feat; -Nan::Persistent Symbols::Desc; -Nan::Persistent Symbols::Indices; -Nan::Persistent Symbols::DX; -Nan::Persistent Symbols::DY; -Nan::Persistent Symbols::NumFeatures; -Nan::Persistent Symbols::X; -Nan::Persistent Symbols::Y; -Nan::Persistent Symbols::Score; -Nan::Persistent Symbols::Orientation; -Nan::Persistent Symbols::Size; -Nan::Persistent Symbols::Idx; -Nan::Persistent Symbols::Dist; -Nan::Persistent Symbols::Succeeded; -Nan::Persistent Symbols::Result; -Nan::Persistent Symbols::Upper; -Nan::Persistent Symbols::Lower; -Nan::Persistent Symbols::Pivot; -Nan::Persistent Symbols::Q; -Nan::Persistent Symbols::R; -Nan::Persistent Symbols::Tau; -Nan::Persistent Symbols::FirstIndex; -Nan::Persistent Symbols::LastIndex; -Nan::Persistent Symbols::RowClass; -Nan::Persistent Symbols::RowsClass; -Nan::Persistent Symbols::ColClass; -Nan::Persistent Symbols::ColsClass; -Nan::Persistent Symbols::SliceClass; -Nan::Persistent Symbols::SlicesClass; -Nan::Persistent Symbols::FailedAtRank; -Nan::Persistent Symbols::AFArrayClass; - -void Symbols::Init() -{ - Nan::HandleScope scope; - - Dims.Reset(Nan::New("dims").ToLocalChecked()); - Begin.Reset(Nan::New("begin").ToLocalChecked()); - End.Reset(Nan::New("end").ToLocalChecked()); - Step.Reset(Nan::New("step").ToLocalChecked()); - IsGFor.Reset(Nan::New("isGFor").ToLocalChecked()); - Imag.Reset(Nan::New("imag").ToLocalChecked()); - Real.Reset(Nan::New("real").ToLocalChecked()); - Elements.Reset(Nan::New("elements").ToLocalChecked()); - Ndims.Reset(Nan::New("ndims").ToLocalChecked()); - NDims.Reset(Nan::New("nDims").ToLocalChecked()); - Name.Reset(Nan::New("name").ToLocalChecked()); - Platform.Reset(Nan::New("platform").ToLocalChecked()); - Toolkit.Reset(Nan::New("toolkit").ToLocalChecked()); - Compute.Reset(Nan::New("compute").ToLocalChecked()); - IsDoubleAvailable.Reset(Nan::New("isDoubleAvailable").ToLocalChecked()); - Cpu.Reset(Nan::New("CPU").ToLocalChecked()); - Index.Reset(Nan::New("index").ToLocalChecked()); - Value.Reset(Nan::New("value").ToLocalChecked()); - Keys.Reset(Nan::New("keys").ToLocalChecked()); - Values.Reset(Nan::New("values").ToLocalChecked()); - Feat.Reset(Nan::New("feat").ToLocalChecked()); - Desc.Reset(Nan::New("desc").ToLocalChecked()); - Indices.Reset(Nan::New("indices").ToLocalChecked()); - DX.Reset(Nan::New("dx").ToLocalChecked()); - DY.Reset(Nan::New("dy").ToLocalChecked()); - NumFeatures.Reset(Nan::New("numFeatures").ToLocalChecked()); - X.Reset(Nan::New("x").ToLocalChecked()); - Y.Reset(Nan::New("y").ToLocalChecked()); - Score.Reset(Nan::New("score").ToLocalChecked()); - Orientation.Reset(Nan::New("orientation").ToLocalChecked()); - Size.Reset(Nan::New("size").ToLocalChecked()); - Idx.Reset(Nan::New("idx").ToLocalChecked()); - Dist.Reset(Nan::New("dist").ToLocalChecked()); - Succeeded.Reset(Nan::New("succeeded").ToLocalChecked()); - Result.Reset(Nan::New("result").ToLocalChecked()); - Upper.Reset(Nan::New("upper").ToLocalChecked()); - Lower.Reset(Nan::New("lower").ToLocalChecked()); - Pivot.Reset(Nan::New("pivot").ToLocalChecked()); - Q.Reset(Nan::New("q").ToLocalChecked()); - R.Reset(Nan::New("r").ToLocalChecked()); - Tau.Reset(Nan::New("tau").ToLocalChecked()); - FirstIndex.Reset(Nan::New("firstIndex").ToLocalChecked()); - LastIndex.Reset(Nan::New("lastIndex").ToLocalChecked()); - RowClass.Reset(Nan::New("Row").ToLocalChecked()); - RowsClass.Reset(Nan::New("Rows").ToLocalChecked()); - ColClass.Reset(Nan::New("Col").ToLocalChecked()); - ColsClass.Reset(Nan::New("Cols").ToLocalChecked()); - SliceClass.Reset(Nan::New("Slice").ToLocalChecked()); - SlicesClass.Reset(Nan::New("Slices").ToLocalChecked()); - FailedAtRank.Reset(Nan::New("failedAtRank").ToLocalChecked()); - AFArrayClass.Reset(Nan::New("AFArray").ToLocalChecked()); -} diff --git a/src/symbols.h b/src/symbols.h deleted file mode 100644 index 5df7731..0000000 --- a/src/symbols.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_JS_SYMBOLS_H -#define ARRAYFIRE_JS_SYMBOLS_H - -#include - -struct Symbols -{ - static Nan::Persistent Dims; - static Nan::Persistent Begin; - static Nan::Persistent End; - static Nan::Persistent Step; - static Nan::Persistent IsGFor; - static Nan::Persistent Imag; - static Nan::Persistent Real; - static Nan::Persistent Elements; - static Nan::Persistent Ndims; - static Nan::Persistent NDims; - static Nan::Persistent Name; - static Nan::Persistent Platform; - static Nan::Persistent Toolkit; - static Nan::Persistent Compute; - static Nan::Persistent IsDoubleAvailable; - static Nan::Persistent Cpu; - static Nan::Persistent Index; - static Nan::Persistent Value; - static Nan::Persistent Keys; - static Nan::Persistent Values; - static Nan::Persistent Feat; - static Nan::Persistent Desc; - static Nan::Persistent Indices; - static Nan::Persistent DX; - static Nan::Persistent DY; - static Nan::Persistent NumFeatures; - static Nan::Persistent X; - static Nan::Persistent Y; - static Nan::Persistent Score; - static Nan::Persistent Orientation; - static Nan::Persistent Size; - static Nan::Persistent Idx; - static Nan::Persistent Dist; - static Nan::Persistent Succeeded; - static Nan::Persistent Result; - static Nan::Persistent Upper; - static Nan::Persistent Lower; - static Nan::Persistent Pivot; - static Nan::Persistent Q; - static Nan::Persistent R; - static Nan::Persistent Tau; - static Nan::Persistent FirstIndex; - static Nan::Persistent LastIndex; - static Nan::Persistent RowClass; - static Nan::Persistent RowsClass; - static Nan::Persistent ColClass; - static Nan::Persistent ColsClass; - static Nan::Persistent SliceClass; - static Nan::Persistent SlicesClass; - static Nan::Persistent FailedAtRank; - static Nan::Persistent AFArrayClass; - - static void Init(); -}; - -#endif // ARRAYFIRE_JS_SYMBOLS_H diff --git a/src/vectoralgorithms.cpp b/src/vectoralgorithms.cpp deleted file mode 100644 index 80934a8..0000000 --- a/src/vectoralgorithms.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "ext.h" -#include "mathfunctions.h" -#include "helpers.h" -#include "arraywrapper.h" -#include "errors.h" -#include "guard.h" -#include "worker.h" - -using namespace v8; -using namespace std; -using namespace node; - -AF_ALGO_V1(AllTrue, allTrue) -AF_ALGO_V1(AnyTrue, anyTrue) -AF_ALGO_V1(Count, count) -AF_ALGO_V1(FindMax, max) -AF_ALGO_V1(FindMin, min) -AF_ALGO_V1(Product, product) -AF_ALGO_V1(Sum, sum) -AF_ALGO_V2(FindMinAt, min) -AF_ALGO_V2(FindMaxAt, max) - -NAN_METHOD(Sort) -{ - - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - unsigned dim = 0; - bool asc = true; - if (info.Length() > 1 && info[1]->IsNumber()) - { - dim = info[1]->Uint32Value(); - } - if (info.Length() > 2 && info[2]->IsBoolean()) - { - asc = info[2]->BooleanValue(); - } - Guard guard; - info.GetReturnValue().Set(ArrayWrapper::New(af::sort(*pArray, dim, asc)));; - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(SortByKey) -{ - - try - { - ARGS_LEN(2); - auto pKeys = ArrayWrapper::GetArrayAt(info, 0); - auto pValues = ArrayWrapper::GetArrayAt(info, 1); - unsigned dim = 0; - bool asc = true; - if (info.Length() > 2 && info[2]->IsNumber()) - { - dim = info[2]->Uint32Value(); - } - if (info.Length() > 3 && info[3]->IsBoolean()) - { - asc = info[3]->BooleanValue(); - } - - Guard guard; - af::array outKeys, outValues; - af::sort(outKeys, outValues, *pKeys, *pValues, dim, asc); - - auto result = Nan::New(); - Nan::Set(result, Nan::New(Symbols::Keys), ArrayWrapper::New(outKeys)); - Nan::Set(result, Nan::New(Symbols::Values), ArrayWrapper::New(outValues)); - - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH -} - -NAN_METHOD(SortIndex) -{ - - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - unsigned dim = 0; - bool asc = true; - if (info.Length() > 1 && info[1]->IsNumber()) - { - dim = info[1]->Uint32Value(); - } - if (info.Length() > 2 && info[2]->IsBoolean()) - { - asc = info[2]->BooleanValue(); - } - - Guard guard; - af::array outValues, outIndices; - af::sort(outValues, outIndices, *pArray, dim, asc); - - auto result = Nan::New(); - result->Set(Nan::New(Symbols::Values), ArrayWrapper::New(outValues)); - result->Set(Nan::New(Symbols::Indices), ArrayWrapper::New(outIndices)); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH -} - -AF_ARR_DIM(Accum, accum) -AF_ARR(Where, where) - -AF_ARR_ARR_BOOL(SetIntersect, setIntersect, false) -AF_ARR_ARR_BOOL(SetUnion, setUnion, false) -AF_ARR_BOOL(SetUnique, setUnique, false) -AF_ARR_DIM(Diff1, diff1) -AF_ARR_DIM(Diff2, diff2) - -NAN_METHOD(Grad) -{ - try - { - ARGS_LEN(1); - auto pArray = ArrayWrapper::GetArrayAt(info, 0); - - Guard guard; - af::array dx, dy; - af::grad(dx, dy, *pArray); - - auto result = Nan::New(); - result->Set(Nan::New(Symbols::DX), (ArrayWrapper::New(dx))); - result->Set(Nan::New(Symbols::DY), (ArrayWrapper::New(dy))); - info.GetReturnValue().Set(result); - } - ARRAYFIRE_CATCH -} - -NAN_MODULE_INIT(InitVectorAlgorithms) -{ - Nan::HandleScope scope; - - Nan::Set(target, Nan::New("allTrue").ToLocalChecked(), Nan::New(AllTrue)->GetFunction()); - Nan::Set(target, Nan::New("anyTrue").ToLocalChecked(), Nan::New(AnyTrue)->GetFunction()); - Nan::Set(target, Nan::New("count").ToLocalChecked(), Nan::New(Count)->GetFunction()); - Nan::Set(target, Nan::New("findMax").ToLocalChecked(), Nan::New(FindMax)->GetFunction()); - Nan::Set(target, Nan::New("findMaxAt").ToLocalChecked(), Nan::New(FindMaxAt)->GetFunction()); - Nan::Set(target, Nan::New("findMin").ToLocalChecked(), Nan::New(FindMin)->GetFunction()); - Nan::Set(target, Nan::New("findMinAt").ToLocalChecked(), Nan::New(FindMinAt)->GetFunction()); - Nan::Set(target, Nan::New("product").ToLocalChecked(), Nan::New(Product)->GetFunction()); - Nan::Set(target, Nan::New("sum").ToLocalChecked(), Nan::New(Sum)->GetFunction()); - - Nan::Set(target, Nan::New("sort").ToLocalChecked(), Nan::New(Sort)->GetFunction()); - Nan::Set(target, Nan::New("sortByKey").ToLocalChecked(), Nan::New(SortByKey)->GetFunction()); - Nan::Set(target, Nan::New("sortIndex").ToLocalChecked(), Nan::New(SortIndex)->GetFunction()); - - Nan::Set(target, Nan::New("accum").ToLocalChecked(), Nan::New(Accum)->GetFunction()); - Nan::Set(target, Nan::New("where").ToLocalChecked(), Nan::New(Where)->GetFunction()); - - Nan::Set(target, Nan::New("setIntersect").ToLocalChecked(), Nan::New(SetIntersect)->GetFunction()); - Nan::Set(target, Nan::New("setUnion").ToLocalChecked(), Nan::New(SetUnion)->GetFunction()); - Nan::Set(target, Nan::New("setUnique").ToLocalChecked(), Nan::New(SetUnique)->GetFunction()); - Nan::Set(target, Nan::New("diff1").ToLocalChecked(), Nan::New(Diff1)->GetFunction()); - Nan::Set(target, Nan::New("diff2").ToLocalChecked(), Nan::New(Diff2)->GetFunction()); - Nan::Set(target, Nan::New("grad").ToLocalChecked(), Nan::New(Grad)->GetFunction()); -} diff --git a/src/vectoralgorithms.h b/src/vectoralgorithms.h deleted file mode 100644 index de16b2f..0000000 --- a/src/vectoralgorithms.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAYFIRE_VECTORALGORITHMS_H -#define ARRAYFIRE_VECTORALGORITHMS_H - -#include - -NAN_MODULE_INIT(InitVectorAlgorithms); - -#endif // ARRAYFIRE_VECTORALGORITHMS_H - diff --git a/src/worker.h b/src/worker.h deleted file mode 100644 index 74c51de..0000000 --- a/src/worker.h +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARRAY_ARRAYFIRE_JS_WORKER_H -#define ARRAY_ARRAYFIRE_JS_WORKER_H - -#include -#include -#include -#include "helpers.h" - -inline NAN_METHOD(Noop) -{ - - info.GetReturnValue().SetUndefined(); -} - -template -struct Worker : public Nan::AsyncWorker -{ - typedef std::function ExecuteFunc; - typedef std::function(Worker*, T)> ResultConvFunc; - - Worker(Nan::Callback *callback, const ExecuteFunc& executeFunc, const ResultConvFunc& resultConvFunc) : - Nan::AsyncWorker(callback ? callback : new Nan::Callback(Nan::New(Noop)->GetFunction())), - executeFunc(executeFunc), - resultConvFunc(std::move(ConvResult(resultConvFunc))) - { - } - - Worker(Nan::Callback *callback, const ExecuteFunc& executeFunc) : - Nan::AsyncWorker(callback ? callback : new Nan::Callback(Nan::New(Noop)->GetFunction())), - executeFunc(executeFunc), - resultConvFunc(std::move(ConvResult([](Worker* w, T v) { return Nan::New(v); }))) - { - } - - Worker(Nan::Callback *callback, ExecuteFunc&& executeFunc, const ResultConvFunc& resultConvFunc) : - Nan::AsyncWorker(callback ? callback : new Nan::Callback(Nan::New(Noop)->GetFunction())), - executeFunc(std::move(executeFunc)), - resultConvFunc(std::move(ConvResult(resultConvFunc))) - { - } - - Worker(Nan::Callback *callback, ExecuteFunc&& executeFunc) : - Nan::AsyncWorker(callback ? callback : new Nan::Callback(Nan::New(Noop)->GetFunction())), - executeFunc(std::move(executeFunc)), - resultConvFunc(std::move(ConvResult([](Worker* w, T v) { return Nan::New(v); }))) - { - } - - void Execute() override - { - using namespace std; - try - { - result = executeFunc(); - } - catch(af::exception& ex) - { - SetErrorMessage(ex.what()); - } - catch(std::exception& ex) - { - SetErrorMessage(ex.what()); - } - catch(...) - { - SetErrorMessage("Unknown error!"); - } - } - -protected: - void HandleOKCallback() override - { - using namespace v8; - - auto convertedResult = resultConvFunc(this, result); - if (convertedResult->IsNativeError()) - { - Local info[] = { convertedResult }; - callback->Call(1, info); - } - else - { - Local info[] = { Nan::Null(), convertedResult }; - callback->Call(2, info); - } - } - -private: - ExecuteFunc executeFunc; - ResultConvFunc resultConvFunc; - T result; - - ResultConvFunc ConvResult(const ResultConvFunc& resultConvFunc) - { - return std::move([=](Worker* i, T result) - { - Nan::EscapableHandleScope scope; - try - { - return scope.Escape(resultConvFunc(i, result)); - } - catch(af::exception& ex) - { - return scope.Escape(Nan::Error(ex.what())); - } - catch(std::exception& ex) - { - return scope.Escape(Nan::Error(ex.what())); - } - catch(...) - { - return scope.Escape(Nan::Error("Unknown error!")); - } - }); - } -}; - -template<> -struct Worker : public Nan::AsyncWorker -{ - typedef std::function ExecuteFunc; - - Worker(Nan::Callback *callback, const ExecuteFunc& executeFunc) : - Nan::AsyncWorker(callback ? callback : new Nan::Callback(Nan::New(Noop)->GetFunction())), - executeFunc(executeFunc) - { - } - - Worker(Nan::Callback *callback, ExecuteFunc&& executeFunc) : - Nan::AsyncWorker(callback ? callback : new Nan::Callback(Nan::New(Noop)->GetFunction())), - executeFunc(std::move(executeFunc)) - { - } - - void Execute() override - { - using namespace std; - try - { - executeFunc(); - } - catch(af::exception& ex) - { - SetErrorMessage(ex.what()); - } - catch(exception& ex) - { - SetErrorMessage(ex.what()); - } - catch(...) - { - SetErrorMessage("Unknown error!"); - } - } - -private: - ExecuteFunc executeFunc; -}; - -#endif diff --git a/tests/es5/afArrayTests.js b/tests/es5/afArrayTests.js deleted file mode 100644 index 74e1234..0000000 --- a/tests/es5/afArrayTests.js +++ /dev/null @@ -1,518 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ - -var assert = require("better-assert"); -var _ = require("lodash"); -var ref = require("ref"); -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var testExec = require("./testExec"); -var float = ref.types.float; - -describe("AFArray class and methods", function () { - testExec.run(function (af) { - var AFArray = af.AFArray; - - it("should export AFArray constructor", function () { - assert(_.isFunction(AFArray)); - }); - - it("should create empty", function () { - var array = new AFArray(); - assert(_.isObject(array)); - assert(array.bytes() === 0); - assert(array.elements() === 0); - assert(array.isempty()); - assert(_.isFunction(array.host)); - assert(_.isFunction(array.hostAsync)); - assert(_.isUndefined(array.hostAsyncAsync)); - assert(_.isFunction(array.hostSync)); - assert(_.isUndefined(array.hostSyncAsync)); - assert(_.isUndefined(array.hostSyncSync)); - assert(_.isUndefined(array.hostAsyncSync)); - }); - - it("should fail with one number argument", function () { - try { - var array = new AFArray(1); - assert(false); - } catch (e) {} - }); - - it("should create new one dimensional", function () { - var array = new AFArray(10, af.dType.s32); - assert(_.isObject(array)); - assert(array.bytes() === 10 * 4); - assert(array.elements() === 10); - assert(array.type() === af.dType.s32); - assert(array.numdims() === 1); - assert(array.dims(0) === 10); - assert(array.dims(1) === 1); - assert(array.dims(2) === 1); - assert(array.dims(3) === 1); - var dims = array.dims(); - assert(_.isObject(dims)); - assert(dims.elements === 10); - assert(dims.ndims === 1); - assert(dims.values[0] === 10); - assert(dims.values[1] === 1); - assert(dims.values[2] === 1); - assert(dims.values[3] === 1); - assert(array.isempty() === false); - assert(array.isscalar() === false); - assert(array.isvector() === true); - assert(array.isrow() === false); - assert(array.iscolumn() === true); - assert(array.iscomplex() === false); - assert(array.isreal() === true); - assert(array.isdouble() === false); - assert(array.issingle() === false); - assert(array.isrealfloating() === false); - assert(array.isfloating() === false); - assert(array.isinteger() === true); - assert(array.isbool() === false); - }); - - it("should create new two dimensional", function () { - var array = new AFArray(10, 20, af.dType.f32); - assert(_.isObject(array)); - assert(array.bytes() === 10 * 20 * 4); - assert(array.elements() === 10 * 20); - assert(array.type() === af.dType.f32); - assert(array.numdims() === 2); - assert(array.dims(0) === 10); - assert(array.dims(1) === 20); - assert(array.dims(2) === 1); - assert(array.dims(3) === 1); - var dims = array.dims(); - assert(_.isObject(dims)); - assert(dims.elements === 10 * 20); - assert(dims.ndims === 2); - assert(dims.values[0] === 10); - assert(dims.values[1] === 20); - assert(dims.values[2] === 1); - assert(dims.values[3] === 1); - assert(array.isempty() === false); - assert(array.isscalar() === false); - assert(array.isvector() === false); - assert(array.isrow() === false); - assert(array.iscolumn() === false); - assert(array.iscomplex() === false); - assert(array.isreal() === true); - assert(array.isdouble() === false); - assert(array.issingle() === true); - assert(array.isrealfloating() === true); - assert(array.isfloating() === true); - assert(array.isinteger() === false); - assert(array.isbool() === false); - }); - - it("should create new three dimensional", function () { - var array = new AFArray(10, 20, 30, af.dType.f32); - assert(_.isObject(array)); - assert(array.bytes() === 10 * 20 * 30 * 4); - assert(array.elements() === 10 * 20 * 30); - assert(array.type() === af.dType.f32); - assert(array.numdims() === 3); - assert(array.dims(0) === 10); - assert(array.dims(1) === 20); - assert(array.dims(2) === 30); - assert(array.dims(3) === 1); - var dims = array.dims(); - assert(_.isObject(dims)); - assert(dims.elements === 10 * 20 * 30); - assert(dims.ndims === 3); - assert(dims.values[0] === 10); - assert(dims.values[1] === 20); - assert(dims.values[2] === 30); - assert(dims.values[3] === 1); - assert(array.isempty() === false); - assert(array.isscalar() === false); - assert(array.isvector() === false); - assert(array.isrow() === false); - assert(array.iscolumn() === false); - assert(array.iscomplex() === false); - assert(array.isreal() === true); - assert(array.isdouble() === false); - assert(array.issingle() === true); - assert(array.isrealfloating() === true); - assert(array.isfloating() === true); - assert(array.isinteger() === false); - assert(array.isbool() === false); - }); - - function verify4(array) { - assert(_.isObject(array)); - assert(array.bytes() === 10 * 20 * 30 * 40 * 4); - assert(array.elements() === 10 * 20 * 30 * 40); - assert(array.type() === af.dType.f32); - assert(array.numdims() === 4); - assert(array.dims(0) === 10); - assert(array.dims(1) === 20); - assert(array.dims(2) === 30); - assert(array.dims(3) === 40); - var dims = array.dims(); - assert(_.isObject(dims)); - assert(dims.elements === 10 * 20 * 30 * 40); - assert(dims.ndims === 4); - assert(dims.values[0] === 10); - assert(dims.values[1] === 20); - assert(dims.values[2] === 30); - assert(dims.values[3] === 40); - assert(array.isempty() === false); - assert(array.isscalar() === false); - assert(array.isvector() === false); - assert(array.isrow() === false); - assert(array.iscolumn() === false); - assert(array.iscomplex() === false); - assert(array.isreal() === true); - assert(array.isdouble() === false); - assert(array.issingle() === true); - assert(array.isrealfloating() === true); - assert(array.isfloating() === true); - assert(array.isinteger() === false); - assert(array.isbool() === false); - } - - it("should create new four dimensional", function () { - var array = new AFArray(10, 20, 30, 40, af.dType.f32); - verify4(array); - }); - - it("should create new four dimensional from dim4", function () { - var array = new AFArray({ values: [10, 20, 30, 40] }, af.dType.f32); - verify4(array); - }); - - it("should create new four dimensional from dim4 array", function () { - var array = new AFArray([10, 20, 30, 40], af.dType.f32); - verify4(array); - }); - - it("should initialize from buffer, copyable, and readable - asynchronously w/ generators", function (done) { - var f = async(regeneratorRuntime.mark(function _callee() { - var int, count, buff, _v, array, buff2, _v2, v1, v2, array2, buff3, _v3, v; - - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - int = ref.types.int; - count = 10; - buff = new Buffer(int.size * count); - - for (_v = 0; _v < count; _v++) { - int.set(buff, _v * int.size, _v * _v); - } - - assert(_.isFunction(AFArray.create)); - assert(_.isFunction(AFArray.createAsync)); - - _context.next = 8; - return AFArray.createAsync(count, af.dType.s32, buff); - - case 8: - array = _context.sent; - - assert(array.bytes() === count * int.size); - assert(array.type() === af.dType.s32); - - buff2 = new Buffer(int.size * count); - _context.next = 14; - return array.hostAsync(buff2); - - case 14: - for (_v2 = 0; _v2 < count; _v2++) { - v1 = int.get(buff, _v2 * int.size); - v2 = int.get(buff2, _v2 * int.size); - - assert(v1 === v2); - assert(v1 === _v2 * _v2); - } - - array2 = array.copy(); - - assert(array2 instanceof AFArray); - assert(array2.bytes() === array.bytes()); - _context.next = 20; - return array2.hostAsync(); - - case 20: - buff3 = _context.sent; - - assert(buff3 instanceof Buffer); - assert(buff3.length === int.size * count); - for (_v3 = 0; _v3 < count; _v3++) { - v1 = int.get(buff, _v3 * int.size); - v2 = int.get(buff3, _v3 * int.size); - - assert(v1 === v2); - assert(v1 === _v3 * _v3); - } - - // Let's do some indexing: - v = array2.value(); - - assert(v === 0.0); - - v = array2.at(1).value(); - assert(v === 1.0); - - v = array2.at(2).scalar(); - assert(v === 4.0); - - v = array2.at("end").scalar(); - assert(v === 9.0 * 9.0); - - v = array2.at(af.end - 1).scalar(); - assert(v === 8.0 * 8.0); - - case 34: - case "end": - return _context.stop(); - } - } - }, _callee, this); - })); - f().nodeify(done); - }); - - it("should initialize from buffer, copyable, and readable - synchronously (blocking)", function () { - var int = ref.types.int; - var count = 10; - var buff = new Buffer(int.size * count); - for (var _v4 = 0; _v4 < count; _v4++) { - int.set(buff, _v4 * int.size, _v4 * _v4); - } - - assert(_.isFunction(AFArray.create)); - assert(_.isFunction(AFArray.createSync)); - - var array = AFArray.createSync(count, af.dType.s32, buff); - assert(array.bytes() === count * int.size); - assert(array.type() === af.dType.s32); - - var buff2 = new Buffer(int.size * count); - array.hostSync(buff2); - for (var _v5 = 0; _v5 < count; _v5++) { - var _v6 = int.get(buff, _v5 * int.size); - var _v7 = int.get(buff2, _v5 * int.size); - assert(_v6 === _v7); - assert(_v6 === _v5 * _v5); - } - - var array2 = array.copy(); - assert(array2 instanceof AFArray); - assert(array2.bytes() === array.bytes()); - var buff3 = array2.hostSync(); - assert(buff3 instanceof Buffer); - assert(buff3.length === int.size * count); - for (var _v8 = 0; _v8 < count; _v8++) { - var _v9 = int.get(buff, _v8 * int.size); - var _v10 = int.get(buff3, _v8 * int.size); - assert(_v9 === _v10); - assert(_v9 === _v8 * _v8); - } - - // Let's do some indexing: - var v = array2.value(); - assert(v === 0.0); - - v = array.at(1).value(); - assert(v === 1.0); - - v = array2.at(2).scalar(); - assert(v === 4.0); - - v = array2.at("end").scalar(); - assert(v === 9.0 * 9.0); - - v = array2.at(af.end - 1).scalar(); - assert(v === 8.0 * 8.0); - }); - - it("should be created of a part of another with new dimensions", function (done) { - async(regeneratorRuntime.mark(function _callee2() { - var arr, sub, sub2, buff; - return regeneratorRuntime.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - arr = new af.AFArray(10, af.dType.f32); - - arr.set(new af.Col(0), 0); - arr.set(3, 1); - arr.set(4, 2); - - sub = arr.at(new af.Seq(3, 6)); - sub2 = new af.AFArray(sub, new af.Dim4(2, 2)); - _context2.next = 8; - return sub2.hostAsync(); - - case 8: - buff = _context2.sent; - - assert(float.get(buff, 0 * float.size) === 1); - assert(float.get(buff, 1 * float.size) === 2); - - arr.set(3, 2); - arr.set(4, 3); - - _context2.next = 15; - return sub2.hostAsync(); - - case 15: - buff = _context2.sent; - - assert(float.get(buff, 0 * float.size) === 1); - assert(float.get(buff, 1 * float.size) === 2); - - case 18: - case "end": - return _context2.stop(); - } - } - }, _callee2, this); - }))().nodeify(done); - }); - - it("should be multiplied by scalar", function (done) { - async(regeneratorRuntime.mark(function _callee3() { - var arr, result, offset, value; - return regeneratorRuntime.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - arr = af.constant(2.0, 10, 10, af.dType.f32); - - assert(!arr.isScalar()); - _context3.next = 4; - return arr.mul(2).hostAsync(); - - case 4: - result = _context3.sent; - - assert(result.length === float.size * 10 * 10); - for (offset = 0; offset < result.length; offset += float.size) { - value = float.get(result, offset); - - assert(value === 4); - } - - case 7: - case "end": - return _context3.stop(); - } - } - }, _callee3, this); - }))().nodeify(done); - }); - - describe("RAII", function () { - describe("scope", function () { - it("should exported as a function", function () { - assert(_.isFunction(af.scope)); - }); - - it("should support RAII interface", function () { - assert(_.isFunction(af.scope.begin)); - assert(_.isFunction(af.scope.end)); - assert(_.isFunction(af.scope.result)); - assert(_.isFunction(af.scope.register)); - }); - - it("should destroy temporaries (sync)", function () { - var arr = undefined, - sub = undefined; - var x = af.scope(function () { - assert(this === af.scope); - arr = new af.AFArray(10, af.dType.f32); - arr.set(new af.Col(0), 0); - arr.set(3, 1); - arr.set(4, 2); - - sub = arr.at(new af.Seq(3, 6)); - - this.result(arr); - - return 1; - }); - - assert(x === 1); - - arr.set(3, 2); - - try { - sub.set(0, 2); - assert(false); - } catch (e) { - if (!/free\(\)/.test(e.message)) { - throw e; - } - } - }); - - it("should destroy registered arrays", function () { - var arr = new af.AFArray(10, af.dType.f32); - arr.set(new af.Col(0), 0); - arr.set(3, 1); - arr.set(4, 2); - - var sub = arr.at(new af.Seq(3, 6)); - - af.scope(function () { - assert(this === af.scope); - - sub.set(0, 0); - - // Part of the scope, hence will be destroyed. - this.register(sub); - }); - - arr.set(3, 2); - - try { - sub.set(0, 2); - assert(false); - } catch (e) { - if (!/free\(\)/.test(e.message)) { - throw e; - } - } - }); - }); - }); - }); -}); -//# sourceMappingURL=afArrayTests.js.map diff --git a/tests/es5/afArrayTests.js.map b/tests/es5/afArrayTests.js.map deleted file mode 100644 index 271d17b..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AE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC3C,uBAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,uBAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,uBAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;;AAEd,wBAAI,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;;AAEnC,sBAAE,CAAC,KAAK,CAAC,YAAY;AACjB,8BAAM,CAAC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;;AAE1B,2BAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;;;AAAC,AAGd,4BAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACtB,CAAC,CAAC;;AAEH,uBAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;;AAEd,wBAAI;AACA,2BAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,8BAAM,CAAC,KAAK,CAAC,CAAC;qBACjB,CACD,OAAO,CAAC,EAAE;AACN,4BAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE;AAC7B,kCAAM,CAAC,CAAC;yBACX;qBACJ;iBACJ,CAAC,CAAC;aACN,CAAC,CAAC;SACN,CAAC,CAAC;KACN,CAAC,CAAC;CACN,CAAC,CAAC","file":"afArrayTests.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n/* global describe,it */\r\nlet assert = require(\"better-assert\");\r\nlet _ = require(\"lodash\");\r\nlet ref = require(\"ref\");\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet testExec = require(\"./testExec\");\r\nlet float = ref.types.float;\r\n\r\ndescribe(\"AFArray class and methods\", function () {\r\n testExec.run(function (af) {\r\n let AFArray = af.AFArray;\r\n\r\n it(\"should export AFArray constructor\", function () {\r\n assert(_.isFunction(AFArray));\r\n });\r\n\r\n it(\"should create empty\", function () {\r\n let array = new AFArray();\r\n assert(_.isObject(array));\r\n assert(array.bytes() === 0);\r\n assert(array.elements() === 0);\r\n assert(array.isempty());\r\n assert(_.isFunction(array.host));\r\n assert(_.isFunction(array.hostAsync));\r\n assert(_.isUndefined(array.hostAsyncAsync));\r\n assert(_.isFunction(array.hostSync));\r\n assert(_.isUndefined(array.hostSyncAsync));\r\n assert(_.isUndefined(array.hostSyncSync));\r\n assert(_.isUndefined(array.hostAsyncSync));\r\n });\r\n\r\n it(\"should fail with one number argument\", function () {\r\n try {\r\n let array = new AFArray(1);\r\n assert(false);\r\n }\r\n catch (e) {\r\n }\r\n });\r\n\r\n it(\"should create new one dimensional\", function () {\r\n let array = new AFArray(10, af.dType.s32);\r\n assert(_.isObject(array));\r\n assert(array.bytes() === 10 * 4);\r\n assert(array.elements() === 10);\r\n assert(array.type() === af.dType.s32);\r\n assert(array.numdims() === 1);\r\n assert(array.dims(0) === 10);\r\n assert(array.dims(1) === 1);\r\n assert(array.dims(2) === 1);\r\n assert(array.dims(3) === 1);\r\n let dims = array.dims();\r\n assert(_.isObject(dims));\r\n assert(dims.elements === 10);\r\n assert(dims.ndims === 1);\r\n assert(dims.values[0] === 10);\r\n assert(dims.values[1] === 1);\r\n assert(dims.values[2] === 1);\r\n assert(dims.values[3] === 1);\r\n assert(array.isempty() === false);\r\n assert(array.isscalar() === false);\r\n assert(array.isvector() === true);\r\n assert(array.isrow() === false);\r\n assert(array.iscolumn() === true);\r\n assert(array.iscomplex() === false);\r\n assert(array.isreal() === true);\r\n assert(array.isdouble() === false);\r\n assert(array.issingle() === false);\r\n assert(array.isrealfloating() === false);\r\n assert(array.isfloating() === false);\r\n assert(array.isinteger() === true);\r\n assert(array.isbool() === false);\r\n });\r\n\r\n it(\"should create new two dimensional\", function () {\r\n let array = new AFArray(10, 20, af.dType.f32);\r\n assert(_.isObject(array));\r\n assert(array.bytes() === 10 * 20 * 4);\r\n assert(array.elements() === 10 * 20);\r\n assert(array.type() === af.dType.f32);\r\n assert(array.numdims() === 2);\r\n assert(array.dims(0) === 10);\r\n assert(array.dims(1) === 20);\r\n assert(array.dims(2) === 1);\r\n assert(array.dims(3) === 1);\r\n let dims = array.dims();\r\n assert(_.isObject(dims));\r\n assert(dims.elements === 10 * 20);\r\n assert(dims.ndims === 2);\r\n assert(dims.values[0] === 10);\r\n assert(dims.values[1] === 20);\r\n assert(dims.values[2] === 1);\r\n assert(dims.values[3] === 1);\r\n assert(array.isempty() === false);\r\n assert(array.isscalar() === false);\r\n assert(array.isvector() === false);\r\n assert(array.isrow() === false);\r\n assert(array.iscolumn() === false);\r\n assert(array.iscomplex() === false);\r\n assert(array.isreal() === true);\r\n assert(array.isdouble() === false);\r\n assert(array.issingle() === true);\r\n assert(array.isrealfloating() === true);\r\n assert(array.isfloating() === true);\r\n assert(array.isinteger() === false);\r\n assert(array.isbool() === false);\r\n });\r\n\r\n it(\"should create new three dimensional\", function () {\r\n let array = new AFArray(10, 20, 30, af.dType.f32);\r\n assert(_.isObject(array));\r\n assert(array.bytes() === 10 * 20 * 30 * 4);\r\n assert(array.elements() === 10 * 20 * 30);\r\n assert(array.type() === af.dType.f32);\r\n assert(array.numdims() === 3);\r\n assert(array.dims(0) === 10);\r\n assert(array.dims(1) === 20);\r\n assert(array.dims(2) === 30);\r\n assert(array.dims(3) === 1);\r\n let dims = array.dims();\r\n assert(_.isObject(dims));\r\n assert(dims.elements === 10 * 20 * 30);\r\n assert(dims.ndims === 3);\r\n assert(dims.values[0] === 10);\r\n assert(dims.values[1] === 20);\r\n assert(dims.values[2] === 30);\r\n assert(dims.values[3] === 1);\r\n assert(array.isempty() === false);\r\n assert(array.isscalar() === false);\r\n assert(array.isvector() === false);\r\n assert(array.isrow() === false);\r\n assert(array.iscolumn() === false);\r\n assert(array.iscomplex() === false);\r\n assert(array.isreal() === true);\r\n assert(array.isdouble() === false);\r\n assert(array.issingle() === true);\r\n assert(array.isrealfloating() === true);\r\n assert(array.isfloating() === true);\r\n assert(array.isinteger() === false);\r\n assert(array.isbool() === false);\r\n });\r\n\r\n function verify4(array) {\r\n assert(_.isObject(array));\r\n assert(array.bytes() === 10 * 20 * 30 * 40 * 4);\r\n assert(array.elements() === 10 * 20 * 30 * 40);\r\n assert(array.type() === af.dType.f32);\r\n assert(array.numdims() === 4);\r\n assert(array.dims(0) === 10);\r\n assert(array.dims(1) === 20);\r\n assert(array.dims(2) === 30);\r\n assert(array.dims(3) === 40);\r\n let dims = array.dims();\r\n assert(_.isObject(dims));\r\n assert(dims.elements === 10 * 20 * 30 * 40);\r\n assert(dims.ndims === 4);\r\n assert(dims.values[0] === 10);\r\n assert(dims.values[1] === 20);\r\n assert(dims.values[2] === 30);\r\n assert(dims.values[3] === 40);\r\n assert(array.isempty() === false);\r\n assert(array.isscalar() === false);\r\n assert(array.isvector() === false);\r\n assert(array.isrow() === false);\r\n assert(array.iscolumn() === false);\r\n assert(array.iscomplex() === false);\r\n assert(array.isreal() === true);\r\n assert(array.isdouble() === false);\r\n assert(array.issingle() === true);\r\n assert(array.isrealfloating() === true);\r\n assert(array.isfloating() === true);\r\n assert(array.isinteger() === false);\r\n assert(array.isbool() === false);\r\n }\r\n\r\n it(\"should create new four dimensional\", function () {\r\n let array = new AFArray(10, 20, 30, 40, af.dType.f32);\r\n verify4(array);\r\n });\r\n\r\n it(\"should create new four dimensional from dim4\", function () {\r\n let array = new AFArray({values: [10, 20, 30, 40]}, af.dType.f32);\r\n verify4(array);\r\n });\r\n\r\n it(\"should create new four dimensional from dim4 array\", function () {\r\n let array = new AFArray([10, 20, 30, 40], af.dType.f32);\r\n verify4(array);\r\n });\r\n\r\n it(\"should initialize from buffer, copyable, and readable - asynchronously w/ generators\", function (done) {\r\n let f = async(function*() {\r\n let int = ref.types.int;\r\n const count = 10;\r\n let buff = new Buffer(int.size * count);\r\n for (let v = 0; v < count; v++) {\r\n int.set(buff, v * int.size, v * v);\r\n }\r\n\r\n assert(_.isFunction(AFArray.create));\r\n assert(_.isFunction(AFArray.createAsync));\r\n\r\n let array = yield AFArray.createAsync(count, af.dType.s32, buff);\r\n assert(array.bytes() === count * int.size);\r\n assert(array.type() === af.dType.s32);\r\n\r\n let buff2 = new Buffer(int.size * count);\r\n yield array.hostAsync(buff2);\r\n for (let v = 0; v < count; v++) {\r\n let v1 = int.get(buff, v * int.size);\r\n let v2 = int.get(buff2, v * int.size);\r\n assert(v1 === v2);\r\n assert(v1 === v * v);\r\n }\r\n\r\n let array2 = array.copy();\r\n assert(array2 instanceof AFArray);\r\n assert(array2.bytes() === array.bytes());\r\n let buff3 = yield array2.hostAsync();\r\n assert(buff3 instanceof Buffer);\r\n assert(buff3.length === int.size * count);\r\n for (let v = 0; v < count; v++) {\r\n let v1 = int.get(buff, v * int.size);\r\n let v2 = int.get(buff3, v * int.size);\r\n assert(v1 === v2);\r\n assert(v1 === v * v);\r\n }\r\n\r\n // Let's do some indexing:\r\n let v = array2.value();\r\n assert(v === 0.0);\r\n\r\n v = array2.at(1).value();\r\n assert(v === 1.0);\r\n\r\n v = array2.at(2).scalar();\r\n assert(v === 4.0);\r\n\r\n v = array2.at(\"end\").scalar();\r\n assert(v === 9.0 * 9.0);\r\n\r\n v = array2.at(af.end - 1).scalar();\r\n assert(v === 8.0 * 8.0);\r\n });\r\n f().nodeify(done);\r\n });\r\n\r\n it(\"should initialize from buffer, copyable, and readable - synchronously (blocking)\", function () {\r\n let int = ref.types.int;\r\n const count = 10;\r\n let buff = new Buffer(int.size * count);\r\n for (let v = 0; v < count; v++) {\r\n int.set(buff, v * int.size, v * v);\r\n }\r\n\r\n assert(_.isFunction(AFArray.create));\r\n assert(_.isFunction(AFArray.createSync));\r\n\r\n let array = AFArray.createSync(count, af.dType.s32, buff);\r\n assert(array.bytes() === count * int.size);\r\n assert(array.type() === af.dType.s32);\r\n\r\n let buff2 = new Buffer(int.size * count);\r\n array.hostSync(buff2);\r\n for (let v = 0; v < count; v++) {\r\n let v1 = int.get(buff, v * int.size);\r\n let v2 = int.get(buff2, v * int.size);\r\n assert(v1 === v2);\r\n assert(v1 === v * v);\r\n }\r\n\r\n let array2 = array.copy();\r\n assert(array2 instanceof AFArray);\r\n assert(array2.bytes() === array.bytes());\r\n let buff3 = array2.hostSync();\r\n assert(buff3 instanceof Buffer);\r\n assert(buff3.length === int.size * count);\r\n for (let v = 0; v < count; v++) {\r\n let v1 = int.get(buff, v * int.size);\r\n let v2 = int.get(buff3, v * int.size);\r\n assert(v1 === v2);\r\n assert(v1 === v * v);\r\n }\r\n\r\n // Let's do some indexing:\r\n let v = array2.value();\r\n assert(v === 0.0);\r\n\r\n v = array.at(1).value();\r\n assert(v === 1.0);\r\n\r\n v = array2.at(2).scalar();\r\n assert(v === 4.0);\r\n\r\n v = array2.at(\"end\").scalar();\r\n assert(v === 9.0 * 9.0);\r\n\r\n v = array2.at(af.end - 1).scalar();\r\n assert(v === 8.0 * 8.0);\r\n });\r\n\r\n it(\"should be created of a part of another with new dimensions\", function (done) {\r\n async(function* () {\r\n let arr = new af.AFArray(10, af.dType.f32);\r\n arr.set(new af.Col(0), 0);\r\n arr.set(3, 1);\r\n arr.set(4, 2);\r\n\r\n let sub = arr.at(new af.Seq(3, 6));\r\n let sub2 = new af.AFArray(sub, new af.Dim4(2, 2));\r\n\r\n let buff = yield sub2.hostAsync();\r\n\r\n assert(float.get(buff, 0 * float.size) === 1);\r\n assert(float.get(buff, 1 * float.size) === 2);\r\n\r\n arr.set(3, 2);\r\n arr.set(4, 3);\r\n\r\n buff = yield sub2.hostAsync();\r\n\r\n assert(float.get(buff, 0 * float.size) === 1);\r\n assert(float.get(buff, 1 * float.size) === 2);\r\n })().nodeify(done);\r\n });\r\n\r\n it(\"should be multiplied by scalar\", function (done) {\r\n async(function* () {\r\n let arr = af.constant(2.0, 10, 10, af.dType.f32);\r\n assert(!arr.isScalar());\r\n let result = yield arr.mul(2).hostAsync();\r\n assert(result.length === float.size * 10 * 10);\r\n for (let offset = 0; offset < result.length; offset += float.size) {\r\n let value = float.get(result, offset);\r\n assert(value === 4);\r\n }\r\n })().nodeify(done);\r\n });\r\n\r\n describe(\"RAII\", function () {\r\n describe(\"scope\", function () {\r\n it(\"should exported as a function\", function () {\r\n assert(_.isFunction(af.scope));\r\n });\r\n\r\n it(\"should support RAII interface\", function () {\r\n assert(_.isFunction(af.scope.begin));\r\n assert(_.isFunction(af.scope.end));\r\n assert(_.isFunction(af.scope.result));\r\n assert(_.isFunction(af.scope.register));\r\n });\r\n\r\n it(\"should destroy temporaries (sync)\", function () {\r\n let arr, sub;\r\n let x = af.scope(function () {\r\n assert(this === af.scope);\r\n arr = new af.AFArray(10, af.dType.f32);\r\n arr.set(new af.Col(0), 0);\r\n arr.set(3, 1);\r\n arr.set(4, 2);\r\n\r\n sub = arr.at(new af.Seq(3, 6));\r\n\r\n this.result(arr);\r\n\r\n return 1;\r\n });\r\n\r\n assert(x === 1);\r\n\r\n arr.set(3, 2);\r\n\r\n try {\r\n sub.set(0, 2);\r\n assert(false);\r\n }\r\n catch (e) {\r\n if (!/free\\(\\)/.test(e.message)) {\r\n throw e;\r\n }\r\n }\r\n });\r\n\r\n it(\"should destroy registered arrays\", function () {\r\n let arr = new af.AFArray(10, af.dType.f32);\r\n arr.set(new af.Col(0), 0);\r\n arr.set(3, 1);\r\n arr.set(4, 2);\r\n\r\n let sub = arr.at(new af.Seq(3, 6));\r\n\r\n af.scope(function () {\r\n assert(this === af.scope);\r\n\r\n sub.set(0, 0);\r\n\r\n // Part of the scope, hence will be destroyed.\r\n this.register(sub);\r\n });\r\n\r\n arr.set(3, 2);\r\n\r\n try {\r\n sub.set(0, 2);\r\n assert(false);\r\n }\r\n catch (e) {\r\n if (!/free\\(\\)/.test(e.message)) {\r\n throw e;\r\n }\r\n }\r\n });\r\n });\r\n });\r\n });\r\n});"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es5/createArrayFunctionTests.js b/tests/es5/createArrayFunctionTests.js deleted file mode 100644 index be159e8..0000000 --- a/tests/es5/createArrayFunctionTests.js +++ /dev/null @@ -1,165 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ - -var assert = require("better-assert"); -var _ = require("lodash"); -var ref = require("ref"); -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var int = ref.types.int; -var float = ref.types.float; -var testExec = require("./testExec"); - -describe("Functions to create arrays", function () { - testExec.run(function (af) { - describe("randu", function () { - it("should yield uniform random int array with 2 dimensions", function (done) { - var f = async(regeneratorRuntime.mark(function _callee() { - var array, data, i, v; - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - array = af.randu(2, 4, af.dType.s32); - _context.next = 3; - return array.copyToHostAsync(); - - case 3: - data = _context.sent; - - assert(data instanceof Buffer); - assert(data.length == 2 * 4 * int.size); - - for (i = 0; i < data.length / int.size; i++) { - v = int.get(data, i * int.size); - - assert(v >= Number.MIN_SAFE_INTEGER && v <= Number.MAX_SAFE_INTEGER); - assert(Math.floor(v) === v); - } - - case 7: - case "end": - return _context.stop(); - } - } - }, _callee, this); - })); - f().nodeify(done); - }); - it("should yield uniform random float array with 2 dimensions", function (done) { - var f = async(regeneratorRuntime.mark(function _callee2() { - var array, data, _i, _v; - - return regeneratorRuntime.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - array = af.randu([2, 4], af.dType.f32); - _context2.next = 3; - return array.copyToHostAsync(); - - case 3: - data = _context2.sent; - - assert(data instanceof Buffer); - assert(data.length == 2 * 4 * float.size); - - for (_i = 0; _i < data.length / float.size; _i++) { - _v = float.get(data, _i * float.size); - - assert(_v === 0 || _v === 1.0 || _v > 0 && _v < 1.0 && _v % 1); - } - - case 7: - case "end": - return _context2.stop(); - } - } - }, _callee2, this); - })); - f().nodeify(done); - }); - }); - - describe("randf", function () { - it("should throw error when invoking normal random int array with 2 dimensions", function () { - try { - var array = af.randn(2, 4, af.dType.s32); - return; - } catch (e) { - if (/invalid dtype argument/ig.test(e.message)) { - return; - } else { - throw new Error("This should throw appropriate error."); - } - } - throw new Error("This should throw."); - }); - it("should yield normal random float array with 2 dimensions", function (done) { - var f = async(regeneratorRuntime.mark(function _callee3() { - var array, data, _i2, _v2; - - return regeneratorRuntime.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - array = af.randn([2, 4], af.dType.f32); - _context3.next = 3; - return array.copyToHostAsync(); - - case 3: - data = _context3.sent; - - assert(data instanceof Buffer); - assert(data.length == 2 * 4 * float.size); - - for (_i2 = 0; _i2 < data.length / float.size; _i2++) { - _v2 = float.get(data, _i2 * float.size); - - assert(_v2 === 0 || _v2 > -4.0 && _v2 < 4.0 && _v2 % 1); - } - - case 7: - case "end": - return _context3.stop(); - } - } - }, _callee3, this); - })); - f().nodeify(done); - }); - }); - }); -}); -//# sourceMappingURL=createArrayFunctionTests.js.map diff --git a/tests/es5/createArrayFunctionTests.js.map b/tests/es5/createArrayFunctionTests.js.map deleted file mode 100644 index a7386c7..0000000 --- a/tests/es5/createArrayFunctionTests.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["createArrayFunctionTests.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY;;AAAC;AAEb,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACtC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC;AAC/B,IAAI,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AACxB,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;AAC5B,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;;AAErC,QAAQ,CAAC,4BAA4B,EAAE,YAAY;AAC/C,YAAQ,CAAC,GAAG,CAAC,UAAS,EAAE,EAAE;AACtB,gBAAQ,CAAC,OAAO,EAAE,YAAY;AAC1B,cAAE,CAAC,yDAAyD,EAAE,UAAU,IAAI,EAAE;AAC1E,oBAAI,CAAC,GAAG,KAAK,yBAAC;wBACN,KAAK,EACL,IAAI,EAIC,CAAC,EACA,CAAC;;;;;AANP,yCAAK,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC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wCAAI;;AACR,0CAAM,CAAC,IAAI,YAAY,MAAM,CAAC,CAAC;AAC/B,0CAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;;AAE1C,yCAAS,GAAC,GAAG,CAAC,EAAE,GAAC,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,GAAC,EAAE,EAAE;AACzC,2CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAC,GAAG,KAAK,CAAC,IAAI,CAAC;;AACzC,8CAAM,CAAC,GAAC,KAAK,CAAC,IAAK,GAAC,GAAG,CAAC,GAAG,IAAI,GAAC,GAAG,GAAG,IAAI,GAAC,GAAG,CAAC,AAAC,CAAC,CAAC;qCACrD;;;;;;;;iBACJ,EAAC,CAAC;AACH,iBAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aACrB,CAAC,CAAC;SACN,CAAC,CAAC;KACN,CAAC,CAAC;CACN,CAAC,CAAC","file":"createArrayFunctionTests.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n/* global describe,it */\r\nlet assert = require(\"better-assert\");\r\nlet _ = require(\"lodash\");\r\nlet ref = require(\"ref\");\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet int = ref.types.int;\r\nlet float = ref.types.float;\r\nlet testExec = require(\"./testExec\");\r\n\r\ndescribe(\"Functions to create arrays\", function () {\r\n testExec.run(function(af) {\r\n describe(\"randu\", function () {\r\n it(\"should yield uniform random int array with 2 dimensions\", function (done) {\r\n let f = async(function*() {\r\n let array = af.randu(2, 4, af.dType.s32);\r\n let data = yield array.copyToHostAsync();\r\n assert(data instanceof Buffer);\r\n assert(data.length == 2 * 4 * int.size);\r\n\r\n for (let i = 0; i < data.length / int.size; i++) {\r\n const v = int.get(data, i * int.size);\r\n assert(v >= Number.MIN_SAFE_INTEGER && v <= Number.MAX_SAFE_INTEGER);\r\n assert(Math.floor(v) === v);\r\n }\r\n });\r\n f().nodeify(done);\r\n });\r\n it(\"should yield uniform random float array with 2 dimensions\", function (done) {\r\n let f = async(function*() {\r\n let array = af.randu([2, 4], af.dType.f32);\r\n let data = yield array.copyToHostAsync();\r\n assert(data instanceof Buffer);\r\n assert(data.length == 2 * 4 * float.size);\r\n\r\n for (let i = 0; i < data.length / float.size; i++) {\r\n const v = float.get(data, i * float.size);\r\n assert(v === 0 || v === 1.0 || (v > 0 && v < 1.0 && v % 1));\r\n }\r\n });\r\n f().nodeify(done);\r\n });\r\n });\r\n\r\n describe(\"randf\", function () {\r\n it(\"should throw error when invoking normal random int array with 2 dimensions\", function () {\r\n try {\r\n let array = af.randn(2, 4, af.dType.s32);\r\n return;\r\n }\r\n catch(e) {\r\n if (/invalid dtype argument/ig.test(e.message)) {\r\n return;\r\n }\r\n else {\r\n throw new Error(\"This should throw appropriate error.\");\r\n }\r\n }\r\n throw new Error(\"This should throw.\");\r\n\r\n });\r\n it(\"should yield normal random float array with 2 dimensions\", function (done) {\r\n let f = async(function*() {\r\n let array = af.randn([2, 4], af.dType.f32);\r\n let data = yield array.copyToHostAsync();\r\n assert(data instanceof Buffer);\r\n assert(data.length == 2 * 4 * float.size);\r\n\r\n for (let i = 0; i < data.length / float.size; i++) {\r\n const v = float.get(data, i * float.size);\r\n assert(v === 0 || (v > -4.0 && v < 4.0 && v % 1));\r\n }\r\n });\r\n f().nodeify(done);\r\n });\r\n });\r\n });\r\n});"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es5/deviceTests.js b/tests/es5/deviceTests.js deleted file mode 100644 index 57fb322..0000000 --- a/tests/es5/deviceTests.js +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ - -var assert = require("better-assert"); -var _ = require("lodash"); -var Bluebird = require("bluebird"); -var testExec = require("./testExec"); - -describe("device methods", function () { - testExec.run(function (af) { - it("should return available devices", function () { - var deviceCount = af.getDeviceCount(); - assert(deviceCount > 0); - var infos = af.getDevices(); - assert(_.isArray(infos)); - assert(infos.length === deviceCount); - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = infos[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var info = _step.value; - - assert(_.isString(info.name) && info.name); - assert(_.isString(info.platform) && info.platform); - assert(_.isString(info.compute) && info.compute); - assert(_.isBoolean(info.isDoubleAvailable)); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - }); - - it("should do sync with callback", function (done) { - af.sync(done); - }); - - it("should do sync with promise", function (done) { - af.syncAsync().nodeify(done); - }); - - it("sync should failed if device is out of range", function (done) { - af.syncAsync(100).then(function () { - done(new Error("This should fail!")); - }, function () { - done(); - }); - }); - }); -}); -//# sourceMappingURL=deviceTests.js.map diff --git a/tests/es5/deviceTests.js.map b/tests/es5/deviceTests.js.map deleted file mode 100644 index 6a9ede1..0000000 --- a/tests/es5/deviceTests.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["deviceTests.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY;;AAAC;AAEb,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACtC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;;AAErC,QAAQ,CAAC,gBAAgB,EAAE,YAAW;AAClC,YAAQ,CAAC,GAAG,CAAC,UAAS,EAAE,EAAE;AACtB,UAAE,CAAC,iCAAiC,EAAE,YAAW;AAC7C,gBAAI,WAAW,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC;AACtC,kBAAM,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;AACxB,gBAAI,KAAK,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC;AAC5B,kBAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACzB,kBAAM,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC;;;;;;AACrC,qCAAiB,KAAK,8HAAE;wBAAf,IAAI;;AACT,0BAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3C,0BAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;AACnD,0BAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;AACjD,0BAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;iBAC/C;;;;;;;;;;;;;;;SACJ,CAAC,CAAC;;AAEH,UAAE,CAAC,8BAA8B,EAAE,UAAS,IAAI,EAAE;AAC9C,cAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACjB,CAAC,CAAC;;AAEH,UAAE,CAAC,6BAA6B,EAAE,UAAS,IAAI,EAAE;AAC7C,cAAE,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAChC,CAAC,CAAC;;AAEH,UAAE,CAAC,8CAA8C,EAAE,UAAS,IAAI,EAAE;AAC9D,cAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CACZ,IAAI,CAAC,YAAW;AACb,oBAAI,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;aACxC,EACD,YAAW;AACP,oBAAI,EAAE,CAAC;aACV,CAAC,CAAC;SACV,CAAC,CAAC;KACN,CAAC,CAAC;CACN,CAAC,CAAC","file":"deviceTests.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n/* global describe,it */\r\nlet assert = require(\"better-assert\");\r\nlet _ = require(\"lodash\");\r\nlet Bluebird = require(\"bluebird\");\r\nlet testExec = require(\"./testExec\");\r\n\r\ndescribe(\"device methods\", function() {\r\n testExec.run(function(af) {\r\n it(\"should return available devices\", function() {\r\n let deviceCount = af.getDeviceCount();\r\n assert(deviceCount > 0);\r\n let infos = af.getDevices();\r\n assert(_.isArray(infos));\r\n assert(infos.length === deviceCount);\r\n for (let info of infos) {\r\n assert(_.isString(info.name) && info.name);\r\n assert(_.isString(info.platform) && info.platform);\r\n assert(_.isString(info.compute) && info.compute);\r\n assert(_.isBoolean(info.isDoubleAvailable));\r\n }\r\n });\r\n\r\n it(\"should do sync with callback\", function(done) {\r\n af.sync(done);\r\n });\r\n\r\n it(\"should do sync with promise\", function(done) {\r\n af.syncAsync().nodeify(done);\r\n });\r\n\r\n it(\"sync should failed if device is out of range\", function(done) {\r\n af.syncAsync(100)\r\n .then(function() {\r\n done(new Error(\"This should fail!\"));\r\n },\r\n function() {\r\n done();\r\n });\r\n });\r\n });\r\n});\r\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es5/gfor.js b/tests/es5/gfor.js deleted file mode 100644 index 555aeba..0000000 --- a/tests/es5/gfor.js +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ - -var assert = require("better-assert"); -var _ = require("lodash"); -var ref = require("ref"); -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var testExec = require("./testExec"); -var float = ref.types.float; - -describe("gfor", function () { - testExec.run(function (af) { - it("should work", function () { - af.scope(function () { - var count = 20; - var arr = af.constant(0.0, count, 10, af.dType.f32); - var val = af.range(new af.Dim4(1, 10), 1, af.dType.f32); - af.gfor(count, function (seq) { - assert(seq instanceof af.Seq); - assert(seq.begin === 0); - assert(seq.end === 19); - assert(seq.isGFor); - arr.assign(seq, af.span, val); - }); - for (var idx = 0; idx < count; idx++) { - var sum = af.sum(arr.at(idx, af.span)); - assert(sum === 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9); - } - }); - }); - }); -}); -//# sourceMappingURL=gfor.js.map diff --git a/tests/es5/gfor.js.map b/tests/es5/gfor.js.map deleted file mode 100644 index 8c994dc..0000000 --- a/tests/es5/gfor.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["gfor.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY;;AAAC;AAEb,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACtC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC;AAC/B,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACrC,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;;AAE5B,QAAQ,CAAC,MAAM,EAAE,YAAY;AACzB,YAAQ,CAAC,GAAG,CAAC,UAAU,EA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N,CAAC,CAAC","file":"gfor.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n/* global describe,it */\r\nlet assert = require(\"better-assert\");\r\nlet _ = require(\"lodash\");\r\nlet ref = require(\"ref\");\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet testExec = require(\"./testExec\");\r\nlet float = ref.types.float;\r\n\r\ndescribe(\"gfor\", function () {\r\n testExec.run(function (af) {\r\n it(\"should work\", function () {\r\n af.scope(() => {\r\n const count = 20;\r\n let arr = af.constant(0.0, count, 10, af.dType.f32);\r\n let val = af.range(new af.Dim4(1, 10), 1, af.dType.f32);\r\n af.gfor(count, function (seq) {\r\n assert(seq instanceof af.Seq);\r\n assert(seq.begin === 0);\r\n assert(seq.end === 19);\r\n assert(seq.isGFor);\r\n arr.assign(seq, af.span, val);\r\n });\r\n for (let idx = 0; idx < count; idx++) {\r\n let sum = af.sum(arr.at(idx, af.span));\r\n assert(sum === (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9));\r\n }\r\n });\r\n });\r\n });\r\n});"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es5/index.js b/tests/es5/index.js deleted file mode 100644 index f3dde4c..0000000 --- a/tests/es5/index.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; - -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -require("./deviceTests"); -require("./afArrayTests"); -require("./createArrayFunctionTests"); -require("./mathFunctionTests"); -require("./moveAndReorderArrayTests"); -require("./gfor"); -//# sourceMappingURL=index.js.map diff --git a/tests/es5/index.js.map b/tests/es5/index.js.map deleted file mode 100644 index 733640e..0000000 --- a/tests/es5/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,OAAO,CAAC,eAAe,CAAC,CAAC;AACzB,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1B,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACtC,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC/B,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACtC,OAAO,CAAC,QAAQ,CAAC,CAAC","file":"index.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\nrequire(\"./deviceTests\");\r\nrequire(\"./afArrayTests\");\r\nrequire(\"./createArrayFunctionTests\");\r\nrequire(\"./mathFunctionTests\");\r\nrequire(\"./moveAndReorderArrayTests\");\r\nrequire(\"./gfor\");"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es5/mathFunctionTests.js b/tests/es5/mathFunctionTests.js deleted file mode 100644 index 5de174a..0000000 --- a/tests/es5/mathFunctionTests.js +++ /dev/null @@ -1,181 +0,0 @@ -/* - Copyright (c) 2014-2015, ArrayFire - Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; -/* global describe,it */ - -var assert = require("better-assert"); -var _ = require("lodash"); -var ref = require("ref"); -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var int = ref.types.int; -var float = ref.types.float; -var testExec = require("./testExec"); -var testHelpers = require("./testHelpers"); - -describe("Math functions", function () { - testExec.run(function (af) { - it("should invoke abs", function () { - testHelpers.testIntfSyncArr(af, af.abs); - }); - it("should invoke arg", function () { - testHelpers.testIntfSyncArr(af, af.arg); - }); - it("should invoke ceil", function () { - testHelpers.testIntfSyncArr(af, af.ceil); - }); - it("should invoke floor", function () { - testHelpers.testIntfSyncArr(af, af.floor); - }); - it("should invoke hypot", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.hypot); - }); - it("should invoke max", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.max); - }); - it("should invoke min", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.min); - }); - it("should invoke mod", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.mod); - }); - it("should invoke round", function () { - testHelpers.testIntfSyncArr(af, af.round); - }); - it("should invoke sign", function () { - testHelpers.testIntfSyncArr(af, af.sign); - }); - it("should invoke trunc", function () { - testHelpers.testIntfSyncArr(af, af.trunc); - }); - it("should invoke rem", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.rem); - }); - it("should invoke acos", function () { - testHelpers.testIntfSyncArr(af, af.acos); - }); - it("should invoke asin", function () { - testHelpers.testIntfSyncArr(af, af.asin); - }); - it("should invoke atan", function () { - testHelpers.testIntfSyncArr(af, af.atan); - }); - it("should invoke atan2", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.atan2); - }); - it("should invoke cos", function () { - testHelpers.testIntfSyncArr(af, af.cos); - }); - it("should invoke sin", function () { - testHelpers.testIntfSyncArr(af, af.sin); - }); - it("should invoke tan", function () { - testHelpers.testIntfSyncArr(af, af.tan); - }); - it("should invoke cbrt", function () { - testHelpers.testIntfSyncArr(af, af.cbrt); - }); - it("should invoke erf", function () { - testHelpers.testIntfSyncArr(af, af.erf); - }); - it("should invoke erfc", function () { - testHelpers.testIntfSyncArr(af, af.erfc); - }); - it("should invoke exp", function () { - testHelpers.testIntfSyncArr(af, af.exp); - }); - it("should invoke expm1", function () { - testHelpers.testIntfSyncArr(af, af.expm1); - }); - it("should invoke factorial", function () { - testHelpers.testIntfSyncArr(af, af.factorial); - }); - it("should invoke lgamma", function () { - testHelpers.testIntfSyncArr(af, af.lgamma); - }); - it("should invoke tgamma", function () { - testHelpers.testIntfSyncArr(af, af.tgamma); - }); - it("should invoke log", function () { - testHelpers.testIntfSyncArr(af, af.log); - }); - it("should invoke log10", function () { - testHelpers.testIntfSyncArr(af, af.log10); - }); - it("should invoke log1p", function () { - testHelpers.testIntfSyncArr(af, af.log1p); - }); - it("should invoke pow", function () { - testHelpers.testIntfSyncArrArr(af, af.pow); - }); - it("should invoke pow2", function () { - testHelpers.testIntfSyncArr(af, af.pow2); - }); - it("should invoke root", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.root); - }); - it("should invoke sqrt", function () { - testHelpers.testIntfSyncArr(af, af.sqrt); - }); - it("should invoke sigmoid", function () { - testHelpers.testIntfSyncArr(af, af.sigmoid); - }); - it("should invoke acosh", function () { - testHelpers.testIntfSyncArr(af, af.acosh); - }); - it("should invoke asinh", function () { - testHelpers.testIntfSyncArr(af, af.asinh); - }); - it("should invoke atanh", function () { - testHelpers.testIntfSyncArr(af, af.atanh); - }); - it("should invoke cosh", function () { - testHelpers.testIntfSyncArr(af, af.cosh); - }); - it("should invoke sinh", function () { - testHelpers.testIntfSyncArr(af, af.sinh); - }); - it("should invoke complex", function () { - testHelpers.testIntfSyncArr(af, af.complex); - }); - it("should invoke conjg", function () { - testHelpers.testIntfSyncArr(af, af.conjg); - }); - it("should invoke imag", function () { - testHelpers.testIntfSyncArr(af, af.imag); - }); - it("should invoke real", function () { - testHelpers.testIntfSyncArr(af, af.real); - }); - }); -}); -//# sourceMappingURL=mathFunctionTests.js.map diff --git a/tests/es5/mathFunctionTests.js.map b/tests/es5/mathFunctionTests.js.map deleted file mode 100644 index 6613ff8..0000000 --- a/tests/es5/mathFunctionTests.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["mathFunctionTests.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY;;AAAC;AAEb,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACtC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,I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n Copyright (c) 2014-2015, ArrayFire\r\n Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\n All rights reserved.\r\n\r\n Redistribution and use in source and binary forms, with or without modification,\r\n are permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n\"use strict\";\r\n/* global describe,it */\r\nlet assert = require(\"better-assert\");\r\nlet _ = require(\"lodash\");\r\nlet ref = require(\"ref\");\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet int = ref.types.int;\r\nlet float = ref.types.float;\r\nlet testExec = require(\"./testExec\");\r\nlet testHelpers = require(\"./testHelpers\");\r\n\r\ndescribe(\"Math functions\", function () {\r\n testExec.run(function(af) {\r\n it(\"should invoke abs\", function () {\r\n testHelpers.testIntfSyncArr(af, af.abs);\r\n });\r\n it(\"should invoke arg\", function () {\r\n testHelpers.testIntfSyncArr(af, af.arg);\r\n });\r\n it(\"should invoke ceil\", function () {\r\n testHelpers.testIntfSyncArr(af, af.ceil);\r\n });\r\n it(\"should invoke floor\", function () {\r\n testHelpers.testIntfSyncArr(af, af.floor);\r\n });\r\n it(\"should invoke hypot\", function () {\r\n testHelpers.testIntfSyncArrDoubleComb(af, af.hypot);\r\n });\r\n it(\"should invoke max\", function () {\r\n testHelpers.testIntfSyncArrDoubleComb(af, af.max);\r\n });\r\n it(\"should invoke min\", function () {\r\n testHelpers.testIntfSyncArrDoubleComb(af, af.min);\r\n });\r\n it(\"should invoke mod\", function () {\r\n testHelpers.testIntfSyncArrDoubleComb(af, af.mod);\r\n });\r\n it(\"should invoke round\", function () {\r\n testHelpers.testIntfSyncArr(af, af.round);\r\n });\r\n it(\"should invoke sign\", function () {\r\n testHelpers.testIntfSyncArr(af, af.sign);\r\n });\r\n it(\"should invoke trunc\", function () {\r\n testHelpers.testIntfSyncArr(af, af.trunc);\r\n });\r\n it(\"should invoke rem\", function () {\r\n testHelpers.testIntfSyncArrDoubleComb(af, af.rem);\r\n });\r\n it(\"should invoke acos\", function () {\r\n testHelpers.testIntfSyncArr(af, af.acos);\r\n });\r\n it(\"should invoke asin\", function () {\r\n testHelpers.testIntfSyncArr(af, af.asin);\r\n });\r\n it(\"should invoke atan\", function () {\r\n testHelpers.testIntfSyncArr(af, af.atan);\r\n });\r\n it(\"should invoke atan2\", function () {\r\n testHelpers.testIntfSyncArrDoubleComb(af, af.atan2);\r\n });\r\n it(\"should invoke cos\", function () {\r\n testHelpers.testIntfSyncArr(af, af.cos);\r\n });\r\n it(\"should invoke sin\", function () {\r\n testHelpers.testIntfSyncArr(af, af.sin);\r\n });\r\n it(\"should invoke tan\", function () {\r\n testHelpers.testIntfSyncArr(af, af.tan);\r\n });\r\n it(\"should invoke cbrt\", function () {\r\n testHelpers.testIntfSyncArr(af, af.cbrt);\r\n });\r\n it(\"should invoke erf\", function () {\r\n testHelpers.testIntfSyncArr(af, af.erf);\r\n });\r\n it(\"should invoke erfc\", function () {\r\n testHelpers.testIntfSyncArr(af, af.erfc);\r\n });\r\n it(\"should invoke exp\", function () {\r\n testHelpers.testIntfSyncArr(af, af.exp);\r\n });\r\n it(\"should invoke expm1\", function () {\r\n testHelpers.testIntfSyncArr(af, af.expm1);\r\n });\r\n it(\"should invoke factorial\", function () {\r\n testHelpers.testIntfSyncArr(af, af.factorial);\r\n });\r\n it(\"should invoke lgamma\", function () {\r\n testHelpers.testIntfSyncArr(af, af.lgamma);\r\n });\r\n it(\"should invoke tgamma\", function () {\r\n testHelpers.testIntfSyncArr(af, af.tgamma);\r\n });\r\n it(\"should invoke log\", function () {\r\n testHelpers.testIntfSyncArr(af, af.log);\r\n });\r\n it(\"should invoke log10\", function () {\r\n testHelpers.testIntfSyncArr(af, af.log10);\r\n });\r\n it(\"should invoke log1p\", function () {\r\n testHelpers.testIntfSyncArr(af, af.log1p);\r\n });\r\n it(\"should invoke pow\", function () {\r\n testHelpers.testIntfSyncArrArr(af, af.pow);\r\n });\r\n it(\"should invoke pow2\", function () {\r\n testHelpers.testIntfSyncArr(af, af.pow2);\r\n });\r\n it(\"should invoke root\", function () {\r\n testHelpers.testIntfSyncArrDoubleComb(af, af.root);\r\n });\r\n it(\"should invoke sqrt\", function () {\r\n testHelpers.testIntfSyncArr(af, af.sqrt);\r\n });\r\n it(\"should invoke sigmoid\", function () {\r\n testHelpers.testIntfSyncArr(af, af.sigmoid);\r\n });\r\n it(\"should invoke acosh\", function () {\r\n testHelpers.testIntfSyncArr(af, af.acosh);\r\n });\r\n it(\"should invoke asinh\", function () {\r\n testHelpers.testIntfSyncArr(af, af.asinh);\r\n });\r\n it(\"should invoke atanh\", function () {\r\n testHelpers.testIntfSyncArr(af, af.atanh);\r\n });\r\n it(\"should invoke cosh\", function () {\r\n testHelpers.testIntfSyncArr(af, af.cosh);\r\n });\r\n it(\"should invoke sinh\", function () {\r\n testHelpers.testIntfSyncArr(af, af.sinh);\r\n });\r\n it(\"should invoke complex\", function () {\r\n testHelpers.testIntfSyncArr(af, af.complex);\r\n });\r\n it(\"should invoke conjg\", function () {\r\n testHelpers.testIntfSyncArr(af, af.conjg);\r\n });\r\n it(\"should invoke imag\", function () {\r\n testHelpers.testIntfSyncArr(af, af.imag);\r\n });\r\n it(\"should invoke real\", function () {\r\n testHelpers.testIntfSyncArr(af, af.real);\r\n });\r\n });\r\n});"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es5/moveAndReorderArrayTests.js b/tests/es5/moveAndReorderArrayTests.js deleted file mode 100644 index d18ee6c..0000000 --- a/tests/es5/moveAndReorderArrayTests.js +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ - -var assert = require("better-assert"); -var _ = require("lodash"); -var ref = require("ref"); -var Bluebird = require("bluebird"); -var async = Bluebird.coroutine; -var int = ref.types.int; -var float = ref.types.float; -var testExec = require("./testExec"); - -describe("Functions to create arrays", function () { - testExec.run(function (af) {}); -}); -//# sourceMappingURL=moveAndReorderArrayTests.js.map diff --git a/tests/es5/moveAndReorderArrayTests.js.map b/tests/es5/moveAndReorderArrayTests.js.map deleted file mode 100644 index 62ee0d2..0000000 --- a/tests/es5/moveAndReorderArrayTests.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["moveAndReorderArrayTests.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY;;AAAC;AAEb,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACtC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC;AAC/B,IAAI,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AACxB,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;AAC5B,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;;AAErC,QAAQ,CAAC,4BAA4B,EAAE,YAAY;AAC/C,UAAQ,CAAC,GAAG,CAAC,UAAS,EAAE,EAAE,EAEzB,CAAC,CAAC;CACN,CAAC,CAAC","file":"moveAndReorderArrayTests.js","sourcesContent":["/*\r\nCopyright (c) 2014-2015, ArrayFire\r\nCopyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n\"use strict\";\r\n/* global describe,it */\r\nlet assert = require(\"better-assert\");\r\nlet _ = require(\"lodash\");\r\nlet ref = require(\"ref\");\r\nlet Bluebird = require(\"bluebird\");\r\nlet async = Bluebird.coroutine;\r\nlet int = ref.types.int;\r\nlet float = ref.types.float;\r\nlet testExec = require(\"./testExec\");\r\n\r\ndescribe(\"Functions to create arrays\", function () {\r\n testExec.run(function(af) {\r\n\r\n });\r\n});"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es5/testExec.js b/tests/es5/testExec.js deleted file mode 100644 index fa6c8c3..0000000 --- a/tests/es5/testExec.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (c) 2014-2015, ArrayFire - Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -var af = require("../.."); - -function runOn(id, f) { - describe(id + " platform", function () { - var afID = af(id); - f(afID); - }); -} - -var testExec = { - run: function run(f) { - var platfroms = af.supportedPlatforms(); - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = platfroms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var pl = _step.value; - - runOn(pl, f); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } -}; - -module.exports = testExec; -//# sourceMappingURL=testExec.js.map diff --git a/tests/es5/testExec.js.map b/tests/es5/testExec.js.map deleted file mode 100644 index 968e8b4..0000000 --- a/tests/es5/testExec.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["testExec.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AACb,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;;AAE1B,SAAS,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE;AAClB,UAAQ,CAAC,EAAE,GAAG,WAAW,EAAE,YAAY;AACnC,QAAI,IAAI,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAClB,KAAC,CAAC,IAAI,CAAC,CAAC;GACX,CAAC,CAAC;CACN;;AAED,IAAI,QAAQ,GAAG;AACX,KAAG,EAAE,aAAS,CAAC,EAAE;AACb,QAAI,SAAS,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC;;;;;;AACxC,2BAAe,SAAS,8HAAE;YAAjB,EAAE;;AACP,aAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;OAChB;;;;;;;;;;;;;;;GACJ;CACJ,CAAC;;AAEF,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC","file":"testExec.js","sourcesContent":["/*\r\n Copyright (c) 2014-2015, ArrayFire\r\n Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\n All rights reserved.\r\n\r\n Redistribution and use in source and binary forms, with or without modification,\r\n are permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n\"use strict\";\r\nlet af = require(\"../..\");\r\n\r\nfunction runOn(id, f) {\r\n describe(id + \" platform\", function () {\r\n let afID = af(id);\r\n f(afID);\r\n });\r\n}\r\n\r\nlet testExec = {\r\n run: function(f) {\r\n let platfroms = af.supportedPlatforms();\r\n for (let pl of platfroms) {\r\n runOn(pl, f);\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = testExec;\r\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es5/testHelpers.js b/tests/es5/testHelpers.js deleted file mode 100644 index 6c6bdea..0000000 --- a/tests/es5/testHelpers.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (c) 2014-2015, ArrayFire - Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; - -var _ = require("lodash"); -var assert = require("better-assert"); - -var testHelpers = { - testIntfSyncArrDoubleComb: function testIntfSyncArrDoubleComb(af, func) { - var result = undefined; - var arr1 = new af.AFArray(10, af.dType.f32); - var arr2 = new af.AFArray(10, af.dType.f32); - result = func(arr1, arr2); - assert(result instanceof af.AFArray); - result = func(arr1, 42); - assert(result instanceof af.AFArray); - result = func(42, arr2); - assert(result instanceof af.AFArray); - try { - func(42, {}); - assert(false); - } catch (e) { - _.noop(e); - } - }, - testIntfSyncArrArr: function testIntfSyncArrArr(af, func) { - var arr1 = new af.AFArray(10, af.dType.f32); - var arr2 = new af.AFArray(10, af.dType.f32); - var result = func(arr1, arr2); - assert(result instanceof af.AFArray); - try { - func(42, {}); - assert(false); - } catch (e) { - _.noop(e); - } - }, - testIntfSyncArr: function testIntfSyncArr(af, func) { - var arr = new af.AFArray(10, af.dType.f32); - var result = func(arr); - assert(result instanceof af.AFArray); - try { - func({}); - assert(false); - } catch (e) { - _.noop(e); - } - } -}; - -module.exports = testHelpers; -//# sourceMappingURL=testHelpers.js.map diff --git a/tests/es5/testHelpers.js.map b/tests/es5/testHelpers.js.map deleted file mode 100644 index f399dd0..0000000 --- a/tests/es5/testHelpers.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["testHelpers.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AACb,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;;AAEtC,IAAI,WAAW,GAAG;AACd,6BAAyB,EAAE,mCAAS,EAAE,EAAE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C,EAAE,EAAE,EAAE,CAAC,CAAC;AACb,kBAAM,CAAC,KAAK,CAAC,CAAC;SACjB,CACD,OAAO,CAAC,EAAE;AACN,aAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb;KACJ;AACD,mBAAe,EAAE,yBAAS,EAAE,EAAE,IAAI,EAAE;AAChC,YAAI,GAAG,GAAG,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC3C,YAAI,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AACvB,cAAM,CAAC,MAAM,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC;AACrC,YAAI;AACA,gBAAI,CAAC,EAAE,CAAC,CAAC;AACT,kBAAM,CAAC,KAAK,CAAC,CAAC;SACjB,CACD,OAAO,CAAC,EAAE;AACN,aAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb;KACJ;CACJ,CAAC;;AAEF,MAAM,CAAC,OAAO,GAAG,WAAW,CAAC","file":"testHelpers.js","sourcesContent":["/*\r\n Copyright (c) 2014-2015, ArrayFire\r\n Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com)\r\n All rights reserved.\r\n\r\n Redistribution and use in source and binary forms, with or without modification,\r\n are permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce the above copyright notice, this\r\n list of conditions and the following disclaimer in the documentation and/or\r\n other materials provided with the distribution.\r\n\r\n * Neither the name of the ArrayFire nor the names of its\r\n contributors may be used to endorse or promote products derived from\r\n this software without specific prior written permission.\r\n\r\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\n ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\r\n ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\n ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n\r\n\"use strict\";\r\nlet _ = require(\"lodash\");\r\nlet assert = require(\"better-assert\");\r\n\r\nlet testHelpers = {\r\n testIntfSyncArrDoubleComb: function(af, func) {\r\n let result;\r\n let arr1 = new af.AFArray(10, af.dType.f32);\r\n let arr2 = new af.AFArray(10, af.dType.f32);\r\n result = func(arr1, arr2);\r\n assert(result instanceof af.AFArray);\r\n result = func(arr1, 42);\r\n assert(result instanceof af.AFArray);\r\n result = func(42, arr2);\r\n assert(result instanceof af.AFArray);\r\n try {\r\n func(42, {});\r\n assert(false);\r\n }\r\n catch (e) {\r\n _.noop(e);\r\n }\r\n },\r\n testIntfSyncArrArr: function(af, func) {\r\n let arr1 = new af.AFArray(10, af.dType.f32);\r\n let arr2 = new af.AFArray(10, af.dType.f32);\r\n let result = func(arr1, arr2);\r\n assert(result instanceof af.AFArray);\r\n try {\r\n func(42, {});\r\n assert(false);\r\n }\r\n catch (e) {\r\n _.noop(e);\r\n }\r\n },\r\n testIntfSyncArr: function(af, func) {\r\n let arr = new af.AFArray(10, af.dType.f32);\r\n let result = func(arr);\r\n assert(result instanceof af.AFArray);\r\n try {\r\n func({});\r\n assert(false);\r\n }\r\n catch (e) {\r\n _.noop(e);\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = testHelpers;"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/tests/es6/afArrayTests.js b/tests/es6/afArrayTests.js deleted file mode 100644 index 58b0ca9..0000000 --- a/tests/es6/afArrayTests.js +++ /dev/null @@ -1,449 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ -let assert = require("better-assert"); -let _ = require("lodash"); -let ref = require("ref"); -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let testExec = require("./testExec"); -let float = ref.types.float; - -describe("AFArray class and methods", function () { - testExec.run(function (af) { - let AFArray = af.AFArray; - - it("should export AFArray constructor", function () { - assert(_.isFunction(AFArray)); - }); - - it("should create empty", function () { - let array = new AFArray(); - assert(_.isObject(array)); - assert(array.bytes() === 0); - assert(array.elements() === 0); - assert(array.isempty()); - assert(_.isFunction(array.host)); - assert(_.isFunction(array.hostAsync)); - assert(_.isUndefined(array.hostAsyncAsync)); - assert(_.isFunction(array.hostSync)); - assert(_.isUndefined(array.hostSyncAsync)); - assert(_.isUndefined(array.hostSyncSync)); - assert(_.isUndefined(array.hostAsyncSync)); - }); - - it("should fail with one number argument", function () { - try { - let array = new AFArray(1); - assert(false); - } - catch (e) { - } - }); - - it("should create new one dimensional", function () { - let array = new AFArray(10, af.dType.s32); - assert(_.isObject(array)); - assert(array.bytes() === 10 * 4); - assert(array.elements() === 10); - assert(array.type() === af.dType.s32); - assert(array.numdims() === 1); - assert(array.dims(0) === 10); - assert(array.dims(1) === 1); - assert(array.dims(2) === 1); - assert(array.dims(3) === 1); - let dims = array.dims(); - assert(_.isObject(dims)); - assert(dims.elements === 10); - assert(dims.ndims === 1); - assert(dims.values[0] === 10); - assert(dims.values[1] === 1); - assert(dims.values[2] === 1); - assert(dims.values[3] === 1); - assert(array.isempty() === false); - assert(array.isscalar() === false); - assert(array.isvector() === true); - assert(array.isrow() === false); - assert(array.iscolumn() === true); - assert(array.iscomplex() === false); - assert(array.isreal() === true); - assert(array.isdouble() === false); - assert(array.issingle() === false); - assert(array.isrealfloating() === false); - assert(array.isfloating() === false); - assert(array.isinteger() === true); - assert(array.isbool() === false); - }); - - it("should create new two dimensional", function () { - let array = new AFArray(10, 20, af.dType.f32); - assert(_.isObject(array)); - assert(array.bytes() === 10 * 20 * 4); - assert(array.elements() === 10 * 20); - assert(array.type() === af.dType.f32); - assert(array.numdims() === 2); - assert(array.dims(0) === 10); - assert(array.dims(1) === 20); - assert(array.dims(2) === 1); - assert(array.dims(3) === 1); - let dims = array.dims(); - assert(_.isObject(dims)); - assert(dims.elements === 10 * 20); - assert(dims.ndims === 2); - assert(dims.values[0] === 10); - assert(dims.values[1] === 20); - assert(dims.values[2] === 1); - assert(dims.values[3] === 1); - assert(array.isempty() === false); - assert(array.isscalar() === false); - assert(array.isvector() === false); - assert(array.isrow() === false); - assert(array.iscolumn() === false); - assert(array.iscomplex() === false); - assert(array.isreal() === true); - assert(array.isdouble() === false); - assert(array.issingle() === true); - assert(array.isrealfloating() === true); - assert(array.isfloating() === true); - assert(array.isinteger() === false); - assert(array.isbool() === false); - }); - - it("should create new three dimensional", function () { - let array = new AFArray(10, 20, 30, af.dType.f32); - assert(_.isObject(array)); - assert(array.bytes() === 10 * 20 * 30 * 4); - assert(array.elements() === 10 * 20 * 30); - assert(array.type() === af.dType.f32); - assert(array.numdims() === 3); - assert(array.dims(0) === 10); - assert(array.dims(1) === 20); - assert(array.dims(2) === 30); - assert(array.dims(3) === 1); - let dims = array.dims(); - assert(_.isObject(dims)); - assert(dims.elements === 10 * 20 * 30); - assert(dims.ndims === 3); - assert(dims.values[0] === 10); - assert(dims.values[1] === 20); - assert(dims.values[2] === 30); - assert(dims.values[3] === 1); - assert(array.isempty() === false); - assert(array.isscalar() === false); - assert(array.isvector() === false); - assert(array.isrow() === false); - assert(array.iscolumn() === false); - assert(array.iscomplex() === false); - assert(array.isreal() === true); - assert(array.isdouble() === false); - assert(array.issingle() === true); - assert(array.isrealfloating() === true); - assert(array.isfloating() === true); - assert(array.isinteger() === false); - assert(array.isbool() === false); - }); - - function verify4(array) { - assert(_.isObject(array)); - assert(array.bytes() === 10 * 20 * 30 * 40 * 4); - assert(array.elements() === 10 * 20 * 30 * 40); - assert(array.type() === af.dType.f32); - assert(array.numdims() === 4); - assert(array.dims(0) === 10); - assert(array.dims(1) === 20); - assert(array.dims(2) === 30); - assert(array.dims(3) === 40); - let dims = array.dims(); - assert(_.isObject(dims)); - assert(dims.elements === 10 * 20 * 30 * 40); - assert(dims.ndims === 4); - assert(dims.values[0] === 10); - assert(dims.values[1] === 20); - assert(dims.values[2] === 30); - assert(dims.values[3] === 40); - assert(array.isempty() === false); - assert(array.isscalar() === false); - assert(array.isvector() === false); - assert(array.isrow() === false); - assert(array.iscolumn() === false); - assert(array.iscomplex() === false); - assert(array.isreal() === true); - assert(array.isdouble() === false); - assert(array.issingle() === true); - assert(array.isrealfloating() === true); - assert(array.isfloating() === true); - assert(array.isinteger() === false); - assert(array.isbool() === false); - } - - it("should create new four dimensional", function () { - let array = new AFArray(10, 20, 30, 40, af.dType.f32); - verify4(array); - }); - - it("should create new four dimensional from dim4", function () { - let array = new AFArray({values: [10, 20, 30, 40]}, af.dType.f32); - verify4(array); - }); - - it("should create new four dimensional from dim4 array", function () { - let array = new AFArray([10, 20, 30, 40], af.dType.f32); - verify4(array); - }); - - it("should initialize from buffer, copyable, and readable - asynchronously w/ generators", function (done) { - let f = async(function*() { - let int = ref.types.int; - const count = 10; - let buff = new Buffer(int.size * count); - for (let v = 0; v < count; v++) { - int.set(buff, v * int.size, v * v); - } - - assert(_.isFunction(AFArray.create)); - assert(_.isFunction(AFArray.createAsync)); - - let array = yield AFArray.createAsync(count, af.dType.s32, buff); - assert(array.bytes() === count * int.size); - assert(array.type() === af.dType.s32); - - let buff2 = new Buffer(int.size * count); - yield array.hostAsync(buff2); - for (let v = 0; v < count; v++) { - let v1 = int.get(buff, v * int.size); - let v2 = int.get(buff2, v * int.size); - assert(v1 === v2); - assert(v1 === v * v); - } - - let array2 = array.copy(); - assert(array2 instanceof AFArray); - assert(array2.bytes() === array.bytes()); - let buff3 = yield array2.hostAsync(); - assert(buff3 instanceof Buffer); - assert(buff3.length === int.size * count); - for (let v = 0; v < count; v++) { - let v1 = int.get(buff, v * int.size); - let v2 = int.get(buff3, v * int.size); - assert(v1 === v2); - assert(v1 === v * v); - } - - // Let's do some indexing: - let v = array2.value(); - assert(v === 0.0); - - v = array2.at(1).value(); - assert(v === 1.0); - - v = array2.at(2).scalar(); - assert(v === 4.0); - - v = array2.at("end").scalar(); - assert(v === 9.0 * 9.0); - - v = array2.at(af.end - 1).scalar(); - assert(v === 8.0 * 8.0); - }); - f().nodeify(done); - }); - - it("should initialize from buffer, copyable, and readable - synchronously (blocking)", function () { - let int = ref.types.int; - const count = 10; - let buff = new Buffer(int.size * count); - for (let v = 0; v < count; v++) { - int.set(buff, v * int.size, v * v); - } - - assert(_.isFunction(AFArray.create)); - assert(_.isFunction(AFArray.createSync)); - - let array = AFArray.createSync(count, af.dType.s32, buff); - assert(array.bytes() === count * int.size); - assert(array.type() === af.dType.s32); - - let buff2 = new Buffer(int.size * count); - array.hostSync(buff2); - for (let v = 0; v < count; v++) { - let v1 = int.get(buff, v * int.size); - let v2 = int.get(buff2, v * int.size); - assert(v1 === v2); - assert(v1 === v * v); - } - - let array2 = array.copy(); - assert(array2 instanceof AFArray); - assert(array2.bytes() === array.bytes()); - let buff3 = array2.hostSync(); - assert(buff3 instanceof Buffer); - assert(buff3.length === int.size * count); - for (let v = 0; v < count; v++) { - let v1 = int.get(buff, v * int.size); - let v2 = int.get(buff3, v * int.size); - assert(v1 === v2); - assert(v1 === v * v); - } - - // Let's do some indexing: - let v = array2.value(); - assert(v === 0.0); - - v = array.at(1).value(); - assert(v === 1.0); - - v = array2.at(2).scalar(); - assert(v === 4.0); - - v = array2.at("end").scalar(); - assert(v === 9.0 * 9.0); - - v = array2.at(af.end - 1).scalar(); - assert(v === 8.0 * 8.0); - }); - - it("should be created of a part of another with new dimensions", function (done) { - async(function* () { - let arr = new af.AFArray(10, af.dType.f32); - arr.set(new af.Col(0), 0); - arr.set(3, 1); - arr.set(4, 2); - - let sub = arr.at(new af.Seq(3, 6)); - let sub2 = new af.AFArray(sub, new af.Dim4(2, 2)); - - let buff = yield sub2.hostAsync(); - - assert(float.get(buff, 0 * float.size) === 1); - assert(float.get(buff, 1 * float.size) === 2); - - arr.set(3, 2); - arr.set(4, 3); - - buff = yield sub2.hostAsync(); - - assert(float.get(buff, 0 * float.size) === 1); - assert(float.get(buff, 1 * float.size) === 2); - })().nodeify(done); - }); - - it("should be multiplied by scalar", function (done) { - async(function* () { - let arr = af.constant(2.0, 10, 10, af.dType.f32); - assert(!arr.isScalar()); - let result = yield arr.mul(2).hostAsync(); - assert(result.length === float.size * 10 * 10); - for (let offset = 0; offset < result.length; offset += float.size) { - let value = float.get(result, offset); - assert(value === 4); - } - })().nodeify(done); - }); - - describe("RAII", function () { - describe("scope", function () { - it("should exported as a function", function () { - assert(_.isFunction(af.scope)); - }); - - it("should support RAII interface", function () { - assert(_.isFunction(af.scope.begin)); - assert(_.isFunction(af.scope.end)); - assert(_.isFunction(af.scope.result)); - assert(_.isFunction(af.scope.register)); - }); - - it("should destroy temporaries (sync)", function () { - let arr, sub; - let x = af.scope(function () { - assert(this === af.scope); - arr = new af.AFArray(10, af.dType.f32); - arr.set(new af.Col(0), 0); - arr.set(3, 1); - arr.set(4, 2); - - sub = arr.at(new af.Seq(3, 6)); - - this.result(arr); - - return 1; - }); - - assert(x === 1); - - arr.set(3, 2); - - try { - sub.set(0, 2); - assert(false); - } - catch (e) { - if (!/free\(\)/.test(e.message)) { - throw e; - } - } - }); - - it("should destroy registered arrays", function () { - let arr = new af.AFArray(10, af.dType.f32); - arr.set(new af.Col(0), 0); - arr.set(3, 1); - arr.set(4, 2); - - let sub = arr.at(new af.Seq(3, 6)); - - af.scope(function () { - assert(this === af.scope); - - sub.set(0, 0); - - // Part of the scope, hence will be destroyed. - this.register(sub); - }); - - arr.set(3, 2); - - try { - sub.set(0, 2); - assert(false); - } - catch (e) { - if (!/free\(\)/.test(e.message)) { - throw e; - } - } - }); - }); - }); - }); -}); \ No newline at end of file diff --git a/tests/es6/createArrayFunctionTests.js b/tests/es6/createArrayFunctionTests.js deleted file mode 100644 index 29b97d7..0000000 --- a/tests/es6/createArrayFunctionTests.js +++ /dev/null @@ -1,110 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ -let assert = require("better-assert"); -let _ = require("lodash"); -let ref = require("ref"); -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let int = ref.types.int; -let float = ref.types.float; -let testExec = require("./testExec"); - -describe("Functions to create arrays", function () { - testExec.run(function(af) { - describe("randu", function () { - it("should yield uniform random int array with 2 dimensions", function (done) { - let f = async(function*() { - let array = af.randu(2, 4, af.dType.s32); - let data = yield array.copyToHostAsync(); - assert(data instanceof Buffer); - assert(data.length == 2 * 4 * int.size); - - for (let i = 0; i < data.length / int.size; i++) { - const v = int.get(data, i * int.size); - assert(v >= Number.MIN_SAFE_INTEGER && v <= Number.MAX_SAFE_INTEGER); - assert(Math.floor(v) === v); - } - }); - f().nodeify(done); - }); - it("should yield uniform random float array with 2 dimensions", function (done) { - let f = async(function*() { - let array = af.randu([2, 4], af.dType.f32); - let data = yield array.copyToHostAsync(); - assert(data instanceof Buffer); - assert(data.length == 2 * 4 * float.size); - - for (let i = 0; i < data.length / float.size; i++) { - const v = float.get(data, i * float.size); - assert(v === 0 || v === 1.0 || (v > 0 && v < 1.0 && v % 1)); - } - }); - f().nodeify(done); - }); - }); - - describe("randf", function () { - it("should throw error when invoking normal random int array with 2 dimensions", function () { - try { - let array = af.randn(2, 4, af.dType.s32); - return; - } - catch(e) { - if (/invalid dtype argument/ig.test(e.message)) { - return; - } - else { - throw new Error("This should throw appropriate error."); - } - } - throw new Error("This should throw."); - - }); - it("should yield normal random float array with 2 dimensions", function (done) { - let f = async(function*() { - let array = af.randn([2, 4], af.dType.f32); - let data = yield array.copyToHostAsync(); - assert(data instanceof Buffer); - assert(data.length == 2 * 4 * float.size); - - for (let i = 0; i < data.length / float.size; i++) { - const v = float.get(data, i * float.size); - assert(v === 0 || (v > -4.0 && v < 4.0 && v % 1)); - } - }); - f().nodeify(done); - }); - }); - }); -}); \ No newline at end of file diff --git a/tests/es6/deviceTests.js b/tests/es6/deviceTests.js deleted file mode 100644 index 454d1de..0000000 --- a/tests/es6/deviceTests.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ -let assert = require("better-assert"); -let _ = require("lodash"); -let Bluebird = require("bluebird"); -let testExec = require("./testExec"); - -describe("device methods", function() { - testExec.run(function(af) { - it("should return available devices", function() { - let deviceCount = af.getDeviceCount(); - assert(deviceCount > 0); - let infos = af.getDevices(); - assert(_.isArray(infos)); - assert(infos.length === deviceCount); - for (let info of infos) { - assert(_.isString(info.name) && info.name); - assert(_.isString(info.platform) && info.platform); - assert(_.isString(info.compute) && info.compute); - assert(_.isBoolean(info.isDoubleAvailable)); - } - }); - - it("should do sync with callback", function(done) { - af.sync(done); - }); - - it("should do sync with promise", function(done) { - af.syncAsync().nodeify(done); - }); - - it("sync should failed if device is out of range", function(done) { - af.syncAsync(100) - .then(function() { - done(new Error("This should fail!")); - }, - function() { - done(); - }); - }); - }); -}); diff --git a/tests/es6/gfor.js b/tests/es6/gfor.js deleted file mode 100644 index 10db310..0000000 --- a/tests/es6/gfor.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ -let assert = require("better-assert"); -let _ = require("lodash"); -let ref = require("ref"); -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let testExec = require("./testExec"); -let float = ref.types.float; - -describe("gfor", function () { - testExec.run(function (af) { - it("should work", function () { - af.scope(() => { - const count = 20; - let arr = af.constant(0.0, count, 10, af.dType.f32); - let val = af.range(new af.Dim4(1, 10), 1, af.dType.f32); - af.gfor(count, function (seq) { - assert(seq instanceof af.Seq); - assert(seq.begin === 0); - assert(seq.end === 19); - assert(seq.isGFor); - arr.assign(seq, af.span, val); - }); - for (let idx = 0; idx < count; idx++) { - let sum = af.sum(arr.at(idx, af.span)); - assert(sum === (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)); - } - }); - }); - }); -}); \ No newline at end of file diff --git a/tests/es6/index.js b/tests/es6/index.js deleted file mode 100644 index 6402f72..0000000 --- a/tests/es6/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -require("./deviceTests"); -require("./afArrayTests"); -require("./createArrayFunctionTests"); -require("./mathFunctionTests"); -require("./moveAndReorderArrayTests"); -require("./gfor"); \ No newline at end of file diff --git a/tests/es6/mathFunctionTests.js b/tests/es6/mathFunctionTests.js deleted file mode 100644 index 11d3754..0000000 --- a/tests/es6/mathFunctionTests.js +++ /dev/null @@ -1,179 +0,0 @@ -/* - Copyright (c) 2014-2015, ArrayFire - Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; -/* global describe,it */ -let assert = require("better-assert"); -let _ = require("lodash"); -let ref = require("ref"); -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let int = ref.types.int; -let float = ref.types.float; -let testExec = require("./testExec"); -let testHelpers = require("./testHelpers"); - -describe("Math functions", function () { - testExec.run(function(af) { - it("should invoke abs", function () { - testHelpers.testIntfSyncArr(af, af.abs); - }); - it("should invoke arg", function () { - testHelpers.testIntfSyncArr(af, af.arg); - }); - it("should invoke ceil", function () { - testHelpers.testIntfSyncArr(af, af.ceil); - }); - it("should invoke floor", function () { - testHelpers.testIntfSyncArr(af, af.floor); - }); - it("should invoke hypot", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.hypot); - }); - it("should invoke max", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.max); - }); - it("should invoke min", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.min); - }); - it("should invoke mod", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.mod); - }); - it("should invoke round", function () { - testHelpers.testIntfSyncArr(af, af.round); - }); - it("should invoke sign", function () { - testHelpers.testIntfSyncArr(af, af.sign); - }); - it("should invoke trunc", function () { - testHelpers.testIntfSyncArr(af, af.trunc); - }); - it("should invoke rem", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.rem); - }); - it("should invoke acos", function () { - testHelpers.testIntfSyncArr(af, af.acos); - }); - it("should invoke asin", function () { - testHelpers.testIntfSyncArr(af, af.asin); - }); - it("should invoke atan", function () { - testHelpers.testIntfSyncArr(af, af.atan); - }); - it("should invoke atan2", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.atan2); - }); - it("should invoke cos", function () { - testHelpers.testIntfSyncArr(af, af.cos); - }); - it("should invoke sin", function () { - testHelpers.testIntfSyncArr(af, af.sin); - }); - it("should invoke tan", function () { - testHelpers.testIntfSyncArr(af, af.tan); - }); - it("should invoke cbrt", function () { - testHelpers.testIntfSyncArr(af, af.cbrt); - }); - it("should invoke erf", function () { - testHelpers.testIntfSyncArr(af, af.erf); - }); - it("should invoke erfc", function () { - testHelpers.testIntfSyncArr(af, af.erfc); - }); - it("should invoke exp", function () { - testHelpers.testIntfSyncArr(af, af.exp); - }); - it("should invoke expm1", function () { - testHelpers.testIntfSyncArr(af, af.expm1); - }); - it("should invoke factorial", function () { - testHelpers.testIntfSyncArr(af, af.factorial); - }); - it("should invoke lgamma", function () { - testHelpers.testIntfSyncArr(af, af.lgamma); - }); - it("should invoke tgamma", function () { - testHelpers.testIntfSyncArr(af, af.tgamma); - }); - it("should invoke log", function () { - testHelpers.testIntfSyncArr(af, af.log); - }); - it("should invoke log10", function () { - testHelpers.testIntfSyncArr(af, af.log10); - }); - it("should invoke log1p", function () { - testHelpers.testIntfSyncArr(af, af.log1p); - }); - it("should invoke pow", function () { - testHelpers.testIntfSyncArrArr(af, af.pow); - }); - it("should invoke pow2", function () { - testHelpers.testIntfSyncArr(af, af.pow2); - }); - it("should invoke root", function () { - testHelpers.testIntfSyncArrDoubleComb(af, af.root); - }); - it("should invoke sqrt", function () { - testHelpers.testIntfSyncArr(af, af.sqrt); - }); - it("should invoke sigmoid", function () { - testHelpers.testIntfSyncArr(af, af.sigmoid); - }); - it("should invoke acosh", function () { - testHelpers.testIntfSyncArr(af, af.acosh); - }); - it("should invoke asinh", function () { - testHelpers.testIntfSyncArr(af, af.asinh); - }); - it("should invoke atanh", function () { - testHelpers.testIntfSyncArr(af, af.atanh); - }); - it("should invoke cosh", function () { - testHelpers.testIntfSyncArr(af, af.cosh); - }); - it("should invoke sinh", function () { - testHelpers.testIntfSyncArr(af, af.sinh); - }); - it("should invoke complex", function () { - testHelpers.testIntfSyncArr(af, af.complex); - }); - it("should invoke conjg", function () { - testHelpers.testIntfSyncArr(af, af.conjg); - }); - it("should invoke imag", function () { - testHelpers.testIntfSyncArr(af, af.imag); - }); - it("should invoke real", function () { - testHelpers.testIntfSyncArr(af, af.real); - }); - }); -}); \ No newline at end of file diff --git a/tests/es6/moveAndReorderArrayTests.js b/tests/es6/moveAndReorderArrayTests.js deleted file mode 100644 index 152264d..0000000 --- a/tests/es6/moveAndReorderArrayTests.js +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -"use strict"; -/* global describe,it */ -let assert = require("better-assert"); -let _ = require("lodash"); -let ref = require("ref"); -let Bluebird = require("bluebird"); -let async = Bluebird.coroutine; -let int = ref.types.int; -let float = ref.types.float; -let testExec = require("./testExec"); - -describe("Functions to create arrays", function () { - testExec.run(function(af) { - - }); -}); \ No newline at end of file diff --git a/tests/es6/testExec.js b/tests/es6/testExec.js deleted file mode 100644 index 3f45160..0000000 --- a/tests/es6/testExec.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (c) 2014-2015, ArrayFire - Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; -let af = require("../.."); - -function runOn(id, f) { - describe(id + " platform", function () { - let afID = af(id); - f(afID); - }); -} - -let testExec = { - run: function(f) { - let platfroms = af.supportedPlatforms(); - for (let pl of platfroms) { - runOn(pl, f); - } - } -}; - -module.exports = testExec; diff --git a/tests/es6/testHelpers.js b/tests/es6/testHelpers.js deleted file mode 100644 index f101c2a..0000000 --- a/tests/es6/testHelpers.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (c) 2014-2015, ArrayFire - Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -"use strict"; -let _ = require("lodash"); -let assert = require("better-assert"); - -let testHelpers = { - testIntfSyncArrDoubleComb: function(af, func) { - let result; - let arr1 = new af.AFArray(10, af.dType.f32); - let arr2 = new af.AFArray(10, af.dType.f32); - result = func(arr1, arr2); - assert(result instanceof af.AFArray); - result = func(arr1, 42); - assert(result instanceof af.AFArray); - result = func(42, arr2); - assert(result instanceof af.AFArray); - try { - func(42, {}); - assert(false); - } - catch (e) { - _.noop(e); - } - }, - testIntfSyncArrArr: function(af, func) { - let arr1 = new af.AFArray(10, af.dType.f32); - let arr2 = new af.AFArray(10, af.dType.f32); - let result = func(arr1, arr2); - assert(result instanceof af.AFArray); - try { - func(42, {}); - assert(false); - } - catch (e) { - _.noop(e); - } - }, - testIntfSyncArr: function(af, func) { - let arr = new af.AFArray(10, af.dType.f32); - let result = func(arr); - assert(result instanceof af.AFArray); - try { - func({}); - assert(false); - } - catch (e) { - _.noop(e); - } - } -}; - -module.exports = testHelpers; \ No newline at end of file diff --git a/tests/index.js b/tests/index.js deleted file mode 100644 index 591a4d5..0000000 --- a/tests/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - - * Neither the name of the ArrayFire nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -var yargs = require("yargs") - .options({ - old: { - demand: false, - type: "boolean" - } - }); -var argv = yargs.argv; - -var es6; - -if (argv.old) { - es6 = false; -} -else { - es6 = true; - try { - eval("(() => {})()"); - } catch (err) { - es6 = false; - } -} - -if (!es6) { - console.log("Testing in ES5 mode ..."); - require("babel-polyfill"); -} - -require(es6 ? "./es6" : "./es5"); \ No newline at end of file