3 ms·
What do you mean?
by tkuraku 4y ago
What do you mean?
- hprotagonist 4y agoin matlab: >> size(4) ans = 1 1 which is 1. wrong and 2. evidence that matlab cannot represent numerical objects of less than rank 2. Numpy can: >> np.shape(4) ()
- ModernMech 4y agoI'm confused by what you mean. In Matlab, everything is a matrix. A naked integer is a 1x1 matrix, hence why the size is reported as [1 1]. Those are the semantics of the language, not a lie.
- hprotagonist 4y agoa naked integer is not a 1x1 matrix, it’s a 0x0. Matlab silently promotes it to one, though, which is a deliberately misleading thing to do because it’s convenient for matlab’s data model. i think it’s fair to call that a (white) lie
- ModernMech 4y ago> a naked integer is not a 1x1 matrix, it’s a 0x0 Do you have a link to where this is asserted in the documentation? I'm confused as to the basis for this.
- hprotagonist 4y agohttps://mathworld.wolfram.com/TensorRank.html https://mathworld.wolfram.com/TensorRank.html it should be clear that i don’t care very much about what matlab has to represent things as. i don’t mean “matlab integers”, i mean the mathematical objects; matlab’s representation of them is poor.
- ModernMech 4y agoOkay, well that's not Matlab lying, that's you not understanding how the tool works. It would be like saying that 0.1 + 0.2 == 0.3 evaluating to false is a lie, because floating point numbers don't accurately represent real numbers as a concept. But floating point numbers aren't actually real numbers, and integers in Matlab (they're actually stored as floating point doubles, is that a lie too?) aren't actually mathematical objects. You have to work within the constraints of the tool. Matlab makes it very clear upfront that the semantics of the language mean that naked numbers are in fact matrices, because everything in the language is a matrix. Maybe you feel that's not a good representation, but it's not a lie, and in fact it's very consistent and useful in the context of the language itself.