These are chat archives for symengine/symengine
hash_set, one for integers, another for rationals, and finally for general expressions.
ringlayer of abstraction.
cos(a)*x**2 + sin(a)*x. Here, you might want to have
xas a generator and
cos(a)as symbolic coefficients.
4*x, you know that
xis a generator (i.e the polynomial is in terms of x). What if you have
In : sring(cos(a)*x**2 + sin(a)*x) Out: (Polynomial ring in x, cos(a), sin(a) over ZZ with lex order, x**2*cos(a) + x*sin(a))
In : R, x = ring('x', EX) In : R(cos(a)*x**2 + sin(a)*x) Out: EX(cos(a))*x**2 + EX(sin(a))*x In : R Out: Polynomial ring in x over EX with lex order
Polynomial<ZZ>and you just need to tell it what the variables are, so you tell it that the variables are
x, sin(a), cos(a).
Polynomial<EX>with the variable 'x'.
(4). Then you multiply with a polynomial in 'y', 'z', let's say you have a term 'y^2 z^5', represented by a tuple
(2, 5). So you need to create a new polynomial with generators (x, y, z) and then the first tuple becomes (4) -> (4, 0, 0) and the second tuple becomes (2, 5) -> (0, 2, 5) and then you just multiply the tuples (4, 0, 0) and (0, 2, 5), and the result is just adding the exponents, so you get (4, 2, 5).
a*x, we could also have a composite domain.
In : R, x = ring('x', QQ[a]) In : R Out: Polynomial ring in x over QQ[a] with lex order In : a*x Out: a*x
In : var("a") Out: a In : R, x = ring('x', QQ[a]) In : R Out: Polynomial ring in x over QQ[a] with lex order In : a*x Out: a*x In : x**2 Out: x**2 In : x**2+3 Out: x**2 + 3 In : x**2+3*a Out: x**2 + 3*a
ainto the domain.
p/q*aas a coefficient, you can do whatever you could with
p/q, you can do any kind of arithmetic operation, since if you do
(p/q)^10, it just becomes some other
p/q*a, it's not clear to me how it is represented internally and what operations are allowed. You can also do QQ[a, b]
awith rational coefficients
R, x = ring('x', QQ[a, b])is some kind of recursive polynomial. The generator is 'x' and the coefficients are polynomials in QQ with generators 'a' and 'b'
Expressionthen this is just a special case of
3xyz^2 + yz+..., you can treat it as a polynomial in 'x' with coefficients of a polynomial in 'y' with coefficients a polynomial in 'z'.
In [*(b + 1)*x + a*b) Out: ((a + 2)*b + a + 2)*x + a*b]: R, x = ring('x', QQ[ ][ ]) In : R((a + 2)
Polynomial<EX>which are sparse polynomials (Piranha style) and then any number of generators, and those generators can be any SymEngine expressions.
QQ[a][b]is isomorphic to
QQ[a, b]. So not having a recursive representation doesn't really mean we are losing out on anything.
rs_muletc. functions in SymEngine just accept just a polynomial as an argument?
rs_mulcan be any polynomial of any coefficient type?
rs_mulof polynomials in SymPy, let's say one is ZZ and the other one is QQ?
rs_mulfunction in SymEngine, and simply declare it something like:
template<C> rs_mul(const Polynomial<C> &a, const Polynomial<C> &b, Polynomial<C> &c, Generator x)
rs_mulcalls) one checks that the generators are identical, otherwise raise an exception.
R(expr)where R is a ring.
if (a.ring != b.ring) throw exception
RCP<const Ring<ZZ>>, so that you can get the type of the coefficients out of it inside the Polynomial and use it in defining the internal data structures.
gem install symengine
gem install symengine
sumith@sumith-Lenovo-Z50-70:~$ sudo gem install symengine [sudo] password for sumith: Fetching: symengine-0.0.1.gem (100%) Successfully installed symengine-0.0.1 Parsing documentation for symengine-0.0.1 Installing ri documentation for symengine-0.0.1 Done installing documentation for symengine after 0 seconds 1 gem installed
symengine.sowhich will only work for the particular architecture it was compiled for
.gemfile has been generated
Could you try
an then in the interpreter
require 'symengine' a = SymEngine::Integer.new(1)
sumith@sumith-Lenovo-Z50-70:~$ irb irb(main):001:0> require 'symengine' LoadError: libsymengine.so: cannot open shared object file: No such file or directory - /usr/local/lib/ruby/gems/2.2.0/gems/symengine-0.0.1/lib/symengine/symengine.so from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/local/lib/ruby/gems/2.2.0/gems/symengine-0.0.1/lib/symengine.rb:1:in `<top (required)>' from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require' from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require' from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require' from (irb):1 from /usr/local/bin/irb:11:in `<main>' irb(main):002:0>
mkmfthen? If specified correctly in
gemspecgem should compile the extensions upon install.
rs_mulallow multiplication of polynomials over them?
extconf.rband you can call
make installfrom it, instead of going through
libsymengine? I suppose we need to build that too.
There are two approaches
libsymengineand ruby wrappers
libsymengineas a library dependency.
1 is the approach for Python wrappers right now, but I like 2 better.
@certik, @abinashmeher999, thoughts?
PolyElement) to allow rational exponents. Dense polynomials still follow the maths definition.
setup.pywhich needs to be done in ruby in a
I suggest to modify it.
to allow rational or to disable it?
rs_serieswork with puiseux series. I will send a PR soon.
a/b + I*p/q.
a*xas in Ring<EX>(x). Any advantage of doing Ring<ZZ>(x, a)?
Ring<ZZ>(x, a)will obviously be a lot faster.
EXrepresented internally in SymEngine?
Ring<ZZ>(x, a)will be a tuple of numbers with a pointer to the list
a*xis a multivariate polynomial.
Ring<ZZ>(x, a)will internally just have a list
[x, a]with the generators. The dictionary is inside a Polynomial, not a Ring.
Keyargument can be
monomial<short>, but if you use
monomial<rational>, then you get rational exponents, i.e. for a Puiseux series.
typedef polynomial<Cf,Key> p_type; p_type x("x"), y("y"), z("z"), t("t"); auto f = x + y + z + t + 1;
x is a polynomial with only one generator 'x'. The same for
t. Then when you write
f = x + y + z + t + 1, Piranha somehow converts the polynomials over different generators into a common base (by padding the zeros in the exponents) and adds them together.
polynomialtype, so I don't understand how the line
f = x + y + z + t + 1;can compile at all.
m_symbol_setwith the generators. So they seem to be saved inside the instance itself.
std::vector<symbol>to check if the generators are the same.