Re: [sage-support] Re: Custom Symbolic Expressions / n-th root of unity

2015-12-09 Thread Johannes

On 08.12.2015 23:18, Nils Bruin wrote:
[..]

yea, you are right. i was not precise enough. So this should be the 
better formulated properties:


* (xi_n in QQbar) == true
* xi.parent() == QQbar
* (exp(2 * pi * I / n) == xi_n)


sage: cyclotomic_polynomial(5).roots(QQbar)
[(-0.8090169943749474? - 0.5877852522924731?*I, 1),
  (-0.8090169943749474? + 0.5877852522924731?*I, 1),
  (0.3090169943749474? - 0.9510565162951536?*I, 1),
  (0.3090169943749474? + 0.9510565162951536?*I, 1)]


that's exactly what i want to avoid.


It might make sense to write a routine that selects that element in
QQbar, and that could even be a method on QQbar. Whether it's worth it
printing such an element in a distinct fashion remains to be seen (and
if you don't care about the printing there is no need for a special
class representing such an element).



I need it to print it, even as further, it would be great if i can group 
all appearances as additional factor, separated from the  others.


Some more Information about the general setting:
I play around with actions of finite groups on a polynomial ring acting 
by multiplication with a power of the n-th root of unity.


bg,
Johannes



--
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
<mailto:sage-support+unsubscr...@googlegroups.com>.
To post to this group, send email to sage-support@googlegroups.com
<mailto: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.


--
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] Custom Symbolic Expressions / n-th root of unity

2015-12-08 Thread Johannes

Hey Guys,

I want to add a symbolic expression to CC representing an primitive n-th 
root of unity analogous to 'I'.


Lets call this Element xi_n, besides the usual rules xi_n should satisfy 
the following properties:


* (xi_n in CC) == true
* xi.parent() == CC
* (exp(2 * pi * I / n) == xi_n)
* latex(xi_n) == "\xi_n"

Maybe the first two conditions are equivalent. I played around with 
sage.symbolic.expression.Expression and 
sage.structure.element.CommutativeRingElement but did not get any idea 
how to start.
I was also looking for a piece of code defining I, but i did not have 
any success.


Is there already an implementation I can use (extend)? Or what is the 
best way implement this?


My main idea is to inherit from a suitable base class and override the 
_pow_ function.


But this results in this error:

sage: xi = NthRootOfUnity(3,parent=CC)
sage: xi**2

TypeError: unsupported operand parent(s) for '*': 'Complex Field with 53 
bits of precision' and 'Complex Field with 53 bits of precision'



best regards,
Johannes

--
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] Wrong indefinte integral

2015-07-17 Thread Johannes Lippmann
Hello,


*Problem:*
Sage 6.7 returns for

integrate(x/(x^2+1),(x,0,infinity))

the result 0. This is obviously wrong, since x/(x^2+1) is positive betwwen 
0 and Infinity.

*What I found out by now:*

I couldn't reproduce the error with any simpler function.


The antiderivate of the function is calculated correctly with

integrate(x/(x^2+1),x)

as 1/2*log(x^2 + 1). Manualy entering the values 0 and Infinity there gives 
the correct result.





What should I do now?

-- 
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] Bug in symbolic integral

2014-11-12 Thread Johannes Lippmann
Hi there,

I want to compute the integral from 2 to 3 of the funktion f(x)=1/log(x)^2. 
Sage gives conflicting results for different ways to compute it:

*numerical way*
(double checked by Wolfram Alpha 
http://www.wolframalpha.com/input/?i=int%20from%202%20to%203%20of%201%2Flog%28x%29^2
 
and Maple):

sage: numerical_integral(1/log(x)^2,2,3)

(*1.273097216447114*, 1.4134218422857824e-14)

*symbolic way*
(I think this is wrong)

sage: N(integral(1/log(x)^2,(x,2,3)))
*0.536566859259958*



The funktion is not that evil in the interval [2,3], so I don't think it is 
just a numerical issue.

This is the minimal example. I am using sage 6.1 and 6.3 (tried both) on 
Ubuntu.

-- 
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] Solving linear equation systems in GF(2)

2013-10-15 Thread Johannes Bauer
Hi list,

I'm trying to use sage to solve linear equation systems in GF(2). For 
example, say I have a matrix A describing the LES:

A := 
[ 1, 1, 1, 0 ]
[ 0, 1, 1, 0 ]
[1, 0, 0, 1]
[0, 1, 0, 1]

and a RHS:

b := 
[0, 1, 1, 0]^T

and would like to get the solution in GF(2):

s = [1, 0, 1, 0]^T

How can I do this in sage?

Thanks in advance,
Johannes

-- 
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/groups/opt_out.


Re: [sage-support] Re: Submodules of QQ['x,y,z'] as module over itself

2013-05-24 Thread Johannes

On 24.05.2013 16:41, Simon King wrote:

Hi Johannes,

On 2013-05-22, Johannes dajo.m...@web.de wrote:

is it implemented to create submodules of QQ['x,y,z'] as module over
itself?
I know it works for QQ['x'] or ZZ.






Perhaps you could show us what you do to make things work for QQ['x']
or ZZ, because I do *not* think that it works in this case. Then one
can try to think what features are missing to make it work in the
multivariate case as well.


Ok, I see the problem, I just checked to documentation and the examples 
of the submodule being the whole module.


The following works:

sage: R.x = QQ[]
sage: FreeModule(R,1)
Ambient free module of rank 1 over the principal ideal domain Univariate 
Polynomial Ring in x over Rational Field


sage: FreeModule(ZZ,1)
Ambient free module of rank 1 over the principal ideal domain Integer Ring

but you are right, even in this case considering submodules fails:
I = [x] * R
sage: FreeModule(I * R ,1)
AttributeError: 'Ideal_1poly_field' object has no attribute 'is_field'

otherwise:
sage: g = M.gens()[0]
sage: M.submodule( [x  * g] )
Free module of degree 1 and rank 1 over Univariate Polynomial Ring in x 
over Rational Field

Echelon basis matrix:
[x]




I do agree that such a feature should be available (it would become
available, or at least easier to make it available, by letting ideals
inherit from sage.structure.parent.Parent).

Best regards,
Simon




bg,
Johannes

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-support] Submodules of QQ['x,y,z'] as module over itself

2013-05-22 Thread Johannes

Hi,
is it implemented to create submodules of QQ['x,y,z'] as module over 
itself? I know it works for QQ['x'] or ZZ.But I don't know how to do 
this in the case of QQ['x,y,z'].
If it's not possible, where and what are the problems? Or is there a 
patch available, which provides this?


bg,
Johannes

P.S.: I'm using sage 5.9 on Debian Wheezy.

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Re: Group action

2013-04-22 Thread Johannes
yea, that's nearly what I am looking for. Is it possible to consider a
weighted group action too?
e.g. If \xi is of order n and \xi a n-th root of unity.
g (p_1,\dots, p_n) \to (\xi^a_1 p1 , dots, \xi^a_n p_n)?
s.t. \sum a_i = n?
bg,
Johannes

On 19.04.2013 17:53, Simon King wrote:
 Hi Johannes,
 
 On 2013-04-18, Johannes dajo.m...@web.de wrote:
 Hi guys,

 I have the following setting: Given a finite subgroup G of GL_\C(n) of
 order k, acting on C[x_1,...,x_n] by multiplication with (potenz of a )
 k-th root of unity. What is the best way, to translate this setting to sage?
 In the end I'm interested into the ring of invariants under G and it's
 representation as quotient.
 
 Towards an answer:
 
 Since you want to compute an invariant ring, and since CC is not exactly
 a field (rounding errors), it might make sense to work over a number
 field that contains a k-th root of unity. For example:
 
 # Create the number field
 sage: F.zeta = NumberField(x^6 + x^5 + x^4 + x^3 + x^2 + x + 1)
 sage: zeta^7 == 1
 True
 # Create a 3x3 matrix that acts by multiplication with zeta
 sage: MS = MatrixSpace(F, 3)
 sage: g = MS(zeta)
 # Create the corresponding matrix group. It has the correct order
 # Note that the method multiplicative_order or the matrix fails!
 sage: G = MatrixGroup([g])
 sage: G.order()
 7
 # Compute a minimal generating set of the invariant ring, as a sub-ring
 sage: G.invariant_generators()
 [x3^7,
  x2*x3^6,
  x1*x3^6,
  x2^2*x3^5,
  x1*x2*x3^5,
  x1^2*x3^5,
  x2^3*x3^4,
  x1*x2^2*x3^4,
  x1^2*x2*x3^4,
  x1^3*x3^4,
  x2^4*x3^3,
  x1*x2^3*x3^3,
  x1^2*x2^2*x3^3,
  x1^3*x2*x3^3,
  x1^4*x3^3,
  x2^5*x3^2,
  x1*x2^4*x3^2,
  x1^2*x2^3*x3^2,
  x1^3*x2^2*x3^2,
  x1^4*x2*x3^2,
  x1^5*x3^2,
  x2^6*x3,
  x1*x2^5*x3,
  x1^2*x2^4*x3,
  x1^3*x2^3*x3,
  x1^4*x2^2*x3,
  x1^5*x2*x3,
  x1^6*x3,
  x2^7,
  x1*x2^6,
  x1^2*x2^5,
  x1^3*x2^4,
  x1^4*x2^3,
  x1^5*x2^2,
  x1^6*x2,
  x1^7]
 
 So, the invariant ring could be represented as a ring with not less than
 36 generators, modulo algebraic relations. Now, I am afraid I don't know
 an easy way to find algebraic relations of the above sub-algebra
 generators---I am afraid I can't answer how to represent it as a
 quotient ring.
 
 Best regards,
 Simon
 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Re: Group action

2013-04-20 Thread Johannes
thnx,
this looks nice. I'll have a deeper look at it in the next days.

bg,
Johannes

On 19.04.2013 17:53, Simon King wrote:
 Hi Johannes,
 
 On 2013-04-18, Johannes dajo.m...@web.de wrote:
 Hi guys,

 I have the following setting: Given a finite subgroup G of GL_\C(n) of
 order k, acting on C[x_1,...,x_n] by multiplication with (potenz of a )
 k-th root of unity. What is the best way, to translate this setting to sage?
 In the end I'm interested into the ring of invariants under G and it's
 representation as quotient.
 
 Towards an answer:
 
 Since you want to compute an invariant ring, and since CC is not exactly
 a field (rounding errors), it might make sense to work over a number
 field that contains a k-th root of unity. For example:
 
 # Create the number field
 sage: F.zeta = NumberField(x^6 + x^5 + x^4 + x^3 + x^2 + x + 1)
 sage: zeta^7 == 1
 True
 # Create a 3x3 matrix that acts by multiplication with zeta
 sage: MS = MatrixSpace(F, 3)
 sage: g = MS(zeta)
 # Create the corresponding matrix group. It has the correct order
 # Note that the method multiplicative_order or the matrix fails!
 sage: G = MatrixGroup([g])
 sage: G.order()
 7
 # Compute a minimal generating set of the invariant ring, as a sub-ring
 sage: G.invariant_generators()
 [x3^7,
  x2*x3^6,
  x1*x3^6,
  x2^2*x3^5,
  x1*x2*x3^5,
  x1^2*x3^5,
  x2^3*x3^4,
  x1*x2^2*x3^4,
  x1^2*x2*x3^4,
  x1^3*x3^4,
  x2^4*x3^3,
  x1*x2^3*x3^3,
  x1^2*x2^2*x3^3,
  x1^3*x2*x3^3,
  x1^4*x3^3,
  x2^5*x3^2,
  x1*x2^4*x3^2,
  x1^2*x2^3*x3^2,
  x1^3*x2^2*x3^2,
  x1^4*x2*x3^2,
  x1^5*x3^2,
  x2^6*x3,
  x1*x2^5*x3,
  x1^2*x2^4*x3,
  x1^3*x2^3*x3,
  x1^4*x2^2*x3,
  x1^5*x2*x3,
  x1^6*x3,
  x2^7,
  x1*x2^6,
  x1^2*x2^5,
  x1^3*x2^4,
  x1^4*x2^3,
  x1^5*x2^2,
  x1^6*x2,
  x1^7]
 
 So, the invariant ring could be represented as a ring with not less than
 36 generators, modulo algebraic relations. Now, I am afraid I don't know
 an easy way to find algebraic relations of the above sub-algebra
 generators---I am afraid I can't answer how to represent it as a
 quotient ring.
 
 Best regards,
 Simon
 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-support] Group action

2013-04-18 Thread Johannes
Hi guys,

I have the following setting: Given a finite subgroup G of GL_\C(n) of
order k, acting on C[x_1,...,x_n] by multiplication with (potenz of a )
k-th root of unity. What is the best way, to translate this setting to sage?
In the end I'm interested into the ring of invariants under G and it's
representation as quotient.

bg,
Johannes

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] uninstall a package

2013-02-27 Thread Johannes
 ls spkg/standard/
cephes-2.8.p1.spkg   libfplll-3.0.12.p3.spkg  README.txt
conway_polynomials-0.4.spkg  libgap-4.5.7.spkgsage-5.7.spkg
cvxopt-1.1.5.p0.spkg linbox-1.3.2.p0.spkg sagenb-0.10.4.spkg
cython-0.17.4.spkg   maxima-5.29.1.p1.spkgsage_root-5.7.spkg
deps mpir-2.6.0.p0.spkg   
sage_scripts-5.7.spkg
ecl-12.12.1.p1.spkg  newest_version   
scipy-0.11.0.p1.spkg
eclib-20120830.spkg  ntl-5.5.2.p0.spkg
singular-3-1-5.p3.spkg
extcode-5.7.spkg pari-2.5.3.p2.spkg   
termcap-1.3.1.p3.spkg
fflas_ffpack-1.6.0.p0.spkg   patch-2.5.9.p3.spkg  VERSION.txt
gap-4.5.7.p3.spkgpolybori-0.8.2.p0.spkg   zlib-1.2.6.p0.spkg
iconv-1.13.1.p4.spkg python-2.7.3.p5.spkg
ipython-0.13.1.spkg  r-2.15.2.p1.spkg


Am Mi 27 Feb 2013 21:44:33 CET schrieb Jeroen Demeyer:
 And what's the output of (from the SAGE_ROOT):
 $ ls -l spkg/standard




-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] uninstall a package

2013-02-27 Thread Johannes
ls spkg/standard/
cephes-2.8.p1.spkg   libfplll-3.0.12.p3.spkg  README.txt
conway_polynomials-0.4.spkg  libgap-4.5.7.spkgsage-5.7.spkg
cvxopt-1.1.5.p0.spkg linbox-1.3.2.p0.spkg sagenb-0.10.4.spkg
cython-0.17.4.spkg   maxima-5.29.1.p1.spkgsage_root-5.7.spkg
deps mpir-2.6.0.p0.spkg   
sage_scripts-5.7.spkg
ecl-12.12.1.p1.spkg  newest_version   
scipy-0.11.0.p1.spkg
eclib-20120830.spkg  ntl-5.5.2.p0.spkg
singular-3-1-5.p3.spkg
extcode-5.7.spkg pari-2.5.3.p2.spkg   
termcap-1.3.1.p3.spkg
fflas_ffpack-1.6.0.p0.spkg   patch-2.5.9.p3.spkg  VERSION.txt
gap-4.5.7.p3.spkgpolybori-0.8.2.p0.spkg   zlib-1.2.6.p0.spkg
iconv-1.13.1.p4.spkg python-2.7.3.p5.spkg
ipython-0.13.1.spkg  r-2.15.2.p1.spkg
j_schn14@neo:/usr/lib/sagemath$


Am Mi 27 Feb 2013 21:44:33 CET schrieb Jeroen Demeyer:
 And what's the output of (from the SAGE_ROOT):
 $ ls -l spkg/standard


-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] uninstall a package

2013-02-27 Thread Johannes
maybe this happened, because the installation failed.  Is there a way 
to force sage using your url below?

Am Mi 27 Feb 2013 22:32:39 CET schrieb Jeroen Demeyer:
 On 2013-02-27 22:29, Johannes wrote:
 ls spkg/standard/
 Somehow, many of the spkg files are missing. I don't know how that
 happened, but that directory should look like

 http://sage.math.washington.edu/home/release/sage-5.7/sage-5.7/spkg/standard/



-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-support] uninstall a package

2013-02-25 Thread Johannes
Hi list,
I cant build sage 5.7 by sage -upgrade, because it can't download
polytopes_db-20120220.
How can I delete this package from my local sage installation, or where
can i install a valid version?

bg,
Johannes

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Re: Intersections of polyhedrons with modules / Latticepolytopes and sublattices

2012-12-29 Thread Johannes
Hi,
yea, that is how I work now.

N = ToricLattice(3)
Ns = SomeSubLatticeOfN
points = [p for p in P.intersection(plane).integral_points() if p in Ns]

but that seems not to be the nicest way to do it.

greatz

Am Sa 29 Dez 2012 18:20:57 CET schrieb Volker Braun:
 A plane is a polyhedron, too:

 sage: P = polytopes.n_cube(3)
 sage: plane = Polyhedron(eqns=[(0,1,1,1)])
 sage: plane.Hrepresentation()
 (An equation (1, 1, 1) x + 0 == 0,)
 sage: P.intersection(plane).integral_points()
 ((-1, 0, 1), (-1, 1, 0), (0, -1, 1), (0, 0, 0), (0, 1, -1), (1, -1,
 0), (1, 0, -1))



 On Saturday, December 29, 2012 3:03:32 PM UTC, Johhannes wrote:

 Hi List,
 I need to know all lattice points in a given polytope with respect
 to a
 sublattice (or considered as submodule) of ZZ^n.
 Is there a build-in way to do this? the default 'intersection' if
 polyhedrons does not work for modules/lattices, and the
 LatticePolytope
 does not have a intersection method at all.

 greatz Johannes

 --
 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.




-- 
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.




[sage-support] Intersection a cone with hyperplanes

2012-11-25 Thread Johannes
Hi List,
Is there a build-in-way to get the intersection of a given cone C with
an given hyperplane h?

In detail I have the following situation:

C = Cone( [List of primitive generators] )
H_h = Hyperplane {x : \sum x_i = h}.

C intersected with H_h will be a bounded polytope.

If there's not such an function, where would be the best place to place
it? Extend/overwrite the existing intersection function of the cone?

regards,
Johannes

-- 
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.




Re: [sage-support] Re: Intersection a cone with hyperplanes

2012-11-25 Thread Johannes
Thank you.

that's exactly what I was looking for.

bg,
Johannes

On 25.11.2012 14:56, Volker Braun wrote:
 Construct cone and hyperplane:
 
 sage: C = Cone([(1,0),(0,1)])
 sage: H = Polyhedron(eqns=[(-2,1,1)])
 sage: H.Hrepresentation()
 (An equation (1, 1) x - 2 == 0,)
 
 Compute the intersection polyhedron:
 
 sage: P = H.intersection( C.polyhedron() );  P
 A 1-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices
 sage: P.Vrepresentation()
 (A vertex at (2, 0), A vertex at (0, 2))
 
 
 On Sunday, November 25, 2012 1:42:24 PM UTC, Johhannes wrote:
 
 Hi List,
 Is there a build-in-way to get the intersection of a given cone C with
 an given hyperplane h?
 
 In detail I have the following situation:
 
 C = Cone( [List of primitive generators] )
 H_h = Hyperplane {x : \sum x_i = h}.
 
 C intersected with H_h will be a bounded polytope.
 
 If there's not such an function, where would be the best place to place
 it? Extend/overwrite the existing intersection function of the cone?
 
 regards,
 Johannes
 
 -- 
 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.
  
  

-- 
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.




Re: [sage-support] GPL and code generation using sage

2012-09-27 Thread Johannes
Hi,
as far as I understand the GPL, I would say you can release the output
of your script under every license you want to, as long as Sage is not
necessary to _compile_ or _run_ the the c++ code.

Take a look from the other side: If you use a programming language
licensed under GPL (the languages, not the libraries) you're still free
to release every program written in this language, using the license you
like to.


greatz Johannes

On 27.09.2012 01:28, Geoffrey Irving wrote:
 Hello,
 
 I recently used sage to write a code generation script for exact
 geometric predicates:
 
 https://github.com/otherlab/simplicity
 
 Since it's a python script that imports sage, the simplicity script is
 GPL.  However, I want the C++ *output* of this script to be license
 unencumbered, so that I can incorporate into either BSD licensed
 software (https://github.com/otherlab/core) or commercial software.
 As discussed in
 
 http://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html#GPLOutput
 
 doing this safely appears to require a special exception in the
 license, since the simplicity script copies a bunch of tiny portions
 of itself into the output.  Examples include
 
 ...
 warning = '// Exact geometric predicates\n// Autogenerated by
 simplicity.py: DO NOT EDIT\n'
 ...
 body.append('  for (int i=starts[permutation];;i++) {')
 body.append('const bool f = terms[i]1;')
 body.append('switch (terms[i]1) {')
 
 
 Has anyone done anything similar before with sage?  It seems
 questionable to add the runtime exemption to my license when it isn't
 in sage's, so I thought I'd ask here first.
 
 Thanks,
 Geoffrey
 

-- 
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.




Re: [sage-support] GPL and code generation using sage

2012-09-27 Thread Johannes
Am Do 27 Sep 2012 20:58:25 CEST schrieb Geoffrey Irving:
 On Thu, Sep 27, 2012 at 11:50 AM, Johannes dajo.m...@web.de wrote:
 Hi,
 as far as I understand the GPL, I would say you can release the output
 of your script under every license you want to, as long as Sage is not
 necessary to _compile_ or _run_ the the c++ code.

 Since my script copies bits of itself into the output, those bits
 carry the GPL along unless you add a special exception to the LICENSE,
 similar to the exceptions added for bison, flex, etc.

are those bits necessary for the output to compile? If not, I don't see 
any problem, maybe - if they are not needed - why can those bit not be 
removed from the c++ code?

 Take a look from the other side: If you use a programming language
 licensed under GPL (the languages, not the libraries) you're still free
 to release every program written in this language, using the license you
 like to.

 To be pendantic, languages are never licensed until the GPL.
 Compilers are, and if the compilers copy bits of themselves into the
 compiled version, I think they need special exceptions.

yea, pendantic but true ;)
 Geoffrey



-- 
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.




Re: [sage-support] Re: Invariant Polynomes under group action

2011-08-16 Thread Johannes
Am 16.08.2011 03:06, schrieb Nils Bruin:
 On Aug 15, 2:54 pm, Johannes dajo.m...@web.de wrote:
 I'm sorry for unclear description of the problem.
 So once again, let R = C[x_1,\dots,x_n]$ be my basering.
 I'm looking for the group G, wich leaves a finite set S of polynomes
 invariant under its action. So the ideal I = S is invariant under the
 G-action too. And because every constant polynome is invariant under the
 action, I can look at the subring C[I] = C[S] \subset R instead of
 looking at I.
 
 These are not the same rings, though. If S={1} then I=R, so C[I]=R and
 C[S]=C.
In my case S only contains monomes like \prod x_{i}^{a_i}
 For your original question, do you mean: Let G subset GL(n,C) be a
 matrix group, consider the polynomial ring R=C[x1,...,xn] and let
 I=R^G be the G-invariant subring of R. What is the minimal subgroup H
 subset G such that
 R^H=R^G?
Yes, maybe this is the best way to say  it.
 I don't think that question would be well-posed in general, since
 there could be several non-conjugate subgroups H1,H2 of G with
 R^H1=R^H2=R^G, such that for no proper subgroup H3 of H1 or H2 we have
 R^H3=R^G. Perhaps your setting has some properties that guarantee a
 unique minimal one? Perhaps those extra properties help in determining
 it?
 
The only extra condition I see from my data (but I'm not sure if it
holds every time), is that the degree of all polynomes is not relatively
primely and the polynomes wich degree is the gcd of all degrees arise in S.

greatz Johannes

-- 
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


Re: [sage-support] Re: Invariant Polynomes under group action

2011-08-15 Thread Johannes
I'm sorry for unclear description of the problem.
So once again, let R = C[x_1,\dots,x_n]$ be my basering.
I'm looking for the group G, wich leaves a finite set S of polynomes
invariant under its action. So the ideal I = S is invariant under the
G-action too. And because every constant polynome is invariant under the
action, I can look at the subring C[I] = C[S] \subset R instead of
looking at I.
But of course you're right, there's a big difference between a ring and
an ideal.

