Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to define Boolean Polynomial Ring in C++

53 views
Skip to first unread message

Abhishek Kesarwani

unread,
Sep 26, 2018, 12:00:23 AM9/26/18
to
Hi

I am new to C++, I need to define Boolean Polynomial Ring in C++, for instance, a similar kind is defined in SAGE,

V=BooleanPolynomialRing(6,['x%d'%(i) for i in range(1,7)])
V.inject_variables().

It is possible to define similar things in C++? Any kind of help is appreciable.

red floyd

unread,
Sep 26, 2018, 12:27:31 AM9/26/18
to
Yes it's possible.

Real Troll

unread,
Sep 26, 2018, 12:42:34 AM9/26/18
to
It's really helpful that you've confirmed it. Now Abhishek can get on
with it :-)


























.

Öö Tiib

unread,
Sep 26, 2018, 2:20:32 AM9/26/18
to
Core of that PolyBoRi library is C++, so what else can one reply?

Abhishek Kesarwani

unread,
Sep 26, 2018, 2:26:17 AM9/26/18
to
How? Tell me the code.

Alf P. Steinbach

unread,
Sep 26, 2018, 2:46:16 AM9/26/18
to
Explain what it does.

Even the terminology has by now slipped quietly out of my head,
somewhere since the 1980s. So what's a boolean ring?; what does that
“'x%d'%(i)” compute?; I guess “for i in range(1,7)” is the same as in
Python, is it?; but what the fump does “.inject_variables()” do?

And it would be nice with a use case also, what you intend to use this for.


Cheers!,

- Alf

Öö Tiib

unread,
Sep 26, 2018, 4:15:39 AM9/26/18
to
Usage code is in unit tests of PolyBoRi.

Öö Tiib

unread,
Sep 26, 2018, 4:18:40 AM9/26/18
to
Heh. Both that PolyBoRi and C++ are mysterious woo doo magic for him
and so he expects some "elder wizards" spoon feed him the incantations.

Bart

unread,
Sep 26, 2018, 5:43:31 AM9/26/18
to
That doesn't follow. The core of CPython is written in C. But you can't
express all the things you can easily do in Python in C in the same way.


--
bart

Jorgen Grahn

unread,
Sep 26, 2018, 6:45:28 AM9/26/18
to
I don't see how you can draw those conclusions from the two postings
I'm seeing. I just see someone who's not good at asking questions on
Usenet -- and someone who hopes to solve an actual problem in C++
while learning to use the language.

I can't help; I don't know the problem domain.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Öö Tiib

unread,
Sep 26, 2018, 6:49:24 AM9/26/18
to
It wasn't meant as logical proof. Tell then is it possible to call
that C++ library that has thin Python wrapper slammed onto top of it
directly from C++ or not?

Liar must at least think that he knows correct answer or otherwise he
can't lie, bullshitter is free of that constraint. ;)

Öö Tiib

unread,
Sep 26, 2018, 7:48:11 AM9/26/18
to
It certainly shows that you are more kind person than I am. You
conclude from OP's vague one-liners that there is someone who
wants to learn but just can't yet ask questions. I see someone who
is too lazy, hasty, careless and/or superficial to investigate what
he has ... like to find his way into PolyBoRi/testsuite/src/
directory. We can be both wrong of course.

Bart

unread,
Sep 26, 2018, 7:57:53 AM9/26/18
to
Here's an example from two of my languages (not C, C++ or Python) which
should illustrate what I mean.

In the easier of the two, you can write stuff like this:

b := "ABC"
c := "XYZ"
a := b + c
print a

Output is ABCXYZ. The other language is more low level, but it is used
to /implement/ the first one.

According to you, that means the low level language should also be able
to do that string concatenation.

Well, you're right. The trouble is that it would look like this (greatly
simplified to only deal with a combination of two strings):

varrec a,b,c

b.tagx := tstring ior hasrefmask
b.objptr := make_str("ABC",3)
c.tagx := tstring ior hasrefmask
c.objptr := make_str("XYZ",3)

a.tagx := tvoid

if b.tag = tstring and c.tag = tstring then
pc_ufree(&a) when a.hasref
a.objptr := add_stringobj(b.objptr, c.objptr)
a.tagx := tstring ior hasrefmask
fi

pch_print(&a,nil)


Do you see the difference?

--
bart

James Kuyper

unread,
Sep 26, 2018, 8:06:25 AM9/26/18
to
Replying with a link to the source code for that library seems like one
obviously superior alternative.
I got as far as <https://git.sagemath.org/sage.git/tree/src/sage>, when
I realized I didn't know which directory contains the PolyBoRi code, and
didn't feel like searching farther. If you know that the code is C++,
you might provide hints to speed up that search.

Öö Tiib

unread,
Sep 26, 2018, 8:25:12 AM9/26/18
to
There are the packages:
https://git.sagemath.org/sage.git/tree/build/pkgs
Hmm the PolyBoRi is renamed as brial.
https://git.sagemath.org/sage.git/tree/build/pkgs/brial/SPKG.txt
So the C++ examples are there:
https://github.com/BRiAl/BRiAl/tree/master/tests
Particularly BoolePolyRingTest.cc is likely of interest.

Öö Tiib

unread,
Sep 26, 2018, 8:47:56 AM9/26/18
to
On Wednesday, 26 September 2018 14:57:53 UTC+3, Bart wrote:
>
> Do you see the difference?

Yes I see, and your example is good in sense that usage of C++ is
indeed at least twice more verbose and complicated than that of Python.
Also, sage has already redirected all hard lifting to libraries
so there is no much performance gain to expect.
However OP did explicitly express his desire to undo that and to
use C++ directly, so he deserves few kicks. ;)

red floyd

unread,
Sep 26, 2018, 2:47:50 PM9/26/18
to
How much are you going to pay me to do your homework?

Jorgen Grahn

unread,
Sep 26, 2018, 4:18:18 PM9/26/18
to
Probably not more kind, but perhaps more restrained.

Or, to be honest, I thought your posting was mean /and/ unlike you.
I normally find your postings very reasonable.

> You
> conclude from OP's vague one-liners that there is someone who
> wants to learn but just can't yet ask questions.

I just don't want to rule it out.

> I see someone who
> is too lazy, hasty, careless and/or superficial to investigate what
> he has ... like to find his way into PolyBoRi/testsuite/src/
> directory. We can be both wrong of course.

Öö Tiib

unread,
Sep 26, 2018, 5:21:33 PM9/26/18
to
On Wednesday, 26 September 2018 23:18:18 UTC+3, Jorgen Grahn wrote:
>
> Or, to be honest, I thought your posting was mean /and/ unlike you.
> I normally find your postings very reasonable.

Hmm, only unusual thing today was that I had to visit a dentist.
Does it make some sort of hormones of evilness and unfairness
go up? :) Next time I take vow of silence after dentist.
0 new messages