Comparing version 0.2.2 to 0.2.3
34
index.js
@@ -85,7 +85,7 @@ "use strict" | ||
function zeros(shape, dtype, order) { | ||
if(typeof(dtype) === "undefined") { | ||
if(!dtype) { | ||
dtype = "float64" | ||
} | ||
//Default row-major order | ||
if(typeof(order) === "undefined") { | ||
if(!order) { | ||
order = new Array(shape.length) | ||
@@ -96,3 +96,3 @@ for(var i=shape.length-1, j=0; i>=0; --i, ++j) { | ||
} | ||
var stride = new Array(shape.length) | ||
var stride = new Array(shape.length) | ||
var size = 1 | ||
@@ -153,7 +153,25 @@ for(var i=0; i<shape.length; ++i) { | ||
function pstride(shape, order) { | ||
var i = 0, d = shape.length | ||
var result = new Array(d), s = 1 | ||
if(order) { | ||
for(i=0; i<d; ++i) { | ||
result[order[i]] = s | ||
s *= shape[order[i]] | ||
} | ||
} else { | ||
for(var i=d-1; i>=0; --i) { | ||
stride[i] = s | ||
s *= shape[i] | ||
} | ||
} | ||
return result | ||
} | ||
module.exports = wrap | ||
module.exports.zeros = zeros | ||
module.exports.dtype = dtype | ||
module.exports.order = order | ||
module.exports.size = size | ||
module.exports.ctor = makeView | ||
module.exports.zeros = zeros | ||
module.exports.dtype = dtype | ||
module.exports.order = order | ||
module.exports.size = size | ||
module.exports.stride = pstride | ||
module.exports.ctor = makeView |
{ | ||
"name": "ndarray", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Multidimensional Arrays", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -133,2 +133,10 @@ ndarray | ||
### `ndarray.stride(shape[, order])` | ||
Computes the stride for a packed ndarray with the given order. If the order is not specified row major order is assumed. | ||
* `shape` the shape if the array | ||
* `order` the order of the stride | ||
**Returns** The stride of the array | ||
Views | ||
@@ -135,0 +143,0 @@ ===== |
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
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
24619
457
277