greatz Johannes
Am 15.08.2011 21:10, schrieb Maarten Derickx:
 Dear Johannes,
 
 I have a lot of trouble understanding your question. Your I is sometimes an 
 ideal and sometimes a ring and for me there is a huge difference between 
 those concepts (i.e. my rings always have an identity, and for every ring I 
 only one ideal with identity).
 
 Thanks,
 Maarten
 

-- 
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] bug in groups.prod?

2011-08-14 Thread Johannes
/site-packages/sage/structure/sage_object.so
in sage.structure.sage_object.SageObject._gap_
(sage/structure/sage_object.c:3909)()

/opt/sage-4.6/local/lib/python2.6/site-packages/sage/structure/sage_object.so
in sage.structure.sage_object.SageObject._interface_
(sage/structure/sage_object.c:3554)()

/opt/sage-4.6/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
in __call__(self, x, name)
   1097
   1098 if isinstance(x, basestring):
- 1099 return cls(self, x, name=name)
   1100 try:
   1101 return self._coerce_from_special_method(x)

/opt/sage-4.6/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
in __init__(self, parent, value, is_name, name)
   1524 except (TypeError, KeyboardInterrupt, RuntimeError,
ValueError), x:
   1525 self._session_number = -1
- 1526 raise TypeError, x
   1527 self._session_number = parent._session_number
   1528

TypeError: Gap produced error output
Variable: 'Complex' must have a value

Syntax error: ; expected
$sage8:=Complex Field with 53 bits of precision;;
^
Variable: 'with' must have a value

Variable: 'bits' must have a value

Variable: 'precision' must have a value


   executing $sage8:=Complex Field with 53 bits of precision;;

greatz Johannes

-- 
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


Re: [sage-support] bug in groups.prod?

2011-08-14 Thread Johannes
I got my error, i mixed prod and cartesian_product.


Am 14.08.2011 16:50, schrieb Johannes:
 Hi list,
 i tried to compute the product of two matrix groups and run in a gap
 parsing error.
 Miniexample:
 g1 = MatrixGroup([Matrix(CC,[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0],
 [0, 0, 0, 1]])])
 g2 = MatrixGroup([Matrix(CC,[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],
 [0, 0, 0, I]])])
 g1.prod(g2)
 
 this leads to the following output:
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (146, 0))
 
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (396, 0))
 
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (29, 0))
 
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (5, 0))
 
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (29, 0))
 
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (5, 0))
 
 ---
 TypeError Traceback (most recent call last)
 
 /home/j_schn14/studium/diplarbeit/tex/ipython console in module()
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/categories/monoids.pyc
 in prod(self, args)
 145 'ab'
 146 
 -- 147 return prod(args, self.one())
 148
 149 def _test_prod(self, **options):
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/misc/cachefunc.pyc
 in __call__(self, *args, **kwds)
 553 return self.cache[k]
 554 except KeyError:
 -- 555 w =
 self._cachedmethod._instance_call(self._instance, *args, **kwds)
 556 self.cache[k] = w
 557 return w
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/misc/cachefunc.pyc
 in _instance_call(self, inst, *args, **kwds)
 776
 777 
 -- 778 return self._cachedfunc.f(inst, *args, **kwds)
 779
 780 def _get_instance_cache(self, inst):
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/categories/monoids.pyc
 in one(self)
  81 ''
  82 
 --- 83 return self(1)
  84
  85 def one_element(self):
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/groups/matrix_gps/matrix_group.pyc
 in __call__(self, x)
 249 M = self.matrix_space()(x)
 250 g = self.element_class(M, self)
 -- 251 if not gap(g) in gap(self):
 252 raise TypeError, no way to coerce element to self.
 253 return g
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
 in __call__(self, x, name)
1099 return cls(self, x, name=name)
1100 try:
 - 1101 return self._coerce_from_special_method(x)
1102 except TypeError:
1103 raise
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
 in _coerce_from_special_method(self, x)
1123 s = '_gp_'
1124 try:
 - 1125 return (x.__getattribute__(s))(self)
1126 except AttributeError:
1127 return self(x._interface_init_())
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/structure/sage_object.so
 in sage.structure.sage_object.SageObject._gap_
 (sage/structure/sage_object.c:3909)()
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/structure/sage_object.so
 in sage.structure.sage_object.SageObject._interface_
 (sage/structure/sage_object.c:3428)()
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/groups/matrix_gps/matrix_group_element.py
 in _gap_init_(self)
 166 true
 167 
 -- 168 return self.__mat._gap_init_()
 169
 170 def _gap_latex_(self):
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/matrix/matrix1.so
 in sage.matrix.matrix1.Matrix._gap_init_ (sage/matrix/matrix1.c:2277)()
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
 in __call__(self, x, name)
1099 return cls(self, x, name=name)
1100 try:
 - 1101 return self._coerce_from_special_method(x)
1102 except TypeError:
1103 raise
 
 /opt/sage-4.6/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
 in _coerce_from_special_method(self, x)
1123

[sage-support] Invariant Polynomes under group action

2011-08-14 Thread Johannes
Hi list
I have given an Ideal I in the polynomial ring R and I need to know the
minimal group G wich acts on I such that I is the Invariant Ring of R
under the action of G.
for example:
let R =  CC.x1,x2,x3,
I the ideal generated by
x1^3, x2^3, x3^3

let G \subset SL_3(CC) act by a e_i - a x_i. If xi is a third primitive
root of unity, then G must be generated by
diagonalmatrix(xi,xi,xi).

Is there a easy way to calculate G from I with Sage?

greatz Johannes

-- 
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


Re: [sage-support] Re: Invariant Polynomes under group action

2011-08-14 Thread Johannes
No, would be nice if there is one, which I just dont know of. There are
algorithmic solution for my problem the other way round (given the group
G, calculate the invariant ring I). But in my eyes the problem looks not
that hard. Most times you see the solution very fast without calcualting
anything.
my main problem lays in the number of generators of I. There are up to
39 in one special case and 902 in total.

greatz
Am 14.08.2011 20:00, schrieb Simon King:
 Hi Johannes,
 
 On 14 Aug., 19:54, Johannes dajo.m...@web.de wrote:
 Hi list
 I have given an Ideal I in the polynomial ring R and I need to know the
 minimal group G wich acts on I such that I is the Invariant Ring of R
 under the action of G.
 
 Just out of curiosity: Do you have  a reference for an algorithmic
 solution of that problem?
 
 Cheers,
 Simon
 

-- 
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] bug in solve_mod?

2011-08-02 Thread Johannes
Hi list,
i just tried to solve a very simple congruences with solve_mod:

x = var('x')
eq = x + 1 == 0
res = solve_mod(eq,1)
res == [()]
true

but in my eyes every x \in ZZ should be a valid solution. I'm just
interested in the minimal one.
On the otherside, in my case I cannot guaranty that the modulus is always 1.

Any ideas or solutions?

greatz Johannes

-- 
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] question about creating homomorphisms

2011-08-02 Thread Johannes
Hi list
i need to construct two morphisms
f:ZZ^n \to Z given by a diagonalmatrix
and g: ZZ - Z/dZ

because I have to find the kernel of the compositoin.
consturcting g was no problem by g = ZZ.hom(ZZ.quotient(ZZ.ideal(d)))
father, getting the kernel of f as matrix worked too.
but how to get the kernel of the compositoin?

greatz Johanens

-- 
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 to solve congruences?

2011-07-26 Thread Johannes
Hi list
I have to solve congruences like
a x \equiv b mod n
for given a,b,n.
how can i do this with sage?

greatz Johanens

-- 
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


Re: [sage-support] Re: How to calculate the affine coordinats of a point

2011-07-19 Thread Johannes
that sounds comprehensibly. explains some more errormessages i got a few
times (like 'bool has no attribute len' when using solve)

greatz

Am 18.07.2011 16:54, schrieb luisfe:

 For me it looks like:
 
 In solve, when writting a == b you assume that a and b are expressions
 involving several variables. If a and b are expressions, then a == b
 is also an expression.
 
 However, p and x*p1+y*p2 are NOT expressions, but vectors. And
 equality of vectors is not the same as equality of expressions
 
 sage: x == y
 x == y
 sage: type(_)
 type 'sage.symbolic.expression.Expression'
 sage: vector([x]) == vector([y])
 False
 sage: type(_)
 type 'bool'
 
 So, in fact, you are passing the following command:
 
 sage: [x * p1 + y * p2 == p]
 [False]
 
 sage: solve([False],x,y)
 
 Which has no solution.  It is subtle, but I would not consider it a
 bug. If you really want to use solve, you may try the following:
 
 sage: solve(x * p1 + y * p2 - p,x,y)
 [[x == (1/4), y == (3/4)]]
 
 In this case, the input is a vector, that is an iterable, so solve
 extracts its components and equals them to zero.
 
 Being said that, I recommend you to use the linear algebra
 interpretation that I suggested, since it will probably be much more
 efficient.
 

-- 
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


Re: [sage-support] How to calculate the affine coordinats of a point

2011-07-15 Thread Johannes
a very easy example would be this:

sage: p1 = vector([-3,1,1])
sage: p2 = vector([1,-3,1])
sage: p = vector([0,-2,1])

#now i'm looking for some x,y such that
#x * p1 + y * p1 == p

x,y = var('x,y')
sage: assume(x  0)
sage: assume(y  0)
sage: solve([x * p1 + y * p2 == p],x,y)
[]

#but: x = 1/4 and y = 3/4 is a solution of this equation.

in the end i need this kind of calculation for every latticepoint on the
border of a lattice-simplex. like the example above shows how it should
work for a line, it also should be extendable to n+1 points on each n
dimensional facet of the simplex, where the points p0,,pn are given
as the vertices of the facet.

greatz Johannes


Am 15.07.2011 03:27, schrieb William Stein:
 On Thu, Jul 14, 2011 at 7:39 PM, Johannes dajo.m...@web.de wrote:
 Hi list,
 i have given a finite set of points (lets call it V \subset ZZ^n) and
 have to express some other points p_0,\dots,p_k \in ZZ^n as affine (or
 convex) combination of elements from V.
 How can i do this?
 I tried it with span(ZZ,V) but that leads to ZZ^n and the p_i are
 written with respect to the default basis.
 otherwise i tried it with the  sage.geometry.triangulation module, but
 i'm not sure if i used it the right way.
 
 Can you provide an explicit example, for example some Sage code one
 can paste in that defines your points in a simple situation?
 This always makes answering questions easier...
 

 greatz Johannes

 --
 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

 
 
 

-- 
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 to calculate the affine coordinats of a point

2011-07-14 Thread Johannes
Hi list,
i have given a finite set of points (lets call it V \subset ZZ^n) and
have to express some other points p_0,\dots,p_k \in ZZ^n as affine (or
convex) combination of elements from V.
How can i do this?
I tried it with span(ZZ,V) but that leads to ZZ^n and the p_i are
written with respect to the default basis.
otherwise i tried it with the  sage.geometry.triangulation module, but
i'm not sure if i used it the right way.

greatz Johannes

-- 
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] Subring of the polynomial ring

2011-06-29 Thread Johannes
Hi list
how can i create a subring of the polynomial ring?
I need to construct the rings like this:
CC[x^3,y^3,z^3] or CC[x^3, y^3, z^3, xy^2, xz^2, yz^2, x^2y, x^2z, y^2z]
how can I do this in sage?
I tried this:
C.x^3,y^3,z^3 =  CC['x^3,y^3,z^3']

   File ipython console, line 1
SyntaxError: can't assign to operator (ipython console, line 1)

and this:
C.x,y,z =  CC['x^3,y^3,z^3']
---
ValueErrorTraceback (most recent call last)

/home/j_schn14/studium/diplarbeit/src/ipython console in module()

/opt/sage-4.6/local/lib/python2.6/site-packages/sage/rings/ring.so in
sage.rings.ring.Ring.__getitem__ (sage/rings/ring.c:2629)()

/opt/sage-4.6/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py
in PolynomialRing(base_ring, arg1, arg2, sparse, order, names, name,
implementation)
348 names = arg1.split(',')
349 n = len(names)
-- 350 R = _multi_variate(base_ring, names, n, sparse, order)
351 elif isinstance(arg1, (list, tuple)):
352 # PolynomialRing(base_ring, names (list or tuple),
order='degrevlex'):

/opt/sage-4.6/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py
in _multi_variate(base_ring, names, n, sparse, order)
439
440 def _multi_variate(base_ring, names, n, sparse, order):
-- 441 names = normalize_names(n, names)
442
443 import sage.rings.polynomial.multi_polynomial_ring as m

/opt/sage-4.6/local/lib/python2.6/site-packages/sage/structure/parent_gens.so
in sage.structure.parent_gens.normalize_names
(sage/structure/parent_gens.c:2121)()

/opt/sage-4.6/local/lib/python2.6/site-packages/sage/structure/parent_gens.so
in sage.structure.parent_gens._certify_names
(sage/structure/parent_gens.c:1654)()

ValueError: variable names must be alphanumeric, but one is 'x^3' which
is not.

greatz Johannes.

p.s.: in the end, I'm interested in the group, which has the given ring
as invariant ring. maybe somebody has any idea how to get this 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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Hermite Normalform

2011-03-14 Thread Johannes
Hi list,
I'm not sure about the behavior of the hermite_form() function of an
integer matrix.
As far as I know the Hermeiteform H of a given matrix A, it is a unique
(up to reordering of the rows and columns) triangular matrix (with some
extra conditions) wich could be obtained by A * U = H for some U \in GL(\Z).
(compare e.g. wikipedia)
But the sagewiki says the following:
H, U = A.hermite_form(transformation=True, include_zero_rows=False)
U*A == H
True
which violates the given definition above, because the multiplication is
from the left here)
In my case it's important if H is optained by row operations or by
columnoperations.
How is this handled in sage, and is this somehow controlable?

greatz Johannes

-- 
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


Re: [sage-support] Re: Checking for convexity of Lattice Polytopes

2011-03-13 Thread Johannes
Am 24.02.2011 19:29, schrieb Dmitri:
 A chosen set of points is convex if it is equal to its convex hull. 

as far as I see this is equivalent to, all points are on a facet of the
polytope.

 I think my problem is actually doing the comparison. So I have this
 chosen set of points which I don't know is convex. I compute its
 convex hull. Now how do I compare these two objects?
 
 Dmitri
 

you can try someting like this:
len([i for i in range(foo.npoints()) if any([i in face.points() for face
in foo.facets()])]) == foo.npoints()

ths is not a nice way to do but it works. maybe it would be nice to put
this into a property of a latticepolytope.

some littel explanation to the piece of code:
we count all points of foo, which lay on some facet of foo. (those
points are just numbered and you can get the value of it by
foo.point(index) but this doesnt matter here because they are indexed in
by the same number in the facets too) and compare them to the total
number of points in foo (and on its boundary)
As long as my comment above is correct (and as long as I got the point
of your problem) this should work.

greatz Johannes

-- 
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


Re: [sage-support] Re: edges in graphs

2011-02-07 Thread Johannes
yea. it's connected. i tried the spanning trees too, but I had to look
ob how the trees differ, depending on how they are build.

I've just one small (opticial) problem remaining.
if I plot the tree all vertices are ordert on each level but beacause of
this many lines are crossing. I dont need to have them sorted, but it
would be nice to have as less as possible edges crossing.

greatz Johannes


Am 05.02.2011 16:02, schrieb Luiz Felipe Martins:
 Oh, I was imprecise. If it has no loops, it is a forest. So you have to get
 a spanning tree for each component.
 
 On Sat, Feb 5, 2011 at 10:01 AM, Luiz Felipe Martins 
 luizfelipe.mart...@gmail.com wrote:
 
 Sorry, I didn't get the beginning of the thread, but if you need the graph
 without loops, it is a tree. So, you can compute a maximal spanning tree of
 the graph, and see if you get the whole graph together. This will also tell
 you what edges to remove, if the graph is not a tree. Of course, the maximal
 spanning tree is not unique, so the set of edges to be removed will not be
 uniquely determined.

 Sorry if this was already mentioned, or if it is actually unrelated to what
 you need.


 On Sat, Feb 5, 2011 at 7:37 AM, Johannes dajo.m...@web.de wrote:

 thnx for your answers.

 I'm dealing with an undirectred graph. In the beginning I have a given
 number of vertices (53 in my case now) and a list or relations between
 them. All I do is adding a new edge (a - b) if a is in relatoin to be.
 My problem is, i dont know form the beginning if it's loopsless. but I
 need to have it without any loops.

 greatz Johannes



 Am 05.02.2011 07:53, schrieb Nathann Cohen:


 how can i add a new edge (a-b) to a given graph G (n.n. connected),
 just in the case that there is no path (a - ... - b) before?


 From your question, I can not infer whether you are dealing with
 directed or
 undirected graphs. So just in case :

 - If your graph is undirected and there are no paths between two
 vertices a
 and b, it means that a and b lie in different connected components.
 Given a
 graph g, you can obtain the list of connected components with
 g.connected_components(). It is a list of list (a partition of the
 vertices). Two vertices are joined by a path if and only if they are in
 the
 same connected component (in a Graph, being linked by a path is an
 equivalence relation). As soon as you add an edge between two connected
 components, you merge them :-)

 http://en.wikipedia.org/wiki/Connected_component_(graph_theory)

 - If your graph is directed, there is no equivalence relation anymore,
 because it is not even reflexive. You may have a path from a to b, but
 no
 path from b to a. We are then talking about strongly connected
 components
 (g.strongly_connected_components()), g.is_strongly_connected()). If you
 have
 two strongly conected components A and B in your graph, [ (adding one
 arc
 from any vertex of A to any vertex of B) AND (adding one arc from any
 vertex
 of B to any vertex of A) ] will ensure that for any pair of vertices in
 A U
 B there exist paths in both directions. Pretty often you just need to
 add
 ONE arc instead of two. You can get this information with the method
 strongly_components_digraph

 Strongly connected components :
 http://en.wikipedia.org/wiki/Strongly_connected_component

 In any case, you will often have a HUGE number of paths in your graphs,
 while checking whether there exists a path from a to b is almost
 instantaneous. You can do it manually with g.distance(a,b) = g.order()
 or
 len(g.shortest_path(u,v))  0. The methods connected_components() or
 strongly_connected_components() actually test all the pairs at the same
 time, which is faster than actually computing shortest paths or
 distances
 between all pair. These methods are the most efficient you will find in
 Sage
 : they are very simple and implemented in Cython, as they appear very,
 very
 often in graph algorithms.

 (if I missed your point, please also tell me whether you are dealing
 with
 graphs/digraphs) :-)

 Nathann

 g

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.comsage-support%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org



 

-- 
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


Re: [sage-support] Re: edges in graphs

2011-02-07 Thread Johannes
Yea, sure. but my problem is a tree like this:

   1
  / \
 23 45

and so on.

but i don't need it in that order I have a few crossing edes in it and
I'd like to have one like

   1
  / \
 35 24

or

  1
 / \
25 34

or someting like that, such that i have just a minimal number of crosssings.

even more, it would be nice, if every vertex is placed under his parent
and not from left to right:

  1
 / \
4   5
   / \   \
  6   7 _ 9

where '_' denotes a free space for a left child node of 5.

greatz
Am 07.02.2011 19:09, schrieb Nathann Cohen:
 Hello !!!
 
 Among the wealth of tricky options one can use in plot/show, you will find :
 
 g.plot(layout='tree')
 
 :-)
 
 Nathann
 

-- 
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


Re: [sage-support] Re: edges in graphs

2011-02-05 Thread Johannes
thnx for your answers.

I'm dealing with an undirectred graph. In the beginning I have a given
number of vertices (53 in my case now) and a list or relations between
them. All I do is adding a new edge (a - b) if a is in relatoin to be.
My problem is, i dont know form the beginning if it's loopsless. but I
need to have it without any loops.

greatz Johannes



Am 05.02.2011 07:53, schrieb Nathann Cohen:
 

 how can i add a new edge (a-b) to a given graph G (n.n. connected),
 just in the case that there is no path (a - ... - b) before?
 
 
From your question, I can not infer whether you are dealing with directed or 
 undirected graphs. So just in case :
 
 - If your graph is undirected and there are no paths between two vertices a 
 and b, it means that a and b lie in different connected components. Given a 
 graph g, you can obtain the list of connected components with 
 g.connected_components(). It is a list of list (a partition of the 
 vertices). Two vertices are joined by a path if and only if they are in the 
 same connected component (in a Graph, being linked by a path is an 
 equivalence relation). As soon as you add an edge between two connected 
 components, you merge them :-)
 
 http://en.wikipedia.org/wiki/Connected_component_(graph_theory)
 
 - If your graph is directed, there is no equivalence relation anymore, 
 because it is not even reflexive. You may have a path from a to b, but no 
 path from b to a. We are then talking about strongly connected components 
 (g.strongly_connected_components()), g.is_strongly_connected()). If you have 
 two strongly conected components A and B in your graph, [ (adding one arc 
 from any vertex of A to any vertex of B) AND (adding one arc from any vertex 
 of B to any vertex of A) ] will ensure that for any pair of vertices in A U 
 B there exist paths in both directions. Pretty often you just need to add 
 ONE arc instead of two. You can get this information with the method 
 strongly_components_digraph
 
 Strongly connected components : 
 http://en.wikipedia.org/wiki/Strongly_connected_component
 
 In any case, you will often have a HUGE number of paths in your graphs, 
 while checking whether there exists a path from a to b is almost 
 instantaneous. You can do it manually with g.distance(a,b) = g.order() or 
 len(g.shortest_path(u,v))  0. The methods connected_components() or 
 strongly_connected_components() actually test all the pairs at the same 
 time, which is faster than actually computing shortest paths or distances 
 between all pair. These methods are the most efficient you will find in Sage 
 : they are very simple and implemented in Cython, as they appear very, very 
 often in graph algorithms. 
 
 (if I missed your point, please also tell me whether you are dealing with 
 graphs/digraphs) :-)
 
 Nathann
 
g

-- 
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


Re: [sage-support] edges in graphs

2011-02-05 Thread Johannes
I just checked the shortes_path method and it wents many times faster. thnx.
Am 05.02.2011 08:08, schrieb Nathann Cohen:
 

 Of course finding the shortest path may be (almost) as expensive as
 finding all of them... If you're doing this for a lot of edges you
 might want to break it up into components, then the test would be
 easy. It would be cool if all_paths were an iterator and you could
 just ask for the first one.

 
 Nono, shortest paths are very quick to compute ! Longest paths are quite a 
 different thing though... :-)
 
 Nathann 
 

 

-- 
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] edges in graphs

2011-02-04 Thread Johannes
Hi list
how can i add a new edge (a-b) to a given graph G (n.n. connected),
just in the case that there is no path (a - ... - b) before?

all i found is the all_path(a,b) method wich tooks very long in my case
and generates a huge overhead.

greatz Johanens

-- 
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] Latticebasis of a sublattice

2011-01-23 Thread Johannes
Hi list
I am looking for a elegant and easy way to compute a basis for a
subspace of a given Lattice.
In paticular i have this situatoin:
Let V \subset ZZ^n be a lattice and U \subset V the sublattice spanned
by u,v \in U.
In my special situatoin I have dim V = n = 3, dim U = 2 but it would be
nice to have a solution for arbitrary dimensions of V and Codim of U = 1.
I need to calculate a basis for some U' \subset V such that U \subset U'
and all basiselements of U' are primitive.
This could be reformulated in the following way:
Given U, I'm looking for the finest lattice U' \subset V, which contains U.

Up to now I did this by calculating a basis of U, looking at the
vectorfield spanned by this basis and take its basis as basis for U'
(after converting the entries back to integers).

This works, but it seems not to be the best way to do it.

greatz Johannes

-- 
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] cant explain this behavior - simple aritmethics / extended euclidean algorithm

2010-12-28 Thread Johannes
Hi list,
I've a very confusing problem with some simple algorithm:

following setting: a matrix sing:
sage: sing
[ 3  0  1]
[-2 -1 -2]
[ 0  1  0]
sage: l = sings.column(2);l
(1, -2, 0)
#my algorithem, code see below:
sage: extgcd(l)
#some printoutput for debugging:
l: (1, -2, 0)
tlist:  (-2, 0)
#this should not be, d = gcd(tlist)
d: 1
l: [1, 1]
[u, v]: [0, 1]
l: (-2, 0)
[u, v]: [1, 0]
res: [0, 1, 0]
#the result:
[0, 1, 0]
#now the same but i construct the vector on my own:
sage: l = vector([1,-2,0]);l
(1, -2, 0)
sage: extgcd(l)
l: (1, -2, 0)
tlist:  (-2, 0)
#here it works fine
d: 2
l: [1, 2]
[u, v]: [1, 0]
l: (-2, 0)
[u, v]: [1, 0]
res: [1, 0, 0]
#getting the expected result:
[1, 0, 0]

the code of my algorithm:

def extgcd(l):
print l:  + str(l)
assert len(l)  1

if len(l) == 2:
#calculated ext euclidean for two values
a = l[0]
b = l[1]

u=t=1
v=s=0
while b0:
q=a//b
a, b = b, a-q*b
u, s = s, u-q*s
v, t = t, v-q*t
print [u, v]:  + str([u, v])
return [u, v]
else:

#this is the part where it does not work!
tlist = l[1:]
print tlist:   + str(tlist)
d =  gcd(tlist)
print d:  + str(gcd(tlist))

#calculate part decomp
u, v = extgcd([l[0],d])
#calculate rest
ttlist = extgcd(tlist)
res =  [u]
#combine results
res.extend([v * item for item in ttlist])
print res:  + str(res)
return res

I hope somebody can help me.
greatz Johannes

-- 
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


Re: [sage-support] cant explain this behavior - simple aritmethics / extended euclidean algorithm

2010-12-28 Thread Johannes
I got it solved. It's a type error:
the matrix sing is a matrix over QQ.
If its a matrix over ZZ it works fine.

but why is gcd(2,0) = 1 for 2,0 as Rationals?
in my eyes its not well defined or should be the maximum of those values.

greatz

Am 28.12.2010 22:08, schrieb Johannes:
 Hi list,
 I've a very confusing problem with some simple algorithm:
 
 following setting: a matrix sing:
 sage: sing
 [ 3  0  1]
 [-2 -1 -2]
 [ 0  1  0]
 sage: l = sings.column(2);l
 (1, -2, 0)
 #my algorithem, code see below:
 sage: extgcd(l)
 #some printoutput for debugging:
 l: (1, -2, 0)
 tlist:  (-2, 0)
 #this should not be, d = gcd(tlist)
 d: 1
 l: [1, 1]
 [u, v]: [0, 1]
 l: (-2, 0)
 [u, v]: [1, 0]
 res: [0, 1, 0]
 #the result:
 [0, 1, 0]
 #now the same but i construct the vector on my own:
 sage: l = vector([1,-2,0]);l
 (1, -2, 0)
 sage: extgcd(l)
 l: (1, -2, 0)
 tlist:  (-2, 0)
 #here it works fine
 d: 2
 l: [1, 2]
 [u, v]: [1, 0]
 l: (-2, 0)
 [u, v]: [1, 0]
 res: [1, 0, 0]
 #getting the expected result:
 [1, 0, 0]
 
 the code of my algorithm:
 
 def extgcd(l):
 print l:  + str(l)
 assert len(l)  1
 
 if len(l) == 2:
 #calculated ext euclidean for two values
 a = l[0]
 b = l[1]
 
 u=t=1
 v=s=0
 while b0:
 q=a//b
 a, b = b, a-q*b
 u, s = s, u-q*s
 v, t = t, v-q*t
 print [u, v]:  + str([u, v])
 return [u, v]
 else:
 
   #this is the part where it does not work!
 tlist = l[1:]
 print tlist:   + str(tlist)
 d =  gcd(tlist)
 print d:  + str(gcd(tlist))
 
 #calculate part decomp
 u, v = extgcd([l[0],d])
 #calculate rest
 ttlist = extgcd(tlist)
 res =  [u]
 #combine results
 res.extend([v * item for item in ttlist])
 print res:  + str(res)
 return res
 
 I hope somebody can help me.
 greatz Johannes
 

-- 
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


Re: [sage-support] cant explain this behavior - simple aritmethics / extended euclidean algorithm

2010-12-28 Thread Johannes
Ok, from this point of view see the point. But I dont know if it's
documented this way somewhere.

greatz
Am 28.12.2010 23:00, schrieb Iwao Kimura:
 Hi Johannes,
 
 I'm not sure but if we think gcd(2, 0) is the generator of the ideal
 generated by 2 and 0 in the rationals, we see gcd(2,0) is 1 because
 the ideal is not zero (and QQ is a field :)
 
 Best regards.
 
 On Wed, Dec 29, 2010 at 6:33 AM, Johannes dajo.m...@web.de wrote:
 I got it solved. It's a type error:
 the matrix sing is a matrix over QQ.
 If its a matrix over ZZ it works fine.

 but why is gcd(2,0) = 1 for 2,0 as Rationals?
 in my eyes its not well defined or should be the maximum of those values.

 greatz

 Am 28.12.2010 22:08, schrieb Johannes:
 Hi list,
 I've a very confusing problem with some simple algorithm:

 following setting: a matrix sing:
 sage: sing
 [ 3  0  1]
 [-2 -1 -2]
 [ 0  1  0]
 sage: l = sings.column(2);l
 (1, -2, 0)
 #my algorithem, code see below:
 sage: extgcd(l)
 #some printoutput for debugging:
 l: (1, -2, 0)
 tlist:  (-2, 0)
 #this should not be, d = gcd(tlist)
 d: 1
 l: [1, 1]
 [u, v]: [0, 1]
 l: (-2, 0)
 [u, v]: [1, 0]
 res: [0, 1, 0]
 #the result:
 [0, 1, 0]
 #now the same but i construct the vector on my own:
 sage: l = vector([1,-2,0]);l
 (1, -2, 0)
 sage: extgcd(l)
 l: (1, -2, 0)
 tlist:  (-2, 0)
 #here it works fine
 d: 2
 l: [1, 2]
 [u, v]: [1, 0]
 l: (-2, 0)
 [u, v]: [1, 0]
 res: [1, 0, 0]
 #getting the expected result:
 [1, 0, 0]

 the code of my algorithm:

 def extgcd(l):
 print l:  + str(l)
 assert len(l)  1

 if len(l) == 2:
 #calculated ext euclidean for two values
 a = l[0]
 b = l[1]

 u=t=1
 v=s=0
 while b0:
 q=a//b
 a, b = b, a-q*b
 u, s = s, u-q*s
 v, t = t, v-q*t
 print [u, v]:  + str([u, v])
 return [u, v]
 else:

   #this is the part where it does not work!
 tlist = l[1:]
 print tlist:   + str(tlist)
 d =  gcd(tlist)
 print d:  + str(gcd(tlist))

 #calculate part decomp
 u, v = extgcd([l[0],d])
 #calculate rest
 ttlist = extgcd(tlist)
 res =  [u]
 #combine results
 res.extend([v * item for item in ttlist])
 print res:  + str(res)
 return res

 I hope somebody can help me.
 greatz Johannes


 --
 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

 
 
 

-- 
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] Solving linear equatoins

2010-12-27 Thread Johannes
Hi list,

I'm looking for a simple way to solve some linear equations. I found the
solution mentioned in the manpage for solve, but thats not what I'm
looking for.

My setting is the following:
I have a Matrix M and from which I need the first row.
r = M.row(0).transpose()
and i need a vector of variables
v = vector([v1,,vn]) (of known dimenension in every case, but the
dimension is not the same all the time)

now I need to get the following equatoin solved:
v * r = 1

but the type of v * r == 1 is boolean, so it could not be handled by
using solve any more.
father more, I'd prefer to have just one vectorsolution instead of using
 v =  vecvtor([var(v + str(i)) for i in range(dimension)])

is there anyway to handle this in a nicer way?

greatz Johannes

-- 
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


Re: [sage-support] Labeled Graphs

2010-11-26 Thread Johannes
no, that's just a part of what I'm looking for. I need to have a graph
with weighted edges _and_ vertices. To stay at your example, the edges
are weighted by the distance between the different cities, and each
vertex is 'weighted' (or better labeled) by the population of the city.
Excactly the vertex should have to labels, the name and the population.

In the end I dont need to do any calculations with this graph. I want to
autocreate latexcode wichc I could use later and i dont want to write my
owen function to do this, or all the latexcode by hand.

greatz Johannes

-- 
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


Re: [sage-support] Re: Labeled Graphs

2010-11-26 Thread Johannes
Alexandre and Eckhard, thnx for your notes, but I have to create 54
graphs and i dont want to this by hand. So at least I need a way to
automate the construction with your tools. In my eyes this ends up in
writing my own function which calls the tools.
I hoped this is not neccessary and there would be some sage-libaries to
do this.

greatz Johannes


Am 24.11.2010 18:55, schrieb Nathann Cohen:
 Hello !!

   
 how do i create a graph where i have a label for each vertex and each
 edge? Precisely I need to labels for each vertex (like a name and a value).
 
 You can deal with labeled vertices using the set_vertex/get_vertex
 methods.

 Nathann

   

-- 
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


Re: [sage-support] Re: Labeled Graphs

2010-11-24 Thread Johannes
thnx, but that's not  excatly what I'm looking for, because te label
does not appear in the picture created by
graph.show()
Johannes
Am 24.11.2010 18:55, schrieb Nathann Cohen:
 Hello !!

   
 how do i create a graph where i have a label for each vertex and each
 edge? Precisely I need to labels for each vertex (like a name and a value).
 
 You can deal with labeled vertices using the set_vertex/get_vertex
 methods.

 Nathann

   

-- 
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


Re: [sage-support] Re: polynomial division by increasing powers

2010-11-17 Thread Johannes Huisman

Hi Simon!

On 11/17/2010 08:33 AM, Simon King wrote:

On 16 Nov., 23:48, Johannes Huismanjohannes.huis...@gmail.com
wrote:

Does sage have a command for polynomial division by increasing powers? I
could not find such a command. Of course, one may use power series
division in order to compute the quotient, but it would be neat if one
could avoid all that.


What exactly do you expect?


Well, it is maybe nonstandard terminolgy, but I meant the division of a 
polynomial a by a polynomial b that is of the form


a = q*b + x^(n+1)*r

where q and r are polynomials, with q of degree less than or equal to n. 
Such a division exists and is unique if b(0)!=0 and the coefficients 
constitute a field, for example. I was wondering whether there is a sage 
command that returns q and r as above, for given a, b and n. It can be 
useful in several situations.


As you observe, one can obtain q by computing a/b as a power series with 
the right precision, and then determine r. It is, however, somewhat 
annoying for pedagogical reasons, to have to use the notion of power 
series in order to compute something that is defined purely in terms of 
polynomials. But maybe, I'm exaggerating. Anyway, I certainly did not 
want to propose that Frac(QQ[x]) be a power series ring in sage!


Thanks a lot,

Johannes



For example:

sage: P.x  = QQ[]
sage: p = P.random_element()
sage: q = P.random_element()
sage: p
4/3*x^2 - x + 7
sage: q
2/7*x^2 - x

1.
Apparently you do not want that the quotient of p and q lives in the
fraction field, as it is currently the case:
sage: p/q
(4/3*x^2 - x + 7)/(2/7*x^2 - x)

2.
Do you need the quotient with remainder? Then you could do
sage: p.quo_rem(q)
(14/3, 11/3*x + 7)

3.
Or do you want that the quotient of p and q actually is a power
series? So, like this:
sage: p/q  # not implemented
-7*x^-1 - 1 - 34/21*x - 68/147*x^2 - 136/1029*x^3 - 272/7203*x^4 -
544/50421*x^5 - 1088/352947*x^6 - 2176/2470629*x^7 - 4352/17294403*x^8
- 8704/121060821*x^9 - 17408/847425747*x^10 - 34816/5931980229*x^11 -
69632/41523861603*x^12 - 139264/290667031221*x^13 -
278528/2034669218547*x^14 - 557056/14242684529829*x^15 -
1114112/99698791708803*x^16 - 2228224/697891541961621*x^17 -
4456448/4885240793731347*x^18 + O(x^19)

Possibility 3. requires that Frac(P) does not return a formal fraction
field (which is currently the case) but a power series ring. I am sure
that it would require much persuasion and a poll on sage-devel if one
wants such change.

Also note that the term order in P and Q differs (with the additional
complication that Q(p) does not have an attribute leading_coefficient,
but p does).
sage: p
4/3*x^2 - x + 7
sage: Q(p)
7 - x + 4/3*x^2


