mathjs icon indicating copy to clipboard operation
mathjs copied to clipboard

range() returning dense matrix?

Open pjmattingly opened this issue 4 years ago • 1 comments

math.range(0, 10, 1)

Should return an array, but instead it returns a matrix? That's very strange behaviour; Am I missing something?

The docs say it can return an array or a matrix. I assumed that if I gave it matrix inputs (to make a mesh for instance), I'd get a matrix output; But instead with simple number inputs we get a matrix instead.

https://mathjs.org/docs/reference/functions/range.html

This gives the expected result:

math.range(0, 10, 1).toArray()

pjmattingly avatar Oct 07 '21 12:10 pjmattingly

You can configure whether the function returns a Matrix or an Array using the configuration option matrix: 'Array', see docs https://mathjs.org/docs/core/configuration.html

josdejong avatar Oct 09 '21 15:10 josdejong