Volker Braun avatar Volker Braun committed 3f4df0f

my reviewer patches

Comments (0)

Files changed (1)

trac_9880_reviewer-vb.patch

 # HG changeset patch
-# Parent 3c4b290ed6ec3f3c3fc8a679f4368bf6a21f9d60
+# Parent 27f7d36cd929d8841c83da1da33ca442db37777a
 
 diff --git a/ginac/add.cpp b/ginac/add.cpp
 --- a/ginac/add.cpp
  	ex overall_coeff;
  #if EXPAIRSEQ_USE_HASHTAB
  	epplistvector hashtab;
+diff --git a/ginac/inifcns_trans.cpp b/ginac/inifcns_trans.cpp
+--- a/ginac/inifcns_trans.cpp
++++ b/ginac/inifcns_trans.cpp
+@@ -1107,6 +1107,23 @@
+ 	    is_a<numeric>(x) && !x.info(info_flags::crational))
+ 		return atan(ex_to<numeric>(y), ex_to<numeric>(x));
+ 
++	// handle infinities
++	if (is_a<infinity>(x) || is_a<infinity>(y)) {
++		if (is_a<infinity>(x) && ex_to<infinity>(x).is_unsigned_infinity())
++			throw (std::runtime_error("arctan2_eval(): arctan2(unsigned_infinity, x) encountered"));
++		if (is_a<infinity>(y) && ex_to<infinity>(y).is_unsigned_infinity())
++			throw (std::runtime_error("arctan2_eval(): arctan2(x, unsigned_infinity) encountered"));
++
++		if (is_a<infinity>(x) && is_a<infinity>(y)) 
++			return atan2_eval(ex_to<infinity>(x).get_direction(), 
++					  ex_to<infinity>(y).get_direction());
++
++		if (is_a<infinity>(x)) 
++			return atan2_eval(ex_to<infinity>(x).get_direction(), 0);
++		if (is_a<infinity>(y)) 
++			return atan2_eval(0, ex_to<infinity>(y).get_direction());
++	}
++
+ 	// atan2(real, real) -> atan(y/x) +/- Pi
+ 	if (y.info(info_flags::real) && x.info(info_flags::real)) {
+ 		if (x.info(info_flags::positive))
+@@ -1119,37 +1136,6 @@
+ 				return atan(y/x)-Pi;
+ 		}
+ 	}
+-
+-	// atan(infinity, infinity) -> error
+-	// atan(oo, x) -> 0
+-	// atan(-oo, x) & x negative -> -Pi
+-	// atan(-oo, x) -> Pi
+-	// atan(UnsignedInfinity, x) -> error
+-	if (y.info(info_flags::infinity)) {
+-		if (x.info(info_flags::infinity))
+-			throw (std::runtime_error("arctan2_eval(): arctan2(infinity, infinity) encountered"));
+-		if (y.is_equal(Infinity)) 
+-			return _ex0;
+-		if (y.is_equal(NegInfinity)) {
+-			if (x.info(info_flags::negative))
+-				return _ex_1*Pi;
+-			return Pi;
+-		}
+-		// y is unsigned_infinity
+-		throw (std::runtime_error("arctan2_eval(): arctan2(unsigned_infinity, x) encountered"));
+-	}
+-
+-	// atan(x, oo) -> Pi/2
+-	// atan(x, -oo) -> -Pi/2
+-	// atan(x, UnsignedInfinity) -> error
+-	if (x.info(info_flags::infinity)) {
+-		if (x.is_equal(Infinity))
+-			return _ex1_2*Pi;
+-		if (x.is_equal(NegInfinity))
+-			return _ex_1_2*Pi;
+-		// x is unsigned_infinity
+-		throw (std::runtime_error("arctan2_eval(): arctan2(x, unsigned_infinity) encountered"));
+-	}
+ 		
+ 	return atan2(y, x).hold();
+ }    
 diff --git a/ginac/mul.cpp b/ginac/mul.cpp
 --- a/ginac/mul.cpp
 +++ b/ginac/mul.cpp
  	exvector neg_powers, others;
  	while (it != itend) {
  		GINAC_ASSERT(is_exactly_a<numeric>(it->coeff));
-@@ -787,10 +786,10 @@
+@@ -653,8 +652,10 @@
+ 	} else if (seq_size==0) {
+ 		// *(;c) -> c
+ 		return overall_coeff;
+-	} else if (seq_size==1 && overall_coeff.is_equal(_ex1)) {
++	} else if (seq_size==1 && overall_coeff.is_equal(_ex1) &&
++		   !ex_to<numeric>(overall_coeff).is_parent_pos_char()) {
+ 		// *(x;1) -> x
++		// except in positive characteristic: 1*(x+2) = x in F_2
+ 		return recombine_pair_to_ex(*(seq.begin()));
+ 	} else if ((seq_size==1) &&
+ 	           is_exactly_a<add>((*seq.begin()).rest) &&
+@@ -787,10 +788,10 @@
  	infinity result = ex_to<infinity>(recombine_pair_to_ex(*infinity_iter));
  	result *= overall_coeff;
  
  	return result;
  }
  
-@@ -1507,15 +1506,15 @@
+@@ -1507,15 +1508,15 @@
  	}
  }
  
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.