]> git.tdb.fi Git - libs/math.git/blobdiff - source/linal/dynamicvector.h
Add formatted output operators for vector and matrix classes
[libs/math.git] / source / linal / dynamicvector.h
index 8839c3365dd34f264c7653892e3ce2ada81210d9..a5379d87002cdea25b4059629c1eb5a4c96b358f 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <algorithm>
 #include <cmath>
+#include <ostream>
 #include <stdexcept>
 
 namespace Msp {
@@ -243,6 +244,20 @@ inline DynamicVector<T> normalize(const DynamicVector<T> &v)
        return r.normalize();
 }
 
+template<typename T>
+inline std::ostream &operator<<(std::ostream &s, const DynamicVector<T> &v)
+{
+       s << "DynamicVector" << v.size() << '(';
+       for(unsigned i=0; i<v.size(); ++i)
+       {
+               if(i)
+                       s << ", ";
+               s << v[i];
+       }
+       s << ')';
+       return s;
+}
+
 } // namespace LinAL
 } // namespace Msp