+ex minimal_dim(const ex & dim1, const ex & dim2)
+{
+ if (dim1.is_equal(dim2) || dim1 < dim2 || (is_exactly_a<numeric>(dim1) && is_a<symbol>(dim2)))
+ return dim1;
+ else if (dim1 > dim2 || (is_a<symbol>(dim1) && is_exactly_a<numeric>(dim2)))
+ return dim2;
+ else
+ throw (std::runtime_error("minimal_dim(): index dimensions cannot be ordered"));
+}
+