446,131 Members | 2,055 Online
Need help? Post your question and get tips & solutions from a community of 446,131 IT Pros & Developers. It's quick & easy.

# Isn't 'vector' a misnomer?

 P: n/a Mathematically speaking, a 'vector' is something you can add to another vector and multiply by a number. But in C++, the following code is illegal: std::vector v1(3), v2(3); v1 + v2; // Illegal v1 * 2.; // Illegal In addition, vectors of different dimensions belong two different spaces (types). But in C++, the following code is legal: std::vector v1(2), v2(3); v1 = v2; // Legal Why they were so dumb to call it 'vector', instead of, say, 'sequence'? -- Carlo Milanesi http://digilander.libero.it/carlmila Jul 19 '05 #1
19 Replies

 P: n/a "Carlo Milanesi" wrote in message news:20031113233531.2c53c12a.ca******************* *@libero.it... Mathematically speaking, a 'vector' is something you can add to another vector and multiply by a number. But in C++, the following code is illegal: std::vector v1(3), v2(3); v1 + v2; // Illegal v1 * 2.; // Illegal That's because C++ is a programming language, not mathematics. In addition, vectors of different dimensions belong two different spaces (types). But in C++, the following code is legal: std::vector v1(2), v2(3); v1 = v2; // Legal That says v1 = v2, not v1 == v2. Why they were so dumb to call it 'vector', instead of, say, 'sequence'? Because they didn't have to adhere to predetermined meanings of words. What do you think "program" meant before computers were invented? See http://wombat.doc.ic.ac.uk/foldoc/fo...&action=Search Jul 19 '05 #2

 P: n/a Hi Carlo Milanesi, "Carlo Milanesi" schrieb im Newsbeitrag news:20031113233531.2c53c12a.ca******************* *@libero.it... Mathematically speaking, a 'vector' is something you can add to another vector and multiply by a number. But in C++, The term is of historical origins. Since the BCPL programming language (the ancestor of C), arrays have been called "vectors". :-) (perhaps b/c that's what they've been used for by the BCPL language inventor Martin Richards, or other people in the 1960ies or earlier even) I hope this helps. Regards, Ekkehard Morgenstern. Jul 19 '05 #3

 P: n/a Carlo Milanesi wrote: Mathematically speaking, a 'vector' is something that you can add to another vector and multiply by a number. But in C++, the following code is illegal: std::vector v1(3), v2(3); v1 + v2; // Illegal v1*2.0; // Illegal In addition, vectors of different dimensions belong two different spaces (types). But in C++, the following code is legal: std::vector v1(2), v2(3); v1 = v2; // Legal Why they were so dumb to call it 'vector', instead of, say, 'sequence'? According to Bjarne Stroustrup, "The C++ Programming Language: Third Edition", Chapter 22: Numerics, Section 4: Vector Arithmetic, page 662: "One could argue that /valarray/ should have been called /vector/ because it is a traditional mathematical vector and that /vector/ should have been called /array/." Evidently, Bjarne agrees with you. The standard vector class is actually a flexible [dynamic] array class. It probably isn't the best choice for vector arithmetic. If you want to use a standard C++ class template, use valarray. Jul 19 '05 #4

 P: n/a E. Robert Tisdale wrote: According to Bjarne Stroustrup, "The C++ Programming Language: Third Edition", Chapter 22: Numerics, Section 4: Vector Arithmetic, page 662: "One could argue that /valarray/ should have been called /vector/ because it is a traditional mathematical vector and that /vector/ should have been called /array/." Evidently, Bjarne agrees with you. Well, he only said that "One could argue", not that he does :-) Jul 19 '05 #5

 P: n/a Carlo Milanesi wrote: Why they were so dumb to call it 'vector', instead of, say, 'sequence'? 'sequence' already has another meaning in C++. Jul 19 '05 #6

 P: n/a "Carlo Milanesi" wrote in message news:20031113233531.2c53c12a.ca******************* *@libero.it... Mathematically speaking, a 'vector' is something you can add to another vector and multiply by a number. But in C++, the following code is illegal: std::vector v1(3), v2(3); v1 + v2; // Illegal v1 * 2.; // Illegal In addition, vectors of different dimensions belong two different spaces (types). But in C++, the following code is legal: std::vector v1(2), v2(3); v1 = v2; // Legal Why they were so dumb to call it 'vector', instead of, say, 'sequence'? -- Carlo Milanesi http://digilander.libero.it/carlmila You could say that about a lot terms, such as functor. Different fields use the same terms for different things. Just ask a chemist and an astrologer (astrophysicist?) what "metal" means. You will get to different answers. Deal with it. Jul 22 '05 #7

 P: n/a "Xenos" wrote in message news:bp*********@cui1.lmms.lmco.com... You could say that about a lot terms, such as functor. Different fields use the same terms for different things. Just ask a chemist and an astrologer (astrophysicist?) what "metal" means. It's a style of rock music. :-) -Mike Jul 22 '05 #8

 P: n/a Mike Wahler wrote: "Xenos" wrote in message news:bp*********@cui1.lmms.lmco.com... You could say that about a lot terms, such as functor. Different fields use the same terms for different things. Just ask a chemist and an astrologer (astrophysicist?) what "metal" means. It's a style of rock music. :-) Would the chemist say that or the astrologer? :-) Jul 22 '05 #9

 P: n/a Xenos wrote: Carlo Milanesi wrote:Mathematically speaking, a 'vector' is something you can add to anothervector and multiply by a number. But in C++, the following code isillegal:std::vector v1(3), v2(3);v1 + v2; // Illegalv1 * 2.; // IllegalIn addition, vectors of different dimensions belong two different spaces(types). But in C++, the following code is legal:std::vector v1(2), v2(3);v1 = v2; // LegalWhy they were so dumb to call it 'vector', instead of, say, 'sequence'?--Carlo Milanesihttp://digilander.libero.it/carlmila You could say that about a lot terms, such as functor. Different fields use the same terms for different things. No. It *is* a misnomer. It doesn't fit in with the jargon of *any* discipline. Deal with it. Jul 22 '05 #10

 P: n/a "Rolf Magnus" wrote in message news:bp*************@news.t-online.com... Mike Wahler wrote: "Xenos" wrote in message news:bp*********@cui1.lmms.lmco.com... You could say that about a lot terms, such as functor. Different fields use the same terms for different things. Just ask a chemist and an astrologer (astrophysicist?) what "metal" means. It's a style of rock music. :-) Would the chemist say that or the astrologer? :-) An astrochemist. You know, the ones that make 'out-of-this-world' recreational substances. :-) -Mike Jul 22 '05 #11

 P: n/a "E. Robert Tisdale" writes: Xenos wrote: Carlo Milanesi wrote:Mathematically speaking, a 'vector' is something you can add to anothervector and multiply by a number. But in C++, the following code isillegal:std::vector v1(3), v2(3);v1 + v2; // Illegalv1 * 2.; // IllegalIn addition, vectors of different dimensions belong two different spaces(types). But in C++, the following code is legal:std::vector v1(2), v2(3);v1 = v2; // LegalWhy they were so dumb to call it 'vector', instead of, say, 'sequence'?--Carlo Milanesihttp://digilander.libero.it/carlmila You could say that about a lot terms, such as functor. Different fields use the same terms for different things. No. It *is* a misnomer. It doesn't fit in with the jargon of *any* discipline. Deal with it. The term 'vector' has been used for quite some time (long before C++) in Computer Science to refer to what is also frequently referred to as an array. You will find it in many good, older CS textbooks. No idea where this usage originated, but it is definitely precedented, and seems quite appropriate, given that the term "array" is already in use for something else. Also, the term "sequence" is used in C++ to refer to a group of containers that include the list, queue, deque, and other classes. "Sequence" would be far to general to be an appropriate term for this beast, at any rate. -- Micah J. Cowan mi***@cowan.name Jul 22 '05 #12

 P: n/a Micah Cowan wrote: The term 'vector' has been used for quite some time (long before C++) in Computer Science to refer to what is also frequently referred to as an array. No. A vector is an array of *numbers*. You will find it in many good, older CS textbooks. Please cite and quote one of these older CS textbooks. I have no idea where this usage originated Probably with Fortran which, until Fortran 90, had no notion of vectors so Fortran programmers were forced to *improvise* with arrays of numbers and *pretend* that they were vectors. Until Fortran 90 and the introduction of derived types, arrays were always arrays of numbers (or characters). Note that vector arithmetic operations *are* defined on Fortran 90/95/00 arrays of numbers so they really are vectors now but Fortran programmers still use the term "array" to describe them. but there is definitely a precedent and it seems quite appropriate, given that the term "array" is already in use for something else. Check out The American Heritage Dictionary of the English Language http://www.bartleby.com/61/ array 5. Computer Science An arrangement of memory elements in one or more planes. vector 1. Mathematics a. A quantity, such as velocity, completely specified by a magnitude and a direction. b. A one-dimensional array. c. An element of a vector space. In computer science, an array is an array of memory elements of *any* type. A vector, on the other hand, is and array of numbers -- a numerical quantity upon which the operations of vector arithmetic are defined. This definition does *not* apply to the standard vector class template. The word "array" is *not* a reserved keyword in the C++ computer programming language or in the standard C++ library. Also, the term "sequence" is used in C++ to refer to a group of containers that include the list, queue, deque, and other classes. "Sequence" would be far to general to be an appropriate term for this beast, at any rate. I don't think sequence is a good name for any standard C++ container class [template]. Sometimes programmers choose names for new types unwisely. In the case of the standard vector class template, this was an unfortunate mistake that we are stuck with. Don't look for any wisdom in this choice because there simply isn't any. Jul 22 '05 #13

 P: n/a "Mike Wahler" wrote in message news:en*****************@newsread2.news.pas.earthl ink.net... An astrochemist. You know, the ones that make 'out-of-this-world' recreational substances. :-) You're thinking of a cosmetologist. Jul 22 '05 #14

 P: n/a "E. Robert Tisdale" writes: Micah Cowan wrote: The term 'vector' has been used for quite some time (long before C++) in Computer Science to refer to what is also frequently referred to as an array. No. A vector is an array of *numbers*. There is absolutely no reason to restrict it to numbers in CS, nor have I ever seen this restriction in practice. In fact, Scheme calls its general-purpose array type "vector". The following search on google turns up scads of non-C++ usages of the term "vector" in exactly the way I asserted it is used, in addition to usages of its mathematical meaning of course: http://www.google.com/search?q=%22ve...2B+programming Among these is a reference to Scheme, and a reference from a csh manual stating that all local variables are "vectors of strings". Check out The American Heritage Dictionary of the English Language http://www.bartleby.com/61/ array 5. Computer Science An arrangement of memory elements in one or more planes. vector 1. Mathematics a. A quantity, such as velocity, completely specified by a magnitude and a direction. b. A one-dimensional array. c. An element of a vector space. 1b fits my definition. As does FOLDOC's definition: 4. A one-dimensional {array}. In computer science, an array is an array of memory elements of *any* type. A vector, on the other hand, is and array of numbers -- a numerical quantity upon which the operations of vector arithmetic are defined. In Math. Not in CS. I have almost never seen the term "vector" used in CS to actually refer to anything having to do with vector arithmetic, unless the problem currently being solved actually had to do with vector math. The word "array" is *not* a reserved keyword in the C++ computer programming language or in the standard C++ library. I didn't say it was. However, it is a word reserved for an entirely different usage in both the C++ Standard and in C and C++ terminology. Also, the term "sequence" is used in C++ to refer to a group of containers that include the list, queue, deque, and other classes. "Sequence" would be far to general to be an appropriate term for this beast, at any rate. I don't think sequence is a good name for any standard C++ container class [template]. I didn't say you did. That statement was directed at Carlo. Sometimes programmers choose names for new types unwisely. In the case of the standard vector class template, this was an unfortunate mistake that we are stuck with. Don't look for any wisdom in this choice because there simply isn't any. It still fits in quite nicely with the usage in which I have seen it. -- Micah J. Cowan mi***@cowan.name Jul 22 '05 #15

 P: n/a "jeffc" wrote in message news:<3f********@news1.prserv.net>... "Mike Wahler" wrote in message news:en*****************@newsread2.news.pas.earthl ink.net... An astrochemist. You know, the ones that make 'out-of-this-world' recreational substances. :-) You're thinking of a cosmetologist. Um, a cosmetologist is someone who applies women's make up (cosmetics). I hope you meant cosmologist. Jack Walker Jul 22 '05 #16

 P: n/a Micah Cowan wrote in message news:... Sometimes computer programmers have a narrow world view and an inflated sense of importance and do not consider established meanings of words that they adopt for program element names. On the otherhand as a mathematician I know that a vector space is an ordered quadruple consisting of a set of elements called vectors, a set of elements called scalers, and the operations vector addition and scaler multiplication. The vectors can be anything you can concieve of for which you can define the other 3 components. The set of continously differentable functions is an infinite dimensional vector space with the complex numbers as scalers. STL vectors do not define scalers, scaler multiplication, nor vector addition so as far as I am concerned they are not vectors. However this a minor flaw and given all of the other advantages of the STL it can be overlooked. Jack Walker Jul 22 '05 #17

 P: n/a Perhaps you're both right. Mr. Tisdale makes an interesting point about the origin of this usage, i.e., that in Fortran 90 arrays were used to *implement* the mathematical concept of a vector. It seems plausible to me that people conflated the implementation of the concept with the concept itself, leading to the widespread use of the term 'vector' to mean 'any one-dimensional array'. Thus, one could argue that this usage of 'vector' originated in a misunderstanding. On the other hand, it is also clear that this usage of the term long predates the C++ standard, and has long been widespread within the computer science community as a whole. Thus, the C++ standard and STL merely follow a usage that (while perhaps originating in error) is quite normal in Computer Science. I would compare this with the way dictionaries work. Consider a word like "nauseous". Both Webster and the American Heritage provide two definitions of this word. The second usage was once considered "wrong", but has since been accepted as correct by both dictionaries. http://www.m-w.com/cgi-bin/dictionar...ry&va=nauseous http://www.bartleby.com/61/32/N0033200.html Dictionaries are both prescriptive and descriptive. They tend to reinforce "normal" usage (prescriptive) but also adapt (with some latency) as the norm changes over time (descriptive). Jul 22 '05 #18

 P: n/a "E. Robert Tisdale" wrote in message news:<3F************@jpl.nasa.gov>... Xenos wrote: Carlo Milanesi wrote: [snip] You could say that about a lot terms, such as functor. Different fields use the same terms for different things. No. It *is* a misnomer. It doesn't fit in with the jargon of *any* discipline. Deal with it. Wouldn't namespaces and typedef(s) make this issue trivial? As an aside, classes and operator overloading give the ability for you to create any type you wish and name it anything you *feel* is appropriate and operate with expected behavior from which the objects domain is modeled under, correct? Combine this with the above satement and this issue is beyond irrelevant and extremely easy to "deal with it", right? Not trolling - just curious if I have been applying what I know of the language correctly on both technical and "moral" principles such as this. -Chris Jul 22 '05 #19

 P: n/a "C Johnson" wrote in message news:63**************************@posting.google.c om... "E. Robert Tisdale" wrote in message news:<3F************@jpl.nasa.gov>... Xenos wrote: Carlo Milanesi wrote: [snip] You could say that about a lot terms, such as functor. Different fields use the same terms for different things. No. It *is* a misnomer. It doesn't fit in with the jargon of *any* discipline. Deal with it. Wouldn't namespaces and typedef(s) make this issue trivial? As an aside, classes and operator overloading give the ability for you to create any type you wish and name it anything you *feel* is appropriate and operate with expected behavior from which the objects domain is modeled under, correct? Combine this with the above ^^^^^^ That's the key issue here, imo. satement and this issue is beyond irrelevant and extremely easy to "deal with it", right? Not trolling - just curious if I have been applying what I know of the language correctly on both technical and "moral" principles such as this. -Chris You make good points. For example, the term 'window' is often used to refer to a rectangular section of a video display. It's not really a 'window' but the term 'window' is used as a metaphor. Another common metaphor is the MS-Windows 'desktop'. Robert ignores context. -Mike Jul 22 '05 #20

### This discussion thread is closed

Replies have been disabled for this discussion.