QuadraticExtension in Polymake 3.0

Questions and problems about using polymake go here.
mws
Posts: 32
Joined: 16 Jan 2014, 22:57

QuadraticExtension in Polymake 3.0

Postby mws » 25 Jan 2016, 00:41

Hello,

I am using the callable library and have two basic questions about the QuadraticExtension type.
  1. 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?
  2. Is it safe to add, multiply, etc. something of type polymake::Rational and polymake::QuadraticExtension?
Thanks!

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: QuadraticExtension in Polymake 3.0

Postby gawrilow » 25 Jan 2016, 01:08

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...

mws
Posts: 32
Joined: 16 Jan 2014, 22:57

Re: QuadraticExtension in Polymake 3.0

Postby mws » 25 Jan 2016, 06:38

Great, many thanks for the quick answer.

mws
Posts: 32
Joined: 16 Jan 2014, 22:57

Re: QuadraticExtension in Polymake 3.0

Postby mws » 29 Jan 2016, 13:11

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?

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: QuadraticExtension in Polymake 3.0

Postby gawrilow » 29 Jan 2016, 14:03

By constructing a temporary object and assigning it to the target variable:

Code: Select all

q = QuadraticExtension<Rational>(4,5,6);

mws
Posts: 32
Joined: 16 Jan 2014, 22:57

Re: QuadraticExtension in Polymake 3.0

Postby mws » 29 Jan 2016, 14:09

Oh, I see. So you cannot directly modify an existing QuadraticExtension variable after creating it?

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: QuadraticExtension in Polymake 3.0

Postby gawrilow » 29 Jan 2016, 14:22

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?

mws
Posts: 32
Joined: 16 Jan 2014, 22:57

Re: QuadraticExtension in Polymake 3.0

Postby mws » 29 Jan 2016, 14:29

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. ;-)

mws
Posts: 32
Joined: 16 Jan 2014, 22:57

Re: QuadraticExtension in Polymake 3.0

Postby mws » 30 Jan 2016, 15:07

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?

mws
Posts: 32
Joined: 16 Jan 2014, 22:57

Re: QuadraticExtension in Polymake 3.0

Postby mws » 31 Jan 2016, 09:06

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;


Return to “Helpdesk”