[sage-support] Re: How to generate permutation matrices (fast)?

2020-11-23 Thread jplab
... ok! Found it:

sage: P = 
Permutations([1,2,3])   

 

sage: elmts = 
P.elements_of_length(3) 

 

sage: e = 
next(elmts) 

 

sage: 
e   

 

[3, 2, 1]
sage: 
e.to_matrix()   

 

[0 0 1]
[0 1 0]
[1 0 0]

... somehow was thinking of using too technical things.

Le lundi 23 novembre 2020 à 14:44:00 UTC+1, jplab a écrit :

> Hi all,
>
> I would have posted this question on AskSage, but I can't seem to be able 
> to connect through my google account (Authorization Error?). So I put the 
> question here.
>
> I would like to know how to iterate through permutation matrices of a 
> fixed size ($n\times n$) by breadth-first-search (by length in the weak 
> order poset). Somehow, this is pretty simple, but I can't seem to figure 
> this out from the jungle of methods available.
>
> I do know that it is possible to get the elements by lengths in the 
> CoxeterGroup(['A',n-1]) structure, but I want the permutation matrix 
> associate to the element.
>
> Somehow, tons of methods are available but the obvious 
> "permutation_matrix" is not there.
>
> Any hint? I know I missed something somewhere!
>
> J-P
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/a8e40b1b-64fd-41bc-8eac-30a925fa0a68n%40googlegroups.com.


[sage-support] How to generate permutation matrices (fast)?

2020-11-23 Thread jplab
Hi all,

I would have posted this question on AskSage, but I can't seem to be able 
to connect through my google account (Authorization Error?). So I put the 
question here.

I would like to know how to iterate through permutation matrices of a fixed 
size ($n\times n$) by breadth-first-search (by length in the weak order 
poset). Somehow, this is pretty simple, but I can't seem to figure this out 
from the jungle of methods available.

I do know that it is possible to get the elements by lengths in the 
CoxeterGroup(['A',n-1]) structure, but I want the permutation matrix 
associate to the element.

Somehow, tons of methods are available but the obvious "permutation_matrix" 
is not there.

Any hint? I know I missed something somewhere!

J-P

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/edf3dd4b-406d-4eff-acfa-fc883d695c1dn%40googlegroups.com.


[sage-support] Re: polyhedron H-representation: variables determined by equations

2019-09-01 Thread jplab
Hi Daniel,

As far as I know, no such method is implemented in the polyhedron class.

If I understood your situation, you want to know the set of coordinates 
"x_i" such that the projection along that axis is an injective function 
i.e. given a point in the image of the projection, you can lift it back 
uniquely using equations.

Already here, I see that this can be non-empty if and only if you have 
equations, 
which is what you want I guess. So, to compute the coordinates for which 
this 
property is true, I would compute a basis for the affine hull of the 
polyhedron 
(essentially, being lazy, I would just compute the polyhedron by dropping 
the 
inequalities and take the lines as my basis) and if that basis has a 
canonical 
vector e_i, then that vector is in the complement of the set you're looking 
for.

Best,
J-P



Le lundi 25 février 2019 11:10:24 UTC+1, Daniel Krenn a écrit :
>
> The H-representation consists of equations and inequalities and the 
> equations seem to be in some canonical form. Is there a method that 
> returns the non-free variables (or indices), i.e. that are the variables 
> completely determined by the equations meaning once a value for the 
> other variables is fixed, then one can compute them and no further 
> restrictions apply. 
>
> E.g. for 
>
> sage: polytopes.simplex(2).Hrepresentation() 
> (An equation (1, 1, 1) x - 1 == 0, 
>  An inequality (0, -1, -1) x + 1 >= 0, 
>  An inequality (0, 1, 0) x + 0 >= 0, 
>  An inequality (0, 0, 1) x + 0 >= 0) 
>
> I simply want to get the list of indices [0], as the first component is 
> only determined by (1, 1, 1) x - 1 and does not appear in any of the 
> inequalities. 
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/c927ad01-a402-46b7-b070-8256aa5f294c%40googlegroups.com.


Re: [sage-support] Re: Is this a bug in Polyhedron class (RDF vs AA)?

2015-10-13 Thread jplab
Hi,

Thank you for your quick answer!

Ok, that makes sense. I have a follow-up question. I will put it on 
sage-devel as it is related to the implementation of a ticket.

Best,
JP





Le lundi 12 octobre 2015 22:21:12 UTC+2, vdelecroix a écrit :
>
> On 12/10/15 12:57, Nathann Cohen wrote: 
> >> Is the following behavior normal: 
> > 
> > Well... In the first case you work on an exact ring, and in the second 
> case 
> > you compare the output of >= and > on an inexact ring. 
> > 
> > I do not know if there is something wrong somewhere, but I do not expect 
> > float computations to be exact either, so I do not know... 
>
> Yeap. This is exactly it. You have vertices over an inexact ring and 
> equations over an inexact ring. You should not expect anything beyond 
> the precision of the ring. Including subtle difference between < and <=. 
>
> sage: 0.9 == 0.3 + 0.3 + 0.3 
> False 
> sage: 0.9 > 0.3 + 0.3 + 0.3 
> True 
>

-- 
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] Is this a bug in Polyhedron class (RDF vs AA)?

2015-10-12 Thread jplab
Hi everyone,

Is the following behavior normal:

sage: P = polytopes.regular_polygon(5)
sage: a_vertex = P.vertices()[0]
sage: for facet in P.Hrepresentation(): print facet.contains(a_vertex), 
facet.interior_contains(a_vertex)

True False
True True
True False
True True
True True
sage: P = polytopes.regular_polygon(5, base_ring=RDF)
sage: a_vertex = P.vertices()[0]
sage: for facet in P.Hrepresentation(): print facet.contains(a_vertex), 
facet.interior_contains(a_vertex) 
True True
True True
True True
True True
True True

Doing this containment test in RDF seems to break. I guess that there are 
many methods that depend on the containment methods that also break then?


-- 
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] "sagesilent" block in a "newcommand" macro

2012-01-16 Thread jplab
Hi everyone,

I would like to include some nice tikz pictures of polytopes generated
by sage (see http://trac.sagemath.org/sage_trac/ticket/12083 for the
ticket.) in a tex file.

But since I'm a lazy guy, I want tex to do the work for me. That's why
I thought of a tex command that would:

1) take all the needed arguments;
2) run a sagesilent block;
3) include the produced tikz picture (produced in the sagesilent
block, included in a file).

All that in a very nice tex command.

Something like (replacing the polytope things by a matrix for
simplication reasons...):

\newcommand{\tikzimage}[1]{\begin{sagesilent}
   M=matrix([[1,1],
[2,2]])
   Image=latex(M)
 
open('dessin.tex', 'w').write(Image);
  \end{sagesilent}
  \input{dessin.tex}
  }

But, there is a problem: \newcommand doesn't like the environment
"sagesilent". It accepts "center" blocks and others, but as soon as a
"sagesilent" is in there... There's a problem:

Runaway argument?
! File ended while scanning use of \next.

Where could the problem come from? My idea is that the "sagesilent"
misses something. What, I personally don't know... :-S

If you have any ideas, it would be great!

Thanks,
J-P Labbé

-- 
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: Precision in (Real) Vector Space / Working with reflection groups

2011-01-26 Thread jplab


On 26 jan, 12:47, "D. S. McNeil"  wrote:
> > (-6.66133814775094e-16, -1.00)
> > <---???
>
> > Why isn't the first coordinate 0??? In theory it should be...
>
> Such things are basically inevitable with floating point whenever any
> number involved can't be perfectly represented-- and in this case
> sqrt(2) is irrational to boot.  Sometimes you luck out and sometimes
> you don't.  help(RR) gives a brief warning.  Here I think you can
> avoid the problem by working not in RR (2^(-53) ~ 1e-16) but the
> symbolic ring SR.

I wasn't sure if it was the representation problem...

>
> sage: V=VectorSpace(RR,2,inner_product_matrix=[[1, -sqrt(2)/2], [-
> sqrt(2)/2, 1]])
> sage: V.basis()
> [
> (1.00, 0.000),
> (0.000, 1.00)
> ]
> sage: V=VectorSpace(SR,2,inner_product_matrix=[[1, -sqrt(2)/2], [-
> sqrt(2)/2, 1]])
> sage: a,b = V.basis()
> sage: a,b
> ((1, 0), (0, 1))
> sage: r1=Sigma(a,b);r1
> (sqrt(2), 1)
> sage: r2=Sigma(r1,a);r2
> (-1, -sqrt(2))
> sage: r3=Sigma(r2,r1);r3
> (0, -1)
>

This change does the thing!!! It is perfect for me!!


> If you really want to work in floating point you're going to have to
> loosen your definition of equality -- see, 
> e.g.,http://floating-point-gui.de/errors/comparison/-- possibly doing so
> rigorously with interval arithmetic.
>
> Doug
>
> --
> Department of Earth Sciences
> University of Hong Kong

Thanks a lot!
J-P

-- 
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] Precision in (Real) Vector Space / Working with reflection groups

2011-01-26 Thread jplab
Hi!

I am interested in computing orbits of vectors in a vector space using
reflections.

More specifically, the vector space is equipped with a inner product
given by a certain Coxeter group (B_4 for those interested...).

Then, I compute some image using my defined reflections operation. At
some point, I should stumble upon a vector that I've already seen or
it's negative, but there is a very small difference between the image
and my original vectors.

Here is the simplified code:


First, the definition of a reflection along a reflection_vector of a
vector_reflected:
--
sage: def Sigma(reflection_vector,vector_reflected):
...   return
vector_reflected-2*reflection_vector.inner_product(vector_reflected)*reflection_vector
--

Then I define my vector space:
--
sage: V=VectorSpace(RR,2,inner_product_matrix=[[1, -sqrt(2)/2], [-
sqrt(2)/2, 1]])
--

And here is the computations:

sage: a,b = V.basis()
sage: r1=Sigma(a,b);r1
(1.41421356237310, 1.00)
sage: r2=Sigma(r1,a);r2
(-1.00, -1.41421356237310)
sage: r3=Sigma(r2,r1);r3
(-6.66133814775094e-16, -1.00)
<---???

Why isn't the first coordinate 0??? In theory it should be... I tried
to find where the approximation error comes from, but I wasn't
successful!

Does someone have an idea??

Thanks!
J-P Labbé

-- 
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] Cosets representatives/Semi-direct product

2010-12-17 Thread jplab
Hi everyone,

My question as two parts:

First, I'm working with a group action on a set of objects and I would
like to generate the orbit of an object.

To simplify, we can think of the group acting on the set as a
permutation group.

Let G be the permutation group and H a subgroup of G.

Basically, I would like to have a set of coset representatives of G/H.
As I've seen, I can get the quotient group if my subgroup is normal
(cf. quotient(N) in 
http://www.sagemath.org/doc/reference/sage/groups/perm_gps/permgroup.html)

But what I want is a set of coset representatives! I guess gap can do
this, but would that be awesome to have something like:

sage: G=SymmetricGroup(5)
sage: H=G.subgroup([1,2,3])
sage: G.coset_representatives(H)
The set coset representatives of H in G

Is there already a simple way to have this???

---

Second, in fact, the group I'm working with is a semi-direct product
of two different direct products of symmetric groups.

So, I would like to know if there is a simple way to define such a
group in sage. I've seen it's possible in gap working around... What's
the simplest way??

-- 
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: Runtime error: Unable to start gap (as user "nobody" with xgrid)

2010-02-11 Thread jplab
Hi,

We switched to sage4.3.1 on all the machines, and it gives the same
problem.

I think it is related to this ticket:

http://trac.sagemath.org/sage_trac/ticket/5965

Because, if we login with a local account on the machine, the command:

sage: gap(2)
2

Works fine,

But if we login with a network account, it does exactly as the ticket
shows.

We will continue to investigate...

JP Labbé

-- 
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: Runtime error: Unable to start gap (as user "nobody" with xgrid)

2010-02-01 Thread jplab
Greetings,

On 1 fév, 14:44, Minh Nguyen  wrote:


> I think that is expected. The bug at
>
> http://trac.sagemath.org/sage_trac/ticket/7095
>
> only affects Mac OS X 10.6. You should have no trouble using Sage 4.3
> on Mac OS X 10.5.

Oh, I see! Great!

Thanks again!

JP Labbé

-- 
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: Runtime error: Unable to start gap (as user "nobody" with xgrid)

2010-02-01 Thread jplab
Hi,

On 1 fév, 14:01, Minh Nguyen  wrote:
> Hi,
>
> On Tue, Feb 2, 2010 at 5:29 AM, jplab  wrote:
>
> 
>
> > My computation are considerably slowed down by this bug and I would be
> > very happy to find a solution! Help! If you need more info, let me
> > know!
>
> My best guess is that mixing Sage 4.3 and 4.3.1 with Mac OS X 10.5 and
> 10.6 can be problematic. As you know, Sage versions prior to 4.3.1
> were unstable on Mac OS X 10.6 due to how Python was compiled on that
> platform. As of Sage 4.3.1, Python is now configured to properly
> compile on Mac OS X 10.6, which got rid of the annoying bug tracked at
> ticket #7095 [1]. One solution would be to use Sage 4.3.1 for all your
> Mac OS X 10.6 machines, or indeed for all your Mac OS X machines. Hope
> that helps.

Good, we will try that by changing the image on all the Mac...

But what is annoying is that on the intel server with 10.5 and sage
4.3, it does work!

But I hope 10.6 & sage4.3.1 will solve the problem!

>
> [1]http://trac.sagemath.org/sage_trac/ticket/7095
>
> --
> Regards
> Minh Van Nguyen

Thanks!
I will keep you posted on that.

JP Labbé

-- 
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] Runtime error: Unable to start gap (as user "nobody" with xgrid)

