Bug 1384

Summary: Several helper functions for Vector class
Product: ns-3 Reporter: Alex Afanasyev <alexander.afanasyev>
Component: coreAssignee: Mathieu Lacage <mathieu.lacage>
Status: PATCH PENDING ---    
Severity: normal CC: ns-bugs, tomh
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: patch

Description Alex Afanasyev 2012-02-29 21:28:26 UTC
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 UTC
Created attachment 1348 [details]
patch
Comment 2 Tommaso Pecorella 2012-03-14 19:30:42 UTC
+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.

T.
Comment 3 Mathieu Lacage 2012-04-24 08:32:13 UTC
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.