@isuruf @abinashmeher999

In the evalf cwrapper tests, I'm getting a segfault in the travis tests.

I have been trying to localize the error, and finally found out that the following lines give the error. (Now that they are commented, travis tests and appveyor are working fine)

I can't figure out what's off with the code.. please help

I am not able to reproduce the segfault. I uncommented the code, and still seems to pass for me.

I am using the following cmake options

`BUILD_TYPE="Debug" WITH_BFD="yes" WITH_MPC="yes"`

@isuruf can youe merge in #989

@rajithv Can you post one of the Travis logs when it failed?

Those builds are not really helpful

@isuruf when a

`Basic`

can't be converted to a Poly, should it throw an exception or a runtime error?
runtime error is an exception right?

yes, sorry I meant a runtime error with a string, or a custom exception

we can make a symengine exception class, later on and classify the exceptions

yes, a custom exception class inheriting runtime_error would be good.

if you don't have time, use runtime_error

@rajithv, can you uncomment the code, add

`symengine_print_stack_on_segfault();`

before https://github.com/symengine/symengine/blob/master/symengine/tests/cwrapper/test_cwrapper.c#L803 and run a build in travis
?

@isuruf will do

I am on a Mac system right now. Even after a

`brew install mpc`

cmake -DWITH_MPC="yes" says `Could NOT find MPC`

Let's wait for the new travis build.

@rajithv The travis test didn't get triggered because it couldn't be merged.

it is running on my personal travis.. I will copy the output from there @abinashmeher999

That's ok. We can see your travis logs.

@isuruf what

SymPy throws

`Symbol`

to use when say I encounter an `Integer`

?SymPy throws

```
In [3]: y = Integer(1)
In [5]: Poly(y)
GeneratorsNeeded: specify generators to give '1' a meaning
```

I was thinking of giving an additional parameter to

`basic_to_upoly`

call it `extra_symbol`

, which will be used if as the generated polys symbol if a symbol is required, but could not be found
like in the case of

`Integer`

@abinashmeher999 @isuruf @Sumith1896 The previously failed tests were passed this time. Don't know what happened there.

I was wondering the same. Maybe the fault was here

maybe. but I corrected that earlier, and that's when the Appveyor error was fixed. Maybe travis didn't run again. but thanks.. good to get it fixed

Indeed

if you are having a segfault, it's not certain that it will repeat in a deterministic fashion over multiple runs

I'd suggest you compile the code with

`-fsanitize=address`

, or run it through valgrind
@bluescarni will do. Thanks.

sure np

@abinashmeher999, if you are on a OSX system, can you look into

`symengine.rb`

link issues?
@srajangarg, I think the SymPy way is fine. In SymPy you can also give the generators

So, Poly(

`Integer`

) should throw an error? What are generators?
Yes

generators are like the variables for the polynomial

For example,

```
In [8]: Poly(x**2+y**2)
Out[8]: Poly(x**2 + y**2, x, y, domain='ZZ')
```

Here

`x`

and `y`

are the generators. Domain gives the domain of the coefficients
```
In [7]: Poly(x**2 + 2*sin(x)+sin(x)**2)
Out[7]: Poly(x**2 + sin(x)**2 + 2*sin(x), x, sin(x), domain='ZZ')
```

Here

`x`

and `sin(x)`

are generators.
Oh, I had not thought about this yet

Do we want arbitrary generators in SymEngine?

Yes

Say you wanted to factorize

`x**2 + 2*sin(x)+sin(x)**2`

You'll need arbitrary generators

Another example,

```
In [5]: Poly(sqrt(2) + sqrt(3))
Out[5]: Poly(sqrt(2) + sqrt(3), sqrt(2), sqrt(3), domain='ZZ')
```

So

Currently for the univariate int case

I'll need to handle cases like

`1 + 2*sin(x)+sin(x)**2`

Yes, exactly

@isuruf Sure will look into it. I am trying to setup symengine first.

@abinashmeher999, thanks. Let me know if you run into troubles

Sure

`x + y +1`

will throw, `y*x**2 + 1`

will also throw right?
If there are no generators given, yes.

If the generator is given, it will not

If the generator is given, it will not

how so?

I'm talking in terms of only univariate int polynomials, right now btw

`Poly(x+y+1, x)`

is a univariate polynomial
Should I treat univariate expr polynomials and univariate int polynomials differently?

`basic_to_uintpoly`

and `basic_to_uexprpoly`

They will be different only on the case above.

`Poly(x+y+1, x)`

is different when expr polynomials are used and not
and how will I construct a polynomial from

`sin(x)**2 + 1`

? The 'generator' for our polynomials (internally) are stored as `Symbol`

I think the interface should be like

For example

`PolynomialClass::fromBasic`

For example

`UIntPoly::fromBasic`

`UExprPoly::fromBasic`

We can change the generator to be

`Basic`

Anywhere I can read about the generator detection, for the univariate case

http://docs.sympy.org/dev/_modules/sympy/polys/constructor.html

This has the source code

This has the source code

Though the overall idea seems clear to me now, I'll still have many doubts. Ill keep asking here. Thanks

I'm not sure if there are more documentation. You can ask on the SymPy chat room

When shifting

`var_`

from Symbol to Basic, in Piranha polynomials, I need to give a string while intializing symbols (to be used internally by Piranha)
earlier

`var_->get_name()`

was used, what should I do now
It's no use to us, should I just pass the hash

You can use the following function, https://github.com/symengine/symengine/blob/master/symengine/expression.cpp

Hash is not unique

@nishnik can you implement an iterator for

`GaloisField`

You may just have to overload

`operator++`

on the std::vector::iterator or you can see `ContainerForIter`

@isuruf what about

`(x+y)**2 + 1`

, can this be `Poly((x+y)**2 + 1, (x+y), domain=ZZ`

Then it will make no sense, because anything can be a polynomial then

@srajangarg, I would follow SymPy on this. What does SymPy do?

Constructs a multivariate poly in x and y

Is there any way to restrict it to univariate polys?

That should be the result, if you give just one generator.

```
In [14]: p = Poly((x+y)**2 + 1, x+y)
In [15]: p.gens
Out[15]: (x + y,)
```

Though this is not a good example.

No, what if a generator is not given. It should not automatically use x + y, as a generator. Yes?