News for hackers. Stuff that matters.
Re:Rust: Enable WebAssembly backend by default by gpm on Sunday November 26, 2017 @04:53PM (#15783245)
I think it agrees pretty well with the mathematical definition, it's just a slight generalization.

A Rust (C++, etc) Vec<T> of length n where T implements addition and multiplication in a way that satisfies field laws is the "reasonable" representation of a n length "mathematical" vector over the field T. It just generalizes that storage type to situations where T is not a field.

It doesn't support addition of two vectors and multiplication by a element of T using the normal mathematical syntax, but that's a fairly reasonable choice given how we regularly use vectors as a sequence of independent numbers and the different priorities for math syntax and programming language syntax.

Re:Rust: Enable WebAssembly backend by default by jholman on Sunday November 26, 2017 @08:47PM (#15784244)
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.

Re:Rust: Enable WebAssembly backend by default by gpm on Monday November 27, 2017 @08:50AM (#15787257)
The 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.

Re:Rust: Enable WebAssembly backend by default by kccqzy on Sunday November 26, 2017 @05:58PM (#15783584)
Just to clarify, a vector space is defined over a field but vectors themselves do not form a field.

Also more importantly in mathematics vectors aren’t really growable. When you change the number of elements you change the dimension (and thus the “type” for that vector). It is then ill-defined to add two vectors of different dimensions.