Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 0d ndarrays #9

Open
antimatter15 opened this issue Jan 24, 2016 · 4 comments
Open

Support for 0d ndarrays #9

antimatter15 opened this issue Jan 24, 2016 · 4 comments

Comments

@antimatter15
Copy link

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").

@rreusser
Copy link
Member

Hmm… I can see the argument either way. The amount of data is defined as the product of the size of the dimensions. So a shape of [2, 2] has four numbers. [5] has five numbers. [] has no data. So it's a no-op.

So maybe it's that it should do nothing and exit early.

@mikolalysenko
Copy link
Member

Yeah, I think this is a bug in cwise. Should open an issue there as well.

@Jabher
Copy link

Jabher commented May 17, 2017

I've made a fix: scijs/cwise-compiler#4
already accepted, waiting for npm release to make it work. This issue can be closed right after the release

@Jabher
Copy link

Jabher commented May 17, 2017

@rreusser correct, but not strictly correct. Size of array is shapes.reduce((a,b) => a * b, 1) which means that <2x2> tensor, which is matrix, has size 4; <2> tensor, which is vector, has size 2. But <> tensor (here goes mind blown) is scalar of size 1. And it is totally fine to use tensor algebra against it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants