Page 1 of 2
QuadraticExtension in Polymake 3.0
Posted: 25 Jan 2016, 00:41
by mws
Hello,
I am using the callable library and have two basic questions about the QuadraticExtension type.
- I create a QuadraticExtension object as follows:
Code: Select all
polymake::QuadraticExtension<polymake::Rational> q {1,2,3}; Is it correct that this corresponds to the element 1 + 2 sqrt(3) in Q(sqrt(3))? So if a + b sqrt(d) is a general element in Q(sqrt(d)), then a is the first parameter, b the second, and the square-free integer d the third, right?
- Is it safe to add, multiply, etc. something of type polymake::Rational and polymake::QuadraticExtension?
Thanks!
Re: QuadraticExtension in Polymake 3.0
Posted: 25 Jan 2016, 01:08
by gawrilow
Yes to both questions.
It's admittedly quite a disgrace that we still haven't managed to provide decent doxygen comments for essential core library classes...
Re: QuadraticExtension in Polymake 3.0
Posted: 25 Jan 2016, 06:38
by mws
Great, many thanks for the quick answer.
Re: QuadraticExtension in Polymake 3.0
Posted: 29 Jan 2016, 13:11
by mws
I feel stupid for asking, but how do you assign a new value to an existing QuadraticExtension variable? Let's say I defined
Code: Select all
QuadraticExtension<Rational> q {1, 2, 3};
Then q corresponds to the number 1 + 2 \sqrt(3). How can I change q's value?
Re: QuadraticExtension in Polymake 3.0
Posted: 29 Jan 2016, 14:03
by gawrilow
By constructing a temporary object and assigning it to the target variable:
Code: Select all
q = QuadraticExtension<Rational>(4,5,6);
Re: QuadraticExtension in Polymake 3.0
Posted: 29 Jan 2016, 14:09
by mws
Oh, I see. So you cannot directly modify an existing QuadraticExtension variable after creating it?
Re: QuadraticExtension in Polymake 3.0
Posted: 29 Jan 2016, 14:22
by gawrilow
Well, you do modify the variable, simply by overwriting its value. Are you missing the possibility to alter the ingredients a, b, or r separately?
Re: QuadraticExtension in Polymake 3.0
Posted: 29 Jan 2016, 14:29
by mws
Yes, that's basically what I was hoping for. For now your suggested solution also works fine, it just makes my code look a bit more clumsy. But I think I'll get over that.

Re: QuadraticExtension in Polymake 3.0
Posted: 30 Jan 2016, 15:07
by mws
Actually, now that I am editing many, many lines of code where I change Rational to QuadraticExtension, I think it is little annoying that QuadraticExtension has so much fewer initialization and altering methods to offer. This not only results in uglier code but also requires a lot of effort on the programmers side. So you might want to consider making this type more similar to existing ones in future releases.
Or am I missing The Good Reason to have it exactly this way?
Re: QuadraticExtension in Polymake 3.0
Posted: 31 Jan 2016, 09:06
by mws
Here is another problem that I encoutered while trying to use the QuadraticExtension type: If I compile the following code
Code: Select all
#include <iostream>
#include <polymake/Main.h>
#include <polymake/Rational.h>
#include <polymake/QuadraticExtension.h>
#include <polymake/polytope/ppl_interface.h>
int main(void) {
try {
polymake::Main pm;
pm.set_application("polytope");
polymake::polytope::ppl_interface::solver<polymake::QuadraticExtension<polymake::Rational>> sv;
return 0;
} catch (const std::exception& ex) {
std::cerr << "Error: " << ex.what() << std::endl;
return 1;
}
return -1;
}
using the commands
Code: Select all
g++ -std=c++11 -c -fpic -o mytest.o -I. -fPIC -march=native -ftemplate-depth-200 -Wall -Wno-strict-aliasing -Wno-parentheses -fwrapv -fopenmp -O3 -DPOLYMAKE_DEBUG=0 -I/usr/local/include mytest.cpp
g++ -std=c++11 -o mytest -ggdb -Wl,--unresolved-symbols=ignore-in-object-files -L/usr/local/lib -fopenmp -Wl,-rpath,/usr/local/lib mytest.o -lpolymake -lpolymake-apps -lgmp -lxml2 -lz -lm -ldl
I get the error
Code: Select all
./mytest: symbol lookup error: ./mytest: undefined symbol: _ZN8polymake8polytope13ppl_interface6solverIN2pm18QuadraticExtensionINS3_8RationalEEEEC1Ev
when I execute the program. The compiler doesn't complain about anything when compiling. Any idea what's the problem?
The error doesn't occur if one uses
Code: Select all
polymake::polytope::ppl_interface::solver<polymake::Rational> sv;
instead of
Code: Select all
polymake::polytope::ppl_interface::solver<polymake::QuadraticExtension<polymake::Rational>> sv;