So, if what you want is 3., then currently you have to use the power
series ring manually, such as:
sage: Q = PowerSeriesRing(QQ,'x')
sage: Q(p)/q  # q is automatically coerced into Q
-7*x^-1 - 1 - 34/21*x - 68/147*x^2 - 136/1029*x^3 - 272/7203*x^4 -
544/50421*x^5 - 1088/352947*x^6 - 2176/2470629*x^7 - 4352/17294403*x^8
- 8704/121060821*x^9 - 17408/847425747*x^10 - 34816/5931980229*x^11 -
69632/41523861603*x^12 - 139264/290667031221*x^13 -
278528/2034669218547*x^14 - 557056/14242684529829*x^15 -
1114112/99698791708803*x^16 - 2228224/697891541961621*x^17 -
4456448/4885240793731347*x^18 + O(x^19)

Cheers,
Simon




--
http://pageperso.univ-brest.fr/~huisman

--
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] polynomial division by increasing powers

2010-11-16 Thread Johannes Huisman

Hello,

Does sage have a command for polynomial division by increasing powers? I 
could not find such a command. Of course, one may use power series 
division in order to compute the quotient, but it would be neat if one 
could avoid all that.


Thanks in advance,

Johannes
--
http://pageperso.univ-brest.fr/~huisman

--
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


Re: [sage-support] Re: list_plot libpng error: Image width or height is zero in IHDR

2010-10-21 Thread Johannes Huisman

On 10/21/2010 05:10 PM, Jason Grout wrote:

On 10/21/10 9:48 AM, Johannes Huisman wrote:

sage: a(n)=(3*n+8)/(5*n-2)
sage: list_plot([a(n) for n in range(100,120)],aspect_ratio=1)




This works after #2100 has been applied to 4.6.alpha3, which fixes a lot
of issues and confusion we've had about aspect ratios and figure sizes.
Ticket #2100 (http://trac.sagemath.org/sage_trac/ticket/2100) still
needs to be reviewed.

The picture still isn't the prettiest after #2100 has been applied (I
think that list_plot could be improved to make the picture better, and
the axes probably need a fix as well), but at least there is no error
thrown.

Jason


Thanks!
Johannes

--
http://pageperso.univ-brest.fr/~huisman

--
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


Re: [sage-support] finite cartesian product

2010-10-04 Thread Johannes
thnx, excatly what i was looking for.
Am 04.10.2010 00:32, schrieb Philipp Schneider:
  Hi,
   
 (...)
 In my next try I used FiniteEnumeratedSet and cartesian_product, but
 this is not iterable.
 Is there any other way to do this?
 
 there is a sage function called cartesian_product_iterator.

 Greetings,
 Phil

   

-- 
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] finite cartesian product

2010-10-03 Thread Johannes
hi list,
I'm looking for a short and nice way to iterate over a product of indices.
If I have the index sets A,B,C i could do it by:
res = []
for a in A:
for b in B:
for c in C:
res.append(doSomething(a,b,c))

Could this be done in a list comprehension too?
I tried
[doSomething(a,b,c) for a,b,c in A,B,C] but this leads to the same as
[doSomething(a,b,c) for a,b,c in zip(A,B,C)]
In my next try I used FiniteEnumeratedSet and cartesian_product, but
this is not iterable.
Is there any other way to do this?

greatz Johannes

-- 
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] creating a test environment

2010-09-29 Thread Johannes
Hi list,
is it possible to create in a given environment in sage a new one, which
know all in the parent defined variables and values, and i i leave it
again, ijust get back to my old values?
i'd like to have this, because i have to test and compare different
calculations based on the same data (polygons with variables in the
coordinates of the vertices).
I hope i could explain what i'm looking for, and for sure, i hope
something like this exists ;)

greatz Johanne

-- 
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


Re: [sage-support] Re: creating a test environment

2010-09-29 Thread Johannes
nearly, i work with save_session and load_session rigthn now, but i need
something like a fast switch between some environments like this:

do some stuff
create_snapshot(sshot1)
do some more stuff
create_snapshot(sshot2)
once again stuff
switch_snapshot(sshot1) #here sshot2 is saved in the last known stat
#here I can work with my bindings from the time i createt  sshot1
switch_snapshot(ssho2)
and once again continue with the last know state from sshot2

this could be done by writing own functions based on load/save_Session,
but i wonder if ther exists a build-in solution.

greatz Johannes


Am 29.09.2010 21:54, schrieb Jason Bandlow:
 On 09/29/2010 01:47 PM, Johannes wrote:
   
 Hi list,
 is it possible to create in a given environment in sage a new one, which
 know all in the parent defined variables and values, and i i leave it
 again, ijust get back to my old values?
 
 Is this what you're looking for?

 http://www.sagemath.org/doc/tutorial/interactive_shell.html#section-save

 Cheers,
 Jason


   

-- 
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


Re: [sage-support] Re: common devisor

2010-09-28 Thread Johannes
I'm wondering about on more little thing:
I have an expression like this:
(-bc)/((1/b -1) bc -1) + c /((1/b -1) bc -1) + (-1)/((1/b -1) bc -1) -1
which could be simplified by hand to (-2(bc +1)/(c-bc -1)
why do i get this complex expression, evne if I call simplify on it?
maybe this question is related to the one of Aidan too (
'simplifying expressions')

greatz Johannes

-- 
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] common devisor

2010-09-27 Thread Johannes
Hi list,
is there a way to get a sum of fraction to a common devisor? or even
better into a product of a fraction like \frac{1}{something here} and a
sum of integers?
and my next step would be this, i dont have a single value, which i want
to get as the above produkt, but i've got a vector for wich i want to
write as produkt of a skalar times an integervektor.
how can i do this?

greatz Johannes

-- 
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


Re: [sage-support] Re: common devisor

2010-09-27 Thread Johannes
thnx, luis,
thats nearly what I'm looking for, but i missed something in my first post.
in my fractions i work with some variable (with are all integer, that's
why I missed this in the beginning)
I'd like to have something like this:

a,b = var('a,b')
v = vector([2/a, 1/ab])
and with the results:
vector_of_nums = (2b,1)
common_denom = ab

but I've to test if this is possible with you or yanns solution.

Johannes

Am 27.09.2010 17:53, schrieb luisfe:
 On Sep 27, 3:34 pm, Johannes dajo.m...@web.de wrote:
   
 Hi list,
 is there a way to get a sum of fraction to a common devisor? or even
 better into a product of a fraction like \frac{1}{something here} and a
 sum of integers?
 and my next step would be this, i dont have a single value, which i want
 to get as the above produkt, but i've got a vector for wich i want to
 write as produkt of a skalar times an integervektor.
 how can i do this?

 greatz Johannes
 
 Hi,

 Is this what you want?

 sage: v = vector([2/3,1/4,0])
 sage: common_denom = denominator(v)
 sage: common_denom
 12
 sage: vector_of_nums = v * common_denom
 sage: vector_of_nums
 (8, 3, 0)

 note that here, internally, vector of nums is a vector with rational
 entries. If you want a vector of sage integers you could do

 sage: vector_of_nums = vector_of_nums.change_ring(ZZ)

 And you will have a vector with Integer entries, if you need this last
 command or not depends on what do you want to do with your vector.

 Luis

   

-- 
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


Re: [sage-support] Re: common devisor

2010-09-27 Thread Johannes
I tried both attempts, but unfortunately both fail:
the first one (using the denominator function) leads to this error:
/TypeError: lcm function not defined for elements of the base ring/
Does this happen, because i have variables in my term?
In this case i would be enough to get a * b as result of lcm(a,b) for
the variable a,b, even if they are not coprime.

and the second one (using QQ.content) to this:
TypeError: Unable to coerce (-b*c/((1/b - 1)*b*c - 1) + c/((1/b - 1)*b*c
- 1) - 1/((1/b - 1)*b*c - 1) - 1) (type
'sage.modules.free_module_element.FreeModuleElement_generic_dense') to
Rational
This sounds comprehensible, because there are some Elements, wich are
not in ZZ because they are variables, even if i allow them just to be
from ZZ. But i don't know where or how i can add this condition. Father
more, I dont know in how far this condition would help

greatz Johannes

Am 27.09.2010 21:16, schrieb Johannes:
 thnx, luis,
 thats nearly what I'm looking for, but i missed something in my first post.
 in my fractions i work with some variable (with are all integer, that's
 why I missed this in the beginning)
 I'd like to have something like this:

 a,b = var('a,b')
 v = vector([2/a, 1/ab])
 and with the results:
 vector_of_nums = (2b,1)
 common_denom = ab

 but I've to test if this is possible with you or yanns solution.

 Johannes

 Am 27.09.2010 17:53, schrieb luisfe:
   
 On Sep 27, 3:34 pm, Johannes dajo.m...@web.de wrote:
   
 
 Hi list,
 is there a way to get a sum of fraction to a common devisor? or even
 better into a product of a fraction like \frac{1}{something here} and a
 sum of integers?
 and my next step would be this, i dont have a single value, which i want
 to get as the above produkt, but i've got a vector for wich i want to
 write as produkt of a skalar times an integervektor.
 how can i do this?

 greatz Johannes
 
   
 Hi,

 Is this what you want?

 sage: v = vector([2/3,1/4,0])
 sage: common_denom = denominator(v)
 sage: common_denom
 12
 sage: vector_of_nums = v * common_denom
 sage: vector_of_nums
 (8, 3, 0)

 note that here, internally, vector of nums is a vector with rational
 entries. If you want a vector of sage integers you could do

 sage: vector_of_nums = vector_of_nums.change_ring(ZZ)

 And you will have a vector with Integer entries, if you need this last
 command or not depends on what do you want to do with your vector.

 Luis

   
 
   

-- 
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] default browser for notebook

2010-09-23 Thread Johannes
hi list,
how can i change the browser, which is started after i started sage
notebook by `sage -notebook`
I want to use firefox, but i always get a new instance of konquer.

greatz Johannes

-- 
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


Re: [sage-support] Re: domains for variables

2010-08-03 Thread Johannes
thnx i got it working.


Am 30.07.2010 12:00, schrieb Harald Schilly:
 On 30 Jul., 00:01, Johannes dajo.m...@web.de wrote:
   
 Hi list,
 i try to solve a linear equation in ZZ in the variables w_i:
 
 Here is a MILP formulation of your problem, I've pasted the input cell
 in {{{}}} and the output in between

 {{{
 p = MixedIntegerLinearProgram(maximization=False)
 # not reals, we want integers
 w = p.new_variable(integer=True)
 p.add_constraint(w[0] + w[1] + w[2] - 14*w[3] == 0)
 p.add_constraint(w[1] + 2*w[2] - 8*w[3] == 0)
 p.add_constraint(2*w[2] - 3*w[3] == 0)
 # we don't want the trivial solution
 p.add_constraint(w[3] = 1)
 # minimum of each variable is 0 by default, make it +infinity
 [p.set_min(w[i], None) for i in range(1,4) ]
 # minimize w3
 p.set_objective(w[3])
 # show what we have created so far
 p.show()
 }}}


 Minimization:
   x_3
 Constraints:
0 = x_0 +x_1 +x_2 -14 x_3 = 0
0 = x_1 +2 x_2 -8 x_3 = 0
0 = 2 x_2 -3 x_3 = 0
-1 x_3 = -1
 Variables:
   x_0 is an integer variable (min=0.0, max=+oo)
   x_1 is an integer variable (min=-oo, max=+oo)
   x_2 is an integer variable (min=-oo, max=+oo)
   x_3 is an integer variable (min=-oo, max=+oo)

 {{{
 # solve it (default is GLPK, there are other solvers, too)
 print 'Objective Value:', p.solve()
 }}}

 Objective Value: 2.0

 {{{
 p.get_values(w)
 }}}

 {0: 15.0, 1: 10.0, 2: 3.0, 3: 2.0}

 {{{
 # to get one value as integer
 w_sol = p.get_values(w)
 int(round(w_sol[2]))
 }}}

 3


 greetings H

   

-- 
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] domains for variables

2010-07-29 Thread Johannes
Hi list,
i try to solve a linear equation in ZZ in the variables w_i:

sage: variables = [var(w + str(i),domain=ZZ)for i in range(s.nvertices())]
sage: eq
(w0 + w1 + w2 - 14*w3, w1 + 2*w2 - 8*w3, 2*w2 - 3*w3)
sage: result
[w0 == 15/2*r548, w1 == 5*r548, w2 == 3/2*r548, w3 == r548]

up to here it's ok, but now im lookin for the smalest integer r548  0
solving this equatoins. in other words, the smalest r548 such that every
wi is in ZZ.
How can i do this?

Johannes

-- 
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


Re: [sage-support] Re: domains for variables

2010-07-29 Thread Johannes
maybe it helps if i give my full pice of code:

