+
+
+/** Helper template to allow initialization of matrices via an overloaded
+ * comma operator (idea stolen from Blitz++). */
+template <typename T, typename It>
+class matrix_init {
+public:
+ matrix_init(It i) : iter(i) {}
+
+ matrix_init<T, It> operator,(const T & x)
+ {
+ *iter = x;
+ return matrix_init<T, It>(++iter);
+ }
+
+ // The following specializations produce much tighter code than the
+ // general case above
+
+ matrix_init<T, It> operator,(int x)
+ {
+ *iter = T(x);
+ return matrix_init<T, It>(++iter);
+ }
+
+ matrix_init<T, It> operator,(unsigned int x)
+ {
+ *iter = T(x);
+ return matrix_init<T, It>(++iter);
+ }
+
+ matrix_init<T, It> operator,(long x)
+ {
+ *iter = T(x);
+ return matrix_init<T, It>(++iter);
+ }
+
+ matrix_init<T, It> operator,(unsigned long x)
+ {
+ *iter = T(x);
+ return matrix_init<T, It>(++iter);
+ }
+
+ matrix_init<T, It> operator,(double x)
+ {
+ *iter = T(x);
+ return matrix_init<T, It>(++iter);
+ }
+
+ matrix_init<T, It> operator,(const symbol & x)
+ {
+ *iter = T(x);
+ return matrix_init<T, It>(++iter);
+ }
+
+private:
+ matrix_init();
+ It iter;
+};
+