These are chat archives for symengine/symengine

20th
Jun 2016
Rajith Vidanaarachchi
@rajithv
Jun 20 2016 09:13

@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)

https://github.com/rajithv/symengine/blob/23e3471e0ae6f4be8b287ff8f1ee30046633e548/symengine/tests/cwrapper/test_cwrapper.c#L946-L949

I can't figure out what's off with the code.. please help
Srajan Garg
@srajangarg
Jun 20 2016 10:14
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"
Srajan Garg
@srajangarg
Jun 20 2016 10:20
@isuruf can youe merge in #989
Abinash Meher
@abinashmeher999
Jun 20 2016 10:22
@rajithv Can you post one of the Travis logs when it failed?
Srajan Garg
@srajangarg
Jun 20 2016 10:33
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?
Isuru Fernando
@isuruf
Jun 20 2016 10:37
runtime error is an exception right?
Srajan Garg
@srajangarg
Jun 20 2016 10:38
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
Isuru Fernando
@isuruf
Jun 20 2016 10:39
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
?
Rajith Vidanaarachchi
@rajithv
Jun 20 2016 10:43
@isuruf will do
Abinash Meher
@abinashmeher999
Jun 20 2016 10:58
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.
Abinash Meher
@abinashmeher999
Jun 20 2016 11:03
@rajithv The travis test didn't get triggered because it couldn't be merged.
Rajith Vidanaarachchi
@rajithv
Jun 20 2016 11:04
it is running on my personal travis.. I will copy the output from there @abinashmeher999
Abinash Meher
@abinashmeher999
Jun 20 2016 11:05
That's ok. We can see your travis logs.
Srajan Garg
@srajangarg
Jun 20 2016 11:09
@isuruf what 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
Rajith Vidanaarachchi
@rajithv
Jun 20 2016 11:37
@abinashmeher999 @isuruf @Sumith1896 The previously failed tests were passed this time. Don't know what happened there.
Abinash Meher
@abinashmeher999
Jun 20 2016 11:39
I was wondering the same. Maybe the fault was here
Rajith Vidanaarachchi
@rajithv
Jun 20 2016 11:41
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
Abinash Meher
@abinashmeher999
Jun 20 2016 11:45
Indeed
Francesco Biscani
@bluescarni
Jun 20 2016 11:47
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
Rajith Vidanaarachchi
@rajithv
Jun 20 2016 11:49
@bluescarni will do. Thanks.
Francesco Biscani
@bluescarni
Jun 20 2016 11:49
sure np
Isuru Fernando
@isuruf
Jun 20 2016 14:37
@abinashmeher999, if you are on a OSX system, can you look into symengine.rb link issues?
Isuru Fernando
@isuruf
Jun 20 2016 16:20
@srajangarg, I think the SymPy way is fine. In SymPy you can also give the generators
Srajan Garg
@srajangarg
Jun 20 2016 16:26
So, Poly(Integer) should throw an error? What are generators?
Isuru Fernando
@isuruf
Jun 20 2016 16:29
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.
Srajan Garg
@srajangarg
Jun 20 2016 16:33
Oh, I had not thought about this yet
Do we want arbitrary generators in SymEngine?
Isuru Fernando
@isuruf
Jun 20 2016 16:33
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')
Srajan Garg
@srajangarg
Jun 20 2016 16:36
So
Currently for the univariate int case
I'll need to handle cases like 1 + 2*sin(x)+sin(x)**2
Isuru Fernando
@isuruf
Jun 20 2016 16:39
Yes, exactly
Abinash Meher
@abinashmeher999
Jun 20 2016 16:39
@isuruf Sure will look into it. I am trying to setup symengine first.
Isuru Fernando
@isuruf
Jun 20 2016 16:39
@abinashmeher999, thanks. Let me know if you run into troubles
Abinash Meher
@abinashmeher999
Jun 20 2016 16:40
Sure
Srajan Garg
@srajangarg
Jun 20 2016 16:40
x + y +1 will throw, y*x**2 + 1 will also throw right?
Isuru Fernando
@isuruf
Jun 20 2016 16:42
If there are no generators given, yes.
If the generator is given, it will not
Srajan Garg
@srajangarg
Jun 20 2016 16:42
how so?
I'm talking in terms of only univariate int polynomials, right now btw
Isuru Fernando
@isuruf
Jun 20 2016 16:43
Poly(x+y+1, x) is a univariate polynomial
Srajan Garg
@srajangarg
Jun 20 2016 16:48
Should I treat univariate expr polynomials and univariate int polynomials differently?
basic_to_uintpoly and basic_to_uexprpoly
Isuru Fernando
@isuruf
Jun 20 2016 16:50
They will be different only on the case above. Poly(x+y+1, x) is different when expr polynomials are used and not
Srajan Garg
@srajangarg
Jun 20 2016 16:51
and how will I construct a polynomial from sin(x)**2 + 1? The 'generator' for our polynomials (internally) are stored as Symbol
Isuru Fernando
@isuruf
Jun 20 2016 16:51
I think the interface should be like PolynomialClass::fromBasic
For example
UIntPoly::fromBasic
UExprPoly::fromBasic
We can change the generator to be Basic
Srajan Garg
@srajangarg
Jun 20 2016 16:52
Anywhere I can read about the generator detection, for the univariate case
Srajan Garg
@srajangarg
Jun 20 2016 16:53
Though the overall idea seems clear to me now, I'll still have many doubts. Ill keep asking here. Thanks
Isuru Fernando
@isuruf
Jun 20 2016 16:54
I'm not sure if there are more documentation. You can ask on the SymPy chat room
Srajan Garg
@srajangarg
Jun 20 2016 17:45
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
Isuru Fernando
@isuruf
Jun 20 2016 17:47
Hash is not unique
Srajan Garg
@srajangarg
Jun 20 2016 18:04
@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
Isuru Fernando
@isuruf
Jun 20 2016 18:23
@srajangarg, I would follow SymPy on this. What does SymPy do?
Srajan Garg
@srajangarg
Jun 20 2016 18:27
Constructs a multivariate poly in x and y
Is there any way to restrict it to univariate polys?
Kalevi Suominen
@jksuom
Jun 20 2016 18:41
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.
Srajan Garg
@srajangarg
Jun 20 2016 19:36
No, what if a generator is not given. It should not automatically use x + y, as a generator. Yes?