ndarray-equals

1.0.3 • Public • Published

ndarray-equals

A simple / not-insane ndarray comparison method that works and obeys sensible rules.

Example:

var ndarray = require('ndarray');
var equals = require('ndarray-equals');
var a1 = ndarray([0,1,2,3], [2,2]);
var a2 = ndarray([0,1,2,3]);
equals(a1, a2); // false
a2 = ndarray([0,1,2,3], [2, 2]);
equals(a1, a2); // true
 
a2 = ndarray(new Float32Array([0,1,2,3]), [2, 2]);
equals(a1, a2); // false
a2 = undefined;
equals(a1, a2); // false
 

That's all there is to it really. Two ndarrays are considered equal if and only if they have the same shape, stride, offset, and the data has the same content and constructor. Note that this condition for equality is much stronger than that found in ndarray-ops equals method.

LICENSE: MIT

Package Sidebar

Install

npm i ndarray-equals

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • coballast