From 4c47ecd9caa39ba1a31f5294e395fcbdf2006431 Mon Sep 17 00:00:00 2001 From: Jens Vollinga Date: Thu, 18 Dec 2008 12:19:35 +0100 Subject: [PATCH] Small fixes to avoid compile warnings (-Wall). --- ginac/clifford.cpp | 21 ++++++++++++++------- ginac/inifcns_nstdsums.cpp | 6 +++--- ginac/mul.cpp | 2 +- ginac/numeric.cpp | 9 ++++++--- ginac/power.cpp | 14 +++++--------- ginac/tensor.cpp | 12 ++++++++---- 6 files changed, 37 insertions(+), 27 deletions(-) diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 07da6935..f332c64e 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -1224,22 +1224,27 @@ static ex get_clifford_comp(const ex & e, const ex & c) else if (is_a(e) || is_a(e)) { // find a Clifford unit with the same metric, delete it and substitute its index size_t ind = e.nops() + 1; - for (size_t j = 0; j < e.nops(); j++) - if (is_a(e.op(j)) && ex_to(c).same_metric(e.op(j))) - if (ind > e.nops()) + for (size_t j = 0; j < e.nops(); j++) { + if (is_a(e.op(j)) && ex_to(c).same_metric(e.op(j))) { + if (ind > e.nops()) { ind = j; - else + } + else { throw(std::invalid_argument("get_clifford_comp(): expression is a Clifford multi-vector")); + } + } + } if (ind < e.nops()) { ex S = 1; bool same_value_index, found_dummy; same_value_index = ( ex_to(e.op(ind).op(1)).is_numeric() && (ival == ex_to(ex_to(e.op(ind).op(1)).get_value()).to_int()) ); found_dummy = same_value_index; - for(size_t j=0; j < e.nops(); j++) - if (j != ind) - if (same_value_index) + for (size_t j=0; j < e.nops(); j++) { + if (j != ind) { + if (same_value_index) { S = S * e.op(j); + } else { exvector ind_vec = ex_to(e.op(j)).get_dummy_indices(ex_to(e.op(ind))); if (ind_vec.size() > 0) { @@ -1257,6 +1262,8 @@ static ex get_clifford_comp(const ex & e, const ex & c) } else S = S * e.op(j); } + } + } return (found_dummy ? S : 0); } else throw(std::invalid_argument("get_clifford_comp(): expression is not a Clifford vector to the given units")); diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index 84a78c42..8212077f 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -210,7 +210,7 @@ void double_Xn() } } // X_n - for (int n=2; n& x, const std::vector& s, Gparameter a(x.size()); exmap subslst; std::size_t pos = 1; - int scale; + int scale = pos; for (sortmap_t::const_iterator it = sortmap.begin(); it != sortmap.end(); ++it) { if (it->second < x.size()) { if (s[it->second] > 0) { @@ -3482,7 +3482,7 @@ static void initcX(std::vector& crX, int Sm = 0; int Smp1 = 0; std::vector > crG(s.size() - 1, std::vector(L2 + 1)); - for (int m=0; m < s.size() - 1; m++) { + for (int m=0; m < (int)s.size() - 1; m++) { Sm += s[m]; Smp1 = Sm + s[m+1]; for (int i = 0; i <= L2; i++) diff --git a/ginac/mul.cpp b/ginac/mul.cpp index 53c38115..c09a0a53 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -683,7 +683,7 @@ bool algebraic_match_mul_with_mul(const mul &e, const ex &pat, exmap& repls, int factor, int &nummatches, const std::vector &subsed, std::vector &matched) { - if (factor == pat.nops()) + if (factor == (int)pat.nops()) return true; for (size_t i=0; i(ebasis)) { - basis_is_numerical = true; num_basis = &ex_to(ebasis); } if (is_exactly_a(eexponent)) { - exponent_is_numerical = true; num_exponent = &ex_to(eexponent); } @@ -403,7 +399,7 @@ ex power::eval(int level) const return ebasis; // ^(0,c1) -> 0 or exception (depending on real value of c1) - if (ebasis.is_zero() && exponent_is_numerical) { + if ( ebasis.is_zero() && num_exponent ) { if ((num_exponent->real()).is_zero()) throw (std::domain_error("power::eval(): pow(0,I) is undefined")); else if ((num_exponent->real()).is_negative()) @@ -424,11 +420,11 @@ ex power::eval(int level) const if (is_exactly_a(ebasis) && ebasis.op(0).info(info_flags::positive) && ebasis.op(1).info(info_flags::real)) return power(ebasis.op(0), ebasis.op(1) * eexponent); - if (exponent_is_numerical) { + if ( num_exponent ) { // ^(c1,c2) -> c1^c2 (c1, c2 numeric(), // except if c1,c2 are rational, but c1^c2 is not) - if (basis_is_numerical) { + if ( num_basis ) { const bool basis_is_crational = num_basis->is_crational(); const bool exponent_is_crational = num_exponent->is_crational(); if (!basis_is_crational || !exponent_is_crational) { diff --git a/ginac/tensor.cpp b/ginac/tensor.cpp index 259af3e4..ce865531 100644 --- a/ginac/tensor.cpp +++ b/ginac/tensor.cpp @@ -364,13 +364,17 @@ ex tensepsilon::eval_indexed(const basic & i) const if (minkowski) { for (size_t j=1; j(x)) + if (!is_a(x)) { throw(std::runtime_error("indices of epsilon tensor in Minkowski space must be of type varidx")); - if (ex_to(x).is_covariant()) - if (ex_to(x).get_value().is_zero()) + } + if (ex_to(x).is_covariant()) { + if (ex_to(x).get_value().is_zero()) { sign = (pos_sig ? -sign : sign); - else + } + else { sign = (pos_sig ? sign : -sign); + } + } } } -- 2.44.0