X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fidx.cpp;h=f69613c69065652569bc7adeb524e0f6ac6bf4e7;hp=26d63910cbfdf0ed395fefee25dadb81a0726196;hb=af6809f55c95cf6ea6ef80bd1d19637a06f32e5a;hpb=bf82f5b1d41738936afe763e1fa6aa347c81ba2c diff --git a/ginac/idx.cpp b/ginac/idx.cpp index 26d63910..f69613c6 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's indices. */ /* - * GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ */ #include +#include #include #include "idx.h" @@ -449,12 +450,7 @@ ex idx::replace_dim(const ex & new_dim) const ex idx::minimal_dim(const idx & other) const { - if (dim.is_equal(other.dim) || dim < other.dim || (is_exactly_a(dim) && is_a(other.dim))) - return dim; - else if (dim > other.dim || (is_a(dim) && is_exactly_a(other.dim))) - return other.dim; - else - throw (std::runtime_error("idx::minimal_dim: index dimensions cannot be ordered")); + return GiNaC::minimal_dim(dim, other.dim); } ex varidx::toggle_variance(void) const @@ -545,4 +541,17 @@ void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator i out_free.push_back(*last); } +ex minimal_dim(const ex & dim1, const ex & dim2) +{ + if (dim1.is_equal(dim2) || dim1 < dim2 || (is_exactly_a(dim1) && is_a(dim2))) + return dim1; + else if (dim1 > dim2 || (is_a(dim1) && is_exactly_a(dim2))) + return dim2; + else { + std::ostringstream s; + s << "minimal_dim(): index dimensions " << dim1 << " and " << dim2 << " cannot be ordered"; + throw (std::runtime_error(s.str())); + } +} + } // namespace GiNaC