rainwoodman / vast

vala and scientific numerical computation
11 stars 1 forks source link

zero dim array shall have a size of 1. #24

Closed rainwoodman closed 7 years ago

rainwoodman commented 7 years ago

It is a scalar.

arteymix commented 7 years ago

However, the shape and strides are empty, no?

rainwoodman commented 7 years ago

Yes.

rainwoodman commented 7 years ago

They are empty. I also think of it this way. size = product(shape). the identity of product operator is 1. So if len(shape) == 0, the product shall be 1.

arteymix commented 7 years ago

I fixed that and added some tests in 97f95d75a567d19338efca1b9033c919e07fb251

I just had to fix the specific case of empty array and did not notice that dimension 0 were used for scalars. I added tests to ensure correct behaviours.

arteymix commented 7 years ago

We can index scalar array with array.get_value ({}). I think it's good for now with the tests.