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 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
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.
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.
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 :-)
Carlo Milanesi wrote: Why they were so dumb to call it 'vector', instead of, say, 'sequence'?
'sequence' already has another meaning in C++.
"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.
"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
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? :-)
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
**********
|
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>
|
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()
|
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;
|
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;
| |
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...
|
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:
|
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
|
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.
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |