diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..af0f0c3 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} \ No newline at end of file diff --git a/.eslintrc b/.eslintrc index 62c05ad..9b9481c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,41 +1,191 @@ { - "ecmaFeatures": { - "arrowFunctions": true, - "binaryLiterals": true, - "blockBindings": true, - "defaultParams": true, - "forOf": true, - "generators": true, - "objectLiteralComputedProperties": true, - "objectLiteralDuplicateProperties": true, - "objectLiteralShorthandMethods": true, - "objectLiteralShorthandProperties": true, - "octalLiterals": true, - "regexUFlag": true, - "regexYFlag": true, - "superInFunctions": true, - "templateStrings": true, - "unicodeCodePointEscapes": true, - "globalReturn": true, - "jsx": true, - "classes": true + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "script", + "ecmaFeatures": { + "jsx": true + } }, "rules": { - "no-underscore-dangle": 0, - "no-unused-vars": 0, - "no-duplicate-case": 0, - "no-new-func": 0, + "comma-dangle": [2, "never"], + "no-cond-assign": 2, + "no-constant-condition": 2, + "no-control-regex": 2, + "no-debugger": 2, + "no-dupe-args": 2, + "no-dupe-keys": 2, + "no-duplicate-case": 2, + "no-empty": 1, + "no-empty-character-class": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": [1, "all", { "conditionalAssign": false }], + "no-extra-semi": 2, + "no-func-assign": 2, + "no-inner-declarations": 2, + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-negated-in-lhs": 2, + "no-obj-calls": 2, + "no-regex-spaces": 2, + "no-sparse-arrays": 2, + "no-unexpected-multiline": 2, + "no-unreachable": 2, + "use-isnan": 2, + "valid-jsdoc": 0, + "valid-typeof": 2, + + "accessor-pairs": [2, {"getWithoutSet": false}], + "array-callback-return": 2, + "block-scoped-var": 2, + "complexity": [1, 10], + "consistent-return": 0, + "curly": 2, + "default-case": 1, + "dot-location": [2, "property"], + "dot-notation": 2, + "eqeqeq": [2, "smart"], + "guard-for-in": 2, + "no-alert": 2, + "no-caller": 2, + "no-case-declarations": 2, + "no-div-regex": 2, + "no-else-return": 0, + "no-empty-function": 1, + "no-empty-pattern": 2, + "no-eq-null": 2, + "no-eval": 1, + "no-extend-native": 2, + "no-extra-bind": 1, + "no-extra-label": 2, + "no-fallthrough": 1, + "no-floating-decimal": 2, + "no-implicit-coercion": 1, + "no-implicit-globals": 0, + "no-implied-eval": 2, + "no-invalid-this": 0, + "no-iterator": 2, + "no-labels": [2, {"allowLoop": true, "allowSwitch": true}], + "no-lone-blocks": 2, "no-loop-func": 0, - "no-eval": 0, - "camelcase": 0, - "eol-last": 0, - "semi": 2, + "no-magic-numbers": 0, + "no-multi-spaces": 0, + "no-multi-str": 2, + "no-native-reassign": [2, {"exceptions": ["Promise"]}], + "no-new": 2, + "no-new-wrappers": 2, + "no-param-reassign": 0, + "no-proto": 2, + "no-redeclare": 2, + "no-return-assign": 0, + "no-self-assign": 2, + "no-self-compare": 2, + "no-sequences": 2, + "no-throw-literal": 2, + "no-unmodified-loop-condition": 2, + "no-unused-expressions": 1, + "no-unused-labels": 1, + "no-useless-call": 2, + "no-useless-concat": 2, + "no-void": 2, + "no-warning-comments": [1, { "terms": ["todo", "fixme", "hack"], "location": "anywhere" }], + "no-with": 2, + "radix": 0, + "vars-on-top": 0, + "wrap-iife": [2, "inside"], + "yoda": 2, + + "callback-return": 2, + "global-require": 1, + "handle-callback-err": 2, + "no-mixed-requires": 2, + "no-new-require": 2, + "no-path-concat": 2, + "no-process-exit": 2, + + "array-bracket-spacing": [2, "never"], + "block-spacing": [2, "always"], + "brace-style": [2, "stroustrup", { "allowSingleLine": true }], + "comma-spacing": [2, {"before": false, "after": true}], + "comma-style": [2, "last"], + "camelcase": 2, + "computed-property-spacing": [2, "never"], + "consistent-this": [2, "self"], + "func-names": 0, + "func-style": [1, "declaration", { "allowArrowFunctions": true }], + "indent": [1, 4, {"SwitchCase": 1}], + "jsx-quotes": 0, + "key-spacing": [2, {"beforeColon": false, "afterColon": true}], + "keyword-spacing": 2, + "linebreak-style": [2, "unix"], + "lines-around-comment": 0, + "max-depth": [1, 3], + "max-len": [1, 150, 4], + "max-nested-callbacks": [1, 4], + "max-params": [1, 4], + "max-statements": [1, 40, {"ignoreTopLevelFunctions": true}], + "new-cap": 0, + "new-parens": 2, + "newline-after-var": 0, + "newline-per-chained-call": 0, + "no-array-constructor": 2, + "no-inline-comments": 0, + "no-lonely-if": 2, + "no-mixed-spaces-and-tabs": [2, "smart-tabs"], + "no-multiple-empty-lines": [2, {"max": 1}], + "no-negated-condition": 0, + "no-nested-ternary": 1, + "no-new-object": 2, + "no-plusplus": 0, + "no-spaced-func": 2, + "no-trailing-spaces": 2, + "no-underscore-dangle": 0, + "no-unneeded-ternary": 2, + "no-whitespace-before-property": 2, + "object-curly-spacing": [2, "always"], + "one-var": 0, + "one-var-declaration-per-line": [2, "initializations"], + "operator-assignment": [1, "always"], + "operator-linebreak": [2, "after", { "overrides": { "?": "ignore", ":": "ignore" } }], + "quote-props": 0, "quotes": 0, - "strict": 0, - "no-alert": 0 + "semi": [2, "always"], + "strict": [2, "global"], + "semi-spacing": [2, {"before": false, "after": true}], + "space-before-blocks": 2, + "space-before-function-paren": [2, {"anonymous": "always", "named": "never"}], + "space-in-parens": [2, "never"], + "space-infix-ops": 2, + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "spaced-comment": [1, "always", { "line": { "exceptions": ["/"] } }], + "unicode-bom": [2, "never"], + + "arrow-body-style": [1, "as-needed"], + "arrow-parens": [1, "as-needed"], + "arrow-spacing": 2, + "constructor-super": 2, + "generator-star-spacing": [2, {"before": false, "after": true}], + "no-class-assign": 2, + "no-confusing-arrow": 0, + "no-const-assign": 2, + "no-dupe-class-members": 2, + "no-new-symbol": 2, + "no-this-before-super": 2, + "no-useless-constructor": 2, + "prefer-arrow-callback": 0, + "prefer-const": 0, + "object-shorthand": 0, + "prefer-reflect": 0, + "prefer-rest-params": 0, + "prefer-spread": 0, + "prefer-template": 0, + "require-yield": 2, + "template-curly-spacing": [2, "always"], + "yield-star-spacing": [2, "after"], + "no-var": 0 }, "env": { "browser": true, "node": true } -} \ No newline at end of file +} diff --git a/.npmignore b/.npmignore index 44d7fcc..56bef8c 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1 @@ -examples/ -documentation/ \ No newline at end of file +examples/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 164c901..e40b4ae 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,27 +2,57 @@ "version": "0.2.0", "configurations": [ { - "name": "Launch", - "type": "node", - "request": "launch", - "program": "./node_modules/mocha/bin/_mocha", - "stopOnEntry": false, - "args": [ - "tests", - "--timeout=10000" - ], - "cwd": ".", - "runtimeExecutable": null, - "runtimeArgs": [ - "--nolazy" - ], - "env": { - "NODE_ENV": "development" - }, - "externalConsole": false, - "sourceMaps": false, - "outDir": null - }, + "name": "test", + "type": "node", + "request": "launch", + "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", + "stopOnEntry": false, + "args": [ + "--timeout=20000" + ], + "cwd": "${workspaceRoot}", + "preLaunchTask": null, + "runtimeExecutable": null, + "runtimeArgs": [ + "--nolazy", + "--expose-gc" + ], + "env": { + "NODE_ENV": "development", + "DEBUG": "arrayfire-js:*", + "AF_DISABLE_GRAPHICS": "1" + }, + "console": "integratedTerminal", + "sourceMaps": false + }, + { + "name": "test-es5", + "type": "node", + "request": "launch", + "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", + "stopOnEntry": false, + "args": [ + "--timeout=20000" + ], + "cwd": "${workspaceRoot}", + "preLaunchTask": "babel", + "runtimeExecutable": null, + "runtimeArgs": [ + "--nolazy", + "--expose-gc" + ], + "env": { + "NODE_ENV": "development", + "DEBUG": "arrayfire-js:*", + "AF_DISABLE_GRAPHICS": "1" + }, + "console": "integratedTerminal", + "sourceMaps": true, + "outFiles": [ + "${workspaceRoot}/lib/es5/**/*.*", + "${workspaceRoot}/test/es5/**/*.*" + ] + }, { "name": "Attach", "type": "node", diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..29c2c1e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "0.1.0", + "command": "npm", + "isShellCommand": true, + "showOutput": "always", + "suppressTaskName": true, + "tasks": [ + { + "taskName": "install", + "args": ["install"] + }, + { + "taskName": "update", + "args": ["update"] + }, + { + "taskName": "test", + "args": ["run", "test"] + }, + { + "taskName": "babel", + "args": ["run", "babel"], + "isBuildCommand": true + } + ] +} \ No newline at end of file diff --git a/CMake/WinCUDASupport.cmake b/CMake/WinCUDASupport.cmake deleted file mode 100644 index 361a635..0000000 --- a/CMake/WinCUDASupport.cmake +++ /dev/null @@ -1,19 +0,0 @@ -function(win_cuda_support) - if(WIN32) - set(cuda_path "$ENV{CUDA_PATH}") - if (cuda_path) - message(STATUS "Creating target to copy CUDA DLLs to module's binary folder.") - file(TO_CMAKE_PATH "${cuda_path}/nvvm/bin" cuda_dll_path) - message(STATUS "Searching CUDA DLLs in: ${cuda_dll_path}") - file(GLOB cuda_dll "${cuda_dll_path}/nvvm64*.dll") - if (cuda_dll) - message(STATUS "CUDA DLL found: ${cuda_dll}") - foreach(dll ${cuda_dll}) - add_custom_command(TARGET ${PROJECT_NAME}_CUDA POST_BUILD - COMMAND ${CMAKE_COMMAND} -E - copy "${cuda_dll}" $) - endforeach() - endif() - endif() - endif(WIN32) -endfunction(win_cuda_support) diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 6194f54..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,135 +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. -]] - -cmake_minimum_required(VERSION 2.8) - -project (arrayfire_js) - -SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") - -include(WinCUDASupport) - -set(ArrayFire_DIR "${AF_PATH}") -if (NOT ArrayFire_DIR) - set(ArrayFire_DIR "$ENV{AF_PATH}") - if (NOT ArrayFire_DIR) - message(FATAL_ERROR "Cannot locate ArrayFire installation. Please set cmake_af_path npm config value or AF_PATH environment variable pointing to your ArrayFire installation directory!" ) - endif() -endif() - -if(UNIX) - if(APPLE) - # CPU - set(ArrayFire_CPU_LIBRARIES "${ArrayFire_DIR}/lib/libafcpu.dylib") - # OpenCL - set(ArrayFire_OpenCL_LIBRARIES "${ArrayFire_DIR}/lib/libafopencl.dylib") - # CUDA - set(ArrayFire_CUDA_LIBRARIES "${ArrayFire_DIR}/lib/libafcuda.dylib") - else() - # CPU - set(ArrayFire_CPU_LIBRARIES "${ArrayFire_DIR}/lib/libafcpu.so") - # OpenCL - set(ArrayFire_OpenCL_LIBRARIES "${ArrayFire_DIR}/lib/libafopencl.so") - # CUDA - set(ArrayFire_CUDA_LIBRARIES "${ArrayFire_DIR}/lib/libafcuda.so") - endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") -elseif(MSVC) - add_definitions("/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /wd4251 /wd4244 /nologo") - # CPU - set(ArrayFire_CPU_LIBRARIES "${ArrayFire_DIR}/lib/afcpu.lib") - # OpenCL - set(ArrayFire_OpenCL_LIBRARIES "${ArrayFire_DIR}/lib/afopencl.lib") - # CUDA - set(ArrayFire_CUDA_LIBRARIES "${ArrayFire_DIR}/lib/afcuda.lib") -endif() - -message(STATUS "ArrayFire Dir: ${ArrayFire_DIR}") - -set(ArrayFire_INCLUDE_DIRS "${ArrayFire_DIR}/include") - -include_directories(${CMAKE_JS_INC};${ArrayFire_INCLUDE_DIRS}) - -file(GLOB COMMON_SOURCE_FILES - "src/fire.*" - "src/ext.*" - "src/symbols.*" - "src/helpers.*" - "src/guard.*" - "src/worker.*" - "src/arraywrapper.*" - "src/createarray.*" - "src/errors.*" - "src/moveandreorderarray.*" - "src/arrayhelperfunctions.*" - "src/functionhelpers.*" - "src/mathfunctions.*" - "src/vectoralgorithms.*" - "src/statistics.*" - "src/imageprocessing.*" - "src/computervision.*" - "src/linearalgebra.*" - "src/signalprocessing.*") - -file(GLOB TRAN_SOURCE_FILES - "src/device.*") - -# Common - -add_library(${PROJECT_NAME}_Common STATIC "${COMMON_SOURCE_FILES}") - -# CPU - -add_library(${PROJECT_NAME}_CPU SHARED "${TRAN_SOURCE_FILES};src/init/init_CPU.cpp") - -set_target_properties(${PROJECT_NAME}_CPU PROPERTIES COMPILE_FLAGS -DCPU) - -set_target_properties(${PROJECT_NAME}_CPU PROPERTIES PREFIX "" SUFFIX ".node") - -target_link_libraries(${PROJECT_NAME}_CPU "${CMAKE_JS_LIB};${ArrayFire_CPU_LIBRARIES};${PROJECT_NAME}_Common") - -# OpenCL - -add_library(${PROJECT_NAME}_OpenCL SHARED "${TRAN_SOURCE_FILES};src/init/init_OpenCL.cpp") - -set_target_properties(${PROJECT_NAME}_OpenCL PROPERTIES PREFIX "" SUFFIX ".node") - -target_link_libraries(${PROJECT_NAME}_OpenCL "${CMAKE_JS_LIB};${ArrayFire_OpenCL_LIBRARIES};${PROJECT_NAME}_Common;${OpenCL}") - -# CUDA - -add_library(${PROJECT_NAME}_CUDA SHARED "${TRAN_SOURCE_FILES};src/init/init_CUDA.cpp") - -set_target_properties(${PROJECT_NAME}_CUDA PROPERTIES PREFIX "" SUFFIX ".node") - -target_link_libraries(${PROJECT_NAME}_CUDA "${CMAKE_JS_LIB};${ArrayFire_CUDA_LIBRARIES};${PROJECT_NAME}_Common") - -win_cuda_support() 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,CAAC,SAAS,CAAC;AAC/B,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC7B,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACrC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;;AAE1B,IAAI,YAAY,GAAG,KAAK,yBAAC,iBAAU,UAAU,EAAE,CAAC,EAAE,IAAI;QAC9C,YAAY,kFACP,UAAU,EAGL,KAAK,EAEL,GAAG;;;;;;AANb,gCAAY,GAAG,EAAE,CAAC,UAAU,CAAC;;;;;gCACV,YAAY,CAAC,UAAU,EAAE;;;;;;;;AAAvC,8BAAU;;0BACX,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,UAAU,CAAC,EAAE,CAAA;;;;;AAC7C,gCAAY,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AAChC,yBAAK,GAAG,GAAG,EAAE;;2BACb,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC;;;AAC3B,uBAAG,GAAG,GAAG,EAAE;;AACjB,2BAAO,CAAC,GAAG,gBAAc,CAAC,CAAC,GAAG,GAAG,KA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AC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;AAItC,2BAAO,CAAC,KAAK,CAAC,aAAE,KAAK,CAAC,CAAC;;;;;;;;CAE9B,EAAC,CAAC;;AAEH,IAAI,eAAe,GAAG,SAAlB,eAAe,CAAa,UAAU,EAAE;AACxC,WAAO,CAAC,GAAG,UAAQ,UAAU,CAAC,EAAE,gBAAW,UAAU,CAAC,IAAI,oBAAe,UAAU,CAAC,QAAQ,mBAAc,UAAU,CAAC,OAAO,mBAAc,UAAU,CAAC,OAAO,CAAG,CAAC;CACnK,CAAC;;AAEF,MAAM,CAAC,OAAO,GAAG;AACb,qBAAiB,EAAE,iBAAiB;AACpC,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,SAAS,CAAC;AAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;AACvC,IAAI,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;;AAErC,SAAS,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;AAC5B,SAAK,GAAG,KAAK,IAAI,IAAI,CAAC;AACtB,QAAI,CAAC,EAAE,GAAG,EAAE,CAAC;AACb,QAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;AAC/B,QAAI,CAAC,MAAM,GAAG,EAAE,CAAC;AACjB,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAClB,SAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE;AACrC,YAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AACnC,YAAI,CAAC,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE;AACxB,gBAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,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AC;AAC5B,gBAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACxE,eAAG,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;SACrF,CAAC,CAAC;;AAEH,YAAM,GAAG,GAAG,GAAG,EAAE,CAAC;AAClB,eAAO,CAAC,GAAG,cAAW,CAAC,GAAG,CAAC,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,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC;AAC/B,IAAI,EAAE,GAAG,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;AACpD,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;AAC5B,IAAI,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;AAC1B,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC;AACzC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1B,IAAI,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACtC,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;;AAE3B,IAAI,QAAQ,GAAG,KAAK,yBAAC,iBAAU,CAAC,EAAE,IAAI;QAC9B,SAAS;;;;;;2BAAS,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;;;AAA7D,6BAAS;;0BACT,SAAS,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AAAnF,8BAAM;;AACV,mCAAW,GAAG,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;AACtC,kCAAU,GAAG,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;;;0DAGjC;AACH,sCAAU,EAAE,UAAU;AACtB,oCAAQ,EAAE,QAAQ;AAClB,mCAAO,EAAE,OAAO;AAChB,uCAAW,EAAE,WAAW;AACxB,sCAAU,EAAE,UAAU;AACtB,uCAAW,EAAE,WAAW;AACxB,sCAAU,EAAE,UAAU;yBACzB;;;;;;;;KACJ,EAAC;CACL,CAAC;;AAEF,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC","file":"machine-learning/mnist.js","sourcesContent":["\"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,QAA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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/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 index 56705ea..bc12d1d 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,6 +1,9 @@ { - "compilerOptions": { - "target": "ES6", - "module": "commonjs" - } + "compilerOptions": { + "target": "es6", + "module": "commonjs" + }, + "exclude": [ + "node_modules" + ] } \ No newline at end of file diff --git a/lib/es5/AFArray.js b/lib/es5/AFArray.js new file mode 100644 index 0000000..f0aba81 --- /dev/null +++ b/lib/es5/AFArray.js @@ -0,0 +1,715 @@ +'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"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var fastcall = require('fastcall'); +var ref = fastcall.ref; +var errors = require('./errors'); +var assert = require('assert'); +var Disposable = fastcall.Disposable; +var typedefs = require('./typedefs'); +var DimTArray = typedefs.DimTArray; +var Dim4 = require('./Dim4'); +var longlong = ref.types.longlong; +var Promise = require('bluebird'); +var async = Promise.coroutine; +var ArrayType = fastcall.ArrayType; +var arrayIndexing = require('./arrayIndexing'); +var _ = require('lodash'); +var helpers = require('./helpers'); + +var AFArray = function (_Disposable) { + _inherits(AFArray, _Disposable); + + _createClass(AFArray, null, [{ + key: 'define', + value: function define(af) { + var lib = af._lib; + var intf = lib.interface; + + // retainArray + + lib.declare('int af_retain_array(void** outArr, void* arr)'); + + af.retainArray = af._makeFunction(function () { + this.res = ref.alloc(typedefs.handleType); + }, function (array) { + return intf.af_retain_array(this.res, helpers.getHandle(array)); + }, function () { + return ref.deref(this.res); + }); + + // releaseArray + + lib.declare('int af_release_array(void* arr)'); + + af.releaseArray = af._makeFunction(function (array) { + return intf.af_release_array(helpers.getHandle(array)); + }); + + // createHandle + + lib.declare('int af_create_handle(void** outArr, uint ndims, longlong* dims, int type)'); + + af.createHandle = af._makeFunction(function () { + this.res = ref.alloc(typedefs.handleType); + }, function () { + var dims = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + var len = dims ? dims.ndims : 0; + return intf.af_create_handle(this.res, len, dims.buffer, type); + }, function () { + return ref.deref(this.res); + }); + + // createArray + + lib.declare('int af_create_array(void** outArr, void* data, uint ndims, longlong* dims, int type)'); + + af.createArray = af._makeFunction(function () { + this.res = ref.alloc(typedefs.handleType); + }, function (data, dims) { + var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : af.dtype.f32; + + var len = dims ? dims.ndims : 0; + try { + return intf.af_create_array(this.res, helpers.toBuffer(data), len, dims.buffer, type); + } catch (err) { + if (err instanceof TypeError) { + throw new TypeError('Argument "data" is not a Buffer.'); + } + throw err; + } + }, function () { + return ref.deref(this.res); + }); + + // deviceArray + + lib.declare('int af_device_array(void** outArr, void* data, uint ndims, longlong* dims, int type)'); + + af.deviceArray = af._makeFunction(function () { + this.res = ref.alloc(typedefs.handleType); + }, function (data, dims) { + var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; + + var len = dims ? dims.ndims : 0; + assert(Buffer.isBuffer(data), 'Argument "data" is not a Buffer.'); + return intf.af_device_array(this.res, data, len, dims.buffer, type); + }, function () { + return ref.deref(this.res); + }); + + // ctors + + af.array = af._makeFunction(function () { + var argsLen = arguments.length; + + // array() + if (argsLen === 0) { + return intf.createHandle(); + } + + var firstArg = arguments[0]; + + if (Buffer.isBuffer(firstArg)) { + // array(handle) + return firstArg; + } + + if (_.isArray(firstArg)) { + return af.createArray(firstArg, af.dim4(firstArg.length)); + } + + if (_.isTypedArray(firstArg)) { + return af.createArray(firstArg, af.dim4(firstArg.length), af.getDTypeOfTypedArray(firstArg)); + } + + if (firstArg instanceof AFArray) { + if (argsLen === 1) { + // array(otherArray) + return af.retainArray(firstArg); + } else { + // array(otherArray, dims...) + var _secondArg = arguments[1]; + assert(_secondArg instanceof Dim4, 'Second argument is not a dimension.'); + return af.moddims(firstArg, arguments[1]); + } + } + + var dims = af.dim4(firstArg); + + assert(dims.ndims > 0, 'First argument is not a dimension.'); + + if (argsLen === 1) { + // array(dims..., f32) + return af.createHandle(dims, af.dtype.f32); + } + + var secondArg = arguments[1]; + var thirdArg = argsLen >= 3 ? arguments[2] : null; + + if (Buffer.isBuffer(secondArg)) { + var type = af.dtype.f32; + var source = af.source.host; + var index = 2; + if (index < argsLen) { + type = arguments[index]; + index++; + if (index < argsLen) { + source = arguments[index]; + } + } + // array(dims..., ptr, [type[, source]]) + if (source === af.source.host) { + return af.createArray(secondArg, dims, type); + } + return af.deviceArray(secondArg, dims, type); + } + + if (_.isArray(secondArg)) { + if (_.isNumber(thirdArg)) { + return af.createArray(makeBufferFromJSArray(secondArg, thirdArg), dims, thirdArg); + } + return af.createArray(secondArg, dims); + } + + if (_.isTypedArray(secondArg)) { + if (_.isNumber(thirdArg)) { + return af.createArray(makeBufferFromJSArray(secondArg, thirdArg), dims, thirdArg); + } + return af.createArray(secondArg, dims, af.getDTypeOfTypedArray(secondArg)); + } + + function makeBufferFromJSArray(jsArray, dtype) { + var len = jsArray.length; + var type = af.dtypeToRefType(dtype); + var buff = new Buffer(len * type.size); + for (var i = 0; i < len; i++) { + type.set(buff, i * type.size, jsArray[i]); + } + return buff; + } + + // array(dims...[, type]) + assert(secondArg >= 0 && secondArg <= af.dtype.u16, 'Second argument is not a dtype.'); + return af.createHandle(dims, secondArg); + }, function (handle) { + return new AFArray(af, handle); + }); + + // getDims + + lib.declare('int af_get_dims(longlong* dim0, longlong* dim1, longlong* dim2, longlong* dim3, void* arr)'); + + af.getDims = af._makeFunction(function () { + this.dims = null; + this.n = -1; + }, function (array) { + var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; + + this.dims = new Dim4(); + this.n = n; + var buff = this.dims.buffer; + var dim0 = buff.slice(0); + var dim1 = buff.slice(longlong.size); + var dim2 = buff.slice(longlong.size * 2); + var dim3 = buff.slice(longlong.size * 3); + return intf.af_get_dims(dim0, dim1, dim2, dim3, helpers.getHandle(array)); + }, function () { + var n = this.n; + if (n >= 0 && n < 4) { + return this.dims[n]; + } + return this.dims; + }); + + // getDataPtr + + lib.declare('int af_get_data_ptr(void* ptr, void* arr)'); + + af.getDataPtr = af._makeFunction(function (array, ptr) { + return intf.af_get_data_ptr(ptr, helpers.getHandle(array)); + }); + + // getType + + lib.declare('int af_get_type(uint* outType, void* arr)'); + + af.getType = af._makeFunction(function () { + this.outType = ref.alloc(ref.types.uint); + }, function (array) { + return intf.af_get_type(this.outType, helpers.getHandle(array)); + }, function () { + return this.outType.deref(); + }); + + af.getRefType = af._makeFunction({ + verify: false, + call: function call(array) { + return af.getType(array); + }, + done: function done(type) { + return af.dtypeToRefType(type); + } + }); + + // getNumdims + + lib.declare('int af_get_numdims(uint* outNum, void* arr)'); + + af.getNumdims = af._makeFunction(function () { + this.outNum = ref.alloc(ref.types.uint); + }, function (array) { + return intf.af_get_numdims(this.outNum, helpers.getHandle(array)); + }, function () { + return this.outNum.deref(); + }); + + // getElements + + lib.declare('int af_get_elements(longlong* outElems, void* arr)'); + + af.getElements = af._makeFunction(function () { + this.outElems = ref.alloc(ref.types.longlong); + }, function (array) { + return intf.af_get_elements(this.outElems, helpers.getHandle(array)); + }, function () { + return this.outElems.deref(); + }); + + // isEmpty + + lib.declare('int af_is_empty(bool* outEmpty, void* arr)'); + + af.isEmpty = af._makeFunction(function () { + this.outEmpty = ref.alloc(ref.types.bool); + }, function (array) { + return intf.af_is_empty(this.outEmpty, helpers.getHandle(array)); + }, function () { + return this.outEmpty.deref(); + }); + + // eval + + var hasMultiEval = false; + var multiEvalEmu = null; + lib.declare('int af_eval(void* arr)'); + if (lib.isSymbolExists('af_eval_multiple')) { + lib.declare('int af_eval_multiple(int num, PointerArray arrays)'); + hasMultiEval = true; + } else { + multiEvalEmu = async(regeneratorRuntime.mark(function _callee(arrays, len) { + var i, res; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + i = 0; + + case 1: + if (!(i < len)) { + _context.next = 10; + break; + } + + _context.next = 4; + return intf.af_eval(helpers.getHandle(arr[i])); + + case 4: + res = _context.sent; + + if (!(res > 0)) { + _context.next = 7; + break; + } + + return _context.abrupt('return', res); + + case 7: + i++; + _context.next = 1; + break; + + case 10: + return _context.abrupt('return', 0); + + case 11: + case 'end': + return _context.stop(); + } + } + }, _callee, this); + })); + } + + af.eval = af._makeFunction(function () { + this.pointers = new lib.arrays.PointerArray(10); + }, function (arr) { + if (_.isArray(arr)) { + len = Math.min(10, arr.length); + if (!len) { + return 0; + } + if (hasMultiEval) { + for (var i = 0; i < len; i++) { + this.pointers.set(i, helpers.getHandle(arr[i])); + } + return intf.af_eval_multiple(len, this.pointers); + } else if (af.options.async) { + return multiEvalEmu(arr, len); + } else { + for (var _i = 0; _i < len; _i++) { + var res = intf.af_eval(helpers.getHandle(arr[_i])); + if (res > 0) { + return res; + } + } + return 0; + } + } else { + return intf.af_eval(helpers.getHandle(arr)); + } + }); + + // index + assign + + arrayIndexing(af, AFArray); + } + }]); + + function AFArray(af, handle) { + _classCallCheck(this, AFArray); + + var _this = _possibleConstructorReturn(this, (AFArray.__proto__ || Object.getPrototypeOf(AFArray)).call(this, function () { + return af.releaseArray(handle); + })); + + _this.af = af; + _this.handle = handle; + _this._host = _this._makeHost(); + _this._toArray = _this._makeToArray(); + _this._toRefArray = _this._makeToRefArray(); + _this._index = _this._makeIndex(); + _this._assign = _this._makeAssign(); + return _this; + } + + _createClass(AFArray, [{ + key: 'type', + value: function type() { + return this.af.getType(this); + } + }, { + key: 'refType', + value: function refType() { + return this.af.getRefType(this); + } + }, { + key: 'dims', + value: function dims(n) { + return this.af.getDims(this, n); + } + }, { + key: 'host', + value: function host(ptr) { + return this._host(ptr); + } + }, { + key: 'toRefArray', + value: function toRefArray() { + return this._toRefArray(); + } + }, { + key: 'toArray', + value: function toArray() { + return this._toArray(); + } + }, { + key: 'numdims', + value: function numdims() { + return this.af.getNumdims(this); + } + }, { + key: 'elements', + value: function elements() { + return this.af.getElements(this); + } + }, { + key: 'isempty', + value: function isempty() { + return this.af.isEmpty(this); + } + }, { + key: 'eval', + value: function _eval() { + return this.af.eval(this); + } + }, { + key: 'index', + value: function index(idx) { + return this._index(idx); + } + }, { + key: 'assign', + value: function assign(idx, value) { + return this._assign(idx, value); + } + }, { + key: '_makeToArray', + value: function _makeToArray() { + var self = this; + var af = this.af; + if (af.options.async) { + return async(regeneratorRuntime.mark(function _callee2(ptr) { + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.t0 = refArrayToArray; + _context2.next = 3; + return self.toRefArray(); + + case 3: + _context2.t1 = _context2.sent; + return _context2.abrupt('return', (0, _context2.t0)(_context2.t1)); + + case 5: + case 'end': + return _context2.stop(); + } + } + }, _callee2, this); + })); + } + return function () { + return refArrayToArray(self.toRefArray()); + }; + + function refArrayToArray(refArr) { + var arr = new Array(refArr.length); + for (var i = 0; i < refArr.length; i++) { + arr[i] = refArr.get(i); + } + return arr; + } + } + }, { + key: '_makeToRefArray', + value: function _makeToRefArray() { + var self = this; + var af = this.af; + if (af.options.async) { + return async(regeneratorRuntime.mark(function _callee3(ptr) { + var HostArray, arr; + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + _context3.t0 = ArrayType; + _context3.next = 3; + return self.refType(); + + case 3: + _context3.t1 = _context3.sent; + HostArray = new _context3.t0(_context3.t1); + _context3.t2 = HostArray; + _context3.next = 8; + return self.elements(); + + case 8: + _context3.t3 = _context3.sent; + arr = new _context3.t2(_context3.t3); + _context3.next = 12; + return af.getDataPtr(self, arr.buffer); + + case 12: + return _context3.abrupt('return', arr); + + case 13: + case 'end': + return _context3.stop(); + } + } + }, _callee3, this); + })); + } + return function () { + var HostArray = new ArrayType(self.refType()); + var arr = new HostArray(self.elements()); + af.getDataPtr(self, arr.buffer); + return arr; + }; + } + }, { + key: '_makeHost', + value: function _makeHost() { + var self = this; + var af = this.af; + if (af.options.async) { + return async(regeneratorRuntime.mark(function _callee4(ptr) { + var HostArray, elems; + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + if (ptr) { + _context4.next = 10; + break; + } + + _context4.t0 = ArrayType; + _context4.next = 4; + return self.refType(); + + case 4: + _context4.t1 = _context4.sent; + HostArray = new _context4.t0(_context4.t1); + _context4.next = 8; + return self.elements(); + + case 8: + elems = _context4.sent; + + ptr = new HostArray(elems).buffer; + + case 10: + assert(Buffer.isBuffer(ptr), 'Argument "ptr" is not a Buffer.'); + _context4.next = 13; + return af.getDataPtr(self, ptr); + + case 13: + return _context4.abrupt('return', ptr); + + case 14: + case 'end': + return _context4.stop(); + } + } + }, _callee4, this); + })); + } + return function (ptr) { + if (!ptr) { + var HostArray = new ArrayType(self.refType()); + ptr = new HostArray(self.elements()).buffer; + } + assert(Buffer.isBuffer(ptr), 'Argument "ptr" is not a Buffer.'); + af.getDataPtr(self, ptr); + return ptr; + }; + } + }, { + key: '_makeIndex', + value: function _makeIndex() { + var self = this; + var af = this.af; + if (af.options.async) { + return async(regeneratorRuntime.mark(function _callee5(idx) { + var newHandle; + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + _context5.next = 2; + return af.index(self, idx); + + case 2: + newHandle = _context5.sent; + return _context5.abrupt('return', new AFArray(af, newHandle)); + + case 4: + case 'end': + return _context5.stop(); + } + } + }, _callee5, this); + })); + } + return function (idx) { + var newHandle = af.index(self, idx); + return new AFArray(af, newHandle); + }; + } + }, { + key: '_makeAssign', + value: function _makeAssign() { + var self = this; + var af = this.af; + if (af.options.async) { + return async(regeneratorRuntime.mark(function _callee6(idx, value) { + var newHandle, otherHandle; + return regeneratorRuntime.wrap(function _callee6$(_context6) { + while (1) { + switch (_context6.prev = _context6.next) { + case 0: + newHandle = void 0; + + if (!(value === undefined)) { + _context6.next = 8; + break; + } + + otherHandle = helpers.getHandle(idx); + _context6.next = 5; + return af.retainArray(otherHandle); + + case 5: + newHandle = _context6.sent; + _context6.next = 11; + break; + + case 8: + _context6.next = 10; + return af.assign(self, idx, value); + + case 10: + newHandle = _context6.sent; + + case 11: + _context6.next = 13; + return self.dispose(); + + case 13: + self.resetDisposable(function () { + return af.releaseArray(newHandle); + }); + self.handle = newHandle; + + case 15: + case 'end': + return _context6.stop(); + } + } + }, _callee6, this); + })); + } + return function (idx, value) { + var newHandle = void 0; + if (value === undefined) { + var otherHandle = helpers.getHandle(idx); + newHandle = af.retainArray(otherHandle); + } else { + newHandle = af.assign(self, idx, value); + } + self.dispose(); + self.resetDisposable(function () { + return af.releaseArray(newHandle); + }); + self.handle = newHandle; + }; + } + }]); + + return AFArray; +}(Disposable); + +module.exports = AFArray; +//# sourceMappingURL=AFArray.js.map \ No newline at end of file diff --git a/lib/es5/AFArray.js.map b/lib/es5/AFArray.js.map new file mode 100644 index 0000000..da2039b --- /dev/null +++ b/lib/es5/AFArray.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/AFArray.js"],"names":["fastcall","require","ref","errors","assert","Disposable","typedefs","DimTArray","Dim4","longlong","types","Promise","async","coroutine","ArrayType","arrayIndexing","_","helpers","AFArray","af","lib","_lib","intf","interface","declare","retainArray","_makeFunction","res","alloc","handleType","array","af_retain_array","getHandle","deref","releaseArray","af_release_array","createHandle","dims","type","len","ndims","af_create_handle","buffer","createArray","data","dtype","f32","af_create_array","toBuffer","err","TypeError","deviceArray","Buffer","isBuffer","af_device_array","argsLen","arguments","length","firstArg","isArray","dim4","isTypedArray","getDTypeOfTypedArray","secondArg","moddims","thirdArg","source","host","index","isNumber","makeBufferFromJSArray","jsArray","dtypeToRefType","buff","size","i","set","u16","handle","getDims","n","dim0","slice","dim1","dim2","dim3","af_get_dims","getDataPtr","ptr","af_get_data_ptr","getType","outType","uint","af_get_type","getRefType","verify","call","done","getNumdims","outNum","af_get_numdims","getElements","outElems","af_get_elements","isEmpty","outEmpty","bool","af_is_empty","hasMultiEval","multiEvalEmu","isSymbolExists","arrays","af_eval","arr","eval","pointers","PointerArray","Math","min","af_eval_multiple","options","_host","_makeHost","_toArray","_makeToArray","_toRefArray","_makeToRefArray","_index","_makeIndex","_assign","_makeAssign","idx","value","self","refArrayToArray","toRefArray","refArr","Array","get","refType","HostArray","elements","elems","newHandle","undefined","otherHandle","assign","dispose","resetDisposable","module","exports"],"mappings":"AAAA;;;;;;;;;;AACA,IAAMA,WAAWC,QAAQ,UAAR,CAAjB;AACA,IAAMC,MAAMF,SAASE,GAArB;AACA,IAAMC,SAASF,QAAQ,UAAR,CAAf;AACA,IAAMG,SAASH,QAAQ,QAAR,CAAf;AACA,IAAMI,aAAaL,SAASK,UAA5B;AACA,IAAMC,WAAWL,QAAQ,YAAR,CAAjB;AACA,IAAMM,YAAYD,SAASC,SAA3B;AACA,IAAMC,OAAOP,QAAQ,QAAR,CAAb;AACA,IAAMQ,WAAWP,IAAIQ,KAAJ,CAAUD,QAA3B;AACA,IAAME,UAAUV,QAAQ,UAAR,CAAhB;AACA,IAAMW,QAAQD,QAAQE,SAAtB;AACA,IAAMC,YAAYd,SAASc,SAA3B;AACA,IAAMC,gBAAgBd,QAAQ,iBAAR,CAAtB;AACA,IAAMe,IAAIf,QAAQ,QAAR,CAAV;AACA,IAAMgB,UAAUhB,QAAQ,WAAR,CAAhB;;IAEMiB,O;;;;;+BACYC,E,EAAI;AACd,gBAAMC,MAAMD,GAAGE,IAAf;AACA,gBAAMC,OAAOF,IAAIG,SAAjB;;AAEA;;AAEAH,gBAAII,OAAJ,CAAY,+CAAZ;;AAEAL,eAAGM,WAAH,GAAiBN,GAAGO,aAAH,CACb,YAAY;AACR,qBAAKC,GAAL,GAAWzB,IAAI0B,KAAJ,CAAUtB,SAASuB,UAAnB,CAAX;AACH,aAHY,EAIb,UAAUC,KAAV,EAAiB;AACb,uBAAOR,KAAKS,eAAL,CAAqB,KAAKJ,GAA1B,EAA+BV,QAAQe,SAAR,CAAk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W,kBAAJ;AACA,oBAAIX,UAAUY,SAAd,EAAyB;AACrB,wBAAMC,cAAchI,QAAQe,SAAR,CAAkBmG,GAAlB,CAApB;AACAY,gCAAY5H,GAAGM,WAAH,CAAewH,WAAf,CAAZ;AACH,iBAHD,MAIK;AACDF,gCAAY5H,GAAG+H,MAAH,CAAUb,IAAV,EAAgBF,GAAhB,EAAqBC,KAArB,CAAZ;AACH;AACDC,qBAAKc,OAAL;AACAd,qBAAKe,eAAL,CAAqB;AAAA,2BAAMjI,GAAGe,YAAH,CAAgB6G,SAAhB,CAAN;AAAA,iBAArB;AACAV,qBAAKvD,MAAL,GAAciE,SAAd;AACH,aAZD;AAaH;;;;EA9gBiB1I,U;;AAihBtBgJ,OAAOC,OAAP,GAAiBpI,OAAjB","file":"AFArray.js","sourcesContent":["'use strict';\nconst fastcall = require('fastcall');\nconst ref = fastcall.ref;\nconst errors = require('./errors');\nconst assert = require('assert');\nconst Disposable = fastcall.Disposable;\nconst typedefs = require('./typedefs');\nconst DimTArray = typedefs.DimTArray;\nconst Dim4 = require('./Dim4');\nconst longlong = ref.types.longlong;\nconst Promise = require('bluebird');\nconst async = Promise.coroutine;\nconst ArrayType = fastcall.ArrayType;\nconst arrayIndexing = require('./arrayIndexing');\nconst _ = require('lodash');\nconst helpers = require('./helpers');\n\nclass AFArray extends Disposable {\n static define(af) {\n const lib = af._lib;\n const intf = lib.interface;\n\n // retainArray\n\n lib.declare('int af_retain_array(void** outArr, void* arr)');\n\n af.retainArray = af._makeFunction(\n function () {\n this.res = ref.alloc(typedefs.handleType);\n },\n function (array) {\n return intf.af_retain_array(this.res, helpers.getHandle(array));\n },\n function () {\n return ref.deref(this.res);\n });\n\n // releaseArray\n\n lib.declare('int af_release_array(void* arr)');\n\n af.releaseArray = af._makeFunction(\n function (array) {\n return intf.af_release_array(helpers.getHandle(array));\n });\n\n // createHandle\n\n lib.declare('int af_create_handle(void** outArr, uint ndims, longlong* dims, int type)');\n\n af.createHandle = af._makeFunction(\n function () {\n this.res = ref.alloc(typedefs.handleType);\n },\n function (dims = null, type = 0) {\n let len = dims ? dims.ndims : 0;\n return intf.af_create_handle(this.res, len, dims.buffer, type);\n },\n function () {\n return ref.deref(this.res);\n });\n\n // createArray\n\n lib.declare('int af_create_array(void** outArr, void* data, uint ndims, longlong* dims, int type)');\n\n af.createArray = af._makeFunction(\n function () {\n this.res = ref.alloc(typedefs.handleType);\n },\n function (data, dims, type = af.dtype.f32) {\n let len = dims ? dims.ndims : 0;\n try {\n return intf.af_create_array(this.res, helpers.toBuffer(data), len, dims.buffer, type);\n }\n catch (err) {\n if (err instanceof TypeError) {\n throw new TypeError('Argument \"data\" is not a Buffer.');\n }\n throw err;\n }\n },\n function () {\n return ref.deref(this.res);\n });\n\n // deviceArray\n\n lib.declare('int af_device_array(void** outArr, void* data, uint ndims, longlong* dims, int type)');\n\n af.deviceArray = af._makeFunction(\n function () {\n this.res = ref.alloc(typedefs.handleType);\n },\n function (data, dims, type = 0) {\n let len = dims ? dims.ndims : 0;\n assert(Buffer.isBuffer(data), 'Argument \"data\" is not a Buffer.');\n return intf.af_device_array(this.res, data, len, dims.buffer, type);\n },\n function () {\n return ref.deref(this.res);\n });\n\n // ctors\n\n af.array = af._makeFunction(\n function () {\n const argsLen = arguments.length;\n\n // array()\n if (argsLen === 0) {\n return intf.createHandle();\n }\n\n const firstArg = arguments[0];\n\n if (Buffer.isBuffer(firstArg)) {\n // array(handle)\n return firstArg;\n }\n\n if (_.isArray(firstArg)) {\n return af.createArray(firstArg, af.dim4(firstArg.length));\n }\n\n if (_.isTypedArray(firstArg)) {\n return af.createArray(firstArg, af.dim4(firstArg.length), af.getDTypeOfTypedArray(firstArg));\n }\n\n if (firstArg instanceof AFArray) {\n if (argsLen === 1) {\n // array(otherArray)\n return af.retainArray(firstArg);\n }\n else {\n // array(otherArray, dims...)\n const secondArg = arguments[1];\n assert(secondArg instanceof Dim4, 'Second argument is not a dimension.');\n return af.moddims(firstArg, arguments[1]);\n }\n }\n\n const dims = af.dim4(firstArg);\n\n assert(dims.ndims > 0, 'First argument is not a dimension.');\n\n if (argsLen === 1) {\n // array(dims..., f32)\n return af.createHandle(dims, af.dtype.f32);\n }\n\n let secondArg = arguments[1];\n let thirdArg = argsLen >= 3 ? arguments[2] : null;\n\n if (Buffer.isBuffer(secondArg)) {\n let type = af.dtype.f32;\n let source = af.source.host;\n let index = 2;\n if (index < argsLen) {\n type = arguments[index];\n index++;\n if (index < argsLen) {\n source = arguments[index];\n }\n }\n // array(dims..., ptr, [type[, source]])\n if (source === af.source.host) {\n return af.createArray(secondArg, dims, type);\n }\n return af.deviceArray(secondArg, dims, type);\n }\n\n if (_.isArray(secondArg)) {\n if (_.isNumber(thirdArg)) {\n return af.createArray(makeBufferFromJSArray(secondArg, thirdArg), dims, thirdArg);\n }\n return af.createArray(secondArg, dims);\n }\n\n if (_.isTypedArray(secondArg)) {\n if (_.isNumber(thirdArg)) {\n return af.createArray(makeBufferFromJSArray(secondArg, thirdArg), dims, thirdArg);\n }\n return af.createArray(secondArg, dims, af.getDTypeOfTypedArray(secondArg));\n }\n\n function makeBufferFromJSArray(jsArray, dtype) {\n const len = jsArray.length;\n const type = af.dtypeToRefType(dtype);\n const buff = new Buffer(len * type.size);\n for (let i = 0; i < len; i++) {\n type.set(buff, i * type.size, jsArray[i]);\n }\n return buff;\n }\n\n // array(dims...[, type])\n assert(secondArg >= 0 && secondArg <= af.dtype.u16, 'Second argument is not a dtype.');\n return af.createHandle(dims, secondArg);\n },\n function (handle) {\n return new AFArray(af, handle);\n });\n\n // getDims\n\n lib.declare('int af_get_dims(longlong* dim0, longlong* dim1, longlong* dim2, longlong* dim3, void* arr)');\n\n af.getDims = af._makeFunction(\n function () {\n this.dims = null;\n this.n = -1;\n },\n function (array, n = -1) {\n this.dims = new Dim4();\n this.n = n;\n const buff = this.dims.buffer;\n const dim0 = buff.slice(0);\n const dim1 = buff.slice(longlong.size);\n const dim2 = buff.slice(longlong.size * 2);\n const dim3 = buff.slice(longlong.size * 3);\n return intf.af_get_dims(dim0, dim1, dim2, dim3, helpers.getHandle(array));\n },\n function () {\n const n = this.n;\n if (n >= 0 && n < 4) {\n return this.dims[n];\n }\n return this.dims;\n });\n\n // getDataPtr\n\n lib.declare('int af_get_data_ptr(void* ptr, void* arr)');\n\n af.getDataPtr = af._makeFunction(\n function (array, ptr) {\n return intf.af_get_data_ptr(ptr, helpers.getHandle(array));\n });\n\n // getType\n\n lib.declare('int af_get_type(uint* outType, void* arr)');\n\n af.getType = af._makeFunction(\n function () {\n this.outType = ref.alloc(ref.types.uint);\n },\n function (array) {\n return intf.af_get_type(this.outType, helpers.getHandle(array));\n },\n function () {\n return this.outType.deref();\n });\n\n af.getRefType = af._makeFunction(\n {\n verify: false,\n call(array) {\n return af.getType(array);\n },\n done(type) {\n return af.dtypeToRefType(type);\n }\n });\n\n // getNumdims\n\n lib.declare('int af_get_numdims(uint* outNum, void* arr)');\n\n af.getNumdims = af._makeFunction(\n function () {\n this.outNum = ref.alloc(ref.types.uint);\n },\n function (array) {\n return intf.af_get_numdims(this.outNum, helpers.getHandle(array));\n },\n function () {\n return this.outNum.deref();\n });\n\n // getElements\n\n lib.declare('int af_get_elements(longlong* outElems, void* arr)');\n\n af.getElements = af._makeFunction(\n function () {\n this.outElems = ref.alloc(ref.types.longlong);\n },\n function (array) {\n return intf.af_get_elements(this.outElems, helpers.getHandle(array));\n },\n function () {\n return this.outElems.deref();\n });\n\n // isEmpty\n\n lib.declare('int af_is_empty(bool* outEmpty, void* arr)');\n\n af.isEmpty = af._makeFunction(\n function () {\n this.outEmpty = ref.alloc(ref.types.bool);\n },\n function (array) {\n return intf.af_is_empty(this.outEmpty, helpers.getHandle(array));\n },\n function () {\n return this.outEmpty.deref();\n });\n\n // eval\n\n let hasMultiEval = false;\n let multiEvalEmu = null;\n lib.declare('int af_eval(void* arr)');\n if (lib.isSymbolExists('af_eval_multiple')) {\n lib.declare('int af_eval_multiple(int num, PointerArray arrays)');\n hasMultiEval = true;\n }\n else {\n multiEvalEmu = async(function* (arrays, len) {\n for (let i = 0; i < len; i++) {\n const res = yield intf.af_eval(helpers.getHandle(arr[i]));\n if (res > 0) {\n return res;\n }\n }\n return 0;\n });\n }\n\n af.eval = af._makeFunction(\n function () {\n this.pointers = new lib.arrays.PointerArray(10);\n },\n function (arr) {\n if (_.isArray(arr)) {\n len = Math.min(10, arr.length);\n if (!len) {\n return 0;\n }\n if (hasMultiEval) {\n for (let i = 0; i < len; i++) {\n this.pointers.set(i, helpers.getHandle(arr[i]));\n }\n return intf.af_eval_multiple(len, this.pointers);\n }\n else if (af.options.async) {\n return multiEvalEmu(arr, len);\n }\n else {\n for (let i = 0; i < len; i++) {\n const res = intf.af_eval(helpers.getHandle(arr[i]));\n if (res > 0) {\n return res;\n }\n }\n return 0;\n }\n }\n else {\n return intf.af_eval(helpers.getHandle(arr));\n }\n });\n\n // index + assign\n\n arrayIndexing(af, AFArray);\n }\n\n constructor(af, handle) {\n super(() => af.releaseArray(handle));\n\n this.af = af;\n this.handle = handle;\n this._host = this._makeHost();\n this._toArray = this._makeToArray();\n this._toRefArray = this._makeToRefArray();\n this._index = this._makeIndex();\n this._assign = this._makeAssign();\n }\n\n type() {\n return this.af.getType(this);\n }\n\n refType() {\n return this.af.getRefType(this);\n }\n\n dims(n) {\n return this.af.getDims(this, n);\n }\n\n host(ptr) {\n return this._host(ptr);\n }\n\n toRefArray() {\n return this._toRefArray();\n }\n\n toArray() {\n return this._toArray();\n }\n\n numdims() {\n return this.af.getNumdims(this);\n }\n\n elements() {\n return this.af.getElements(this);\n }\n\n isempty() {\n return this.af.isEmpty(this);\n }\n\n eval() {\n return this.af.eval(this);\n }\n\n index(idx) {\n return this._index(idx);\n }\n\n assign(idx, value) {\n return this._assign(idx, value);\n }\n\n _makeToArray() {\n const self = this;\n const af = this.af;\n if (af.options.async) {\n return async(function* (ptr) {\n return refArrayToArray(yield self.toRefArray());\n });\n }\n return function () {\n return refArrayToArray(self.toRefArray());\n };\n\n function refArrayToArray(refArr) {\n const arr = new Array(refArr.length);\n for (let i = 0; i < refArr.length; i++) {\n arr[i] = refArr.get(i);\n }\n return arr;\n }\n }\n\n _makeToRefArray() {\n const self = this;\n const af = this.af;\n if (af.options.async) {\n return async(function* (ptr) {\n const HostArray = new ArrayType(yield self.refType());\n const arr = new HostArray(yield self.elements());\n yield af.getDataPtr(self, arr.buffer);\n return arr;\n });\n }\n return function () {\n const HostArray = new ArrayType(self.refType());\n const arr = new HostArray(self.elements());\n af.getDataPtr(self, arr.buffer);\n return arr;\n };\n }\n\n _makeHost() {\n const self = this;\n const af = this.af;\n if (af.options.async) {\n return async(function* (ptr) {\n if (!ptr) {\n const HostArray = new ArrayType(yield self.refType());\n const elems = yield self.elements();\n ptr = new HostArray(elems).buffer;\n }\n assert(Buffer.isBuffer(ptr), 'Argument \"ptr\" is not a Buffer.');\n yield af.getDataPtr(self, ptr);\n return ptr;\n });\n }\n return function (ptr) {\n if (!ptr) {\n const HostArray = new ArrayType(self.refType());\n ptr = new HostArray(self.elements()).buffer;\n }\n assert(Buffer.isBuffer(ptr), 'Argument \"ptr\" is not a Buffer.');\n af.getDataPtr(self, ptr);\n return ptr;\n };\n }\n\n _makeIndex() {\n const self = this;\n const af = this.af;\n if (af.options.async) {\n return async(function* (idx) {\n const newHandle = yield af.index(self, idx);\n return new AFArray(af, newHandle);\n });\n }\n return function (idx) {\n const newHandle = af.index(self, idx);\n return new AFArray(af, newHandle);\n };\n }\n\n _makeAssign() {\n const self = this;\n const af = this.af;\n if (af.options.async) {\n return async(function* (idx, value) {\n let newHandle;\n if (value === undefined) {\n const otherHandle = helpers.getHandle(idx);\n newHandle = yield af.retainArray(otherHandle);\n }\n else {\n newHandle = yield af.assign(self, idx, value);\n }\n yield self.dispose();\n self.resetDisposable(() => af.releaseArray(newHandle));\n self.handle = newHandle;\n });\n }\n return function (idx, value) {\n let newHandle;\n if (value === undefined) {\n const otherHandle = helpers.getHandle(idx);\n newHandle = af.retainArray(otherHandle);\n }\n else {\n newHandle = af.assign(self, idx, value);\n }\n self.dispose();\n self.resetDisposable(() => af.releaseArray(newHandle));\n self.handle = newHandle;\n };\n }\n}\n\nmodule.exports = AFArray;"]} \ No newline at end of file diff --git a/lib/es5/ArrayFire.js b/lib/es5/ArrayFire.js new file mode 100644 index 0000000..495de54 --- /dev/null +++ b/lib/es5/ArrayFire.js @@ -0,0 +1,319 @@ +'use strict'; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +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 os = require('os'); +var _ = require('lodash'); +var fastcall = require('fastcall'); +var Promise = require('bluebird'); +var Library = fastcall.Library; +var device = require('./device'); +var errors = require('./errors'); +var enums = require('./enums'); +var unified = require('./unified'); +var AFArray = require('./AFArray'); +var create = require('./create'); +var assert = require('assert'); +var typedefs = require('./typedefs'); +var Dim4 = require('./Dim4'); +var Idx = require('./Idx'); +var Seq = require('./Seq'); +var Col = require('./Col'); +var Cols = require('./Cols'); +var Row = require('./Row'); +var Rows = require('./Rows'); +var ref = fastcall.ref; + +var defOptions = { + async: false, + chainable: true +}; + +var span = Symbol('span'); + +var created = false; + +var dtypeMap = null; + +var ArrayFire = function () { + function ArrayFire(options) { + _classCallCheck(this, ArrayFire); + + if (created) { + throw new Error('Only one instance of ArrayFire class allowed.'); + } + + this.options = Object.freeze(_.defaults(options, defOptions)); + this._lib = new Library(getLibName(), this._makeLibOptions()); + this._batch = false; + + typedefs.define(this); + Dim4.define(this); + Idx.define(this); + Seq.define(this); + Col.define(this); + Cols.define(this); + Row.define(this); + Rows.define(this); + device(this); + unified(this); + AFArray.define(this); + create(this); + + created = true; + } + + _createClass(ArrayFire, [{ + key: 'release', + value: function release() { + this._lib.release(); + created = false; + } + }, { + key: 'enumToString', + value: function enumToString(values, value) { + assert(_.isObject(values), 'Argument "values" is not an object.'); + + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = _.keys(values)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var key = _step.value; + + var curr = values[key]; + if (curr === value) { + return key; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + throw new TypeError('Value "' + value + '" not fuond on enum values.'); + } + }, { + key: 'getDTypeOfTypedArray', + value: function getDTypeOfTypedArray(array) { + if (array instanceof Int8Array) { + return enums.dtype.u8; + } + if (array instanceof Uint8Array) { + return enums.dtype.u8; + } + if (array instanceof Uint8ClampedArray) { + return enums.dtype.u8; + } + if (array instanceof Int16Array) { + return enums.dtype.s16; + } + if (array instanceof Uint16Array) { + return enums.dtype.u16; + } + if (array instanceof Int32Array) { + return enums.dtype.s32; + } + if (array instanceof Uint32Array) { + return enums.dtype.u32; + } + if (array instanceof Float32Array) { + return enums.dtype.f32; + } + if (array instanceof Float64Array) { + return enums.dtype.f64; + } + throw new TypeError('Argument "array" is not a typed array.'); + } + }, { + key: 'dtypeToRefType', + value: function dtypeToRefType(type) { + switch (type) { + case enums.dtype.f32: + return ref.types.float; + case enums.dtype.c32: + throw new Error('Complext types are not supported yet.'); + case enums.dtype.f64: + return ref.types.double; + case enums.dtype.c64: + throw new Error('Complext types are not supported yet.'); + case enums.dtype.b8: + return ref.types.bool; + case enums.dtype.s32: + return ref.types.uint32; + case enums.dtype.u32: + return ref.types.uint32; + case enums.dtype.u8: + return ref.types.uint8; + case enums.dtype.s64: + return ref.types.int64; + case enums.dtype.u64: + return ref.types.uint64; + case enums.dtype.s16: + return ref.types.int16; + case enums.dtype.u16: + return ref.types.uint16; + default: + throw new TypeError('Argument value "' + type + '" is not a valid dtype.'); + } + } + }, { + key: '_makeFunction', + value: function _makeFunction(init, call, done) { + var verify = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + + if (_.isPlainObject(init)) { + var args = init; + init = args.init || _.noop; + call = args.call; + done = args.done; + verify = args.verify === undefined ? true : args.verify; + } else if (done === undefined) { + done = call; + call = init; + init = _.noop; + } + + var Caller = function Caller() { + init.call(this); + }; + + Caller.prototype.call = call; + + Caller.prototype.done = done || _.noop; + + if (this.options.async) { + if (this.options.chainable) { + Caller.prototype.call = ArrayFire._asChainable(call); + } + Caller.prototype.process = function () { + var _this = this; + + return this.call.apply(this, arguments).then(function (result) { + if (verify) { + errors.verify(result); + } + return _this.done(result); + }); + }; + return function () { + var caller = new Caller(); + return caller.process.apply(caller, arguments); + }; + } else { + var _ret = function () { + Caller.prototype.process = function () { + var result = this.call.apply(this, arguments); + if (verify) { + errors.verify(result); + } + return this.done(result); + }; + var caller = new Caller(); + return { + v: function v() { + return caller.process.apply(caller, arguments); + } + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + } + } + }, { + key: '_makeLibOptions', + value: function _makeLibOptions() { + return { + callMode: this.options.async ? Library.callMode.async : Library.callMode.sync, + syncMode: Library.syncMode.lock // TODO: benchmark for this + }; + } + }, { + key: 'scope', + get: function get() { + return fastcall.scope; + } + }, { + key: 'span', + get: function get() { + return span; + } + }, { + key: 'end', + get: function get() { + return -1; + } + }, { + key: 'backend', + get: function get() { + return enums.backend; + } + }, { + key: 'dtype', + get: function get() { + return enums.dtype; + } + }, { + key: 'source', + get: function get() { + return enums.source; + } + }], [{ + key: '_asChainable', + value: function _asChainable(func) { + return function () { + var _this2 = this; + + var errs = []; + return Promise.map(arguments, function (arg, idx) { + return Promise.resolve(arg).catch(function (err) { + errs.push(err); + return null; + }); + }).then(function (args) { + if (errs.length) { + throw new errors.ArrayFireChainedError(errs); + } + return func.apply(_this2, args); + }); + }; + } + }]); + + return ArrayFire; +}(); + +module.exports = ArrayFire; + +function getLibName() { + var plat = os.platform(); + var isWin = plat === 'win32'; + var isOSX = plat === 'darwin'; + var postfix = ''; + var prefix = ''; + if (isOSX) { + postfix = '.dynlib'; + } else if (!isWin) { + postfix = '.so'; + } + if (!isWin) { + prefix = 'lib'; + } + return prefix + 'af' + postfix; +} +//# sourceMappingURL=ArrayFire.js.map \ No newline at end of file diff --git a/lib/es5/ArrayFire.js.map b/lib/es5/ArrayFire.js.map new file mode 100644 index 0000000..2c35fc7 --- /dev/null +++ b/lib/es5/ArrayFire.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/ArrayFire.js"],"names":["os","require","_","fastcall","Promise","Library","device","errors","enums","unified","AFArray","create","assert","typedefs","Dim4","Idx","Seq","Col","Cols","Row","Rows","ref","defOptions","async","chainable","span","Symbol","created","dtypeMap","ArrayFire","options","Error","Object","freeze","defaults","_lib","getLibName","_makeLibOptions","_batch","define","release","values","value","isObject","keys","key","curr","TypeError","array","Int8Array","dtype","u8","Uint8Array","Uint8ClampedArray","Int16Array","s16","Uint16Array","u16","Int32Array","s32","Uint32Array","u32","Float32Array","f32","Float64Array","f64","type","types","float","c32","double","c64","b8","bool","uint32","uint8","s64","int64","u64","uint64","int16","uint16","init","call","done","verify","isPlainObject","args","noop","undefined","Caller","prototype","_asChainable","process","apply","arguments","then","result","caller","callMode","sync","syncMode","lock","scope","backend","source","func","errs","map","arg","idx","resolve","catch","push","err","length","ArrayFireChainedError","module","exports","plat","platform","isWin","isOSX","postfix","prefix"],"mappings":"AAAA;;;;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AACF,KAAL,EAAY;AACRG,iBAAS,KAAT;AACH;AACD,WAAOA,SAAS,IAAT,GAAgBD,OAAvB;AACH","file":"ArrayFire.js","sourcesContent":["'use strict';\nconst os = require('os');\nconst _ = require('lodash');\nconst fastcall = require('fastcall');\nconst Promise = require('bluebird');\nconst Library = fastcall.Library;\nconst device = require('./device');\nconst errors = require('./errors');\nconst enums = require('./enums');\nconst unified = require('./unified');\nconst AFArray = require('./AFArray');\nconst create = require('./create');\nconst assert = require('assert');\nconst typedefs = require('./typedefs');\nconst Dim4 = require('./Dim4');\nconst Idx = require('./Idx');\nconst Seq = require('./Seq');\nconst Col = require('./Col');\nconst Cols = require('./Cols');\nconst Row = require('./Row');\nconst Rows = require('./Rows');\nconst ref = fastcall.ref;\n\nconst defOptions = {\n async: false,\n chainable: true\n};\n\nconst span = Symbol('span');\n\nlet created = false;\n\nlet dtypeMap = null;\n\nclass ArrayFire {\n constructor(options) {\n if (created) {\n throw new Error('Only one instance of ArrayFire class allowed.');\n }\n\n this.options = Object.freeze(_.defaults(options, defOptions));\n this._lib = new Library(getLibName(), this._makeLibOptions());\n this._batch = false;\n\n typedefs.define(this);\n Dim4.define(this);\n Idx.define(this);\n Seq.define(this);\n Col.define(this);\n Cols.define(this);\n Row.define(this);\n Rows.define(this);\n device(this);\n unified(this);\n AFArray.define(this);\n create(this);\n\n created = true;\n }\n\n release() {\n this._lib.release();\n created = false;\n }\n\n get scope() {\n return fastcall.scope;\n }\n\n get span() {\n return span;\n }\n\n get end() {\n return -1;\n }\n\n get backend() {\n return enums.backend;\n }\n\n get dtype() {\n return enums.dtype;\n }\n\n get source() {\n return enums.source;\n }\n\n enumToString(values, value) {\n assert(_.isObject(values), 'Argument \"values\" is not an object.');\n\n for (const key of _.keys(values)) {\n const curr = values[key];\n if (curr === value) {\n return key;\n }\n }\n\n throw new TypeError(`Value \"${ value }\" not fuond on enum values.`);\n }\n\n getDTypeOfTypedArray(array) {\n if (array instanceof Int8Array) {\n return enums.dtype.u8;\n }\n if (array instanceof Uint8Array) {\n return enums.dtype.u8;\n }\n if (array instanceof Uint8ClampedArray) {\n return enums.dtype.u8;\n }\n if (array instanceof Int16Array) {\n return enums.dtype.s16;\n }\n if (array instanceof Uint16Array) {\n return enums.dtype.u16;\n }\n if (array instanceof Int32Array) {\n return enums.dtype.s32;\n }\n if (array instanceof Uint32Array) {\n return enums.dtype.u32;\n }\n if (array instanceof Float32Array) {\n return enums.dtype.f32;\n }\n if (array instanceof Float64Array) {\n return enums.dtype.f64;\n }\n throw new TypeError('Argument \"array\" is not a typed array.');\n }\n\n dtypeToRefType(type) {\n switch (type) {\n case enums.dtype.f32:\n return ref.types.float;\n case enums.dtype.c32:\n throw new Error('Complext types are not supported yet.');\n case enums.dtype.f64:\n return ref.types.double;\n case enums.dtype.c64:\n throw new Error('Complext types are not supported yet.');\n case enums.dtype.b8:\n return ref.types.bool;\n case enums.dtype.s32:\n return ref.types.uint32;\n case enums.dtype.u32:\n return ref.types.uint32;\n case enums.dtype.u8:\n return ref.types.uint8;\n case enums.dtype.s64:\n return ref.types.int64;\n case enums.dtype.u64:\n return ref.types.uint64;\n case enums.dtype.s16:\n return ref.types.int16;\n case enums.dtype.u16:\n return ref.types.uint16;\n default:\n throw new TypeError(`Argument value \"${ type }\" is not a valid dtype.`);\n }\n }\n\n _makeFunction(init, call, done, verify = true) {\n if (_.isPlainObject(init)) {\n const args = init;\n init = args.init || _.noop;\n call = args.call;\n done = args.done;\n verify = args.verify === undefined ? true : args.verify;\n }\n else if (done === undefined) {\n done = call;\n call = init;\n init = _.noop;\n }\n\n const Caller = function () {\n init.call(this);\n };\n\n Caller.prototype.call = call;\n\n Caller.prototype.done = done || _.noop;\n\n if (this.options.async) {\n if (this.options.chainable) {\n Caller.prototype.call = ArrayFire._asChainable(call);\n }\n Caller.prototype.process = function () {\n return this.call.apply(this, arguments)\n .then(result => {\n if (verify) {\n errors.verify(result);\n }\n return this.done(result);\n });\n };\n return function () {\n const caller = new Caller();\n return caller.process.apply(caller, arguments);\n };\n }\n else {\n Caller.prototype.process = function () {\n const result = this.call.apply(this, arguments);\n if (verify) {\n errors.verify(result);\n }\n return this.done(result);\n };\n const caller = new Caller();\n return function () {\n return caller.process.apply(caller, arguments);\n };\n }\n }\n\n static _asChainable(func) {\n return function () {\n const errs = [];\n return Promise.map(arguments, (arg, idx) => {\n return Promise.resolve(arg)\n .catch(err => {\n errs.push(err);\n return null;\n });\n })\n .then(args => {\n if (errs.length) {\n throw new errors.ArrayFireChainedError(errs);\n }\n return func.apply(this, args);\n });\n };\n }\n\n _makeLibOptions() {\n return {\n callMode: this.options.async ? Library.callMode.async : Library.callMode.sync,\n syncMode: Library.syncMode.lock // TODO: benchmark for this\n };\n }\n}\n\nmodule.exports = ArrayFire;\n\nfunction getLibName() {\n const plat = os.platform();\n const isWin = plat === 'win32';\n const isOSX = plat === 'darwin';\n let postfix = '';\n let prefix = '';\n if (isOSX) {\n postfix = '.dynlib';\n }\n else if (!isWin) {\n postfix = '.so';\n }\n if (!isWin) {\n prefix = 'lib';\n }\n return prefix + 'af' + postfix;\n}"]} \ No newline at end of file diff --git a/lib/es5/Col.js b/lib/es5/Col.js new file mode 100644 index 0000000..e4e9cea --- /dev/null +++ b/lib/es5/Col.js @@ -0,0 +1,27 @@ +'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 Col = function () { + _createClass(Col, null, [{ + key: 'define', + value: function define(af) { + af.col = function (index) { + return new Col(index); + }; + } + }]); + + function Col(index) { + _classCallCheck(this, Col); + + this.index = index; + } + + return Col; +}(); + +module.exports = Col; +//# sourceMappingURL=Col.js.map \ No newline at end of file diff --git a/lib/es5/Col.js.map b/lib/es5/Col.js.map new file mode 100644 index 0000000..e1dfe9e --- /dev/null +++ b/lib/es5/Col.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/Col.js"],"names":["Col","af","col","index","module","exports"],"mappings":"AAAA;;;;;;IAEMA,G;;;+BACYC,E,EAAI;AACdA,eAAGC,GAAH,GAAS,UAAUC,KAAV,EAAiB;AACtB,uBAAO,IAAIH,GAAJ,CAAQG,KAAR,CAAP;AACH,aAFD;AAGH;;;AAED,iBAAYA,KAAZ,EAAmB;AAAA;;AACf,aAAKA,KAAL,GAAaA,KAAb;AACH;;;;;AAGLC,OAAOC,OAAP,GAAiBL,GAAjB","file":"Col.js","sourcesContent":["'use strict';\n\nclass Col {\n static define(af) {\n af.col = function (index) {\n return new Col(index);\n };\n }\n\n constructor(index) {\n this.index = index;\n }\n}\n\nmodule.exports = Col;"]} \ No newline at end of file diff --git a/lib/es5/Cols.js b/lib/es5/Cols.js new file mode 100644 index 0000000..6e30d7d --- /dev/null +++ b/lib/es5/Cols.js @@ -0,0 +1,28 @@ +'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 Cols = function () { + _createClass(Cols, null, [{ + key: 'define', + value: function define(af) { + af.cols = function (firstIndex, lastIndex) { + return new Cols(firstIndex, lastIndex); + }; + } + }]); + + function Cols(firstIndex, lastIndex) { + _classCallCheck(this, Cols); + + this.firstIndex = firstIndex; + this.lastIndex = lastIndex; + } + + return Cols; +}(); + +module.exports = Cols; +//# sourceMappingURL=Cols.js.map \ No newline at end of file diff --git a/lib/es5/Cols.js.map b/lib/es5/Cols.js.map new file mode 100644 index 0000000..c5d4dc8 --- /dev/null +++ b/lib/es5/Cols.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/Cols.js"],"names":["Cols","af","cols","firstIndex","lastIndex","module","exports"],"mappings":"AAAA;;;;;;IAEMA,I;;;+BACYC,E,EAAI;AACdA,eAAGC,IAAH,GAAU,UAAUC,UAAV,EAAsBC,SAAtB,EAAiC;AACvC,uBAAO,IAAIJ,IAAJ,CAASG,UAAT,EAAqBC,SAArB,CAAP;AACH,aAFD;AAGH;;;AAED,kBAAYD,UAAZ,EAAwBC,SAAxB,EAAmC;AAAA;;AAC/B,aAAKD,UAAL,GAAkBA,UAAlB;AACA,aAAKC,SAAL,GAAiBA,SAAjB;AACH;;;;;AAGLC,OAAOC,OAAP,GAAiBN,IAAjB","file":"Cols.js","sourcesContent":["'use strict';\n\nclass Cols {\n static define(af) {\n af.cols = function (firstIndex, lastIndex) {\n return new Cols(firstIndex, lastIndex);\n };\n }\n\n constructor(firstIndex, lastIndex) {\n this.firstIndex = firstIndex;\n this.lastIndex = lastIndex;\n }\n}\n\nmodule.exports = Cols;"]} \ No newline at end of file diff --git a/lib/es5/Dim4.js b/lib/es5/Dim4.js new file mode 100644 index 0000000..9dd6f80 --- /dev/null +++ b/lib/es5/Dim4.js @@ -0,0 +1,175 @@ +'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 _ = require('lodash'); +var fastcall = require('fastcall'); +var ref = fastcall.ref; +var typedefs = require('./typedefs'); +var DimTArray = typedefs.DimTArray; +var assert = require('assert'); + +var Dim4 = function () { + _createClass(Dim4, null, [{ + key: 'define', + value: function define(af) { + af.dim4 = function () { + return new (Function.prototype.bind.apply(Dim4, [null].concat(Array.prototype.slice.call(arguments))))(); + }; + } + }]); + + function Dim4() { + _classCallCheck(this, Dim4); + + this.data = new DimTArray(); + this.first = 0; + this.second = 0; + this.third = 0; + this.fourth = 0; + + if (arguments.length) { + var firstArg = arguments[0]; + + if (_.isObject(firstArg) || _.isArray(firstArg)) { + if (firstArg[0] >= 0) { + this.first = firstArg[0]; + } + if (firstArg[1] >= 0) { + this.second = firstArg[1]; + } + if (firstArg[2] >= 0) { + this.third = firstArg[2]; + } + if (firstArg[3] >= 0) { + this.fourth = firstArg[3]; + } + } else { + if (arguments[0] >= 0) { + this.first = arguments[0]; + } + if (arguments[1] >= 0) { + this.second = arguments[1]; + } + if (arguments[2] >= 0) { + this.third = arguments[2]; + } + if (arguments[3] >= 0) { + this.fourth = arguments[3]; + } + } + } + } + + _createClass(Dim4, [{ + key: 'first', + get: function get() { + return this.data.get(0); + }, + set: function set(value) { + this.data.set(0, value); + } + }, { + key: 'second', + get: function get() { + return this.data.get(1); + }, + set: function set(value) { + this.data.set(1, value); + } + }, { + key: 'third', + get: function get() { + return this.data.get(2); + }, + set: function set(value) { + this.data.set(2, value); + } + }, { + key: 'fourth', + get: function get() { + return this.data.get(3); + }, + set: function set(value) { + this.data.set(3, value); + } + }, { + key: 0, + get: function get() { + return this.first; + }, + set: function set(value) { + this.first = value; + } + }, { + key: 1, + get: function get() { + return this.second; + }, + set: function set(value) { + this.second = value; + } + }, { + key: 2, + get: function get() { + return this.third; + }, + set: function set(value) { + this.third = value; + } + }, { + key: 3, + get: function get() { + return this.fourth; + }, + set: function set(value) { + this.fourth = value; + } + }, { + key: 'ndims', + get: function get() { + if (this.fourth > 1) { + return 4; + } + if (this.third > 1) { + return 3; + } + if (this.second > 1) { + return 2; + } + if (this.first > 0) { + return 1; + } + return 0; + } + }, { + key: 'elements', + get: function get() { + if (this.fourth > 0) { + return this.fourth * this.third * this.second * this.first; + } + if (this.third > 0) { + return this.third * this.second * this.first; + } + if (this.second > 0) { + return this.second * this.first; + } + if (this.first > 0) { + return this.first; + } + return 0; + } + }, { + key: 'buffer', + get: function get() { + return this.data.buffer; + } + }]); + + return Dim4; +}(); + +module.exports = Dim4; +//# sourceMappingURL=Dim4.js.map \ No newline at end of file diff --git a/lib/es5/Dim4.js.map b/lib/es5/Dim4.js.map new file mode 100644 index 0000000..3315293 --- /dev/null +++ b/lib/es5/Dim4.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/Dim4.js"],"names":["_","require","fastcall","ref","typedefs","DimTArray","assert","Dim4","af","dim4","arguments","data","first","second","third","fourth","length","firstArg","isObject","isArray","get","value","set","buffer","module","exports"],"mappings":"AAAA;;;;;;AACA,IAAMA,IAAIC,QAAQ,QAAR,CAAV;AACA,IAAMC,WAAWD,QAAQ,UAAR,CAAjB;AACA,IAAME,MAAMD,SAASC,GAArB;AACA,IAAMC,WAAWH,QAAQ,YAAR,CAAjB;AACA,IAAMI,YAAYD,SAASC,SAA3B;AACA,IAAMC,SAASL,QAAQ,QAAR,CAAf;;IAEMM,I;;;+BACYC,E,EAAI;AACdA,eAAGC,IAAH,GAAU,YAAY;AAClB,0DAAWF,IAAX,2CAAmBG,SAAnB;AACH,aAFD;AAGH;;;AAED,oBAAc;AAAA;;AACV,aAAKC,IAAL,GAAY,IAAIN,SAAJ,EAAZ;AACA,aAAKO,KAAL,GAAa,CAAb;AACA,aAAKC,MAAL,GAAc,CAAd;AACA,aAAKC,KAAL,GAAa,CAAb;AACA,aAAKC,MAAL,GAAc,CAAd;;AAEA,YAAIL,UAAUM,MAAd,EAAsB;AAClB,gBAAMC,WAAW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jB,EAAoB;AAChB,uBAAO,KAAKA,KAAL,GAAa,KAAKD,MAAlB,GAA2B,KAAKD,KAAvC;AACH;AACD,gBAAI,KAAKC,MAAL,GAAc,CAAlB,EAAqB;AACjB,uBAAO,KAAKA,MAAL,GAAc,KAAKD,KAA1B;AACH;AACD,gBAAI,KAAKA,KAAL,GAAa,CAAjB,EAAoB;AAChB,uBAAO,KAAKA,KAAZ;AACH;AACD,mBAAO,CAAP;AACH;;;4BAEY;AACT,mBAAO,KAAKD,IAAL,CAAUY,MAAjB;AACH;;;;;;AAGLC,OAAOC,OAAP,GAAiBlB,IAAjB","file":"Dim4.js","sourcesContent":["'use strict';\nconst _ = require('lodash');\nconst fastcall = require('fastcall');\nconst ref = fastcall.ref;\nconst typedefs = require('./typedefs');\nconst DimTArray = typedefs.DimTArray;\nconst assert = require('assert');\n\nclass Dim4 {\n static define(af) {\n af.dim4 = function () {\n return new Dim4(...arguments);\n };\n }\n\n constructor() {\n this.data = new DimTArray();\n this.first = 0;\n this.second = 0;\n this.third = 0;\n this.fourth = 0;\n\n if (arguments.length) {\n const firstArg = arguments[0];\n\n if (_.isObject(firstArg) || _.isArray(firstArg)) {\n if (firstArg[0] >= 0) {\n this.first = firstArg[0];\n }\n if (firstArg[1] >= 0) {\n this.second = firstArg[1];\n }\n if (firstArg[2] >= 0) {\n this.third = firstArg[2];\n }\n if (firstArg[3] >= 0) {\n this.fourth = firstArg[3];\n }\n }\n else {\n if (arguments[0] >= 0) {\n this.first = arguments[0];\n }\n if (arguments[1] >= 0) {\n this.second = arguments[1];\n }\n if (arguments[2] >= 0) {\n this.third = arguments[2];\n }\n if (arguments[3] >= 0) {\n this.fourth = arguments[3];\n }\n }\n }\n }\n\n get first() {\n return this.data.get(0);\n }\n\n set first(value) {\n this.data.set(0, value);\n }\n\n get second() {\n return this.data.get(1);\n }\n\n set second(value) {\n this.data.set(1, value);\n }\n\n get third() {\n return this.data.get(2);\n }\n\n set third(value) {\n this.data.set(2, value);\n }\n\n get fourth() {\n return this.data.get(3);\n }\n\n set fourth(value) {\n this.data.set(3, value);\n }\n\n get [0]() {\n return this.first;\n }\n\n set [0](value) {\n this.first = value;\n }\n\n get [1]() {\n return this.second;\n }\n\n set [1](value) {\n this.second = value;\n }\n\n get [2]() {\n return this.third;\n }\n\n set [2](value) {\n this.third = value;\n }\n\n get [3]() {\n return this.fourth;\n }\n\n set [3](value) {\n this.fourth = value;\n }\n\n get ndims() {\n if (this.fourth > 1) {\n return 4;\n }\n if (this.third > 1) {\n return 3;\n }\n if (this.second > 1) {\n return 2;\n }\n if (this.first > 0) {\n return 1;\n }\n return 0;\n }\n\n get elements() {\n if (this.fourth > 0) {\n return this.fourth * this.third * this.second * this.first;\n }\n if (this.third > 0) {\n return this.third * this.second * this.first;\n }\n if (this.second > 0) {\n return this.second * this.first;\n }\n if (this.first > 0) {\n return this.first;\n }\n return 0;\n }\n\n get buffer() {\n return this.data.buffer;\n }\n}\n\nmodule.exports = Dim4;"]} \ No newline at end of file diff --git a/lib/es5/Idx.js b/lib/es5/Idx.js new file mode 100644 index 0000000..b46730c --- /dev/null +++ b/lib/es5/Idx.js @@ -0,0 +1,101 @@ +'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 _ = require('lodash'); +var fastcall = require('fastcall'); +var assert = require('assert'); +var Seq = require('./Seq'); +var Col = require('./Col'); +var Cols = require('./Cols'); +var Row = require('./Row'); +var Rows = require('./Rows'); +var helpers = require('./helpers'); + +var Idx = function () { + _createClass(Idx, null, [{ + key: 'define', + value: function define(af) { + af.idx = function () { + return new (Function.prototype.bind.apply(Idx, [null].concat([af], Array.prototype.slice.call(arguments))))(); + }; + } + }]); + + function Idx(af) { + _classCallCheck(this, Idx); + + this.indices = af._lib.arrays.IndexArray.type(4); + this.ndims = 0; + + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + this._parseIndexArgs(af, args); + } + + _createClass(Idx, [{ + key: '_parseIndexArgs', + value: function _parseIndexArgs(af, args) { + var lib = af._lib; + var i = 0; + for (; i < args.length; i++) { + var arg = args[i]; + if (arg instanceof Seq) { + this.indices.set(i, seqIndex(arg)); + } else if (arg === af.span) { + this.indices.set(i, seqIndex(new Seq(1, 1, 0))); + } else if (_.isNumber(arg)) { + this.indices.set(i, seqIndex(new Seq(arg))); + } else if (arg instanceof Row) { + this.indices.set(i++, seqIndex(new Seq(arg.index))); + this.indices.set(i, seqIndex(new Seq(1, 1, 0))); + } else if (arg instanceof Rows) { + this.indices.set(i++, seqIndex(new Seq(arg.firstIndex, arg.lastIndex))); + this.indices.set(i, seqIndex(new Seq(1, 1, 0))); + } else if (arg instanceof Col) { + this.indices.set(i++, seqIndex(new Seq(1, 1, 0))); + this.indices.set(i, seqIndex(new Seq(arg.index))); + } else if (arg instanceof Cols) { + this.indices.set(i++, seqIndex(new Seq(1, 1, 0))); + this.indices.set(i, seqIndex(new Seq(arg.firstIndex, arg.lastIndex))); + } else { + // AFArray + this.indices.set(i, lib.structs.IndexT.type({ + idx: { + arr: helpers.getHandle(arg) + }, + isSeq: false, + isBatch: af._batch + })); + } + } + + assert(i > 0 && i <= 4, 'Invalid index arguments.'); + this.ndims = i; + + function seqIndex(seq) { + return lib.structs.IndexT.type({ + idx: { + seq: seq.data + }, + isSeq: true, + isBatch: af._batch + }); + } + } + }, { + key: 'buffer', + get: function get() { + return this.indices.buffer; + } + }]); + + return Idx; +}(); + +module.exports = Idx; +//# sourceMappingURL=Idx.js.map \ No newline at end of file diff --git a/lib/es5/Idx.js.map b/lib/es5/Idx.js.map new file mode 100644 index 0000000..1fd9adc --- /dev/null +++ b/lib/es5/Idx.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/Idx.js"],"names":["_","require","fastcall","assert","Seq","Col","Cols","Row","Rows","helpers","Idx","af","idx","arguments","indices","_lib","arrays","IndexArray","type","ndims","args","_parseIndexArgs","lib","i","length","arg","set","seqIndex","span","isNumber","index","firstIndex","lastIndex","structs","IndexT","arr","getHandle","isSeq","isBatch","_batch","seq","data","buffer","module","exports"],"mappings":"AAAA;;;;;;AACA,IAAMA,IAAIC,QAAQ,QAAR,CAAV;AACA,IAAMC,WAAWD,QAAQ,UAAR,CAAjB;AACA,IAAME,SAASF,QAAQ,QAAR,CAAf;AACA,IAAMG,MAAMH,QAAQ,OAAR,CAAZ;AACA,IAAMI,MAAMJ,QAAQ,OAAR,CAAZ;AACA,IAAMK,OAAOL,QAAQ,QAAR,CAAb;AACA,IAAMM,MAAMN,QAAQ,OAAR,CAAZ;AACA,IAAMO,OAAOP,QAAQ,QAAR,CAAb;AACA,IAAMQ,UAAUR,QAAQ,WAAR,CAAhB;;IAEMS,G;;;+BACYC,E,EAAI;AACdA,eAAGC,GAAH,GAAS,YAAY;AACjB,0DAAWF,GAAX,iBAAeC,EAAf,8BAAsBE,SAAtB;AACH,aAFD;AAGH;;;AAED,iBAAYF,EAAZ,EAAyB;AAAA;;AACrB,aAAKG,OAAL,GAAeH,GAAGI,IAAH,CAAQC,MAAR,CAAeC,UAAf,CAA0BC,IAA1B,CAA+B,CAA/B,CAAf;AACA,aAAKC,KAAL,GAAa,CAAb;;AAFqB,0CAANC,IAAM;AAANA,gBAAM;AAAA;;AAGrB,aAAKC,eAAL,CAAqBV,EAArB,EAAyBS,IAAzB;AACH;;;;wCAMeT,E,EAAIS,I,EAAM;AACtB,gBAAME,MAAMX,GAAGI,IAAf;AACA,gBAAIQ,IAAI,CAAR;AACA,mBAAOA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;;;AA2DLC,OAAOC,OAAP,GAAiBlC,GAAjB","file":"Idx.js","sourcesContent":["'use strict';\nconst _ = require('lodash');\nconst fastcall = require('fastcall');\nconst assert = require('assert');\nconst Seq = require('./Seq');\nconst Col = require('./Col');\nconst Cols = require('./Cols');\nconst Row = require('./Row');\nconst Rows = require('./Rows');\nconst helpers = require('./helpers');\n\nclass Idx {\n static define(af) {\n af.idx = function () {\n return new Idx(af, ...arguments);\n };\n }\n\n constructor(af, ...args) {\n this.indices = af._lib.arrays.IndexArray.type(4);\n this.ndims = 0;\n this._parseIndexArgs(af, args);\n }\n\n get buffer() {\n return this.indices.buffer;\n }\n\n _parseIndexArgs(af, args) {\n const lib = af._lib;\n let i = 0;\n for (; i < args.length; i++) {\n const arg = args[i];\n if (arg instanceof Seq) {\n this.indices.set(i, seqIndex(arg));\n }\n else if (arg === af.span) {\n this.indices.set(i, seqIndex(new Seq(1, 1, 0)));\n }\n else if (_.isNumber(arg)) {\n this.indices.set(i, seqIndex(new Seq(arg)));\n }\n else if (arg instanceof Row) {\n this.indices.set(i++, seqIndex(new Seq(arg.index)));\n this.indices.set(i, seqIndex(new Seq(1, 1, 0)));\n }\n else if (arg instanceof Rows) {\n this.indices.set(i++, seqIndex(new Seq(arg.firstIndex, arg.lastIndex)));\n this.indices.set(i, seqIndex(new Seq(1, 1, 0)));\n }\n else if (arg instanceof Col) {\n this.indices.set(i++, seqIndex(new Seq(1, 1, 0)));\n this.indices.set(i, seqIndex(new Seq(arg.index)));\n }\n else if (arg instanceof Cols) {\n this.indices.set(i++, seqIndex(new Seq(1, 1, 0)));\n this.indices.set(i, seqIndex(new Seq(arg.firstIndex, arg.lastIndex)));\n }\n else {\n // AFArray\n this.indices.set(i, lib.structs.IndexT.type({\n idx: {\n arr: helpers.getHandle(arg)\n },\n isSeq: false,\n isBatch: af._batch\n }));\n }\n }\n\n assert(i > 0 && i <= 4, 'Invalid index arguments.');\n this.ndims = i;\n\n function seqIndex(seq) {\n return lib.structs.IndexT.type({\n idx: {\n seq: seq.data\n },\n isSeq: true,\n isBatch: af._batch\n });\n }\n }\n}\n\nmodule.exports = Idx;"]} \ No newline at end of file diff --git a/lib/es5/Row.js b/lib/es5/Row.js new file mode 100644 index 0000000..a4cfbd6 --- /dev/null +++ b/lib/es5/Row.js @@ -0,0 +1,27 @@ +'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 Row = function () { + _createClass(Row, null, [{ + key: 'define', + value: function define(af) { + af.row = function (index) { + return new Row(index); + }; + } + }]); + + function Row(index) { + _classCallCheck(this, Row); + + this.index = index; + } + + return Row; +}(); + +module.exports = Row; +//# sourceMappingURL=Row.js.map \ No newline at end of file diff --git a/lib/es5/Row.js.map b/lib/es5/Row.js.map new file mode 100644 index 0000000..042dbf2 --- /dev/null +++ b/lib/es5/Row.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/Row.js"],"names":["Row","af","row","index","module","exports"],"mappings":"AAAA;;;;;;IAEMA,G;;;+BACYC,E,EAAI;AACdA,eAAGC,GAAH,GAAS,UAAUC,KAAV,EAAiB;AACtB,uBAAO,IAAIH,GAAJ,CAAQG,KAAR,CAAP;AACH,aAFD;AAGH;;;AAED,iBAAYA,KAAZ,EAAmB;AAAA;;AACf,aAAKA,KAAL,GAAaA,KAAb;AACH;;;;;AAGLC,OAAOC,OAAP,GAAiBL,GAAjB","file":"Row.js","sourcesContent":["'use strict';\n\nclass Row {\n static define(af) {\n af.row = function (index) {\n return new Row(index);\n };\n }\n\n constructor(index) {\n this.index = index;\n }\n}\n\nmodule.exports = Row;"]} \ No newline at end of file diff --git a/lib/es5/Rows.js b/lib/es5/Rows.js new file mode 100644 index 0000000..d7902d7 --- /dev/null +++ b/lib/es5/Rows.js @@ -0,0 +1,28 @@ +'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 Rows = function () { + _createClass(Rows, null, [{ + key: 'define', + value: function define(af) { + af.rows = function (firstIndex, lastIndex) { + return new Rows(firstIndex, lastIndex); + }; + } + }]); + + function Rows(firstIndex, lastIndex) { + _classCallCheck(this, Rows); + + this.firstIndex = firstIndex; + this.lastIndex = lastIndex; + } + + return Rows; +}(); + +module.exports = Rows; +//# sourceMappingURL=Rows.js.map \ No newline at end of file diff --git a/lib/es5/Rows.js.map b/lib/es5/Rows.js.map new file mode 100644 index 0000000..3126a9e --- /dev/null +++ b/lib/es5/Rows.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/Rows.js"],"names":["Rows","af","rows","firstIndex","lastIndex","module","exports"],"mappings":"AAAA;;;;;;IAEMA,I;;;+BACYC,E,EAAI;AACdA,eAAGC,IAAH,GAAU,UAAUC,UAAV,EAAsBC,SAAtB,EAAiC;AACvC,uBAAO,IAAIJ,IAAJ,CAASG,UAAT,EAAqBC,SAArB,CAAP;AACH,aAFD;AAGH;;;AAED,kBAAYD,UAAZ,EAAwBC,SAAxB,EAAmC;AAAA;;AAC/B,aAAKD,UAAL,GAAkBA,UAAlB;AACA,aAAKC,SAAL,GAAiBA,SAAjB;AACH;;;;;AAGLC,OAAOC,OAAP,GAAiBN,IAAjB","file":"Rows.js","sourcesContent":["'use strict';\n\nclass Rows {\n static define(af) {\n af.rows = function (firstIndex, lastIndex) {\n return new Rows(firstIndex, lastIndex);\n };\n }\n\n constructor(firstIndex, lastIndex) {\n this.firstIndex = firstIndex;\n this.lastIndex = lastIndex;\n }\n}\n\nmodule.exports = Rows;"]} \ No newline at end of file diff --git a/lib/es5/Seq.js b/lib/es5/Seq.js new file mode 100644 index 0000000..221f437 --- /dev/null +++ b/lib/es5/Seq.js @@ -0,0 +1,76 @@ +'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 typedefs = require('./typedefs'); +var SeqT = typedefs.SeqT; + +var Seq = function () { + _createClass(Seq, null, [{ + key: 'define', + value: function define(af) { + af.seq = function () { + return new (Function.prototype.bind.apply(Seq, [null].concat(Array.prototype.slice.call(arguments))))(); + }; + } + }]); + + function Seq(v1, v2, v3) { + _classCallCheck(this, Seq); + + if (v3 === undefined) { + if (v2 === undefined) { + this.data = new SeqT({ + begin: v1, + end: v1, + step: 1 + }); + } else { + this.data = new SeqT({ + begin: v1, + end: v2, + step: 1 + }); + } + } else { + this.data = new SeqT({ + begin: v1, + end: v2, + step: v3 + }); + } + } + + _createClass(Seq, [{ + key: 'begin', + get: function get() { + return this.data.begin; + }, + set: function set(value) { + this.data.begin = value; + } + }, { + key: 'end', + get: function get() { + return this.data.end; + }, + set: function set(value) { + this.data.end = value; + } + }, { + key: 'step', + get: function get() { + return this.data.step; + }, + set: function set(value) { + this.data.step = value; + } + }]); + + return Seq; +}(); + +module.exports = Seq; +//# sourceMappingURL=Seq.js.map \ No newline at end of file diff --git a/lib/es5/Seq.js.map b/lib/es5/Seq.js.map new file mode 100644 index 0000000..0874d07 --- /dev/null +++ b/lib/es5/Seq.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/Seq.js"],"names":["typedefs","require","SeqT","Seq","af","seq","arguments","v1","v2","v3","undefined","data","begin","end","step","value","module","exports"],"mappings":"AAAA;;;;;;AACA,IAAMA,WAAWC,QAAQ,YAAR,CAAjB;AACA,IAAMC,OAAOF,SAASE,IAAtB;;IAEMC,G;;;+BACYC,E,EAAI;AACdA,eAAGC,GAAH,GAAS,YAAY;AACjB,0DAAWF,GAAX,2CAAkBG,SAAlB;AACH,aAFD;AAGH;;;AAED,iBAAYC,EAAZ,EAAgBC,EAAhB,EAAoBC,EAApB,EAAwB;AAAA;;AACpB,YAAIA,OAAOC,SAAX,EAAsB;AAClB,gBAAIF,OAAOE,SAAX,EAAsB;AAClB,qBAAKC,IAAL,GAAY,IAAIT,IAAJ,CAAS;AACjBU,2BAAOL,EADU;AAEjBM,yBAAKN,EAFY;AAGjBO,0BAAM;AAHW,iBAAT,CAAZ;AAKH,aAND,MAOK;AACD,qBAAKH,IAAL,GAAY,IAAIT,IAAJ,CAAS;AACjBU,2BAAOL,EADU;AAEjBM,yBAAKL,EAFY;AAGjBM,0BAAM;AAHW,iBAAT,CAAZ;AAKH;AACJ,SAfD,MAgBK;AACD,iBAAKH,IAAL,GAAY,IAAIT,IAAJ,CAAS;AACjBU,uBAAOL,EADU;AAEjBM,qBAAKL,EAFY;AAGjBM,sBAAML;AAHW,aAAT,CAAZ;AAKH;AACJ;;;;4BAEW;AACR,mBAAO,KAAKE,IAAL,CAAUC,KAAjB;AACH,S;0BAESG,K,EAAO;AACb,iBAAKJ,IAAL,CAAUC,KAAV,GAAkBG,KAAlB;AACH;;;4BAES;AACN,mBAAO,KAAKJ,IAAL,CAAUE,GAAjB;AACH,S;0BAEOE,K,EAAO;AACX,iBAAKJ,IAAL,CAAUE,GAAV,GAAgBE,KAAhB;AACH;;;4BAEU;AACP,mBAAO,KAAKJ,IAAL,CAAUG,IAAjB;AACH,S;0BAEQC,K,EAAO;AACZ,iBAAKJ,IAAL,CAAUG,IAAV,GAAiBC,KAAjB;AACH;;;;;;AAGLC,OAAOC,OAAP,GAAiBd,GAAjB","file":"Seq.js","sourcesContent":["'use strict';\nconst typedefs = require('./typedefs');\nconst SeqT = typedefs.SeqT;\n\nclass Seq {\n static define(af) {\n af.seq = function () {\n return new Seq(...arguments);\n };\n }\n\n constructor(v1, v2, v3) {\n if (v3 === undefined) {\n if (v2 === undefined) {\n this.data = new SeqT({\n begin: v1,\n end: v1,\n step: 1\n });\n }\n else {\n this.data = new SeqT({\n begin: v1,\n end: v2,\n step: 1\n });\n }\n }\n else {\n this.data = new SeqT({\n begin: v1,\n end: v2,\n step: v3\n });\n }\n }\n\n get begin() {\n return this.data.begin;\n }\n\n set begin(value) {\n this.data.begin = value;\n }\n\n get end() {\n return this.data.end;\n }\n\n set end(value) {\n this.data.end = value;\n }\n\n get step() {\n return this.data.step;\n }\n\n set step(value) {\n this.data.step = value;\n }\n}\n\nmodule.exports = Seq;"]} \ No newline at end of file diff --git a/lib/es5/arrayIndexing.js b/lib/es5/arrayIndexing.js new file mode 100644 index 0000000..3e6c1d3 --- /dev/null +++ b/lib/es5/arrayIndexing.js @@ -0,0 +1,118 @@ +'use strict'; + +var fastcall = require('fastcall'); +var ref = fastcall.ref; +var typedefs = require('./typedefs'); +var handleType = typedefs.handleType; +var helpers = require('./helpers'); +var Promise = require('bluebird'); +var async = Promise.coroutine; +var Seq = require('./Seq'); +var assert = require('assert'); +var Idx = require('./Idx'); +var _ = require('lodash'); + +module.exports = function (af, AFArray) { + var lib = af._lib; + var intf = lib.interface; + + var callAssign = null; + + // .get + + lib.declare('int af_index_gen(void** out, void* in, longlong ndims, IndexT* indices)'); + + af.index = af._makeFunction(function () { + this.out = ref.alloc(handleType); + }, function (array, idx) { + idx = asIdx(idx); + return intf.af_index_gen(this.out, helpers.getHandle(array), idx.ndims, idx.buffer); + }, function () { + return this.out.deref(); + }); + + // .set + + lib.declare('int af_assign_gen(void** out, void* lhs, longlong ndims, IndexT* indices, void* rhs)'); + + af.assign = af._makeFunction(function () { + this.out = ref.alloc(handleType); + }, function (array, idx, value) { + idx = asIdx(idx); + assert(value !== undefined, 'Argument "value" expected.'); + return callAssign(this.out, helpers.getHandle(array), idx, value); + }, function () { + return this.out.deref(); + }); + + function asIdx(idx) { + if (idx instanceof Idx) { + return idx; + } + return af.idx(idx); + } + + if (af.options.async) { + callAssign = function callAssign(out, arrayHandle, idx, value) { + return af.scope.async(regeneratorRuntime.mark(function _callee() { + var rhs; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + rhs = void 0; + + if (!_.isNumber(value)) { + _context.next = 15; + break; + } + + _context.t0 = af; + _context.t1 = value; + _context.next = 6; + return af.getDims(arrayHandle); + + case 6: + _context.t2 = _context.sent; + _context.next = 9; + return af.getType(arrayHandle); + + case 9: + _context.t3 = _context.sent; + _context.next = 12; + return _context.t0.constant.call(_context.t0, _context.t1, _context.t2, _context.t3); + + case 12: + rhs = _context.sent.handle; + _context.next = 16; + break; + + case 15: + rhs = helpers.getHandle(value); + + case 16: + return _context.abrupt('return', intf.af_assign_gen(out, arrayHandle, idx.ndims, idx.buffer, rhs)); + + case 17: + case 'end': + return _context.stop(); + } + } + }, _callee, this); + })); + }; + } else { + callAssign = function callAssign(out, arrayHandle, idx, value) { + return af.scope(function () { + var rhs = void 0; + if (_.isNumber(value)) { + rhs = af.constant(value, af.getDims(arrayHandle), af.getType(arrayHandle)).handle; + } else { + rhs = helpers.getHandle(value); + } + return intf.af_assign_gen(out, arrayHandle, idx.ndims, idx.buffer, rhs); + }); + }; + } +}; +//# sourceMappingURL=arrayIndexing.js.map \ No newline at end of file diff --git a/lib/es5/arrayIndexing.js.map b/lib/es5/arrayIndexing.js.map new file mode 100644 index 0000000..078b83d --- /dev/null +++ b/lib/es5/arrayIndexing.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/arrayIndexing.js"],"names":["fastcall","require","ref","typedefs","handleType","helpers","Promise","async","coroutine","Seq","assert","Idx","_","module","exports","af","AFArray","lib","_lib","intf","interface","callAssign","declare","index","_makeFunction","out","alloc","array","idx","asIdx","af_index_gen","getHandle","ndims","buffer","deref","assign","value","undefined","options","arrayHandle","scope","rhs","isNumber","getDims","getType","constant","handle","af_assign_gen"],"mappings":"AAAA;;AACA,IAAMA,WAAWC,QAAQ,UAAR,CAAjB;AACA,IAAMC,MAAMF,SAASE,GAArB;AACA,IAAMC,WAAWF,QAAQ,YAAR,CAAjB;AACA,IAAMG,aAAaD,SAASC,UAA5B;AACA,IAAMC,UAAUJ,QAAQ,WAAR,CAAhB;AACA,IAAMK,UAAUL,QAAQ,UAAR,CAAhB;AACA,IAAMM,QAAQD,QAAQE,SAAtB;AACA,IAAMC,MAAMR,QAAQ,OAAR,CAAZ;AACA,IAAMS,SAAST,QAAQ,QAAR,CAAf;AACA,IAAMU,MAAMV,QAAQ,OAAR,CAAZ;AACA,IAAMW,IAAIX,QAAQ,QAAR,CAAV;;AAEAY,OAAOC,OAAP,GAAiB,UAAUC,EAAV,EAAcC,OAAd,EAAuB;AACpC,QAAMC,MAAMF,GAAGG,IAAf;AACA,QAAMC,OAAOF,IAAIG,SAAjB;;AAEA,QAAIC,aAAa,IAAjB;;AAEA;;AAEAJ,QAAIK,OAAJ,CAAY,yEAAZ;;AAEAP,OAAGQ,KAAH,GAAWR,GAAGS,aAAH,CACP,YAAY;AACR,aAAKC,GAAL,GAAWvB,IAAIwB,KAAJ,CAAUtB,UAAV,CAAX;AACH,KAHM,EAIP,UAAUuB,KAAV,EAAiBC,GAAjB,EAAsB;AAClBA,cAAMC,MAAMD,GAAN,CAAN;AACA,eAAOT,KAAKW,YAAL,CAA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OAAH,CAAWJ,WAAX,CAHxB;;AAAA;AAAA;AAAA;AAAA,uCAGuDxB,GAAG6B,OAAH,CAAWL,WAAX,CAHvD;;AAAA;AAAA;AAAA;AAAA,mDAGEM,QAHF;;AAAA;AAGdJ,mCAHc,iBAGiFK,MAHjF;AAAA;AAAA;;AAAA;AAMdL,sCAAMpC,QAAQ0B,SAAR,CAAkBK,KAAlB,CAAN;;AANc;AAAA,iEAQXjB,KAAK4B,aAAL,CAAmBtB,GAAnB,EAAwBc,WAAxB,EAAqCX,IAAII,KAAzC,EAAgDJ,IAAIK,MAApD,EAA4DQ,GAA5D,CARW;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAf,EAAP;AAUH,SAXD;AAYH,KAbD,MAcK;AACDpB,qBAAa,oBAAUI,GAAV,EAAec,WAAf,EAA4BX,GAA5B,EAAiCQ,KAAjC,EAAwC;AACjD,mBAAOrB,GAAGyB,KAAH,CAAS,YAAM;AAClB,oBAAIC,YAAJ;AACA,oBAAI7B,EAAE8B,QAAF,CAAWN,KAAX,CAAJ,EAAuB;AACnBK,0BAAM1B,GAAG8B,QAAH,CAAYT,KAAZ,EAAmBrB,GAAG4B,OAAH,CAAWJ,WAAX,CAAnB,EAA4CxB,GAAG6B,OAAH,CAAWL,WAAX,CAA5C,EAAqEO,MAA3E;AACH,iBAFD,MAGK;AACDL,0BAAMpC,QAAQ0B,SAAR,CAAkBK,KAAlB,CAAN;AACH;AACD,uBAAOjB,KAAK4B,aAAL,CAAmBtB,GAAnB,EAAwBc,WAAxB,EAAqCX,IAAII,KAAzC,EAAgDJ,IAAIK,MAApD,EAA4DQ,GAA5D,CAAP;AACH,aATM,CAAP;AAUH,SAXD;AAYH;AACJ,CA1ED","file":"arrayIndexing.js","sourcesContent":["'use strict';\nconst fastcall = require('fastcall');\nconst ref = fastcall.ref;\nconst typedefs = require('./typedefs');\nconst handleType = typedefs.handleType;\nconst helpers = require('./helpers');\nconst Promise = require('bluebird');\nconst async = Promise.coroutine;\nconst Seq = require('./Seq');\nconst assert = require('assert');\nconst Idx = require('./Idx');\nconst _ = require('lodash');\n\nmodule.exports = function (af, AFArray) {\n const lib = af._lib;\n const intf = lib.interface;\n\n let callAssign = null;\n\n // .get\n\n lib.declare('int af_index_gen(void** out, void* in, longlong ndims, IndexT* indices)');\n\n af.index = af._makeFunction(\n function () {\n this.out = ref.alloc(handleType);\n },\n function (array, idx) {\n idx = asIdx(idx);\n return intf.af_index_gen(this.out, helpers.getHandle(array), idx.ndims, idx.buffer);\n },\n function () {\n return this.out.deref();\n });\n\n // .set\n\n lib.declare('int af_assign_gen(void** out, void* lhs, longlong ndims, IndexT* indices, void* rhs)');\n\n af.assign = af._makeFunction(\n function () {\n this.out = ref.alloc(handleType);\n },\n function (array, idx, value) {\n idx = asIdx(idx);\n assert(value !== undefined, 'Argument \"value\" expected.');\n return callAssign(this.out, helpers.getHandle(array), idx, value);\n },\n function () {\n return this.out.deref();\n });\n\n function asIdx(idx) {\n if (idx instanceof Idx) {\n return idx;\n }\n return af.idx(idx);\n }\n\n if (af.options.async) {\n callAssign = function (out, arrayHandle, idx, value) {\n return af.scope.async(function* () {\n let rhs;\n if (_.isNumber(value)) {\n rhs = (yield af.constant(value, yield af.getDims(arrayHandle), yield af.getType(arrayHandle))).handle;\n }\n else {\n rhs = helpers.getHandle(value);\n }\n return intf.af_assign_gen(out, arrayHandle, idx.ndims, idx.buffer, rhs);\n });\n };\n }\n else {\n callAssign = function (out, arrayHandle, idx, value) {\n return af.scope(() => {\n let rhs;\n if (_.isNumber(value)) {\n rhs = af.constant(value, af.getDims(arrayHandle), af.getType(arrayHandle)).handle;\n }\n else {\n rhs = helpers.getHandle(value);\n }\n return intf.af_assign_gen(out, arrayHandle, idx.ndims, idx.buffer, rhs);\n });\n };\n }\n};"]} \ 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/create.js b/lib/es5/create.js new file mode 100644 index 0000000..2715749 --- /dev/null +++ b/lib/es5/create.js @@ -0,0 +1,29 @@ +'use strict'; + +var _ = require('lodash'); +var fastcall = require('fastcall'); +var ref = fastcall.ref; +var Dim4 = require('./Dim4'); +var assert = require('assert'); +var typedefs = require('./typedefs'); + +module.exports = function (af) { + var lib = af._lib; + var intf = lib.interface; + + // constant + + lib.declare('int af_constant(void** outArr, double value, uint ndims, longlong* dims, int type)'); + + af.constant = af._makeFunction(function () { + this.res = ref.alloc(typedefs.handleType); + }, function (value, dims) { + var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; + + assert(dims instanceof Dim4, 'Argument "dims" is not a Dim4 instance.'); + return intf.af_constant(this.res, value, dims.ndims, dims.buffer, type); + }, function () { + return af.array(ref.deref(this.res)); + }); +}; +//# sourceMappingURL=create.js.map \ No newline at end of file diff --git a/lib/es5/create.js.map b/lib/es5/create.js.map new file mode 100644 index 0000000..9edf19b --- /dev/null +++ b/lib/es5/create.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/create.js"],"names":["_","require","fastcall","ref","Dim4","assert","typedefs","module","exports","af","lib","_lib","intf","interface","declare","constant","_makeFunction","res","alloc","handleType","value","dims","type","af_constant","ndims","buffer","array","deref"],"mappings":"AAAA;;AACA,IAAMA,IAAIC,QAAQ,QAAR,CAAV;AACA,IAAMC,WAAWD,QAAQ,UAAR,CAAjB;AACA,IAAME,MAAMD,SAASC,GAArB;AACA,IAAMC,OAAOH,QAAQ,QAAR,CAAb;AACA,IAAMI,SAASJ,QAAQ,QAAR,CAAf;AACA,IAAMK,WAAWL,QAAQ,YAAR,CAAjB;;AAEAM,OAAOC,OAAP,GAAiB,UAAUC,EAAV,EAAc;AAC3B,QAAMC,MAAMD,GAAGE,IAAf;AACA,QAAMC,OAAOF,IAAIG,SAAjB;;AAEA;;AAEAH,QAAII,OAAJ,CAAY,oFAAZ;;AAEAL,OAAGM,QAAH,GAAcN,GAAGO,aAAH,CACV,YAAY;AACR,aAAKC,GAAL,GAAWd,IAAIe,KAAJ,CAAUZ,SAASa,UAAnB,CAAX;AACH,KAHS,EAIV,UAAUC,KAAV,EAAiBC,IAAjB,EAAiC;AAAA,YAAVC,IAAU,uEAAH,CAAG;;AAC7BjB,eAAOgB,gBAAgBjB,IAAvB,EAA6B,yCAA7B;AACA,eAAOQ,KAAKW,WAAL,CAAiB,KAAKN,GAAtB,EAA2BG,KAA3B,EAAkCC,KAAKG,KAAvC,EAA8CH,KAAKI,MAAnD,EAA2DH,IAA3D,CAAP;AACH,KAPS,EAQV,YAAY;AACR,eAAOb,GAAGiB,KAAH,CAASvB,IAAIwB,KAAJ,CAAU,KAAKV,GAAf,CAAT,CAAP;AACH,KAVS,CAAd;AAWH,CAnBD","file":"create.js","sourcesContent":["'use strict';\nconst _ = require('lodash');\nconst fastcall = require('fastcall');\nconst ref = fastcall.ref;\nconst Dim4 = require('./Dim4');\nconst assert = require('assert');\nconst typedefs = require('./typedefs');\n\nmodule.exports = function (af) {\n const lib = af._lib;\n const intf = lib.interface;\n\n // constant\n\n lib.declare('int af_constant(void** outArr, double value, uint ndims, longlong* dims, int type)');\n\n af.constant = af._makeFunction(\n function () {\n this.res = ref.alloc(typedefs.handleType);\n },\n function (value, dims, type = 0) {\n assert(dims instanceof Dim4, 'Argument \"dims\" is not a Dim4 instance.');\n return intf.af_constant(this.res, value, dims.ndims, dims.buffer, type);\n },\n function () {\n return af.array(ref.deref(this.res));\n });\n};"]} \ No newline at end of file diff --git a/lib/es5/device.js b/lib/es5/device.js new file mode 100644 index 0000000..3c35d3a --- /dev/null +++ b/lib/es5/device.js @@ -0,0 +1,115 @@ +'use strict'; + +var fastcall = require('fastcall'); +var ref = fastcall.ref; + +module.exports = function (af) { + var lib = af._lib; + var intf = lib.interface; + + // deviceInfo + + lib.declare('int af_device_info(CString name, CString platform, CString toolkit, CString compute)'); + + af.deviceInfo = af._makeFunction(function () { + this.name = new Buffer(512); + this.platform = new Buffer(512); + this.toolkit = new Buffer(512); + this.compute = new Buffer(512); + }, function (name, platform, toolkit, compute) { + this.outName = name; + this.outPlatform = platform; + this.outToolkit = toolkit; + this.outCompute = compute; + + this.name.fill(0); + this.platform.fill(0); + this.toolkit.fill(0); + this.compute.fill(0); + + return intf.af_device_info(this.name, this.platform, this.toolkit, this.compute); + }, function () { + this.outName && (this.outName.value = ref.readCString(this.name)); + this.outPlatform && (this.outPlatform.value = ref.readCString(this.platform)); + this.outToolkit && (this.outToolkit.value = ref.readCString(this.toolkit)); + this.outCompute && (this.outCompute.value = ref.readCString(this.compute)); + }); + + // infoString + + if (lib.isSymbolExists('af_info_string')) { + lib.declare('int af_info_string(char** result, bool verbose)'); + + af.infoString = af._makeFunction(function () { + this.infoPtr = ref.alloc('char*'); + }, function () { + var verbose = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + + return intf.af_info_string(this.infoPtr); + }, function () { + return ref.readCString(this.infoPtr.deref()); + }); + } else { + af.infoString = af._makeFunction(function () { + this.outName = { value: null }; + this.outPlatform = { value: null }; + this.outToolkit = { value: null }; + this.outCompute = { value: null }; + }, function () { + return af.deviceInfo(this.outName, this.outPlatform, this.outToolkit, this.outCompute); + }, function () { + return 'name: ' + this.outName.value + ', \' +\n \'platform: ' + this.outPlatform.value + ', \' +\n \'toolkit: ' + this.outToolkit.value + ', \' + \n \'compute: ' + this.outCompute.value; + }); + } + + // getDeviceCount + + lib.declare('int af_get_device_count(int* id)'); + + af.getDeviceCount = af._makeFunction(function () { + this.res = ref.alloc(ref.types.int); + }, function () { + return intf.af_get_device_count(this.res); + }, function () { + return this.res.deref(); + }); + + // setDevice + + lib.declare('int af_set_device(int id)'); + + af.setDevice = af._makeFunction(function (id) { + return intf.af_set_device(id); + }); + + // getDevice + + lib.declare('int af_get_device(int* id)'); + + af.getDevice = af._makeFunction(function () { + this.res = ref.alloc(ref.types.int); + }, function () { + return intf.af_get_device(this.res); + }, function () { + return this.res.deref(); + }); + + // setSeed + + lib.declare('int af_set_seed(uint64 seed)'); + + af.setSeed = af._makeFunction(function (seed) { + return intf.af_set_seed(seed); + }); + + // sync + + lib.declare('int af_sync(int deviceId)'); + + af.sync = af._makeFunction(function () { + var deviceId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1; + + return intf.af_sync(deviceId); + }); +}; +//# sourceMappingURL=device.js.map \ No newline at end of file diff --git a/lib/es5/device.js.map b/lib/es5/device.js.map new file mode 100644 index 0000000..684ce72 --- /dev/null +++ b/lib/es5/device.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/device.js"],"names":["fastcall","require","ref","module","exports","af","lib","_lib","intf","interface","declare","deviceInfo","_makeFunction","name","Buffer","platform","toolkit","compute","outName","outPlatform","outToolkit","outCompute","fill","af_device_info","value","readCString","isSymbolExists","infoString","infoPtr","alloc","verbose","af_info_string","deref","getDeviceCount","res","types","int","af_get_device_count","setDevice","id","af_set_device","getDevice","af_get_device","setSeed","seed","af_set_seed","sync","deviceId","af_sync"],"mappings":"AAAA;;AACA,IAAMA,WAAWC,QAAQ,UAAR,CAAjB;AACA,IAAMC,MAAMF,SAASE,GAArB;;AAEAC,OAAOC,OAAP,GAAiB,UAAUC,EAAV,EAAc;AAC3B,QAAMC,MAAMD,GAAGE,IAAf;AACA,QAAMC,OAAOF,IAAIG,SAAjB;;AAEA;;AAEAH,QAAII,OAAJ,CAAY,sFAAZ;;AAEAL,OAAGM,UAAH,GAAgBN,GAAGO,aAAH,CACZ,YAAY;AACR,aAAKC,IAAL,GAAY,IAAIC,MAAJ,CAAW,GAAX,CAAZ;AACA,aAAKC,QAAL,GAAgB,IAAID,MAAJ,CAAW,GAAX,CAAhB;AACA,aAAKE,OAAL,GAAe,IAAIF,MAAJ,CAAW,GAAX,CAAf;AACA,aAAKG,OAAL,GAAe,IAAIH,MAAJ,CAAW,GAAX,CAAf;AACH,KANW,EAOZ,UAAUD,IAAV,EAAgBE,QAAhB,EAA0BC,OAA1B,EAAmCC,OAAnC,EAA4C;AACxC,aAAKC,OAAL,GAAeL,IAAf;AACA,aAAKM,WAAL,GAAmBJ,QAAnB;AACA,aAAKK,UAAL,GAAkBJ,OAAlB;AACA,aAAKK,UAAL,GAAkBJ,OAAlB;;AAEA,aAAKJ,IAAL,CAAUS,IAAV,CAAe,CAAf;AACA,aAAKP,QAAL,CAAcO,IAAd,CAAmB,CAAnB;AACA,aAAKN,OAAL,CAAaM,IAAb,CAAkB,CAAlB;AACA,aAAKL,OAAL,CAAaK,IAAb,CAAkB,CAAlB;;AAEA,eAAOd,KAAKe,cAAL,CAAoB,KAAKV,IAAzB,EAA+B,KAAKE,QAApC,EAA8C,KAAKC,OAAnD,EAA4D,KAAKC,OAAjE,CAAP;AACH,KAnBW,EAoBZ,YAAY;AACR,aAAKC,OAAL,KAAiB,KAAKA,OAAL,CAAaM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AAV,EAAgB;AACZ,eAAOpC,KAAKqC,WAAL,CAAiBD,IAAjB,CAAP;AACH,KAHQ,CAAb;;AAKA;;AAEAtC,QAAII,OAAJ,CAAY,2BAAZ;;AAEAL,OAAGyC,IAAH,GAAUzC,GAAGO,aAAH,CACN,YAAyB;AAAA,YAAfmC,QAAe,uEAAJ,CAAC,CAAG;;AACrB,eAAOvC,KAAKwC,OAAL,CAAaD,QAAb,CAAP;AACH,KAHK,CAAV;AAIH,CA/HD","file":"device.js","sourcesContent":["'use strict';\nconst fastcall = require('fastcall');\nconst ref = fastcall.ref;\n\nmodule.exports = function (af) {\n const lib = af._lib;\n const intf = lib.interface;\n\n // deviceInfo\n\n lib.declare('int af_device_info(CString name, CString platform, CString toolkit, CString compute)');\n\n af.deviceInfo = af._makeFunction(\n function () {\n this.name = new Buffer(512);\n this.platform = new Buffer(512);\n this.toolkit = new Buffer(512);\n this.compute = new Buffer(512);\n },\n function (name, platform, toolkit, compute) {\n this.outName = name;\n this.outPlatform = platform;\n this.outToolkit = toolkit;\n this.outCompute = compute;\n\n this.name.fill(0);\n this.platform.fill(0);\n this.toolkit.fill(0);\n this.compute.fill(0);\n\n return intf.af_device_info(this.name, this.platform, this.toolkit, this.compute);\n },\n function () {\n this.outName && (this.outName.value = ref.readCString(this.name));\n this.outPlatform && (this.outPlatform.value = ref.readCString(this.platform));\n this.outToolkit && (this.outToolkit.value = ref.readCString(this.toolkit));\n this.outCompute && (this.outCompute.value = ref.readCString(this.compute));\n });\n\n // infoString\n\n if (lib.isSymbolExists('af_info_string')) {\n lib.declare('int af_info_string(char** result, bool verbose)');\n\n af.infoString = af._makeFunction(\n function () {\n this.infoPtr = ref.alloc('char*');\n },\n function (verbose = false) {\n return intf.af_info_string(this.infoPtr);\n },\n function () {\n return ref.readCString(this.infoPtr.deref());\n }\n );\n }\n else {\n af.infoString = af._makeFunction(\n function () {\n this.outName = { value: null };\n this.outPlatform = { value: null };\n this.outToolkit = { value: null };\n this.outCompute = { value: null };\n },\n function () {\n return af.deviceInfo(this.outName, this.outPlatform, this.outToolkit, this.outCompute);\n },\n function () {\n return `name: ${ this.outName.value }, ' +\n 'platform: ${ this.outPlatform.value }, ' +\n 'toolkit: ${ this.outToolkit.value }, ' + \n 'compute: ${ this.outCompute.value }`;\n });\n }\n\n // getDeviceCount\n\n lib.declare('int af_get_device_count(int* id)');\n\n af.getDeviceCount = af._makeFunction(\n function () {\n this.res = ref.alloc(ref.types.int);\n },\n function () {\n return intf.af_get_device_count(this.res);\n },\n function () {\n return this.res.deref();\n });\n\n // setDevice\n\n lib.declare('int af_set_device(int id)');\n\n af.setDevice = af._makeFunction(\n function (id) {\n return intf.af_set_device(id);\n });\n\n // getDevice\n\n lib.declare('int af_get_device(int* id)');\n\n af.getDevice = af._makeFunction(\n function () {\n this.res = ref.alloc(ref.types.int);\n },\n function () {\n return intf.af_get_device(this.res);\n },\n function () {\n return this.res.deref();\n });\n\n // setSeed\n\n lib.declare('int af_set_seed(uint64 seed)');\n\n af.setSeed = af._makeFunction(\n function (seed) {\n return intf.af_set_seed(seed);\n });\n\n // sync\n\n lib.declare('int af_sync(int deviceId)');\n\n af.sync = af._makeFunction(\n function (deviceId = -1) {\n return intf.af_sync(deviceId);\n });\n}"]} \ 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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AAC,CAAA;KAAE,MAAM;AAAE,YAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAAE;AAC9E,QAAI,KAAK,YAAA,CAAC;AACV,SAAK,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;AACjC,YAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;AAC1B,kBAAM;SACT;KACJ;AACD,QAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;AACpC,QAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,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;;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Array {\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/enums.js b/lib/es5/enums.js new file mode 100644 index 0000000..bb8ea23 --- /dev/null +++ b/lib/es5/enums.js @@ -0,0 +1,47 @@ +'use strict'; + +exports.backend = { + // Default backend order: OpenCL -> CUDA -> CPU. + DEFAULT: 0, + // CPU a.k.a sequential algorithms. + CPU: 1, + // CUDA Compute Backend. + CUDA: 2, + // OpenCL Compute Backend. + OPENCL: 3 +}; + +exports.dtype = { + f32: 0, + // 32-bit floating point values + c32: 1, + // 32-bit complex floating point values + f64: 2, + // 64-bit complex floating point values + c64: 3, + // 64-bit complex floating point values + b8: 4, + // 8-bit boolean values + s32: 5, + // 32-bit signed integral values + u32: 6, + // 32-bit unsigned integral values + u8: 7, + // 8-bit unsigned integral values + s64: 8, + // 64-bit signed integral values + u64: 9, + // 64-bit unsigned integral values + s16: 10, + // 16-bit signed integral values + u16: 11 + // 16-bit unsigned integral values +}; + +exports.source = { + // Device pointer. + device: 0, + // Host pointer. + host: 1 +}; +//# sourceMappingURL=enums.js.map \ No newline at end of file diff --git a/lib/es5/enums.js.map b/lib/es5/enums.js.map new file mode 100644 index 0000000..a3009aa --- /dev/null +++ b/lib/es5/enums.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/enums.js"],"names":["exports","backend","DEFAULT","CPU","CUDA","OPENCL","dtype","f32","c32","f64","c64","b8","s32","u32","u8","s64","u64","s16","u16","source","device","host"],"mappings":"AAAA;;AAEAA,QAAQC,OAAR,GAAkB;AACd;AACAC,aAAS,CAFK;AAGd;AACAC,SAAK,CAJS;AAKd;AACAC,UAAM,CANQ;AAOd;AACAC,YAAQ;AARM,CAAlB;;AAWAL,QAAQM,KAAR,GAAgB;AACZC,SAAK,CADO;AAEZ;AACAC,SAAK,CAHO;AAIZ;AACAC,SAAK,CALO;AAMZ;AACAC,SAAK,CAPO;AAQZ;AACAC,QAAI,CATQ;AAUZ;AACAC,SAAK,CAXO;AAYZ;AACAC,SAAK,CAbO;AAcZ;AACAC,QAAI,CAfQ;AAgBZ;AACAC,SAAK,CAjBO;AAkBZ;AACAC,SAAK,CAnBO;AAoBZ;AACAC,SAAK,EArBO;AAsBZ;AACAC,SAAK;AACL;AAxBY,CAAhB;;AA2BAlB,QAAQmB,MAAR,GAAiB;AACb;AACAC,YAAQ,CAFK;AAGb;AACAC,UAAM;AAJO,CAAjB","file":"enums.js","sourcesContent":["'use strict';\n\nexports.backend = {\n // Default backend order: OpenCL -> CUDA -> CPU.\n DEFAULT: 0,\n // CPU a.k.a sequential algorithms.\n CPU: 1,\n // CUDA Compute Backend.\n CUDA: 2,\n // OpenCL Compute Backend.\n OPENCL: 3\n};\n\nexports.dtype = {\n f32: 0,\n // 32-bit floating point values\n c32: 1,\n // 32-bit complex floating point values\n f64: 2,\n // 64-bit complex floating point values\n c64: 3,\n // 64-bit complex floating point values\n b8: 4,\n // 8-bit boolean values\n s32: 5,\n // 32-bit signed integral values\n u32: 6,\n // 32-bit unsigned integral values\n u8: 7,\n // 8-bit unsigned integral values\n s64: 8,\n // 64-bit signed integral values\n u64: 9,\n // 64-bit unsigned integral values\n s16: 10,\n // 16-bit signed integral values\n u16: 11\n // 16-bit unsigned integral values\n};\n\nexports.source = {\n // Device pointer.\n device: 0,\n // Host pointer.\n host: 1\n};"]} \ No newline at end of file diff --git a/lib/es5/errors.js b/lib/es5/errors.js new file mode 100644 index 0000000..54d97e7 --- /dev/null +++ b/lib/es5/errors.js @@ -0,0 +1,36 @@ +'use strict'; + +var util = require('util'); +var assert = require('assert'); + +exports.AFError = AFError; +exports.AFChainedError = AFChainedError; +exports.verify = verify; + +function AFError(message, code) { + Error.captureStackTrace(this, this.constructor); + this.name = this.constructor.name; + this.message = (message || 'Unknown ArrayFire error.') + (' (code: ' + code + ')'); + if (code !== undefined) { + this.code = code; + } +} + +util.inherits(AFError, Error); + +function AFChainedError(errors) { + assert(errors.lenght); + + AFError.call(this, errors[0].message + ' (More errors captured, refer to "errors" property\'s value.)', errors[0].code); + this.errors = errors; + this.code = errors[0].code; +} + +util.inherits(AFChainedError, AFError); + +function verify(code) { + if (code > 0) { + throw new AFError("AFError", code); + } +} +//# sourceMappingURL=errors.js.map \ No newline at end of file diff --git a/lib/es5/errors.js.map b/lib/es5/errors.js.map new file mode 100644 index 0000000..b0e168f --- /dev/null +++ b/lib/es5/errors.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/errors.js"],"names":["util","require","assert","exports","AFError","AFChainedError","verify","message","code","Error","captureStackTrace","constructor","name","undefined","inherits","errors","lenght","call"],"mappings":"AAAA;;AACA,IAAMA,OAAOC,QAAQ,MAAR,CAAb;AACA,IAAMC,SAASD,QAAQ,QAAR,CAAf;;AAEAE,QAAQC,OAAR,GAAkBA,OAAlB;AACAD,QAAQE,cAAR,GAAyBA,cAAzB;AACAF,QAAQG,MAAR,GAAiBA,MAAjB;;AAEA,SAASF,OAAT,CAAiBG,OAAjB,EAA0BC,IAA1B,EAAgC;AAC5BC,UAAMC,iBAAN,CAAwB,IAAxB,EAA8B,KAAKC,WAAnC;AACA,SAAKC,IAAL,GAAY,KAAKD,WAAL,CAAiBC,IAA7B;AACA,SAAKL,OAAL,GAAe,CAACA,WAAW,0BAAZ,KAA2C,aAAaC,IAAb,GAAoB,GAA/D,CAAf;AACA,QAAIA,SAASK,SAAb,EAAwB;AACpB,aAAKL,IAAL,GAAYA,IAAZ;AACH;AACJ;;AAEDR,KAAKc,QAAL,CAAcV,OAAd,EAAuBK,KAAvB;;AAEA,SAASJ,cAAT,CAAwBU,MAAxB,EAAgC;AAC5Bb,WAAOa,OAAOC,MAAd;;AAEAZ,YAAQa,IAAR,CAAa,IAAb,EAAuBF,OAAO,CAAP,EAAUR,OAAjC,oEAAyGQ,OAAO,CAAP,EAAUP,IAAnH;AACA,SAAKO,MAAL,GAAcA,MAAd;AACA,SAAKP,IAAL,GAAYO,OAAO,CAAP,EAAUP,IAAtB;AACH;;AAEDR,KAAKc,QAAL,CAAcT,cAAd,EAA8BD,OAA9B;;AAEA,SAASE,MAAT,CAAgBE,IAAhB,EAAsB;AAClB,QAAIA,OAAO,CAAX,EAAc;AACV,cAAM,IAAIJ,OAAJ,CAAY,SAAZ,EAAuBI,IAAvB,CAAN;AACH;AACJ","file":"errors.js","sourcesContent":["'use strict';\nconst util = require('util');\nconst assert = require('assert');\n\nexports.AFError = AFError;\nexports.AFChainedError = AFChainedError;\nexports.verify = verify;\n\nfunction AFError(message, code) {\n Error.captureStackTrace(this, this.constructor);\n this.name = this.constructor.name;\n this.message = (message || 'Unknown ArrayFire error.') + (' (code: ' + code + ')');\n if (code !== undefined) {\n this.code = code;\n }\n}\n\nutil.inherits(AFError, Error);\n\nfunction AFChainedError(errors) {\n assert(errors.lenght);\n\n AFError.call(this, `${ errors[0].message } (More errors captured, refer to \"errors\" property's value.)`, errors[0].code);\n this.errors = errors;\n this.code = errors[0].code;\n}\n\nutil.inherits(AFChainedError, AFError);\n\nfunction verify(code) {\n if (code > 0) {\n throw new AFError(\"AFError\", code);\n }\n}"]} \ 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.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["ext.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY,CAAC;;AAEb,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAA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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/helpers.js b/lib/es5/helpers.js new file mode 100644 index 0000000..8a487b8 --- /dev/null +++ b/lib/es5/helpers.js @@ -0,0 +1,59 @@ +'use strict'; + +var Dim4 = require('./Dim4'); +var _ = require('lodash'); +var assert = require('assert'); +var fastcall = require('fastcall'); +var ArrayType = fastcall.ArrayType; +var FloatArray = new ArrayType('float'); +var semver = require('semver'); + +var helpers = exports; + +helpers.getHandle = function (array) { + if (array.handle) { + return array.handle; + } + return array; +}; + +helpers.toBuffer = function (obj) { + if (Buffer.isBuffer(obj)) { + return obj; + } + if (_.isArray(obj)) { + var arr = new FloatArray(obj.length); + for (var i = 0; i < obj.length; i++) { + arr.set(i, Number(obj[i])); + } + return arr.buffer; + } + if (_.isTypedArray(obj)) { + return _typedArrayToBuffer(obj); + } + throw new TypeError('Argument "obj" is not a Buffer.'); +}; + +helpers.typedArrayToBuffer = function (arr) { + assert(_.isTypedArray(arr), 'Argument "arr" is not a typed array.'); + + return _typedArrayToBuffer(arr); +}; + +function _typedArrayToBuffer(arr) { + if (arr.byteLength !== arr.buffer.byteLength) { + return helpers.arrayToBuffer(arr.buffer, arr.byteOffset, arr.byteLength); + } + return helpers.arrayToBuffer(arr.buffer); +} + +if (semver.gt(process.versions.node, '5.1.0')) { + helpers.arrayToBuffer = function (arr, byteOffset, length) { + return Buffer.from(arr, byteOffset, length); + }; +} else { + helpers.arrayToBuffer = function (arr, byteOffset, length) { + return new Buffer(arr, byteOffset, length); + }; +} +//# sourceMappingURL=helpers.js.map \ No newline at end of file diff --git a/lib/es5/helpers.js.map b/lib/es5/helpers.js.map new file mode 100644 index 0000000..ca066f5 --- /dev/null +++ b/lib/es5/helpers.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/helpers.js"],"names":["Dim4","require","_","assert","fastcall","ArrayType","FloatArray","semver","helpers","exports","getHandle","array","handle","toBuffer","obj","Buffer","isBuffer","isArray","arr","length","i","set","Number","buffer","isTypedArray","_typedArrayToBuffer","TypeError","typedArrayToBuffer","byteLength","arrayToBuffer","byteOffset","gt","process","versions","node","from"],"mappings":"AAAA;;AACA,IAAMA,OAAOC,QAAQ,QAAR,CAAb;AACA,IAAMC,IAAID,QAAQ,QAAR,CAAV;AACA,IAAME,SAASF,QAAQ,QAAR,CAAf;AACA,IAAMG,WAAWH,QAAQ,UAAR,CAAjB;AACA,IAAMI,YAAYD,SAASC,SAA3B;AACA,IAAMC,aAAa,IAAID,SAAJ,CAAc,OAAd,CAAnB;AACA,IAAME,SAASN,QAAQ,QAAR,CAAf;;AAEA,IAAMO,UAAUC,OAAhB;;AAEAD,QAAQE,SAAR,GAAoB,UAAUC,KAAV,EAAiB;AACjC,QAAIA,MAAMC,MAAV,EAAkB;AACd,eAAOD,MAAMC,MAAb;AACH;AACD,WAAOD,KAAP;AACH,CALD;;AAOAH,QAAQK,QAAR,GAAmB,UAAUC,GAAV,EAAe;AAC9B,QAAIC,OAAOC,QAAP,CAAgBF,GAAhB,CAAJ,EAA0B;AACtB,eAAOA,GAAP;AACH;AACD,QAAIZ,EAAEe,OAAF,CAAUH,GAAV,CAAJ,EAAoB;AAChB,YAAMI,MAAM,IAAIZ,UAAJ,CAAeQ,IAAIK,MAAnB,CAAZ;AACA,aAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAIN,IAAIK,MAAxB,EAAgCC,GAAhC,EAAqC;AACjCF,gBAAIG,GAAJ,CAAQD,CAAR,EAAWE,OAAOR,IAAIM,CAAJ,CAAP,CAAX;AACH;AACD,eAAOF,IAAIK,MAAX;AACH;AACD,QAAIrB,EAAEsB,YAAF,CAAeV,GAAf,CAAJ,EAAyB;AACrB,eAAOW,oBAAoBX,GAApB,CAAP;AACH;AACD,UAAM,IAAIY,SAAJ,CAAc,iCAAd,CAAN;AACH,CAfD;;AAiBAlB,QAAQmB,kBAAR,GAA6B,UAAUT,GAAV,EAAe;AACxCf,WAAOD,EAAEsB,YAAF,CAAeN,GAAf,CAAP,EAA4B,sCAA5B;;AAEA,WAAOO,oBAAoBP,GAApB,CAAP;AACH,CAJD;;AAMA,SAASO,mBAAT,CAA6BP,GAA7B,EAAkC;AAC9B,QAAIA,IAAIU,UAAJ,KAAmBV,IAAIK,MAAJ,CAAWK,UAAlC,EAA8C;AAC1C,eAAOpB,QAAQqB,aAAR,CAAsBX,IAAIK,MAA1B,EAAkCL,IAAIY,UAAtC,EAAkDZ,IAAIU,UAAtD,CAAP;AACH;AACD,WAAOpB,QAAQqB,aAAR,CAAsBX,IAAIK,MAA1B,CAAP;AACH;;AAED,IAAIhB,OAAOwB,EAAP,CAAUC,QAAQC,QAAR,CAAiBC,IAA3B,EAAiC,OAAjC,CAAJ,EAA+C;AAC3C1B,YAAQqB,aAAR,GAAwB,UAAUX,GAAV,EAAeY,UAAf,EAA2BX,MAA3B,EAAmC;AACvD,eAAOJ,OAAOoB,IAAP,CAAYjB,GAAZ,EAAiBY,UAAjB,EAA6BX,MAA7B,CAAP;AACH,KAFD;AAGH,CAJD,MAKK;AACDX,YAAQqB,aAAR,GAAwB,UAAUX,GAAV,EAAeY,UAAf,EAA2BX,MAA3B,EAAmC;AACvD,eAAO,IAAIJ,MAAJ,CAAWG,GAAX,EAAgBY,UAAhB,EAA4BX,MAA5B,CAAP;AACH,KAFD;AAGH","file":"helpers.js","sourcesContent":["'use strict';\nconst Dim4 = require('./Dim4');\nconst _ = require('lodash');\nconst assert = require('assert');\nconst fastcall = require('fastcall');\nconst ArrayType = fastcall.ArrayType;\nconst FloatArray = new ArrayType('float');\nconst semver = require('semver');\n\nconst helpers = exports;\n\nhelpers.getHandle = function (array) {\n if (array.handle) {\n return array.handle;\n }\n return array;\n};\n\nhelpers.toBuffer = function (obj) {\n if (Buffer.isBuffer(obj)) {\n return obj;\n }\n if (_.isArray(obj)) {\n const arr = new FloatArray(obj.length);\n for (let i = 0; i < obj.length; i++) {\n arr.set(i, Number(obj[i]));\n }\n return arr.buffer;\n }\n if (_.isTypedArray(obj)) {\n return _typedArrayToBuffer(obj);\n }\n throw new TypeError('Argument \"obj\" is not a Buffer.');\n};\n\nhelpers.typedArrayToBuffer = function (arr) {\n assert(_.isTypedArray(arr), 'Argument \"arr\" is not a typed array.');\n\n return _typedArrayToBuffer(arr);\n};\n\nfunction _typedArrayToBuffer(arr) {\n if (arr.byteLength !== arr.buffer.byteLength) {\n return helpers.arrayToBuffer(arr.buffer, arr.byteOffset, arr.byteLength);\n }\n return helpers.arrayToBuffer(arr.buffer);\n}\n\nif (semver.gt(process.versions.node, '5.1.0')) {\n helpers.arrayToBuffer = function (arr, byteOffset, length) {\n return Buffer.from(arr, byteOffset, length);\n };\n}\nelse {\n helpers.arrayToBuffer = function (arr, byteOffset, length) {\n return new Buffer(arr, byteOffset, length);\n };\n}"]} \ No newline at end of file diff --git a/lib/es5/index.js b/lib/es5/index.js index cb7989d..a0552d4 100644 --- a/lib/es5/index.js +++ b/lib/es5/index.js @@ -1,80 +1,4 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. +'use strict'; -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 +exports.ArrayFire = require('./ArrayFire'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib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YAAY,GAAG,EAAE,GAAG,qBAAqB,CAAC,CAAC;AAAA,SAClE;KACJ;AACD,QAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;AACpB,QAAI,CAAC,EAAE,CAAC,UAAU,EAAE;AAChB,WAAG,CAAC,EAAE,CAAC,CAAC;AACR,UAAE,CAAC,UAAU,GAAG,IAAI,CAAC;KACxB;AACD,WAAO,EAAE,CAAC;CACb,CAAC;;AAEF,KAAK,CAAC,kBAAkB,GAAG,YAAW;AAClC,QAAI,SAAS,GAAG,EAAE,CAAC;eACJ,CAAC,KAAK,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 +{"version":3,"sources":["../es6/index.js"],"names":["exports","ArrayFire","require"],"mappings":"AAAA;;AAEAA,QAAQC,SAAR,GAAoBC,QAAQ,aAAR,CAApB","file":"index.js","sourcesContent":["'use strict';\n\nexports.ArrayFire = require('./ArrayFire');"]} \ 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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIml0ZXJwVHlwZS5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUErQkE7QUFBQSxXQUFXLENBQUM7QUFFWixBQUFJLEVBQUEsQ0FBQSxVQUFTLEVBQUksQ0FBQSxNQUFLLFFBQVEsRUFBSTtBQUM5QixRQUFNLENBQUcsRUFBQTtBQUNULE9BQUssQ0FBRyxFQUFBO0FBQ1IsVUFBUSxDQUFJLEVBQUE7QUFDWixNQUFJLENBQUcsRUFBQTtBQUNQLGtCQUFnQixDQUFHLEVBQUE7QUFDbkIsaUJBQWUsQ0FBRyxFQUFBO0FBQ2xCLG1CQUFpQixDQUFJLEVBQUE7QUFDckIsZ0JBQWMsQ0FBRyxFQUFBO0FBQUEsQUFDckIsQ0FBQztBQUFBIiwiZmlsZSI6Iml0ZXJwVHlwZS5qcyIsInNvdXJjZVJvb3QiOiJsaWIvZXM2Iiwic291cmNlc0NvbnRlbnQiOlsiLypcbkNvcHlyaWdodCAoYykgMjAxNC0yMDE1LCBBcnJheUZpcmVcbkNvcHlyaWdodCAoYykgMjAxNSBHw6Fib3IgTWV6xZEgYWthIHVuYm9ybmNoaWtrZW4gKGdhYm9yLm1lem9Ab3V0bG9vay5jb20pXG5BbGwgcmlnaHRzIHJlc2VydmVkLlxuXG5SZWRpc3RyaWJ1dGlvbiBhbmQgdXNlIGluIHNvdXJjZSBhbmQgYmluYXJ5IGZvcm1zLCB3aXRoIG9yIHdpdGhvdXQgbW9kaWZpY2F0aW9uLFxuYXJlIHBlcm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wb2xhdGlvbixcbiAgICBBRl9JTlRFUlBfTkVBUkVTVDogMCwgIC8vLzwgTmVhcmVzdCBJbnRlcnBvbGF0aW9uXG4gICAgQUZfSU5URVJQX0xJTkVBUjogMSwgICAvLy88IExpbmVhciBJbnRlcnBvbGF0aW9uXG4gICAgQUZfSU5URVJQX0JJTElORUFSIDogMiwgLy8vPCBCaWxpbmVhciBJbnRlcnBvbGF0aW9uXG4gICAgQUZfSU5URVJQX0NVQklDOiAzICAgICAvLy88IEN1YmljIEludGVycG9sYXRpb25cbn07Il19 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,a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;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/null @@ -1 +0,0 @@ -{"version":3,"sources":["scope.js"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;;AAE1B,IAAI,WAAW,GAAG,EAAE,CAAC;;AAErB,SAAS,KAAK,CAAC,CAAC,EAAE;AACd,QAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;AACjB,aAAK,CAAC,KAAK,EAAE,CAAC;AACd,YAAI;AACA,mBAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;SAC/B,SACO;AACJ,iBAAK,CAAC,GAAG,EAAE,CAAC;SACf;KACJ;CACJ;;AAED,KAAK,CAAC,KAAK,GAAG,YAAW;AACrB,eAAW,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;AAC5B,WAAO,KAAK,CAAC;CAChB,CAAC;;AAEF,KAAK,CAAC,GAAG,GAAG,YAAW;AACnB,QAAI,WAAW,CAAC,MAAM,EAAE;AACpB,YAAI,GAAG,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,mBAAW,CAAC,MAAM,EAAE,CAAC;AACrB,YAAI,CAAC,GAAG,CAAC,CAAC;KACb;AACD,WAAO,KAAK,CAAC;CAChB,CAAC;;AAEF,KAAK,CAAC,QAAQ,GAAG,UAAS,KAAK,EAAE;AAC7B,QAAI,WAAW,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;AACrE,YAAI,GAAG,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,WAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KAClB;CACJ,CAAC;;AAEF,KAAK,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/es5/typedefs.js b/lib/es5/typedefs.js new file mode 100644 index 0000000..e6957b7 --- /dev/null +++ b/lib/es5/typedefs.js @@ -0,0 +1,26 @@ +'use strict'; + +var fastcall = require('fastcall'); +var ref = fastcall.ref; +var ArrayType = fastcall.ArrayType; +var StructType = fastcall.StructType; + +var typedefs = exports; + +typedefs.handleType = ref.refType('void'); +typedefs.outHandleType = ref.refType(typedefs.handleType); +typedefs.DimTArray = new ArrayType('longlong', 4); +typedefs.SeqT = new StructType({ + begin: 'double', + end: 'double', + step: 'double' +}); + +typedefs.define = function (af) { + var lib = af._lib; + + lib.struct({ SeqT: typedefs.SeqT }); + + lib.declare('void*[] PointerArray;' + 'union ArrayOrSeqT { void* arr; SeqT seq; };' + 'struct IndexT { ArrayOrSeqT idx; bool isSeq; bool isBatch; };' + 'IndexT[] IndexArray;'); +}; +//# sourceMappingURL=typedefs.js.map \ No newline at end of file diff --git a/lib/es5/typedefs.js.map b/lib/es5/typedefs.js.map new file mode 100644 index 0000000..3f5b53f --- /dev/null +++ b/lib/es5/typedefs.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/typedefs.js"],"names":["fastcall","require","ref","ArrayType","StructType","typedefs","exports","handleType","refType","outHandleType","DimTArray","SeqT","begin","end","step","define","af","lib","_lib","struct","declare"],"mappings":"AAAA;;AACA,IAAMA,WAAWC,QAAQ,UAAR,CAAjB;AACA,IAAMC,MAAMF,SAASE,GAArB;AACA,IAAMC,YAAYH,SAASG,SAA3B;AACA,IAAMC,aAAaJ,SAASI,UAA5B;;AAEA,IAAMC,WAAWC,OAAjB;;AAEAD,SAASE,UAAT,GAAsBL,IAAIM,OAAJ,CAAY,MAAZ,CAAtB;AACAH,SAASI,aAAT,GAAyBP,IAAIM,OAAJ,CAAYH,SAASE,UAArB,CAAzB;AACAF,SAASK,SAAT,GAAqB,IAAIP,SAAJ,CAAc,UAAd,EAA0B,CAA1B,CAArB;AACAE,SAASM,IAAT,GAAgB,IAAIP,UAAJ,CAAe;AAC3BQ,WAAO,QADoB;AAE3BC,SAAK,QAFsB;AAG3BC,UAAM;AAHqB,CAAf,CAAhB;;AAMAT,SAASU,MAAT,GAAkB,UAAUC,EAAV,EAAc;AAC5B,QAAMC,MAAMD,GAAGE,IAAf;;AAEAD,QAAIE,MAAJ,CAAW,EAAER,MAAMN,SAASM,IAAjB,EAAX;;AAEAM,QAAIG,OAAJ,CACI,0BACA,6CADA,GAEA,+DAFA,GAGA,sBAJJ;AAKH,CAVD","file":"typedefs.js","sourcesContent":["'use strict';\nconst fastcall = require('fastcall');\nconst ref = fastcall.ref;\nconst ArrayType = fastcall.ArrayType;\nconst StructType = fastcall.StructType;\n\nconst typedefs = exports;\n\ntypedefs.handleType = ref.refType('void');\ntypedefs.outHandleType = ref.refType(typedefs.handleType);\ntypedefs.DimTArray = new ArrayType('longlong', 4);\ntypedefs.SeqT = new StructType({\n begin: 'double',\n end: 'double',\n step: 'double'\n});\n\ntypedefs.define = function (af) {\n const lib = af._lib;\n\n lib.struct({ SeqT: typedefs.SeqT });\n\n lib.declare(\n 'void*[] PointerArray;' +\n 'union ArrayOrSeqT { void* arr; SeqT seq; };' +\n 'struct IndexT { ArrayOrSeqT idx; bool isSeq; bool isBatch; };' +\n 'IndexT[] IndexArray;');\n};"]} \ No newline at end of file diff --git a/lib/es5/unified.js b/lib/es5/unified.js new file mode 100644 index 0000000..d031335 --- /dev/null +++ b/lib/es5/unified.js @@ -0,0 +1,56 @@ +'use strict'; + +var fastcall = require('fastcall'); +var ref = fastcall.ref; + +module.exports = function (af) { + var lib = af._lib; + var intf = lib.interface; + + // getActiveBackend + + lib.declare('int af_get_active_backend(int* backend)'); + + af.getActiveBackend = af._makeFunction(function () { + this.res = ref.alloc(ref.types.int); + }, function () { + return intf.af_get_active_backend(this.res); + }, function () { + return this.res.deref(); + }); + + // getAvailableBackends + + lib.declare('int af_get_available_backends(int* backend)'); + + af.getAvailableBackends = af._makeFunction(function () { + this.res = ref.alloc(ref.types.int); + }, function () { + return intf.af_get_available_backends(this.res); + }, function () { + return this.res.deref(); + }); + + // getBackendCount + + lib.declare('int af_get_backend_count(uint* backend)'); + + af.getBackendCount = af._makeFunction(function () { + this.res = ref.alloc(ref.types.uint); + }, function () { + return intf.af_get_backend_count(this.res); + }, function () { + return this.res.deref(); + }); + + // setBackend + + lib.declare('int af_set_backend(int deviceId)'); + + af.setBackend = af._makeFunction(function (id) { + return intf.af_set_backend(id); + }); + + // TODO: getBackendId, getDeviceId for array +}; +//# sourceMappingURL=unified.js.map \ No newline at end of file diff --git a/lib/es5/unified.js.map b/lib/es5/unified.js.map new file mode 100644 index 0000000..6163b89 --- /dev/null +++ b/lib/es5/unified.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/unified.js"],"names":["fastcall","require","ref","module","exports","af","lib","_lib","intf","interface","declare","getActiveBackend","_makeFunction","res","alloc","types","int","af_get_active_backend","deref","getAvailableBackends","af_get_available_backends","getBackendCount","uint","af_get_backend_count","setBackend","id","af_set_backend"],"mappings":"AAAA;;AACA,IAAMA,WAAWC,QAAQ,UAAR,CAAjB;AACA,IAAMC,MAAMF,SAASE,GAArB;;AAEAC,OAAOC,OAAP,GAAiB,UAAUC,EAAV,EAAc;AAC3B,QAAMC,MAAMD,GAAGE,IAAf;AACA,QAAMC,OAAOF,IAAIG,SAAjB;;AAEA;;AAEAH,QAAII,OAAJ,CAAY,yCAAZ;;AAEAL,OAAGM,gBAAH,GAAsBN,GAAGO,aAAH,CAClB,YAAY;AACR,aAAKC,GAAL,GAAWX,IAAIY,KAAJ,CAAUZ,IAAIa,KAAJ,CAAUC,GAApB,CAAX;AACH,KAHiB,EAIlB,YAAY;AACR,eAAOR,KAAKS,qBAAL,CAA2B,KAAKJ,GAAhC,CAAP;AACH,KANiB,EAOlB,YAAY;AACR,eAAO,KAAKA,GAAL,CAASK,KAAT,EAAP;AACH,KATiB,CAAtB;;AAWA;;AAEAZ,QAAII,OAAJ,CAAY,6CAAZ;;AAEAL,OAAGc,oBAAH,GAA0Bd,GAAGO,aAAH,CACtB,YAAY;AACR,aAAKC,GAAL,GAAWX,IAAIY,KAAJ,CAAUZ,IAAIa,KAAJ,CAAUC,GAApB,CAAX;AACH,KAHqB,EAItB,YAAY;AACR,eAAOR,KAAKY,yBAAL,CAA+B,KAAKP,GAApC,CAAP;AACH,KANqB,EAOtB,YAAY;AACR,eAAO,KAAKA,GAAL,CAASK,KAAT,EAAP;AACH,KATqB,CAA1B;;AAWA;;AAEAZ,QAAII,OAAJ,CAAY,yCAAZ;;AAEAL,OAAGgB,eAAH,GAAqBhB,GAAGO,aAAH,CACjB,YAAY;AACR,aAAKC,GAAL,GAAWX,IAAIY,KAAJ,CAAUZ,IAAIa,KAAJ,CAAUO,IAApB,CAAX;AACH,KAHgB,EAIjB,YAAY;AACR,eAAOd,KAAKe,oBAAL,CAA0B,KAAKV,GAA/B,CAAP;AACH,KANgB,EAOjB,YAAY;AACR,eAAO,KAAKA,GAAL,CAASK,KAAT,EAAP;AACH,KATgB,CAArB;;AAWA;;AAEAZ,QAAII,OAAJ,CAAY,kCAAZ;;AAEAL,OAAGmB,UAAH,GAAgBnB,GAAGO,aAAH,CACZ,UAAUa,EAAV,EAAc;AACV,eAAOjB,KAAKkB,cAAL,CAAoBD,EAApB,CAAP;AACH,KAHW,CAAhB;;AAKA;AACH,CA3DD","file":"unified.js","sourcesContent":["'use strict';\nconst fastcall = require('fastcall');\nconst ref = fastcall.ref;\n\nmodule.exports = function (af) {\n const lib = af._lib;\n const intf = lib.interface;\n\n // getActiveBackend\n\n lib.declare('int af_get_active_backend(int* backend)');\n\n af.getActiveBackend = af._makeFunction(\n function () {\n this.res = ref.alloc(ref.types.int);\n },\n function () {\n return intf.af_get_active_backend(this.res);\n },\n function () {\n return this.res.deref();\n });\n\n // getAvailableBackends\n\n lib.declare('int af_get_available_backends(int* backend)');\n\n af.getAvailableBackends = af._makeFunction(\n function () {\n this.res = ref.alloc(ref.types.int);\n },\n function () {\n return intf.af_get_available_backends(this.res);\n },\n function () {\n return this.res.deref();\n });\n\n // getBackendCount\n\n lib.declare('int af_get_backend_count(uint* backend)');\n\n af.getBackendCount = af._makeFunction(\n function () {\n this.res = ref.alloc(ref.types.uint);\n },\n function () {\n return intf.af_get_backend_count(this.res);\n },\n function () {\n return this.res.deref();\n });\n\n // setBackend\n\n lib.declare('int af_set_backend(int deviceId)');\n\n af.setBackend = af._makeFunction(\n function (id) {\n return intf.af_set_backend(id);\n });\n\n // TODO: getBackendId, getDeviceId for array\n};"]} \ No newline at end of file diff --git a/lib/es6/AFArray.js b/lib/es6/AFArray.js new file mode 100644 index 0000000..855c49a --- /dev/null +++ b/lib/es6/AFArray.js @@ -0,0 +1,567 @@ +'use strict'; +const fastcall = require('fastcall'); +const ref = fastcall.ref; +const errors = require('./errors'); +const assert = require('assert'); +const Disposable = fastcall.Disposable; +const typedefs = require('./typedefs'); +const DimTArray = typedefs.DimTArray; +const Dim4 = require('./Dim4'); +const longlong = ref.types.longlong; +const Promise = require('bluebird'); +const async = Promise.coroutine; +const ArrayType = fastcall.ArrayType; +const arrayIndexing = require('./arrayIndexing'); +const _ = require('lodash'); +const helpers = require('./helpers'); + +class AFArray extends Disposable { + static define(af) { + const lib = af._lib; + const intf = lib.interface; + + // retainArray + + lib.declare('int af_retain_array(void** outArr, void* arr)'); + + af.retainArray = af._makeFunction( + function () { + this.res = ref.alloc(typedefs.handleType); + }, + function (array) { + return intf.af_retain_array(this.res, helpers.getHandle(array)); + }, + function () { + return ref.deref(this.res); + }); + + // releaseArray + + lib.declare('int af_release_array(void* arr)'); + + af.releaseArray = af._makeFunction( + function (array) { + return intf.af_release_array(helpers.getHandle(array)); + }); + + // createHandle + + lib.declare('int af_create_handle(void** outArr, uint ndims, longlong* dims, int type)'); + + af.createHandle = af._makeFunction( + function () { + this.res = ref.alloc(typedefs.handleType); + }, + function (dims = null, type = 0) { + let len = dims ? dims.ndims : 0; + return intf.af_create_handle(this.res, len, dims.buffer, type); + }, + function () { + return ref.deref(this.res); + }); + + // createArray + + lib.declare('int af_create_array(void** outArr, void* data, uint ndims, longlong* dims, int type)'); + + af.createArray = af._makeFunction( + function () { + this.res = ref.alloc(typedefs.handleType); + }, + function (data, dims, type = af.dtype.f32) { + let len = dims ? dims.ndims : 0; + try { + return intf.af_create_array(this.res, helpers.toBuffer(data), len, dims.buffer, type); + } + catch (err) { + if (err instanceof TypeError) { + throw new TypeError('Argument "data" is not a Buffer.'); + } + throw err; + } + }, + function () { + return ref.deref(this.res); + }); + + // deviceArray + + lib.declare('int af_device_array(void** outArr, void* data, uint ndims, longlong* dims, int type)'); + + af.deviceArray = af._makeFunction( + function () { + this.res = ref.alloc(typedefs.handleType); + }, + function (data, dims, type = 0) { + let len = dims ? dims.ndims : 0; + assert(Buffer.isBuffer(data), 'Argument "data" is not a Buffer.'); + return intf.af_device_array(this.res, data, len, dims.buffer, type); + }, + function () { + return ref.deref(this.res); + }); + + // ctors + + af.array = af._makeFunction( + function () { + const argsLen = arguments.length; + + // array() + if (argsLen === 0) { + return intf.createHandle(); + } + + const firstArg = arguments[0]; + + if (Buffer.isBuffer(firstArg)) { + // array(handle) + return firstArg; + } + + if (_.isArray(firstArg)) { + return af.createArray(firstArg, af.dim4(firstArg.length)); + } + + if (_.isTypedArray(firstArg)) { + return af.createArray(firstArg, af.dim4(firstArg.length), af.getDTypeOfTypedArray(firstArg)); + } + + if (firstArg instanceof AFArray) { + if (argsLen === 1) { + // array(otherArray) + return af.retainArray(firstArg); + } + else { + // array(otherArray, dims...) + const secondArg = arguments[1]; + assert(secondArg instanceof Dim4, 'Second argument is not a dimension.'); + return af.moddims(firstArg, arguments[1]); + } + } + + const dims = af.dim4(firstArg); + + assert(dims.ndims > 0, 'First argument is not a dimension.'); + + if (argsLen === 1) { + // array(dims..., f32) + return af.createHandle(dims, af.dtype.f32); + } + + let secondArg = arguments[1]; + let thirdArg = argsLen >= 3 ? arguments[2] : null; + + if (Buffer.isBuffer(secondArg)) { + let type = af.dtype.f32; + let source = af.source.host; + let index = 2; + if (index < argsLen) { + type = arguments[index]; + index++; + if (index < argsLen) { + source = arguments[index]; + } + } + // array(dims..., ptr, [type[, source]]) + if (source === af.source.host) { + return af.createArray(secondArg, dims, type); + } + return af.deviceArray(secondArg, dims, type); + } + + if (_.isArray(secondArg)) { + if (_.isNumber(thirdArg)) { + return af.createArray(makeBufferFromJSArray(secondArg, thirdArg), dims, thirdArg); + } + return af.createArray(secondArg, dims); + } + + if (_.isTypedArray(secondArg)) { + if (_.isNumber(thirdArg)) { + return af.createArray(makeBufferFromJSArray(secondArg, thirdArg), dims, thirdArg); + } + return af.createArray(secondArg, dims, af.getDTypeOfTypedArray(secondArg)); + } + + function makeBufferFromJSArray(jsArray, dtype) { + const len = jsArray.length; + const type = af.dtypeToRefType(dtype); + const buff = new Buffer(len * type.size); + for (let i = 0; i < len; i++) { + type.set(buff, i * type.size, jsArray[i]); + } + return buff; + } + + // array(dims...[, type]) + assert(secondArg >= 0 && secondArg <= af.dtype.u16, 'Second argument is not a dtype.'); + return af.createHandle(dims, secondArg); + }, + function (handle) { + return new AFArray(af, handle); + }); + + // getDims + + lib.declare('int af_get_dims(longlong* dim0, longlong* dim1, longlong* dim2, longlong* dim3, void* arr)'); + + af.getDims = af._makeFunction( + function () { + this.dims = null; + this.n = -1; + }, + function (array, n = -1) { + this.dims = new Dim4(); + this.n = n; + const buff = this.dims.buffer; + const dim0 = buff.slice(0); + const dim1 = buff.slice(longlong.size); + const dim2 = buff.slice(longlong.size * 2); + const dim3 = buff.slice(longlong.size * 3); + return intf.af_get_dims(dim0, dim1, dim2, dim3, helpers.getHandle(array)); + }, + function () { + const n = this.n; + if (n >= 0 && n < 4) { + return this.dims[n]; + } + return this.dims; + }); + + // getDataPtr + + lib.declare('int af_get_data_ptr(void* ptr, void* arr)'); + + af.getDataPtr = af._makeFunction( + function (array, ptr) { + return intf.af_get_data_ptr(ptr, helpers.getHandle(array)); + }); + + // getType + + lib.declare('int af_get_type(uint* outType, void* arr)'); + + af.getType = af._makeFunction( + function () { + this.outType = ref.alloc(ref.types.uint); + }, + function (array) { + return intf.af_get_type(this.outType, helpers.getHandle(array)); + }, + function () { + return this.outType.deref(); + }); + + af.getRefType = af._makeFunction( + { + verify: false, + call(array) { + return af.getType(array); + }, + done(type) { + return af.dtypeToRefType(type); + } + }); + + // getNumdims + + lib.declare('int af_get_numdims(uint* outNum, void* arr)'); + + af.getNumdims = af._makeFunction( + function () { + this.outNum = ref.alloc(ref.types.uint); + }, + function (array) { + return intf.af_get_numdims(this.outNum, helpers.getHandle(array)); + }, + function () { + return this.outNum.deref(); + }); + + // getElements + + lib.declare('int af_get_elements(longlong* outElems, void* arr)'); + + af.getElements = af._makeFunction( + function () { + this.outElems = ref.alloc(ref.types.longlong); + }, + function (array) { + return intf.af_get_elements(this.outElems, helpers.getHandle(array)); + }, + function () { + return this.outElems.deref(); + }); + + // isEmpty + + lib.declare('int af_is_empty(bool* outEmpty, void* arr)'); + + af.isEmpty = af._makeFunction( + function () { + this.outEmpty = ref.alloc(ref.types.bool); + }, + function (array) { + return intf.af_is_empty(this.outEmpty, helpers.getHandle(array)); + }, + function () { + return this.outEmpty.deref(); + }); + + // eval + + let hasMultiEval = false; + let multiEvalEmu = null; + lib.declare('int af_eval(void* arr)'); + if (lib.isSymbolExists('af_eval_multiple')) { + lib.declare('int af_eval_multiple(int num, PointerArray arrays)'); + hasMultiEval = true; + } + else { + multiEvalEmu = async(function* (arrays, len) { + for (let i = 0; i < len; i++) { + const res = yield intf.af_eval(helpers.getHandle(arr[i])); + if (res > 0) { + return res; + } + } + return 0; + }); + } + + af.eval = af._makeFunction( + function () { + this.pointers = new lib.arrays.PointerArray(10); + }, + function (arr) { + if (_.isArray(arr)) { + len = Math.min(10, arr.length); + if (!len) { + return 0; + } + if (hasMultiEval) { + for (let i = 0; i < len; i++) { + this.pointers.set(i, helpers.getHandle(arr[i])); + } + return intf.af_eval_multiple(len, this.pointers); + } + else if (af.options.async) { + return multiEvalEmu(arr, len); + } + else { + for (let i = 0; i < len; i++) { + const res = intf.af_eval(helpers.getHandle(arr[i])); + if (res > 0) { + return res; + } + } + return 0; + } + } + else { + return intf.af_eval(helpers.getHandle(arr)); + } + }); + + // index + assign + + arrayIndexing(af, AFArray); + } + + constructor(af, handle) { + super(() => af.releaseArray(handle)); + + this.af = af; + this.handle = handle; + this._host = this._makeHost(); + this._toArray = this._makeToArray(); + this._toRefArray = this._makeToRefArray(); + this._index = this._makeIndex(); + this._assign = this._makeAssign(); + } + + type() { + return this.af.getType(this); + } + + refType() { + return this.af.getRefType(this); + } + + dims(n) { + return this.af.getDims(this, n); + } + + host(ptr) { + return this._host(ptr); + } + + toRefArray() { + return this._toRefArray(); + } + + toArray() { + return this._toArray(); + } + + numdims() { + return this.af.getNumdims(this); + } + + elements() { + return this.af.getElements(this); + } + + isempty() { + return this.af.isEmpty(this); + } + + eval() { + return this.af.eval(this); + } + + index(idx) { + return this._index(idx); + } + + assign(idx, value) { + return this._assign(idx, value); + } + + _makeToArray() { + const self = this; + const af = this.af; + if (af.options.async) { + return async(function* (ptr) { + return refArrayToArray(yield self.toRefArray()); + }); + } + return function () { + return refArrayToArray(self.toRefArray()); + }; + + function refArrayToArray(refArr) { + const arr = new Array(refArr.length); + for (let i = 0; i < refArr.length; i++) { + arr[i] = refArr.get(i); + } + return arr; + } + } + + _makeToRefArray() { + const self = this; + const af = this.af; + if (af.options.async) { + return async(function* (ptr) { + const HostArray = new ArrayType(yield self.refType()); + const arr = new HostArray(yield self.elements()); + yield af.getDataPtr(self, arr.buffer); + return arr; + }); + } + return function () { + const HostArray = new ArrayType(self.refType()); + const arr = new HostArray(self.elements()); + af.getDataPtr(self, arr.buffer); + return arr; + }; + } + + _makeHost() { + const self = this; + const af = this.af; + if (af.options.async) { + return async(function* (ptr) { + if (!ptr) { + const HostArray = new ArrayType(yield self.refType()); + const elems = yield self.elements(); + ptr = new HostArray(elems).buffer; + } + assert(Buffer.isBuffer(ptr), 'Argument "ptr" is not a Buffer.'); + yield af.getDataPtr(self, ptr); + return ptr; + }); + } + return function (ptr) { + if (!ptr) { + const HostArray = new ArrayType(self.refType()); + ptr = new HostArray(self.elements()).buffer; + } + assert(Buffer.isBuffer(ptr), 'Argument "ptr" is not a Buffer.'); + af.getDataPtr(self, ptr); + return ptr; + }; + } + + _makeIndex() { + const self = this; + const af = this.af; + if (af.options.async) { + return async(function* (idx) { + const newHandle = yield af.index(self, idx); + return new AFArray(af, newHandle); + }); + } + return function (idx) { + const newHandle = af.index(self, idx); + return new AFArray(af, newHandle); + }; + } + + _makeAssign() { + const self = this; + const af = this.af; + if (af.options.async) { + return async(function* (idx, value) { + let newHandle; + if (value === undefined) { + const otherHandle = helpers.getHandle(idx); + newHandle = yield af.retainArray(otherHandle); + } + else { + try { + newHandle = yield af.assign(self, idx, value); + } + catch (err) { + self.resetDisposable(() => {}); + yield self.dispose(); + self.handle = null; + throw err; + } + } + if (newHandle.address() !== self.handle.address()) { + yield self.dispose(); + self.resetDisposable(() => af.releaseArray(newHandle)); + self.handle = newHandle; + } + }); + } + return function (idx, value) { + let newHandle; + if (value === undefined) { + const otherHandle = helpers.getHandle(idx); + newHandle = af.retainArray(otherHandle); + } + else { + try { + newHandle = af.assign(self, idx, value); + } + catch (err) { + self.resetDisposable(() => {}); + self.dispose(); + self.handle = null; + throw err; + } + } + if (newHandle.address() !== self.handle.address()) { + self.dispose(); + self.resetDisposable(() => af.releaseArray(newHandle)); + self.handle = newHandle; + } + }; + } +} + +module.exports = AFArray; \ No newline at end of file diff --git a/lib/es6/ArrayFire.js b/lib/es6/ArrayFire.js new file mode 100644 index 0000000..74a32d5 --- /dev/null +++ b/lib/es6/ArrayFire.js @@ -0,0 +1,265 @@ +'use strict'; +const os = require('os'); +const _ = require('lodash'); +const fastcall = require('fastcall'); +const Promise = require('bluebird'); +const Library = fastcall.Library; +const device = require('./device'); +const errors = require('./errors'); +const enums = require('./enums'); +const unified = require('./unified'); +const AFArray = require('./AFArray'); +const create = require('./create'); +const assert = require('assert'); +const typedefs = require('./typedefs'); +const Dim4 = require('./Dim4'); +const Idx = require('./Idx'); +const Seq = require('./Seq'); +const Col = require('./Col'); +const Cols = require('./Cols'); +const Row = require('./Row'); +const Rows = require('./Rows'); +const ref = fastcall.ref; + +const defOptions = { + async: false, + chainable: true +}; + +const span = Symbol('span'); + +let created = false; + +let dtypeMap = null; + +class ArrayFire { + constructor(options) { + if (created) { + throw new Error('Only one instance of ArrayFire class allowed.'); + } + + this.options = Object.freeze(_.defaults(options, defOptions)); + this._lib = new Library(getLibName(), this._makeLibOptions()); + this._batch = false; + + typedefs.define(this); + Dim4.define(this); + Idx.define(this); + Seq.define(this); + Col.define(this); + Cols.define(this); + Row.define(this); + Rows.define(this); + device(this); + unified(this); + AFArray.define(this); + create(this); + + created = true; + } + + release() { + this._lib.release(); + created = false; + } + + get scope() { + return fastcall.scope; + } + + get span() { + return span; + } + + get end() { + return -1; + } + + get backend() { + return enums.backend; + } + + get dtype() { + return enums.dtype; + } + + get source() { + return enums.source; + } + + enumToString(values, value) { + assert(_.isObject(values), 'Argument "values" is not an object.'); + + for (const key of _.keys(values)) { + const curr = values[key]; + if (curr === value) { + return key; + } + } + + throw new TypeError(`Value "${ value }" not fuond on enum values.`); + } + + getDTypeOfTypedArray(array) { + if (array instanceof Int8Array) { + return enums.dtype.u8; + } + if (array instanceof Uint8Array) { + return enums.dtype.u8; + } + if (array instanceof Uint8ClampedArray) { + return enums.dtype.u8; + } + if (array instanceof Int16Array) { + return enums.dtype.s16; + } + if (array instanceof Uint16Array) { + return enums.dtype.u16; + } + if (array instanceof Int32Array) { + return enums.dtype.s32; + } + if (array instanceof Uint32Array) { + return enums.dtype.u32; + } + if (array instanceof Float32Array) { + return enums.dtype.f32; + } + if (array instanceof Float64Array) { + return enums.dtype.f64; + } + throw new TypeError('Argument "array" is not a typed array.'); + } + + dtypeToRefType(type) { + switch (type) { + case enums.dtype.f32: + return ref.types.float; + case enums.dtype.c32: + throw new Error('Complext types are not supported yet.'); + case enums.dtype.f64: + return ref.types.double; + case enums.dtype.c64: + throw new Error('Complext types are not supported yet.'); + case enums.dtype.b8: + return ref.types.bool; + case enums.dtype.s32: + return ref.types.uint32; + case enums.dtype.u32: + return ref.types.uint32; + case enums.dtype.u8: + return ref.types.uint8; + case enums.dtype.s64: + return ref.types.int64; + case enums.dtype.u64: + return ref.types.uint64; + case enums.dtype.s16: + return ref.types.int16; + case enums.dtype.u16: + return ref.types.uint16; + default: + throw new TypeError(`Argument value "${ type }" is not a valid dtype.`); + } + } + + _makeFunction(init, call, done, verify = true) { + if (_.isPlainObject(init)) { + const args = init; + init = args.init || _.noop; + call = args.call; + done = args.done; + verify = args.verify === undefined ? true : args.verify; + } + else if (done === undefined) { + done = call; + call = init; + init = _.noop; + } + + const Caller = function () { + init.call(this); + }; + + Caller.prototype.call = call; + + Caller.prototype.done = done || _.noop; + + if (this.options.async) { + if (this.options.chainable) { + Caller.prototype.call = ArrayFire._asChainable(call); + } + Caller.prototype.process = function () { + return this.call.apply(this, arguments) + .then(result => { + if (verify) { + errors.verify(result); + } + return this.done(result); + }); + }; + return function () { + const caller = new Caller(); + return caller.process.apply(caller, arguments); + }; + } + else { + Caller.prototype.process = function () { + const result = this.call.apply(this, arguments); + if (verify) { + errors.verify(result); + } + return this.done(result); + }; + const caller = new Caller(); + return function () { + return caller.process.apply(caller, arguments); + }; + } + } + + static _asChainable(func) { + return function () { + const errs = []; + return Promise.map(arguments, (arg, idx) => { + return Promise.resolve(arg) + .catch(err => { + errs.push(err); + return null; + }); + }) + .then(args => { + if (errs.length) { + throw new errors.ArrayFireChainedError(errs); + } + return func.apply(this, args); + }); + }; + } + + _makeLibOptions() { + return { + callMode: this.options.async ? Library.callMode.async : Library.callMode.sync, + syncMode: Library.syncMode.lock // TODO: benchmark for this + }; + } +} + +module.exports = ArrayFire; + +function getLibName() { + const plat = os.platform(); + const isWin = plat === 'win32'; + const isOSX = plat === 'darwin'; + let postfix = ''; + let prefix = ''; + if (isOSX) { + postfix = '.dynlib'; + } + else if (!isWin) { + postfix = '.so'; + } + if (!isWin) { + prefix = 'lib'; + } + return prefix + 'af' + postfix; +} \ No newline at end of file diff --git a/lib/es6/Col.js b/lib/es6/Col.js new file mode 100644 index 0000000..6eef4f2 --- /dev/null +++ b/lib/es6/Col.js @@ -0,0 +1,15 @@ +'use strict'; + +class Col { + static define(af) { + af.col = function (index) { + return new Col(index); + }; + } + + constructor(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 new file mode 100644 index 0000000..0ea1f45 --- /dev/null +++ b/lib/es6/Cols.js @@ -0,0 +1,16 @@ +'use strict'; + +class Cols { + static define(af) { + af.cols = function (firstIndex, lastIndex) { + return new Cols(firstIndex, lastIndex); + }; + } + + constructor(firstIndex, lastIndex) { + this.firstIndex = firstIndex; + this.lastIndex = lastIndex; + } +} + +module.exports = Cols; \ No newline at end of file diff --git a/lib/es6/Dim4.js b/lib/es6/Dim4.js new file mode 100644 index 0000000..ef8ae78 --- /dev/null +++ b/lib/es6/Dim4.js @@ -0,0 +1,158 @@ +'use strict'; +const _ = require('lodash'); +const fastcall = require('fastcall'); +const ref = fastcall.ref; +const typedefs = require('./typedefs'); +const DimTArray = typedefs.DimTArray; +const assert = require('assert'); + +class Dim4 { + static define(af) { + af.dim4 = function () { + return new Dim4(...arguments); + }; + } + + constructor() { + this.data = new DimTArray(); + this.first = 0; + this.second = 0; + this.third = 0; + this.fourth = 0; + + if (arguments.length) { + const firstArg = arguments[0]; + + if (_.isObject(firstArg) || _.isArray(firstArg)) { + if (firstArg[0] >= 0) { + this.first = firstArg[0]; + } + if (firstArg[1] >= 0) { + this.second = firstArg[1]; + } + if (firstArg[2] >= 0) { + this.third = firstArg[2]; + } + if (firstArg[3] >= 0) { + this.fourth = firstArg[3]; + } + } + else { + if (arguments[0] >= 0) { + this.first = arguments[0]; + } + if (arguments[1] >= 0) { + this.second = arguments[1]; + } + if (arguments[2] >= 0) { + this.third = arguments[2]; + } + if (arguments[3] >= 0) { + this.fourth = arguments[3]; + } + } + } + } + + get first() { + return this.data.get(0); + } + + set first(value) { + this.data.set(0, value); + } + + get second() { + return this.data.get(1); + } + + set second(value) { + this.data.set(1, value); + } + + get third() { + return this.data.get(2); + } + + set third(value) { + this.data.set(2, value); + } + + get fourth() { + return this.data.get(3); + } + + set fourth(value) { + this.data.set(3, value); + } + + get [0]() { + return this.first; + } + + set [0](value) { + this.first = value; + } + + get [1]() { + return this.second; + } + + set [1](value) { + this.second = value; + } + + get [2]() { + return this.third; + } + + set [2](value) { + this.third = value; + } + + get [3]() { + return this.fourth; + } + + set [3](value) { + this.fourth = value; + } + + get ndims() { + if (this.fourth > 1) { + return 4; + } + if (this.third > 1) { + return 3; + } + if (this.second > 1) { + return 2; + } + if (this.first > 0) { + return 1; + } + return 0; + } + + get elements() { + if (this.fourth > 0) { + return this.fourth * this.third * this.second * this.first; + } + if (this.third > 0) { + return this.third * this.second * this.first; + } + if (this.second > 0) { + return this.second * this.first; + } + if (this.first > 0) { + return this.first; + } + return 0; + } + + get buffer() { + return this.data.buffer; + } +} + +module.exports = Dim4; \ No newline at end of file diff --git a/lib/es6/Idx.js b/lib/es6/Idx.js new file mode 100644 index 0000000..18745a6 --- /dev/null +++ b/lib/es6/Idx.js @@ -0,0 +1,90 @@ +'use strict'; +const _ = require('lodash'); +const fastcall = require('fastcall'); +const assert = require('assert'); +const Seq = require('./Seq'); +const Col = require('./Col'); +const Cols = require('./Cols'); +const Row = require('./Row'); +const Rows = require('./Rows'); +const helpers = require('./helpers'); + +class Idx { + static define(af) { + af.idx = function () { + return new Idx(af, ...arguments); + }; + } + + constructor(af, ...args) { + this.indices = af._lib.arrays.IndexArray.type(4); + this.ndims = 0; + this._parseIndexArgs(af, args); + } + + get buffer() { + return this.indices.buffer; + } + + get(idx) { + return this.indices.get(idx); + } + + _parseIndexArgs(af, args) { + const lib = af._lib; + let i = 0; + for (; i < args.length; i++) { + const arg = args[i]; + if (arg instanceof Seq) { + this.indices.set(i, seqIndex(arg)); + } + else if (arg === af.span) { + this.indices.set(i, seqIndex(new Seq(1, 1, 0))); + } + else if (_.isNumber(arg)) { + this.indices.set(i, seqIndex(new Seq(arg))); + } + else if (arg instanceof Row) { + this.indices.set(i++, seqIndex(new Seq(arg.index))); + this.indices.set(i, seqIndex(new Seq(1, 1, 0))); + } + else if (arg instanceof Rows) { + this.indices.set(i++, seqIndex(new Seq(arg.firstIndex, arg.lastIndex))); + this.indices.set(i, seqIndex(new Seq(1, 1, 0))); + } + else if (arg instanceof Col) { + this.indices.set(i++, seqIndex(new Seq(1, 1, 0))); + this.indices.set(i, seqIndex(new Seq(arg.index))); + } + else if (arg instanceof Cols) { + this.indices.set(i++, seqIndex(new Seq(1, 1, 0))); + this.indices.set(i, seqIndex(new Seq(arg.firstIndex, arg.lastIndex))); + } + else { + // AFArray + this.indices.set(i, lib.structs.IndexT.type({ + idx: { + arr: helpers.getHandle(arg) + }, + isSeq: false, + isBatch: af._batch + })); + } + } + + assert(i > 0 && i <= 4, 'Invalid index arguments.'); + this.ndims = i; + + function seqIndex(seq) { + return lib.structs.IndexT.type({ + idx: { + seq: seq.data + }, + isSeq: true, + isBatch: af._batch + }); + } + } +} + +module.exports = Idx; \ No newline at end of file diff --git a/lib/es6/Row.js b/lib/es6/Row.js new file mode 100644 index 0000000..e8be390 --- /dev/null +++ b/lib/es6/Row.js @@ -0,0 +1,15 @@ +'use strict'; + +class Row { + static define(af) { + af.row = function (index) { + return new Row(index); + }; + } + + constructor(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 new file mode 100644 index 0000000..f82eb55 --- /dev/null +++ b/lib/es6/Rows.js @@ -0,0 +1,16 @@ +'use strict'; + +class Rows { + static define(af) { + af.rows = function (firstIndex, lastIndex) { + return new Rows(firstIndex, lastIndex); + }; + } + + constructor(firstIndex, lastIndex) { + this.firstIndex = firstIndex; + this.lastIndex = lastIndex; + } +} + +module.exports = Rows; \ No newline at end of file diff --git a/lib/es6/Seq.js b/lib/es6/Seq.js new file mode 100644 index 0000000..23979aa --- /dev/null +++ b/lib/es6/Seq.js @@ -0,0 +1,63 @@ +'use strict'; +const typedefs = require('./typedefs'); +const SeqT = typedefs.SeqT; + +class Seq { + static define(af) { + af.seq = function () { + return new Seq(...arguments); + }; + } + + constructor(v1, v2, v3) { + if (v3 === undefined) { + if (v2 === undefined) { + this.data = new SeqT({ + begin: v1, + end: v1, + step: 1 + }); + } + else { + this.data = new SeqT({ + begin: v1, + end: v2, + step: 1 + }); + } + } + else { + this.data = new SeqT({ + begin: v1, + end: v2, + step: v3 + }); + } + } + + get begin() { + return this.data.begin; + } + + set begin(value) { + this.data.begin = value; + } + + get end() { + return this.data.end; + } + + set end(value) { + this.data.end = value; + } + + get step() { + return this.data.step; + } + + set step(value) { + this.data.step = value; + } +} + +module.exports = Seq; \ No newline at end of file diff --git a/lib/es6/arrayIndexing.js b/lib/es6/arrayIndexing.js new file mode 100644 index 0000000..58d121e --- /dev/null +++ b/lib/es6/arrayIndexing.js @@ -0,0 +1,138 @@ +'use strict'; +const fastcall = require('fastcall'); +const ref = fastcall.ref; +const typedefs = require('./typedefs'); +const handleType = typedefs.handleType; +const helpers = require('./helpers'); +const Promise = require('bluebird'); +const async = Promise.coroutine; +const Seq = require('./Seq'); +const assert = require('assert'); +const Idx = require('./Idx'); +const _ = require('lodash'); + +module.exports = function (af, AFArray) { + const lib = af._lib; + const intf = lib.interface; + + let callAssign = null; + + // index + + lib.declare('int af_index_gen(void** out, void* in, longlong ndims, IndexT* indices)'); + + af.index = af._makeFunction( + function () { + this.out = ref.alloc(handleType); + }, + function (array, idx) { + const _idx = asIdx(idx); + return intf.af_index_gen(this.out, helpers.getHandle(array), _idx.ndims, _idx.buffer); + }, + function () { + return this.out.deref(); + }); + + // assign + + lib.declare('int af_assign_gen(void** out, void* lhs, longlong ndims, IndexT* indices, void* rhs)'); + + af.assign = af._makeFunction( + function () { + this.out = ref.alloc(handleType); + }, + function (array, idx, value) { + const _idx = asIdx(idx); + assert(value !== undefined, 'Argument "value" expected.'); + return callAssign(this.out, helpers.getHandle(array), _idx, value); + }, + function () { + return this.out.deref(); + }); + + function asIdx(idx) { + if (idx instanceof Idx) { + return idx; + } + return af.idx(idx); + } + + if (af.options.async) { + callAssign = function (out, arrayHandle, idx, value) { + return af.scope.async(function* () { + let rhs; + if (_.isNumber(value)) { + let dims; + if (idx.ndims === 1 && !idx.get(0).isSeq) { + const elems = yield af.getElements(idx.get(0).idx.arr); + dims = af.dim4(elems); + } + else { + let arrDims = null; + const getArrDims = async(function* () { + if (arrDims === null) { + arrDims = yield af.getDims(arrayHandle); + } + return arrDims; + }); + dims = af.dim4(1, 1, 1, 1); + for (let i = 0; i < idx.ndims; i++) { + const seq = idx.get(i).idx.seq; + if (seq.step === 0) { + // span: + dims[i] = (yield getArrDims())[i]; + } + else { + dims[i] = seq.end - seq.begin + 1; + } + } + } + rhs = yield af.constant(value, dims, yield af.getType(arrayHandle)).handle; + } + else { + rhs = helpers.getHandle(value); + } + return yield intf.af_assign_gen(out, arrayHandle, idx.ndims, idx.buffer, rhs); + }); + }; + } + else { + callAssign = function (out, arrayHandle, idx, value) { + return af.scope(() => { + let rhs; + if (_.isNumber(value)) { + let dims; + if (idx.ndims === 1 && !idx.get(0).isSeq) { + const elems = af.getElements(idx.get(0).idx.arr); + dims = af.dim4(elems); + } + else { + let arrDims = null; + const getArrDims = () => { + if (arrDims === null) { + arrDims = af.getDims(arrayHandle); + } + return arrDims; + }; + dims = af.dim4(1, 1, 1, 1); + for (let i = 0; i < idx.ndims; i++) { + const seq = idx.get(i).idx.seq; + if (seq.step === 0) { + // span: + dims[i] = getArrDims()[i]; + } + else { + dims[i] = seq.end - seq.begin + 1; + } + } + } + rhs = af.constant(value, dims, af.getType(arrayHandle)).handle; + } + else { + rhs = helpers.getHandle(value); + } + return intf.af_assign_gen(out, arrayHandle, idx.ndims, idx.buffer, rhs); + }); + }; + } +}; \ 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/create.js b/lib/es6/create.js new file mode 100644 index 0000000..c688d28 --- /dev/null +++ b/lib/es6/create.js @@ -0,0 +1,28 @@ +'use strict'; +const _ = require('lodash'); +const fastcall = require('fastcall'); +const ref = fastcall.ref; +const Dim4 = require('./Dim4'); +const assert = require('assert'); +const typedefs = require('./typedefs'); + +module.exports = function (af) { + const lib = af._lib; + const intf = lib.interface; + + // constant + + lib.declare('int af_constant(void** outArr, double value, uint ndims, longlong* dims, int type)'); + + af.constant = af._makeFunction( + function () { + this.res = ref.alloc(typedefs.handleType); + }, + function (value, dims, type = 0) { + assert(dims instanceof Dim4, 'Argument "dims" is not a Dim4 instance.'); + return intf.af_constant(this.res, value, dims.ndims, dims.buffer, type); + }, + function () { + return af.array(ref.deref(this.res)); + }); +}; \ No newline at end of file diff --git a/lib/es6/device.js b/lib/es6/device.js new file mode 100644 index 0000000..ef212be --- /dev/null +++ b/lib/es6/device.js @@ -0,0 +1,132 @@ +'use strict'; +const fastcall = require('fastcall'); +const ref = fastcall.ref; + +module.exports = function (af) { + const lib = af._lib; + const intf = lib.interface; + + // deviceInfo + + lib.declare('int af_device_info(CString name, CString platform, CString toolkit, CString compute)'); + + af.deviceInfo = af._makeFunction( + function () { + this.name = new Buffer(512); + this.platform = new Buffer(512); + this.toolkit = new Buffer(512); + this.compute = new Buffer(512); + }, + function (name, platform, toolkit, compute) { + this.outName = name; + this.outPlatform = platform; + this.outToolkit = toolkit; + this.outCompute = compute; + + this.name.fill(0); + this.platform.fill(0); + this.toolkit.fill(0); + this.compute.fill(0); + + return intf.af_device_info(this.name, this.platform, this.toolkit, this.compute); + }, + function () { + this.outName && (this.outName.value = ref.readCString(this.name)); + this.outPlatform && (this.outPlatform.value = ref.readCString(this.platform)); + this.outToolkit && (this.outToolkit.value = ref.readCString(this.toolkit)); + this.outCompute && (this.outCompute.value = ref.readCString(this.compute)); + }); + + // infoString + + if (lib.isSymbolExists('af_info_string')) { + lib.declare('int af_info_string(char** result, bool verbose)'); + + af.infoString = af._makeFunction( + function () { + this.infoPtr = ref.alloc('char*'); + }, + function (verbose = false) { + return intf.af_info_string(this.infoPtr); + }, + function () { + return ref.readCString(this.infoPtr.deref()); + } + ); + } + else { + af.infoString = af._makeFunction( + function () { + this.outName = { value: null }; + this.outPlatform = { value: null }; + this.outToolkit = { value: null }; + this.outCompute = { value: null }; + }, + function () { + return af.deviceInfo(this.outName, this.outPlatform, this.outToolkit, this.outCompute); + }, + function () { + return `name: ${ this.outName.value }, ' + + 'platform: ${ this.outPlatform.value }, ' + + 'toolkit: ${ this.outToolkit.value }, ' + + 'compute: ${ this.outCompute.value }`; + }); + } + + // getDeviceCount + + lib.declare('int af_get_device_count(int* id)'); + + af.getDeviceCount = af._makeFunction( + function () { + this.res = ref.alloc(ref.types.int); + }, + function () { + return intf.af_get_device_count(this.res); + }, + function () { + return this.res.deref(); + }); + + // setDevice + + lib.declare('int af_set_device(int id)'); + + af.setDevice = af._makeFunction( + function (id) { + return intf.af_set_device(id); + }); + + // getDevice + + lib.declare('int af_get_device(int* id)'); + + af.getDevice = af._makeFunction( + function () { + this.res = ref.alloc(ref.types.int); + }, + function () { + return intf.af_get_device(this.res); + }, + function () { + return this.res.deref(); + }); + + // setSeed + + lib.declare('int af_set_seed(uint64 seed)'); + + af.setSeed = af._makeFunction( + function (seed) { + return intf.af_set_seed(seed); + }); + + // sync + + lib.declare('int af_sync(int deviceId)'); + + af.sync = af._makeFunction( + function (deviceId = -1) { + return intf.af_sync(deviceId); + }); +} \ 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/enums.js b/lib/es6/enums.js new file mode 100644 index 0000000..67ece14 --- /dev/null +++ b/lib/es6/enums.js @@ -0,0 +1,46 @@ +'use strict'; + +exports.backend = { + // Default backend order: OpenCL -> CUDA -> CPU. + DEFAULT: 0, + // CPU a.k.a sequential algorithms. + CPU: 1, + // CUDA Compute Backend. + CUDA: 2, + // OpenCL Compute Backend. + OPENCL: 3 +}; + +exports.dtype = { + f32: 0, + // 32-bit floating point values + c32: 1, + // 32-bit complex floating point values + f64: 2, + // 64-bit complex floating point values + c64: 3, + // 64-bit complex floating point values + b8: 4, + // 8-bit boolean values + s32: 5, + // 32-bit signed integral values + u32: 6, + // 32-bit unsigned integral values + u8: 7, + // 8-bit unsigned integral values + s64: 8, + // 64-bit signed integral values + u64: 9, + // 64-bit unsigned integral values + s16: 10, + // 16-bit signed integral values + u16: 11 + // 16-bit unsigned integral values +}; + +exports.source = { + // Device pointer. + device: 0, + // Host pointer. + host: 1 +}; \ No newline at end of file diff --git a/lib/es6/errors.js b/lib/es6/errors.js new file mode 100644 index 0000000..1379a21 --- /dev/null +++ b/lib/es6/errors.js @@ -0,0 +1,34 @@ +'use strict'; +const util = require('util'); +const assert = require('assert'); + +exports.AFError = AFError; +exports.AFChainedError = AFChainedError; +exports.verify = verify; + +function AFError(message, code) { + Error.captureStackTrace(this, this.constructor); + this.name = this.constructor.name; + this.message = (message || 'Unknown ArrayFire error.') + (' (code: ' + code + ')'); + if (code !== undefined) { + this.code = code; + } +} + +util.inherits(AFError, Error); + +function AFChainedError(errors) { + assert(errors.lenght); + + AFError.call(this, `${ errors[0].message } (More errors captured, refer to "errors" property's value.)`, errors[0].code); + this.errors = errors; + this.code = errors[0].code; +} + +util.inherits(AFChainedError, AFError); + +function verify(code) { + if (code > 0) { + throw new AFError("AFError", code); + } +} \ 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/helpers.js b/lib/es6/helpers.js new file mode 100644 index 0000000..c3a359f --- /dev/null +++ b/lib/es6/helpers.js @@ -0,0 +1,58 @@ +'use strict'; +const Dim4 = require('./Dim4'); +const _ = require('lodash'); +const assert = require('assert'); +const fastcall = require('fastcall'); +const ArrayType = fastcall.ArrayType; +const FloatArray = new ArrayType('float'); +const semver = require('semver'); + +const helpers = exports; + +helpers.getHandle = function (array) { + if (array.handle) { + return array.handle; + } + return array; +}; + +helpers.toBuffer = function (obj) { + if (Buffer.isBuffer(obj)) { + return obj; + } + if (_.isArray(obj)) { + const arr = new FloatArray(obj.length); + for (let i = 0; i < obj.length; i++) { + arr.set(i, Number(obj[i])); + } + return arr.buffer; + } + if (_.isTypedArray(obj)) { + return _typedArrayToBuffer(obj); + } + throw new TypeError('Argument "obj" is not a Buffer.'); +}; + +helpers.typedArrayToBuffer = function (arr) { + assert(_.isTypedArray(arr), 'Argument "arr" is not a typed array.'); + + return _typedArrayToBuffer(arr); +}; + +function _typedArrayToBuffer(arr) { + if (arr.byteLength !== arr.buffer.byteLength) { + return helpers.arrayToBuffer(arr.buffer, arr.byteOffset, arr.byteLength); + } + return helpers.arrayToBuffer(arr.buffer); +} + +if (semver.gt(process.versions.node, '5.1.0')) { + helpers.arrayToBuffer = function (arr, byteOffset, length) { + return Buffer.from(arr, byteOffset, length); + }; +} +else { + helpers.arrayToBuffer = function (arr, byteOffset, length) { + return new Buffer(arr, byteOffset, length); + }; +} \ No newline at end of file diff --git a/lib/es6/index.js b/lib/es6/index.js index 66c143b..9f9878d 100644 --- a/lib/es6/index.js +++ b/lib/es6/index.js @@ -1,78 +1,6 @@ -/* -Copyright (c) 2014-2015, ArrayFire -Copyright (c) 2015 Gábor Mező aka unbornchikken (gabor.mezo@outlook.com) -All rights reserved. +'use strict'; +const errors = require('./errors'); -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 +exports.ArrayFire = require('./ArrayFire'); +exports.AFError = errors.AFError; +exports.AFChainedError = errors.AFChainedError; \ 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/es6/typedefs.js b/lib/es6/typedefs.js new file mode 100644 index 0000000..af0268d --- /dev/null +++ b/lib/es6/typedefs.js @@ -0,0 +1,28 @@ +'use strict'; +const fastcall = require('fastcall'); +const ref = fastcall.ref; +const ArrayType = fastcall.ArrayType; +const StructType = fastcall.StructType; + +const typedefs = exports; + +typedefs.handleType = ref.refType('void'); +typedefs.outHandleType = ref.refType(typedefs.handleType); +typedefs.DimTArray = new ArrayType('longlong', 4); +typedefs.SeqT = new StructType({ + begin: 'double', + end: 'double', + step: 'double' +}); + +typedefs.define = function (af) { + const lib = af._lib; + + lib.struct({ SeqT: typedefs.SeqT }); + + lib.declare( + 'void*[] PointerArray;' + + 'union ArrayOrSeqT { void* arr; SeqT seq; };' + + 'struct IndexT { ArrayOrSeqT idx; bool isSeq; bool isBatch; };' + + 'IndexT[] IndexArray;'); +}; \ No newline at end of file diff --git a/lib/es6/unified.js b/lib/es6/unified.js new file mode 100644 index 0000000..c0439c4 --- /dev/null +++ b/lib/es6/unified.js @@ -0,0 +1,64 @@ +'use strict'; +const fastcall = require('fastcall'); +const ref = fastcall.ref; + +module.exports = function (af) { + const lib = af._lib; + const intf = lib.interface; + + // getActiveBackend + + lib.declare('int af_get_active_backend(int* backend)'); + + af.getActiveBackend = af._makeFunction( + function () { + this.res = ref.alloc(ref.types.int); + }, + function () { + return intf.af_get_active_backend(this.res); + }, + function () { + return this.res.deref(); + }); + + // getAvailableBackends + + lib.declare('int af_get_available_backends(int* backend)'); + + af.getAvailableBackends = af._makeFunction( + function () { + this.res = ref.alloc(ref.types.int); + }, + function () { + return intf.af_get_available_backends(this.res); + }, + function () { + return this.res.deref(); + }); + + // getBackendCount + + lib.declare('int af_get_backend_count(uint* backend)'); + + af.getBackendCount = af._makeFunction( + function () { + this.res = ref.alloc(ref.types.uint); + }, + function () { + return intf.af_get_backend_count(this.res); + }, + function () { + return this.res.deref(); + }); + + // setBackend + + lib.declare('int af_set_backend(int deviceId)'); + + af.setBackend = af._makeFunction( + function (id) { + return intf.af_set_backend(id); + }); + + // TODO: getBackendId, getDeviceId for array +}; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 2248102..18dff17 100644 --- a/lib/index.js +++ b/lib/index.js @@ -29,12 +29,22 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var es6 = true; -try { - eval("(() => {})()"); -} catch (err) { +var args = require('minimist')(process.argv.slice(2)); + +var es6; + +if (args.old) { es6 = false; } +else { + es6 = true; + try { + eval('const err = () => { throw new Error(`foo`); };const args = ["a", "return a"];new Function(...args)(1) === 1||err();'); + eval('function Poo (a = 1) {}'); + } catch (err) { + es6 = false; + } +} var es = es6 ? "es6" : "es5"; diff --git a/package.json b/package.json index 3017ca4..50dc7df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arrayfire-js", - "version": "0.21.4", + "version": "0.3.0", "description": "ArrayFire.js - ArrayFire for Node.js platform", "license": "BSD-3-Clause", "repository": { @@ -8,33 +8,25 @@ "url": "https://github.com/arrayfire/arrayfire-js.git" }, "dependencies": { - "babel-polyfill": "^6.2.0", - "bluebird": "^3.0.5", - "lodash": "^3.10.1", - "bindings": "*", - "cmake-js": "3", - "nan": "^2.1.0", - "better-assert": "*" + "babel-polyfill": "^6.16.0", + "bindings": "1", + "bluebird": "3", + "debug": "^2.2.0", + "fastcall": "~0.2.3", + "lodash": "4", + "minimist": "^1.2.0", + "nan": "^2.4.0", + "semver": "^5.3.0" }, "scripts": { - "install": "cmake-js compile", - "test": "mocha tests", - "test-es5": "mocha tests --old" + "test": "mocha -gc -t 20000", + "test-es5": "mocha --old", + "babel": "babel lib/es6 -d lib/es5 --source-maps&&babel test/es6 -d test/es5 --source-maps" }, "main": "lib/", "devDependencies": { - "babel": "^6.1.18", - "babel-preset-es2015": "^6.1.18", - "debug": "*", - "fs-extra": "*", - "gulp": "^3.9.0", - "gulp-babel": "^6.1.0", - "gulp-sequence": "^0.4.1", - "gulp-sourcemaps": "^1.6.0", - "merge2": "*", - "mocha": "^2.3.4", - "performance-now": "*", - "ref": "*", - "yargs": "^3.31.0" + "babel-cli": "^6.18.0", + "babel-preset-es2015": "^6.18.0", + "mocha": "3" } } 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/test/es5/array.js b/test/es5/array.js new file mode 100644 index 0000000..c4967e6 --- /dev/null +++ b/test/es5/array.js @@ -0,0 +1,916 @@ +'use strict'; + +var Promise = require('bluebird'); +var assert = require('assert'); +var _ = require('lodash'); +var async = Promise.coroutine; +var arrayFireJs = require('../..'); +var ArrayFire = arrayFireJs.ArrayFire; +var fastcall = require('fastcall'); +var ArrayType = fastcall.ArrayType; +var FloatArray = new ArrayType('float'); +var IntArray = new ArrayType('int32'); +var ref = fastcall.ref; + +describe('AFArray', function () { + describe('sync', function () { + var af = null; + + beforeEach(function () { + af = new ArrayFire(); + af.scope.begin(); + }); + + afterEach(function () { + if (af) { + af.scope.end(); + af.release(); + af = null; + } + }); + + it('could be created by calling af.array()', function () { + var arr = void 0; + var afArr = void 0; + var dims = void 0; + var buff = void 0; + var refArr = void 0; + + arr = [1, 2]; + afArr = af.array(arr); + dims = afArr.dims(); + assert.strictEqual(dims[0], 2); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 1); + assert.strictEqual(afArr.dims(0), 2); + assert.strictEqual(afArr.dims(1), 1); + assert.strictEqual(afArr.dims(2), 1); + assert.strictEqual(afArr.dims(3), 1); + + arr = new Float32Array([1, 2]); + afArr = af.array(arr); + dims = afArr.dims(); + assert.strictEqual(dims[0], 2); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 1); + assert.strictEqual(afArr.dims(0), 2); + assert.strictEqual(afArr.dims(1), 1); + assert.strictEqual(afArr.dims(2), 1); + assert.strictEqual(afArr.dims(3), 1); + buff = afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new FloatArray(buff); + assert.equal(refArr.length, 2); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + refArr.set(0, 0); + refArr.set(1, 0); + assert.equal(refArr.get(0), 0); + assert.equal(refArr.get(1), 0); + afArr.host(refArr.buffer); + assert.equal(refArr.length, 2); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + + arr = new FloatArray(2); + arr.set(0, 1); + arr.set(1, 2); + afArr = af.array(af.dim4(1, 2), arr.buffer); + dims = afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 2); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 2); + + afArr = af.array(af.dim4(3), af.dtype.s32); + dims = afArr.dims(); + assert.strictEqual(dims[0], 3); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 3); + assert.strictEqual(dims.ndims, 1); + buff = afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new IntArray(buff); + assert.equal(refArr.length, 3); + + afArr = af.array(af.dim4(1, 3)); + dims = afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 3); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 3); + assert.strictEqual(dims.ndims, 2); + assert.strictEqual(afArr.type(), af.dtype.f32); + assert.strictEqual(afArr.refType(), ref.types.float); + + arr = [1, 2, 3, 4]; + afArr = af.array(af.dim4(1, 1, 4), arr, af.dtype.s32); + dims = afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 4); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 4); + assert.strictEqual(dims.ndims, 3); + buff = afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new IntArray(buff); + assert.equal(refArr.length, 4); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + assert.equal(refArr.get(2), 3); + assert.equal(refArr.get(3), 4); + }); + + it('should support .index() for various parameter types', function () { + var afArr = void 0; + var afIdx = void 0; + var indexed = void 0; + var arr = void 0; + var dims = void 0; + + afArr = af.array([1, 2, 3, 4, 5]); + dims = afArr.dims(); + assert.strictEqual(dims[0], 5); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(afArr.elements(), 5); + assert.strictEqual(afArr.numdims(), 1); + + indexed = afArr.index(af.seq(1)); + assert.deepEqual(indexed.toArray(), [2]); + + indexed = afArr.index(2); + assert.deepEqual(indexed.toArray(), [3]); + + indexed = afArr.index(af.seq(1, 3)); + assert.deepEqual(indexed.toArray(), [2, 3, 4]); + + afArr = af.array(af.dim4(4, 4), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + assert.strictEqual(afArr.elements(), 16); + assert.strictEqual(afArr.numdims(), 2); + assert.strictEqual(afArr.dims(0), 4); + assert.strictEqual(afArr.dims(1), 4); + + indexed = afArr.index(af.seq(2, 4)); + assert.deepEqual(indexed.toArray(), [3, 4, 5]); + + indexed = afArr.index(af.idx(af.seq(0, 2), af.seq(1, 2))); + assert.deepEqual(indexed.toArray(), [5, 6, 7, 9, 10, 11]); + + indexed = afArr.index(af.idx(af.end, af.seq(2, 3))); + assert.deepEqual(indexed.toArray(), [12, 16]); + + indexed = afArr.index(af.span); + assert.deepEqual(indexed.toArray(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + indexed = afArr.index(af.idx(1, af.span)); + assert.deepEqual(indexed.toArray(), [2, 6, 10, 14]); + + afArr = af.array([1, 2, 3, 4, 5]); + afIdx = af.array([1, 0, 2]); + indexed = afArr.index(afIdx); + assert.deepEqual(indexed.toArray(), [2, 1, 3]); + + afArr = af.array(af.dim4(4, 4), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + afIdx = af.array(af.dim4(3, 2), [1, 0, 2, 5, 10, 2]); + + indexed = afArr.index(afIdx); + assert.deepEqual(indexed.toArray(), [2, 1, 3, 6, 11, 3]); + + // Col, Row + afArr = af.array(af.dim4(3, 3), [0, 1, 2, 3, 4, 5, 6, 7, 8]); + + indexed = afArr.index(af.row(0)); + assert.deepEqual(indexed.toArray(), [0, 3, 6]); + + indexed = afArr.index(af.row(2)); + assert.deepEqual(indexed.toArray(), [2, 5, 8]); + + indexed = afArr.index(af.rows(0, 1)); + assert.deepEqual(indexed.toArray(), [0, 1, 3, 4, 6, 7]); + + indexed = afArr.index(af.col(0)); + assert.deepEqual(indexed.toArray(), [0, 1, 2]); + + indexed = afArr.index(af.col(2)); + assert.deepEqual(indexed.toArray(), [6, 7, 8]); + + indexed = afArr.index(af.cols(1, 2)); + assert.deepEqual(indexed.toArray(), [3, 4, 5, 6, 7, 8]); + }); + + it.only('should support .assign() for various parameter types', function () { + var afArr = void 0; + + afArr = af.array([1, 2, 3, 4]); + afArr.assign(af.span, 5); + assert.deepEqual(afArr.toArray(), [5, 5, 5, 5]); + + afArr = af.array([1, 2, 3, 4]); + afArr.assign(af.seq(1, 2), 5.5); + assert.deepEqual(afArr.toArray(), [1, 5.5, 5.5, 4]); + /* + afArr = array(af, [1,2,3,4]) + afArr[2:3] = 5.5f0 + @test host(afArr) == [1,5,5,4] + afArr = array(af, [1,2,3,4]) + afArr[1:2] = array(af, [10.1f0, 11.1f0]) + @test host(afArr) == [10,11,3,4] + @test_throws AFErrorException afArr[1:2] = array(af, [10.1f0, 11.1f0, 12.2f0]) + afArr = array(af, [[1,2,3,4] [5,6,7,8] [9,10,11,12] [13, 14, 15, 16]]) + afArr[:, 3:4] = array(af, [[1,2,3,4] [5,6,7,8]]) + @test host(afArr) == [[1,2,3,4] [5,6,7,8] [1,2,3,4] [5,6,7,8]] + afArr[3:4, :] = 1.1f0 + @test host(afArr) == [[1,2,1,1] [5,6,1,1] [1,2,1,1] [5,6,1,1]] + afArr = array(af, [[1,2,3,4] [5,6,7,8] [9,10,11,12] [13, 14, 15, 16]]) + afArr[array(af, [10, 11, 12, 13, 14, 15])] = array(af, [55, 66, 77, 88, 99, 100]) + @test host(afArr) == [[1,2,3,4] [5,6,7,8] [9,10,55,66] [77, 88, 99, 100]] + afArr[array(af, [[1, 2, 3] [4, 5, 6]])] = array(af, [55, 66, 77, 88, 99, 100]) + @test host(afArr) == [[1,55,66,77] [88,99,100,8] [9,10,55,66] [77, 88, 99, 100]] + @test_throws AFErrorException afArr[array(af, [[1, 2, 3] [4, 5, 6]])] = array(af, [[55, 66, 77] [88, 99, 100]]) + afArr = array(af, [[1,2,3,4] [5,6,7,8] [9,10,11,12] [13, 14, 15, 16]]) + afArr[array(af, [[1, 2, 3] [4, 5, 6]])] = -1 + @test host(afArr) == [[1,-1,-1,-1] [-1,-1,-1,8] [9,10,11,12] [13, 14, 15, 16]] + */ + }); + + it('should support copy-on-write', function () {}); + }); + + describe('async', function () { + var af = null; + + beforeEach(function () { + af = new ArrayFire({ async: true }); + af.scope.begin(); + }); + + afterEach(async(regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + if (!af) { + _context.next = 5; + break; + } + + _context.next = 3; + return af.scope.end(); + + case 3: + af.release(); + af = null; + + case 5: + case 'end': + return _context.stop(); + } + } + }, _callee, this); + }))); + + it('could be created by calling af.array()', async(regeneratorRuntime.mark(function _callee2() { + var arr, afArr, dims, buff, refArr; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + arr = void 0; + afArr = void 0; + dims = void 0; + buff = void 0; + refArr = void 0; + + + arr = [1, 2]; + _context2.next = 8; + return af.array(arr); + + case 8: + afArr = _context2.sent; + _context2.next = 11; + return afArr.dims(); + + case 11: + dims = _context2.sent; + + assert.strictEqual(dims[0], 2); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 1); + _context2.t0 = assert; + _context2.next = 21; + return afArr.dims(0); + + case 21: + _context2.t1 = _context2.sent; + + _context2.t0.strictEqual.call(_context2.t0, _context2.t1, 2); + + _context2.t2 = assert; + _context2.next = 26; + return afArr.dims(1); + + case 26: + _context2.t3 = _context2.sent; + + _context2.t2.strictEqual.call(_context2.t2, _context2.t3, 1); + + _context2.t4 = assert; + _context2.next = 31; + return afArr.dims(2); + + case 31: + _context2.t5 = _context2.sent; + + _context2.t4.strictEqual.call(_context2.t4, _context2.t5, 1); + + _context2.t6 = assert; + _context2.next = 36; + return afArr.dims(3); + + case 36: + _context2.t7 = _context2.sent; + + _context2.t6.strictEqual.call(_context2.t6, _context2.t7, 1); + + arr = new Float32Array([1, 2]); + _context2.next = 41; + return af.array(arr); + + case 41: + afArr = _context2.sent; + _context2.next = 44; + return afArr.dims(); + + case 44: + dims = _context2.sent; + + assert.strictEqual(dims[0], 2); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 1); + _context2.t8 = assert; + _context2.next = 54; + return afArr.dims(0); + + case 54: + _context2.t9 = _context2.sent; + + _context2.t8.strictEqual.call(_context2.t8, _context2.t9, 2); + + _context2.t10 = assert; + _context2.next = 59; + return afArr.dims(1); + + case 59: + _context2.t11 = _context2.sent; + + _context2.t10.strictEqual.call(_context2.t10, _context2.t11, 1); + + _context2.t12 = assert; + _context2.next = 64; + return afArr.dims(2); + + case 64: + _context2.t13 = _context2.sent; + + _context2.t12.strictEqual.call(_context2.t12, _context2.t13, 1); + + _context2.t14 = assert; + _context2.next = 69; + return afArr.dims(3); + + case 69: + _context2.t15 = _context2.sent; + + _context2.t14.strictEqual.call(_context2.t14, _context2.t15, 1); + + _context2.next = 73; + return afArr.host(); + + case 73: + buff = _context2.sent; + + assert(Buffer.isBuffer(buff)); + refArr = new FloatArray(buff); + assert.equal(refArr.length, 2); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + refArr.set(0, 0); + refArr.set(1, 0); + assert.equal(refArr.get(0), 0); + assert.equal(refArr.get(1), 0); + _context2.next = 85; + return afArr.host(refArr.buffer); + + case 85: + assert.equal(refArr.length, 2); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + + arr = new FloatArray(2); + arr.set(0, 1); + arr.set(1, 2); + _context2.next = 93; + return af.array(af.dim4(1, 2), arr.buffer); + + case 93: + afArr = _context2.sent; + _context2.next = 96; + return afArr.dims(); + + case 96: + dims = _context2.sent; + + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 2); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 2); + + _context2.next = 105; + return af.array(af.dim4(3), af.dtype.s32); + + case 105: + afArr = _context2.sent; + _context2.next = 108; + return afArr.dims(); + + case 108: + dims = _context2.sent; + + assert.strictEqual(dims[0], 3); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 3); + assert.strictEqual(dims.ndims, 1); + _context2.next = 117; + return afArr.host(); + + case 117: + buff = _context2.sent; + + assert(Buffer.isBuffer(buff)); + refArr = new IntArray(buff); + assert.equal(refArr.length, 3); + + _context2.next = 123; + return af.array(af.dim4(1, 3)); + + case 123: + afArr = _context2.sent; + _context2.next = 126; + return afArr.dims(); + + case 126: + dims = _context2.sent; + + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 3); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 3); + assert.strictEqual(dims.ndims, 2); + _context2.t16 = assert; + _context2.next = 136; + return afArr.type(); + + case 136: + _context2.t17 = _context2.sent; + _context2.t18 = af.dtype.f32; + + _context2.t16.strictEqual.call(_context2.t16, _context2.t17, _context2.t18); + + _context2.t19 = assert; + _context2.next = 142; + return afArr.refType(); + + case 142: + _context2.t20 = _context2.sent; + _context2.t21 = ref.types.float; + + _context2.t19.strictEqual.call(_context2.t19, _context2.t20, _context2.t21); + + arr = [1, 2, 3, 4]; + _context2.next = 148; + return af.array(af.dim4(1, 1, 4), arr, af.dtype.s32); + + case 148: + afArr = _context2.sent; + _context2.next = 151; + return afArr.dims(); + + case 151: + dims = _context2.sent; + + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 4); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 4); + assert.strictEqual(dims.ndims, 3); + _context2.next = 160; + return afArr.host(); + + case 160: + buff = _context2.sent; + + assert(Buffer.isBuffer(buff)); + refArr = new IntArray(buff); + assert.equal(refArr.length, 4); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + assert.equal(refArr.get(2), 3); + assert.equal(refArr.get(3), 4); + + case 168: + case 'end': + return _context2.stop(); + } + } + }, _callee2, this); + }))); + + it('should support .index() for various parameter types', async(regeneratorRuntime.mark(function _callee3() { + var afArr, afIdx, indexed, arr, dims; + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + afArr = void 0; + afIdx = void 0; + indexed = void 0; + arr = void 0; + dims = void 0; + _context3.next = 7; + return af.array([1, 2, 3, 4, 5]); + + case 7: + afArr = _context3.sent; + _context3.next = 10; + return afArr.dims(); + + case 10: + dims = _context3.sent; + + assert.strictEqual(dims[0], 5); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + _context3.t0 = assert; + _context3.next = 18; + return afArr.elements(); + + case 18: + _context3.t1 = _context3.sent; + + _context3.t0.strictEqual.call(_context3.t0, _context3.t1, 5); + + _context3.t2 = assert; + _context3.next = 23; + return afArr.numdims(); + + case 23: + _context3.t3 = _context3.sent; + + _context3.t2.strictEqual.call(_context3.t2, _context3.t3, 1); + + _context3.next = 27; + return afArr.index(af.seq(1)); + + case 27: + indexed = _context3.sent; + _context3.t4 = assert; + _context3.next = 31; + return indexed.toArray(); + + case 31: + _context3.t5 = _context3.sent; + _context3.t6 = [2]; + + _context3.t4.deepEqual.call(_context3.t4, _context3.t5, _context3.t6); + + _context3.next = 36; + return afArr.index(2); + + case 36: + indexed = _context3.sent; + _context3.t7 = assert; + _context3.next = 40; + return indexed.toArray(); + + case 40: + _context3.t8 = _context3.sent; + _context3.t9 = [3]; + + _context3.t7.deepEqual.call(_context3.t7, _context3.t8, _context3.t9); + + _context3.next = 45; + return afArr.index(af.seq(1, 3)); + + case 45: + indexed = _context3.sent; + _context3.t10 = assert; + _context3.next = 49; + return indexed.toArray(); + + case 49: + _context3.t11 = _context3.sent; + _context3.t12 = [2, 3, 4]; + + _context3.t10.deepEqual.call(_context3.t10, _context3.t11, _context3.t12); + + _context3.next = 54; + return af.array(af.dim4(4, 4), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + case 54: + afArr = _context3.sent; + _context3.t13 = assert; + _context3.next = 58; + return afArr.elements(); + + case 58: + _context3.t14 = _context3.sent; + + _context3.t13.strictEqual.call(_context3.t13, _context3.t14, 16); + + _context3.t15 = assert; + _context3.next = 63; + return afArr.numdims(); + + case 63: + _context3.t16 = _context3.sent; + + _context3.t15.strictEqual.call(_context3.t15, _context3.t16, 2); + + _context3.t17 = assert; + _context3.next = 68; + return afArr.dims(0); + + case 68: + _context3.t18 = _context3.sent; + + _context3.t17.strictEqual.call(_context3.t17, _context3.t18, 4); + + _context3.t19 = assert; + _context3.next = 73; + return afArr.dims(1); + + case 73: + _context3.t20 = _context3.sent; + + _context3.t19.strictEqual.call(_context3.t19, _context3.t20, 4); + + _context3.next = 77; + return afArr.index(af.seq(2, 4)); + + case 77: + indexed = _context3.sent; + _context3.t21 = assert; + _context3.next = 81; + return indexed.toArray(); + + case 81: + _context3.t22 = _context3.sent; + _context3.t23 = [3, 4, 5]; + + _context3.t21.deepEqual.call(_context3.t21, _context3.t22, _context3.t23); + + _context3.next = 86; + return afArr.index(af.idx(af.seq(0, 2), af.seq(1, 2))); + + case 86: + indexed = _context3.sent; + _context3.t24 = assert; + _context3.next = 90; + return indexed.toArray(); + + case 90: + _context3.t25 = _context3.sent; + _context3.t26 = [5, 6, 7, 9, 10, 11]; + + _context3.t24.deepEqual.call(_context3.t24, _context3.t25, _context3.t26); + + _context3.next = 95; + return afArr.index(af.idx(af.end, af.seq(2, 3))); + + case 95: + indexed = _context3.sent; + _context3.t27 = assert; + _context3.next = 99; + return indexed.toArray(); + + case 99: + _context3.t28 = _context3.sent; + _context3.t29 = [12, 16]; + + _context3.t27.deepEqual.call(_context3.t27, _context3.t28, _context3.t29); + + _context3.next = 104; + return afArr.index(af.span); + + case 104: + indexed = _context3.sent; + _context3.t30 = assert; + _context3.next = 108; + return indexed.toArray(); + + case 108: + _context3.t31 = _context3.sent; + _context3.t32 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; + + _context3.t30.deepEqual.call(_context3.t30, _context3.t31, _context3.t32); + + _context3.next = 113; + return afArr.index(af.idx(1, af.span)); + + case 113: + indexed = _context3.sent; + _context3.t33 = assert; + _context3.next = 117; + return indexed.toArray(); + + case 117: + _context3.t34 = _context3.sent; + _context3.t35 = [2, 6, 10, 14]; + + _context3.t33.deepEqual.call(_context3.t33, _context3.t34, _context3.t35); + + _context3.next = 122; + return af.array([1, 2, 3, 4, 5]); + + case 122: + afArr = _context3.sent; + _context3.next = 125; + return af.array([1, 0, 2]); + + case 125: + afIdx = _context3.sent; + _context3.next = 128; + return afArr.index(afIdx); + + case 128: + indexed = _context3.sent; + _context3.t36 = assert; + _context3.next = 132; + return indexed.toArray(); + + case 132: + _context3.t37 = _context3.sent; + _context3.t38 = [2, 1, 3]; + + _context3.t36.deepEqual.call(_context3.t36, _context3.t37, _context3.t38); + + _context3.next = 137; + return af.array(af.dim4(4, 4), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + case 137: + afArr = _context3.sent; + _context3.next = 140; + return af.array(af.dim4(3, 2), [1, 0, 2, 5, 10, 2]); + + case 140: + afIdx = _context3.sent; + _context3.next = 143; + return afArr.index(afIdx); + + case 143: + indexed = _context3.sent; + _context3.t39 = assert; + _context3.next = 147; + return indexed.toArray(); + + case 147: + _context3.t40 = _context3.sent; + _context3.t41 = [2, 1, 3, 6, 11, 3]; + + _context3.t39.deepEqual.call(_context3.t39, _context3.t40, _context3.t41); + + _context3.next = 152; + return af.array(af.dim4(3, 3), [0, 1, 2, 3, 4, 5, 6, 7, 8]); + + case 152: + afArr = _context3.sent; + _context3.next = 155; + return afArr.index(af.row(0)); + + case 155: + indexed = _context3.sent; + _context3.t42 = assert; + _context3.next = 159; + return indexed.toArray(); + + case 159: + _context3.t43 = _context3.sent; + _context3.t44 = [0, 3, 6]; + + _context3.t42.deepEqual.call(_context3.t42, _context3.t43, _context3.t44); + + _context3.next = 164; + return afArr.index(af.row(2)); + + case 164: + indexed = _context3.sent; + _context3.t45 = assert; + _context3.next = 168; + return indexed.toArray(); + + case 168: + _context3.t46 = _context3.sent; + _context3.t47 = [2, 5, 8]; + + _context3.t45.deepEqual.call(_context3.t45, _context3.t46, _context3.t47); + + _context3.next = 173; + return afArr.index(af.rows(0, 1)); + + case 173: + indexed = _context3.sent; + _context3.t48 = assert; + _context3.next = 177; + return indexed.toArray(); + + case 177: + _context3.t49 = _context3.sent; + _context3.t50 = [0, 1, 3, 4, 6, 7]; + + _context3.t48.deepEqual.call(_context3.t48, _context3.t49, _context3.t50); + + _context3.next = 182; + return afArr.index(af.col(0)); + + case 182: + indexed = _context3.sent; + _context3.t51 = assert; + _context3.next = 186; + return indexed.toArray(); + + case 186: + _context3.t52 = _context3.sent; + _context3.t53 = [0, 1, 2]; + + _context3.t51.deepEqual.call(_context3.t51, _context3.t52, _context3.t53); + + _context3.next = 191; + return afArr.index(af.col(2)); + + case 191: + indexed = _context3.sent; + _context3.t54 = assert; + _context3.next = 195; + return indexed.toArray(); + + case 195: + _context3.t55 = _context3.sent; + _context3.t56 = [6, 7, 8]; + + _context3.t54.deepEqual.call(_context3.t54, _context3.t55, _context3.t56); + + _context3.next = 200; + return afArr.index(af.cols(1, 2)); + + case 200: + indexed = _context3.sent; + _context3.t57 = assert; + _context3.next = 204; + return indexed.toArray(); + + case 204: + _context3.t58 = _context3.sent; + _context3.t59 = [3, 4, 5, 6, 7, 8]; + + _context3.t57.deepEqual.call(_context3.t57, _context3.t58, _context3.t59); + + case 207: + case 'end': + return _context3.stop(); + } + } + }, _callee3, this); + }))); + }); +}); +//# sourceMappingURL=array.js.map \ No newline at end of file diff --git a/test/es5/array.js.map b/test/es5/array.js.map new file mode 100644 index 0000000..766a8f0 --- /dev/null +++ b/test/es5/array.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/array.js"],"names":["Promise","require","assert","_","async","coroutine","arrayFireJs","ArrayFire","fastcall","ArrayType","FloatArray","IntArray","ref","describe","af","beforeEach","scope","begin","afterEach","end","release","it","arr","afArr","dims","buff","refArr","array","strictEqual","elements","ndims","Float32Array","host","Buffer","isBuffer","equal","length","get","set","buffer","dim4","dtype","s32","type","f32","refType","types","float","afIdx","indexed","numdims","index","seq","deepEqual","toArray","idx","span","row","rows","col","cols","only","assign"],"mappings":"AAAA;;AACA,IAAMA,UAAUC,QAAQ,UAAR,CAAhB;AACA,IAAMC,SAASD,QAAQ,QAAR,CAAf;AACA,IAAME,IAAIF,QAAQ,QAAR,CAAV;AACA,IAAMG,QAAQJ,QAAQK,SAAtB;AACA,IAAMC,cAAcL,QAAQ,OAAR,CAApB;AACA,IAAMM,YAAYD,YAAYC,SAA9B;AACA,IAAMC,WAAWP,QAAQ,UAAR,CAAjB;AACA,IAAMQ,YAAYD,SAASC,SAA3B;AACA,IAAMC,aAAa,IAAID,SAAJ,CAAc,OAAd,CAAnB;AACA,IAAME,WAAW,IAAIF,SAAJ,CAAc,OAAd,CAAjB;AACA,IAAMG,MAAMJ,SAASI,GAArB;;AAEAC,SAAS,SAAT,EAAoB,YAAY;AAC5BA,aAAS,MAAT,EAAiB,YAAY;AACzB,YAAIC,KAAK,IAAT;;AAEAC,mBAAW,YAAY;AACnBD,iBAAK,IAAIP,SAAJ,EAAL;AACAO,eAAGE,KAAH,CAASC,KAAT;AACH,SAHD;;AAKAC,kBAAU,YAAY;AAClB,gBAAIJ,EAAJ,EAAQ;AACJA,mBAAGE,KAAH,CAASG,GAAT;AACAL,mBAAGM,OA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,MAAM4B,KAAN,CAAYrC,GAAG6C,GAAH,CAAO,CAAP,CAAZ,CApF4C;;AAAA;AAoF5DV,mCApF4D;AAAA,4CAqF5D/C,MArF4D;AAAA;AAAA,mCAqFrC+C,QAAQK,OAAR,EArFqC;;AAAA;AAAA;AAAA,4CAqFlB,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CArFkB;;AAAA,0CAqFrDD,SArFqD;;AAAA;AAAA,mCAuF5C9B,MAAM4B,KAAN,CAAYrC,GAAG8C,IAAH,CAAQ,CAAR,EAAW,CAAX,CAAZ,CAvF4C;;AAAA;AAuF5DX,mCAvF4D;AAAA,4CAwF5D/C,MAxF4D;AAAA;AAAA,mCAwFrC+C,QAAQK,OAAR,EAxFqC;;AAAA;AAAA;AAAA,4CAwFlB,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,EAAgB,CAAhB,CAxFkB;;AAAA,0CAwFrDD,SAxFqD;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAN,EAA1D;AA0FH,KAlND;AAmNH,CAtdD","file":"array.js","sourcesContent":["'use strict';\nconst Promise = require('bluebird');\nconst assert = require('assert');\nconst _ = require('lodash');\nconst async = Promise.coroutine;\nconst arrayFireJs = require('../..');\nconst ArrayFire = arrayFireJs.ArrayFire;\nconst fastcall = require('fastcall');\nconst ArrayType = fastcall.ArrayType;\nconst FloatArray = new ArrayType('float');\nconst IntArray = new ArrayType('int32');\nconst ref = fastcall.ref;\n\ndescribe('AFArray', function () {\n describe('sync', function () {\n let af = null;\n\n beforeEach(function () {\n af = new ArrayFire();\n af.scope.begin();\n });\n\n afterEach(function () {\n if (af) {\n af.scope.end();\n af.release();\n af = null;\n }\n });\n\n it('could be created by calling af.array()', function () {\n let arr;\n let afArr;\n let dims;\n let buff;\n let refArr;\n\n arr = [1, 2];\n afArr = af.array(arr);\n dims = afArr.dims();\n assert.strictEqual(dims[0], 2);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 2);\n assert.strictEqual(dims.ndims, 1);\n assert.strictEqual(afArr.dims(0), 2);\n assert.strictEqual(afArr.dims(1), 1);\n assert.strictEqual(afArr.dims(2), 1);\n assert.strictEqual(afArr.dims(3), 1);\n\n arr = new Float32Array([1, 2]);\n afArr = af.array(arr);\n dims = afArr.dims();\n assert.strictEqual(dims[0], 2);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 2);\n assert.strictEqual(dims.ndims, 1);\n assert.strictEqual(afArr.dims(0), 2);\n assert.strictEqual(afArr.dims(1), 1);\n assert.strictEqual(afArr.dims(2), 1);\n assert.strictEqual(afArr.dims(3), 1);\n buff = afArr.host();\n assert(Buffer.isBuffer(buff));\n refArr = new FloatArray(buff);\n assert.equal(refArr.length, 2);\n assert.equal(refArr.get(0), 1);\n assert.equal(refArr.get(1), 2);\n refArr.set(0, 0);\n refArr.set(1, 0);\n assert.equal(refArr.get(0), 0);\n assert.equal(refArr.get(1), 0);\n afArr.host(refArr.buffer);\n assert.equal(refArr.length, 2);\n assert.equal(refArr.get(0), 1);\n assert.equal(refArr.get(1), 2);\n\n arr = new FloatArray(2);\n arr.set(0, 1);\n arr.set(1, 2);\n afArr = af.array(af.dim4(1, 2), arr.buffer);\n dims = afArr.dims();\n assert.strictEqual(dims[0], 1);\n assert.strictEqual(dims[1], 2);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 2);\n assert.strictEqual(dims.ndims, 2);\n\n afArr = af.array(af.dim4(3), af.dtype.s32);\n dims = afArr.dims();\n assert.strictEqual(dims[0], 3);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 3);\n assert.strictEqual(dims.ndims, 1);\n buff = afArr.host();\n assert(Buffer.isBuffer(buff));\n refArr = new IntArray(buff);\n assert.equal(refArr.length, 3);\n\n afArr = af.array(af.dim4(1, 3));\n dims = afArr.dims();\n assert.strictEqual(dims[0], 1);\n assert.strictEqual(dims[1], 3);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 3);\n assert.strictEqual(dims.ndims, 2);\n assert.strictEqual(afArr.type(), af.dtype.f32);\n assert.strictEqual(afArr.refType(), ref.types.float);\n\n arr = [1, 2, 3, 4];\n afArr = af.array(af.dim4(1, 1, 4), arr, af.dtype.s32);\n dims = afArr.dims();\n assert.strictEqual(dims[0], 1);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 4);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 4);\n assert.strictEqual(dims.ndims, 3);\n buff = afArr.host();\n assert(Buffer.isBuffer(buff));\n refArr = new IntArray(buff);\n assert.equal(refArr.length, 4);\n assert.equal(refArr.get(0), 1);\n assert.equal(refArr.get(1), 2);\n assert.equal(refArr.get(2), 3);\n assert.equal(refArr.get(3), 4);\n });\n\n it('should support .index() for various parameter types', function () {\n let afArr;\n let afIdx;\n let indexed;\n let arr;\n let dims;\n\n afArr = af.array([1, 2, 3, 4, 5]);\n dims = afArr.dims();\n assert.strictEqual(dims[0], 5);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(afArr.elements(), 5);\n assert.strictEqual(afArr.numdims(), 1);\n\n indexed = afArr.index(af.seq(1));\n assert.deepEqual(indexed.toArray(), [2]);\n\n indexed = afArr.index(2);\n assert.deepEqual(indexed.toArray(), [3]);\n\n indexed = afArr.index(af.seq(1, 3));\n assert.deepEqual(indexed.toArray(), [2, 3, 4]);\n\n afArr = af.array(af.dim4(4, 4),\n [1, 2, 3, 4,\n 5, 6, 7, 8,\n 9, 10, 11, 12,\n 13, 14, 15, 16]);\n\n assert.strictEqual(afArr.elements(), 16);\n assert.strictEqual(afArr.numdims(), 2);\n assert.strictEqual(afArr.dims(0), 4);\n assert.strictEqual(afArr.dims(1), 4);\n\n indexed = afArr.index(af.seq(2, 4));\n assert.deepEqual(indexed.toArray(), [3, 4, 5]);\n\n indexed = afArr.index(af.idx(af.seq(0, 2), af.seq(1, 2)));\n assert.deepEqual(indexed.toArray(), [5, 6, 7, 9, 10, 11]);\n\n indexed = afArr.index(af.idx(af.end, af.seq(2, 3)));\n assert.deepEqual(indexed.toArray(), [12, 16]);\n\n indexed = afArr.index(af.span);\n assert.deepEqual(indexed.toArray(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);\n\n indexed = afArr.index(af.idx(1, af.span));\n assert.deepEqual(indexed.toArray(), [2, 6, 10, 14]);\n\n afArr = af.array([1, 2, 3, 4, 5]);\n afIdx = af.array([1, 0, 2]);\n indexed = afArr.index(afIdx);\n assert.deepEqual(indexed.toArray(), [2, 1, 3]);\n\n afArr = af.array(af.dim4(4, 4),\n [1, 2, 3, 4,\n 5, 6, 7, 8,\n 9, 10, 11, 12,\n 13, 14, 15, 16]);\n\n afIdx = af.array(af.dim4(3, 2),\n [1, 0, 2,\n 5, 10, 2]);\n\n indexed = afArr.index(afIdx);\n assert.deepEqual(indexed.toArray(), [2, 1, 3, 6, 11, 3]);\n\n // Col, Row\n afArr = af.array(af.dim4(3, 3), [0, 1, 2, 3, 4, 5, 6, 7, 8]);\n\n indexed = afArr.index(af.row(0));\n assert.deepEqual(indexed.toArray(), [0, 3, 6]);\n\n indexed = afArr.index(af.row(2));\n assert.deepEqual(indexed.toArray(), [2, 5, 8]);\n\n indexed = afArr.index(af.rows(0, 1));\n assert.deepEqual(indexed.toArray(), [0, 1, 3, 4, 6, 7]);\n\n indexed = afArr.index(af.col(0));\n assert.deepEqual(indexed.toArray(), [0, 1, 2]);\n\n indexed = afArr.index(af.col(2));\n assert.deepEqual(indexed.toArray(), [6, 7, 8]);\n\n indexed = afArr.index(af.cols(1, 2));\n assert.deepEqual(indexed.toArray(), [3, 4, 5, 6, 7, 8]);\n });\n\n it.only('should support .assign() for various parameter types', function () {\n let afArr;\n\n afArr = af.array([1, 2, 3, 4]);\n afArr.assign(af.span, 5);\n assert.deepEqual(afArr.toArray(), [5, 5, 5, 5]);\n\n afArr = af.array([1, 2, 3, 4]);\n afArr.assign(af.seq(1, 2), 5.5);\n assert.deepEqual(afArr.toArray(), [1, 5.5, 5.5, 4]);\n /*\n\n afArr = array(af, [1,2,3,4])\n afArr[2:3] = 5.5f0\n @test host(afArr) == [1,5,5,4]\n\n afArr = array(af, [1,2,3,4])\n afArr[1:2] = array(af, [10.1f0, 11.1f0])\n @test host(afArr) == [10,11,3,4]\n\n @test_throws AFErrorException afArr[1:2] = array(af, [10.1f0, 11.1f0, 12.2f0])\n\n afArr = array(af, [[1,2,3,4] [5,6,7,8] [9,10,11,12] [13, 14, 15, 16]])\n afArr[:, 3:4] = array(af, [[1,2,3,4] [5,6,7,8]])\n @test host(afArr) == [[1,2,3,4] [5,6,7,8] [1,2,3,4] [5,6,7,8]]\n\n afArr[3:4, :] = 1.1f0\n @test host(afArr) == [[1,2,1,1] [5,6,1,1] [1,2,1,1] [5,6,1,1]]\n\n afArr = array(af, [[1,2,3,4] [5,6,7,8] [9,10,11,12] [13, 14, 15, 16]])\n afArr[array(af, [10, 11, 12, 13, 14, 15])] = array(af, [55, 66, 77, 88, 99, 100])\n @test host(afArr) == [[1,2,3,4] [5,6,7,8] [9,10,55,66] [77, 88, 99, 100]]\n afArr[array(af, [[1, 2, 3] [4, 5, 6]])] = array(af, [55, 66, 77, 88, 99, 100])\n @test host(afArr) == [[1,55,66,77] [88,99,100,8] [9,10,55,66] [77, 88, 99, 100]]\n\n @test_throws AFErrorException afArr[array(af, [[1, 2, 3] [4, 5, 6]])] = array(af, [[55, 66, 77] [88, 99, 100]])\n\n afArr = array(af, [[1,2,3,4] [5,6,7,8] [9,10,11,12] [13, 14, 15, 16]])\n afArr[array(af, [[1, 2, 3] [4, 5, 6]])] = -1\n @test host(afArr) == [[1,-1,-1,-1] [-1,-1,-1,8] [9,10,11,12] [13, 14, 15, 16]]\n */\n });\n\n it('should support copy-on-write', function () {\n });\n });\n\n describe('async', function () {\n let af = null;\n\n beforeEach(function () {\n af = new ArrayFire({ async: true });\n af.scope.begin();\n });\n\n afterEach(async(function* () {\n if (af) {\n yield af.scope.end();\n af.release();\n af = null;\n }\n }));\n\n it('could be created by calling af.array()', async(function* () {\n let arr;\n let afArr;\n let dims;\n let buff;\n let refArr;\n\n arr = [1, 2];\n afArr = yield af.array(arr);\n dims = yield afArr.dims();\n assert.strictEqual(dims[0], 2);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 2);\n assert.strictEqual(dims.ndims, 1);\n assert.strictEqual(yield afArr.dims(0), 2);\n assert.strictEqual(yield afArr.dims(1), 1);\n assert.strictEqual(yield afArr.dims(2), 1);\n assert.strictEqual(yield afArr.dims(3), 1);\n\n arr = new Float32Array([1, 2]);\n afArr = yield af.array(arr);\n dims = yield afArr.dims();\n assert.strictEqual(dims[0], 2);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 2);\n assert.strictEqual(dims.ndims, 1);\n assert.strictEqual(yield afArr.dims(0), 2);\n assert.strictEqual(yield afArr.dims(1), 1);\n assert.strictEqual(yield afArr.dims(2), 1);\n assert.strictEqual(yield afArr.dims(3), 1);\n buff = yield afArr.host();\n assert(Buffer.isBuffer(buff));\n refArr = new FloatArray(buff);\n assert.equal(refArr.length, 2);\n assert.equal(refArr.get(0), 1);\n assert.equal(refArr.get(1), 2);\n refArr.set(0, 0);\n refArr.set(1, 0);\n assert.equal(refArr.get(0), 0);\n assert.equal(refArr.get(1), 0);\n yield afArr.host(refArr.buffer);\n assert.equal(refArr.length, 2);\n assert.equal(refArr.get(0), 1);\n assert.equal(refArr.get(1), 2);\n\n arr = new FloatArray(2);\n arr.set(0, 1);\n arr.set(1, 2);\n afArr = yield af.array(af.dim4(1, 2), arr.buffer);\n dims = yield afArr.dims();\n assert.strictEqual(dims[0], 1);\n assert.strictEqual(dims[1], 2);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 2);\n assert.strictEqual(dims.ndims, 2);\n\n afArr = yield af.array(af.dim4(3), af.dtype.s32);\n dims = yield afArr.dims();\n assert.strictEqual(dims[0], 3);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 3);\n assert.strictEqual(dims.ndims, 1);\n buff = yield afArr.host();\n assert(Buffer.isBuffer(buff));\n refArr = new IntArray(buff);\n assert.equal(refArr.length, 3);\n\n afArr = yield af.array(af.dim4(1, 3));\n dims = yield afArr.dims();\n assert.strictEqual(dims[0], 1);\n assert.strictEqual(dims[1], 3);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 3);\n assert.strictEqual(dims.ndims, 2);\n assert.strictEqual(yield afArr.type(), af.dtype.f32);\n assert.strictEqual(yield afArr.refType(), ref.types.float);\n\n arr = [1, 2, 3, 4];\n afArr = yield af.array(af.dim4(1, 1, 4), arr, af.dtype.s32);\n dims = yield afArr.dims();\n assert.strictEqual(dims[0], 1);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 4);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(dims.elements, 4);\n assert.strictEqual(dims.ndims, 3);\n buff = yield afArr.host();\n assert(Buffer.isBuffer(buff));\n refArr = new IntArray(buff);\n assert.equal(refArr.length, 4);\n assert.equal(refArr.get(0), 1);\n assert.equal(refArr.get(1), 2);\n assert.equal(refArr.get(2), 3);\n assert.equal(refArr.get(3), 4);\n }));\n\n it('should support .index() for various parameter types', async(function* () {\n let afArr;\n let afIdx;\n let indexed;\n let arr;\n let dims;\n\n afArr = yield af.array([1, 2, 3, 4, 5]);\n dims = yield afArr.dims();\n assert.strictEqual(dims[0], 5);\n assert.strictEqual(dims[1], 1);\n assert.strictEqual(dims[2], 1);\n assert.strictEqual(dims[3], 1);\n assert.strictEqual(yield afArr.elements(), 5);\n assert.strictEqual(yield afArr.numdims(), 1);\n\n indexed = yield afArr.index(af.seq(1));\n assert.deepEqual(yield indexed.toArray(), [2]);\n\n indexed = yield afArr.index(2);\n assert.deepEqual(yield indexed.toArray(), [3]);\n\n indexed = yield afArr.index(af.seq(1, 3));\n assert.deepEqual(yield indexed.toArray(), [2, 3, 4]);\n\n afArr = yield af.array(af.dim4(4, 4),\n [1, 2, 3, 4,\n 5, 6, 7, 8,\n 9, 10, 11, 12,\n 13, 14, 15, 16]);\n\n assert.strictEqual(yield afArr.elements(), 16);\n assert.strictEqual(yield afArr.numdims(), 2);\n assert.strictEqual(yield afArr.dims(0), 4);\n assert.strictEqual(yield afArr.dims(1), 4);\n\n indexed = yield afArr.index(af.seq(2, 4));\n assert.deepEqual(yield indexed.toArray(), [3, 4, 5]);\n\n indexed = yield afArr.index(af.idx(af.seq(0, 2), af.seq(1, 2)));\n assert.deepEqual(yield indexed.toArray(), [5, 6, 7, 9, 10, 11]);\n\n indexed = yield afArr.index(af.idx(af.end, af.seq(2, 3)));\n assert.deepEqual(yield indexed.toArray(), [12, 16]);\n\n indexed = yield afArr.index(af.span);\n assert.deepEqual(yield indexed.toArray(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);\n\n indexed = yield afArr.index(af.idx(1, af.span));\n assert.deepEqual(yield indexed.toArray(), [2, 6, 10, 14]);\n\n afArr = yield af.array([1, 2, 3, 4, 5]);\n afIdx = yield af.array([1, 0, 2]);\n indexed = yield afArr.index(afIdx);\n assert.deepEqual(yield indexed.toArray(), [2, 1, 3]);\n\n afArr = yield af.array(af.dim4(4, 4),\n [1, 2, 3, 4,\n 5, 6, 7, 8,\n 9, 10, 11, 12,\n 13, 14, 15, 16]);\n\n afIdx = yield af.array(af.dim4(3, 2),\n [1, 0, 2,\n 5, 10, 2]);\n\n indexed = yield afArr.index(afIdx);\n assert.deepEqual(yield indexed.toArray(), [2, 1, 3, 6, 11, 3]);\n\n // Col, Row\n afArr = yield af.array(af.dim4(3, 3), [0, 1, 2, 3, 4, 5, 6, 7, 8]);\n\n indexed = yield afArr.index(af.row(0));\n assert.deepEqual(yield indexed.toArray(), [0, 3, 6]);\n\n indexed = yield afArr.index(af.row(2));\n assert.deepEqual(yield indexed.toArray(), [2, 5, 8]);\n\n indexed = yield afArr.index(af.rows(0, 1));\n assert.deepEqual(yield indexed.toArray(), [0, 1, 3, 4, 6, 7]);\n\n indexed = yield afArr.index(af.col(0));\n assert.deepEqual(yield indexed.toArray(), [0, 1, 2]);\n\n indexed = yield afArr.index(af.col(2));\n assert.deepEqual(yield indexed.toArray(), [6, 7, 8]);\n\n indexed = yield afArr.index(af.cols(1, 2));\n assert.deepEqual(yield indexed.toArray(), [3, 4, 5, 6, 7, 8]);\n }));\n });\n});"]} \ No newline at end of file diff --git a/test/es5/device.js b/test/es5/device.js new file mode 100644 index 0000000..f0ba8de --- /dev/null +++ b/test/es5/device.js @@ -0,0 +1,216 @@ +'use strict'; + +var Promise = require('bluebird'); +var assert = require('assert'); +var _ = require('lodash'); +var async = Promise.coroutine; +var arrayFireJs = require('../..'); +var ArrayFire = arrayFireJs.ArrayFire; + +describe('device functions', function () { + var af = null; + + afterEach(function () { + if (af) { + af.release(); + af = null; + } + }); + + it('should give result for deviceInfo (sync)', function () { + af = new ArrayFire(); + assert(_.isFunction(af.deviceInfo)); + var name = {}; + var platform = {}; + var toolkit = {}; + var compute = {}; + af.deviceInfo(name, platform, toolkit, compute); + assert(_.isString(name.value) && name.value.length); + assert(_.isString(platform.value) && platform.value.length); + assert(_.isString(toolkit.value) && toolkit.value.length); + assert(_.isString(compute.value) && compute.value.length); + }); + + it('should give result for deviceInfo (async)', async(regeneratorRuntime.mark(function _callee() { + var name, platform, toolkit, compute; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + af = new ArrayFire({ async: true }); + assert(_.isFunction(af.deviceInfo)); + name = {}; + platform = {}; + toolkit = {}; + compute = {}; + _context.next = 8; + return af.deviceInfo(name, platform, toolkit, compute); + + case 8: + assert(_.isString(name.value) && name.value.length); + assert(_.isString(platform.value) && platform.value.length); + assert(_.isString(toolkit.value) && toolkit.value.length); + assert(_.isString(compute.value) && compute.value.length); + + case 12: + case 'end': + return _context.stop(); + } + } + }, _callee, this); + }))); + + it('should give result for infoString (sync)', function () { + af = new ArrayFire(); + assert(_.isFunction(af.infoString)); + var info = af.infoString(); + assert(_.isString(info) && info.length); + var vInfo = af.infoString(true); + assert(_.isString(vInfo) && vInfo.length); + assert(vInfo.length >= info.length); + }); + + it('should give result for infoString (async)', async(regeneratorRuntime.mark(function _callee2() { + var info, vInfo; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + af = new ArrayFire({ async: true }); + assert(_.isFunction(af.infoString)); + _context2.next = 4; + return af.infoString(); + + case 4: + info = _context2.sent; + + assert(_.isString(info) && info.length); + _context2.next = 8; + return af.infoString(true); + + case 8: + vInfo = _context2.sent; + + assert(_.isString(vInfo) && vInfo.length); + assert(vInfo.length >= info.length); + + case 11: + case 'end': + return _context2.stop(); + } + } + }, _callee2, this); + }))); + + it('should report device count (sync)', function () { + af = new ArrayFire(); + assert(_.isFunction(af.getDeviceCount)); + var count = af.getDeviceCount(); + assert(count > 0 && count < 10); + }); + + it('should report device count (async)', async(regeneratorRuntime.mark(function _callee3() { + var count; + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + af = new ArrayFire({ async: true }); + assert(_.isFunction(af.getDeviceCount)); + _context3.next = 4; + return af.getDeviceCount(); + + case 4: + count = _context3.sent; + + assert(count > 0 && count < 10); + + case 6: + case 'end': + return _context3.stop(); + } + } + }, _callee3, this); + }))); + + it('should set and get device ids (sync)', function () { + af = new ArrayFire(); + var count = af.getDeviceCount(); + assert(count > 0 && count < 10); + assert(_.isFunction(af.getDevice)); + assert(_.isFunction(af.setDevice)); + assert(_.isFunction(af.sync)); + for (var id = count - 1; id >= 0; id--) { + af.setDevice(id); + assert.strictEqual(af.getDevice(), id); + af.sync(id); + af.sync(); // -1 = current + } + }); + + it('should set and get device ids (async)', async(regeneratorRuntime.mark(function _callee4() { + var count, id; + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + af = new ArrayFire({ async: true }); + _context4.next = 3; + return af.getDeviceCount(); + + case 3: + count = _context4.sent; + + assert(count > 0 && count < 10); + assert(_.isFunction(af.getDevice)); + assert(_.isFunction(af.setDevice)); + assert(_.isFunction(af.sync)); + id = count - 1; + + case 9: + if (!(id >= 0)) { + _context4.next = 25; + break; + } + + _context4.next = 12; + return af.setDevice(id); + + case 12: + _context4.t0 = assert; + _context4.next = 15; + return af.getDevice(); + + case 15: + _context4.t1 = _context4.sent; + _context4.t2 = id; + + _context4.t0.strictEqual.call(_context4.t0, _context4.t1, _context4.t2); + + _context4.next = 20; + return af.sync(id); + + case 20: + _context4.next = 22; + return af.sync(); + + case 22: + id--; + _context4.next = 9; + break; + + case 25: + case 'end': + return _context4.stop(); + } + } + }, _callee4, this); + }))); + + it('should set seed', function () { + af = new ArrayFire(); + assert(_.isFunction(af.setSeed)); + af.setSeed(42); + }); +}); +//# sourceMappingURL=device.js.map \ No newline at end of file diff --git a/test/es5/device.js.map b/test/es5/device.js.map new file mode 100644 index 0000000..b99b92c --- /dev/null +++ b/test/es5/device.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/device.js"],"names":["Promise","require","assert","_","async","coroutine","arrayFireJs","ArrayFire","describe","af","afterEach","release","it","isFunction","deviceInfo","name","platform","toolkit","compute","isString","value","length","infoString","info","vInfo","getDeviceCount","count","getDevice","setDevice","sync","id","strictEqual","setSeed"],"mappings":"AAAA;;AACA,IAAMA,UAAUC,QAAQ,UAAR,CAAhB;AACA,IAAMC,SAASD,QAAQ,QAAR,CAAf;AACA,IAAME,IAAIF,QAAQ,QAAR,CAAV;AACA,IAAMG,QAAQJ,QAAQK,SAAtB;AACA,IAAMC,cAAcL,QAAQ,OAAR,CAApB;AACA,IAAMM,YAAYD,YAAYC,SAA9B;;AAEAC,SAAS,kBAAT,EAA6B,YAAY;AACrC,QAAIC,KAAK,IAAT;;AAEAC,cAAU,YAAY;AAClB,YAAID,EAAJ,EAAQ;AACJA,eAAGE,OAAH;AACAF,iBAAK,IAAL;AACH;AACJ,KALD;;AAOAG,OAAG,0CAAH,EAA+C,YAAY;AACvDH,aAAK,IAAIF,SAAJ,EAAL;AACAL,eAAOC,EAAEU,UAAF,CAAaJ,GAAGK,UAAhB,CAAP;AACA,YAAMC,OAAO,EAAb;AACA,YAAMC,WAAW,EAAjB;AACA,YAAMC,UAAU,EAAhB;AACA,YAAMC,UAAU,EAAhB;AACAT,WAAGK,UAAH,CAAcC,IAAd,EAAoBC,QAApB,EAA8BC,OAA9B,EAAuCC,OAAvC;AACAhB,eAAOC,EAAEgB,QAAF,CAAWJ,KAAKK,KAAhB,KAA0BL,KAAKK,KAAL,CAAWC,MAA5C;AACAnB,eAAOC,EAAEgB,QAAF,CAAWH,SAASI,KAApB,KAA8BJ,SAASI,KAAT,CAAeC,MAApD;AACAnB,eAAOC,EAAEgB,QAAF,CAAWF,QAAQG,KAAnB,KAA6BH,QAAQG,KAAR,CAAcC,MAAlD;AACAnB,eAAOC,EAAEgB,QAAF,CAAWD,QAAQE,KAAnB,KAA6BF,QAAQE,KAAR,CAAcC,MAAlD;AACH,KAZD;;AAcAT,OAAG,2CAAH,EAAgDR,8BAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAClDK,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AGoB,IAAH,CAAQC,EAAR,CAVoC;;AAAA;AAAA;AAAA,+BAWpCrB,GAAGoB,IAAH,EAXoC;;AAAA;AAOZC,4BAPY;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAN,EAA5C;;AAeAlB,OAAG,iBAAH,EAAsB,YAAY;AAC9BH,aAAK,IAAIF,SAAJ,EAAL;AACAL,eAAOC,EAAEU,UAAF,CAAaJ,GAAGuB,OAAhB,CAAP;AACAvB,WAAGuB,OAAH,CAAW,EAAX;AACH,KAJD;AAKH,CA3GD","file":"device.js","sourcesContent":["'use strict';\nconst Promise = require('bluebird');\nconst assert = require('assert');\nconst _ = require('lodash');\nconst async = Promise.coroutine;\nconst arrayFireJs = require('../..');\nconst ArrayFire = arrayFireJs.ArrayFire;\n\ndescribe('device functions', function () {\n let af = null;\n\n afterEach(function () {\n if (af) {\n af.release();\n af = null;\n }\n });\n\n it('should give result for deviceInfo (sync)', function () {\n af = new ArrayFire();\n assert(_.isFunction(af.deviceInfo));\n const name = {};\n const platform = {};\n const toolkit = {};\n const compute = {};\n af.deviceInfo(name, platform, toolkit, compute);\n assert(_.isString(name.value) && name.value.length);\n assert(_.isString(platform.value) && platform.value.length);\n assert(_.isString(toolkit.value) && toolkit.value.length);\n assert(_.isString(compute.value) && compute.value.length);\n });\n\n it('should give result for deviceInfo (async)', async(function* () {\n af = new ArrayFire({ async: true });\n assert(_.isFunction(af.deviceInfo));\n const name = {};\n const platform = {};\n const toolkit = {};\n const compute = {};\n yield af.deviceInfo(name, platform, toolkit, compute);\n assert(_.isString(name.value) && name.value.length);\n assert(_.isString(platform.value) && platform.value.length);\n assert(_.isString(toolkit.value) && toolkit.value.length);\n assert(_.isString(compute.value) && compute.value.length);\n }));\n\n it('should give result for infoString (sync)', function () {\n af = new ArrayFire();\n assert(_.isFunction(af.infoString));\n const info = af.infoString();\n assert(_.isString(info) && info.length);\n const vInfo = af.infoString(true);\n assert(_.isString(vInfo) && vInfo.length);\n assert(vInfo.length >= info.length);\n });\n\n it('should give result for infoString (async)', async(function* () {\n af = new ArrayFire({ async: true });\n assert(_.isFunction(af.infoString));\n const info = yield af.infoString();\n assert(_.isString(info) && info.length);\n const vInfo = yield af.infoString(true);\n assert(_.isString(vInfo) && vInfo.length);\n assert(vInfo.length >= info.length);\n }));\n\n it('should report device count (sync)', function () {\n af = new ArrayFire();\n assert(_.isFunction(af.getDeviceCount));\n const count = af.getDeviceCount();\n assert(count > 0 && count < 10);\n });\n\n it('should report device count (async)', async(function* () {\n af = new ArrayFire({ async: true });\n assert(_.isFunction(af.getDeviceCount));\n const count = yield af.getDeviceCount();\n assert(count > 0 && count < 10);\n }));\n\n it('should set and get device ids (sync)', function () {\n af = new ArrayFire();\n const count = af.getDeviceCount();\n assert(count > 0 && count < 10);\n assert(_.isFunction(af.getDevice));\n assert(_.isFunction(af.setDevice));\n assert(_.isFunction(af.sync));\n for (let id = count - 1; id >= 0; id--) {\n af.setDevice(id);\n assert.strictEqual(af.getDevice(), id);\n af.sync(id);\n af.sync(); // -1 = current\n }\n });\n\n it('should set and get device ids (async)', async(function* () {\n af = new ArrayFire({ async: true });\n const count = yield af.getDeviceCount();\n assert(count > 0 && count < 10);\n assert(_.isFunction(af.getDevice));\n assert(_.isFunction(af.setDevice));\n assert(_.isFunction(af.sync));\n for (let id = count - 1; id >= 0; id--) {\n yield af.setDevice(id);\n assert.strictEqual(yield af.getDevice(), id);\n yield af.sync(id);\n yield af.sync(); // -1 = current\n }\n }));\n\n it('should set seed', function () {\n af = new ArrayFire();\n assert(_.isFunction(af.setSeed));\n af.setSeed(42);\n });\n});"]} \ No newline at end of file diff --git a/test/es5/index.js b/test/es5/index.js new file mode 100644 index 0000000..5669040 --- /dev/null +++ b/test/es5/index.js @@ -0,0 +1,6 @@ +'use strict'; + +require('./device'); +require('./unified'); +require('./array'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/test/es5/index.js.map b/test/es5/index.js.map new file mode 100644 index 0000000..b79cca3 --- /dev/null +++ b/test/es5/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/index.js"],"names":["require"],"mappings":"AAAA;;AAEAA,QAAQ,UAAR;AACAA,QAAQ,WAAR;AACAA,QAAQ,SAAR","file":"index.js","sourcesContent":["'use strict';\n\nrequire('./device');\nrequire('./unified');\nrequire('./array');"]} \ No newline at end of file diff --git a/test/es5/unified.js b/test/es5/unified.js new file mode 100644 index 0000000..dd25b25 --- /dev/null +++ b/test/es5/unified.js @@ -0,0 +1,64 @@ +'use strict'; + +var Promise = require('bluebird'); +var assert = require('assert'); +var _ = require('lodash'); +var async = Promise.coroutine; +var arrayFireJs = require('../..'); +var ArrayFire = arrayFireJs.ArrayFire; + +describe('unified backend functions', function () { + var af = null; + + beforeEach(function () { + af = new ArrayFire(); + }); + + afterEach(function () { + if (af) { + af.release(); + af = null; + } + }); + + it('should give available backends', function () { + assert(_.isObject(af.backend)); + assert(_.isFunction(af.getAvailableBackends)); + + var cpu = af.getAvailableBackends() & af.backend.CPU; + var cuda = af.getAvailableBackends() & af.backend.CUDA; + var ocl = af.getAvailableBackends() & af.backend.OPENCL; + + assert(cpu && (cuda || ocl)); + assert.equal(af.getBackendCount(), (cpu && 1) + (cuda && 1) + (ocl && 1)); + }); + + it('should switch to other backends', function () { + var cuda = af.getAvailableBackends() & af.backend.CUDA; + var ocl = af.getAvailableBackends() & af.backend.OPENCL; + + cuda && tryBackend(af.backend.CUDA); + ocl && tryBackend(af.backend.OPENCL); + tryBackend(af.backend.CPU); + + function tryBackend(backend) { + try { + af.setBackend(backend); + assert.strictEqual(af.getActiveBackend(), backend); + } catch (e) { + if (e.code === 501) { + return; + } + if (e.code) { + throw Error('Error with backend ' + af.enumToString(af.backend, backend) + ', code: ' + e.code + ', message: ' + e.message); + } + throw e; + } + } + }); + + it.skip('should give back array\'s backend and device information', function () { + assert(false, 'TODO'); + }); +}); +//# sourceMappingURL=unified.js.map \ No newline at end of file diff --git a/test/es5/unified.js.map b/test/es5/unified.js.map new file mode 100644 index 0000000..5f404ad --- /dev/null +++ b/test/es5/unified.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../es6/unified.js"],"names":["Promise","require","assert","_","async","coroutine","arrayFireJs","ArrayFire","describe","af","beforeEach","afterEach","release","it","isObject","backend","isFunction","getAvailableBackends","cpu","CPU","cuda","CUDA","ocl","OPENCL","equal","getBackendCount","tryBackend","setBackend","strictEqual","getActiveBackend","e","code","Error","enumToString","message","skip"],"mappings":"AAAA;;AACA,IAAMA,UAAUC,QAAQ,UAAR,CAAhB;AACA,IAAMC,SAASD,QAAQ,QAAR,CAAf;AACA,IAAME,IAAIF,QAAQ,QAAR,CAAV;AACA,IAAMG,QAAQJ,QAAQK,SAAtB;AACA,IAAMC,cAAcL,QAAQ,OAAR,CAApB;AACA,IAAMM,YAAYD,YAAYC,SAA9B;;AAEAC,SAAS,2BAAT,EAAsC,YAAY;AAC9C,QAAIC,KAAK,IAAT;;AAEAC,eAAW,YAAY;AACnBD,aAAK,IAAIF,SAAJ,EAAL;AACH,KAFD;;AAIAI,cAAU,YAAY;AAClB,YAAIF,EAAJ,EAAQ;AACJA,eAAGG,OAAH;AACAH,iBAAK,IAAL;AACH;AACJ,KALD;;AAOAI,OAAG,gCAAH,EAAqC,YAAY;AAC7CX,eAAOC,EAAEW,QAAF,CAAWL,GAAGM,OAAd,CAAP;AACAb,eAAOC,EAAEa,UAAF,CAAaP,GAAGQ,oBAAhB,CAAP;;AAEA,YAAMC,MAAMT,GAAGQ,oBAAH,KAA4BR,GAAGM,OAAH,CAAWI,GAAnD;AACA,YAAMC,OAAOX,GAAGQ,oBAAH,KAA4BR,GAAGM,OAAH,CAAWM,IAApD;AACA,YAAMC,MAAMb,GAAGQ,oBAAH,KAA4BR,GAAGM,OAAH,CAAWQ,MAAnD;;AAEArB,eAAOgB,QAAQE,QAAQE,GAAhB,CAAP;AACApB,eAAOsB,KAAP,CAAaf,GAAGgB,eAAH,EAAb,EAAmC,CAACP,OAAO,CAAR,KAAcE,QAAQ,CAAtB,KAA4BE,OAAO,CAAnC,CAAnC;AACH,KAVD;;AAYAT,OAAG,iCAAH,EAAsC,YAAY;AAC9C,YAAMO,OAAOX,GAAGQ,oBAAH,KAA4BR,GAAGM,OAAH,CAAWM,IAApD;AACA,YAAMC,MAAMb,GAAGQ,oBAAH,KAA4BR,GAAGM,OAAH,CAAWQ,MAAnD;;AAEAH,gBAAQM,WAAWjB,GAAGM,OAAH,CAAWM,IAAtB,CAAR;AACAC,eAAOI,WAAWjB,GAAGM,OAAH,CAAWQ,MAAtB,CAAP;AACAG,mBAAWjB,GAAGM,OAAH,CAAWI,GAAtB;;AAEA,iBAASO,UAAT,CAAoBX,OAApB,EAA6B;AACzB,gBAAI;AACAN,mBAAGkB,UAAH,CAAcZ,OAAd;AACAb,uBAAO0B,WAAP,CAAmBnB,GAAGoB,gBAAH,EAAnB,EAA0Cd,OAA1C;AACH,aAHD,CAIA,OAAOe,CAAP,EAAU;AACN,oBAAIA,EAAEC,IAAF,KAAW,GAAf,EAAoB;AAChB;AACH;AACD,oBAAID,EAAEC,IAAN,EAAY;AACR,0BAAMC,8BAA6BvB,GAAGwB,YAAH,CAAgBxB,GAAGM,OAAnB,EAA4BA,OAA5B,CAA7B,gBAA8Ee,EAAEC,IAAhF,mBAAoGD,EAAEI,OAAtG,CAAN;AACH;AACD,sBAAMJ,CAAN;AACH;AACJ;AACJ,KAvBD;;AAyBAjB,OAAGsB,IAAH,6DAAmE,YAAY;AAC3EjC,eAAO,KAAP,EAAc,MAAd;AACH,KAFD;AAGH,CAtDD","file":"unified.js","sourcesContent":["'use strict';\nconst Promise = require('bluebird');\nconst assert = require('assert');\nconst _ = require('lodash');\nconst async = Promise.coroutine;\nconst arrayFireJs = require('../..');\nconst ArrayFire = arrayFireJs.ArrayFire;\n\ndescribe('unified backend functions', function () {\n let af = null;\n\n beforeEach(function () {\n af = new ArrayFire();\n });\n\n afterEach(function () {\n if (af) {\n af.release();\n af = null;\n }\n });\n\n it('should give available backends', function () {\n assert(_.isObject(af.backend));\n assert(_.isFunction(af.getAvailableBackends));\n\n const cpu = af.getAvailableBackends() & af.backend.CPU;\n const cuda = af.getAvailableBackends() & af.backend.CUDA;\n const ocl = af.getAvailableBackends() & af.backend.OPENCL;\n\n assert(cpu && (cuda || ocl));\n assert.equal(af.getBackendCount(), (cpu && 1) + (cuda && 1) + (ocl && 1));\n });\n\n it('should switch to other backends', function () {\n const cuda = af.getAvailableBackends() & af.backend.CUDA;\n const ocl = af.getAvailableBackends() & af.backend.OPENCL;\n\n cuda && tryBackend(af.backend.CUDA);\n ocl && tryBackend(af.backend.OPENCL);\n tryBackend(af.backend.CPU);\n\n function tryBackend(backend) {\n try {\n af.setBackend(backend);\n assert.strictEqual(af.getActiveBackend(), backend);\n }\n catch (e) {\n if (e.code === 501) {\n return;\n }\n if (e.code) {\n throw Error(`Error with backend ${ af.enumToString(af.backend, backend) }, code: ${ e.code }, message: ${ e.message }`);\n }\n throw e;\n }\n }\n });\n\n it.skip(`should give back array's backend and device information`, function () {\n assert(false, 'TODO');\n });\n});"]} \ No newline at end of file diff --git a/test/es6/array.js b/test/es6/array.js new file mode 100644 index 0000000..172c817 --- /dev/null +++ b/test/es6/array.js @@ -0,0 +1,495 @@ +'use strict'; +const Promise = require('bluebird'); +const assert = require('assert'); +const _ = require('lodash'); +const async = Promise.coroutine; +const arrayFireJs = require('../..'); +const ArrayFire = arrayFireJs.ArrayFire; +const AFError = arrayFireJs.AFError; +const fastcall = require('fastcall'); +const ArrayType = fastcall.ArrayType; +const FloatArray = new ArrayType('float'); +const IntArray = new ArrayType('int32'); +const ref = fastcall.ref; + +describe('AFArray', function () { + describe('sync', function () { + let af = null; + + beforeEach(function () { + af = new ArrayFire(); + af.scope.begin(); + }); + + afterEach(function () { + if (af) { + af.scope.end(); + af.release(); + af = null; + } + }); + + it('could be created by calling af.array()', function () { + let arr; + let afArr; + let dims; + let buff; + let refArr; + + arr = [1, 2]; + afArr = af.array(arr); + dims = afArr.dims(); + assert.strictEqual(dims[0], 2); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 1); + assert.strictEqual(afArr.dims(0), 2); + assert.strictEqual(afArr.dims(1), 1); + assert.strictEqual(afArr.dims(2), 1); + assert.strictEqual(afArr.dims(3), 1); + + arr = new Float32Array([1, 2]); + afArr = af.array(arr); + dims = afArr.dims(); + assert.strictEqual(dims[0], 2); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 1); + assert.strictEqual(afArr.dims(0), 2); + assert.strictEqual(afArr.dims(1), 1); + assert.strictEqual(afArr.dims(2), 1); + assert.strictEqual(afArr.dims(3), 1); + buff = afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new FloatArray(buff); + assert.equal(refArr.length, 2); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + refArr.set(0, 0); + refArr.set(1, 0); + assert.equal(refArr.get(0), 0); + assert.equal(refArr.get(1), 0); + afArr.host(refArr.buffer); + assert.equal(refArr.length, 2); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + + arr = new FloatArray(2); + arr.set(0, 1); + arr.set(1, 2); + afArr = af.array(af.dim4(1, 2), arr.buffer); + dims = afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 2); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 2); + + afArr = af.array(af.dim4(3), af.dtype.s32); + dims = afArr.dims(); + assert.strictEqual(dims[0], 3); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 3); + assert.strictEqual(dims.ndims, 1); + buff = afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new IntArray(buff); + assert.equal(refArr.length, 3); + + afArr = af.array(af.dim4(1, 3)); + dims = afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 3); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 3); + assert.strictEqual(dims.ndims, 2); + assert.strictEqual(afArr.type(), af.dtype.f32); + assert.strictEqual(afArr.refType(), ref.types.float); + + arr = [1, 2, 3, 4]; + afArr = af.array(af.dim4(1, 1, 4), arr, af.dtype.s32); + dims = afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 4); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 4); + assert.strictEqual(dims.ndims, 3); + buff = afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new IntArray(buff); + assert.equal(refArr.length, 4); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + assert.equal(refArr.get(2), 3); + assert.equal(refArr.get(3), 4); + }); + + it('should support .index() for various parameter types', function () { + let afArr; + let afIdx; + let indexed; + let arr; + let dims; + + afArr = af.array([1, 2, 3, 4, 5]); + dims = afArr.dims(); + assert.strictEqual(dims[0], 5); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(afArr.elements(), 5); + assert.strictEqual(afArr.numdims(), 1); + + indexed = afArr.index(af.seq(1)); + assert.deepEqual(indexed.toArray(), [2]); + + indexed = afArr.index(2); + assert.deepEqual(indexed.toArray(), [3]); + + indexed = afArr.index(af.seq(1, 3)); + assert.deepEqual(indexed.toArray(), [2, 3, 4]); + + afArr = af.array(af.dim4(4, 4), + [1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16]); + + assert.strictEqual(afArr.elements(), 16); + assert.strictEqual(afArr.numdims(), 2); + assert.strictEqual(afArr.dims(0), 4); + assert.strictEqual(afArr.dims(1), 4); + + indexed = afArr.index(af.seq(2, 4)); + assert.deepEqual(indexed.toArray(), [3, 4, 5]); + + indexed = afArr.index(af.idx(af.seq(0, 2), af.seq(1, 2))); + assert.deepEqual(indexed.toArray(), [5, 6, 7, 9, 10, 11]); + + indexed = afArr.index(af.idx(af.end, af.seq(2, 3))); + assert.deepEqual(indexed.toArray(), [12, 16]); + + indexed = afArr.index(af.span); + assert.deepEqual(indexed.toArray(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + indexed = afArr.index(af.idx(1, af.span)); + assert.deepEqual(indexed.toArray(), [2, 6, 10, 14]); + + afArr = af.array([1, 2, 3, 4, 5]); + afIdx = af.array([1, 0, 2]); + indexed = afArr.index(afIdx); + assert.deepEqual(indexed.toArray(), [2, 1, 3]); + + afArr = af.array(af.dim4(4, 4), + [1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16]); + + afIdx = af.array(af.dim4(3, 2), + [1, 0, 2, + 5, 10, 2]); + + indexed = afArr.index(afIdx); + assert.deepEqual(indexed.toArray(), [2, 1, 3, 6, 11, 3]); + + // Col, Row + afArr = af.array(af.dim4(3, 3), [0, 1, 2, 3, 4, 5, 6, 7, 8]); + + indexed = afArr.index(af.row(0)); + assert.deepEqual(indexed.toArray(), [0, 3, 6]); + + indexed = afArr.index(af.row(2)); + assert.deepEqual(indexed.toArray(), [2, 5, 8]); + + indexed = afArr.index(af.rows(0, 1)); + assert.deepEqual(indexed.toArray(), [0, 1, 3, 4, 6, 7]); + + indexed = afArr.index(af.col(0)); + assert.deepEqual(indexed.toArray(), [0, 1, 2]); + + indexed = afArr.index(af.col(2)); + assert.deepEqual(indexed.toArray(), [6, 7, 8]); + + indexed = afArr.index(af.cols(1, 2)); + assert.deepEqual(indexed.toArray(), [3, 4, 5, 6, 7, 8]); + }); + + it.only('should support .assign() for various parameter types', function () { + let afArr; + + afArr = af.array([1, 2, 3, 4]); + afArr.assign(af.span, 5); + assert.deepEqual(afArr.toArray(), [5, 5, 5, 5]); + + afArr = af.array([1, 2, 3, 4]); + afArr.assign(af.seq(1, 2), 5.5); + assert.deepEqual(afArr.toArray(), [1, 5.5, 5.5, 4]); + + afArr = af.array([1, 2, 3, 4]); + afArr.assign(af.seq(0, 1), af.array([10.5, 11.5])); + assert.deepEqual(afArr.toArray(), [10.5, 11.5, 3, 4]); + + afArr.assign(af.seq(0, 1), af.array([10, 11])); + assert.deepEqual(afArr.toArray(), [10, 11, 3, 4]);4 + + try { + afArr.assign(af.seq(0, 1), af.array([10.5, 11.5, 12.5])); + assert(false); + } + catch (e) { + assert(e instanceof AFError); + } + + afArr = af.array(af.dim4(4, 4), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], af.dtype.s32); + afArr.assign(af.idx(af.span, af.seq(2, 3)), af.array(af.dim4(4, 2), [1, 2, 3, 4, 5, 6, 7, 8])); + assert.deepEqual(afArr.toArray(), [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8]); + + afArr.assign(af.idx(af.seq(2, 3), af.span), 1.1); + assert.deepEqual(afArr.toArray(), [1, 2, 1, 1, 5, 6, 1, 1, 1, 2, 1, 1, 5, 6, 1, 1]); + + afArr = af.array(af.dim4(4, 4), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + afArr.assign(af.array([10, 11, 12, 13, 14, 15]), af.array([55, 66, 77, 88, 99, 100])); + assert.deepEqual(afArr.toArray(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 55, 66, 77, 88, 99, 100]); + + afArr.assign(af.array(af.dim4(3, 2), [1, 2, 3, 4, 5, 6]), af.array([55, 66, 77, 88, 99, 100])); + assert.deepEqual(afArr.toArray(), [1, 55, 66, 77, 88, 99, 100, 8, 9, 10, 55, 66, 77, 88, 99, 100]); + + try { + afArr.assign(af.array(af.dim4(3, 2), [1, 2, 3, 4, 5, 6]), af.array(af.dim4(3, 2), [55, 66, 77, 88, 99, 100])); + assert(false); + } + catch (e) { + assert(e instanceof AFError); + } + + afArr = af.array(af.dim4(4, 4), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + afArr.assign(af.array(af.dim4(3, 2), [1, 2, 3, 4, 5, 6]), -1); + assert.deepEqual(afArr.toArray(), [1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + }); + + it('should support copy-on-write', function () { + }); + }); + + describe('async', function () { + let af = null; + + beforeEach(function () { + af = new ArrayFire({ async: true }); + af.scope.begin(); + }); + + afterEach(async(function* () { + if (af) { + yield af.scope.end(); + af.release(); + af = null; + } + })); + + it('could be created by calling af.array()', async(function* () { + let arr; + let afArr; + let dims; + let buff; + let refArr; + + arr = [1, 2]; + afArr = yield af.array(arr); + dims = yield afArr.dims(); + assert.strictEqual(dims[0], 2); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 1); + assert.strictEqual(yield afArr.dims(0), 2); + assert.strictEqual(yield afArr.dims(1), 1); + assert.strictEqual(yield afArr.dims(2), 1); + assert.strictEqual(yield afArr.dims(3), 1); + + arr = new Float32Array([1, 2]); + afArr = yield af.array(arr); + dims = yield afArr.dims(); + assert.strictEqual(dims[0], 2); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 1); + assert.strictEqual(yield afArr.dims(0), 2); + assert.strictEqual(yield afArr.dims(1), 1); + assert.strictEqual(yield afArr.dims(2), 1); + assert.strictEqual(yield afArr.dims(3), 1); + buff = yield afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new FloatArray(buff); + assert.equal(refArr.length, 2); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + refArr.set(0, 0); + refArr.set(1, 0); + assert.equal(refArr.get(0), 0); + assert.equal(refArr.get(1), 0); + yield afArr.host(refArr.buffer); + assert.equal(refArr.length, 2); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + + arr = new FloatArray(2); + arr.set(0, 1); + arr.set(1, 2); + afArr = yield af.array(af.dim4(1, 2), arr.buffer); + dims = yield afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 2); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 2); + assert.strictEqual(dims.ndims, 2); + + afArr = yield af.array(af.dim4(3), af.dtype.s32); + dims = yield afArr.dims(); + assert.strictEqual(dims[0], 3); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 3); + assert.strictEqual(dims.ndims, 1); + buff = yield afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new IntArray(buff); + assert.equal(refArr.length, 3); + + afArr = yield af.array(af.dim4(1, 3)); + dims = yield afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 3); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 3); + assert.strictEqual(dims.ndims, 2); + assert.strictEqual(yield afArr.type(), af.dtype.f32); + assert.strictEqual(yield afArr.refType(), ref.types.float); + + arr = [1, 2, 3, 4]; + afArr = yield af.array(af.dim4(1, 1, 4), arr, af.dtype.s32); + dims = yield afArr.dims(); + assert.strictEqual(dims[0], 1); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 4); + assert.strictEqual(dims[3], 1); + assert.strictEqual(dims.elements, 4); + assert.strictEqual(dims.ndims, 3); + buff = yield afArr.host(); + assert(Buffer.isBuffer(buff)); + refArr = new IntArray(buff); + assert.equal(refArr.length, 4); + assert.equal(refArr.get(0), 1); + assert.equal(refArr.get(1), 2); + assert.equal(refArr.get(2), 3); + assert.equal(refArr.get(3), 4); + })); + + it('should support .index() for various parameter types', async(function* () { + let afArr; + let afIdx; + let indexed; + let arr; + let dims; + + afArr = yield af.array([1, 2, 3, 4, 5]); + dims = yield afArr.dims(); + assert.strictEqual(dims[0], 5); + assert.strictEqual(dims[1], 1); + assert.strictEqual(dims[2], 1); + assert.strictEqual(dims[3], 1); + assert.strictEqual(yield afArr.elements(), 5); + assert.strictEqual(yield afArr.numdims(), 1); + + indexed = yield afArr.index(af.seq(1)); + assert.deepEqual(yield indexed.toArray(), [2]); + + indexed = yield afArr.index(2); + assert.deepEqual(yield indexed.toArray(), [3]); + + indexed = yield afArr.index(af.seq(1, 3)); + assert.deepEqual(yield indexed.toArray(), [2, 3, 4]); + + afArr = yield af.array(af.dim4(4, 4), + [1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16]); + + assert.strictEqual(yield afArr.elements(), 16); + assert.strictEqual(yield afArr.numdims(), 2); + assert.strictEqual(yield afArr.dims(0), 4); + assert.strictEqual(yield afArr.dims(1), 4); + + indexed = yield afArr.index(af.seq(2, 4)); + assert.deepEqual(yield indexed.toArray(), [3, 4, 5]); + + indexed = yield afArr.index(af.idx(af.seq(0, 2), af.seq(1, 2))); + assert.deepEqual(yield indexed.toArray(), [5, 6, 7, 9, 10, 11]); + + indexed = yield afArr.index(af.idx(af.end, af.seq(2, 3))); + assert.deepEqual(yield indexed.toArray(), [12, 16]); + + indexed = yield afArr.index(af.span); + assert.deepEqual(yield indexed.toArray(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + + indexed = yield afArr.index(af.idx(1, af.span)); + assert.deepEqual(yield indexed.toArray(), [2, 6, 10, 14]); + + afArr = yield af.array([1, 2, 3, 4, 5]); + afIdx = yield af.array([1, 0, 2]); + indexed = yield afArr.index(afIdx); + assert.deepEqual(yield indexed.toArray(), [2, 1, 3]); + + afArr = yield af.array(af.dim4(4, 4), + [1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16]); + + afIdx = yield af.array(af.dim4(3, 2), + [1, 0, 2, + 5, 10, 2]); + + indexed = yield afArr.index(afIdx); + assert.deepEqual(yield indexed.toArray(), [2, 1, 3, 6, 11, 3]); + + // Col, Row + afArr = yield af.array(af.dim4(3, 3), [0, 1, 2, 3, 4, 5, 6, 7, 8]); + + indexed = yield afArr.index(af.row(0)); + assert.deepEqual(yield indexed.toArray(), [0, 3, 6]); + + indexed = yield afArr.index(af.row(2)); + assert.deepEqual(yield indexed.toArray(), [2, 5, 8]); + + indexed = yield afArr.index(af.rows(0, 1)); + assert.deepEqual(yield indexed.toArray(), [0, 1, 3, 4, 6, 7]); + + indexed = yield afArr.index(af.col(0)); + assert.deepEqual(yield indexed.toArray(), [0, 1, 2]); + + indexed = yield afArr.index(af.col(2)); + assert.deepEqual(yield indexed.toArray(), [6, 7, 8]); + + indexed = yield afArr.index(af.cols(1, 2)); + assert.deepEqual(yield indexed.toArray(), [3, 4, 5, 6, 7, 8]); + })); + }); +}); \ No newline at end of file diff --git a/test/es6/device.js b/test/es6/device.js new file mode 100644 index 0000000..b71e391 --- /dev/null +++ b/test/es6/device.js @@ -0,0 +1,116 @@ +'use strict'; +const Promise = require('bluebird'); +const assert = require('assert'); +const _ = require('lodash'); +const async = Promise.coroutine; +const arrayFireJs = require('../..'); +const ArrayFire = arrayFireJs.ArrayFire; + +describe('device functions', function () { + let af = null; + + afterEach(function () { + if (af) { + af.release(); + af = null; + } + }); + + it('should give result for deviceInfo (sync)', function () { + af = new ArrayFire(); + assert(_.isFunction(af.deviceInfo)); + const name = {}; + const platform = {}; + const toolkit = {}; + const compute = {}; + af.deviceInfo(name, platform, toolkit, compute); + assert(_.isString(name.value) && name.value.length); + assert(_.isString(platform.value) && platform.value.length); + assert(_.isString(toolkit.value) && toolkit.value.length); + assert(_.isString(compute.value) && compute.value.length); + }); + + it('should give result for deviceInfo (async)', async(function* () { + af = new ArrayFire({ async: true }); + assert(_.isFunction(af.deviceInfo)); + const name = {}; + const platform = {}; + const toolkit = {}; + const compute = {}; + yield af.deviceInfo(name, platform, toolkit, compute); + assert(_.isString(name.value) && name.value.length); + assert(_.isString(platform.value) && platform.value.length); + assert(_.isString(toolkit.value) && toolkit.value.length); + assert(_.isString(compute.value) && compute.value.length); + })); + + it('should give result for infoString (sync)', function () { + af = new ArrayFire(); + assert(_.isFunction(af.infoString)); + const info = af.infoString(); + assert(_.isString(info) && info.length); + const vInfo = af.infoString(true); + assert(_.isString(vInfo) && vInfo.length); + assert(vInfo.length >= info.length); + }); + + it('should give result for infoString (async)', async(function* () { + af = new ArrayFire({ async: true }); + assert(_.isFunction(af.infoString)); + const info = yield af.infoString(); + assert(_.isString(info) && info.length); + const vInfo = yield af.infoString(true); + assert(_.isString(vInfo) && vInfo.length); + assert(vInfo.length >= info.length); + })); + + it('should report device count (sync)', function () { + af = new ArrayFire(); + assert(_.isFunction(af.getDeviceCount)); + const count = af.getDeviceCount(); + assert(count > 0 && count < 10); + }); + + it('should report device count (async)', async(function* () { + af = new ArrayFire({ async: true }); + assert(_.isFunction(af.getDeviceCount)); + const count = yield af.getDeviceCount(); + assert(count > 0 && count < 10); + })); + + it('should set and get device ids (sync)', function () { + af = new ArrayFire(); + const count = af.getDeviceCount(); + assert(count > 0 && count < 10); + assert(_.isFunction(af.getDevice)); + assert(_.isFunction(af.setDevice)); + assert(_.isFunction(af.sync)); + for (let id = count - 1; id >= 0; id--) { + af.setDevice(id); + assert.strictEqual(af.getDevice(), id); + af.sync(id); + af.sync(); // -1 = current + } + }); + + it('should set and get device ids (async)', async(function* () { + af = new ArrayFire({ async: true }); + const count = yield af.getDeviceCount(); + assert(count > 0 && count < 10); + assert(_.isFunction(af.getDevice)); + assert(_.isFunction(af.setDevice)); + assert(_.isFunction(af.sync)); + for (let id = count - 1; id >= 0; id--) { + yield af.setDevice(id); + assert.strictEqual(yield af.getDevice(), id); + yield af.sync(id); + yield af.sync(); // -1 = current + } + })); + + it('should set seed', function () { + af = new ArrayFire(); + assert(_.isFunction(af.setSeed)); + af.setSeed(42); + }); +}); \ No newline at end of file diff --git a/test/es6/index.js b/test/es6/index.js new file mode 100644 index 0000000..3a6a720 --- /dev/null +++ b/test/es6/index.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./device'); +require('./unified'); +require('./array'); \ No newline at end of file diff --git a/test/es6/unified.js b/test/es6/unified.js new file mode 100644 index 0000000..9cad84e --- /dev/null +++ b/test/es6/unified.js @@ -0,0 +1,63 @@ +'use strict'; +const Promise = require('bluebird'); +const assert = require('assert'); +const _ = require('lodash'); +const async = Promise.coroutine; +const arrayFireJs = require('../..'); +const ArrayFire = arrayFireJs.ArrayFire; + +describe('unified backend functions', function () { + let af = null; + + beforeEach(function () { + af = new ArrayFire(); + }); + + afterEach(function () { + if (af) { + af.release(); + af = null; + } + }); + + it('should give available backends', function () { + assert(_.isObject(af.backend)); + assert(_.isFunction(af.getAvailableBackends)); + + const cpu = af.getAvailableBackends() & af.backend.CPU; + const cuda = af.getAvailableBackends() & af.backend.CUDA; + const ocl = af.getAvailableBackends() & af.backend.OPENCL; + + assert(cpu && (cuda || ocl)); + assert.equal(af.getBackendCount(), (cpu && 1) + (cuda && 1) + (ocl && 1)); + }); + + it('should switch to other backends', function () { + const cuda = af.getAvailableBackends() & af.backend.CUDA; + const ocl = af.getAvailableBackends() & af.backend.OPENCL; + + tryBackend(af.backend.CPU); + ocl && tryBackend(af.backend.OPENCL); + cuda && tryBackend(af.backend.CUDA); + + function tryBackend(backend) { + try { + af.setBackend(backend); + assert.strictEqual(af.getActiveBackend(), backend); + } + catch (e) { + if (e.code === 501) { + return; + } + if (e.code) { + throw Error(`Error with backend ${ af.enumToString(af.backend, backend) }, code: ${ e.code }, message: ${ e.message }`); + } + throw e; + } + } + }); + + it.skip(`should give back array's backend and device information`, function () { + assert(false, 'TODO'); + }); +}); \ No newline at end of file diff --git a/tests/index.js b/test/index.js similarity index 88% rename from tests/index.js rename to test/index.js index 591a4d5..8c90ebe 100644 --- a/tests/index.js +++ b/test/index.js @@ -29,24 +29,18 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 args = require('minimist')(process.argv.slice(2)); var es6; -if (argv.old) { +if (args.old) { es6 = false; } else { es6 = true; try { - eval("(() => {})()"); + eval('const err = () => { throw new Error(`foo`); };const args = ["a", "return a"];new Function(...args)(1) === 1||err();'); + eval('function Poo (a = 1) {}'); } catch (err) { es6 = false; } 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..0000000 --- a/tests/es5/afArrayTests.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["afArrayTests.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,YAAY;;AAAC;AA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AAG,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,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;;2CACvB,KAAK,CAAC,eAAe,EAAE;;;AAApC,wCAAI;;AACR,0CAAM,CAAC,IAAI,YAAY,MAAM,CAAC,CAAC;A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;;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,EAAE,EAAE;AACvB,UAAE,CAAC,aAAa,EAAE,YAAY;AAC1B,cAAE,CAAC,KAAK,CAAC,YAAM;AACX,oBAAM,KAAK,GAAG,EAAE,CAAC;AACjB,oBAAI,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACpD,oBAAI,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACxD,kBAAE,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,EAAE;AAC1B,0BAAM,CAAC,GAAG,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;AAC9B,0BAAM,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;AACxB,0BAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;AACvB,0BAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACnB,uBAAG,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;iBACjC,CAAC,CAAC;AACH,qBAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE;AAClC,wBAAI,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACvC,0BAAM,CAAC,GAAG,KAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,AAAC,CAAC,CAAC;iBACvD;aACJ,CAAC,CAAC;SACN,CAAC,CAAC;KACN,CAAC,CAAC;CACN,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,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,KA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AE,YAAY;AAClC,uBAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;SAC7C,CAAC,CAAC;AACH,UAAE,CAAC,qBAAqB,EAAE,YAAY;AAClC,uBAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;SAC7C,CAAC,CAAC;AACH,UAAE,CAAC,oBAAoB,EAAE,YAAY;AACjC,uBAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;SAC5C,CAAC,CAAC;AACH,UAAE,CAAC,oBAAoB,EAAE,YAAY;AACjC,uBAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;SAC5C,CAAC,CAAC;AACH,UAAE,CAAC,uBAAuB,EAAE,YAAY;AACpC,uBAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;SAC/C,CAAC,CAAC;AACH,UAAE,CAAC,qBAAqB,EAAE,YAAY;AAClC,uBAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;SAC7C,CAAC,CAAC;AACH,UAAE,CAAC,oBAAoB,EAAE,YAAY;AACjC,uBAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;SAC5C,CAAC,CAAC;AACH,UAAE,CAAC,oBAAoB,EAAE,YAAY;AACjC,uBAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;SAC5C,CAAC,CAAC;KACN,CAAC,CAAC;CACN,CAAC,CAAC","file":"mathFunctionTests.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/* 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,IAAI,EAAE;AAC1C,YAAI,MAAM,YAAA,CAAC;AACX,YAAI,IAAI,GAAG,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AA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;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/typings.json b/typings.json new file mode 100644 index 0000000..a7c9d3c --- /dev/null +++ b/typings.json @@ -0,0 +1,8 @@ +{ + "globalDevDependencies": { + "mocha": "registry:dt/mocha#2.2.5+20161119044246" + }, + "globalDependencies": { + "semver": "registry:dt/semver#5.3.0+20160803221903" + } +} diff --git a/typings/globals/mocha/index.d.ts b/typings/globals/mocha/index.d.ts new file mode 100644 index 0000000..241f436 --- /dev/null +++ b/typings/globals/mocha/index.d.ts @@ -0,0 +1,205 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/253e456e3c0bf4bd34afaceb7dcbae282da14066/mocha/index.d.ts +interface MochaSetupOptions { + //milliseconds to wait before considering a test slow + slow?: number; + + // timeout in milliseconds + timeout?: number; + + // ui name "bdd", "tdd", "exports" etc + ui?: string; + + //array of accepted globals + globals?: any[]; + + // reporter instance (function or string), defaults to `mocha.reporters.Spec` + reporter?: any; + + // bail on the first test failure + bail?: boolean; + + // ignore global leaks + ignoreLeaks?: boolean; + + // grep string or regexp to filter tests with + grep?: any; +} + +declare var mocha: Mocha; +declare var describe: Mocha.IContextDefinition; +declare var xdescribe: Mocha.IContextDefinition; +// alias for `describe` +declare var context: Mocha.IContextDefinition; +// alias for `describe` +declare var suite: Mocha.IContextDefinition; +declare var it: Mocha.ITestDefinition; +declare var xit: Mocha.ITestDefinition; +// alias for `it` +declare var test: Mocha.ITestDefinition; +declare var specify: Mocha.ITestDefinition; + +// Used with the --delay flag; see https://mochajs.org/#hooks +declare function run(): void; + +interface MochaDone { + (error?: any): any; +} + +interface ActionFunction { + (done: MochaDone): any | PromiseLike +} + +declare function setup(action: ActionFunction): void; +declare function teardown(action: ActionFunction): void; +declare function suiteSetup(action: ActionFunction): void; +declare function suiteTeardown(action: ActionFunction): void; +declare function before(action: ActionFunction): void; +declare function before(description: string, action: ActionFunction): void; +declare function after(action: ActionFunction): void; +declare function after(description: string, action: ActionFunction): void; +declare function beforeEach(action: ActionFunction): void; +declare function beforeEach(description: string, action: ActionFunction): void; +declare function afterEach(action: ActionFunction): void; +declare function afterEach(description: string, action: ActionFunction): void; + +declare class Mocha { + currentTest: Mocha.ITestDefinition; + constructor(options?: { + grep?: RegExp; + ui?: string; + reporter?: string; + timeout?: number; + bail?: boolean; + }); + + /** Setup mocha with the given options. */ + setup(options: MochaSetupOptions): Mocha; + bail(value?: boolean): Mocha; + addFile(file: string): Mocha; + /** Sets reporter by name, defaults to "spec". */ + reporter(name: string): Mocha; + /** Sets reporter constructor, defaults to mocha.reporters.Spec. */ + reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha; + ui(value: string): Mocha; + grep(value: string): Mocha; + grep(value: RegExp): Mocha; + invert(): Mocha; + ignoreLeaks(value: boolean): Mocha; + checkLeaks(): Mocha; + /** + * Function to allow assertion libraries to throw errors directly into mocha. + * This is useful when running tests in a browser because window.onerror will + * only receive the 'message' attribute of the Error. + */ + throwError(error: Error): void; + /** Enables growl support. */ + growl(): Mocha; + globals(value: string): Mocha; + globals(values: string[]): Mocha; + useColors(value: boolean): Mocha; + useInlineDiffs(value: boolean): Mocha; + timeout(value: number): Mocha; + slow(value: number): Mocha; + enableTimeouts(value: boolean): Mocha; + asyncOnly(value: boolean): Mocha; + noHighlighting(value: boolean): Mocha; + /** Runs tests and invokes `onComplete()` when finished. */ + run(onComplete?: (failures: number) => void): Mocha.IRunner; +} + +// merge the Mocha class declaration with a module +declare namespace Mocha { + /** Partial interface for Mocha's `Runnable` class. */ + interface IRunnable { + title: string; + fn: Function; + async: boolean; + sync: boolean; + timedOut: boolean; + } + + /** Partial interface for Mocha's `Suite` class. */ + interface ISuite { + parent: ISuite; + title: string; + + fullTitle(): string; + } + + /** Partial interface for Mocha's `Test` class. */ + interface ITest extends IRunnable { + parent: ISuite; + pending: boolean; + + fullTitle(): string; + } + + /** Partial interface for Mocha's `Runner` class. */ + interface IRunner {} + + interface IContextDefinition { + (description: string, spec: () => void): ISuite; + only(description: string, spec: () => void): ISuite; + skip(description: string, spec: () => void): void; + timeout(ms: number): void; + } + + interface ITestDefinition { + (expectation: string, assertion?: ActionFunction): ITest; + only(expectation: string, assertion?: ActionFunction): ITest; + skip(expectation: string, assertion?: ActionFunction): void; + timeout(ms: number): void; + state: "failed" | "passed"; + } + + export module reporters { + export class Base { + stats: { + suites: number; + tests: number; + passes: number; + pending: number; + failures: number; + }; + + constructor(runner: IRunner); + } + + export class Doc extends Base {} + export class Dot extends Base {} + export class HTML extends Base {} + export class HTMLCov extends Base {} + export class JSON extends Base {} + export class JSONCov extends Base {} + export class JSONStream extends Base {} + export class Landing extends Base {} + export class List extends Base {} + export class Markdown extends Base {} + export class Min extends Base {} + export class Nyan extends Base {} + export class Progress extends Base { + /** + * @param options.open String used to indicate the start of the progress bar. + * @param options.complete String used to indicate a complete test on the progress bar. + * @param options.incomplete String used to indicate an incomplete test on the progress bar. + * @param options.close String used to indicate the end of the progress bar. + */ + constructor(runner: IRunner, options?: { + open?: string; + complete?: string; + incomplete?: string; + close?: string; + }); + } + export class Spec extends Base {} + export class TAP extends Base {} + export class XUnit extends Base { + constructor(runner: IRunner, options?: any); + } + } +} + +declare module "mocha" { + export = Mocha; +} diff --git a/typings/globals/mocha/typings.json b/typings/globals/mocha/typings.json new file mode 100644 index 0000000..38c085e --- /dev/null +++ b/typings/globals/mocha/typings.json @@ -0,0 +1,8 @@ +{ + "resolution": "main", + "tree": { + "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/253e456e3c0bf4bd34afaceb7dcbae282da14066/mocha/index.d.ts", + "raw": "registry:dt/mocha#2.2.5+20161119044246", + "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/253e456e3c0bf4bd34afaceb7dcbae282da14066/mocha/index.d.ts" + } +} diff --git a/typings/globals/node/index.d.ts b/typings/globals/node/index.d.ts new file mode 100644 index 0000000..ca40fc6 --- /dev/null +++ b/typings/globals/node/index.d.ts @@ -0,0 +1,3774 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/types/env-node/088b6275167df0e4bec9bee3205c703253ef4ace/6.0/node.d.ts +interface NodeError { + /** + * Returns a string describing the point in the code at which the Error was instantiated. + * + * For example: + * + * ``` + * Error: Things keep happening! + * at /home/gbusey/file.js:525:2 + * at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21) + * at Actor. (/home/gbusey/actors.js:400:8) + * at increaseSynergy (/home/gbusey/actors.js:701:6) + * ``` + * + * The first line is formatted as : , and is followed by a series of stack frames (each line beginning with "at "). Each frame describes a call site within the code that lead to the error being generated. V8 attempts to display a name for each function (by variable name, function name, or object method name), but occasionally it will not be able to find a suitable name. If V8 cannot determine a name for the function, only location information will be displayed for that frame. Otherwise, the determined function name will be displayed with location information appended in parentheses. + */ + stack?: string; + + /** + * Returns the string description of error as set by calling new Error(message). The message passed to the constructor will also appear in the first line of the stack trace of the Error, however changing this property after the Error object is created may not change the first line of the stack trace. + * + * ``` + * const err = new Error('The message'); + * console.log(err.message); + * // Prints: The message + * ``` + */ + message: string; +} + +interface Error extends NodeError { } + +interface ErrorConstructor { + /** + * Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()`` was called. + * + * ```js + * const myObject = {}; + * Error.captureStackTrace(myObject); + * myObject.stack // similar to `new Error().stack` + * ``` + * + * The first line of the trace, instead of being prefixed with `ErrorType : message`, will be the result of calling `targetObject.toString()``. + * + * The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. + * + * The constructorOpt argument is useful for hiding implementation details of error generation from an end user. For instance: + * + * ```js + * function MyError() { + * Error.captureStackTrace(this, MyError); + * } + * + * // Without passing MyError to captureStackTrace, the MyError + * // frame would should up in the .stack property. by passing + * // the constructor, we omit that frame and all frames above it. + * new MyError().stack + * ``` + */ + captureStackTrace(targetObject: T, constructorOpt?: new () => T): void; + + /** + * The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj))``. + * + * The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. + * + * If set to a non-number value, or set to a negative number, stack traces will not capture any frames. + */ + stackTraceLimit: number; +} + +// ES2015 collection types +interface NodeCollection { + size: number; +} + +interface NodeWeakCollection {} + +interface IterableIterator {} + +interface NodeCollectionConstructor { + prototype: T; +} + +interface Map extends NodeCollection { + clear(): void; + delete(key: K): boolean; + entries(): Array<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): Array; + set(key: K, value?: V): Map; + values(): Array; + // [Symbol.iterator]():Array<[K,V]>; + // [Symbol.toStringTag]: "Map"; +} + +interface MapConstructor extends NodeCollectionConstructor> { + new (): Map; + new (): Map; +} + +declare var Map: MapConstructor; + +interface WeakMap extends NodeWeakCollection { + clear(): void; + delete(key: K): boolean; + get(key: K): V | void; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; +} + +interface WeakMapConstructor extends NodeCollectionConstructor> { + new (): WeakMap; + new (): WeakMap; +} + +declare var WeakMap: WeakMapConstructor; + +interface Set extends NodeCollection { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): Array<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): Array; + values(): Array; + // [Symbol.iterator]():Array; + // [Symbol.toStringTag]: "Set"; +} + +interface SetConstructor extends NodeCollectionConstructor> { + new (): Set; + new (): Set; + new (iterable: Array): Set; +} + +declare var Set: SetConstructor; + +interface WeakSet extends NodeWeakCollection { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + // [Symbol.toStringTag]: "WeakSet"; +} + +interface WeakSetConstructor extends NodeCollectionConstructor> { + new (): WeakSet; + new (): WeakSet; + new (iterable: Array): WeakSet; +} + +declare var WeakSet: WeakSetConstructor; + +/************************************************ +* * +* GLOBAL * +* * +************************************************/ +declare var process: NodeJS.Process; +declare var global: NodeJS.Global; + +declare var __filename: string; +declare var __dirname: string; + +declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearTimeout(timeoutId: NodeJS.Timer): void; +declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearInterval(intervalId: NodeJS.Timer): void; +declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; +declare function clearImmediate(immediateId: any): void; + +interface NodeRequireFunction { + (id: string): any; +} + +interface NodeRequire extends NodeRequireFunction { + resolve(id: string): string; + cache: { [filename: string]: NodeModule }; + extensions: NodeExtensions; + main: any; +} + +interface NodeExtensions { + '.js': (m: NodeModule, filename: string) => any; + '.json': (m: NodeModule, filename: string) => any; + '.node': (m: NodeModule, filename: string) => any; + [ext: string]: (m: NodeModule, filename: string) => any; +} + +declare var require: NodeRequire; + +declare class NodeModule { + static runMain(): void; + static wrap(code: string): string; + static _nodeModulePaths(path: string): string[]; + static _load(request: string, parent?: NodeModule, isMain?: boolean): any; + static _resolveFilename(request: string, parent?: NodeModule, isMain?: boolean): string; + static _extensions: NodeExtensions; + + constructor(filename: string); + _compile(code: string, filename: string): string; + + id: string; + parent: NodeModule; + filename: string; + paths: string[]; + children: NodeModule[]; + exports: any; + loaded: boolean; + require: NodeRequireFunction; +} + +declare var module: NodeModule; + +// Same as module.exports +declare var exports: any; +declare var SlowBuffer: { + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (size: Uint8Array): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; + isBuffer(obj: any): boolean; + byteLength(string: string, encoding?: string): number; + concat(list: Buffer[], totalLength?: number): Buffer; +}; + +// Console class (compatible with TypeScript `lib.d.ts`). +declare interface Console { + log(msg: any, ...params: any[]): void; + info(msg: any, ...params: any[]): void; + warn(msg: any, ...params: any[]): void; + error(msg: any, ...params: any[]): void; + dir(value: any, ...params: any[]): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(msg: any, ...params: any[]): void; + assert(test?: boolean, msg?: string, ...params: any[]): void; + + Console: new (stdout: NodeJS.WritableStream) => Console; +} + +declare var console: Console; + +declare class Buffer extends Uint8Array { + [index: number]: number; + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + */ + constructor(str: string, encoding?: string); + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + */ + constructor(size: number); + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + constructor(array: Uint8Array); + /** + * Produces a Buffer backed by the same allocated memory as + * the given {ArrayBuffer}. + * + * + * @param arrayBuffer The ArrayBuffer with which to share memory. + */ + constructor(arrayBuffer: ArrayBuffer); + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + constructor(array: any[]); + /** + * Copies the passed {buffer} data onto a new {Buffer} instance. + * + * @param buffer The buffer to copy. + */ + constructor(buffer: Buffer); + /** + * Allocates a new Buffer using an {array} of octets. + * + * @param array + */ + static from(array: any[]): Buffer; + /** + * When passed a reference to the .buffer property of a TypedArray instance, + * the newly created Buffer will share the same allocated memory as the TypedArray. + * The optional {byteOffset} and {length} arguments specify a memory range + * within the {arrayBuffer} that will be shared by the Buffer. + * + * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() + * @param byteOffset + * @param length + */ + static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; + /** + * Copies the passed {buffer} data onto a new Buffer instance. + * + * @param buffer + */ + static from(buffer: Buffer): Buffer; + /** + * Creates a new Buffer containing the given JavaScript string {str}. + * If provided, the {encoding} parameter identifies the character encoding. + * If not provided, {encoding} defaults to 'utf8'. + * + * @param str + */ + static from(str: string, encoding?: string): Buffer; + /** + * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the `Buffer` will be _zero-filled_. + * + * @param size The desired length of the new `Buffer` + * @param fill A value to pre-fill the new `Buffer` with. Default: `0` + * @param encoding If `fill` is a string, this is its encoding. Default: `'utf8'` + */ + static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; + /** + * Allocates a new _non-zero-filled_ `Buffer` of `size` bytes. The `size` must be less than or equal to the value of `buffer.kMaxLength`. Otherwise, a `RangeError` is thrown. A zero-length `Buffer` will be created if `size <= 0`. + * + * The underlying memory for `Buffer` instances created in this way is not initialized. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize such `Buffer` instances to zeroes. + * + * @param size The desired length of the new `Buffer` + */ + static allocUnsafe(size: number): Buffer; + /** + * Returns `true` if `obj` is a Buffer, `false` otherwise. + */ + static isBuffer(obj: any): obj is Buffer; + /** + * Returns `true` if `encoding` contains a supported character encoding, or `false` otherwise. + * + * @param encoding A character encoding name to check. + */ + static isEncoding(encoding: string): boolean; + /** + * Gives the actual byte length of a string. encoding defaults to 'utf8'. + * This is not the same as String.prototype.length since that returns the number of characters in a string. + * + * @param string string to test. + * @param encoding encoding used to evaluate (defaults to 'utf8') + */ + static byteLength(string: string, encoding?: string): number; + /** + * Returns a buffer which is the result of concatenating all the buffers in the list together. + * + * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. + * If the list has exactly one item, then the first item of the list is returned. + * If the list has more than one item, then a new Buffer is created. + * + * @param list An array of Buffer objects to concatenate + * @param totalLength Total length of the buffers when concatenated. + * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. + */ + static concat(list: Buffer[], totalLength?: number): Buffer; + /** + * The same as buf1.compare(buf2). + */ + compare(buf1: Buffer, buf2: Buffer): number; + write(string: string, offset?: number, length?: number, encoding?: string): number; + toString(encoding?: string, start?: number, end?: number): string; + toJSON(): any; + equals(otherBuffer: Buffer): boolean; + compare(otherBuffer: Buffer): number; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; + writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readUInt8(offset: number, noAssert?: boolean): number; + readUInt16LE(offset: number, noAssert?: boolean): number; + readUInt16BE(offset: number, noAssert?: boolean): number; + readUInt32LE(offset: number, noAssert?: boolean): number; + readUInt32BE(offset: number, noAssert?: boolean): number; + readInt8(offset: number, noAssert?: boolean): number; + readInt16LE(offset: number, noAssert?: boolean): number; + readInt16BE(offset: number, noAssert?: boolean): number; + readInt32LE(offset: number, noAssert?: boolean): number; + readInt32BE(offset: number, noAssert?: boolean): number; + readFloatLE(offset: number, noAssert?: boolean): number; + readFloatBE(offset: number, noAssert?: boolean): number; + readDoubleLE(offset: number, noAssert?: boolean): number; + readDoubleBE(offset: number, noAssert?: boolean): number; + writeUInt8(value: number, offset: number, noAssert?: boolean): number; + writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeInt8(value: number, offset: number, noAssert?: boolean): number; + writeInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeFloatLE(value: number, offset: number, noAssert?: boolean): number; + writeFloatBE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; + fill(value: any, offset?: number, end?: number): this; + indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + swap16(): this; + swap32(): this; + swap64(): this; + includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; + entries(): IterableIterator<[number, number]>; + keys(): IterableIterator; + values(): IterableIterator; +} + +/************************************************ +* * +* GLOBAL INTERFACES * +* * +************************************************/ +declare namespace NodeJS { + export interface ErrnoException extends Error { + errno?: number; + code?: string; + path?: string; + syscall?: string; + stack?: string; + } + + export interface EventEmitter { + addListener(event: string, listener: Function): this; + on(event: string, listener: Function): this; + once(event: string, listener: Function): this; + prependListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: Function): this; + removeListener(event: string, listener: Function): this; + removeAllListeners(event?: string): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + eventNames(): string[]; + listenerCount(type: string): number; + } + + export interface ReadableStream extends EventEmitter { + readable: boolean; + read(size?: number): string | Buffer; + setEncoding(encoding: string): this; + isPaused(): boolean; + pause(): this; + resume(): this; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: Buffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + } + + export interface WritableStream extends EventEmitter { + writable: boolean; + setDefaultEncoding(encoding: string): this; + write(buffer: Buffer | string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export interface ReadWriteStream extends ReadableStream, WritableStream { } + + export interface Events extends EventEmitter { } + + export interface Domain extends Events { + run(fn: Function): void; + add(emitter: Events): void; + remove(emitter: Events): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; + + addListener(event: string, listener: Function): this; + on(event: string, listener: Function): this; + once(event: string, listener: Function): this; + removeListener(event: string, listener: Function): this; + removeAllListeners(event?: string): this; + } + + export interface MemoryUsage { + rss: number; + heapTotal: number; + heapUsed: number; + } + + export interface Env { + PATH: string; + [key: string]: string; + } + + export interface Versions { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + modules: string; + openssl: string; + } + + export interface Process extends EventEmitter { + stdout: WritableStream; + stderr: WritableStream; + stdin: ReadableStream; + argv: string[]; + argv0: string; + /** + * The process.execArgv property returns the set of Node.js-specific command-line options passed when the Node.js process was launched. These options do not appear in the array returned by the process.argv property, and do not include the Node.js executable, the name of the script, or any options following the script name. These options are useful in order to spawn child processes with the same execution environment as the parent. + */ + execArgv: string[]; + execPath: string; + abort(): void; + chdir(directory: string): void; + cwd(): string; + env: Env; + exit(code?: number): void; + exitCode?: number; + getgid(): number; + setgid(id: number): void; + setgid(id: string): void; + getuid(): number; + setuid(id: number): void; + setuid(id: string): void; + version: string; + versions: Versions; + config: { + target_defaults: { + cflags: any[]; + default_configuration: string; + defines: string[]; + include_dirs: string[]; + libraries: string[]; + }; + variables: { + clang: number; + host_arch: string; + node_install_npm: boolean; + node_install_waf: boolean; + node_prefix: string; + node_shared_openssl: boolean; + node_shared_v8: boolean; + node_shared_zlib: boolean; + node_use_dtrace: boolean; + node_use_etw: boolean; + node_use_openssl: boolean; + target_arch: string; + v8_no_strict_aliasing: number; + v8_use_snapshot: boolean; + visibility: string; + }; + }; + kill(pid: number, signal?: string | number): void; + pid: number; + title: string; + arch: string; + platform: string; + memoryUsage(): MemoryUsage; + nextTick(callback: Function): void; + umask(mask?: number): number; + uptime(): number; + hrtime(time?: number[]): number[]; + domain: Domain; + + // Worker + send?(message: any, sendHandle?: any): void; + disconnect(): void; + connected: boolean; + } + + export interface Global { + Array: typeof Array; + ArrayBuffer: typeof ArrayBuffer; + Boolean: typeof Boolean; + Buffer: typeof Buffer; + DataView: typeof DataView; + Date: typeof Date; + Error: typeof Error; + EvalError: typeof EvalError; + Float32Array: typeof Float32Array; + Float64Array: typeof Float64Array; + Function: typeof Function; + GLOBAL: Global; + Infinity: typeof Infinity; + Int16Array: typeof Int16Array; + Int32Array: typeof Int32Array; + Int8Array: typeof Int8Array; + Intl: typeof Intl; + JSON: typeof JSON; + Map: MapConstructor; + Math: typeof Math; + NaN: typeof NaN; + Number: typeof Number; + Object: typeof Object; + Promise: Function; + RangeError: typeof RangeError; + ReferenceError: typeof ReferenceError; + RegExp: typeof RegExp; + Set: SetConstructor; + String: typeof String; + Symbol: Function; + SyntaxError: typeof SyntaxError; + TypeError: typeof TypeError; + URIError: typeof URIError; + Uint16Array: typeof Uint16Array; + Uint32Array: typeof Uint32Array; + Uint8Array: typeof Uint8Array; + Uint8ClampedArray: Function; + WeakMap: WeakMapConstructor; + WeakSet: WeakSetConstructor; + clearImmediate: (immediateId: any) => void; + clearInterval: (intervalId: NodeJS.Timer) => void; + clearTimeout: (timeoutId: NodeJS.Timer) => void; + console: typeof console; + decodeURI: typeof decodeURI; + decodeURIComponent: typeof decodeURIComponent; + encodeURI: typeof encodeURI; + encodeURIComponent: typeof encodeURIComponent; + escape: (str: string) => string; + eval: typeof eval; + global: Global; + isFinite: typeof isFinite; + isNaN: typeof isNaN; + parseFloat: typeof parseFloat; + parseInt: typeof parseInt; + process: Process; + root: Global; + setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; + setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + undefined: typeof undefined; + unescape: (str: string) => string; + gc: () => void; + v8debug?: any; + } + + export interface Timer { + ref(): void; + unref(): void; + _called: boolean; + _onTimeout: Function; + _timerArgs?: any[]; + } + + export interface Immediate { + _argv?: any[]; + _callback: Function; + _onImmediate: Function; + } +} + +/************************************************ +* * +* MODULES * +* * +************************************************/ +declare module "buffer" { + export var INSPECT_MAX_BYTES: number; + export var kMaxLength: number; + + export type Encoding = "ascii" | "latin1" | "binary" | "utf8" | "utf-8" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "hex" | "base64"; + + var BuffType: typeof Buffer; + var SlowBuffType: typeof SlowBuffer; + + export { BuffType as Buffer, SlowBuffType as SlowBuffer }; +} + +declare module "querystring" { + export interface StringifyOptions { + encodeURIComponent?: Function; + } + + export interface ParseOptions { + maxKeys?: number; + decodeURIComponent?: Function; + } + + export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; + export function escape(str: string): string; + export function unescape(str: string): string; +} + +declare module "events" { + export class EventEmitter implements NodeJS.EventEmitter { + static EventEmitter: EventEmitter; + static listenerCount(emitter: EventEmitter, event: string): number; // deprecated + static defaultMaxListeners: number; + + addListener(event: string, listener: (...args: any[]) => void): this; + on(event: string, listener: (...args: any[]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + removeListener(event: string, listener: (...args: any[]) => void): this; + removeAllListeners(event?: string): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string): Array<(...args: any[]) => void>; + listenerCount(event: string): number; + emit(event: string, ...args: any[]): boolean; + eventNames(): string[]; + } + + export interface Listener { + on(event: E, listener: L): this; + once(event: E, listener: L): this; + addListener(event: E, listener: L): this; + removeListener(event: E, listener: L): this; + listeners(event: E): L[]; + } +} + +declare module "http" { + import * as events from "events"; + import * as net from "net"; + import * as stream from "stream"; + + export interface OutgoingHeaders { + [header: string]: number | string | string[]; + } + + export interface IncomingHeaders { + [header: string]: string | string[]; + } + + export interface RequestOptions { + protocol?: string; + host?: string; + hostname?: string; + family?: number; + port?: number | string; + localAddress?: string; + socketPath?: string; + method?: string; + path?: string; + headers?: OutgoingHeaders; + auth?: string; + agent?: Agent | boolean; + } + + export class Server extends net.Server { + setTimeout(msecs: number, callback: Function): void; + maxHeadersCount: number; + timeout: number; + listening: boolean; + } + + export class ServerResponse extends stream.Writable { + finished: boolean; + headersSent: boolean; + statusCode: number; + statusMessage: string; + sendDate: boolean; + + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + writeContinue(): void; + writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void; + writeHead(statusCode: number, headers?: OutgoingHeaders): void; + setHeader(name: string, value: string | string[]): void; + setTimeout(msecs: number, callback: () => void): this; + getHeader(name: string): string; + removeHeader(name: string): void; + write(chunk: any, encoding?: string): any; + addTrailers(headers: OutgoingHeaders): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export class ClientRequest extends stream.Writable { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + write(chunk: any, encoding?: string): void; + abort(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; + + setHeader(name: string, value: string | string[]): void; + getHeader(name: string): string; + removeHeader(name: string): void; + addTrailers(headers: any): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + + export class IncomingMessage extends stream.Readable { + httpVersion: string; + headers: IncomingHeaders; + rawHeaders: string[]; + trailers: IncomingHeaders; + rawTrailers: string[]; + setTimeout(msecs: number, callback: Function): NodeJS.Timer; + destroy(error?: Error): void; + /** + * Only valid for request obtained from http.Server. + */ + method?: string; + /** + * Only valid for request obtained from http.Server. + */ + url?: string; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusCode?: number; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusMessage?: string; + socket: net.Socket; + } + + export interface AgentOptions { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number; + } + + export class Agent { + maxSockets: number; + sockets: any; + requests: any; + + constructor(opts?: AgentOptions); + + /** + * Destroy any sockets that are currently in use by the agent. + * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, + * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, + * sockets may hang open for quite a long time before the server terminates them. + */ + destroy(): void; + } + + export var METHODS: string[]; + + export var STATUS_CODES: { + [errorCode: number]: string; + [errorCode: string]: string; + }; + + export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server; + export function createClient(port?: number, host?: string): any; + export function request(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + export function get(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + export var globalAgent: Agent; +} + +declare module "cluster" { + import * as child from "child_process"; + import * as events from "events"; + + export interface ClusterSettings { + exec?: string; + args?: string[]; + silent?: boolean; + } + + export interface Address { + address: string; + port: number; + addressType: string; + } + + export class Worker extends events.EventEmitter { + id: string; + process: child.ChildProcess; + suicide: boolean; + send(message: any, sendHandle?: any): boolean; + kill(signal?: string): void; + destroy(signal?: string): void; + disconnect(): void; + isConnected(): boolean; + isDead(): boolean; + } + + export var settings: ClusterSettings; + export var isMaster: boolean; + export var isWorker: boolean; + export function setupMaster(settings?: ClusterSettings): void; + export function fork(env?: any): Worker; + export function disconnect(callback?: Function): void; + export var worker: Worker; + export var workers: { + [index: string]: Worker + }; + + // Event emitter + export function addListener(event: string, listener: Function): void; + export function on(event: "disconnect", listener: (worker: Worker) => void): void; + export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void; + export function on(event: "fork", listener: (worker: Worker) => void): void; + export function on(event: "listening", listener: (worker: Worker, address: any) => void): void; + export function on(event: "message", listener: (worker: Worker, message: any) => void): void; + export function on(event: "online", listener: (worker: Worker) => void): void; + export function on(event: "setup", listener: (settings: any) => void): void; + export function on(event: string, listener: Function): any; + export function once(event: string, listener: Function): void; + export function removeListener(event: string, listener: Function): void; + export function removeAllListeners(event?: string): void; + export function setMaxListeners(n: number): void; + export function listeners(event: string): Function[]; + export function emit(event: string, ...args: any[]): boolean; +} + +declare module "zlib" { + import * as stream from "stream"; + + export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } + export interface ZlibCallback { (error: Error, result: any): void } + + export interface Gzip extends stream.Transform { } + export interface Gunzip extends stream.Transform { } + export interface Deflate extends stream.Transform { } + export interface Inflate extends stream.Transform { } + export interface DeflateRaw extends stream.Transform { } + export interface InflateRaw extends stream.Transform { } + export interface Unzip extends stream.Transform { } + + export function createGzip(options?: ZlibOptions): Gzip; + export function createGunzip(options?: ZlibOptions): Gunzip; + export function createDeflate(options?: ZlibOptions): Deflate; + export function createInflate(options?: ZlibOptions): Inflate; + export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; + export function createInflateRaw(options?: ZlibOptions): InflateRaw; + export function createUnzip(options?: ZlibOptions): Unzip; + + export function deflate(buf: Buffer | string, callback?: ZlibCallback): void; + export function deflate(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function deflateSync(buf: Buffer | string, options?: ZlibOptions): any; + export function deflateRaw(buf: Buffer | string, callback?: ZlibCallback): void; + export function deflateRaw(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): any; + export function gzip(buf: Buffer | string, callback?: ZlibCallback): void; + export function gzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function gzipSync(buf: Buffer | string, options?: ZlibOptions): any; + export function gunzip(buf: Buffer | string, callback?: ZlibCallback): void; + export function gunzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function gunzipSync(buf: Buffer | string, options?: ZlibOptions): any; + export function inflate(buf: Buffer | string, callback?: ZlibCallback): void; + export function inflate(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function inflateSync(buf: Buffer | string, options?: ZlibOptions): any; + export function inflateRaw(buf: Buffer | string, callback?: ZlibCallback): void; + export function inflateRaw(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function inflateRawSync(buf: Buffer | string, options?: ZlibOptions): any; + export function unzip(buf: Buffer | string, callback?: ZlibCallback): void; + export function unzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function unzipSync(buf: Buffer | string, options?: ZlibOptions): any; + + // Constants + export var Z_NO_FLUSH: number; + export var Z_PARTIAL_FLUSH: number; + export var Z_SYNC_FLUSH: number; + export var Z_FULL_FLUSH: number; + export var Z_FINISH: number; + export var Z_BLOCK: number; + export var Z_TREES: number; + export var Z_OK: number; + export var Z_STREAM_END: number; + export var Z_NEED_DICT: number; + export var Z_ERRNO: number; + export var Z_STREAM_ERROR: number; + export var Z_DATA_ERROR: number; + export var Z_MEM_ERROR: number; + export var Z_BUF_ERROR: number; + export var Z_VERSION_ERROR: number; + export var Z_NO_COMPRESSION: number; + export var Z_BEST_SPEED: number; + export var Z_BEST_COMPRESSION: number; + export var Z_DEFAULT_COMPRESSION: number; + export var Z_FILTERED: number; + export var Z_HUFFMAN_ONLY: number; + export var Z_RLE: number; + export var Z_FIXED: number; + export var Z_DEFAULT_STRATEGY: number; + export var Z_BINARY: number; + export var Z_TEXT: number; + export var Z_ASCII: number; + export var Z_UNKNOWN: number; + export var Z_DEFLATED: number; + export var Z_NULL: number; +} + +declare module "os" { + export interface CpuInfo { + model: string; + speed: number; + times: { + user: number; + nice: number; + sys: number; + idle: number; + irq: number; + }; + } + + export interface NetworkInterfaceInfo { + address: string; + netmask: string; + family: string; + mac: string; + internal: boolean; + } + + export function tmpdir(): string; + export function homedir(): string; + export function endianness(): "BE" | "LE"; + export function hostname(): string; + export function type(): string; + export function platform(): string; + export function arch(): string; + export function release(): string; + export function uptime(): number; + export function loadavg(): number[]; + export function totalmem(): number; + export function freemem(): number; + export function cpus(): CpuInfo[]; + export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] }; + export function userInfo(options?: { encoding: 'buffer' }): { username: Buffer, uid: number, gid: number, shell: Buffer | null, homedir: Buffer } + export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: string | null, homedir: string } + export var EOL: string; +} + +declare module "https" { + import * as tls from "tls"; + import * as events from "events"; + import * as http from "http"; + + export interface ServerOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + crl?: any; + ciphers?: string; + honorCipherOrder?: boolean; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; + SNICallback?: (servername: string) => any; + } + + export interface RequestOptions extends http.RequestOptions { + pfx?: string | Buffer; + key?: string | Buffer; + passphrase?: string; + cert?: string | Buffer; + ca?: string | Buffer | string[] | Buffer[]; + ciphers?: string; + rejectUnauthorized?: boolean; + secureProtocol?: string; + } + + export interface AgentOptions extends http.AgentOptions { + /** + * Certificate, Private key and CA certificates to use for SSL. Default `null`. + */ + pfx?: string | Buffer; + /** + * Private key to use for SSL. Default `null`. + */ + key?: string | Buffer | string[] | Buffer[]; + /** + * A string of passphrase for the private key or pfx. Default `null`. + */ + passphrase?: string; + /** + * Public x509 certificate to use. Default `null`. + */ + cert?: string | Buffer | string[] | Buffer[]; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. + */ + ca?: string | Buffer | string[] | Buffer[]; + /** + * A string describing the ciphers to use or exclude. Consult https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT for details on the format. + */ + ciphers?: string; + /** + * If `true`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Default `true`. + */ + rejectUnauthorized?: boolean; + /** + * Servername for SNI (Server Name Indication) TLS extension. + */ + servername?: string; + /** + * The SSL method to use, e.g. `SSLv3_method` to force SSL version 3. The possible values depend on your installation of OpenSSL and are defined in the constant SSL_METHODS. + */ + secureProtocol?: string; + maxCachedSessions?: number; + } + + export class Agent extends http.Agent { + constructor(options?: AgentOptions); + } + + export class Server extends tls.Server { } + + export function createServer(options: ServerOptions, requestListener?: Function): Server; + export function request(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export function get(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export var globalAgent: Agent; +} + +declare module "punycode" { + export function decode(string: string): string; + export function encode(string: string): string; + export function toUnicode(domain: string): string; + export function toASCII(domain: string): string; + export var ucs2: ucs2; + interface ucs2 { + decode(string: string): number[]; + encode(codePoints: number[]): string; + } + export var version: any; +} + +declare module "repl" { + import { EventEmitter } from "events"; + import { Interface } from "readline"; + + export interface ReplOptions { + prompt?: string; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + terminal?: boolean; + eval?: Function; + useColors?: boolean; + useGlobal?: boolean; + ignoreUndefined?: boolean; + writer?: Function; + completer?: Function; + replMode?: symbol; + breakEvalOnSigint?: boolean; + } + + export function start(options: ReplOptions): REPLServer; + + export type REPLCommand = (this: REPLServer, rest: string) => void; + + export class REPLServer extends Interface { + inputStream: NodeJS.ReadableStream; + outputStream: NodeJS.WritableStream; + useColors: boolean; + commands: { + [command: string]: REPLCommand; + }; + defineCommand(keyword: string, cmd: REPLCommand | { help: string, action: REPLCommand }): void; + displayPrompt(preserveCursor?: boolean): void; + setPrompt(prompt: string): void; + turnOffEditorMode(): void; + } + + export class Recoverable extends SyntaxError { + err: Error; + constructor(err: Error); + } +} + +declare module "readline" { + import * as events from "events"; + import * as stream from "stream"; + + export interface Key { + sequence?: string; + name?: string; + ctrl?: boolean; + meta?: boolean; + shift?: boolean; + } + + export class Interface extends events.EventEmitter { + setPrompt(prompt: string): void; + prompt(preserveCursor?: boolean): void; + question(query: string, callback: (answer: string) => void): void; + pause(): this; + resume(): this; + close(): void; + write(data: string | Buffer, key?: Key): void; + } + + export interface Completer { + (line: string): CompleterResult; + (line: string, callback: (err: any, result: CompleterResult) => void): any; + } + + export interface CompleterResult { + completions: string[]; + line: string; + } + + export interface InterfaceOptions { + input: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + completer?: Completer; + terminal?: boolean; + historySize?: number; + } + + export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): Interface; + export function createInterface(options: InterfaceOptions): Interface; + + export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; + export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void; + export function clearLine(stream: NodeJS.WritableStream, dir: number): void; + export function clearScreenDown(stream: NodeJS.WritableStream): void; +} + +declare module "vm" { + export interface Context { } + + export interface ScriptOptions { + filename?: string; + lineOffset?: number; + columnOffset?: number; + displayErrors?: boolean; + timeout?: number; + cachedData?: Buffer; + produceCachedData?: boolean; + } + + export interface RunInNewContextOptions { + filename?: string; + lineOffset?: number; + columnOffset?: number; + displayErrors?: boolean; + timeout?: number; + } + + export interface RunInContextOptions extends RunInNewContextOptions { + breakOnSigint?: boolean; + } + + export class Script { + constructor(code: string, options?: string | ScriptOptions); + runInContext(contextifiedSandbox: Context, options?: RunInContextOptions): any; + runInNewContext(sandbox?: Context, options?: RunInNewContextOptions): any; + runInThisContext(options?: RunInNewContextOptions): any; + } + + export function createContext(sandbox?: Context): Context; + export function isContext(sandbox: Context): boolean; + export function runInContext(code: string, contextifiedSandbox: Context, options?: string | RunInNewContextOptions): any; + export function runInDebugContext(code: string): any; + export function runInNewContext(code: string, sandbox?: Context, options?: string | RunInNewContextOptions): any; + export function runInThisContext(code: string, options?: string | RunInNewContextOptions): any; + /** + * @deprecated + */ + export function createScript(code: string, options?: string | ScriptOptions): Script; +} + +declare module "child_process" { + import * as events from "events"; + import * as stream from "stream"; + import * as buffer from "buffer"; + import * as net from "net"; + + export class ChildProcess extends events.EventEmitter implements + events.Listener<'close', (code: number, signal: string) => void>, + events.Listener<'error', (error: Error) => void>, + events.Listener<'exit', ((code: number, signal: string | null) => void) | ((code: number | null, signal: string) => void)>, + events.Listener<'message', (message: any, sendHandle?: net.Socket | net.Server) => void>, + events.Listener<'disconnect', () => void> { + stdin: stream.Writable; + stdout: stream.Readable; + stderr: stream.Readable; + stdio: [stream.Writable, stream.Readable, stream.Readable]; + pid: number; + kill(signal?: string): void; + send(message: any, sendHandle?: any): boolean; + connected: boolean; + disconnect(): void; + unref(): void; + } + + export interface SpawnOptions { + cwd?: string; + env?: any; + stdio?: any; + detached?: boolean; + uid?: number; + gid?: number; + shell?: boolean | string; + } + + export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess; + + export interface ExecOptions { + cwd?: string; + env?: any; + shell?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + uid?: number; + gid?: number; + encoding?: buffer.Encoding | 'buffer'; + } + + export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function exec(command: string, options: ExecOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + + export interface ExecFileOptions { + cwd?: string; + env?: any; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + uid?: number; + gid?: number; + encoding?: buffer.Encoding | 'buffer'; + } + + export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, options?: ExecFileOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, args?: string[], options?: ExecFileOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + + export interface ForkOptions { + cwd?: string; + env?: any; + execPath?: string; + execArgv?: string[]; + silent?: boolean; + uid?: number; + gid?: number; + } + + export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess; + + export interface SpawnSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + shell?: boolean | string; + encoding?: buffer.Encoding | 'buffer'; + } + + export interface SpawnSyncReturns { + pid: number; + output: string[]; + stdout: T; + stderr: T; + status: number; + signal: string; + error: Error; + } + export function spawnSync(command: string): SpawnSyncReturns; + export function spawnSync(command: string, options?: SpawnSyncOptions & { encoding: 'buffer' }): SpawnSyncReturns; + export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; + export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions & { encoding: 'buffer' }): SpawnSyncReturns; + export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns; + + export interface ExecSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + shell?: string; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + encoding?: buffer.Encoding | 'buffer'; + } + + export function execSync(command: string): Buffer; + export function execSync(command: string, options?: ExecSyncOptions & { encoding: 'buffer' }): Buffer; + export function execSync(command: string, options?: ExecSyncOptions): Buffer; + + export interface ExecFileSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + encoding?: buffer.Encoding | 'buffer'; + } + + export function execFileSync(command: string): Buffer; + export function execFileSync(command: string, options?: ExecFileSyncOptions & { encoding: 'buffer' }): Buffer; + export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer; + export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions & { encoding: 'buffer' }): Buffer; + export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer; +} + +declare module "url" { + export interface Url { + href?: string; + protocol?: string; + auth?: string; + hostname?: string; + port?: string; + host?: string; + pathname?: string; + search?: string; + query?: string | any; + slashes?: boolean; + hash?: string; + path?: string; + } + + export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; + export function format(url: Url | string): string; + export function resolve(from: string, to: string): string; +} + +declare module "dns" { + export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string; + export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string; + export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; + + export const NODATA: 'ENODATA'; + export const FORMERR: 'EFORMERR'; + export const SERVFAIL: 'ESERVFAIL'; + export const NOTFOUND: 'ENOTFOUND'; + export const NOTIMP: 'ENOTIMP'; + export const REFUSED: 'EREFUSED'; + export const BADQUERY: 'EBADQUERY'; + export const BADNAME: 'EBADNAME'; + export const BADFAMILY: 'EBADFAMILY'; + export const BADRESP: 'EBADRESP'; + export const CONNREFUSED: 'ECONNREFUSED'; + export const TIMEOUT: 'ETIMEOUT'; + export const EOF: 'EOF'; + export const FILE: 'EFILE'; + export const NOMEM: 'ENOMEM'; + export const DESTRUCTION: 'EDESTRUCTION'; + export const BADSTR: 'EBADSTR'; + export const BADFLAGS: 'EBADFLAGS'; + export const NONAME: 'ENONAME'; + export const BADHINTS: 'EBADHINTS'; + export const NOTINITIALIZED: 'ENOTINITIALIZED'; + export const LOADIPHLPAPI: 'ELOADIPHLPAPI'; + export const ADDRGETNETWORKPARAMS: 'EADDRGETNETWORKPARAMS'; + export const CANCELLED: 'ECANCELLED'; +} + +declare module "net" { + import * as stream from "stream"; + + export class Socket extends stream.Duplex { + constructor(options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }); + + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + connect(port: number, host?: string, connectionListener?: Function): void; + connect(path: string, connectionListener?: Function): void; + bufferSize: number; + write(data: any, encoding?: string, callback?: Function): void; + destroy(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setKeepAlive(enable?: boolean, initialDelay?: number): void; + address(): { port: number; family: string; address: string; }; + unref(): void; + ref(): void; + + remoteAddress: string; + remoteFamily: string; + remotePort: number; + localAddress: string; + localPort: number; + bytesRead: number; + bytesWritten: number; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + + export interface ListenOptions { + port?: number; + host?: string; + backlog?: number; + path?: string; + exclusive?: boolean; + } + + export class Server extends Socket { + listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): this; + listen(port: number, hostname?: string, listeningListener?: Function): this; + listen(port: number, backlog?: number, listeningListener?: Function): this; + listen(port: number, listeningListener?: Function): this; + listen(path: string, backlog?: number, listeningListener?: Function): this; + listen(path: string, listeningListener?: Function): this; + listen(handle: any, backlog?: number, listeningListener?: Function): this; + listen(handle: any, listeningListener?: Function): this; + listen(options: ListenOptions, listeningListener?: Function): this; + close(callback?: () => void): this; + address(): { port: number; family: string; address: string; }; + getConnections(cb: (error: Error, count: number) => void): void; + ref(): this; + unref(): this; + maxConnections: number; + connections: number; + } + + export function createServer(connectionListener?: (socket: Socket) => void): Server; + export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server; + export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function connect(port: number, host?: string, connectionListener?: Function): Socket; + export function connect(path: string, connectionListener?: Function): Socket; + export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; + export function createConnection(path: string, connectionListener?: Function): Socket; + export function isIP(input: string): number; + export function isIPv4(input: string): boolean; + export function isIPv6(input: string): boolean; +} + +declare module "dgram" { + import * as events from "events"; + + export interface RemoteInfo { + address: string; + port: number; + size: number; + } + + export interface AddressInfo { + address: string; + family: string; + port: number; + } + + export interface BindOptions { + port: number; + address?: string; + exclusive?: boolean; + } + + export interface SocketOptions { + type: string; + reuseAddr?: boolean; + } + + export function createSocket(type: string | SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + + export class Socket extends events.EventEmitter { + send(msg: Buffer | string | Array, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; + send(msg: Buffer | string | Array, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; + bind(port: number, address?: string, callback?: () => void): void; + bind(options: BindOptions, callback?: () => void): void; + close(callback?: () => void): void; + setTTL(ttl: number): void; + address(): AddressInfo; + setBroadcast(flag: boolean): void; + setMulticastTTL(ttl: number): void; + setMulticastLoopback(flag: boolean): void; + addMembership(multicastAddress: string, multicastInterface?: string): void; + dropMembership(multicastAddress: string, multicastInterface?: string): void; + ref(): void; + unref(): void; + } +} + +declare module "fs" { + import * as stream from "stream"; + import * as events from "events"; + import * as buffer from "buffer"; + + /** + * Objects returned from `fs.stat()`, `fs.lstat()` and `fs.fstat()` and their synchronous counterparts are of this type. + */ + export class Stats { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + blksize: number; + blocks: number; + /** + * "Access Time" - Time when file data last accessed. Changed by the `mknod(2)`, `utimes(2)`, and `read(2)` system calls. + */ + atime: Date; + /** + * "Modified Time" - Time when file data last modified. Changed by the `mknod(2)`, `utimes(2)`, and `write(2)` system calls. + */ + mtime: Date; + /** + * "Change Time" - Time when file status was last changed (inode data modification). Changed by the `chmod(2)`, `chown(2)`, `link(2)`, `mknod(2)`, `rename(2)`, `unlink(2)`,` utimes(2)`, `read(2)`, and `write(2)` system calls. + */ + ctime: Date; + /** + * "Birth Time" - Time of file creation. Set once when the file is created. On filesystems where birthtime is not available, this field may instead hold either the `ctime` or `1970-01-01T00:00Z` (ie, unix epoch timestamp `0`). Note that this value may be greater than `atime` or `mtime` in this case. On Darwin and other FreeBSD variants, also set if the `atime` is explicitly set to an earlier value than the current `birthtime` using the `utimes(2)` system call. + */ + birthtime: Date; + } + + export type WatchListener = (eventType: string, filename?: string | Buffer) => void; + + /** + * Objects returned from fs.watch() are of this type. + */ + export class FSWatcher extends events.EventEmitter implements + events.Listener<'change', WatchListener> { + close(): void; + } + + export class ReadStream extends stream.Readable implements + events.Listener<'open', (fd: number) => void>, + events.Listener<'close', () => void> { + bytesRead: number; + path: string | Buffer; + close(): void; + destroy(): void; + } + + export class WriteStream extends stream.Writable implements + events.Listener<'open', (fd: number) => void>, + events.Listener<'close', () => void> { + close(): void; + bytesWritten: number; + path: string | Buffer; + } + + export const F_OK: number; + export const R_OK: number; + export const W_OK: number; + export const X_OK: number; + + export const constants: { + O_RDONLY: number; + O_WRONLY: number; + O_RDWR: number; + S_IFMT: number; + S_IFREG: number; + S_IFDIR: number; + S_IFCHR: number; + S_IFBLK: number; + S_IFIFO: number; + S_IFLNK: number; + S_IFSOCK: number; + O_CREAT: number; + O_EXCL: number; + O_NOCTTY: number; + O_TRUNC: number; + O_APPEND: number; + O_DIRECTORY: number; + O_NOFOLLOW: number; + O_SYNC: number; + O_SYMLINK: number; + O_NONBLOCK: number; + S_IRWXU: number; + S_IRUSR: number; + S_IWUSR: number; + S_IXUSR: number; + S_IRWXG: number; + S_IRGRP: number; + S_IWGRP: number; + S_IXGRP: number; + S_IRWXO: number; + S_IROTH: number; + S_IWOTH: number; + S_IXOTH: number; + F_OK: number; + R_OK: number; + W_OK: number; + X_OK: number; + [key: string]: number; + } + + /** + * Tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the accessibility checks to be performed. The following constants define the possible values of `mode`. It is possible to create a mask consisting of the bitwise OR of two or more values. + */ + export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous version of `fs.access()`. This throws if any accessibility checks fail, and does nothing otherwise. + */ + export function accessSync(path: string | Buffer, mode?: number): void; + + export interface AppendFileOptions { + encoding?: buffer.Encoding; + mode?: number; + flag?: string; + } + + /** + * Asynchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a buffer. + */ + export function appendFile(file: string | Buffer | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function appendFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | AppendFileOptions, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * The synchronous version of `fs.appendFile()`. + */ + export function appendFileSync(file: string | Buffer | number, data: string | Buffer, options?: AppendFileOptions): void; + + /** + * Asynchronous chmod(2). + */ + export function chmod(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous chmod(2). + */ + export function chmodSync(path: string | Buffer, mode: number): void; + + /** + * Asynchronous chown(2). + */ + export function chown(path: string | Buffer, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous chown(2). + */ + export function chownSync(path: string | Buffer, uid: number, gid: number): void; + + /** + * Asynchronous close(2). + */ + export function close(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous close(2). + */ + export function closeSync(fd: number): void; + + export interface ReadStreamOptions { + flags?: string; + encoding?: buffer.Encoding; + fd?: number; + mode?: number; + autoClose?: boolean; + start?: number; + end?: number; + } + + /** + * Returns a new ReadStream object. + * + * Be aware that, unlike the default value set for `highWaterMark` on a readable stream (16 kb), the stream returned by this method has a default value of 64 kb for the same parameter. + */ + export function createReadStream(path: string | Buffer, options?: ReadStreamOptions): ReadStream; + + export interface WriteStreamOptions { + flags?: string; + defaultEncoding?: buffer.Encoding; + fd?: number; + mode?: number; + autoClose?: boolean; + start: number; + end: number; + } + + /** + * Returns a new WriteStream object. + */ + export function createWriteStream(path: string | Buffer, options?: WriteStreamOptions): WriteStream; + + /** + * Test whether or not the given path exists by checking with the file system. Then call the `callback` argument with either true or false. + * + * @deprecated + */ + export function exists(path: string | Buffer, callback: (exists: boolean) => void): void; + + /** + * Synchronous version of `fs.exists()`. Returns true if the file exists, false otherwise. + */ + export function existsSync(path: string | Buffer): boolean; + + /** + * Asynchronous fchmod(2). + */ + export function fchmod(fd: number, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous fchmod(2). + */ + export function fchmodSync(fd: number, mode: number): void; + + /** + * Asynchronous fchown(2). + */ + export function fchown(fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous fchown(2). + */ + export function fchownSync(fd: number, uid: number, gid: number): void; + + /** + * Asynchronous fdatasync(2). + */ + export function fdatasync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous fdatasync(2). + */ + export function fdatasyncSync(fd: number): void; + + /** + * Asynchronous fstat(2). + */ + export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + + /** + * Synchronous fstat(2). + */ + export function fstatSync(fd: number): Stats; + + /** + * Asynchronous fsync(2). + */ + export function fsync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous fsync(2). + */ + export function fsyncSync(fd: number): void; + + /** + * Asynchronous ftruncate(2). + * + * If the file referred to by the file descriptor was larger than `len` bytes, only the first `len` bytes will be retained in the file. + * + * If the file previously was shorter than `len` bytes, it is extended, and the extended part is filled with null bytes ('\0'). + */ + export function ftruncate(fd: number, len: number | null | undefined, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous ftruncate(2). + */ + export function ftruncateSync(fd: number, len?: number | null): void; + + /** + * Change the file timestamps of a file referenced by the supplied file descriptor. + */ + export function futimes(fd: number, atime: number, mtime: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous version of `fs.futimes()`. + */ + export function futimesSync(fd: number, atime: number, mtime: number): void; + + /** + * Asynchronous lchmod(2). + * + * Only available on Mac OS X. + * + * @deprecated + */ + export function lchmod(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous lchmod(2). + * + * @deprecated + */ + export function lchmodSync(path: string | Buffer, mode: number): void; + + /** + * Asynchronous lchown(2). + * + * @deprecated + */ + export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous lchown(2). + * + * @deprecated + */ + export function lchownSync(path: string | Buffer, uid: number, gid: number): void; + + /** + * Asynchronous link(2). + */ + export function link(existingPath: string | Buffer, newPath: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous link(2). + */ + export function linkSync(existingPath: string | Buffer, newPath: string | Buffer): void; + + /** + * Asynchronous lstat(2). `lstat()` is identical to `stat()`, except that if `path` is a symbolic link, then the link itself is stat-ed, not the file that it refers to. + */ + export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + + /** + * Synchronous lstat(2). + */ + export function lstatSync(path: string | Buffer): Stats; + + /** + * Asynchronous mkdir(2). `mode` defaults to `0o777`. + */ + export function mkdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function mkdir(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous mkdir(2). + */ + export function mkdirSync(path: string | Buffer, mode?: number): void; + + export interface MkdtempOptions { + encoding: buffer.Encoding; + } + + /** + * Creates a unique temporary directory. + * + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * + * The created folder path is passed as a string to the callback's second parameter. + */ + export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void; + export function mkdtemp(prefix: string, options: buffer.Encoding | MkdtempOptions, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void; + + /** + * The synchronous version of fs.mkdtemp(). Returns the created folder path. + */ + export function mkdtempSync(prefix: string, options?: buffer.Encoding | MkdtempOptions): string; + + /** + * Asynchronous file open. See open(2). `flags` can be: + * + * 'r' - Open file for reading. An exception occurs if the file does not exist. + * + * 'r+' - Open file for reading and writing. An exception occurs if the file does not exist. + * + * 'rs+' - Open file for reading and writing in synchronous mode. Instructs the operating system to bypass the local file system cache. + * + * This is primarily useful for opening files on NFS mounts as it allows you to skip the potentially stale local cache. It has a very real impact on I/O performance so don't use this flag unless you need it. + * + * Note that this doesn't turn `fs.open()` into a synchronous blocking call. If that's what you want then you should be using `fs.openSync()` + * + * 'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists). + * + * 'wx' - Like `'w'` but fails if `path` exists. + * + * 'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists). + * + * 'wx+' - Like `'w+'` but fails if `path` exists. + * + * 'a' - Open file for appending. The file is created if it does not exist. + * + * 'ax' - Like 'a' but fails if `path` exists. + * + * 'a+' - Open file for reading and appending. The file is created if it does not exist. + * + * 'ax+' - Like 'a+' but fails if `path` exists. + * + * `mode` sets the file mode (permission and sticky bits), but only if the file was created. It defaults to `0666`, readable and writable. + */ + export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; + export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; + + /** + * Synchronous version of `fs.open()`. + */ + export function openSync(path: string | Buffer, flags: string | number, mode?: number): number; + + /** + * Read data from the file specified by fd. + * + * @param buffer is the buffer that the data will be written to. + * @param offset is the offset in the buffer to start writing at. + * @param length is an integer specifying the number of bytes to read. + * @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position. + */ + export function read(fd: number, buffer: string | Buffer, offset: number, length: number, position: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: Buffer) => void): void; + + export interface ReaddirOptions { + encoding?: buffer.Encoding | 'buffer'; + } + + /** + * Asynchronous readdir(3). Reads the contents of a directory. + * + * @param files is an array of the names of the files in the directory excluding '.' and '..'. + */ + export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; + export function readdir(path: string | Buffer, options: 'buffer' | (ReadFileOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void; + export function readdir(path: string | Buffer, options: buffer.Encoding | ReaddirOptions, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; + + /** + * Synchronous readdir(3). Returns an array of filenames excluding '.' and '..'. + */ + export function readdirSync(path: string | Buffer): string[]; + export function readdirSync(path: string | Buffer, options: 'buffer' | (ReaddirOptions & { encoding: 'buffer' })): Buffer[]; + export function readdirSync(path: string | Buffer, options: buffer.Encoding | ReaddirOptions): string[]; + + export interface ReadFileOptions { + encoding?: buffer.Encoding | 'buffer'; + flag?: string; + } + + /** + * Asynchronously reads the entire contents of a file. + */ + export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; + export function readFile(file: string | Buffer | number, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding }), callback: (err: NodeJS.ErrnoException | null, data: string) => void): void; + export function readFile(file: string | Buffer | number, options: 'buffer' | ReadFileOptions, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; + + /** + * Synchronous version of `fs.readFile`. + */ + export function readFileSync(file: string | Buffer | number): Buffer; + export function readFileSync(file: string | Buffer | number, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding })): string; + export function readFileSync(file: string | Buffer | number, options: 'buffer' | ReadFileOptions): Buffer; + + export interface ReadlinkOptions { + encoding?: buffer.Encoding | 'buffer'; + } + + /** + * Asynchronous readlink(2). + */ + export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void; + export function readlink(path: string | Buffer, options: 'buffer' | (ReadlinkOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void; + export function readlink(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void; + + /** + * Synchronous readlink(2). + */ + export function readlinkSync(path: string | Buffer): string; + export function readlinkSync(path: string | Buffer, options: 'buffer' | (ReadlinkOptions & { encoding: 'buffer' })): Buffer; + export function readlinkSync(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions): string; + + /** + * Synchronous version of `fs.read()`. + */ + export function readSync(fd: number, buffer: string | Buffer, offset: number, length: number, position: number): number; + + export interface RealpathOptions { + encoding?: buffer.Encoding | 'buffer'; + } + + /** + * Asynchronous realpath(3). May use `process.cwd` to resolve relative paths. + * + * Only paths that can be converted to UTF8 strings are supported. + */ + export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void; + export function realpath(path: string | Buffer, options: 'buffer' | (RealpathOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void; + export function realpath(path: string | Buffer, options: buffer.Encoding | RealpathOptions, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void; + + /** + * Synchronous realpath(3). Returns the resolved path. + * + * Only paths that can be converted to UTF8 strings are supported. + */ + export function realpathSync(path: string | Buffer): string; + export function realpathSync(path: string | Buffer, options: 'buffer' | (RealpathOptions & { encoding: 'buffer' })): Buffer; + export function realpathSync(path: string | Buffer, options: buffer.Encoding | RealpathOptions): string; + + /** + * Asynchronous rename(2). + */ + export function rename(oldPath: string | Buffer, newPath: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous rename(2). + */ + export function renameSync(oldPath: string | Buffer, newPath: string | Buffer): void; + + /** + * Asynchronous rmdir(2). + */ + export function rmdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous rmdir(2). + */ + export function rmdirSync(path: string | Buffer): void; + + /** + * Asynchronous stat(2). + * + * In case of an error, the `err.code` will be one of Common System Errors. + * + * Using `fs.stat()` to check for the existence of a file before calling `fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Instead, user code should open/read/write the file directly and handle the error raised if the file is not available. + * + * To check if a file exists without manipulating it afterwards, `fs.access()` is recommended. + */ + export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + + /** + * Synchronous stat(2). + */ + export function statSync(path: string | Buffer): Stats; + + /** + * Asynchronous symlink(2). The type argument is only available on Windows (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. When using `'junction'`, the target argument will automatically be normalized to absolute path. + */ + export function symlink(target: string | Buffer, path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function symlink(target: string | Buffer, path: string | Buffer, type: 'dir' | 'file' | 'junction', callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous symlink(2). + */ + export function symlinkSync(target: string | Buffer, path: string | Buffer, type?: 'dir' | 'file' | 'junction'): void; + + /** + * Asynchronous truncate(2). + */ + export function truncate(path: string | Buffer, len: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous truncate(2). + */ + export function truncateSync(path: string | Buffer, len?: number): void; + + /** + * Asynchronous unlink(2). + */ + export function unlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous unlink(2). + */ + export function unlinkSync(path: string | Buffer): void; + + /** + * Stop watching for changes on `filename`. If `listener` is specified, only that particular listener is removed. Otherwise, _all_ listeners are removed and you have effectively stopped watching `filename`. + * + * Calling `fs.unwatchFile()` with a filename that is not being watched is a no-op, not an error. + * + * Note: `fs.watch()` is more efficient than `fs.watchFile()` and `fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()` and `fs.unwatchFile()` when possible. + */ + export function unwatchFile(filename: string | Buffer, listener?: WatchListener): void; + + /** + * Change file timestamps of the file referenced by the supplied path. + * + * Note: the arguments `atime` and `mtime` of the following related functions follow these rules: + * + * - The value should be a Unix timestamp in seconds. For example, `Date.now()` returns milliseconds, so it should be divided by 1000 before passing it in. + * If the value is a numeric string like `'123456789'`, the value will get converted to the corresponding number. + * If the value is `NaN` or `Infinity`, the value will get converted to `Date.now() / 1000`. + */ + export function utimes(path: string | Buffer, atime: number, mtime: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous version of `fs.utimes()`. + */ + export function utimesSync(path: string | Buffer, atime: number, mtime: number): void; + + export interface WatchOptions { + /** + * Indicates whether the process should continue to run as long as files are being watched. default = `true`. + */ + persistent?: boolean; + /** + * Indicates whether all subdirectories should be watched, or only the current directory. The applies when a directory is specified, and only on supported platforms (See Caveats). default = `false`. + */ + recursive?: boolean; + /** + * Specifies the character encoding to be used for the filename passed to the listener. default = `'utf8'`. + */ + encoding?: buffer.Encoding; + } + + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory. The returned object is a `fs.FSWatcher`. + * + * Please note the listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but they are not the same thing. + */ + export function watch(filename: string | Buffer): FSWatcher; + export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions): FSWatcher; + export function watch(filename: string | Buffer, listener: WatchListener): FSWatcher; + export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions, listener: WatchListener): FSWatcher; + + export interface WatchFileOptions { + /** + * Indicates whether the process should continue to run as long as files are being watched + */ + persistent: boolean; + /** + * Indicates how often the target should be polled in milliseconds. The default is `5007`. + */ + interval: number; + } + + /** + * Watch for changes on filename. The callback listener will be called each time the file is accessed. + * + * Note: when an `fs.watchFile` operation results in an `ENOENT` error, it will invoke the listener once, with all the fields zeroed (or, for dates, the Unix Epoch). In Windows, `blksize` and `blocks` fields will be `undefined`, instead of zero. If the file is created later on, the listener will be called again, with the latest stat objects. + * + * Note: `fs.watch()` is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible. + */ + export function watchFile(filename: string | Buffer, listener: (curr: Stats, prev: Stats) => void): void; + export function watchFile(filename: string | Buffer, options: WatchFileOptions, listener: (curr: Stats, prev: Stats) => void): void; + + /** + * Write `buffer` to the file specified by `fd`. + * + * `offset` and `length` determine the part of the buffer to be written. + * + * `position` refers to the offset from the beginning of the file where this data should be written. If `typeof position !== 'number'`, the data will be written at the current position. See pwrite(2). + * + * Note that it is unsafe to use `fs.write` multiple times on the same file without waiting for the callback. For this scenario, `fs.createWriteStream` is strongly recommended. + * + * On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file. + */ + export function write(fd: number, buffer: string | Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: string | Buffer, offset: number, length: number, position: number, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: Buffer) => void): void; + export function write(fd: number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; + export function write(fd: number, data: string | Buffer, position: number, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; + export function write(fd: number, data: string | Buffer, position: number, encoding: buffer.Encoding, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; + + export interface WriteFileOptions { + encoding?: buffer.Encoding; + mode?: number; + flag?: string; + } + + /** + * Asynchronously writes data to a file, replacing the file if it already exists. + * + * Note that it is unsafe to use `fs.writeFile` multiple times on the same file without waiting for the callback. For this scenario, `fs.createWriteStream` is strongly recommended. + * + * Note: If a file descriptor is specified as the `file`, it will not be closed automatically. + */ + export function writeFile(file: string | Buffer | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function writeFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | WriteFileOptions, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * The synchronous version of `fs.writeFile()`. + */ + export function writeFileSync(file: string | Buffer | number, data: string | Buffer, options?: buffer.Encoding | WriteFileOptions): void; + + /** + * Synchronous `fs.write`. + */ + export function writeSync(fd: number, buffer: string | Buffer, offset: number, length: number, position?: number): void; + export function writeSync(fd: number, data: string | Buffer, position?: number, encoding?: buffer.Encoding): void; +} + +declare module "path" { + + /** + * A parsed path object generated by path.parse() or consumed by path.format(). + */ + export interface ParsedPath { + /** + * The root of the path such as '/' or 'c:\' + */ + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; + } + + /** + * Normalize a string path, reducing '..' and '.' parts. + * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. + * + * @param p string path to normalize. + */ + export function normalize(p: string): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths string paths to join. + */ + export function join(...paths: string[]): string; + /** + * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. + * + * Starting from leftmost {from} paramter, resolves {to} to an absolute path. + * + * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. + * + * @param pathSegments string paths to join. Non-string arguments are ignored. + */ + export function resolve(...pathSegments: string[]): string; + /** + * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. + * + * @param path path to test. + */ + export function isAbsolute(path: string): boolean; + /** + * Solve the relative path from {from} to {to}. + * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. + * + * @param from + * @param to + */ + export function relative(from: string, to: string): string; + /** + * Return the directory name of a path. Similar to the Unix dirname command. + * + * @param p the path to evaluate. + */ + export function dirname(p: string): string; + /** + * Return the last portion of a path. Similar to the Unix basename command. + * Often used to extract the file name from a fully qualified path. + * + * @param p the path to evaluate. + * @param ext optionally, an extension to remove from the result. + */ + export function basename(p: string, ext?: string): string; + /** + * Return the extension of the path, from the last '.' to end of string in the last portion of the path. + * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string + * + * @param p the path to evaluate. + */ + export function extname(p: string): string; + /** + * The platform-specific file separator. '\\' or '/'. + */ + export var sep: string; + /** + * The platform-specific file delimiter. ';' or ':'. + */ + export var delimiter: string; + /** + * Returns an object from a path string - the opposite of format(). + * + * @param pathString path to evaluate. + */ + export function parse(pathString: string): ParsedPath; + /** + * Returns a path string from an object - the opposite of parse(). + * + * @param pathString path to evaluate. + */ + export function format(pathObject: ParsedPath): string; + + export module posix { + export function normalize(p: string): string; + export function join(...paths: string[]): string; + export function resolve(...pathSegments: string[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } + + export module win32 { + export function normalize(p: string): string; + export function join(...paths: string[]): string; + export function resolve(...pathSegments: string[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } +} + +declare module "string_decoder" { + import * as buffer from "buffer"; + + export class StringDecoder { + /** + * @param encoding The character encoding the `StringDecoder` will use. Defaults to `'utf8'`. + */ + constructor(encoding?: buffer.Encoding); + /** + * Returns a decoded string, ensuring that any incomplete multibyte characters at the end of the `Buffer` are omitted from the returned string and stored in an internal buffer for the next call to `stringDecoder.write()` or `stringDecoder.end()`. + * + * @param buffer A `Buffer` containing the bytes to decode. + */ + write(buffer: Buffer): string; + /** + * Returns any remaining input stored in the internal buffer as a string. Bytes representing incomplete UTF-8 and UTF-16 characters will be replaced with substitution characters appropriate for the character encoding. + * + * If the `buffer` argument is provided, one final call to `stringDecoder.write()` is performed before returning the remaining input. + * + * @param buffer A `Buffer` containing the bytes to decode. + */ + end(buffer?: Buffer): string; + } +} + +declare module "tls" { + import * as crypto from "crypto"; + import * as net from "net"; + import * as stream from "stream"; + + export var CLIENT_RENEG_LIMIT: number; + export var CLIENT_RENEG_WINDOW: number; + export var SLAB_BUFFER_SIZE: number; + export var DEFAULT_CIPHERS: string; + export var DEFAULT_ECDH_CURVE: string; + + export class Server extends net.Server { + /** + * The `server.addContext()` method adds a secure context that will be used if the client request's SNS hostname matches the supplied `hostname` (or wildcard). + * + * @param hostname A SNI hostname or wildcard (e.g. `'*'`) + * @param options An object containing any of the possible properties from the `tls.createSecureContext()` options arguments + */ + addContext(hostName: string, options: SecureContextOptions): void; + /** + * Returns a `Buffer` instance holding the keys currently used for encryption/decryption of the TLS Session Tickets. + */ + getTicketKeys(): Buffer; + /** + * Updates the keys for encryption/decryption of the TLS Session Tickets. + * + * Note: The key's Buffer should be 48 bytes long. See ticketKeys option in tls.createServer for more information on how it is used. + * + * Note: Changes to the ticket keys are effective only for future server connections. Existing or currently pending server connections will use the previous keys. + */ + setTicketKeys(keys: Buffer): void; + /** + * Returns the current number of concurrent connections on the server. + */ + connections: number; + } + + export interface Certificate { + /** + * Country code. + */ + C: string; + /** + * Street. + */ + ST: string; + /** + * Locality. + */ + L: string; + /** + * Organization. + */ + O: string; + /** + * Organizational unit. + */ + OU: string; + /** + * Common name. + */ + CN: string; + } + + export interface Cipher { + /** + * The cipher name. + */ + name: string; + /** + * SSL/TLS protocol version. + */ + version: string; + } + + export interface EphemeralKeyInfo { + type: 'DH' | 'ECDH'; + name?: string; + size: number; + } + + export interface PeerCertificate { + subject: Certificate; + issuerInfo: Certificate; + issuer: Certificate; + raw: Buffer; + valid_from: string; + valid_to: string; + fingerprint: string; + serialNumber: string; + } + + export interface TLSSocketOptions { + /** + * An optional TLS context object from `tls.createSecureContext()`. + */ + secureContext?: SecureContext; + /** + * If true the TLS socket will be instantiated in server-mode. Defaults to `false`. + */ + isServer?: boolean; + /** + * An optional net.Server instance. + */ + server?: net.Server; + /** + * Optional, see `tls.createServer()`. + */ + requestCert?: boolean; + /** + * Optional, see `tls.createServer()`. + */ + rejectUnauthorized?: boolean; + /** + * Optional, see `tls.createServer()`. + */ + NPNProtocols?: string[] | Buffer; + /** + * Optional, see `tls.createServer()`. + */ + ALPNProtocols?: string[] | Buffer; + /** + * Optional, see `tls.createServer()`. + */ + SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void; + /** + * An optional Buffer instance containing a TLS session. + */ + session?: Buffer; + /** + * If `true`, specifies that the OCSP status request extension will be added to the client hello and an 'OCSPResponse' event will be emitted on the socket before establishing a secure communication + */ + requestOCSP?: boolean; + } + + export interface RenegotiateOptions { + rejectUnauthorized?: boolean; + requestCert?: boolean; + } + + export class TLSSocket extends net.Socket { + /** + * Construct a new `tls.TLSSocket` object from an existing TCP socket. + */ + constructor(socket: net.Socket, options?: TLSSocketOptions); + /** + * Returns `true` if the peer certificate was signed by one of the CAs specified when creating the `tls.TLSSocket` instance, otherwise `false`. + */ + authorized: boolean; + /** + * Returns the reason why the peer's certificate was not been verified. This property is set only when `tlsSocket.authorized === false`. + */ + authorizationError?: Error; + /** + * Always returns `true`. This may be used to distinguish TLS sockets from regular `net.Socket` instances. + */ + encrypted: true; + /** + * Returns an object representing the cipher name and the SSL/TLS protocol version that first defined the cipher. + */ + getCipher(): Cipher; + /** + * Returns an object representing the type, name, and size of parameter of an ephemeral key exchange in Perfect Forward Secrecy on a client connection. It returns an empty object when the key exchange is not ephemeral. As this is only supported on a client socket; `null` is returned if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The `name` property is available only when type is `'ECDH'`. + */ + getEphemeralKeyInfo(): EphemeralKeyInfo; + /** + * Returns an object representing the peer's certificate. The returned object has some properties corresponding to the fields of the certificate. + * + * @param detailed Specify `true` to request that the full certificate chain with the `issuer` property be returned; false to return only the top certificate without the `issuer` property. + */ + getPeerCertificate(detailed?: boolean): PeerCertificate; + /** + * Returns a string containing the negotiated SSL/TLS protocol version of the current connection. The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process. The value `null` will be returned for server sockets or disconnected client sockets. + */ + getProtocol(): string | null; + /** + * Returns the ASN.1 encoded TLS session or `undefined` if no session was negotiated. Can be used to speed up handshake establishment when reconnecting to the server. + */ + getSession(): Buffer | undefined; + /** + * Returns the TLS session ticket or `undefined` if no session was negotiated. + * + * Note: This only works with client TLS sockets. Useful only for debugging, for session reuse `provide` session option to `tls.connect()`. + */ + getTLSTicket(): Buffer | undefined; + /** + * Returns the string representation of the local IP address. + */ + localAddress: string; + /** + * Returns the numeric representation of the local port. + */ + localPort: number; + /** + * Returns the string representation of the remote IP address. For example, `'74.125.127.100'` or `'2001:4860:a005::68'`. + */ + remoteAddress: string; + /** + * Returns the string representation of the remote IP family. `'IPv4'` or `'IPv6'`. + */ + remoteFamily: string; + /** + * The numeric representation of the remote port. For example, 443. + */ + remotePort: number; + /** + * The `tlsSocket.renegotiate()` method initiates a TLS renegotiation process. + * + * Note: This method can be used to request a peer's certificate after the secure connection has been established. + * + * Note: When running as the server, the socket will be destroyed with an error after `handshakeTimeout` timeout. + */ + renegotiate(options: RenegotiateOptions, callback: (err: Error | null) => any): any; + /** + * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size. Returns `true` if setting the limit succeeded; false otherwise. + * + * Smaller fragment sizes decrease the buffering latency on the client: larger fragments are buffered by the TLS layer until the entire fragment is received and its integrity is verified; large fragments can span multiple roundtrips and their processing can be delayed due to packet loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, which may decrease overall server throughput. + * + * @param size The maximum TLS fragment size. Defaults to `16384`. The maximum value is `16384`. + */ + setMaxSendFragment(size: number): boolean; + } + + export interface ConnectOptions { + /** + * Host the client should connect to. + */ + host?: string; + /** + * Port the client should connect to. + */ + port?: number | string; + /** + * Establish secure connection on a given socket rather than creating a new socket. If this option is specified, `host` and `port` are ignored. + */ + socket?: net.Socket; + /** + * Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored. + */ + path?: string; + /** + * A `string` or `Buffer` containing the private key, certificate, and CA certs of the client in PFX or PKCS12 format. + */ + pfx?: string | Buffer; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s containing the private key of the client in PEM format. + */ + key?: string | Buffer | string[] | Buffer[]; + /** + * A string containing the passphrase for the private key or pfx. + */ + passphrase?: string; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s containing the certificate key of the client in PEM format. + */ + cert?: string | Buffer | string[] | Buffer[]; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. + */ + ca?: string | Buffer | string[] | Buffer[]; + /** + * A string describing the ciphers to use or exclude, separated by `:`. Uses the same default cipher suite as `tls.createServer()`. + */ + ciphers?: string; + /** + * If true, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails; `err.code` contains the OpenSSL error code. Defaults to `true`. + */ + rejectUnauthorized?: boolean; + /** + * An array of strings or `Buffer`s containing supported NPN protocols. `Buffer`s should have the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the first byte is the length of the next protocol name. Passing an array is usually much simpler, e.g. `['hello', 'world']`. + */ + NPNProtocols?: string[] | Buffer[]; + /** + * An array of strings or `Buffer`s containing the supported ALPN protocols. `Buffer`s should have the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the first byte is the length of the next protocol name. Passing an array is usually much simpler: `['hello', 'world']`.) + */ + ALPNProtocols?: string[] | Buffer[]; + /** + * Server name for the SNI (Server Name Indication) TLS extension. + */ + servername?: string; + /** + * A callback function to be used when checking the server's hostname against the certificate. This should throw an error if verification fails. The method should return `undefined` if the `servername` and `cert` are verified. + */ + checkServerIdentity?: (servername: string, cert: Buffer) => void; + /** + * The SSL method to use, e.g., `SSLv3_method` to force SSL version 3. The possible values depend on the version of OpenSSL installed in the environment and are defined in the constant SSL_METHODS. + */ + secureProtocol?: string; + /** + * An optional TLS context object as returned by from `tls.createSecureContext( ... )`. It can be used for caching client certificates, keys, and CA certificates. + */ + secureContext?: SecureContext; + /** + * A `Buffer` instance, containing TLS session. + */ + session?: Buffer; + /** + * Minimum size of the DH parameter in bits to accept a TLS connection. When a server offers a DH parameter with a size less than `minDHSize`, the TLS connection is destroyed and an error is thrown. Defaults to `1024`. + */ + minDHSize?: number; + } + + export interface SecureContextOptions { + /** + * A string or `Buffer` holding the PFX or PKCS12 encoded private key, certificate, and CA certificates. + */ + pfx?: string | Buffer; + /** + * The private key of the server in PEM format. To support multiple keys using different algorithms, an array can be provided either as an array of key strings or as an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys. + */ + key?: string | string[] | Buffer | Array<{ pem: string | string[] | Buffer, passphrase: string }>; + /** + * A string containing the passphrase for the private key or pfx. + */ + passphrase?: string; + /** + * A string containing the PEM encoded certificate. + */ + cert?: string | Buffer | string[] | Buffer[]; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If omitted, several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. + */ + ca?: string | Buffer | string[] | Buffer[]; + /** + * Either a string or array of strings of PEM encoded CRLs (Certificate Revocation List). + */ + crl?: string | string[]; + /** + * A string describing the ciphers to use or exclude. Consult https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT for details on the format. + */ + ciphers?: string; + /** + * If `true`, when a cipher is being selected, the server's preferences will be used instead of the client preferences. + */ + honorCipherOrder?: boolean; + } + + export interface CreateServerOptions { + /** + * A `string` or `Buffer` containing the private key, certificate and CA certs of the server in PFX or PKCS12 format. (Mutually exclusive with the `key`, `cert`, and `ca` options.) + */ + pfx?: string | Buffer; + /** + * The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys. + */ + key?: string | string[] | Buffer | Array<{ pem: string | string[] | Buffer, passphrase: string }>; + /** + * A string containing the passphrase for the private key or pfx. + */ + passphrase?: string; + /** + * A string containing the PEM encoded certificate. + */ + cert?: string | Buffer | string[] | Buffer[]; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If omitted, several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. + */ + ca?: string | Buffer | string[] | Buffer[]; + /** + * Either a string or array of strings of PEM encoded CRLs (Certificate Revocation List). + */ + crl?: string | string[]; + /** + * A string describing the ciphers to use or exclude, separated by `:`. + */ + ciphers?: string; + /** + * A string describing a named curve to use for ECDH key agreement or false to disable ECDH. Defaults to `prime256v1` (NIST P-256). Use crypto.getCurves() to obtain a list of available curve names. On recent releases, `openssl ecparam -list_curves` will also display the name and description of each available elliptic curve. + */ + ecdhCurve?: string; + /** + * A string or `Buffer` containing Diffie Hellman parameters, required for Perfect Forward Secrecy. Use `openssl dhparam` to create the parameters. The key length must be greater than or equal to 1024 bits, otherwise an error will be thrown. It is strongly recommended to use 2048 bits or larger for stronger security. If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. + */ + dhparam?: string | Buffer; + /** + * Abort the connection if the SSL/TLS handshake does not finish in the specified number of milliseconds. Defaults to `120` seconds. A `'clientError'` is emitted on the `tls.Server` object whenever a handshake times out. + */ + handshakeTimeout?: number; + /** + * When choosing a cipher, use the server's preferences instead of the client preferences. Defaults to `true`. + */ + honorCipherOrder?: boolean; + /** + * If `true` the server will request a certificate from clients that connect and attempt to verify that certificate. Defaults to `false`. + */ + requestCert?: boolean; + /** + * If `true` the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if `requestCert` is `true`. Defaults to `false`. + */ + rejectUnauthorized?: boolean; + /** + * An array of strings or a `Buffer` naming possible NPN protocols. (Protocols should be ordered by their priority.) + */ + NPNProtocols?: string[] | Buffer; + /** + * An array of strings or a `Buffer` naming possible ALPN protocols. (Protocols should be ordered by their priority.) When the server receives both NPN and ALPN extensions from the client, ALPN takes precedence over NPN and the server does not send an NPN extension to the client. + */ + ALPNProtocols?: string[] | Buffer; + /** + * A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: `servername` and `cb`. `SNICallback` should invoke `cb(null, ctx)`, where `ctx` is a SecureContext instance. (`tls.createSecureContext(...)` can be used to get a proper SecureContext.) If `SNICallback` wasn't provided the default callback with high-level API will be used (see below). + */ + SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void; + /** + * An integer specifying the number of seconds after which the TLS session identifiers and TLS session tickets created by the server will time out. See SSL_CTX_set_timeout for more details. + */ + sessionTimeout?: number; + /** + * A 48-byte `Buffer` instance consisting of a 16-byte prefix, a 16-byte HMAC key, and a 16-byte AES key. This can be used to accept TLS session tickets on multiple instances of the TLS server. Note that this is automatically shared between `cluster` module workers. + */ + ticketKeys?: Buffer; + /** + * A string containing an opaque identifier for session resumption. If `requestCert` is true, the default is a 128 bit truncated SHA1 hash value generated from the command-line. Otherwise, a default is not provided. + */ + sessionIdContext?: string; + /** + * The SSL method to use, e.g., `SSLv3_method` to force SSL version 3. The possible values depend on the version of OpenSSL installed in the environment and are defined in the constant SSL_METHODS. + */ + secureProtocol?: string; + } + + export interface SecureContext { + context: any; + } + + /** + * Creates a new tls.Server. The secureConnectionListener, if provided, is automatically set as a listener for the `'secureConnection'` event. + */ + export function createServer(options: CreateServerOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; + + /** + * Creates a new client connection to the given `port` and `host` or `options.port` and `options.host`. (If `host` is omitted, it defaults to `localhost`.) + */ + export function connect(options: ConnectOptions, callback?: () => void): TLSSocket; + export function connect(port: number, options?: ConnectOptions, callback?: () => void): TLSSocket; + export function connect(port: number, host?: string, options?: ConnectOptions, callback?: () => void): TLSSocket; + + /** + * The `tls.createSecureContext()` method creates a credentials object. + * + * If the `'ca'` option is not given, then Node.js will use the default publicly trusted list of CAs as given in http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt. + */ + export function createSecureContext(options: SecureContextOptions): SecureContext; + + /** + * Returns an array with the names of the supported SSL ciphers. + */ + export function getCiphers(): string[]; +} + +declare module "crypto" { + import * as stream from "stream"; + + export var constants: { + defaultCipherList: string; + defaultCoreCipherList: string; + [key: string]: string | number; + } + + export function getCiphers(): string[]; + export function getCurves(): string[]; + export function getHashes(): string[]; + + export class Certificate { + constructor(); + exportChallenge(spkac: string | Buffer, encoding?: string): string; + exportPublicKey(spkac: string | Buffer, encoding?: string): Buffer; + verifySpkac(spkac: Buffer): boolean; + } + + export function createHash(algorithm: string): Hash; + + export class Hash extends stream.Transform { + update(data: string | Buffer, input_encoding?: string): Hash; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): string; + digest(): Buffer; + } + + export function createHmac(algorithm: string, key: string | Buffer): Hmac; + + export class Hmac extends stream.Transform { + update(data: string | Buffer, input_encoding?: string): Hmac; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): string; + digest(): Buffer; + } + + export function createCipher(algorithm: string, password: string | Buffer): Cipher; + export function createCipheriv(algorithm: string, key: string | Buffer, iv: string | Buffer): Cipher; + + export class Cipher extends stream.Transform { + update(data: Buffer): Buffer; + update(data: string, input_encoding: "utf8" | "ascii" | "binary" | "latin1"): Buffer; + update(data: Buffer, input_encoding: any, output_encoding: "binary" | "latin1" | "base64" | "hex"): string; + update(data: string, input_encoding: "utf8" | "ascii" | "binary" | "latin1", output_encoding: "binary" | "latin1" | "base64" | "hex"): string; + final(): Buffer; + final(output_encoding: string): string; + setAAD(buffer: Buffer): void; + setAutoPadding(auto_padding: boolean): void; + getAuthTag(): Buffer; + } + + export function createDecipher(algorithm: string, password: string | Buffer): Decipher; + export function createDecipheriv(algorithm: string, key: string | Buffer, iv: string | Buffer): Decipher; + + export class Decipher extends stream.Transform { + update(data: Buffer): Buffer; + update(data: string, input_encoding: "binary" | "latin1" | "base64" | "hex"): Buffer; + update(data: Buffer, input_encoding: any, output_encoding: "utf8" | "ascii" | "binary" | "latin1"): string; + update(data: string, input_encoding: "binary" | "latin1" | "base64" | "hex", output_encoding: "utf8" | "ascii" | "binary" | "latin1"): string; + final(): Buffer; + final(output_encoding: string): string; + setAAD(buffer: Buffer): void; + setAutoPadding(auto_padding: boolean): void; + setAuthTag(tag: Buffer): void; + } + + export function createSign(algorithm: string): Signer; + + export class Signer extends stream.Writable { + update(data: string | Buffer): void; + sign(private_key: string): Buffer; + sign(private_key: string, output_format: string): string; + } + + export function createVerify(algorith: string): Verify; + + export class Verify extends stream.Writable { + update(data: string | Buffer): void; + verify(object: string, signature: string, signature_format?: string): boolean; + } + + export function createDiffieHellman(prime: number, prime_encoding?: string, generator?: number | string | Buffer, generator_encoding?: string): DiffieHellman; + export function createDiffieHellman(prime_length: number, generator?: number | string | Buffer): DiffieHellman; + export function getDiffieHellman(group_name: string): DiffieHellman; + + export class DiffieHellman { + verifyError: number; + computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; + generateKeys(encoding?: string): string; + getPrime(encoding?: string): string; + getGenerator(encoding?: string): string; + getPublicKey(encoding?: string): string; + getPrivateKey(encoding?: string): string; + setPublicKey(public_key: string, encoding?: string): void; + setPrivateKey(public_key: string, encoding?: string): void; + } + + export function createECDH(curve_name: string): ECDH; + + export class ECDH { + computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; + generateKeys(encoding?: string, format?: string): string; + getPrivateKey(encoding?: string): string; + getPublicKey(encoding?: string, format?: string): string; + setPrivateKey(private_key: string, encoding?: string): void; + } + + export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => void): void; + export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => void): void; + + export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number): Buffer; + export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer; + + export function randomBytes(size: number): Buffer; + export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; + + export function pseudoRandomBytes(size: number): Buffer; + export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; + + export interface RsaKey { + key: string; + passphrase?: string, + padding?: number; + } + + export function timingSafeEqual(a: Buffer, b: Buffer): boolean; + export function publicEncrypt(public_key: string | RsaKey, buffer: Buffer): Buffer; + export function privateEncrypt(private_key: string | RsaKey, buffer: Buffer): Buffer; + export function publicDecrypt(public_key: string | RsaKey, buffer: Buffer): Buffer; + export function privateDecrypt(private_key: string | RsaKey, buffer: Buffer): Buffer; + + export function setEngine(engine: string, flags?: number): void; +} + +declare module "stream" { + import * as events from "events"; + + export class Stream extends events.EventEmitter { + pipe(destination: T, options?: { end?: boolean; }): T; + } + + export interface ReadableOptions { + highWaterMark?: number; + encoding?: string; + objectMode?: boolean; + read?: (size?: number) => any; + } + + export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { + readable: boolean; + constructor(opts?: ReadableOptions); + _read(size: number): void; + read(size?: number): any; + isPaused(): boolean; + setEncoding(encoding: string): this; + pause(): this; + resume(): this; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; + } + + export interface WritableOptions { + highWaterMark?: number; + decodeStrings?: boolean; + objectMode?: boolean; + write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; + writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; + } + + export class Writable extends events.EventEmitter implements NodeJS.WritableStream { + writable: boolean; + constructor(opts?: WritableOptions); + setDefaultEncoding(encoding: string): this; + _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean; + readableObjectMode?: boolean; + writableObjectMode?: boolean; + } + + // Note: Duplex extends both Readable and Writable. + export class Duplex extends Readable implements NodeJS.ReadWriteStream { + writable: boolean; + constructor(opts?: DuplexOptions); + setDefaultEncoding(encoding: string): this; + _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export interface TransformOptions extends ReadableOptions, WritableOptions { + write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; + writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; + } + + // Note: Transform lacks the _read and _write methods of Readable/Writable. + export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { + readable: boolean; + writable: boolean; + constructor(opts?: TransformOptions); + _transform(chunk: any, encoding: string, callback: Function): void; + _flush(callback: Function): void; + read(size?: number): any; + setEncoding(encoding: string): this; + setDefaultEncoding(encoding: string): this; + isPaused(): boolean; + pause(): this; + resume(): this; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export class PassThrough extends Transform { } +} + +declare module "util" { + /** + * The `util.debuglog()` method is used to create a function that conditionally writes debug messages to `stderr` based on the existence of the `NODE_DEBUG` environment variable. If the `section` name appears within the value of that environment variable, then the returned function operates similar to console.error(). If not, then the returned function is a no-op. + */ + export function debuglog(section: string): (msg: any, ...args: any[]) => void; + + export interface InspectOptions { + /** + * If `true`, the `object`'s non-enumerable symbols and properties will be included in the formatted result. Defaults to `false`. + */ + showHidden?: boolean; + /** + * Specifies the number of times to recurse while formatting the `object`. This is useful for inspecting large complicated objects. Defaults to `2`. To make it recurse indefinitely pass `null`. + */ + depth?: number | null; + /** + * If `true`, the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable, see "Customizing util.inspect colors". + */ + colors?: boolean; + /** + * If `false`, then custom `inspect(depth, opts)` functions exported on the object being inspected will not be called. Defaults to `true`. + */ + customInspect?: boolean; + /** + * If `true`, then objects and functions that are `Proxy` objects will be introspected to show their `target` and `handler` objects. Defaults to `false`. + */ + showProxy?: boolean; + /** + * Specifies the maximum number of array and `TypedArray` elements to include when formatting. Defaults to `100`. Set to `null` to show all array elements. Set to `0` or negative to show no array elements. + */ + maxArrayLength?: number | null; + /** + * The length at which an object's keys are split across multiple lines. Set to `Infinity` to format an object as a single line. Defaults to `60` for legacy compatibility. + */ + breakLength?: number; + } + + /** + * The `util.inspect()` method returns a string representation of object that is primarily useful for debugging. + */ + export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string; + export function inspect(object: any, options: InspectOptions): string; + + export namespace inspect { + export var colors: { + bold: [number, number]; + italic: [number, number]; + underline: [number, number]; + inverse: [number, number]; + white: [number, number]; + grey: [number, number]; + black: [number, number]; + blue: [number, number]; + cyan: [number, number]; + green: [number, number]; + magenta: [number, number]; + red: [number, number]; + yellow: [number, number]; + } + + export var styles: { + special: string; + number: string; + boolean: string; + undefined: string; + null: string; + string: string; + symbol: string; + date: string; + regexp: string; + }; + + export var custom: symbol; + } + + /** + * The `util.deprecate()` method wraps the given function or class in such a way that it is marked as deprecated. + */ + export function deprecate(fn: T, string: string): T; + + /** + * The `util.format()` method returns a formatted string using the first argument as a printf-like format. + */ + export function format(format: any, ...param: any[]): string; + + /** + * Inherit the prototype methods from one constructor into another. The prototype of constructor will be set to a new object created from superConstructor. + */ + export function inherits(constructor: any, superConstructor: any): void; + + /** + * Deprecated predecessor of `console.error`. + * + * @deprecated + */ + export function debug(string: string): void; + + /** + * Deprecated predecessor of `console.error`. + * + * @deprecated + */ + export function error(...strings: string[]): void; + + /** + * Internal alias for `Array.isArray`. + * + * @deprecated + */ + export function isArray(object: any): object is any[]; + + /** + * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isBoolean(object: any): object is boolean; + + /** + * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isBuffer(object: any): object is Buffer; + + /** + * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isDate(object: any): object is Date; + + /** + * Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isError(object: any): object is Error; + + /** + * Returns `true` if the given `object` is a `Function`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isFunction(object: any): object is Function; + + /** + * Returns `true` if the given `object` is strictly `null`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isNull(object: any): object is null; + + /** + * Returns `true` if the given `object` is `null` or `undefined`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isNullOrUndefined(object: any): object is null | undefined; + + /** + * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isNumber(object: any): object is number; + + /** + * Returns true if the given `object` is strictly an `Object` and not a `Function`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isObject(object: any): object is Object; + + /** + * Returns true if the given `object` is a primitive type. Otherwise, returns `false`. + * + * @deprecated + */ + export function isPrimitive(object: any): object is string | number | boolean | null | undefined; + + /** + * Returns true if the given `object` is a `RegExp`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isRegExp(object: any): object is RegExp; + + /** + * Returns true if the given `object` is a `String`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isString(object: any): object is string; + + /** + * Returns true if the given `object` is a `Symbol`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isSymbol(object: any): object is symbol; + + /** + * Returns true if the given `object` is `undefined`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isUndefined(object: any): object is symbol; + + /** + * The `util.log()` method prints the given `string` to `stdout` with an included timestamp. + * + * @deprecated + */ + export function log(string: string): void; + + /** + * Deprecated predecessor of `console.log`. + * + * @deprecated + */ + export function print(strings: string[]): void; + + /** + * Deprecated predecessor of `console.log`. + * + * @deprecated + */ + export function puts(strings: string[]): void; + + /** + * The `util._extend()` method was never intended to be used outside of internal Node.js modules. The community found and used it anyway. + * + * It is deprecated and should not be used in new code. JavaScript comes with very similar built-in functionality through `Object.assign()`. + * + * @deprecated + */ + export function _extend(target: T, source: U): T & U; +} + +declare module "assert" { + function internal(value: any, message?: string): void; + namespace internal { + export class AssertionError implements Error { + name: string; + message: string; + actual: any; + expected: any; + operator: string; + generatedMessage: boolean; + + constructor(options?: { + message?: string; actual?: any; expected?: any; + operator?: string; stackStartFunction?: Function + }); + } + + export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; + export function ok(value: any, message?: string): void; + export function equal(actual: any, expected: any, message?: string): void; + export function notEqual(actual: any, expected: any, message?: string): void; + export function deepEqual(actual: any, expected: any, message?: string): void; + export function notDeepEqual(acutal: any, expected: any, message?: string): void; + export function strictEqual(actual: any, expected: any, message?: string): void; + export function notStrictEqual(actual: any, expected: any, message?: string): void; + export function deepStrictEqual(actual: any, expected: any, message?: string): void; + export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; + export var throws: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export var doesNotThrow: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export function ifError(value: any): void; + } + + export = internal; +} + +declare module "tty" { + import * as net from "net"; + + export function isatty(fd: number): boolean; + export interface ReadStream extends net.Socket { + isRaw: boolean; + setRawMode(mode: boolean): void; + isTTY: boolean; + } + export interface WriteStream extends net.Socket { + columns: number; + rows: number; + isTTY: boolean; + } +} + +declare module "domain" { + import * as events from "events"; + + export class Domain extends events.EventEmitter implements NodeJS.Domain { + run(fn: Function): void; + add(emitter: events.EventEmitter): void; + remove(emitter: events.EventEmitter): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; + members: any[]; + enter(): void; + exit(): void; + } + + export function create(): Domain; +} + +declare module "constants" { + export var E2BIG: number; + export var EACCES: number; + export var EADDRINUSE: number; + export var EADDRNOTAVAIL: number; + export var EAFNOSUPPORT: number; + export var EAGAIN: number; + export var EALREADY: number; + export var EBADF: number; + export var EBADMSG: number; + export var EBUSY: number; + export var ECANCELED: number; + export var ECHILD: number; + export var ECONNABORTED: number; + export var ECONNREFUSED: number; + export var ECONNRESET: number; + export var EDEADLK: number; + export var EDESTADDRREQ: number; + export var EDOM: number; + export var EEXIST: number; + export var EFAULT: number; + export var EFBIG: number; + export var EHOSTUNREACH: number; + export var EIDRM: number; + export var EILSEQ: number; + export var EINPROGRESS: number; + export var EINTR: number; + export var EINVAL: number; + export var EIO: number; + export var EISCONN: number; + export var EISDIR: number; + export var ELOOP: number; + export var EMFILE: number; + export var EMLINK: number; + export var EMSGSIZE: number; + export var ENAMETOOLONG: number; + export var ENETDOWN: number; + export var ENETRESET: number; + export var ENETUNREACH: number; + export var ENFILE: number; + export var ENOBUFS: number; + export var ENODATA: number; + export var ENODEV: number; + export var ENOENT: number; + export var ENOEXEC: number; + export var ENOLCK: number; + export var ENOLINK: number; + export var ENOMEM: number; + export var ENOMSG: number; + export var ENOPROTOOPT: number; + export var ENOSPC: number; + export var ENOSR: number; + export var ENOSTR: number; + export var ENOSYS: number; + export var ENOTCONN: number; + export var ENOTDIR: number; + export var ENOTEMPTY: number; + export var ENOTSOCK: number; + export var ENOTSUP: number; + export var ENOTTY: number; + export var ENXIO: number; + export var EOPNOTSUPP: number; + export var EOVERFLOW: number; + export var EPERM: number; + export var EPIPE: number; + export var EPROTO: number; + export var EPROTONOSUPPORT: number; + export var EPROTOTYPE: number; + export var ERANGE: number; + export var EROFS: number; + export var ESPIPE: number; + export var ESRCH: number; + export var ETIME: number; + export var ETIMEDOUT: number; + export var ETXTBSY: number; + export var EWOULDBLOCK: number; + export var EXDEV: number; + export var WSAEINTR: number; + export var WSAEBADF: number; + export var WSAEACCES: number; + export var WSAEFAULT: number; + export var WSAEINVAL: number; + export var WSAEMFILE: number; + export var WSAEWOULDBLOCK: number; + export var WSAEINPROGRESS: number; + export var WSAEALREADY: number; + export var WSAENOTSOCK: number; + export var WSAEDESTADDRREQ: number; + export var WSAEMSGSIZE: number; + export var WSAEPROTOTYPE: number; + export var WSAENOPROTOOPT: number; + export var WSAEPROTONOSUPPORT: number; + export var WSAESOCKTNOSUPPORT: number; + export var WSAEOPNOTSUPP: number; + export var WSAEPFNOSUPPORT: number; + export var WSAEAFNOSUPPORT: number; + export var WSAEADDRINUSE: number; + export var WSAEADDRNOTAVAIL: number; + export var WSAENETDOWN: number; + export var WSAENETUNREACH: number; + export var WSAENETRESET: number; + export var WSAECONNABORTED: number; + export var WSAECONNRESET: number; + export var WSAENOBUFS: number; + export var WSAEISCONN: number; + export var WSAENOTCONN: number; + export var WSAESHUTDOWN: number; + export var WSAETOOMANYREFS: number; + export var WSAETIMEDOUT: number; + export var WSAECONNREFUSED: number; + export var WSAELOOP: number; + export var WSAENAMETOOLONG: number; + export var WSAEHOSTDOWN: number; + export var WSAEHOSTUNREACH: number; + export var WSAENOTEMPTY: number; + export var WSAEPROCLIM: number; + export var WSAEUSERS: number; + export var WSAEDQUOT: number; + export var WSAESTALE: number; + export var WSAEREMOTE: number; + export var WSASYSNOTREADY: number; + export var WSAVERNOTSUPPORTED: number; + export var WSANOTINITIALISED: number; + export var WSAEDISCON: number; + export var WSAENOMORE: number; + export var WSAECANCELLED: number; + export var WSAEINVALIDPROCTABLE: number; + export var WSAEINVALIDPROVIDER: number; + export var WSAEPROVIDERFAILEDINIT: number; + export var WSASYSCALLFAILURE: number; + export var WSASERVICE_NOT_FOUND: number; + export var WSATYPE_NOT_FOUND: number; + export var WSA_E_NO_MORE: number; + export var WSA_E_CANCELLED: number; + export var WSAEREFUSED: number; + export var SIGHUP: number; + export var SIGINT: number; + export var SIGILL: number; + export var SIGABRT: number; + export var SIGFPE: number; + export var SIGKILL: number; + export var SIGSEGV: number; + export var SIGTERM: number; + export var SIGBREAK: number; + export var SIGWINCH: number; + export var SSL_OP_ALL: number; + export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; + export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; + export var SSL_OP_CISCO_ANYCONNECT: number; + export var SSL_OP_COOKIE_EXCHANGE: number; + export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; + export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; + export var SSL_OP_EPHEMERAL_RSA: number; + export var SSL_OP_LEGACY_SERVER_CONNECT: number; + export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; + export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; + export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; + export var SSL_OP_NETSCAPE_CA_DN_BUG: number; + export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; + export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NO_COMPRESSION: number; + export var SSL_OP_NO_QUERY_MTU: number; + export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; + export var SSL_OP_NO_SSLv2: number; + export var SSL_OP_NO_SSLv3: number; + export var SSL_OP_NO_TICKET: number; + export var SSL_OP_NO_TLSv1: number; + export var SSL_OP_NO_TLSv1_1: number; + export var SSL_OP_NO_TLSv1_2: number; + export var SSL_OP_PKCS1_CHECK_1: number; + export var SSL_OP_PKCS1_CHECK_2: number; + export var SSL_OP_SINGLE_DH_USE: number; + export var SSL_OP_SINGLE_ECDH_USE: number; + export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; + export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; + export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; + export var SSL_OP_TLS_D5_BUG: number; + export var SSL_OP_TLS_ROLLBACK_BUG: number; + export var ENGINE_METHOD_DSA: number; + export var ENGINE_METHOD_DH: number; + export var ENGINE_METHOD_RAND: number; + export var ENGINE_METHOD_ECDH: number; + export var ENGINE_METHOD_ECDSA: number; + export var ENGINE_METHOD_CIPHERS: number; + export var ENGINE_METHOD_DIGESTS: number; + export var ENGINE_METHOD_STORE: number; + export var ENGINE_METHOD_PKEY_METHS: number; + export var ENGINE_METHOD_PKEY_ASN1_METHS: number; + export var ENGINE_METHOD_ALL: number; + export var ENGINE_METHOD_NONE: number; + export var DH_CHECK_P_NOT_SAFE_PRIME: number; + export var DH_CHECK_P_NOT_PRIME: number; + export var DH_UNABLE_TO_CHECK_GENERATOR: number; + export var DH_NOT_SUITABLE_GENERATOR: number; + export var NPN_ENABLED: number; + export var RSA_PKCS1_PADDING: number; + export var RSA_SSLV23_PADDING: number; + export var RSA_NO_PADDING: number; + export var RSA_PKCS1_OAEP_PADDING: number; + export var RSA_X931_PADDING: number; + export var RSA_PKCS1_PSS_PADDING: number; + export var POINT_CONVERSION_COMPRESSED: number; + export var POINT_CONVERSION_UNCOMPRESSED: number; + export var POINT_CONVERSION_HYBRID: number; + export var O_RDONLY: number; + export var O_WRONLY: number; + export var O_RDWR: number; + export var S_IFMT: number; + export var S_IFREG: number; + export var S_IFDIR: number; + export var S_IFCHR: number; + export var S_IFBLK: number; + export var S_IFIFO: number; + export var S_IFSOCK: number; + export var S_IRWXU: number; + export var S_IRUSR: number; + export var S_IWUSR: number; + export var S_IXUSR: number; + export var S_IRWXG: number; + export var S_IRGRP: number; + export var S_IWGRP: number; + export var S_IXGRP: number; + export var S_IRWXO: number; + export var S_IROTH: number; + export var S_IWOTH: number; + export var S_IXOTH: number; + export var S_IFLNK: number; + export var O_CREAT: number; + export var O_EXCL: number; + export var O_NOCTTY: number; + export var O_DIRECTORY: number; + export var O_NOATIME: number; + export var O_NOFOLLOW: number; + export var O_SYNC: number; + export var O_SYMLINK: number; + export var O_DIRECT: number; + export var O_NONBLOCK: number; + export var O_TRUNC: number; + export var O_APPEND: number; + export var F_OK: number; + export var R_OK: number; + export var W_OK: number; + export var X_OK: number; + export var UV_UDP_REUSEADDR: number; +} + +declare module "module" { + export = NodeModule; +} + +declare module "process" { + export = process; +} + +declare module "timers" { + export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; + export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; + export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate; + export function clearTimeout(timeoutId: NodeJS.Timer): void; + export function clearInterval(intervalId: NodeJS.Timer): void; + export function clearImmediate(immediateId: NodeJS.Immediate): void; +} diff --git a/typings/globals/node/typings.json b/typings/globals/node/typings.json new file mode 100644 index 0000000..5ea9407 --- /dev/null +++ b/typings/globals/node/typings.json @@ -0,0 +1,12 @@ +{ + "resolution": "main", + "tree": { + "src": "https://raw.githubusercontent.com/types/env-node/088b6275167df0e4bec9bee3205c703253ef4ace/6.0/typings.json", + "raw": "registry:env/node#6.0.0+20161105011511", + "version": "6", + "files": [ + "node.d.ts" + ], + "name": "node" + } +} diff --git a/typings/globals/semver/index.d.ts b/typings/globals/semver/index.d.ts new file mode 100644 index 0000000..cc9da9b --- /dev/null +++ b/typings/globals/semver/index.d.ts @@ -0,0 +1,183 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/8252b2118a0b7b4c40ed3d4c3090a5c96d111420/semver/index.d.ts +declare namespace SemVerModule { + /** + * Return the parsed version, or null if it's not valid. + */ + function valid(v: string, loose?: boolean): string; + /** + * Returns cleaned (removed leading/trailing whitespace, remove '=v' prefix) and parsed version, or null if version is invalid. + */ + function clean(version: string, loose?: boolean): string; + /** + * Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid. + */ + function inc(v: string, release: string, loose?: boolean): string; + /** + * Return the major version number. + */ + function major(v: string, loose?: boolean): number; + /** + * Return the minor version number. + */ + function minor(v: string, loose?: boolean): number; + /** + * Return the patch version number. + */ + function patch(v: string, loose?: boolean): number; + /** + * Returns an array of prerelease components, or null if none exist. + */ + function prerelease(v: string, loose?: boolean): string[]; + + // Comparison + /** + * v1 > v2 + */ + function gt(v1: string, v2: string, loose?: boolean): boolean; + /** + * v1 >= v2 + */ + function gte(v1: string, v2: string, loose?: boolean): boolean; + /** + * v1 < v2 + */ + function lt(v1: string, v2: string, loose?: boolean): boolean; + /** + * v1 <= v2 + */ + function lte(v1: string, v2: string, loose?: boolean): boolean; + /** + * v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings. + */ + function eq(v1: string, v2: string, loose?: boolean): boolean; + /** + * v1 != v2 The opposite of eq. + */ + function neq(v1: string, v2: string, loose?: boolean): boolean; + /** + * Pass in a comparison string, and it'll call the corresponding semver comparison function. "===" and "!==" do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided. + */ + function cmp(v1: string, comparator: any, v2: string, loose?: boolean): boolean; + /** + * Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort(). + */ + function compare(v1: string, v2: string, loose?: boolean): number; + /** + * The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort(). + */ + function rcompare(v1: string, v2: string, loose?: boolean): number; + /** + * Returns difference between two versions by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if the versions are the same. + */ + function diff(v1: string, v2: string, loose?: boolean): string; + + // Ranges + /** + * Return the valid range or null if it's not valid + */ + function validRange(range: string, loose?: boolean): string; + /** + * Return true if the version satisfies the range. + */ + function satisfies(version: string, range: string, loose?: boolean): boolean; + /** + * Return the highest version in the list that satisfies the range, or null if none of them do. + */ + function maxSatisfying(versions: string[], range: string, loose?: boolean): string; + /** + * Return the lowest version in the list that satisfies the range, or null if none of them do. + */ + function minSatisfying(versions: string[], range: string, loose?: boolean): string; + /** + * Return true if version is greater than all the versions possible in the range. + */ + function gtr(version: string, range: string, loose?: boolean): boolean; + /** + * Return true if version is less than all the versions possible in the range. + */ + function ltr(version: string, range: string, loose?: boolean): boolean; + /** + * Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.) + */ + function outside(version: string, range: string, hilo: string, loose?: boolean): boolean; + + class SemVerBase { + raw: string; + loose: boolean; + format(): string; + inspect(): string; + toString(): string; + } + + class SemVer extends SemVerBase { + constructor(version: string, loose?: boolean); + + major: number; + minor: number; + patch: number; + version: string; + build: string[]; + prerelease: string[]; + + compare(other:SemVer): number; + compareMain(other:SemVer): number; + comparePre(other:SemVer): number; + inc(release: string): SemVer; + } + + class Comparator extends SemVerBase { + constructor(comp: string, loose?: boolean); + + semver: SemVer; + operator: string; + value: boolean; + parse(comp: string): void; + test(version:SemVer): boolean; + } + + class Range extends SemVerBase { + constructor(range: string, loose?: boolean); + + set: Comparator[][]; + parseRange(range: string): Comparator[]; + test(version: SemVer): boolean; + } +} + +interface SemVerStatic { + SemVer(version: string, loose?: boolean): SemVerModule.SemVer; + Comparator(comp: string, loose?: boolean): SemVerModule.Comparator; + Range(range: string, loose?: boolean): SemVerModule.Range; + clean(version: string, loose?: boolean): string; + + SEMVER_SPEC_VERSION: string; + + valid(v: string, loose?: boolean): string; + inc(v: string, release: string, loose?: boolean): string; + major(v: string, loose?: boolean): number; + minor(v: string, loose?: boolean): number; + patch(v: string, loose?: boolean): number; + gt(v1: string, v2: string, loose?: boolean): boolean; + gte(v1: string, v2: string, loose?: boolean): boolean; + lt(v1: string, v2: string, loose?: boolean): boolean; + lte(v1: string, v2: string, loose?: boolean): boolean; + eq(v1: string, v2: string, loose?: boolean): boolean; + neq(v1: string, v2: string, loose?: boolean): boolean; + cmp(v1: string, comparator: any, v2: string, loose?: boolean): boolean; + compare(v1: string, v2: string, loose?: boolean): number; + rcompare(v1: string, v2: string, loose?: boolean): number; + diff(v1: string, v2: string, loose?: boolean): string; + validRange(range: string, loose?: boolean): string; + satisfies(version: string, range: string, loose?: boolean): boolean; + maxSatisfying(versions: string[], range: string, loose?: boolean): string; + gtr(version: string, range: string, loose?: boolean): boolean; + ltr(version: string, range: string, loose?: boolean): boolean; + outside(version: string, range: string, hilo: string, loose?: boolean): boolean; +} + +declare var semver: SemVerStatic; + +declare module "semver" { + export = SemVerModule; +} diff --git a/typings/globals/semver/typings.json b/typings/globals/semver/typings.json new file mode 100644 index 0000000..e61eb46 --- /dev/null +++ b/typings/globals/semver/typings.json @@ -0,0 +1,8 @@ +{ + "resolution": "main", + "tree": { + "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/8252b2118a0b7b4c40ed3d4c3090a5c96d111420/semver/index.d.ts", + "raw": "registry:dt/semver#5.3.0+20160803221903", + "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/8252b2118a0b7b4c40ed3d4c3090a5c96d111420/semver/index.d.ts" + } +} diff --git a/typings/index.d.ts b/typings/index.d.ts new file mode 100644 index 0000000..af8bee0 --- /dev/null +++ b/typings/index.d.ts @@ -0,0 +1,3 @@ +/// +/// +/// diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..766659b --- /dev/null +++ b/yarn.lock @@ -0,0 +1,2001 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +abbrev@1: + version "1.0.9" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" + +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + +ansi-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.0.0.tgz#c5061b6e0ef8a81775e50f5d66151bf6bf371107" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +ansi@^0.3.0, ansi@~0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/ansi/-/ansi-0.3.1.tgz#0c42d4fb17160d5a9af1e484bace1c66922c1b21" + +anymatch@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" + dependencies: + arrify "^1.0.0" + micromatch "^2.1.5" + +aproba@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.0.4.tgz#2713680775e7614c8ba186c065d4e2e52d1072c0" + +are-we-there-yet@~1.0.0: + version "1.0.6" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.0.6.tgz#a2d28c93102aa6cc96245a26cb954de06ec53f0c" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.0 || ^1.1.13" + +are-we-there-yet@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.0 || ^1.1.13" + +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + +arr-flatten@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +async-each@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws4@^1.2.1: + version "1.5.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755" + +babel-cli@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.18.0.tgz#92117f341add9dead90f6fa7d0a97c0cc08ec186" + dependencies: + babel-core "^6.18.0" + babel-polyfill "^6.16.0" + babel-register "^6.18.0" + babel-runtime "^6.9.0" + commander "^2.8.1" + convert-source-map "^1.1.0" + fs-readdir-recursive "^1.0.0" + glob "^5.0.5" + lodash "^4.2.0" + output-file-sync "^1.1.0" + path-is-absolute "^1.0.0" + slash "^1.0.0" + source-map "^0.5.0" + v8flags "^2.0.10" + optionalDependencies: + chokidar "^1.0.0" + +babel-code-frame@^6.20.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.20.0.tgz#b968f839090f9a8bc6d41938fb96cb84f7387b26" + dependencies: + chalk "^1.1.0" + esutils "^2.0.2" + js-tokens "^2.0.0" + +babel-core@^6.18.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.20.0.tgz#ab0d7176d9dea434e66badadaf92237865eab1ec" + dependencies: + babel-code-frame "^6.20.0" + babel-generator "^6.20.0" + babel-helpers "^6.16.0" + babel-messages "^6.8.0" + babel-register "^6.18.0" + babel-runtime "^6.20.0" + babel-template "^6.16.0" + babel-traverse "^6.20.0" + babel-types "^6.20.0" + babylon "^6.11.0" + convert-source-map "^1.1.0" + debug "^2.1.1" + json5 "^0.5.0" + lodash "^4.2.0" + minimatch "^3.0.2" + path-is-absolute "^1.0.0" + private "^0.1.6" + slash "^1.0.0" + source-map "^0.5.0" + +babel-generator@^6.20.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.20.0.tgz#fee63614e0449390103b3097f3f6a118016c6766" + dependencies: + babel-messages "^6.8.0" + babel-runtime "^6.20.0" + babel-types "^6.20.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.2.0" + source-map "^0.5.0" + +babel-helper-call-delegate@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.18.0.tgz#05b14aafa430884b034097ef29e9f067ea4133bd" + dependencies: + babel-helper-hoist-variables "^6.18.0" + babel-runtime "^6.0.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helper-define-map@^6.18.0, babel-helper-define-map@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.18.0.tgz#8d6c85dc7fbb4c19be3de40474d18e97c3676ec2" + dependencies: + babel-helper-function-name "^6.18.0" + babel-runtime "^6.9.0" + babel-types "^6.18.0" + lodash "^4.2.0" + +babel-helper-function-name@^6.18.0, babel-helper-function-name@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.18.0.tgz#68ec71aeba1f3e28b2a6f0730190b754a9bf30e6" + dependencies: + babel-helper-get-function-arity "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helper-get-function-arity@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.18.0.tgz#a5b19695fd3f9cdfc328398b47dafcd7094f9f24" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-hoist-variables@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.18.0.tgz#a835b5ab8b46d6de9babefae4d98ea41e866b82a" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-optimise-call-expression@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.18.0.tgz#9261d0299ee1a4f08a6dd28b7b7c777348fd8f0f" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-regex@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.18.0.tgz#ae0ebfd77de86cb2f1af258e2cc20b5fe893ecc6" + dependencies: + babel-runtime "^6.9.0" + babel-types "^6.18.0" + lodash "^4.2.0" + +babel-helper-replace-supers@^6.18.0, babel-helper-replace-supers@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.18.0.tgz#28ec69877be4144dbd64f4cc3a337e89f29a924e" + dependencies: + babel-helper-optimise-call-expression "^6.18.0" + babel-messages "^6.8.0" + babel-runtime "^6.0.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helpers@^6.16.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.16.0.tgz#1095ec10d99279460553e67eb3eee9973d3867e3" + dependencies: + babel-runtime "^6.0.0" + babel-template "^6.16.0" + +babel-messages@^6.8.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.8.0.tgz#bf504736ca967e6d65ef0adb5a2a5f947c8e0eb9" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-check-es2015-constants@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.8.0.tgz#dbf024c32ed37bfda8dee1e76da02386a8d26fe7" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-arrow-functions@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.8.0.tgz#5b63afc3181bdc9a8c4d481b5a4f3f7d7fef3d9d" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.8.0.tgz#ed95d629c4b5a71ae29682b998f70d9833eb366d" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-block-scoping@^6.18.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.20.0.tgz#5d8f3e83b1a1ae1064e64a9e5bb83108d8e73be3" + dependencies: + babel-runtime "^6.20.0" + babel-template "^6.15.0" + babel-traverse "^6.20.0" + babel-types "^6.20.0" + lodash "^4.2.0" + +babel-plugin-transform-es2015-classes@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.18.0.tgz#ffe7a17321bf83e494dcda0ae3fc72df48ffd1d9" + dependencies: + babel-helper-define-map "^6.18.0" + babel-helper-function-name "^6.18.0" + babel-helper-optimise-call-expression "^6.18.0" + babel-helper-replace-supers "^6.18.0" + babel-messages "^6.8.0" + babel-runtime "^6.9.0" + babel-template "^6.14.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-computed-properties@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.8.0.tgz#f51010fd61b3bd7b6b60a5fdfd307bb7a5279870" + dependencies: + babel-helper-define-map "^6.8.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-destructuring@^6.18.0: + version "6.19.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.19.0.tgz#ff1d911c4b3f4cab621bd66702a869acd1900533" + dependencies: + babel-runtime "^6.9.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.6.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.8.0.tgz#fd8f7f7171fc108cc1c70c3164b9f15a81c25f7d" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.8.0" + +babel-plugin-transform-es2015-for-of@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.18.0.tgz#4c517504db64bf8cfc119a6b8f177211f2028a70" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-function-name@^6.9.0: + version "6.9.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.9.0.tgz#8c135b17dbd064e5bba56ec511baaee2fca82719" + dependencies: + babel-helper-function-name "^6.8.0" + babel-runtime "^6.9.0" + babel-types "^6.9.0" + +babel-plugin-transform-es2015-literals@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.8.0.tgz#50aa2e5c7958fc2ab25d74ec117e0cc98f046468" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-modules-amd@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.18.0.tgz#49a054cbb762bdf9ae2d8a807076cfade6141e40" + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-modules-commonjs@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.18.0.tgz#c15ae5bb11b32a0abdcc98a5837baa4ee8d67bcc" + dependencies: + babel-plugin-transform-strict-mode "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.16.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-modules-systemjs@^6.18.0: + version "6.19.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.19.0.tgz#50438136eba74527efa00a5b0fefaf1dc4071da6" + dependencies: + babel-helper-hoist-variables "^6.18.0" + babel-runtime "^6.11.6" + babel-template "^6.14.0" + +babel-plugin-transform-es2015-modules-umd@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.18.0.tgz#23351770ece5c1f8e83ed67cb1d7992884491e50" + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-object-super@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.8.0.tgz#1b858740a5a4400887c23dcff6f4d56eea4a24c5" + dependencies: + babel-helper-replace-supers "^6.8.0" + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-parameters@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.18.0.tgz#9b2cfe238c549f1635ba27fc1daa858be70608b1" + dependencies: + babel-helper-call-delegate "^6.18.0" + babel-helper-get-function-arity "^6.18.0" + babel-runtime "^6.9.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-shorthand-properties@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.18.0.tgz#e2ede3b7df47bf980151926534d1dd0cbea58f43" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-spread@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.8.0.tgz#0217f737e3b821fa5a669f187c6ed59205f05e9c" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-sticky-regex@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.8.0.tgz#e73d300a440a35d5c64f5c2a344dc236e3df47be" + dependencies: + babel-helper-regex "^6.8.0" + babel-runtime "^6.0.0" + babel-types "^6.8.0" + +babel-plugin-transform-es2015-template-literals@^6.6.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.8.0.tgz#86eb876d0a2c635da4ec048b4f7de9dfc897e66b" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.18.0.tgz#0b14c48629c90ff47a0650077f6aa699bee35798" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-unicode-regex@^6.3.13: + version "6.11.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.11.0.tgz#6298ceabaad88d50a3f4f392d8de997260f6ef2c" + dependencies: + babel-helper-regex "^6.8.0" + babel-runtime "^6.0.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-regenerator@^6.16.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.20.0.tgz#a546cd2aa1c9889929d5c427a31303847847ab75" + dependencies: + regenerator-transform "0.9.8" + +babel-plugin-transform-strict-mode@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.18.0.tgz#df7cf2991fe046f44163dcd110d5ca43bc652b9d" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-polyfill@^6.16.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.20.0.tgz#de4a371006139e20990aac0be367d398331204e7" + dependencies: + babel-runtime "^6.20.0" + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-preset-es2015@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.18.0.tgz#b8c70df84ec948c43dcf2bf770e988eb7da88312" + dependencies: + babel-plugin-check-es2015-constants "^6.3.13" + babel-plugin-transform-es2015-arrow-functions "^6.3.13" + babel-plugin-transform-es2015-block-scoped-functions "^6.3.13" + babel-plugin-transform-es2015-block-scoping "^6.18.0" + babel-plugin-transform-es2015-classes "^6.18.0" + babel-plugin-transform-es2015-computed-properties "^6.3.13" + babel-plugin-transform-es2015-destructuring "^6.18.0" + babel-plugin-transform-es2015-duplicate-keys "^6.6.0" + babel-plugin-transform-es2015-for-of "^6.18.0" + babel-plugin-transform-es2015-function-name "^6.9.0" + babel-plugin-transform-es2015-literals "^6.3.13" + babel-plugin-transform-es2015-modules-amd "^6.18.0" + babel-plugin-transform-es2015-modules-commonjs "^6.18.0" + babel-plugin-transform-es2015-modules-systemjs "^6.18.0" + babel-plugin-transform-es2015-modules-umd "^6.18.0" + babel-plugin-transform-es2015-object-super "^6.3.13" + babel-plugin-transform-es2015-parameters "^6.18.0" + babel-plugin-transform-es2015-shorthand-properties "^6.18.0" + babel-plugin-transform-es2015-spread "^6.3.13" + babel-plugin-transform-es2015-sticky-regex "^6.3.13" + babel-plugin-transform-es2015-template-literals "^6.6.0" + babel-plugin-transform-es2015-typeof-symbol "^6.18.0" + babel-plugin-transform-es2015-unicode-regex "^6.3.13" + babel-plugin-transform-regenerator "^6.16.0" + +babel-register@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.18.0.tgz#892e2e03865078dd90ad2c715111ec4449b32a68" + dependencies: + babel-core "^6.18.0" + babel-runtime "^6.11.6" + core-js "^2.4.0" + home-or-tmp "^2.0.0" + lodash "^4.2.0" + mkdirp "^0.5.1" + source-map-support "^0.4.2" + +babel-runtime@^6.0.0, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.20.0, babel-runtime@^6.9.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.20.0.tgz#87300bdcf4cd770f09bf0048c64204e17806d16f" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-template@^6.14.0, babel-template@^6.15.0, babel-template@^6.16.0, babel-template@^6.8.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.16.0.tgz#e149dd1a9f03a35f817ddbc4d0481988e7ebc8ca" + dependencies: + babel-runtime "^6.9.0" + babel-traverse "^6.16.0" + babel-types "^6.16.0" + babylon "^6.11.0" + lodash "^4.2.0" + +babel-traverse@^6.16.0, babel-traverse@^6.18.0, babel-traverse@^6.20.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.20.0.tgz#5378d1a743e3d856e6a52289994100bbdfd9872a" + dependencies: + babel-code-frame "^6.20.0" + babel-messages "^6.8.0" + babel-runtime "^6.20.0" + babel-types "^6.20.0" + babylon "^6.11.0" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.20.0, babel-types@^6.8.0, babel-types@^6.9.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.20.0.tgz#3869ecb98459533b37df809886b3f7f3b08d2baa" + dependencies: + babel-runtime "^6.20.0" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babylon@^6.11.0: + version "6.14.1" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.14.1.tgz#956275fab72753ad9b3435d7afe58f8bf0a29815" + +balanced-match@^0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" + +bcrypt-pbkdf@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.0.tgz#3ca76b85241c7170bf7d9703e7b9aa74630040d4" + dependencies: + tweetnacl "^0.14.3" + +binary-extensions@^1.0.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" + +"binary@>= 0.3.0 < 1": + version "0.3.0" + resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" + dependencies: + buffers "~0.1.1" + chainsaw "~0.1.0" + +bindings@1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11" + +block-stream@*: + version "0.0.9" + resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + dependencies: + inherits "~2.0.0" + +bluebird@3: + version "3.4.6" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.6.tgz#01da8d821d87813d158967e743d5fe6c62cf8c0f" + +bluebird@^2.9.15: + version "2.11.0" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" + +boom@2.x.x: + version "2.10.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +brace-expansion@^1.0.0: + version "1.1.6" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" + dependencies: + balanced-match "^0.4.1" + concat-map "0.0.1" + +braces@^1.8.2: + version "1.8.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + +browser-stdout@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" + +buffer-shims@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" + +buffers@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb" + +camelcase@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + +chainsaw@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98" + dependencies: + traverse ">=0.3.0 <0.4" + +chalk@^1.1.0, chalk@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chokidar@^1.0.0: + version "1.6.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + +cliui@^3.0.3: + version "3.2.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrap-ansi "^2.0.0" + +cmake-js@3: + version "3.3.1" + resolved "https://registry.yarnpkg.com/cmake-js/-/cmake-js-3.3.1.tgz#f5672d1a5a0663f028d873f5bd630cc6e0616076" + dependencies: + bluebird "^2.9.15" + debug "^2.1.3" + fs-extra "^0.16.5" + is-iojs "^1.0.1" + lodash "^3.6.0" + memory-stream "0" + npmconf "^2.1.2" + npmlog "^1.2.0" + request "^2.54.0" + semver "^5.0.3" + splitargs "0" + tar "^1.0.3" + traceur "0.0.x" + unzip "^0.1.11" + url-join "0" + which "^1.0.9" + yargs "^3.6.0" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +commander@2.9.0, commander@2.9.x, commander@^2.8.1, commander@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +config-chain@~1.1.8: + version "1.1.11" + resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.11.tgz#aba09747dfbe4c3e70e766a6e41586e1859fc6f2" + dependencies: + ini "^1.3.4" + proto-list "~1.2.1" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +convert-source-map@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.3.0.tgz#e9f3e9c6e2728efc2676696a70eb382f73106a67" + +core-js@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +debug@2.2.0, debug@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +debug@^2.1.1, debug@^2.1.3, debug@^2.2.0: + version "2.3.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c" + dependencies: + ms "0.7.2" + +decamelize@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +deep-extend@~0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + dependencies: + repeating "^2.0.0" + +diff@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + +expand-range@^1.8.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + +extend@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + +extglob@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + +extsprintf@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" + +fastcall@^0.1.24: + version "0.1.28" + resolved "https://registry.yarnpkg.com/fastcall/-/fastcall-0.1.28.tgz#01c8de90a2c9ff71c1fa185ed5cb391b2998ed3c" + dependencies: + babel-polyfill "^6.16.0" + bindings "1" + bluebird "3" + cmake-js "3" + debug "^2.2.0" + lodash "4" + minimist "^1.2.0" + nan "^2.4.0" + +filename-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + +fill-range@^2.1.0: + version "2.2.3" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^1.1.3" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + +for-in@^0.1.5: + version "0.1.6" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.6.tgz#c9f96e89bfad18a545af5ec3ed352a1d9e5b4dc8" + +for-own@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.4.tgz#0149b41a39088c7515f51ebe1c1386d45f935072" + dependencies: + for-in "^0.1.5" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +fs-extra@^0.16.5: + version "0.16.5" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.16.5.tgz#1ad661fa6c86c9608cd1b49efc6fce834939a750" + dependencies: + graceful-fs "^3.0.5" + jsonfile "^2.0.0" + rimraf "^2.2.8" + +fs-readdir-recursive@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@^1.0.0: + version "1.0.15" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.0.15.tgz#fa63f590f3c2ad91275e4972a6cea545fb0aae44" + dependencies: + nan "^2.3.0" + node-pre-gyp "^0.6.29" + +fstream-ignore@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" + dependencies: + fstream "^1.0.0" + inherits "2" + minimatch "^3.0.0" + +"fstream@>= 0.1.30 < 1": + version "0.1.31" + resolved "https://registry.yarnpkg.com/fstream/-/fstream-0.1.31.tgz#7337f058fbbbbefa8c9f561a28cab0849202c988" + dependencies: + graceful-fs "~3.0.2" + inherits "~2.0.0" + mkdirp "0.5" + rimraf "2" + +fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.10.tgz#604e8a92fe26ffd9f6fae30399d4984e1ab22822" + dependencies: + graceful-fs "^4.1.2" + inherits "~2.0.0" + mkdirp ">=0.5 0" + rimraf "2" + +gauge@~1.2.0: + version "1.2.7" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-1.2.7.tgz#e9cec5483d3d4ee0ef44b60a7d99e4935e136d93" + dependencies: + ansi "^0.3.0" + has-unicode "^2.0.0" + lodash.pad "^4.1.0" + lodash.padend "^4.1.0" + lodash.padstart "^4.1.0" + +gauge@~2.7.1: + version "2.7.2" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.2.tgz#15cecc31b02d05345a5d6b0e171cdb3ad2307774" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + supports-color "^0.2.0" + wide-align "^1.1.0" + +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + +getpass@^0.1.1: + version "0.1.6" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + dependencies: + assert-plus "^1.0.0" + +glob-base@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + +glob@5.0.x, glob@^5.0.5: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@7.0.5, glob@^7.0.5: + version "7.0.5" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.5.tgz#b4202a69099bbb4d292a7c1b95b6682b67ebdc95" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^9.0.0: + version "9.14.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034" + +graceful-fs@^3.0.5, graceful-fs@~3.0.2: + version "3.0.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" + dependencies: + natives "^1.1.0" + +graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + +har-validator@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +hawk@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hoek@2.x.x: + version "2.16.3" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ini@^1.2.0, ini@^1.3.4, ini@~1.3.0: + version "1.3.4" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + +invariant@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + dependencies: + loose-envify "^1.0.0" + +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.0.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" + +is-dotfile@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + +is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + +is-iojs@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-iojs/-/is-iojs-1.1.0.tgz#4c11033b5d5d94d6eab3775dedc9be7d008325f1" + +is-my-json-valid@^2.12.4: + version "2.15.0" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz#936edda3ca3c211fd98f3b2d3e08da43f7b2915b" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-number@^2.0.2, is-number@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isexe@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-1.1.2.tgz#36f3e22e60750920f5e7241a476a8c6a42275ad0" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +jodid25519@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" + dependencies: + jsbn "~0.1.0" + +js-tokens@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-2.0.0.tgz#79903f5563ee778cc1162e6dcf1a0027c97f9cb5" + +jsbn@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.0.tgz#650987da0dd74f4ebf5a11377a2aa2d273e97dfd" + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json3@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" + +json5@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + +jsonfile@^2.0.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + optionalDependencies: + graceful-fs "^4.1.6" + +jsonpointer@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.0.tgz#6661e161d2fc445f19f98430231343722e1fcbd5" + +jsprim@^1.2.2: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.3.1.tgz#2a7256f70412a29ee3670aaca625994c4dcff252" + dependencies: + extsprintf "1.0.2" + json-schema "0.2.3" + verror "1.3.6" + +kind-of@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" + dependencies: + is-buffer "^1.0.2" + +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + dependencies: + invert-kv "^1.0.0" + +lodash._baseassign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" + dependencies: + lodash._basecopy "^3.0.0" + lodash.keys "^3.0.0" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + +lodash._basecreate@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + +lodash.create@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" + dependencies: + lodash._baseassign "^3.0.0" + lodash._basecreate "^3.0.0" + lodash._isiterateecall "^3.0.0" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +lodash.pad@^4.1.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/lodash.pad/-/lodash.pad-4.5.1.tgz#4330949a833a7c8da22cc20f6a26c4d59debba70" + +lodash.padend@^4.1.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.padend/-/lodash.padend-4.6.1.tgz#53ccba047d06e158d311f45da625f4e49e6f166e" + +lodash.padstart@^4.1.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.padstart/-/lodash.padstart-4.6.1.tgz#d2e3eebff0d9d39ad50f5cbd1b52a7bce6bb611b" + +lodash@4, lodash@^4.2.0: + version "4.17.2" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42" + +lodash@^3.6.0: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + +loose-envify@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.0.tgz#6b26248c42f6d4fa4b0d8542f78edfcde35642a8" + dependencies: + js-tokens "^2.0.0" + +"match-stream@>= 0.0.2 < 1": + version "0.0.2" + resolved "https://registry.yarnpkg.com/match-stream/-/match-stream-0.0.2.tgz#99eb050093b34dffade421b9ac0b410a9cfa17cf" + dependencies: + buffers "~0.1.1" + readable-stream "~1.0.0" + +memory-stream@0: + version "0.0.3" + resolved "https://registry.yarnpkg.com/memory-stream/-/memory-stream-0.0.3.tgz#ebe8dd1c3b8bc38c0e7941e9ddd5aebe6b4de83f" + dependencies: + readable-stream "~1.0.26-2" + +micromatch@^2.1.5: + version "2.3.11" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + +mime-db@~1.25.0: + version "1.25.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.25.0.tgz#c18dbd7c73a5dbf6f44a024dc0d165a1e7b1c392" + +mime-types@^2.1.12, mime-types@~2.1.7: + version "2.1.13" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.13.tgz#e07aaa9c6c6b9a7ca3012c69003ad25a39e92a88" + dependencies: + mime-db "~1.25.0" + +"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" + dependencies: + brace-expansion "^1.0.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +mkdirp@0.5, mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mocha@3: + version "3.2.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.2.0.tgz#7dc4f45e5088075171a68896814e6ae9eb7a85e3" + dependencies: + browser-stdout "1.3.0" + commander "2.9.0" + debug "2.2.0" + diff "1.4.0" + escape-string-regexp "1.0.5" + glob "7.0.5" + growl "1.9.2" + json3 "3.3.2" + lodash.create "3.1.1" + mkdirp "0.5.1" + supports-color "3.1.2" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +ms@0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" + +nan@^2.3.0, nan@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.4.0.tgz#fb3c59d45fe4effe215f0b890f8adf6eb32d2232" + +natives@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.0.tgz#e9ff841418a6b2ec7a495e939984f78f163e6e31" + +node-pre-gyp@^0.6.29: + version "0.6.32" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.32.tgz#fc452b376e7319b3d255f5f34853ef6fd8fe1fd5" + dependencies: + mkdirp "~0.5.1" + nopt "~3.0.6" + npmlog "^4.0.1" + rc "~1.1.6" + request "^2.79.0" + rimraf "~2.5.4" + semver "~5.3.0" + tar "~2.2.1" + tar-pack "~3.3.0" + +nopt@~3.0.1, nopt@~3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" + dependencies: + abbrev "1" + +normalize-path@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" + +npmconf@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/npmconf/-/npmconf-2.1.2.tgz#66606a4a736f1e77a059aa071a79c94ab781853a" + dependencies: + config-chain "~1.1.8" + inherits "~2.0.0" + ini "^1.2.0" + mkdirp "^0.5.0" + nopt "~3.0.1" + once "~1.3.0" + osenv "^0.1.0" + semver "2 || 3 || 4" + uid-number "0.0.5" + +npmlog@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-1.2.1.tgz#28e7be619609b53f7ad1dd300a10d64d716268b6" + dependencies: + ansi "~0.3.0" + are-we-there-yet "~1.0.0" + gauge "~1.2.0" + +npmlog@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.1.tgz#d14f503b4cd79710375553004ba96e6662fbc0b8" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.1" + set-blocking "~2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +oauth-sign@~0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" + +object.omit@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +once@~1.3.0, once@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" + dependencies: + wrappy "1" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-locale@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" + dependencies: + lcid "^1.0.0" + +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +osenv@^0.1.0: + version "0.1.3" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.3.tgz#83cf05c6d6458fc4d5ac6362ea325d92f2754217" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +output-file-sync@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" + dependencies: + graceful-fs "^4.1.4" + mkdirp "^0.5.1" + object-assign "^4.1.0" + +"over@>= 0.0.5 < 1": + version "0.0.5" + resolved "https://registry.yarnpkg.com/over/-/over-0.0.5.tgz#f29852e70fd7e25f360e013a8ec44c82aedb5708" + +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +preserve@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + +private@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.6.tgz#55c6a976d0f9bafb9924851350fe47b9b5fbb7c1" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +proto-list@~1.2.1: + version "1.2.4" + resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" + +"pullstream@>= 0.4.1 < 1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/pullstream/-/pullstream-0.4.1.tgz#d6fb3bf5aed697e831150eb1002c25a3f8ae1314" + dependencies: + over ">= 0.0.5 < 1" + readable-stream "~1.0.31" + setimmediate ">= 1.0.2 < 2" + slice-stream ">= 1.0.0 < 2" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +qs@~6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442" + +randomatic@^1.1.3: + version "1.1.6" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" + dependencies: + is-number "^2.0.2" + kind-of "^3.0.2" + +rc@~1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.1.6.tgz#43651b76b6ae53b5c802f1151fa3fc3b059969c9" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~1.0.4" + +"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e" + dependencies: + buffer-shims "^1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +readable-stream@~1.0.0, readable-stream@~1.0.26-2, readable-stream@~1.0.31: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@~2.1.4: + version "2.1.5" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" + dependencies: + buffer-shims "^1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +readdirp@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" + dependencies: + graceful-fs "^4.1.2" + minimatch "^3.0.2" + readable-stream "^2.0.2" + set-immediate-shim "^1.0.1" + +regenerate@^1.2.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" + +regenerator-runtime@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.1.tgz#257f41961ce44558b18f7814af48c17559f9faeb" + +regenerator-transform@0.9.8: + version "0.9.8" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.9.8.tgz#0f88bb2bc03932ddb7b6b7312e68078f01026d6c" + dependencies: + babel-runtime "^6.18.0" + babel-types "^6.19.0" + private "^0.1.6" + +regex-cache@^0.4.2: + version "0.4.3" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + dependencies: + is-equal-shallow "^0.1.3" + is-primitive "^2.0.0" + +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + dependencies: + jsesc "~0.5.0" + +repeat-element@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +request@^2.54.0, request@^2.79.0: + version "2.79.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~2.0.6" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + qs "~6.3.0" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "~0.4.1" + uuid "^3.0.0" + +rimraf@2, rimraf@^2.2.8, rimraf@~2.5.1, rimraf@~2.5.4: + version "2.5.4" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" + dependencies: + glob "^7.0.5" + +rsvp@^3.0.13: + version "3.3.3" + resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.3.3.tgz#34633caaf8bc66ceff4be3c2e1dffd032538a813" + +"semver@2 || 3 || 4", semver@^4.3.3: + version "4.3.6" + resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" + +semver@^5.0.3, semver@~5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + +"setimmediate@>= 1.0.1 < 2", "setimmediate@>= 1.0.2 < 2": + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + +signal-exit@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + +"slice-stream@>= 1.0.0 < 2": + version "1.0.0" + resolved "https://registry.yarnpkg.com/slice-stream/-/slice-stream-1.0.0.tgz#5b33bd66f013b1a7f86460b03d463dec39ad3ea0" + dependencies: + readable-stream "~1.0.31" + +sntp@1.x.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +source-map-support@^0.4.2: + version "0.4.6" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.6.tgz#32552aa64b458392a85eab3b0b5ee61527167aeb" + dependencies: + source-map "^0.5.3" + +source-map-support@~0.2.8: + version "0.2.10" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.2.10.tgz#ea5a3900a1c1cb25096a0ae8cc5c2b4b10ded3dc" + dependencies: + source-map "0.1.32" + +source-map@0.1.32: + version "0.1.32" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.32.tgz#c8b6c167797ba4740a8ea33252162ff08591b266" + dependencies: + amdefine ">=0.0.4" + +source-map@^0.5.0, source-map@^0.5.3: + version "0.5.6" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + +splitargs@0: + version "0.0.7" + resolved "https://registry.yarnpkg.com/splitargs/-/splitargs-0.0.7.tgz#fe9f7ae657371b33b10cb80da143cf8249cf6b3b" + +sshpk@^1.7.0: + version "1.10.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.10.1.tgz#30e1a5d329244974a1af61511339d595af6638b0" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jodid25519 "^1.0.0" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +stringstream@~0.0.4: + version "0.0.5" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-json-comments@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" + +supports-color@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + dependencies: + has-flag "^1.0.0" + +supports-color@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +tar-pack@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.3.0.tgz#30931816418f55afc4d21775afdd6720cee45dae" + dependencies: + debug "~2.2.0" + fstream "~1.0.10" + fstream-ignore "~1.0.5" + once "~1.3.3" + readable-stream "~2.1.4" + rimraf "~2.5.1" + tar "~2.2.1" + uid-number "~0.0.6" + +tar@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tar/-/tar-1.0.3.tgz#15bcdab244fa4add44e4244a0176edb8aa9a2b44" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +tar@~2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +to-fast-properties@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + +tough-cookie@~2.3.0: + version "2.3.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" + dependencies: + punycode "^1.4.1" + +traceur@0.0.x: + version "0.0.111" + resolved "https://registry.yarnpkg.com/traceur/-/traceur-0.0.111.tgz#c04de74d14696c3373427de4fc08ecaf913fc3a1" + dependencies: + commander "2.9.x" + glob "5.0.x" + rsvp "^3.0.13" + semver "^4.3.3" + source-map-support "~0.2.8" + +"traverse@>=0.3.0 <0.4": + version "0.3.9" + resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9" + +tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.4" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.4.tgz#8c9dbfb52795686f166cd2023794bcf103d13c2b" + +uid-number@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.5.tgz#5a3db23ef5dbd55b81fce0ec9a2ac6fccdebb81e" + +uid-number@~0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + +unzip@^0.1.11: + version "0.1.11" + resolved "https://registry.yarnpkg.com/unzip/-/unzip-0.1.11.tgz#89749c63b058d7d90d619f86b98aa1535d3b97f0" + dependencies: + binary ">= 0.3.0 < 1" + fstream ">= 0.1.30 < 1" + match-stream ">= 0.0.2 < 1" + pullstream ">= 0.4.1 < 1" + readable-stream "~1.0.31" + setimmediate ">= 1.0.1 < 2" + +url-join@0: + version "0.0.1" + resolved "https://registry.yarnpkg.com/url-join/-/url-join-0.0.1.tgz#1db48ad422d3402469a87f7d97bdebfe4fb1e3c8" + +user-home@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +uuid@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + +v8flags@^2.0.10: + version "2.0.11" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881" + dependencies: + user-home "^1.1.1" + +verror@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" + dependencies: + extsprintf "1.0.2" + +which@^1.0.9: + version "1.2.12" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192" + dependencies: + isexe "^1.1.1" + +wide-align@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + dependencies: + string-width "^1.0.1" + +window-size@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" + +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +xtend@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + +y18n@^3.2.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" + +yargs@^3.6.0: + version "3.32.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995" + dependencies: + camelcase "^2.0.1" + cliui "^3.0.3" + decamelize "^1.1.1" + os-locale "^1.4.0" + string-width "^1.0.1" + window-size "^0.1.4" + y18n "^3.2.0"