def calc_wights_by_sum_to_zero(s):
#create the equations
variables = [var(w + str(i),domain=ZZ)for i in range(s.nvertices())]
equation = reduce(lambda f1,f2: f1 + f2, [variables[i] * s.vertex(i)
for i in range(s.nvertices())])
#calculate the result, containing a parameter r
result =  solve(equation,variables)[0]
#get the name of the parameter
parameter = result[0].variables()[0]

#add the constrain r == 1
result.append(parameter == 1)
variables.append(parameter)

#get the result for r = 1
result = solve(result,variables)
return tuple( [ww.right_hand_side() for ww in result[0]][0:-1])

i know that the equations are always solveable in ZZ.

greatz
Am 30.07.2010 02:03, schrieb kcrisman:

 On Jul 29, 6:01 pm, Johannes dajo.m...@web.de wrote:
   
 Hi list,
 i try to solve a linear equation in ZZ in the variables w_i:

 sage: variables = [var(w + str(i),domain=ZZ)for i in range(s.nvertices())]
 sage: eq
 (w0 + w1 + w2 - 14*w3, w1 + 2*w2 - 8*w3, 2*w2 - 3*w3)
 sage: result
 [w0 == 15/2*r548, w1 == 5*r548, w2 == 3/2*r548, w3 == r548]

 up to here it's ok, but now im lookin for the smalest integer r548  0
 solving this equatoins. in other words, the smalest r548 such that every
 wi is in ZZ.
 How can i do this?
 
 This sounds sort of like integer programming, which is very tough in
 general.  Although in this case r548=2 looks like it would give all
 integer wi, just by inspection.  Presumably this wouldn't always be
 possible with whatever you are looking at, though.  I suppose one
 could just do

 r548=1
 while all wi not integers:
 r548+=1

 or something, though obviously that's a hack.

 Another issue is that solve() does not actually take the domain into
 account necessarily.  (In fact, I'm not sure what var(domain=blah)
 does, but someone else may want to clarify that.)  At any rate, Maxima
 (which does our solving) is explicitly designed not to take
 assumptions of this kind into account - though, again, I don't know
 that domain=ZZ would pass that on to Maxima anyway; presumably this is
 a Pynac thing.

 Does anyone else have ideas for this?
 - kcrisman

   

-- 
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] Recucing equatoins

2010-07-28 Thread Johannes
Hi list,
i have a questoin about the handling of (mathematical) functoins in sage.

i have a function
f : k^n \times (k^m)^n - k for some Field k. with
f(q_1,\dots,q_n,x_1,\dots,x_n) - \sum\limits_{i=1}^n q_i * x_i
for a given n,m.
and i want to create a family (f_i)_{i=1\dots l} of functions from f where
f_i(q_1,\dots,q_n) = f(q_0,\dots,q_n,x_{i,1},\dots, x_{i,n})

i started with this:
f(q0,q1,q2,q3,x0,x1,x2,x3) = q0 * x0 + q1 * x1 + q2 * x2 + q3 * x3

and a function createFamilyItem(s)

def createFamilyItem(s):
ff(q0,q1,q2,q3) =
f(q0,q1,q2,q3,s.vertices(0),s.vertices(1),s.vertices(2),s.vertices(3))
return ff

but executing createFamilyItem always leads to
TypeError Traceback (most recent call last)
/opt/sage-4.4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so
in sage.symbolic.expression.Expression.__call__
(sage/symbolic/expression.cpp:15476)()

/opt/sage-4.4.3/local/lib/python2.6/site-packages/sage/symbolic/callable.pyc
in _call_element_(self, _the_element, *args, **kwds)
449 d = dict(zip(map(repr, self.arguments()), args))
450 d.update(kwds)
-- 451 return SR(_the_element.substitute(**d))
452
453

/opt/sage-4.4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so
in sage.symbolic.expression.Expression.substitute
(sage/symbolic/expression.cpp:14850)()

/opt/sage-4.4.3/local/lib/python2.6/site-packages/sage/symbolic/expression.so
in sage.symbolic.expression.Expression.coerce_in
(sage/symbolic/expression.cpp:10193)()

/opt/sage-4.4.3/local/lib/python2.6/site-packages/sage/structure/parent_old.so
in sage.structure.parent_old.Parent._coerce_
(sage/structure/parent_old.c:3288)()

/opt/sage-4.4.3/local/lib/python2.6/site-packages/sage/structure/parent.so
in sage.structure.parent.Parent.coerce (sage/structure/parent.c:7235)()

TypeError: no canonical coercion from Ambient free module of rank 3 over
the principal ideal domain Integer Ring to Callable function ring with
arguments (q0, x0, q1, x1, q2, x2, q3, x3)


what do i do wrong?

and is there a way to ensure that the x_i are vectors in k^m?

greatz  thnx Johannes

-- 
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


Re: [sage-support] Define an action

2010-07-26 Thread Johannes
maybe Y[k] is possible if you create a subclass of matrix and overload
the [] operator.
but you have to think about Y[1] returns the first row of the matrix so
it would be inconsistent.

greatz
Am 25.07.2010 10:52, schrieb drenwal:
 Hello,

 I would like to define an action, let us say:

 def Ac(Y,k):
 return k.transpose()*Y*k

 where Y and k are square matrices of the same size.

 But, I would prefer to use a more mathematical notation, like Y[k] or
 y...@k or whatever non already used symbol instead of Ac(y,k).

 How is it possible to do that?

 Best regards.

 Drenwal

   

-- 
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] types for functions

2010-07-14 Thread Johannes
Hi list,
i have a problem defining a function realizing the default scalar:
i have m = matrix([[1,0,0,],[0,1,0],[0,0,1]])
and want to define
scalar(v,w) = v * m * w
but i always get this:
(v, w) |--
[v*w   0   0]
[  0 v*w   0]
[  0   0 v*w]

otherwise, if i do it this way, directly on the console it works:
v1 = vector([1,1,1])
v2 = vector([1,0,0])

v1 * m * v2.transpose()

how can i force the type in my scalarfunction to be an matrix or even a
vector?

by the way, is there a scalarfunction defined somewhere? a
matrixmultiplication for this seems to be a little bit much overhead for me.

greatz

-- 
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


Re: [sage-support] Re: how to change show() defaults for 2D plots

2010-07-12 Thread Johannes Huisman

Mike Hansen wrote:

On Sun, Jul 11, 2010 at 5:48 AM, Johannes johannes.huis...@gmail.com wrote:

Sorry for posting twice. I just noticed that
my first message got through all right, though I did
not receive it myself! Is this a common behaviour
of google groups?


Yes, this is a common behavior of Google Groups and Gmail.

You can set defaults in the plot.options dictionary.

sage: plot.options['frame'] = False


Thanks, but I did try that. It doesn't make
any difference, in any case in sage version 4.4.3
that I'm running. In fact, the sage dictionary
plot.options does not contain the keyword 'frame'.
So, setting it to False is, of course possible,
but seemingly without any effect.

Johan

--
http://pageperso.univ-brest.fr/~huisman

--
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 to change show() defaults for 2D plots

2010-07-11 Thread Johannes
Is there a way to change default settings of the show()
method for 2D plots? According to the reference manual,
such a feature does exist for 3D plots through the commands

from sage.plot.plot3d.base import SHOW_DEFAULTS
SHOW_DEFAULTS['frame']=False

They set the default value of frame to False
for the 3D show() method. Indeed, the commands

var('t,u,v')
cubic=t*(u^2+v^2+1)-u*v
S=implicit_plot3d(cubic==0,(t,-3,3),(u,-3,3),(v,-3,3))
S.show()

then result in a nice cubic surface being displayed
without frames; no need to type

S.show(frame=False)

However, for 2D plots, this feature does not seem to
be available, or did I miss something?

Johan

-- 
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: how to change show() defaults for 2D plots

2010-07-11 Thread Johannes
Sorry for posting twice. I just noticed that
my first message got through all right, though I did
not receive it myself! Is this a common behaviour
of google groups?

Johan

On Jul 11, 2:21 pm, Johannes johannes.huis...@gmail.com wrote:
 Is there a way to change default settings of the show()
 method for 2D plots? According to the reference manual,
 such a feature does exist for 3D plots through the commands

 from sage.plot.plot3d.base import SHOW_DEFAULTS
 SHOW_DEFAULTS['frame']=False

 They set the default value of frame to False
 for the 3D show() method. Indeed, the commands

 var('t,u,v')
 cubic=t*(u^2+v^2+1)-u*v
 S=implicit_plot3d(cubic==0,(t,-3,3),(u,-3,3),(v,-3,3))
 S.show()

 then result in a nice cubic surface being displayed
 without frames; no need to type

 S.show(frame=False)

 However, for 2D plots, this feature does not seem to
 be available, or did I miss something?

 Johan

-- 
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 to change show() defaults for 2D plots

2010-07-10 Thread Johannes Huisman

Is there a way to change default settings of the show()
method for 2D plots? According to the reference manual,
such a feature exists for 3D plots through the commands

from sage.plot.plot3d.base import SHOW_DEFAULTS
SHOW_DEFAULTS['frame']=False

They set the default value of frame to False
for the 3D show() method. Indeed, 


var('t,u,v')
cubic=t*(u^2+v^2+1)-u*v
S=implicit_plot3d(cubic==0,(t,-3,3),(u,-3,3),(v,-3,3))
S.show()

then results in a nice cubic surface being displayed
without frames; no need to type

S.show(frame=False)

However, for 2D plots, this feature does not seem to
be available, or did I miss something?

Johan

--
http://pageperso.univ-brest.fr/~huisman

--
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] more finely lattice

2010-07-06 Thread Johannes
Hi list,
is there a way in sage to create some lattice more finely than
anotherone, for exampl 1/3ZZ = the localisation of ZZ to the mult.
system genrated by 3ZZ.
thnx for answers,
greatz Johannes.

-- 
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] Why does LatticePolytope not implement a special __eq__ function?

2010-07-04 Thread Johannes
Hi list,
im just playing around with sage and LatticePolytopes and im wondering
why theres no __eq__ implementet for them.
if i have this code:
s1 = LatteciPolytope(matrix([[1,0,-1],[0,1,-1]])
s2 = LatteciPolytope(matrix([[1,0,-1],[0,1,-1]])

then s1 == s2 evals to false.
thats right in the sentence of ref-equality but in my eyes two polytopes
are equal, if they live in the same space (in this case, on the same
Lattice) and have the same edges.
Is there any reason, why its not implemented that way?

greatz Johannes

-- 
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] Subclass from LatticePolytope

2010-07-04 Thread Johannes
Hi list,
i just tried to create a extended Version of LatticePolytope, but it did
not work.
I always get the following error:
Error when calling the metaclass bases function() argument 1 must be
code, not str.
i found out this is because LatticePolytope is not a class, but a function.
otherwise, the type of LatticePolytope(somePoints) is given as:
sage.geometry.lattice_polytope.LatticePolytopeClass.
How can i extend this?
Where can i find informations about this class?

greatz Johannes

-- 
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


Re: [sage-support] Subclass from LatticePolytope

2010-07-04 Thread Johannes
thnx,
i did not know all about the sagehelp. but the ?? is a wonderfull feature.
I'll look at the code next, and i hope it helps me somehow.
gretz Johannes.
Am 04.07.2010 23:52, schrieb Justin C. Walker:
 Hi, Johannes,

 On Jul 4, 2010, at 07:24 , Johannes wrote:

 i just tried to create a extended Version of LatticePolytope, but it did
 not work.
 I always get the following error:
 Error when calling the metaclass bases function() argument 1 must be
 code, not str.
 i found out this is because LatticePolytope is not a class, but a
 function.
 otherwise, the type of LatticePolytope(somePoints) is given as:
 sage.geometry.lattice_polytope.LatticePolytopeClass.
 How can i extend this?
 Where can i find informations about this class?

 I can't help with the details of the Lattice Polytope code, but this
 may help.  Since I'm not sure of your understanding of the Sage
 system, I'm not sure of how much you know, so this is basic info:

 In general, given a Sage (or Python) object 'x', typing 'x.[TAB]'
 (i.e., 'x.' followed by the TAB key) will give you a list of methods
 associated to 'x' (or to its type; also, not all listed items may be
 implemented for a given object).

 Also, typing str[TAB] will give you a list of all known (global)
 names beginning with str.

 If you type something like s1.polar? (from your previous email),
 Sage will respond with whatever documentation is provided by the
 implementor of the polar() method for Lattice Polytopes.  With a
 double ??, you get documentation and possibly the code that
 implements it (if Sage can find it).  For this to work, s1 must be
 the full name of an object, class, function, or method (sometimes
 'str[tab]?' works wonders :-}).

 At the beginning of each of the latter output lists is a line
 beginning File: .  This line contains the full path to the source
 file where the code lives, so you can examine things like class
 definitions and function or method implementations.

 HTH

 Justin

 -- 
 Justin C. Walker, Curmudgeon at Large
 Institute for the Absorption of Federal Funds
 ---
 My wife 'n kids 'n dogs are gone,
 I can't get Jesus on the phone,
 But Ol' Milwaukee's Best is my best friend.
 ---



