This file records noteworthy changes.
+0.6.5 ()
+* Non-integer powers of a symbol are treated as constants by (l)degree() and
+ coeff(). Using these functions on an expression containing such powers used
+ to fail with an internal error message. The side-effect is that collect()
+ can be used on expressions which are not polynomials.
+
0.6.4 (10 August 2000)
* Complete revamp of methods in class matrix. Some redundant (and poor)
implementations of elimination schemes were thrown out. The code is now
{
int deg_sum = 0;
for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
- deg_sum+=(*cit).rest.degree(s) * ex_to_numeric((*cit).coeff).to_int();
+ if (ex_to_numeric(cit->coeff).is_integer())
+ deg_sum+=cit->rest.degree(s) * ex_to_numeric(cit->coeff).to_int();
}
return deg_sum;
}
{
int deg_sum = 0;
for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
- deg_sum+=(*cit).rest.ldegree(s) * ex_to_numeric((*cit).coeff).to_int();
+ if (ex_to_numeric(cit->coeff).is_integer())
+ deg_sum+=cit->rest.ldegree(s) * ex_to_numeric(cit->coeff).to_int();
}
return deg_sum;
}
int power::degree(const symbol & s) const
{
if (is_exactly_of_type(*exponent.bp,numeric)) {
- if ((*basis.bp).compare(s)==0)
- return ex_to_numeric(exponent).to_int();
- else
+ if ((*basis.bp).compare(s)==0) {
+ if (ex_to_numeric(exponent).is_integer())
+ return ex_to_numeric(exponent).to_int();
+ else
+ return 0;
+ } else
return basis.degree(s) * ex_to_numeric(exponent).to_int();
}
return 0;
int power::ldegree(const symbol & s) const
{
if (is_exactly_of_type(*exponent.bp,numeric)) {
- if ((*basis.bp).compare(s)==0)
- return ex_to_numeric(exponent).to_int();
- else
+ if ((*basis.bp).compare(s)==0) {
+ if (ex_to_numeric(exponent).is_integer())
+ return ex_to_numeric(exponent).to_int();
+ else
+ return 0;
+ } else
return basis.ldegree(s) * ex_to_numeric(exponent).to_int();
}
return 0;
{
if ((*basis.bp).compare(s)!=0) {
// basis not equal to s
- if (n==0) {
+ if (n == 0)
return *this;
- } else {
+ else
return _ex0();
+ } else {
+ // basis equal to s
+ if (is_exactly_of_type(*exponent.bp, numeric) && ex_to_numeric(exponent).is_integer()) {
+ // integer exponent
+ int int_exp = ex_to_numeric(exponent).to_int();
+ if (n == int_exp)
+ return _ex1();
+ else
+ return _ex0();
+ } else {
+ // non-integer exponents are treated as zero
+ if (n == 0)
+ return *this;
+ else
+ return _ex0();
}
- } else if (is_exactly_of_type(*exponent.bp,numeric)&&
- (static_cast<const numeric &>(*exponent.bp).compare(numeric(n))==0)) {
- return _ex1();
}
-
- return _ex0();
}
ex power::eval(int level) const