Commits

Volker Braun  committed 453c5a2 Merge

Merged pynac/pynac into default

  • Participants
  • Parent commits 1837355, b7fe62b

Comments (0)

Files changed (4)

 4a60be2c2ecb97a76036ef8efe517ab45a48c6e1 pynac-0.2.5
 d178f77211b5ad97eadfb705cb4d48c2af4b6395 pynac-0.2.6
 3b02b5245b5600854b5d12c9b4aa5508128d17fb pynac-0.3.0
+6dca556c0311a0b5f271b9ce100f05bd847a1240 pynac-0.3.1

File configure.ac

 
 m4_define([ginac_major_version], [0])
 m4_define([ginac_minor_version], [3])
-m4_define([ginac_micro_version], [0])
+m4_define([ginac_micro_version], [1])
 m4_define([ginac_version], [ginac_major_version.ginac_minor_version.ginac_micro_version])
 m4_define([ginac_release], [ginac_major_version.ginac_minor_version])
 m4_define([ginac_interface_age], [0])
-m4_define([ginac_binary_age], [0])
+m4_define([ginac_binary_age], [1])
 
 AC_INIT([pynac], ginac_version, [<pynac-devel@googlegroups.com>])
 AC_PREREQ(2.59)

File ginac/function.cpp

 	return eval_result;
 }
 
-ex function::evalf(int level, PyObject* parent) const
+ex function::evalf(int level, PyObject* kwds) const
 {
 	GINAC_ASSERT(serial<registered_functions().size());
 	const function_options &opt = registered_functions()[serial];
 		--level;
 		exvector::const_iterator it = seq.begin(), itend = seq.end();
 		while (it != itend) {
-			eseq.push_back(it->evalf(level, parent));
+			eseq.push_back(it->evalf(level, kwds));
 			++it;
 		}
 	}
 	if (opt.python_func & function_options::evalf_python_f) { 
 		// convert seq to a PyTuple of Expressions
 		PyObject* args = py_funcs.exvector_to_PyTuple(eseq);
-		// create a dictionary {'prec':prec} for the precision argument
-		PyObject* kwds = Py_BuildValue("{s:O}","parent",parent);
 		// call opt.evalf_f with this list
 		PyObject* pyresult = PyEval_CallObjectWithKeywords(
 			PyObject_GetAttrString((PyObject*)opt.evalf_f,
 				"_evalf_"), args, kwds);
 		Py_DECREF(args);
-		Py_DECREF(kwds);
 		if (!pyresult) { 
 			throw(std::runtime_error("function::evalf(): python function raised exception"));
 		}
 		return result;
 	}
 	if (opt.evalf_use_exvector_args)
-		return ((evalf_funcp_exvector)(opt.evalf_f))(seq, parent);
+		return ((evalf_funcp_exvector)(opt.evalf_f))(seq, kwds);
 	switch (opt.nparams) {
 		// the following lines have been generated for max. 14 parameters
 	case 1:
-		return ((evalf_funcp_1)(opt.evalf_f))(eseq[1-1], parent);
+		return ((evalf_funcp_1)(opt.evalf_f))(eseq[1-1], kwds);
 	case 2:
-		return ((evalf_funcp_2)(opt.evalf_f))(eseq[1-1], eseq[2-1], parent);
+		return ((evalf_funcp_2)(opt.evalf_f))(eseq[1-1], eseq[2-1], kwds);
 	case 3:
-		return ((evalf_funcp_3)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], parent);
+		return ((evalf_funcp_3)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], kwds);
 
 		// end of generated lines
 	}

File ginac/mul.cpp

 		}
 
 	} else {
+		// negative powers are empty
+		if (!latex_tags) {
+			print_overall_coeff(overall_coeff, c, sep, latex_tags);
 
-		print_overall_coeff(overall_coeff, c,
-				latex_tags ? " \\, " : sep, latex_tags);
+			print_exvector(others, c, sep);
+		} else {
+			// Decide which separator to use after the overall
+			// coefficient.
+			// overall coefficient is printed first in the
+			// output, if the first character after the
+			// coefficient is a number, then it is hard to
+			// distinguish these in the latex output:
+			//
+			// sage: e = 2 * 2^(1/3)
+			// sage: print latex(e)
+			// 2 \, 2^{\left(\frac{1}{3}\right)}
+			//
+			// In this case instead of the usual separator \,
+			// we use \cdot
 
-		print_exvector(others, c, sep);
+			std::stringstream tstream;
+			print_latex tcontext(tstream, c.options);
+			print_exvector(others, tcontext, sep);
+			print_overall_coeff(overall_coeff, c,
+					std::isdigit(tstream.peek()) ?
+						" \\cdot " : " \\, ",
+					latex_tags);
+			c.s<<tstream.str();
+		}
 	}
 	if (precedence() <= level){
 		if (latex_tags)