Ask Your Question

jaebond's profile - activity

2024-01-16 04:31:12 +0100 received badge  Famous Question (source)
2024-01-16 04:31:12 +0100 received badge  Notable Question (source)
2023-11-02 07:56:29 +0100 received badge  Notable Question (source)
2023-11-02 07:56:29 +0100 received badge  Popular Question (source)
2023-08-29 04:13:50 +0100 edited question Using docbuild on an external package

Using docbuild on an external package I am attempting to use docbuild to build Sage-style documentation for a package th

2023-08-29 03:42:48 +0100 asked a question Using docbuild on an external package

Using docbuild on an external package I am attempting to use docbuild to build Sage-style documentation for a package th

2022-12-16 23:39:24 +0100 received badge  Famous Question (source)
2022-11-14 22:22:54 +0100 received badge  Taxonomist
2022-01-18 22:49:28 +0100 received badge  Popular Question (source)
2021-07-07 03:34:49 +0100 received badge  Notable Question (source)
2020-08-25 00:24:15 +0100 received badge  Notable Question (source)
2020-06-23 21:13:24 +0100 received badge  Notable Question (source)
2020-05-01 22:32:35 +0100 received badge  Popular Question (source)
2020-01-31 01:08:50 +0100 received badge  Famous Question (source)
2019-06-27 15:06:22 +0100 received badge  Notable Question (source)
2019-06-26 17:43:24 +0100 received badge  Popular Question (source)
2019-02-10 19:00:06 +0100 received badge  Nice Question (source)
2019-01-08 17:43:34 +0100 received badge  Popular Question (source)
2018-01-06 18:16:35 +0100 answered a question Using Singular's solve.lib

Looking in src/sage/interfaces/singular.py as suggested by @tmonteil, I noticed in some of the docstrings that the way to get at a Singular object is singular('obj_name'). Continuing the first example from the question, rlist can be accessed with singular('rlist'). Although it is still a Singular list, it can be indexed into, iterated over, etc. So something like the following will work:

sage: [[coord for coord in sol] for sol in singular('rlist')]

Again, the elements are still Singular objects, but one (perhaps rudimentary) way to convert them is

sage: [[sage_eval(coord._sage_repr()) for coord in sol] for sol in singular('rlist')]

Perhaps more robust than sage_eval and ._sage_repr() would be using .repart() and .impart() (which are the Singular functions for real and imaginary part):

sage: [[ComplexNumber(coord.repart(), coord.impart()) for coord in sol] for sol in singular('rlist')]

Note that ComplexNumber has an optional min_prec argument to control the precision of the ComplexField used to create the number, so that if the computations are performed at a high precision in Singular, the same precision can be ensured in Sage.

2018-01-06 18:03:29 +0100 commented answer Using Singular's solve.lib

