RSS Forums RSS
Please support our Computer Science and Software Design advertiser: Programming Forums
Views: 683 | Replies: 4
Reply
Join Date: Sep 2007
Posts: 10
Reputation: drichird is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
drichird drichird is offline Offline
Newbie Poster

vector (1xm array) comparisons

  #1  
Apr 22nd, 2008
In linear algebra a 1 by m array of (let's say integers) can be considered a vector (row or column). Given 2 row vectors of the same size, can they be compared using <,> ? If so, what relation between individual elements in the arrays is required for "less than" to be true?

Is vector {2,3,3} < vector {2,3,4}...

...or does every element have to be less (i.e. {1,2,3} < {2,3,4} but not so for {2,3,3})
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,923
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 452
Colleague
Salem's Avatar
Salem Salem is offline Offline
Senior Poster

Re: vector (1xm array) comparisons

  #2  
Apr 23rd, 2008
Does your linear algebra text book describe a "less than" operation?

If so, then it would be perfectly possible to write some code to do the same thing.

Now whether std::vector implements that or not is for you to research, or maybe you can implement your own vector class.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Reply With Quote  
Join Date: Oct 2007
Location: Cambridge, MA
Posts: 269
Reputation: sarehu is on a distinguished road 
Rep Power: 2
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: vector (1xm array) comparisons

  #3  
Apr 23rd, 2008
Originally Posted by Salem View Post
Does your linear algebra text book describe a "less than" operation?


No.
Reply With Quote  
Join Date: Sep 2007
Posts: 10
Reputation: drichird is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
drichird drichird is offline Offline
Newbie Poster

Re: vector (1xm array) comparisons

  #4  
Apr 23rd, 2008
Originally Posted by Salem View Post
Does your linear algebra text book describe a "less than" operation?

If so, then it would be perfectly possible to write some code to do the same thing.

Now whether std::vector implements that or not is for you to research, or maybe you can implement your own vector class.


I had not thought of looking at C++ vector class, that was a good point. It would appear std::vector supports comparisons on a lexicographic basis, in which cas {2,3,3} is less than {2,3,4}. That's fine, but what I was really wondering is not how to implement comparisons programatically but if "<" or ">" are defined (for row/column vectors) from a mathematical, linear algebra standpoint. I don't think so, I don't see anything in any books I have. They only talk about "=", "+", "-", and "*".
Reply With Quote  
Join Date: Oct 2007
Location: Cambridge, MA
Posts: 269
Reputation: sarehu is on a distinguished road 
Rep Power: 2
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: vector (1xm array) comparisons

  #5  
Apr 23rd, 2008
There are no standard mathematical definitions for the comparison of vectors. You could compare properties of vectors -- by 'property' I mean functions that take vectors and produce real numbers. You could compare vectors' lengths, their first coordinates, etc.

The thing is, as long as you're measuring a property represented by a continuous function, you're going to have vectors that compare equally (for example, if their lengths are equal). There are also some comparison functions that don't correspond to any 'property' that can be measured by real numbers. Lexicographical ordering would be one of these.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:29 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC