[sage-support] Generation of graphs where all maximal cliques have the same size
Hi, how can I generate, in a fast enough way, connected graphs for which the clique complex is pure, ie, for which all containmentwise maximal cliques are of the same size ? Fast enough here means that I can produce examples of such graphs with 20 vertices, edge degrees between 10 and 14 (an example of such a graph on diagonals in a regular 7-gon with edges being pairwise noncrossing diagonals and the resulting clique complex the dual associahedron of dimension 4). What I got so far is: from sage.graphs.independent_sets import IndependentSets for G in graphs.nauty_geng("20 -c -d10 -D14"): cliques = IndependentSets(G, maximal = True, complement = True) sizes = map(len,cliques) size_min = min(sizes) if size_min > 4: size_max = max(sizes) if size_min == size_max: print list(cliques) But this seems to be too slow, already because it takes too long for this to turn the graph6 string from nauty into a sage graph. Does someone know how I can do this computation more low-level? Best would clearly be to teach nauty to only iter through such graphs, but that does not seem to be possible... Thanks, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Random connected poset on n elements
Is there a way to obtain a random connected poset on n unlabelled elements in sage? Random preferably means uniformly at random, but other randomness might be okay if it is not too far away from uniform. Generating all posets, checking for connectedness and picking is way too slow. Equivalently, what about random connected acyclic graphs ? I find sage: from sage.graphs.graph_generators_pyx import RandomGNP sage: D = RandomGNP(10, .2, directed = True) but this ignores connected (not too bad) and acyclic (bad), and doesn't seeem to be close is not even close to uniformly at random. Thanks, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Random connected poset on n elements
> > 0) take a connected random graph (call graphs.RandomGNP in a loop, until > you get something connected) > 1) take a random ordering of vertices, say v1,v2,...,vn. > 2) orient each edge (vi,vj) in the direction j>i. > This last step is actually a good idea, I didn't think of this way of getting a somewhat random acyclic orientation -- I'll try playing, thanks! -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] Random connected poset on n elements
> How big is your n? > not very big, I aim for the biggest n for which I can loop through all permutations of n and compute some numbers. I expect this to be between 10 and 14. > "Almost all" finite posets are connected, so uniform distribution of all > posets would work too for bigger n. > how would I get uniform distribution on all posets? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] Random connected poset on n elements
> There is a code for generating posets, see attachment at > https://trac.sagemath.org/ticket/14110 , but unfortunately it has not > been > integrated to Sage. I just tested and it takes about 2,2 seconds to > generate 11-element posets (there are 46749427 of those) and 38 seconds > for 12-element posets. I guess you could use that up to 14 elements. > that's indeed a good pointer, that might indeed work! -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Graph canonical form directly on matrices
(This question is about speed improvements of an existing approach, not about finding a first toy solution.) Let A, B be two ( (n+m) x n ) integer matrices. Say that these are isomorphic if they coincide up to *simultaneous* row and column permutations of the indices 0,...,n-1. Example: [[1,0],[0,0]] and [[0,0],[0,1]] are isomorphic because interchanging rows 0 and 1 and also columns 0 and 1 interchange the two. NonExample: [[1,0],[0,0]] and [[0,1],[0,0]] are not isomorphic. I would now like to obtain a canonical form CF : Mat( (n+m) x n) -> Mat( (n+m) x n) for each isomorphism class. This is CF(M1) == CF(M2) if and only if M1 and M2 are isomorphic. I actually do not care if the canonical form is a matrix, a canonical hash function is enough and what I do use below. This is almost the graph canonical form because two graphs are isomorphic if and only if their adjacency matrices are isomorphic in the above sense. So what I do currently is * turn my integer matrix into a directed, edge-labelled graph * turn this edge-labelled graph into an unlabelled graph by replacing each non-one-label into a new vertex and keep track which new vertices represent the same edge label * use the canonical form algorithm in Sage to compute a canonical form (I use the bliss version, because it allows me to not get back a graph, but only a list of edges which is good enough to compute a canonical hash). The code is def matrix_canonical_hash(M, n, m): dg,partition = _matrix_to_digraph(M, n, m) dg_canon = dg.canonical_label(partition=partition, algorithm="bliss", return_graph=False) return hash(tuple(sorted(dg_canon))) def _matrix_to_digraph(M, n, m): dg = DiGraph(sparse=True) dg.add_vertices(range(n+m)) edge_labels = [] new_vertex = n+m new_partition = [] for i, j in M.nonzero_positions(): if i < n: a, b = M[i, j], M[j, i] else: a, b = M[i, j], -M[i, j] if a > 0: if a == 1 and b == -1: dg._backend.add_edge(i,j,None,True) else: try: x = edge_labels.index((a,b)) except ValueError: x = len(edge_labels) edge_labels.append((a,b)) new_partition.append([]) finally: dg.add_vertex(new_vertex) dg._backend.add_edge(i,new_vertex,None,True) dg._backend.add_edge(new_vertex,j,None,True) new_partition[x].append(new_vertex) new_vertex += 1 elif i >= n: if a == -1 and b == 1: dg._backend.add_edge(j,i,None,True) else: a = -a b = -b try: x = edge_labels.index((a,b)) except ValueError: x = len(edge_labels) edge_labels.append((a,b)) new_partition.append([]) finally: dg.add_vertex(new_vertex) dg._backend.add_edge(j,new_vertex,None,True) dg._backend.add_edge(new_vertex,i,None,True) new_partition[x].append(new_vertex) new_vertex += 1 partition = [list(range(n))] if m > 0: partition.append(list(range(n,n+m))) if new_partition: partition.extend(new_partition) return dg, partition def fast_copy(M, n, m): Mnew = zero_matrix(n+m,n) for (i,j),val in M.dict().iteritems(): Mnew[i,j] = val return Mnew My matrices have a few more properties which I use in _matrix_to_digraph (namely that M[i,j] and M[j,i] have opposite signs and M[i,j] > 0 for i >= n). Since I have to do many of such test, it needs to be fast. Currently, only 1/3 of the time is spent doing the bliss algorithm. My questions thus are: 1. Does anyone know if there is a (similarly optimized) version of the canonical form algorithms that do the canonical forms on matrices rather than on graphs? 2. Does anyone see how I can speed the construction of the canonical form input graph from a given matrix ? Many thanks for your help -- any improvements will make their way into the cluster algebra and quiver mutation functionality in main Sage, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Graph canonical form directly on matrices
Let me add that the situations I care about are n,m <= 20, the entries are <=5 and the matrices are sparsely filled. An random and typical example is sage: M = matrix([(0, -1, 0, 0, 0, 0, 0, 1), : (1, 0, 1, 0, 0, 0, 0, 0), : (0, -1, 0, 0, 1, 0, 0, 0), : (0, 0, 0, 0, 0, 1, 0, 0), : (0, 0, -1, 0, 0, 0, 1, 0), : (0, 0, 0, -1, 0, 0, -1, 0), : (0, 0, 0, 0, -1, 1, 0, 0), : (-2, 0, 0, 0, 0, 0, 0, 0), : (-1, 1, 0, 0, 0, 0, 0, 0), : (0, 1, 0, 0, 0, 0, 0, -1), : (0, 1, 0, 1, 0, -1, 0, -1), : (0, 2, -1, 1, 0, -1, 0, -1), : (0, 2, -1, 0, 0, -1, 0, -1), : (0, 2, 0, 0, -1, -1, 0, -1), : (0, 2, 0, 0, -1, 0, -1, -1), : (0, 2, 0, 0, 0, 0, -2, -1)] : ) sage: M [ 0 -1 0 0 0 0 0 1] [ 1 0 1 0 0 0 0 0] [ 0 -1 0 0 1 0 0 0] [ 0 0 0 0 0 1 0 0] [ 0 0 -1 0 0 0 1 0] [ 0 0 0 -1 0 0 -1 0] [ 0 0 0 0 -1 1 0 0] [-2 0 0 0 0 0 0 0] [-1 1 0 0 0 0 0 0] [ 0 1 0 0 0 0 0 -1] [ 0 1 0 1 0 -1 0 -1] [ 0 2 -1 1 0 -1 0 -1] [ 0 2 -1 0 0 -1 0 -1] [ 0 2 0 0 -1 -1 0 -1] [ 0 2 0 0 -1 0 -1 -1] [ 0 2 0 0 0 0 -2 -1] sage: matrix_canonical_hash(M, 8, 8) 2718289463783950847 -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] Graph canonical form directly on matrices
Dear Johan, > The most inefficient part of _matrix_to_digraph seems to be the > following line: > > > x = edge_labels.index((a,b)) > you are totally right, thanks for this suggestion! (Unfortunately, this will not change anything in practice, because the list edge_labels will usually be at most of length 2, and never be longer than 5 in my case, independent of n and m.) Cheers, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Graph canonical form directly on matrices
Hi Simon, Thanks for trying! I was actually hoping for a way to completely avoid creating this sage DiGraph. But either to get the matrix directly into the algorithm (which currently seems impossible), or at least to directly construct some internal graph data structure. Looking at the code of sage.graphs.bliss.canonical_form, you see that the input digraph is turned into a bliss_digraph (whatever that is). So I believe that there is, in principle, a way to bypass the DiGraph creation... Thanks again, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Graph canonical form directly on matrices
Dear Dima, Ultimately, the classical canonical form/isomorphism implementations run on > (di)graphs represented by 0-1 matrices, often > with bit entries. So that's how bliss_digraph is represented too. > Thanks for this info clarifying that it seems impossible to feed the algorithm any other kind of integer matrix. Anyhow, the main inefficiency in your approach is coming from constructing > unnecessarily big graphs. > Also thanks for this reference, for the general problem this is certainly the correct approach. In my example cases though (as mentioned above), I have only very few edge labels (usually only two) so I doubt this improvement would change the overall performance. If you implemented this in Sage, it would be a great contribution! > I agree that this would be very worth having! But my cython skills are too weak to do this in the appropriate speed context. One question here: am I correct that the best we can currently hope for is to 1. feed the algorithm a list of labelled edges 2. turn this list of labelled edges into a list of unlabelled edges representing the edge-labelled graph as in Section 13 3. feed this to either the bliss or the nauty algorithm 4. get back an unlabelled graph 5. turn this back into an edge labelled graph > Also, I am not sure whether bliss is faster than nauty (nauty also is a > Sage standard package, but lacks a cython interface) > The only reason I use bliss over nauty is that it can return only a list of edges rather than creating the output DiGraph. And in the tests I did, 1/3 of the time was spend on constructing the canonical form and 2/3 were used to turn these output edges into a DiGraph (this compares bliss with and without constructing the output graph, nauty was as fast as bliss with output graph construction). Cheers, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Graph canonical form directly on matrices
Dear Simon, Anyway, looking at sage/graphs/bliss.pyx, it seems easy to modify your > code to directly create a bliss graph. > Help there is highly appreciated :-), I don't know how to do that appropriately... Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Graph canonical form directly on matrices
Dear Simon and Dima, I moved this to https://trac.sagemath.org/ticket/24924 for better traceability and to show you some code snippets... Cheers, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] All hamiltonian cycles in graphs
Hi there, is the functionality to get *ALL* hamiltonian cycles in a graph somehow already available in Sage? (Mathematica provides that, http://reference.wolfram.com/language/Combinatorica/ref/HamiltonianCycle.html, but I would prefer not to pay for each hamiltonian cycle I am offered by my computer...) Thanks, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: All hamiltonian cycles in graphs
Many thanks, works well and fast enough! -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: gfan, reduced bases, and weight vectors
> > In short, the Gröbner fan knows the correct ordering (in terms of a weight > vector) but Sage's output presents the basis with a different ordering. > This caused me no small amount of confusion. Is this a feature, or a bug? > I ran into this very same issue today -- to get a functionality out of this would be to provide a method for Gröbner fans that returns the leading monomials of a given reduced Gröbner basis with respect to the corresponding weight vector. The only assumption that I would need to make is that the reduced Gröbner bases come in the same order the weight vectors come. Can anyone confirm that this is always the case? Thanks, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Word problem in finite permutation groups as monoids
The method "word_problem" for a permutation group element can be found at http://doc.sagemath.org/html/en/reference/groups/sage/groups/perm_gps/permgroup_element.html#sage.groups.perm_gps.permgroup_element.PermutationGroupElement.word_problem But if the permutation group G is finite, I wonder whether I can also obtain a shortest word of an element w in G that does not use the inverses? This is, is there a way to get a word in M(G) = < g1, ... gm >_{monoid} as a monoid (of course M(G) = G as sets for G finite)? If this is not yet anywhere in Sage, is there maybe a function in gap that does provide that, which I could wrap? One simple example would be: sage: pi (1,12)(2,24)(3,19)(4,22)(5,17)(6,20)(7,23)(8,9)(10,21)(11,13)(14,18)(15,16) sage: G.gens() [(1,3,9)(2,4,7)(5,10,18)(6,11,16)(8,12,19)(13,15,20)(14,17,21)(22,23,24), (1,5,13)(2,6,10)(3,7,14)(4,8,15)(9,16,22)(11,12,17)(18,19,23)(20,21,24)] sage: pi.word_problem(G.gens(),False)[0] 'x1*x2^-1*x1^-2*x2^-1' sage: pi.not_existing_word_problem_method_as_monoid(G.gens()) 'x2*x1*x1*x2*x1*x1' Thanks! Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] How to run Macaulay2 code through Sage interface
Hi, is there a way to achieve the below computation directly in Sage, possibly using the M2 interface ? Thanks, Christian $ sage -M2 Macaulay2, version 1.4 with packages: ConwayPolynomials, Elimination, IntegralClosure, LLLBases, PrimaryDecomposition, ReesAlgebra, TangentCone i1 : loadPackage "Points"; i2 : M = matrix{{1,2,3},{4,5,6}}; o2 = | 1 2 3 | | 4 5 6 | 23 o2 : Matrix ZZ <--- ZZ i3 : R = QQ[x,y,MonomialOrder=>Lex]; i4 : (Q,inG,G) = points(M,R) 2 33 2 o4 = ({1, y, y }, ideal (y , x), {y - 15y + 74y - 120, x - y + 3}) o4 : Sequence -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] How to run Macaulay2 code through Sage interface
> YES. thanks, that's the first step -- I did actually mean so that I get the output as Sage objects. Sorry for not saying that explicitly... -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] How to run Macaulay2 code through Sage interface
> I spent most of the last week at a Macaulay2 workshop, and actually playing with M2<->Sage interface :-) > here you are: Awesome, thanks! -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] parallelize for-loop with side effects
Hi there, I wonder how to parallelize the following scenario. I have a method that initiates a (not very simple) data strucure and then runs a for-loop (of, say, length 1,000-20,000) to populate that data structure with data. The computations in each loop is not trivial, but fairly optimized using cython. All iteration steps done serially take a few secs (about 2 or 3). Nevertheless, the computations are fairly independent and I would like to do them in parallel. If I extract the content of the for-loop into an @parallel(2) decorated function, it still seems to be using only one cpu to do the computation (why?), but all the forking takes tons of time (i.e., including 80secs for posix.wait and 15 for posix.fork). If I read the documentation right, this is due to the issue that every computation is done in a subprocess itself and the data structure is also forked and passed to the subprocess. Is that correct? If I use @parallel('reference',2) instead (without knowing what that actually does), it is again as quick as in the beginning but also uses only a single cpu. What am I doing wrong here? Does anyone know how I should handle such a (I suspect not very uncommon) situation? Thanks, Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] parallelize for-loop with side effects
Thanks, William! > It absolutely will use two additional *processes*, as you might see by > watching with htop, top, or using ps. Is it right that the master process is creating all the subprocesses? I'd suspect I don't quite see the other processes in action simply because they are there only for milliseconds... > Yes-ish. Just to be clear there is one single fork that happens, > which means that > (almost) all state of the process is inherited by the subprocess. Yes, but every subprocess modified the data structure *within the subprocess*, the object in the main process is not modified, or am I missing something? (That's at least how I understand the documentation, and what I see happening in my computation output.) > That fakes @parallel -- providing the same API -- but actually running > everything in serial in the parent process. No forking or anything > else happens. It's for testing and development purposes. I see. > Break up your computation into far less than 20,000 separate steps, then us > @parallel. Okay, I'll do that. But I still don't see how I should handle the side effects that are supposed to effect objects in the main process. Or are you suggesting that I should (actually also for clarity of the code) completely remove all side effects, do the computations in parallel, but instead of the side effects return the stuff I need and then do the side effect stuff in serial. Sth. like @parallel def f(m): return [ factor(k) for k in range(1000*m, 1000*(m+1)) ] obj = MyObj() for x in f([1..20]): print x[0] for y in x: obj.store_new_data(y) If I should do it this way: is the body of the for-loop executed in the main process *in parallel* to the subprocess computing the next element of the iterator f([1..20]) ? Thanks again for the clarification! Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] parallelize for-loop with side effects
> I encourage you to read the source code of this @parallel stuff -- > it's only about 2 pages of actual code, > which I wrote at some Sage days as my project back in maybe 2008. Will do, thanks again! -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] vector space dimension of a subring of a quotient of a polynomial ring?
Hello, I would like to do the following computation concerning a subring of a quotient of a polynomial ring: The first task is easily solvable: compute the dimension of the coinvariant ring of the symmetric group: sage: R. = QQ['x1, x2, x3'] sage: I = R.ideal( x1+x2+x3, x1^2+x2^2+x3^2, x1^3+x2^3+x3^3 ) sage: I.vector_space_dimension() 6 This is the dimension of the the quotient of the ring R by the ideal I. Now imagine that R is replaced by QQ['x1, x2, x3, y1, y2, y3']. I would like to mod out by the same ideal and then compute the vector space dimension of a subring of this quotient having again finite vector space dimension. In the example, the subring is generated by x1, x2, x3, x1*y1+x2*y2+x3*y3, x1^2*y1+x2^2*y2+x3^2*y3, x1^3*y1+x2^3*y2+x3^3*y3. Is there any construction solving this kind of problem? Thanks for your help, Christian Stump -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: Data list
> m=[0.6158, 0.5893, 0.5682, 0.51510, 0.4980, 0.4750, 0.5791, > 0.5570,0.5461, 0.4970, 0.4920, 0.4358, 0.422, 0.420] > m.count len(m) does the job, you should probably look into the tutorial at http://www.sagemath.org/doc/tutorial/ for this kind of questions... m.count is a function returning the number of times some element appears in the list, so [1,2,3,2,2,4].count(2) returns 3 > Another similar thing, i want to multiply the all the elements for > 10^-6 if you want to apply a function to every element in a list, you can do that by [ f(i) for i in your_list ]. e.g., [ 2*i for i in [1,2,3] ] returns 2,4,6 Best, Christian -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] dimension of hom space between modules over an algebra?
Hello, we constructed some modules over the path algebra, and then the hom space using Hom. - How can we actually see that we computed the hom space over the algebra rather than as vector spaces over the base field? We tried getting out the dimension as a test, but there seems to be no way to do that. Does someone have some example code doing anything in this direction? Thanks a lot! Christian -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] faster computation of big sums of products of multivariate polynomials
Hello -- I want to do some computations with multivariate polynomials in the group W of type H4 (14400 elements). I have a summand for every element w \in W, and a product of 4 polynomials in each summand: gens = [] for obj in gens_objects: p = 0 for w in W: mon_w = F[obj][w][0] * F[obj][w][1] * F[obj][w][2] * F[obj][w][3] p = p + mon_w gens.append(p) return gens for every obj, this takes about 10sec (doing the same computation in Magma is about 4 times faster), and almost all the time is spend in all these multiplications (I also tried prod( F[obj][w] ) and P.prod( F[obj][w] ) where P is a polynomial ring in 8 variables, but both were slower. So my question is if I can somehow do the complete construction of such a generator p somehow directly in singular, and then turn it into a Sage object only before appending it to gens? Thanks for your help! Christian -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] How can I test if two symbolic expressions coincide?
Hello, can anyone tell me how I can use sage to check that the following two (fairly simple) expressions coincide. Some unneeded background: both come from identities in character theory for complex reflection groups, Sage was able to solve similar expressions, see below, and this is the smallest example I have were it doesn't work ? sage: f -(e^(2/3*I*pi) + 1)*e^(2/15*I*pi - 32*XX) + 3*(e^(2/3*I*pi) + 1)*e^(2/15*I*pi - 12*XX) - 5*(e^(2/3*I*pi) + 1)*e^(2/15*I*pi + 4*XX) + 3*(e^(2/3*I*pi) + 1)*e^(2/15*I*pi + 8*XX) - 5*(e^(2/3*I*pi) + 1)*e^(4*XX) + 6*(e^(2/3*I*pi) + 1)*e^(8*XX) - (e^(2/3*I*pi) + 1)*e^(28*XX) + 3*(((e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(-12*XX) - 5*(((e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(-8*XX) + 3*(((e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(8*XX) - (((e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(28*XX) - 5*(e^(2/15*I*pi) - 1)*e^(4/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(4/15*I*pi) - 1)*e^(4*XX) + 5*(e^(4/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(4/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(4*XX) + 3*(e^(2/15*I*pi) - 1)*e^(4/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(4/15*I*pi) - 1)*e^(8*XX) - 3*(e^(4/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(4/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(8*XX) + 3*(e^(2/15*I*pi) - 1)*e^(4/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(4/15*I*pi) - 1)*e^(-12*XX) - 3*(e^(4/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(4/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(-12*XX) - (e^(2/15*I*pi) - 1)*e^(4/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(4/15*I*pi) - 1)*e^(-32*XX) + (e^(4/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(4/15*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(-32*XX) - e^(4/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(-32*XX) + 3*e^(4/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(-12*XX) - 5*e^(4/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(4*XX) + 3*e^(4/15*I*pi) - 1)*e^(2/15*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/15*I*pi) - 1)*e^(8*XX) + 5*e^(4/15*I*pi + 4*XX) + 5*e^(14/15*I*pi + 4*XX) + 5*e^(8/15*I*pi + 4*XX) + 5*e^(2/15*I*pi + 4*XX) + 5*e^(2/3*I*pi + 4*XX) + 5*e^(6/5*I*pi - 8*XX) + 5*e^(4/5*I*pi - 8*XX) + 5*e^(2/5*I*pi - 8*XX) - 3*e^(4/15*I*pi + 8*XX) - 3*e^(14/15*I*pi + 8*XX) - 3*e^(8/15*I*pi + 8*XX) - 3*e^(2/15*I*pi + 8*XX) - 3*e^(4/15*I*pi - 12*XX) - 3*e^(14/15*I*pi - 12*XX) - 3*e^(8/15*I*pi - 12*XX) - 3*e^(2/15*I*pi - 12*XX) - 6*e^(2/3*I*pi + 8*XX) - 3*e^(6/5*I*pi + 8*XX) - 3*e^(4/5*I*pi + 8*XX) - 3*e^(2/5*I*pi + 8*XX) - 3*e^(6/5*I*pi - 12*XX) - 3*e^(4/5*I*pi - 12*XX) - 3*e^(2/5*I*pi - 12*XX) + e^(4/15*I*pi - 32*XX) + e^(14/15*I*pi - 32*XX) + e^(8/15*I*pi - 32*XX) + e^(2/15*I*pi - 32*XX) + e^(6/5*I*pi + 28*XX) + e^(4/5*I*pi + 28*XX) + e^(2/5*I*pi + 28*XX) + e^(2/3*I*pi + 28*XX) + 5*e^(-8*XX) - 6*e^(8*XX) + e^(88*XX) sage: g e^(-32*XX) - 2*e^(28*XX) + e^(88*XX) Other similar examples were property simplified: sage: h (((e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(-42*XX) - 5*(((e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(-6*XX) + 5*(((e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(6*XX) - (((e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(2/5*I*pi) + 1)*e^(18*XX) + 5*e^(6/5*I*pi - 6*XX) + 5*e^(4/5*I*pi - 6*XX) + 5*e^(2/5*I*pi - 6*XX) - 5*e^(6/5*I*pi + 6*XX) - 5*e^(4/5*I*pi + 6*XX) - 5*e^(2/5*I*pi + 6*XX) - 4*e^(1/10*I*pi + 3*XX) + 4*e^(7/10*I*pi + 3*XX) + 4*e^(3/10*I*pi + 3*XX) + 4*e^(1/10*I*pi + 3*XX) - 4*e^(7/10*I*pi + 3*XX) - 4*e^(3/10*I*pi + 3*XX) - 4*e^(6/5*I*pi + 3*XX) - 4*e^(4/5*I*pi + 3*XX) - 4*e^(2/5*I*pi + 3*XX) + 4*e^(6/5*I*pi + 3*XX) + 4*e^(4/5*I*pi + 3*XX) + 4*e^(2/5*I*pi + 3*XX) + 2*e^(1/10*I*pi + 18*XX) - 2*e^(7/10*I*pi + 18*XX) - 2*e^(3/10*I*pi + 18*XX) - 2*e^(1/10*I*pi + 18*XX) + 2*e^(7/10*I*pi + 18*XX) + 2*e^(3/10*I*pi + 18*XX) + 2*e^(1/10*I*pi - 12*XX) - 2*e^(7/10*I*pi - 12*XX) - 2*e^(3/10*I*pi - 12*XX) - 2*e^(1/10*I*pi - 12*XX) + 2*e^(7/10*I*pi - 12*XX) + 2*e^(3/10*I*pi - 12*XX) + e^(6/5*I*pi + 18*XX) + e^(4/5*I*pi + 18*XX) + e^(2/5*I*pi + 18*XX) - e^(6/5*I*pi - 42*XX) - e^(4/5*I*pi - 42*XX) - e^(2/5*I*pi - 42*XX) + 5*e^(-6*XX) - 5*e^(6*XX) - e^(18*XX) + e^(78*XX) sage: h.factor().expand() e^(-42*XX) - 2*e^(18*XX) + e^(78*XX) I now tested the first equality by taking the first terms of the Taylor expansion of f and numerically evaluated the coefficients which turn out to coincide with the coefficients of the Taylor expansion of g. Thanks for pointer or further ideas! Christian -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-supp
[sage-support] Re: How can I test if two symbolic expressions coincide?
Okay, I got the simplification by doing sage: f.expand().simplify() while sage: f.simplify() or sage: f.simplify_full() did actually not work... -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.