-- 
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] solving equations with constrains

2010-06-29 Thread Johannes
Hi list,
i have some equatione, wich i want to solove using the solve function:

q0,q1,q2,q3 = var(q0,q1,q2,q3)
eq = (q0 - q3, q1 - q3, q2 - q3)
solve(eq,q0,q1,q2,q3) returns
[[q1 == r5, q2 == r5, q3 == r5, q0 == r5]]
this is correct, but i want to have r5 in \N r5 \neq 0 with
gcd(q1,q2,q3,q0) = 1, meaninga in this case, r5 = 1.

i tried to extend eq to
eq = [(q0  * v0 ) + (q1 * v1) + (q2 * v2) + (q3 * v3) , gcd(q0,q1) == 1,
gcd(q1,q2) == 1, gcd(q2,q3) == 1]
and i get this:
[[q1 == r8, q2 == r7, q3 == r7, q0 == r6]]
thats not even waht i want to have.

how do i have to do it?

greatz Johannes

-- 
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


Re: [sage-support] Quotient of two submodules

2010-06-19 Thread Johannes
i tried the first example in the given link and i get the following error:

sage: V0 = span([[1/2,0,0],[3/2,2,1],[0,0,1]],ZZ)
---
TypeError Traceback (most recent call last)

/home/j_schn14/ipython console in module()

/usr/lib/python2.5/site-packages/sage/modules/free_module.pyc in span(R,
gens, check, already_echelonized)
349 [1 0 1]
350 
-- 351 if len(gens) == 0:
352 return FreeModule(R, 0)
353 else:

/usr/lib/python2.5/site-packages/sage/rings/integer_ring.so in
sage.rings.integer_ring.IntegerRing_class.__len__
(sage/rings/integer_ring.c:3903)()

TypeError: len() of unsized object

is this a bug, or am I doing something wrong?
greatz Mad


Am 19.06.2010 00:32, schrieb William Stein:
 On Fri, Jun 18, 2010 at 3:26 PM, Mad dajo.m...@web.de wrote:
   
 Hi folkz,
 i want to create a quotient of two submodules generatet by some
 vektors and i don't know how to do this.
 
 See the examples here:

   http://sagemath.org/doc/reference/sage/modules/fg_pid/fgp_module.html

 Already, the first example there is what you're asking about.

 William

   
 i tried this:
 m = ZZ^2
 m1 = m.submodul([2,1],[1,2])  #this is ZZ^2 again, but of type
 'sage.modules.free_module.FreeModule_submodule_pid'
 m2 = m.submodul([3,2],[2,1])
 #i want to do something like:
 mQuot = m1.quotient(m2)

 but m1 (or FreeModule_submodule_pid) does not have a member quotient
 like it has sage.modules.free_module.FreeModule_ambient_pid (of wich
 typ m is).

 How do i have to do it?

 greatz and thnx for your tipps and answers Mad

 --
 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

 


   

-- 
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


Re: [sage-support] Quotient of two submodules

2010-06-19 Thread Johannes
I'm working with the version, contained in ubuntu 10.04

j_sch...@neo:~$ sage -version
| SAGE Version 3.0.5, Release Date: 2008-07-11   |
j_sch...@neo:~$ uname  -a
Linux neo 2.6.31-22-generic #60-Ubuntu SMP Thu May 27 00:22:23 UTC 2010
i686 GNU/Linux
j_sch...@neo:~$ python --version
Python 2.6.4

greatz

Am 19.06.2010 16:51, schrieb William Stein:
 On Sat, Jun 19, 2010 at 7:33 AM, Johannes dajo.m...@web.de wrote:
   
 i tried the first example in the given link and i get the following error:

 sage: V0 = span([[1/2,0,0],[3/2,2,1],[0,0,1]],ZZ)
 ---
 TypeError Traceback (most recent call last)

 /home/j_schn14/ipython console in module()

 /usr/lib/python2.5/site-packages/sage/modules/free_module.pyc in span(R,
 gens, check, already_echelonized)
349 [1 0 1]
350 
 -- 351 if len(gens) == 0:
352 return FreeModule(R, 0)
353 else:

 /usr/lib/python2.5/site-packages/sage/rings/integer_ring.so in
 sage.rings.integer_ring.IntegerRing_class.__len__
 (sage/rings/integer_ring.c:3903)()

 TypeError: len() of unsized object

 is this a bug, or am I doing something wrong?
 greatz Mad
 
 What version of Sage are you using?  It works fine in recent versions:

 flat:Library wstein$ sage
 --
 | Sage Version 4.4.2, Release Date: 2010-05-19   |
 | Type notebook() for the GUI, and license() for information.|
 --
 sage: V0 = span([[1/2,0,0],[3/2,2,1],[0,0,1]],ZZ)
 sage:
 sage: V0
 Free module of degree 3 and rank 3 over Integer Ring
 Echelon basis matrix:
 [1/2   0   0]
 [  0   2   0]
 [  0   0   1]
   

-- 
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: SAGE working with Paraview

2009-01-20 Thread Johannes Reichold

Many thanks for your answer Jaap!
Unfortunately, building the experimental cmake failed (see error report 
below), however I have cmake installed on my system outside of SAGE. I 
will give it a try.
Best,
Johannes

g++  -framework Carbon 
-I/Applications/Science/sage/spkg/build/cmake-2.4.8/src/Source   
-I/Applications/Science/sage/spkg/build/cmake-2.4.8/src/Bootstrap.cmk  
cmake.o cmakemain.o cmakewizard.o cmCommandArgumentLexer.o 
cmCommandArgumentParser.o cmCommandArgumentParserHelper.o cmDepends.o 
cmDependsC.o cmMakeDepend.o cmMakefile.o cmGeneratedFileStream.o 
cmGlobalGenerator.o cmLocalGenerator.o cmInstallGenerator.o 
cmInstallFilesGenerator.o cmInstallScriptGenerator.o 
cmInstallTargetGenerator.o cmSourceFile.o cmSystemTools.o 
cmFileTimeComparison.o cmGlobalUnixMakefileGenerator3.o 
cmLocalUnixMakefileGenerator3.o cmMakefileExecutableTargetGenerator.o 
cmMakefileLibraryTargetGenerator.o cmMakefileTargetGenerator.o 
cmMakefileUtilityTargetGenerator.o cmBootstrapCommands.o cmCommands.o 
cmTarget.o cmTest.o cmCustomCommand.o cmCacheManager.o cmListFileCache.o 
cmOrderLinkDirectories.o cmListFileLexer.o Directory.o Glob.o 
RegularExpression.o SystemTools.o ProcessUNIX.o System.o -o cmake
dyld: Symbol not found: __cg_png_create_info_struct
   Referenced from: 
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
   Expected in: /Applications/Science/sage/local/lib//libPng.dylib

./bootstrap: line 1301:  2919 Trace/BPT trap  
${cmake_bootstrap_dir}/cmake ${cmake_source_dir} 
-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake 
-G${cmake_bootstrap_generator} ${cmake_bootstrap_system_libs}
-
Error when bootstrapping CMake:
Problem while running initial CMake
-
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target `install'.  Stop.



On 20.01.2009 20:23 Uhr, Jaap Spies wrote:
 msafiri wrote:

 Hello everyone,

 I'm using SAGE to analyze the brain's vasculature. The vessel network
 is stored as a networkX graph and I would like to plot this graph from
 the SAGE command line (or notebook) using Paraview (http://
 www.paraview.org).
 I use OS X Leopard and I have the latest versions of both SAGE and
 Paraview, versions 3.2.3 and 3.4.0 respectively.

 What I have tried so far:
 Both the sage folder and paraview.app reside in /Applications
  From the SAGE command line set PYTHONPATH:
 sage: sys.path.append('/Applications/paraview.app/Contents/MacOS')
 sage: sys.path.append('/Applications/paraview.app/Contents/Resources/
 paraview)
 In bash .profile set DYLD_LIBRARY_PATH to /Applications/paraview.app/
 Contents/MacOS
 sage: import servermanager as sm
 fails with a fatal error, presumably because SAGE and Paraview use
 different versions of python.

 Has anyone successfully made the two softwares work together and can
 give me some hints?
 Any help is greatly appreciated,
 Johannes
  

 A first step could be to install paraview3 in the sage environment.
 You need cmake, so eventually install the experimental cmake-2.4.8.spkg:
 ./sage -i cmake-2.4.8.spkg

 then do a ./sage -sh
 and follow the instructions on
 http://paraview.org/Wiki/ParaView:Build_And_Install
 to build and install paraview within Sage.


 Can't check this because I don't have a mac.

 Jaap


 


--~--~-~--~~~---~--~~
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
For more options, visit this group at 
http://groups.google.com/group/sage-support?hl=en
-~--~~~~--~~--~--~---



[sage-support] Re: SAGE working with Paraview

2009-01-20 Thread Johannes Reichold

Hello Mike,

Paraview is an immensly powerful tool (based on vtk) that allows 
visualizing huge datasets. The data can be located on a remote computer 
running the Paraview server, to which you would connect with the 
corresponding PV client. It is also Python scriptable, which is what I 
want to exploit from within SAGE. You get lots of control over the 
rendering details ect. - at the expense that it is more involved than, 
say, the plot3d command. A description of how the scripting works can be 
found at
http://www.paraview.org/Wiki/images/f/f9/Servermanager2.pdf
I will give Jaap's hint a try and let you know how it went. But it's 
midnight now and tomorrow I'm off to ski :-) So that will have to wait 
till thursday.
Many thanks,

Johannes


On 20.01.2009 23:43 Uhr, Mike Hansen wrote:
 Hi Johannes,

 On Tue, Jan 20, 2009 at 2:37 PM, Johannes Reichold
 reich...@ifd.mavt.ethz.ch  wrote:

 Many thanks for your answer Jaap!
 Unfortunately, building the experimental cmake failed (see error report
 below), however I have cmake installed on my system outside of SAGE. I
 will give it a try.
 Best,
 Johannes
  

 I tried (briefly) looking for online docs of ParaView to get a sense
 for how it works, but was unable to find any.  Could you describe what
 you would do to plot _any_ graph in ParaView?

 It might be easiest to just run ParaView in a separate process than
 the Sage one.

 --Mike

 


--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: SAGE working with Paraview

2009-01-20 Thread Johannes Reichold

Hello Mike,

Paraview is an immensly powerful tool (based on vtk) that allows 
visualizing huge datasets. The data can be located on a remote computer 
running the Paraview server, to which you would connect with the 
corresponding PV client. It is also Python scriptable, which is what I 
want to exploit from within SAGE. You get lots of control over the 
rendering details ect. - at the expense that it is more involved than, 
say, the plot3d command. A description of how the scripting works can be 
found at
http://www.paraview.org/Wiki/images/f/f9/Servermanager2.pdf
I will give Jaap's hint a try and let you know how it went. But it's 
midnight now and tomorrow I'm off to ski :-) So that will have to wait 
till thursday.
Many thanks,

Johannes


On 20.01.2009 23:43 Uhr, Mike Hansen wrote:
 Hi Johannes,

 On Tue, Jan 20, 2009 at 2:37 PM, Johannes Reichold
 reich...@ifd.mavt.ethz.ch  wrote:

 Many thanks for your answer Jaap!
 Unfortunately, building the experimental cmake failed (see error report
 below), however I have cmake installed on my system outside of SAGE. I
 will give it a try.
 Best,
 Johannes


 I tried (briefly) looking for online docs of ParaView to get a sense
 for how it works, but was unable to find any.  Could you describe what
 you would do to plot _any_ graph in ParaView?

 It might be easiest to just run ParaView in a separate process than
 the Sage one.

 --Mike

 


--~--~-~--~~~---~--~~
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
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---