When I tried I.variety(), Sage printed verbose 0 (3324: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation., so it looks like Sage is still using Groebner bases, just with a slower implementation. Is this accurate?

2018-01-06 16:40:29 +0100 received badge  Notable Question (source)
2018-01-06 16:19:46 +0100 received badge  Good Question (source)
2018-01-06 14:32:22 +0100 received badge  Enthusiast
2018-01-06 04:35:56 +0100 asked a question Using Singular's solve.lib

I am trying to use Singular's solve.lib from Sage, but I am running into issues with getting the result out of Singular. I tried using the Singular interface and was able to make it this far:

sage: singular.lib('solve.lib')
sage: r = singular.ring('complex', '(x,y)', 'lp')
sage: I = singular.ideal('(x-5)*y/32', 'y^2-x^3-5*x-10')
sage: R = singular.fglm_solve(I)
sage: singular.setring(R)

at which point the result is stored in a list rlist inside of R. I can do singular.eval('rlist') and see the answer, but in order to get it back into Sage I would have to parse the resulting string. Is there a better way to get rlist?

Alternatively, I tried to use libSingular as follows:

sage: from sage.libs.singular.function import singular_function, lib
sage: lib('solve.lib')
sage: fglm_solve = singular_function('fglm_solve')
sage: P = PolynomialRing(QQ,'x,y',order='lex'); x,y = P.gens()
sage: I = Ideal((x-5)*y/32, y^2-x^3-5*x-10)
sage: R = fglm_solve(I)

// 'fglm_solve' created a ring, in which a list rlist of numbers (the
// complex solutions) is stored.
// To access the list of complex solutions, type (if the name R was assigned
// to the return value):
        setring R; rlist; 
<RingWrap>

But then R is a <RingWrap> instance and this time I don't even know how to go about seeing the answer. Also, I would prefer to work over the complex field, but I couldn't get fglm_solve to accept an ideal in CC['x,y']

Any help in either direction would be greatly appreciated.

2017-12-12 17:58:49 +0100 marked best answer Faster function for working with cosets

I would like to get the cosets of a non-normal subgroup and in the documentation for the .cosets() method here:

PermutationGroup_generic.cosets

there is a Note: that says

Sage and GAP provide more sophisticated functions for working quickly with cosets of larger groups.

but doesn't mention what these functions are. I was hoping that someone could point me to these functions.

If it makes a difference, I want to iterate over a set of coset representatives and it will all be done in a permutation group.

2017-12-12 04:06:39 +0100 asked a question Error when trying to import without sage.all

I am trying to import only the Sage functions needed as is done in the Sage source code, but I am running into issues. For example, (running sage -python),

>>> from sage.groups.group import Group

results in

...
from sage.rings.complex_double import CDF
File "sage/rings/real_double.pxd", line 8, in init sage.rings.complex_double (/export/pkgs/linux-rh6/sagemath-7.0/src/build/cythonized/sage/rings/complex_double.c:22654)
File "sage/rings/real_double.pyx", line 64, in init sage.rings.real_double (/export/pkgs/linux-rh6/sagemath-7.0/src/build/cythonized/sage/rings/real_double.c:25060)
ImportError: cannot import name ZZ

(I can post the full traceback if that would be helpful.) Similar things happen for almost any import I try. I was using the import_statements to determine what to import.

Am I missing something?

EDIT:

I think I get the picture a little better now. The Sage source files aren't meant to be imported in Python, they are meant to be imported into Sage, which presumably runs import sage.all when it starts.

2017-12-08 06:34:33 +0100 asked a question Substituting a complex embedding for a number field element

Is there a way to take an element of a number field (or a polynomial or a number field) and replace the generator of the field by one of its complex embeddings? For example, something like

sage: K.<a> = NumberField(x^2 - 3)
sage: (3*a + 5).substitute(a=a.complex_embeddings()[1])

It's feasible to do this with sage_eval, but hopefully there is a better way.

2017-12-02 07:21:59 +0100 asked a question Import just one function from .sage file

I have a .sage file that has a single function I want to import. If it were a .py file, I would obviously use from temp import myfun, but as far as I know, .sage files have to be imported with either load('temp.sage') or attach('temp.sage') (or preparsed, but this gets tiresome). Is there a way to import just one function from a .sage file?

2017-08-02 17:25:06 +0100 received badge  Nice Answer (source)
2017-07-14 00:45:01 +0100 received badge  Nice Question (source)
2017-07-02 16:44:02 +0100 asked a question Loading a module causes the __name__ == '__main__' block to execute

I have a module that can also be run from the command line:

def func()
    print('Hello!')

if __name__ == '__main__':
    func()

When I try to load it in Sage, the main block is executed:

sage: load('module.sage')
Hello!
sage:

The bigger problem is that the main block parses command line arguments and Sage aborts the load with an error because it didn't receive any command line arguments. Is there any way to handle this? I can preparse module.sage and import it as a Python module, but its so much easier to attach('module.sage') than having to reload(module) every time I change it when I'm editing.

2017-06-27 18:57:59 +0100 commented question Accessing GAP's in function through the C Interface

Edited to clarify that I wanted to call this from Sage.

2017-02-13 02:12:31 +0100 asked a question Is there a way to relabel the domain of a permutation group?

Suppose I have a permutation group on the domain {1,2,3,4,5}, but instead I wanted this permutation group to be on the domain {a,b,c,d,e}. Is there a way to achieve this? Hopefully something like the relabel method for graphs...

2017-02-06 20:22:46 +0100 asked a question How to increase GAP's recursion limit

Is there a way to increase the recursion limit of (lib)GAP processes? I am hitting a recursion limit when computing a double coset:

--> 531 coset_space = libgap.DoubleCosets(G, C_G_s0, C_G_s1)

ValueError: libGAP: Error, recursion depth trap (5000)

2017-02-05 17:24:58 +0100 asked a question Accessing GAP's in function through the C Interface

Is there a way to access GAP's in function through Sage's C Interface to GAP?

gap> Identity(G) in G;
true

EDIT:

I was wondering how to call this from Sage:

sage: G = libgap.SymmetricGroup(5)
sage: g = libgap.eval('(1,2,3)(4,5)')

How do I test if g is in G?

2016-11-29 06:17:42 +0100 edited answer using GAP: Group Theory

Here is the problem:

sage: parent(gens)
C library interface to GAP

Just coerce them to GAP:

sage: parent(gap(gens))
Gap
sage: PermutationGroup(gap(gens))
Permutation Group with generators [(3,4), (2,3)]