3 ms·
What makes a C++/Rust/etc vector distinct from an array is that it's resizable. That is its defining property. On the other hand, a mathematical vector is not
by jholman 9y ago
What makes a C++/Rust/etc vector distinct from an array is that it's resizable. That is its defining property.
On the other hand, a mathematical vector is not a resizable thing: a vector in R² is of a fundamentally different type from a vector in R³.
A type named "vector" should be more like Vec<T, n> for some type T and some integer n. Failing that, the reasonable representation of an n-length mathematical vector, in C++/whatever, is an array.
- gpm 9y agoThe whole idea of mutation is not common in mathematics, so of course mathematical vectors don't commonly resize. The idea of appending an element to make a new vector is however extremely common, particularly in induction like proofs. Vec<T, n> is in a sense already what we have, it's just that we are not capable of storing the n in the type information^0 so we store it at runtime. ^0 For a number of reasons. n can change with mutation while types can't. We don't necessarily know n ahead of time when building a vector (which happens in math too) but we have to know types at compile time. And we just don't have a great way of storing numbers in types in Rust anyways.