ex basic::operator[](const ex & index) const
{
- if (is_exactly_of_type(*index.bp,numeric))
- return op(static_cast<const numeric &>(*index.bp).to_int());
-
+ if (is_ex_exactly_of_type(index,numeric))
+ return op(ex_to<numeric>(index).to_int());
+
throw(std::invalid_argument("non-numeric indices not supported by this type"));
}
* sign as a multiplicative factor. */
bool numeric::has(const ex &other) const
{
- if (!is_exactly_of_type(*other.bp, numeric))
+ if (!is_ex_exactly_of_type(other, numeric))
return false;
- const numeric &o = static_cast<const numeric &>(*other.bp);
+ const numeric &o = ex_to<numeric>(other);
if (this->is_equal(o) || this->is_equal(-o))
return true;
if (o.imag().is_zero()) // e.g. scan for 3 in -3*I
return tmp;
}
-/** Expression Postfix decrement. Returns the ex and leaves the original
+/** Expression postfix decrement. Returns the ex and leaves the original
* decremented by 1. */
const ex operator--(ex & lh, int)
{
return tmp;
}
-/** Numeric Postfix decrement. Returns the number and leaves the original
+/** Numeric postfix decrement. Returns the number and leaves the original
* decremented by 1. */
const numeric operator--(numeric & lh, int)
{
int power::degree(const ex & s) const
{
- if (is_exactly_of_type(*exponent.bp, numeric) && ex_to<numeric>(exponent).is_integer()) {
+ if (is_ex_exactly_of_type(exponent, numeric) && ex_to<numeric>(exponent).is_integer()) {
if (basis.is_equal(s))
return ex_to<numeric>(exponent).to_int();
else
int power::ldegree(const ex & s) const
{
- if (is_exactly_of_type(*exponent.bp, numeric) && ex_to<numeric>(exponent).is_integer()) {
+ if (is_ex_exactly_of_type(exponent, numeric) && ex_to<numeric>(exponent).is_integer()) {
if (basis.is_equal(s))
return ex_to<numeric>(exponent).to_int();
else
return _ex0();
} else {
// basis equal to s
- if (is_exactly_of_type(*exponent.bp, numeric) && ex_to<numeric>(exponent).is_integer()) {
+ if (is_ex_exactly_of_type(exponent, numeric) && ex_to<numeric>(exponent).is_integer()) {
// integer exponent
int int_exp = ex_to<numeric>(exponent).to_int();
if (n == int_exp)
const numeric *num_basis;
const numeric *num_exponent;
- if (is_exactly_of_type(*ebasis.bp,numeric)) {
+ if (is_ex_exactly_of_type(ebasis, numeric)) {
basis_is_numerical = true;
- num_basis = static_cast<const numeric *>(ebasis.bp);
+ num_basis = &ex_to<numeric>(ebasis);
}
- if (is_exactly_of_type(*eexponent.bp,numeric)) {
+ if (is_ex_exactly_of_type(eexponent, numeric)) {
exponent_is_numerical = true;
- num_exponent = static_cast<const numeric *>(eexponent.bp);
+ num_exponent = &ex_to<numeric>(eexponent);
}
// ^(x,0) -> 1 (0^0 also handled here)
ex basic::series(const relational & r, int order, unsigned options) const
{
epvector seq;
- numeric fac(1);
+ numeric fac = 1;
ex deriv = *this;
ex coeff = deriv.subs(r);
const symbol &s = ex_to<symbol>(r.lhs());
int symbol::degree(const ex & s) const
{
- return is_equal(*s.bp) ? 1 : 0;
+ return is_equal(ex_to<basic>(s)) ? 1 : 0;
}
int symbol::ldegree(const ex & s) const
{
- return is_equal(*s.bp) ? 1 : 0;
+ return is_equal(ex_to<basic>(s)) ? 1 : 0;
}
ex symbol::coeff(const ex & s, int n) const
{
- if (is_equal(*s.bp))
+ if (is_equal(ex_to<basic>(s)))
return n==1 ? _ex1() : _ex0();
else
return n==0 ? *this : _ex0();
// Wildcards must match each other exactly (this is required for
// subs() to work properly because in the final step it substitutes
// all wildcards by their matching expressions)
- return is_equal(*pattern.bp);
+ return is_equal(ex_to<basic>(pattern));
}
} // namespace GiNaC
| T_SYMBOL '(' exprseq ')' {
fcn_tab::const_iterator i = find_function($1, $3.nops());
if (i->second.is_ginac) {
- $$ = ((fcnp2)(i->second.p))(static_cast<const exprseq &>(*($3.bp)), i->second.serial);
+ $$ = ((fcnp2)(i->second.p))(ex_to<exprseq>($3), i->second.serial);
} else {
- $$ = (i->second.p)(static_cast<const exprseq &>(*($3.bp)));
+ $$ = (i->second.p)(ex_to<exprseq>($3));
}
}
| T_DIGITS '=' T_NUMBER {$$ = $3; Digits = ex_to<numeric>($3).to_int();}
;
exprseq : exp {$$ = exprseq($1);}
- | exprseq ',' exp {exprseq es(static_cast<exprseq &>(*($1.bp))); $$ = es.append($3);}
+ | exprseq ',' exp {exprseq es(ex_to<exprseq>($1)); $$ = es.append($3);}
;
list_or_empty: /* empty */ {$$ = *new lst;}
;
list : exp {$$ = lst($1);}
- | list ',' exp {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($3);}
+ | list ',' exp {lst l(ex_to<lst>($1)); $$ = l.append($3);}
;
matrix : '[' row ']' {$$ = lst($2);}
- | matrix ',' '[' row ']' {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($4);}
+ | matrix ',' '[' row ']' {lst l(ex_to<lst>($1)); $$ = l.append($4);}
;
row : exp {$$ = lst($1);}
- | row ',' exp {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($3);}
+ | row ',' exp {lst l(ex_to<lst>($1)); $$ = l.append($3);}
;