cwise-compiler
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -0,0 +0,0 @@ "use strict" |
@@ -0,0 +0,0 @@ "use strict" |
@@ -38,3 +38,5 @@ "use strict" | ||
var proc_args = [["array",proc.arrayArgs[0],".shape.slice(", // Slice shape so that we only retain the shape over which we iterate (which gets passed to the cwise operator as SS). | ||
Math.max(0,proc.arrayBlockIndices[i]),proc.arrayBlockIndices[i]<0?(","+proc.arrayBlockIndices[i]+")"):")"].join("")] | ||
Math.max(0,proc.arrayBlockIndices[0]),proc.arrayBlockIndices[0]<0?(","+proc.arrayBlockIndices[0]+")"):")"].join("")] | ||
var shapeLengthConditions = [], shapeConditions = [] | ||
// Process array arguments | ||
for(var i=0; i<proc.arrayArgs.length; ++i) { | ||
@@ -51,6 +53,19 @@ var j = proc.arrayArgs[i] | ||
proc_args.push("array" + j + ".offset|0") | ||
if (i>0) { // Gather conditions to check for shape equality (ignoring block indices) | ||
shapeLengthConditions.push("array" + proc.arrayArgs[0] + ".shape.length===array" + j + ".shape.length+" + (Math.abs(proc.arrayBlockIndices[0])-Math.abs(proc.arrayBlockIndices[i]))) | ||
shapeConditions.push("array" + proc.arrayArgs[0] + ".shape[shapeIndex+" + Math.max(0,proc.arrayBlockIndices[0]) + "]===array" + j + ".shape[shapeIndex+" + Math.max(0,proc.arrayBlockIndices[i]) + "]") | ||
} | ||
} | ||
// Check for shape equality | ||
if (proc.arrayArgs.length > 1) { | ||
code.push("if (!(" + shapeLengthConditions.join(" && ") + ")) throw new Error('cwise: Arrays do not all have the same dimensionality!')") | ||
code.push("for(var shapeIndex=array" + proc.arrayArgs[0] + ".shape.length-" + Math.abs(proc.arrayBlockIndices[0]) + "; shapeIndex-->0;) {") | ||
code.push("if (!(" + shapeConditions.join(" && ") + ")) throw new Error('cwise: Arrays do not all have the same shape!')") | ||
code.push("}") | ||
} | ||
// Process scalar arguments | ||
for(var i=0; i<proc.scalarArgs.length; ++i) { | ||
proc_args.push("scalar" + proc.scalarArgs[i]) | ||
} | ||
// Check for cached function (and if not present, generate it) | ||
vars.push(["type=[", string_typesig.join(","), "].join()"].join("")) | ||
@@ -57,0 +72,0 @@ vars.push("proc=CACHED[type]") |
{ | ||
"name": "cwise-compiler", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "cwise's internal compiler", | ||
"main": "compiler.js", | ||
"scripts": { | ||
"test": "tap test/*.js" | ||
"test": "tape test/*.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/mikolalysenko/cwise-compiler.git" | ||
"url": "git://github.com/scijs/cwise-compiler.git" | ||
}, | ||
@@ -19,2 +19,5 @@ "keywords": [ | ||
"author": "Mikola Lysenko", | ||
"contributors": [ | ||
"Jasper van de Gronde <th.v.d.gronde@hccnet.nl>" | ||
], | ||
"license": "MIT", | ||
@@ -24,3 +27,3 @@ "readmeFilename": "README.md", | ||
"bugs": { | ||
"url": "https://github.com/mikolalysenko/cwise-compiler/issues" | ||
"url": "https://github.com/scijs/cwise-compiler/issues" | ||
}, | ||
@@ -34,4 +37,4 @@ "dependencies": { | ||
"cwise-parser": "^1.0.0", | ||
"tape": "^3.0.0" | ||
"tape": "^4.0.0" | ||
} | ||
} |
@@ -5,7 +5,12 @@ cwise-compiler | ||
## Install | ||
[![build status](https://secure.travis-ci.org/scijs/cwise-compiler.png)](http:// | ||
travis-ci.org/scijs/cwise-compiler) | ||
# Install | ||
Install using [npm](https://www.npmjs.com/): | ||
npm install cwise-compiler | ||
## `require("cwise-compiler")(procedure)` | ||
# API | ||
#### `require("cwise-compiler")(procedure)` | ||
Compiles a cwise procedure for the given procedure. The object procedure must have the following fields: | ||
@@ -21,3 +26,3 @@ | ||
## Credits | ||
# License | ||
(c) 2013 Mikola Lysenko. MIT License |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27109
9
542
27
3