- // Add fractions
- if (den.is_equal(_ex1())) {
-
- // Common denominator is 1, simply add all fractions
- exvector num_seq;
- for (ait=o.begin(); ait!=aitend; ait++) {
- num_seq.push_back(ait->op(0) / ait->op(1));
- }
- return (new lst((new add(num_seq))->setflag(status_flags::dynallocated), den))->setflag(status_flags::dynallocated);
-
- } else {
-
- // Perform fractional addition
- exvector num_seq;
- for (ait=o.begin(); ait!=aitend; ait++) {
- ex q;
- if (!divide(den, ait->op(1), q, false)) {
- // should not happen
- throw(std::runtime_error("invalid expression in add::normal, division failed"));
- }
- num_seq.push_back((ait->op(0) * q).expand());
- }
- ex num = (new add(num_seq))->setflag(status_flags::dynallocated);
-
- // Cancel common factors from num/den
- return frac_cancel(num, den);
- }
+ // Cancel common factors from num/den
+ return frac_cancel(num, den);