Bug 1384 - Several helper functions for Vector class
Several helper functions for Vector class
Product: ns-3
Classification: Unclassified
Component: core
All All
: P5 normal
Assigned To: Mathieu Lacage
Depends on:
  Show dependency treegraph
Reported: 2012-02-29 21:28 EST by Alex Afanasyev
Modified: 2012-04-24 08:32 EDT (History)
2 users (show)

See Also:

patch (4.73 KB, patch)
2012-02-29 21:28 EST, Alex Afanasyev
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Afanasyev 2012-02-29 21:28:26 EST
To following patch implements a useful set of helpers that can simplify various calculations on vectors.  The set is incomplete and if people think this would be useful, I can add missing operations.

- Math operators with double: +, +=, *, -, /
- Math operators (component-wise) with another vector: +, +=, *, -
- length of the vector (Euclidean distance from 0,0,0)
- scalar vector multiplication
Comment 1 Alex Afanasyev 2012-02-29 21:28:47 EST
Created attachment 1348 [details]
Comment 2 Tommaso Pecorella 2012-03-14 19:30:42 EDT
+1 (with the missing operators).

Since ns-3 might be linked also with boost, and boost does have vector 
rtemplates, it might be as well interesting to have casting operators (if 
possible). On the other hand they'd need to be compilation-aware, as boost 
might be missing as well.

Comment 3 Mathieu Lacage 2012-04-24 08:32:13 EDT
1) ScalarMultiplication is a really bad misnomer. 
2) The operator coverage is far from complete. Most users who might use your operators will simply not understand why some are implemented and others are not and they will not know what to do when their code fails to build with strange compiler messages. i.e., the outcome of missing operators is very surprising for most users.