20121225

words, truth and reality

the problem with playing with words or truth or reality is that if you play with them for long enough, you forget what they actually are.


what is a vector?

i was talking to my wife today about this comment on hacker news and i realized i keep in my head several simultaneous but non-obvious definitions for the term "vector". there are at least 3 different common understandings of this word, depending on what field of science or technology you are familiar with.

physics, math, chemistry(?):

from my time as a math/physics major in college i was familiar with the term vector in a technical sense as meaning "a magnitude and a direction". or, symbolically, an arrow, whose size indicates the magnitude of the represented quantity.

so for the canonical example: john, walking at 5 kilometers per hour is a speed, but john, walking at 5 kilometers per hour to the northeast is a vector.

programming, computer science:

in programming, it appears that the term vector usually means something like a re-sizable array. that is, a contiguous sequence of memory locations that can hold arbitrary values, but which unlike a c language array, can be resized transparently to allow more (or less) values to be added to the structure after it’s initial creation.

i believe this terminology was popularized from it’s usage as a data type in c++. java seems to use the same terminology. it seems to go by the term "array slice" in go unless i’m getting confused (which is possible).

in this form, it is contrasted with a linked list, which is a (potentially) non-contiguous group of memory structures that are linked one to another because each constituent substructure holds the address of the "next" substructure in the list. typically a linked list can hold arbitrary values, and new values can be inserted at arbitrary points and at arbitrary times, by rewriting the memory references on either side of the new data item.

a vector can also be contrasted with an "array" (used here in the c language sense) which in this analysis is the simplified or degenerate form of a vector in that an array is contiguous but fixed in form once defined. that is, an array is defined to hold a certain number and type of elements, and once defined, the memory is set aside and allocated. however, once defined, one cannot change the number of elements in an array. instead one must create a new array with the desired size and then copy the desired elements into the new array.

under the covers, if you took a snapshot of a vector at a point in time, it would like like a c array.

update: see here for a very good explanation of c arrays vs implementing higher level language "vectors".

biology, medicine, social sciences(?):

in these fields the term vector refers to something like the idea of a "path". that is, the route that some item takes to get from one point to another. in graph terms it is probably something like a directed edge, or perhaps a sequence of directed edges.

for example, if there is a parasite that moves from birds to humans via the mechanism of birds pooping on cars, and humans cleaning up the bird poop, then i believe the poop would be considered the vector. but perhaps if birds pooped and rats ate the poop and then bit humans to transfer the parasite, the rats would be the vector. or perhaps the vector would be more technically poop -> rat -> human. i’m less sure on this last point.

consider the compound term "disease vector" as a similar example.

are there other common definitions of the term "vector" that people know and use? if so, i’d be interested to hear.

update: see patrick moran’s comment (copied below) for two other uses that are often assumed in technical documents.

you might also note the use of vector in computer science to mean a small static sized array that one can act one with simd instructions. the whole process is known as vectorizing your code, one individual segment of some (2, 4, 8, maybe more) numbers next to each other is known as a vector. processors that work with them are known as vector processors.

http://en.wikipedia.org/wiki/vectorization_(parallel_computing)

there is also vector as in vector graphics (as opposed to raster graphics). this describes image representations like svg that can be thought of as programmatically drawing the image rather than representing it as a 2d array of pixels. this use of vector is different from the math/physics one in that the vectors are arbitrary curves, not necessarily straight lines. http://en.wikipedia.org/wiki/vector_graphics

Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s