473,545 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Isn't 'vector' a misnomer?

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<dou ble> 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<dou ble> 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 3276

"Carlo Milanesi" <ca************ ********@libero .it> wrote in message
news:2003111323 3531.2c53c12a.c a************** ******@libero.i t...
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<dou ble> 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<dou ble> 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
Hi Carlo Milanesi,

"Carlo Milanesi" <ca************ ********@libero .it> schrieb im Newsbeitrag
news:2003111323 3531.2c53c12a.c a************** ******@libero.i t...
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
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<dou ble> 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<dou ble> 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
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
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

"Carlo Milanesi" <ca************ ********@libero .it> wrote in message
news:2003111323 3531.2c53c12a.c a************** ******@libero.i t...
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<dou ble> 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<dou ble> 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

"Xenos" <do**********@s pamhate.com> wrote in message
news:bp******** *@cui1.lmms.lmc o.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
Mike Wahler wrote:

"Xenos" <do**********@s pamhate.com> wrote in message
news:bp******** *@cui1.lmms.lmc o.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
Xenos wrote:
Carlo Milanesi wrote:
Mathematicall y 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<d ouble> 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<d ouble> 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.


No. It *is* a misnomer.
It doesn't fit in with the jargon of *any* discipline.
Deal with it.

Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3197
by: {AGUT2}=IWIK= | last post by:
Hello all, It's my fisrt post here and I am feeling a little stupid here, so go easy.. :) (Oh, and I've spent _hours_ searching...) I am desperately trying to read in an ASCII "stereolithography" file (*.STL) into my program. This has the following syntax... Begin STL Snippet **********
9
2961
by: luigi | last post by:
Hi, I am trying to speed up the perfomance of stl vector by allocating/deallocating blocks of memory manually. one version of the code crashes when I try to free the memory. The other version seem to work. I would appreciate someone to comment on this. Version 1 (crashes on deallocating) #include <iostream>
7
10614
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using namespace std; : : vector<string>* getTyphoon()
14
2313
by: lutorm | last post by:
Hi everyone, I'm trying to use istream_iterators to read a file consisting of pairs of numbers. To do this, I wrote the following: #include <fstream> #include <vector> #include <iterator> using namespace std;
10
4820
by: Bob | last post by:
Here's what I have: void miniVector<T>::insertOrder(miniVector<T>& v,const T& item) { int i, j; T target; vSize += 1; T newVector; newVector=new T;
8
5095
by: Ross A. Finlayson | last post by:
I'm trying to write some C code, but I want to use C++'s std::vector. Indeed, if the code is compiled as C++, I want the container to actually be std::vector, in this case of a collection of value types or std::vector<int>. So where I would use an int* and reallocate it from time to time in C, and randomly access it via , then I figure to...
14
2170
by: artifact.one | last post by:
It'd be really pleasant (in my opinion) if the next revision of the C language actually allowed some portable control over data alignment. Compiler-specific mechanisms for this stuff are so varied that it becomes impossible to even abstract the details away behind preprocessor macros. What I'd like to see:
15
1870
by: ianweise | last post by:
hello, before i post my code for this, is there anyone out there at this moment? no sense in posting if no one is out there to read and answer it =P
6
5689
by: arnuld | last post by:
This works fine, I welcome any views/advices/coding-practices :) /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a program to store each line from a file into a * vector<string>. Now, use istringstream to read read each line * from the vector a word at a time.
0
7393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7411
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5965
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5322
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4942
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1871
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.