Alex Rivera | Logout

What are vectors and how are they used in programming?

Asked 2009-02-03T18:44:06.223
69

I'm familiar with the mathematical/physics concept of a vector as a magnitude and a direction, but I also keep coming across references to vectors in the context of programming (for example C++ seems to have a stl::vector library which comes up fairly frequently on SO).

My intuition from the context has been that they're a fairly primitive construct most often used to represent something along the lines of a variable length array (storing its size as the magnitude, I presume), but it would be really helpful if somebody could provide me with a more complete explanation, preferably including how and why they're used in practice.

Edit
Report

1 Answer

7

The mathematical vectors you're used to are tensors of rank one; the data structures in computer science don't necessarily obey the tensor transformation rules. They're just arrays that can expand and contract, as noted earlier.

answered 2009-02-03T18:51:06.833

Your Answer