scijs / ndarray-ops Goto Github PK
View Code? Open in Web Editor NEWndarray operations
License: MIT License
ndarray operations
License: MIT License
Could you explain the reason that the min/max element functions are named "inf" and "sup". I only stumbled over them after writing my own with ndarray-cwise. Maybe minvalue, maxvalue or something more obvious?
Thanks,
john
It seems like there is little or no work coming in for this repo, yet I grabbed it along with several others mentioned here: http://scijs.net/packages/ as it seemed pretty essential to some of the experimental things I am doing with ndarray.
I have been chasing my tail for a few hours trying to figure an out an odd bug that comes back to ndarray-ops::assign. Now, I am wondering if it is worth the effort to try to correct the issue (PR), or if this particular repo is essentially abandoned in favor of just using cwise.
cwise on the other hand looks to have been updated 19 minutes ago, at the time of following this issue, so that's great.
Either way thanks for the work so far.
I believe there is a slight perf improvement available by combining loops in the case of performing multiple operations in series. Although, I'm not sure how difficult this would be, or whether or not it should be implemented here or directly upon cwise.
What do you think?
I have been encountering various problems with ops.equals when running tests for my own ndarray modules.
Different lengths seem to play a role. I wrote the following test and it fails:
var x2 = ndarray(new Float32Array([0]));
var y2 = ndarray(new Float32Array([0, 1]));
t.assert(!ops.equals(x2, y2))
Maybe this is outside the intended use case and you only intended that ndarrays with the same length and same underlying buffer format get compared. Nevertheless, having more robust falsiness behavior would make it easier to instrument and test modules.
I think there are other things. I will update this issue as I find them. I will also try to fix them.
UPDATE:
I am just going to implement my own equals method, since that would be faster/easier for me.
Following the discussion on scijs/ndarray#22 I tried implementing this, mostly by copy pasting the existing argmin/max:
For reference:
function nullargminmax (op) {
let minus = op === 'max' ? '-' : ''
let comp = op === 'max' ? '>' : '<'
// adapted from ndarray-ops argmin/argmax
return compile({
args:["index","array","shape"],
pre:{
body:"{this_v=" + minus + "Infinity;this_i=_inline_0_arg2_.slice(0)}",
args:[
{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},
{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},
{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}
],
thisVars:["this_i","this_v"],
localVars:[]},
body:{
body:"{if(_inline_1_arg1_ !== null && _inline_1_arg1_ " + comp + "this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",
args:[
{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},
{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],
thisVars:["this_i","this_v"],
localVars:["_inline_1_k"]},
post:{
body:"{return this_i}",
args:[],
thisVars:["this_i"],
localVars:[]}
})
}
var nullargmin = nullargminmax('min')
var nullargmax = nullargminmax('max')
It works. However, I have a problem when the array contains only nulls. Then for some reason I get an array [2]
as an answer where the number is the length of the array, e.g. for ndarray([null,null]). Does this make any sense? I'm a bit lost understanding this low-level code.
This doesn't seem to work with 0d ndarrays:
var a = ndarray(new Float32Array(128*128))
ops.addseq(a.pick(0), 2)
Throws "SyntaxError: Unexpected token |="
It looks like cwise-compiler (maybe this is a bug which should be filed there instead) is assembling some code which includes a var
statement with no argument (i.e. "var \n a |= 0").
Last time I checked, subtraction and division were not commutative...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.