[sage-devel] Re: multi-polynomial substitution consistency
I'd say that for a "full" evaluation at a list of images V for all variables, a guide would be that f(*V) should be roughly: sum(c*prod(m^e for e,m in zip(es,V)) for es,c in f.dict().items()) Only roughly, though, because for, for instance, if f==0, then this code evaluates to an empty sum, so we probably get the integer 0 back, which is not particularly desirable. So, I'd say for a full evaluation, the result should be whatever the coercion system can find to be the "common over-ring" for f.base_ring() and the elements of V. We'd probably want to have some shortcuts in determining this codomain. It also suggests that if you want to do multiple evaluations, building the corresponding homomorphism might be faster, since it avoids a lot of discovery. I'd say that a partial evaluation such as R.=QQ[] f=x^2+x*y+y^2 f(x=1) should correspond to a full evaluation, where the unmentioned variables are taken to be evaluated at themselves, so the result should be f(1,y) which means it's f(*V) with V=(1,y). The same codomain determination rules as above apply. In particular, this means that something like f(x=1.0) still works and would give the same result as f(1.0,y) It looks like the example you give would then not work anymore, because sage does not create a common parent for QQ['x','y'] and QQ['q']. I think this ends up being a little more permissive rule for (partial) evaluations than you are proposing, but it would be a little more consistent with what we''re doing right now. On Sunday, May 9, 2021 at 1:50:06 AM UTC-7 vdelecroix wrote: > Dear all, > > Sage currently supports in a weird way partial substitution > of multivariate polynomials > > sage: R. = QQ[] > sage: S. = QQ[] > sage: p = x > sage: p.subs(x=q) > q > sage: p.subs(x=q).parent() > Univariate Polynomial Ring in q over Rational Field > > What is annoying in the above scenario is that it breaks > badly the rule "same input parent" -> "same output parent". > Here are three distinct output parents for the same substitution > command > > sage: p1 = R.zero() > sage: p2 = x > sage: p3 = x + y > sage: p1.subs(x=q).parent() > Rational Field > sage: p2.subs(x=q).parent() > Univariate Polynomial Ring in q over Rational Field > sage: p3.subs(x=q).parent() > Traceback (most recent call last): > ... > TypeError: unsupported operand parent(s) for +: > 'Univariate Polynomial Ring in q over Rational Field' and > 'Multivariate Polynomial Ring in x, y over Rational Field' > > I propose to raise a TypeError in all the above scenarii. In case > somebody wants to mutate the parent, she should provide a full > translation, namely > > sage: x.subs(x=q, y=S.zero()) > > In other words > > x.subs(x=*): partial substitution, output has parent parent(x) > x.subs(x=*, y=*): full substitution, output has parent the merge of > the base ring and the arguments > > What do you think? > > Best > Vincent > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/f802ca76-8608-4285-91b6-8c87012be56bn%40googlegroups.com.
Re: [sage-devel] [abi:cxx11] in givaro prevents linking to system givaro on Fedora 32
PS: Fedora 32 EOL is imminent (= 4 weeks after the just-released fedora 34), so I wouldn't worry too much about it On Sunday, May 9, 2021 at 12:24:23 PM UTC+2 Volker Braun wrote: > This is c++11 dual abi, see > https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html > > IMHO we just shouldn't use the system version then, but building Sage with > -D_GLIBCXX_USE_CXX11_ABI=0 should allow you to link with old-style abi > libraries. > > The default value of _GLIBCXX_USE_CXX11_ABI can be changed by the distro, > which is probably what accounts for the differences seen in this thread. > > > On Saturday, May 8, 2021 at 7:01:13 PM UTC+2 Steven Trogdon wrote: > >> Building Givaro on Gentoo I have >> >> CXXFLAGS=-O2 -pipe -march=native -O2 -pipe -fabi-version=6 -msse >> -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx >> >> Your Redhat has >> >> CXXFLAGS=-O2 -g -pipe -Wall -Werror=format-security >> -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions >> -fstack-protector-strong -grecord-gcc-switches >> -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 >> -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic >> -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection >> >> Could the abi-version=6 be the issue? >> >> On Saturday, May 8, 2021 at 6:01:02 AM UTC-6 dim...@gmail.com wrote: >> >>> one has >>> https://kojipkgs.fedoraproject.org//packages/givaro/4.1.1/1.fc32/data/logs/x86_64/build.log >>> and other logs there >>> >>> On Saturday, May 8, 2021 at 12:45:07 PM UTC+1 Dima Pasechnik wrote: >>> On Saturday, May 8, 2021 at 12:34:11 PM UTC+1 François Bissey wrote: > What compiler and flags have used to compile fedora 32 givaro? Can we > easily find out? the compiler used to build Sage is g++ 10.2.1 $ g++ -v Using built-in specs. COLLECT_GCC=/usr/bin/g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl= http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.2.1 20201125 (Red Hat 10.2.1-9) (GCC) > > > > On 8/05/2021, at 23:31, Dima Pasechnik wrote: > > > > With system Givaro, one gets > > > > [dochtml] ImportError: > /home/scratch2/dimpase/sage/sage/local/lib64/python3.8/site-packages/sage/matrix/ > matrix_modn_sparse.cpython-38-x86_64-linux-gnu.so: undefined symbol: > _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev > > > > make[3]: *** [Makefile:2280: doc-html] Error 1 > > > > which demangled says > > > > $ c++filt > _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev > > > > Givaro::Integer::operator std::__cxx11::basic_string std::char_traits, std::allocator >[abi:cxx11]() const > > > > The system library has Givaro::Integer::operator > std::__cxx11::basic_string, > std::allocator >() const > > > > (no of that weird [abi:cxx11] qualifier) > > > > Any ideas how to fix this? (besides not using system Givaro) ? > > > > Dima > > > > -- > > You received this message because you are subscribed to the Google > Groups "sage-devel" group. > > To unsubscribe from this group and stop receiving emails from it, > send an email to sage-devel+...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sage-devel/b187faf3-50c4-42c4-ae37-77c5a3902bbcn%40googlegroups.com. > > > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/c1ada588-aa08-4115-ad21-f121ae47fa30n%40googlegroups.com.
Re: [sage-devel] [abi:cxx11] in givaro prevents linking to system givaro on Fedora 32
This is c++11 dual abi, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html IMHO we just shouldn't use the system version then, but building Sage with -D_GLIBCXX_USE_CXX11_ABI=0 should allow you to link with old-style abi libraries. The default value of _GLIBCXX_USE_CXX11_ABI can be changed by the distro, which is probably what accounts for the differences seen in this thread. On Saturday, May 8, 2021 at 7:01:13 PM UTC+2 Steven Trogdon wrote: > Building Givaro on Gentoo I have > > CXXFLAGS=-O2 -pipe -march=native -O2 -pipe -fabi-version=6 -msse > -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx > > Your Redhat has > > CXXFLAGS=-O2 -g -pipe -Wall -Werror=format-security > -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions > -fstack-protector-strong -grecord-gcc-switches > -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 > -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic > -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection > > Could the abi-version=6 be the issue? > > On Saturday, May 8, 2021 at 6:01:02 AM UTC-6 dim...@gmail.com wrote: > >> one has >> https://kojipkgs.fedoraproject.org//packages/givaro/4.1.1/1.fc32/data/logs/x86_64/build.log >> and other logs there >> >> On Saturday, May 8, 2021 at 12:45:07 PM UTC+1 Dima Pasechnik wrote: >> >>> On Saturday, May 8, 2021 at 12:34:11 PM UTC+1 François Bissey wrote: >>> What compiler and flags have used to compile fedora 32 givaro? Can we easily find out? >>> >>> >>> the compiler used to build Sage is g++ 10.2.1 >>> >>> $ g++ -v >>> Using built-in specs. >>> COLLECT_GCC=/usr/bin/g++ >>> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper >>> OFFLOAD_TARGET_NAMES=nvptx-none >>> OFFLOAD_TARGET_DEFAULT=1 >>> Target: x86_64-redhat-linux >>> Configured with: ../configure --enable-bootstrap >>> --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr >>> --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl= >>> http://bugzilla.redhat.com/bugzilla --enable-shared >>> --enable-threads=posix --enable-checking=release --enable-multilib >>> --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions >>> --enable-gnu-unique-object --enable-linker-build-id >>> --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin >>> --enable-initfini-array --with-isl --enable-offload-targets=nvptx-none >>> --without-cuda-driver --enable-gnu-indirect-function --enable-cet >>> --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux >>> Thread model: posix >>> Supported LTO compression algorithms: zlib zstd >>> gcc version 10.2.1 20201125 (Red Hat 10.2.1-9) (GCC) >>> >>> >>> > On 8/05/2021, at 23:31, Dima Pasechnik wrote: > > With system Givaro, one gets > > [dochtml] ImportError: /home/scratch2/dimpase/sage/sage/local/lib64/python3.8/site-packages/sage/matrix/ matrix_modn_sparse.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev > make[3]: *** [Makefile:2280: doc-html] Error 1 > > which demangled says > > $ c++filt _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev > Givaro::Integer::operator std::__cxx11::basic_string>>> std::char_traits, std::allocator >[abi:cxx11]() const > > The system library has Givaro::Integer::operator std::__cxx11::basic_string, std::allocator >() const > > (no of that weird [abi:cxx11] qualifier) > > Any ideas how to fix this? (besides not using system Givaro) ? > > Dima > > -- > You received this message because you are subscribed to the Google Groups "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/b187faf3-50c4-42c4-ae37-77c5a3902bbcn%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/d5ab7843-811a-452d-bf74-c3c21bc4aef2n%40googlegroups.com.
[sage-devel] multi-polynomial substitution consistency
Dear all, Sage currently supports in a weird way partial substitution of multivariate polynomials sage: R. = QQ[] sage: S. = QQ[] sage: p = x sage: p.subs(x=q) q sage: p.subs(x=q).parent() Univariate Polynomial Ring in q over Rational Field What is annoying in the above scenario is that it breaks badly the rule "same input parent" -> "same output parent". Here are three distinct output parents for the same substitution command sage: p1 = R.zero() sage: p2 = x sage: p3 = x + y sage: p1.subs(x=q).parent() Rational Field sage: p2.subs(x=q).parent() Univariate Polynomial Ring in q over Rational Field sage: p3.subs(x=q).parent() Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for +: 'Univariate Polynomial Ring in q over Rational Field' and 'Multivariate Polynomial Ring in x, y over Rational Field' I propose to raise a TypeError in all the above scenarii. In case somebody wants to mutate the parent, she should provide a full translation, namely sage: x.subs(x=q, y=S.zero()) In other words x.subs(x=*): partial substitution, output has parent parent(x) x.subs(x=*, y=*): full substitution, output has parent the merge of the base ring and the arguments What do you think? Best Vincent -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/6db84c5e-f6c3-31dd-6fc9-58283fd0d093%40gmail.com.