2010-02-01 Thread jplab
Hi,

I'm currently using xgrid for my computations... Here is the setup:

We have multiple imac OS 10.6, a intel server with mac OS 10.5 and two
G5 mac (10.5). All of them have sage4.3 (or 4.3.1) binary build.

In order for us to make xgrid work with sage, we gave some more rights
for user "nobody". (We copied /usr/share/sandbox/
xgridagentd_task_somebody.sb over xgridagentd_task_nobody.sb. So now
xgrid can execute sage anywhere on the disk)

We created a batch job ( a .plist file) to send to xgrid. The tasks
are .sh files containing the lines:

--
#!/bin/bash

export HOME=`pwd`

/usr/local/bin/sage Script.sage
--

and Script.sage contains the line:
--
load My_module.py

Fonction(int1,int2,int3)
--

The Script.py generated file (located on the agent's disk) is then:
--
# This file was *autogenerated* from the file Script.sage.
from sage.all_cmdline import *   # import sage library
_sage_const_int1 = Integer(int1); _sage_const_int2 = Integer(int2);
_sage_const_int3 = Integer(int3)
execfile("My_module.py")

Fonction(_sage_const_int1 ,_sage_const_int2 ,_sage_const_int3 )
--

Now, we send the batch job to xgrid. The intel server does everything
OK, so as the G5. But all the imac give the following error:

WARNING: There is one major unsolved bug in some versions of
Sage on OS X 10.6 that causes an 'Abort trap' crash when
doing certain symbolic computations.
See http://trac.sagemath.org/sage_trac/ticket/7095/.
Setting permissions of DOT_SAGE directory so only you can read and
write it.
Traceback (most recent call last):
  File "Script.py", line 2, in 
from sage.all_cmdline import *   # import sage library
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
all_cmdline.py", line 14, in 
from sage.all import *
  File "/Library/sage/local/lib/python2.6/site-packages/sage/all.py",
line 64, in 
from sage.misc.all   import * # takes a while
  File "/Library/sage/local/lib/python2.6/site-packages/sage/misc/
all.py", line 70, in 
from sage_input import sage_input
  File "/Library/sage/local/lib/python2.6/site-packages/sage/misc/
sage_input.py", line 163, in 
from sage.misc.functional import parent
  File "/Library/sage/local/lib/python2.6/site-packages/sage/misc/
functional.py", line 37, in 
from sage.rings.complex_double import CDF
  File "complex_double.pyx", line 88, in init
sage.rings.complex_double (sage/rings/complex_double.c:13660)
  File "/Library/sage/local/lib/python2.6/site-packages/sage/rings/
complex_field.py", line 86, in ComplexField
C = ComplexField_class(prec)
  File "/Library/sage/local/lib/python2.6/site-packages/sage/rings/
complex_field.py", line 177, in __init__
self._populate_coercion_lists_(coerce_list=[complex_number.RRtoCC
(self._real_field(), self)])
  File "complex_number.pyx", line 2003, in
sage.rings.complex_number.RRtoCC.__init__ (sage/rings/complex_number.c:
12936)
  File "map.pyx", line 41, in sage.categories.map.Map.__init__ (sage/
categories/map.c:1962)
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
categories/homset.py", line 152, in Hom
H = category.hom_category().parent_class(X, Y, category =
category)
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
categories/rings.py", line 117, in __new__
from sage.rings.homset import RingHomset
  File "/Library/sage/local/lib/python2.6/site-packages/sage/rings/
homset.py", line 17, in 
import quotient_ring
  File "/Library/sage/local/lib/python2.6/site-packages/sage/rings/
quotient_ring.py", line 32, in 
import sage.rings.polynomial.multi_polynomial_ideal
  File "/Library/sage/local/lib/python2.6/site-packages/sage/rings/
polynomial/multi_polynomial_ideal.py", line 229, in 
from sage.interfaces.all import (singular as singular_default,
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
interfaces/all.py", line 8, in 
from gap import gap, gap_reset_workspace, gap_console,
gap_version, is_GapElement, Gap
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
interfaces/gap.py", line 987, in 
gap_reset_workspace(verbose=False)
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
interfaces/gap.py", line 978, in gap_reset_workspace
g.eval('SaveWorkspace("%s");'%WORKSPACE)
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
interfaces/gap.py", line 480, in eval
result = Expect.eval(self, input_line, **kwds)
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
interfaces/expect.py", line 983, in eval
return '\n'.join([self._eval_line(L, **kwds) for L in code.split
('\n') if L != ''])
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
interfaces/gap.py", line 685, in _eval_line
self._start()
  File "/Library/sage/local/lib/python2.6/site-packages/sage/
interfaces/gap.py", line 362, in _start
raise Runt