Re: [sage-devel] Question about Free algebra

2015-06-09 Thread Nicolas Borie

Le 09/06/2015 06:50, Viviane Pons a écrit :

Hi everyone,

I'm doing this:

sage: FreeA. = FreeAlgebra(QQ,implementation="letterplace")
sage: P = a*b*a*c*c*b + a*b*a*d*d*b + a*c*a*d*d*c + b*c*b*d*d*c
sage: X = P.lm()
sage: X
a*b*a*c*c*b

And now I would like a way to "cut" my element X into two factors of a 
given size. Something like


sage: u,v = X[:2],X[2:]

with then u=a*b and v = a*c*c*d

except this doesn't work (no __getitem__ on X). I have looked a bit, 
but I cannot find how to do this even though it seems quite a natural 
operation. I must say, I don't even understand the datastructure of X, 
list(X) doesn't give me something I can easily read or transform into 
a word or anything...


If someone knows about this, I would appreciate the help.

Hello,

This feature seems to be strongly wrapped... You can access the data 
structure by iterating on element :


**
sage: FreeA. = FreeAlgebra(QQ,implementation="letterplace")
sage: P = a*b*a*c*c*b + a*b*a*d*d*b + a*c*a*d*d*c + b*c*b*d*d*c
sage: for basis_elt, coef in P:
: print list(basis_elt), coef
:
[1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 
0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0] 1
[1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 
0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0] 1
[0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 
0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0] 1
[1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0] 1

**

Depending what is your need, perhaps one of the following will be easier 
to manipulate :

**
sage: W = Words(['abcdef'])
sage: A = W.algebra(QQ)
sage: A
Free module generated by Words over {'abcdef'} over Rational Field
sage: A = FreeMonoid(6, 'a,b,c,d,e,f').algebra(QQ)
sage: A
Free module generated by Free monoid on 6 generators (a, b, c, d, e, f) 
over Rational Field

**

Note that the first one using Words produce a strange bug on my machine 
(old sage 6.4.beta2)

**
sage: W = Words(['abcdef'])
sage: W.algebra(QQ)
---
AttributeErrorTraceback (most recent call last)
 in ()
> 1 W.algebra(QQ)

/home/nborie/sage-6.3/local/lib/python2.7/site-packages/sage/structure/parent.so 
in sage.structure.parent.Parent.__getattr__ 
(build/cythonized/sage/structure/parent.c:7213)()


AttributeError: 'Words_over_OrderedAlphabet' object has no attribute 
'algebra'

sage: W.al
W.algebra   W.alphabet
sage: W.algebra(QQ)
Free module generated by Words over {'abcdef'} over Rational Field
**

The method algebra works only after I asked for a tab completion on W... 
Never see that before


Following the feature you choose, you will perhaps have to add a product 
method (product_on_basis or whatever, most of the time, the categories 
does it already for you...)


Cheers,
Nicolas.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] What are we unable to do right now ?

2014-12-05 Thread Nicolas Borie

Hello,

Computing the inverse of the identity matrix is not possible. Ok, it 
works for rings using RingElement class for the elements (like ZZ, QQ, 
RR, CC, ...).


sage: SF = SymmetricFunctions(QQ).schur(); SF
Symmetric Functions over Rational Field in the Schur basis
sage: one = SF.one()
sage: zero = SF.zero()
sage: M = Matrix([[one, zero], [zero, one]])
sage: M
[s[]   0]
[  0 s[]]
sage: M.det()
s[]
sage: M.is_invertible()
True
sage: M.inverse()
...
AttributeError: 'SymmetricFunctionAlgebra_schur_with_category' object 
has no attribute 'fraction_field'

sage: M = Matrix([[one]])
...
AttributeError: 'tuple' object has no attribute 'parent'
sage: M*M
[s[]   0]
[  0 s[]]
sage: SteenrodAlgebra(7)
mod 7 Steenrod algebra, milnor basis
sage: A = SteenrodAlgebra(7)
sage: M = Matrix([[A.one(), A.zero()], [A.zero(), A.one()]])
sage: M^2
[1 0]
[0 1]
sage: M.inverse()
AttributeError: 'SteenrodAlgebra_generic_with_category' object has no 
attribute 'fraction_field'


For the curious, defining a fraction_field for these rings is not 
enought. The good fix should be more serious than that.


More generally, there is no any linear algebra in Sage for general 
rings. As I worked (the last 6 months) around the coinvariants of the 
symmetric group (with a module of rank n! over the symmetric polynomials 
in n variables), I only work locally on my machine with a hard hack that 
breaks linear algebra over classical rings. I REALLY do not know how to 
fix that... ( see http://trac.sagemath.org/ticket/15160 for curious 
people, the fix proposed in attachment breaks scalar multiplication for 
vector whose element use RingElement class, so it breaks Sage 
horribly... ).


Sage is able to model impressively my ring as an abstract free module 
over the symmetric functions with 5 different bases (Parent with 
multiples realizations : Harmonic polynomials, Schubert polynomials, 
Descents monomials, monomials under the staircase and higher Specht 
polynomials are the available bases). I have most of basis changes 
implemented on my machine but I do need my hack for inverse the 
coercions between these bases (since inverting a matrix with unital 
determinant over general ring need a fix).


I am ok with the fact that such a bug concerns only people working with 
exotic rings or people needing to defined their own rings (like in 
algebraic combinatorics, we do need vectors spaces indexed by 
anything). My problems can't be easily translated as problem of 
linear algebra over QQ.


Cheers,
Nicolas B.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Re: Building Sage fails on Lubuntu 14

2014-09-07 Thread Nicolas Borie

Le 07/09/2014 13:31, Volker Braun a écrit :

I would recommend that you try to compile the latest version from source.


Hello,

On Lubuntu 64 bits (up to date),

When trying to compile the 6.3 from sources, I just got :



real13m9.547s
user18m36.662s
sys0m51.881s
Successfully installed singular-3.1.6.p3
Deleting temporary build directory
/home/nborie/sage-6.3/local/var/tmp/sage/build/singular-3.1.6.p3
Finished installing singular-3.1.6.p3.spkg
make[2]: quittant le répertoire « /home/nborie/sage-6.3/build »
make[1]: *** [all] Erreur 2
make[1]: quittant le répertoire « /home/nborie/sage-6.3/build »

real43m34.145s
user137m50.951s
sys12m7.358s
***
Error building Sage.

The following package(s) may have failed to build:

package: r-3.1.1.p0
log file: /home/nborie/sage-6.3/logs/pkgs/r-3.1.1.p0.log
build directory: /home/nborie/sage-6.3/local/var/tmp/sage/build/r-3.1.1.p0

The build directory may contain configuration files and other potentially
helpful information. WARNING: if you now run 'make' again, the build
directory will, by default, be deleted. Set the environment variable
SAGE_KEEP_BUILT_SPKGS to 'yes' to prevent this.

make: *** [build] Erreur 1

I also attached the log file to this mail...

Cheers,
Nicolas B.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.
Found local metadata for r-3.1.1.p0
Found local sources at /home/nborie/sage-6.3/upstream/r-3.1.1.tar.gz
Checksum: e974ecc92e49266529e8e791e02a80c75e50b696 vs e974ecc92e49266529e8e791e02a80c75e50b696
r-3.1.1.p0

Setting up build directory for r-3.1.1.p0
Finished set up

Host system:
Linux perceval 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

C compiler: gcc
C compiler version:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-multilib
Thread model: posix
gcc version 4.9.0 (GCC) 

patching file src/scripts/R.sh.in
patching file configure
patching file configure.ac
Hunk #1 succeeded at 1332 (offset 11 lines).
patching file configure
Hunk #1 succeeded at 26248 (offset 1 line).
patching file src/scripts/Makefile.in
Configuring R with ATLAS
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
loading site script './config.site'
loading build-specific script './config.site'
checking for pwd... /bin/pwd
checking whether builddir is srcdir... yes
checking for working aclocal... missing
checking for working autoconf... missing
checking for working automake... missing
checking for working autoheader... missing
checking for gawk... gawk
checking whether ln -s works... yes
checking for bison... no
checking for byacc... no
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for sed... /bin/sed
checking for which... /usr/bin/which
checking for less... /usr/bin/less
checking for gtar... no
checking for gnutar... no
checking for tar... /bin/tar
checking for tex... /usr/bin/tex
checking for pdftex... /usr/bin/pdftex
checking for pdflatex... /usr/bin/pdflatex
checking for makeindex... /usr/bin/makeindex
checking for makeinfo... /usr/bin/makeinfo
checking whether makeinfo version is at least 4.7... yes
checking for ginstall-info... /usr/bin/ginstall-info
checking for texi2dvi... /usr/bin/texi2dvi
checking for kpsewhich... /usr/bin/kpsewhich
checking for latex inconsolata package... found zi4.sty
checking for unzip... /usr/bin/unzip
checking for zip... /usr/bin/zip
checking for gzip... /bin/gzip
checking for bzip2... /home/nborie/sage-6.3/local/bin/bzip2
checking for firefox... /usr/bin/firefox
using default browser ... /usr/bin/firefox
checking for acroread... no
checking for acroread4... no
checking for xdg-open... /usr/bin/xdg-open
checking for notangle... false
checking for realpath... false
checking for pkg-config... /home/nborie/sage-6.3/local/bin/pkg-config
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to a

Re: [sage-devel] Should Ring.sum([...]) behave well if the ...'s are not in Ring?

2013-12-02 Thread Nicolas Borie

On 02/12/2013 20:34, Darij Grinberg wrote:

Hi,

Is the following a case of refused bequest? (If you don't know much
about symmetric functions, it should be enough to know that p and s
are two free modules with coercions between them.)

sage: Sym = SymmetricFunctions(QQ)
sage: p = Sym.p()
sage: s = Sym.s()
sage: sum([s[2,1]])
s[2, 1]
sage: p(sum([s[2,1]]))
1/3*p[1, 1, 1] - 1/3*p[3]
sage: p.sum([s[2,1]])
p[2, 1]

Some comments: When R is a ring, I expected R.sum(...) to basically be
a glorified sum(...) which ensures that an empty iterable sums to
R.zero() and that the result ends up in R. But here, the result is
explicitly wrong because the iterable contained elements not in R
(even though they coerce into R). This behavior comes from the sum
method as overridden by sage/combinat/free_module.py.

Is this a bug? The documentation of the original R.sum(...) method (in
sage/categories/commutative_additive_monoids.py ) says nothing about
what happens if elements not lying R are fed into it, so my example
above probably qualifies as abuse, but I found it very natural to
expect that things that can coerce into R do so when one operates on
them by methods of R...

   Best regards,
   Darij


Hello,

IMO : I think this should be considered as a bug. We want to compute 
sums very fast but we first want correct results. So we should increase 
the level of checking in the parent method "sum" of the category of 
commutative additive monoids. An extra argument check=True should be 
enough (with the proper tests checking that elements live in self). A 
such code can produce behaviors so much hard to debug... This seems to 
me too tricky for every parents with multiple realizations (for which 
each realization coerce each other). That will prevent me conjecturing 
false theorems.


Cheers,
N. Borie.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [sage-devel] Re: Should ClasscallMetaclass do a consistency test?

2013-07-30 Thread Nicolas Borie

Le 30/07/2013 14:18, Simon King a écrit :

Hi all,
I determined all classes-with-ClasscallMetaclass that sometimes return
instances that are not instances of this class:
...

sage.combinat.integer_vectors_mod_permgroup.IntegerVectorsModPermutationGroup
...

What do you think? These are relatively few classes. Would it be
reasonable to change them, such that when on tries to create instances
of these classes then one is guaranteed to actually get an instance of
these classes (or a sub-class, at least)?

Hi Simon,

Concerning this class, I think it could be nice for the semantic to 
change the code. It is probably something like a one or two lines 
modification but the design deserves it.


Concerning Classcall in general, I am too young to have a strong 
opinion. I just think that if no one is able to present a fair usecase 
in which returning an instance of a total different class is really 
useful, we should try to use the feature as you described. It is perhaps 
no necessary to add an assert (I mean I can't judge that from my little 
experience...) but for the semantic sake, the object returned should 
definitely have the original class in the mro of its class... The proper 
class or a derived class is clearly fine.


And thanks you so much for all your hard works on the design, the 
coherence and the quality of Sage code in general, that allows level one 
contributor like me to not crash on walls.

Cheers,
Nicolas B.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-devel] Inverse a matrix over a ring with a unit determinant

2013-07-10 Thread Nicolas Borie

Le 10/07/2013 17:10, David Roe a écrit :



I think the right solution is to define a method inverse_of_unit for 
general square matrices, implemented exactly as you suggest (it should 
go in matrix0.pyx). Unlike __invert__, this would not change base 
rings and would fail for matrices with non-unit determinant.  Such a 
function already exists a few places in Sage (integers, p-adics, 
polynomials).


def inverse_of_unit(self):
R = self.base_ring()
d = R(~self.det())
return d*self.adjoint()

Thanks you very much. I Just realized that there everything already in 
Sage (Division free algorithms for charpoly, thus adjoint, thus 
inverse).


I just add Sage-combinat-devel for the following issue :

The first problem appearing when I try to invert is that a method : 
change_variable_name rename the variable used in the charpoly :


*
def change_variable_name(self, var):
"""
Return a new polynomial over the same base ring but in a different
variable.
...
"""
R = self.parent().base_ring()[var]    NOT COMBINATORIAL 
FREE MODULE COMPATIBLE 

return R(self.list())
*

Which gives the following error for rings and algebras using the 
CombinatorialFreeModule data structure (Because the call try to build an 
element basis from a combinatorial object (Partition, Permutation, 
Composition, ...))


*
ValueError: ['x'] is not an element of Partitions
*

So, can someone confirm it is ok to change the line in the 
change_variable_name method for:

R = PolynomialRing(self.parent().base_ring(), var)

Anyway, after that, everything should work fine :

*
sage: SF = SymmetricFunctions(QQ).schur()
sage: Id = identity_matrix(SF, 6);
sage: Id
[s[]   0   0   0   0   0]
[  0 s[]   0   0   0   0]
[  0   0 s[]   0   0   0]
[  0   0   0 s[]   0   0]
[  0   0   0   0 s[]   0]
[  0   0   0   0   0 s[]]
sage: Id._charpoly_df()
s[]*x^6 - 6*s[]*x^5 + 15*s[]*x^4 - 20*s[]*x^3 + 15*s[]*x^2 - 6*s[]*x + s[]
sage: Id.charpoly()
Traceback (most recent call last):
...
ValueError: ['x'] is not an element of Partitions
*********

Cheers,
Nicolas Borie.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.




[sage-devel] Inverse a matrix over a ring with a unit determinant

2013-07-10 Thread Nicolas Borie
on2.7/site-packages/sage/structure/parent.so 
in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6650)()


/home/nborie/sage/local/lib/python2.7/site-packages/sage/structure/misc.so 
in sage.structure.misc.getattr_from_other_class 
(sage/structure/misc.c:1606)()


AttributeError: 'SymmetricFunctionAlgebra_schur_with_category' object 
has no attribute 'fraction_field'

**

And sorry, you could not reproduce this error as it depends on a large 
part of the combinat queue and a local patch on my machine. If someone 
already fall on this for another ring... Without the pubilicity for my 
free modules, here is a simpler way to reproduced the error on a regular 
Sage 5.10 :


**
sage: SF = SymmetricFunctions(QQ).schur()
sage: Id = identity_matrix(SF, 6); Id
[s[]   0   0   0   0   0]
[  0 s[]   0   0   0   0]
[  0   0 s[]   0   0   0]
[  0   0   0 s[]   0   0]
[  0   0   0   0 s[]   0]
[  0   0   0   0   0 s[]]
sage: Id*Id
[s[]   0   0   0   0   0]
[  0 s[]   0   0   0   0]
[  0   0 s[]   0   0   0]
[  0   0   0 s[]   0   0]
[  0   0   0   0 s[]   0]
[  0   0   0   0   0 s[]]
sage: Id.inverse()
---
AttributeErrorTraceback (most recent call last)
 in ()
> 1 Id.inverse()

/home/nborie/sage/local/lib/python2.7/site-packages/sage/matrix/matrix2.so 
in sage.matrix.matrix2.Matrix.inverse (sage/matrix/matrix2.c:40647)()


/home/nborie/sage/local/lib/python2.7/site-packages/sage/matrix/matrix0.so 
in sage.matrix.matrix0.Matrix.__invert__ (sage/matrix/matrix0.c:26304)()


/home/nborie/sage/local/lib/python2.7/site-packages/sage/matrix/matrix1.so 
in sage.matrix.matrix1.Matrix.matrix_over_field 
(sage/matrix/matrix1.c:5354)()


/home/nborie/sage/local/lib/python2.7/site-packages/sage/structure/parent.so 
in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6650)()


/home/nborie/sage/local/lib/python2.7/site-packages/sage/structure/misc.so 
in sage.structure.misc.getattr_from_other_class 
(sage/structure/misc.c:1606)()


AttributeError: 'SymmetricFunctionAlgebra_schur_with_category' object 
has no attribute 'fraction_field'

**

Also, I apology for my English and don't judge the names appearing in my 
code too hardly, that's still draft code which hasn't been readed by a 
native speaker...


Cheers,
Nicolas Borie.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-devel] Re: SearchForest and post_process...

2012-10-10 Thread Nicolas Borie

Le 10/10/2012 15:53, Simon King a écrit :


Why not "RecursiveSet"? The word "Generated" seems redundant to me.

And what you tell about the role of "post_process" makes me think it could be
renamed into "branch_cut".

Best regards,
Simon

Hello,

The post_process hardly depend on a fonction (placed in itertools of 
sage) which is "imap_and_filter_none". There are two points on this 
output processing : you cut branches and you also apply an output 
fonction...


I like the Set suffix for the name. As the feature returns a parent with 
category, it seems fine for me the name should be close to blablablaSet. 
IMHO, the feature accept multiples roots but no one would search for 
"forest", we naturally search for Tree, TreeLikeStruture, ...


In an other directions, we should make a micro patch to modify the 
documentation of EnumeratedSet, FiniteEnumeratedSet, ...Set to advertise 
the user of the existance of the searchForest (old name) feature. I 
don't know if sphnix accept such references... Just putting in other doc 
: for set defined with roots and a children fonction, 
see:/SearchForest. Perhaps also, the code should be moved out from 
bactrack.py...


Cheers,
Nicolas B.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To post to this group, send email to sage-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-devel+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.




Re: [sage-devel] Re: Matrix groups from GAP

2012-07-19 Thread Nicolas Borie

Le 19/07/2012 11:17, Simon King a écrit :

Hi!

On 2012-07-19, Dima Pasechnik  wrote:

let me nitpick first by saying that in group theory=20
"presentation" means "presentation by generators and
relations" whereas you mean a (linear) "representation".

In this way of thinking, the most compact way to represent Z_n is by
generators and relations, i.e. Z_n=3D.
But of course this requires quite a bit of machinery to be useful.
Z_n can also be naturally represented as a permutation group, with=20
<(1,2,...,n)> the most straightforward one.

To me, that sounds like we should use the "parents with multiple
realisations" (recently introduced by Nicolas) as a base class for
groups. In that way, we would have an abstract group, which would then
be able to provide different realisations of itself (as permutation group,
by different faithful linear representations, by a group presentation)
and transitions between different realisations.

Perhaps Nicolas can chime in...

Best regards,
Simon


Hi all,

Currently, the most sophiticated example in Sage is probably the 
Symmetric Functions. It is an abstract parent with no element class, 
with no basis as free module. It is just an abstract Parent gluyng 
differant realizations.


*
sage: SF = SymmetricFunctions(QQ); SF
Symmetric Functions over Rational Field
sage: SF.category()
Join of Category of hopf algebras over Rational Field and Category of 
graded algebras over Rational Field and Category of coalgebras over 
Rational Field with realizations

sage: for pres in SF.realizations(): print pres
:
Symmetric Function Algebra over Rational Field, Power symmetric 
functions as basis
Symmetric Function Algebra over Rational Field, Homogeneous symmetric 
functions as basis
Symmetric Function Algebra over Rational Field, Elementary symmetric 
functions as basis
Symmetric Function Algebra over Rational Field, Schur symmetric 
functions as basis
Symmetric Function Algebra over Rational Field, Monomial symmetric 
functions as basis

sage: SF.basis()
Traceback (most recent call last):
...
AttributeError: 'SymmetricFunctions_with_category' object has no 
attribute 'basis'

sage: SF.schur().basis()
Lazy family (Term map from Partitions to Symmetric Function Algebra over 
Rational Field, Schur symmetric functions as basis(i))_{i in Partitions}

*

Now, I am not sure but I really think the Realizations framework is 
adapted to any kind of parent (Any Group should work fine...)


Here is the structure of the code to declare practical realizations of 
an abstract parent.

**
class MyAbstractParent(UniqueRepresentation, Parent):
def __init__(self, foo):
Parent.__init__(self, bla, category = ( 
cat1.WithRealizations(), cat2,  cat3, ... ) )


def realization_as_bla(self):
return PracticalRealization1( good_args )

...

class PracticalRealization1(UniqueRepresentation, Parent):
def __init__(self, foo3):
Parent.__init__(self, bla2, category = ( 
Realizations(MyAbstractParent), cat4, cat5, ... ) )


...

class Element( Good_data_structure_class ):
...
**

I don't really know what are the good pointers for the documentation. 
One can read :

sage: Realizations??
sage: SymmetricFunctions??

As I am only a level 1 sage contributor with categories, I can't tell 
you how to implement morphisms between the differents realizations. But 
that's clearly the second step (and the interessting one!!). The 
TestSuite is already aware of abstract parent and their different 
realizations.


Hope that would help a little.
Best regards,
Nicolas B.

P.S. : Nicolas (Thiéry) is probably not availlable for a time...

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





Re: [sage-combinat-devel] Re: [sage-devel] Free groups, feedback wanted.

2012-01-23 Thread Nicolas Borie
Le lundi 23 janvier 2012 à 03:58 -0800, Dima Pasechnik a écrit :
> Given that Chevie needs Maple, it can be regarded as "highly
> optional". 

Hello Dima,

If you are a Chevie lover, you can already have it in Sage in a fully
open-source way. As Jean pointed out, Chevie is also a GAP'3' <--
package. For this reason, Franco took the time to implement an optional
interface to Gap3 (see #8380 and thanks to Franco one more time). That
still optional but that's not a Maple constraint...

Cheers,
Nicolas.

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


Re: [sage-devel] Free groups, feedback wanted.

2012-01-22 Thread Nicolas Borie
Le dimanche 22 janvier 2012 à 11:37 -0800, mmarco a écrit :
> I am trying to implement free groups, finitely presented groups and
> braid groups in sage. So far i have writen a proof of concept for the
> free groups (see ticket 12339), but i don't have any experience with
> the category and coercion frameworks.
> 
> Any feedback and/or colaboration would be most welcome.

Hello,

Some veterans of the sage combinat community have probably already
"think" about adding free groups and braid groups in Sage. It was
perhaps discussed during the sage-gap_chevie meeting last year, I don't
remember. For this reason, I also send this topic to
sage-combinat-devel.

You should look at some examples already in Sage (and there is not
enough example for now...). I added an example of group using the
category framework some time ago (with an expert under my shoulder (my
thesis advisor : Nicolas Thiéry)). Categories are in the file :
sage/categories/...your...category...py
and some of these categories have example in the file :
sage/categories/examples/...your...category...py

You should look in examples how to initialize properly the category of
the parent and where place the element class, look also at the
conventional name of methods (I think identity_element() should be
one()), ...

A nice entrance point for the categories is:
sage: sage.categories.primer?
I can assure you that the authors will be VERY VERY happy to get some
comments about this primer, feel free to post them on
sage-combinat-devel.

The first time with categories will cost you some time to adapt your
code to the framework but it produced a more robust code, more
factorized code and better tests. 

Look at the Dihedral groups in the file : 
sage/categories/examples/finite_coxeter_groups.py
250 lines allows you to benefit of functorial construction as follows
(here the group algebra of a group):

sage: D5 = DihedralGroup(5); D5
Dihedral group of order 10 as a permutation group
sage: TestSuite(D5).run(verbose=True)
running ._test_an_element() . . . pass
running ._test_associativity() . . . pass
running ._test_category() . . . pass
running ._test_elements() . . .
  Running the test suite of self.an_element()
  running ._test_category() . . . pass
  running ._test_eq() . . . pass
  running ._test_not_implemented_methods() . . . pass
  running ._test_pickling() . . . pass
  pass
running ._test_elements_eq() . . . pass
running ._test_enumerated_set_contains() . . . pass
running ._test_enumerated_set_iter_cardinality() . . . pass
running ._test_enumerated_set_iter_list() . . . pass
running ._test_eq() . . . pass
running ._test_inverse() . . . pass
running ._test_len() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_one() . . . pass
running ._test_pickling() . . . pass
running ._test_prod() . . . pass
running ._test_some_elements() . . . pass
sage: GA_D5 = D5.algebra(QQ); GA_D5
Group algebra of Dihedral group of order 10 as a permutation group over
Rational Field
sage: p = GA_D5.an_element(); p
B[()] + 2*B[(2,5)(3,4)] + 3*B[(1,2)(3,5)] + B[(1,2,3,4,5)]
sage: (p+1)^2
17*B[()] + 11*B[(2,5)(3,4)] + 14*B[(1,2)(3,5)] + 10*B[(1,2,3,4,5)] +
3*B[(1,3)(4,5)] + B[(1,3,5,2,4)] + 6*B[(1,5,4,3,2)] + 2*B[(1,5)(2,4)]
sage: TestSuite(GA_D5).run(verbose=True)
running ._test_additive_associativity() . . . pass
running ._test_an_element() . . . pass
running ._test_associativity() . . . pass
running ._test_category() . . . pass
running ._test_distributivity() . . . pass
running ._test_elements() . . .
  Running the test suite of self.an_element()
  running ._test_category() . . . pass
  running ._test_eq() . . . pass
  running ._test_not_implemented_methods() . . . pass
  running ._test_pickling() . . . pass
  pass
running ._test_elements_eq() . . . pass
running ._test_eq() . . . pass
running ._test_len() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_one() . . . pass
running ._test_pickling() . . . pass
running ._test_prod() . . . pass
running ._test_some_elements() . . . pass
running ._test_zero() . . . pass


Checking the TestSuite is an excellent way to verify you correctly use
the category framework. (necessary but not sufficient)

This was just a small tour about the categories and some expert will
probably tell better advises than me. Also sorry for my English.

Cheers,
Nicolas Borie.

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


Re: [sage-devel] where to put Sidon g-sets?

2011-07-25 Thread Nicolas Borie
Le lundi 25 juillet 2011 à 04:47 -0700, Martin Raum a écrit :
> Hello all,

Hello Martin,

> I happened to think about Sidon g-sets and to do some computations I
> implemented a recursive enumeration of such sets. Clearly, this would
> go into the combinatorics tree. I am not an expert in combinatorics.
> Since the code doesn't seem to fit in any of the files in sage/
> combinat, please could anybody point out the right place put it? I
> will then open a ticket with an according patch.

Creating a new file sidon_sets.py in root_sage/sage/combinat/ seems a
nice solution for such an enhancement. There are a lot of files inside
the folder but I think it is the first place anybody would search in
first.

Although a lot of people are in holidays, if you need more advises for
this implementation, you can also post to the sage-combinat-devel google
group.

Cheers,
Nicolas B.

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


Re: [sage-devel] Re: Coxter Groups

2011-07-25 Thread Nicolas Borie
Le dimanche 24 juillet 2011 à 15:38 -0700, Dima Pasechnik a écrit :
> On Sunday, 24 July 2011 22:37:05 UTC+1, Rafael T wrote:
> 
> The gap-system already has the ability to work with Coxeter
> groups: 
> http://www.gap-system.org/Gap3/Manual3/C075S005.htm Maybe I
> could use 
> some of their code? 

> GAP 3 (not the current GAP 4) has it, as an interface to a package
> called Chevie (written mostly in Maple, if I recall right),  but it's
> rather old unmaintained stuff.

I can't manage to use it now... So, it is perhaps broken these days (the
sage-combinat queue of patches is relatively experimental...).

To get the implementation of Coxeter groups in Sage, there is a lot of
things to do yourself.


See : 

print gap3._install_hints()

Your attempt to start GAP3 failed, either because you do not have
have GAP3 installed, or because it is not configured correctly.

- If you do not have GAP3 installed, then you must download and
  install it yourself because it is not distrubuted with Sage.
  Here are some ways to obtain GAP3:

- There is an optional Sage package providing GAP3 pre-packaged
  with several GAP3 packages:
http://trac.sagemath.org/sage_trac/ticket/8906

- Frank Luebeck maintains a GAP3 Linux executable, optimized
  for i686 and statically linked for jobs of 2 GByte or more:
http://www.math.rwth-aachen.de/~Frank.Luebeck/gap/GAP3

- Jean Michel maintains a version of GAP3 pre-packaged with
  CHEVIE and VKCURVE. It can be obtained here:
http://people.math.jussieu.fr/~jmichel/chevie/chevie.html

- Finally, you can download GAP3 from the GAP website below.
Since
  GAP3 is no longer an officially supported distribution of GAP,
it
  may not be easy to install this version.
http://www.gap-system.org/Gap3/Download3/download.html

- If you have GAP3 installed, then perhaps it is not configured
  correctly. Sage assumes that you can start GAP3 with the command
  /opt/gap3r4p4/bin/gap.sh. Alternatively, you can use the following
command
  to point Sage to the correct command for your system.

  gap3 = Gap3(command='/usr/local/bin/gap3')



Once you will have gap3 on your computer, it is not still ended. You
will have to make Sage know there Gap3 and chevie available.

On my computer, gap3 is at /opt/gap3r4p4/ . I tell it to sage like :

gap3 = Gap3(command='/opt/gap3r4p4/bin/gap.sh')

after that, i can do :
sage: gap3.console()
 
 Lehrstuhl D fuer
Mathematik 
   ###   RWTH
Aachen 
  ##
##  
 ##  # ###
#  
###  ##  ## #
## 
##   #   #   ## #
##
##   ##   # #
##
 # ###   ##  ## ##
## 
   # ##
###  
 #
#
##   Version 3
#
   ###   Release 4.4
#
  ## #   18 Apr 97
#
 ##
#   
##   #  Alice Niemeyer, Werner Nickel,  Martin
Schoenert 
   ###  Johannes Meier, Alex Wegner,Thomas
Bischops  
  ## #  Frank Celler,   Juergen Mnich,  Udo
Polis
  ###   ##  Thomas Breuer,  Goetz Pfeiffer, Hans U.
Besche   
   ##   Volkmar Felsch, Heiko Theissen, Alexander
Hulpke 
Ansgar Kaup,Akos Seress,Erzsebet
Horvath 
Bettina
Eick 
For help
enter: ?
gap> RequirePackage("chevie"); 

  Welcome  to  the  CHEVIE  package,  Version 4.devel (Feb 2010)
http://www.math.rwth-aachen.de/~CHEVIE for the stable version 3.1
http://www.math.jussieu.fr/~jmichel/chevie for this version

 Meinolf Geck,  Frank Luebeck,   Gerhard Hiss, 
 Gunter Malle,  Jean Michel, Goetz Pfeiffer
 Lehrstuhl D fuer Mathematik, RWTH Aachen
 Universit'e Paris VII
 AG Computational Mathematics Universit"at Kassel
 Galway University

   This replaces the former weyl package. For first help type
  ?CHEVIE Version 4 -- a short introduction

gap> quit;;
sage: 

***

[sage-devel] Re: Iterators for various structures

2010-08-02 Thread Nicolas Borie
Hello,

I put a message on the trac 8361...

I still work on the SearchForest feature (and rebase it because it no
longer worked with 4.5.2). But it is definitely right that an iterator
of IntergerVectors doesn't deserve to use the SearchForest engine
(SearchForest is only adapted for poor tree-like structure,
IntegerVectors are a too much rich structure and need a proper
code...). This ticket sleep a very long time due to my fault and in
spite of I opened it, I have no really good mathematical argument or
idea to produced a good method. Fell free to give any proposition and
assign to anyone the ticket.

For information, I don't think the combinat community use this code
(It'a has been broken the whole last month on the combinat
repository...) as no one already asked me to clean it.

Sorry for my English and many thanks for your comments and the time
took to deal with this ticket.

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


[sage-devel] Name for NonNegativeIntegers

2010-05-31 Thread Nicolas Borie
Hello all!

I have a language question: which one of the following is the correct
name for the semiring of non-negative integers:

 - NonNegativeIntegerSemiring
 - NonNegativeIntegersSemiring

On IRC, Tim suggested :
(12:15:44) nborie: English Language question : we say Integer Ring,
not Integers Ring. What about Non Negative Integers ? Non Negative
Integer(s) Semiring ?
(12:16:18) timdumol: Non-negative Integer Semiring
(12:16:45) timdumol: Plurals are not generally used (if at all) as
noun adjectives.

I found both in sage :

 - ModularFormsRing
 - IntegerRing

Cheers,
Nicolas (the little).

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


[sage-devel] Build a FreeModule with a step by step construction...

2010-03-17 Thread Nicolas Borie
Hello,

As often in algebraic combinatoric, I compute very very huge
FreeModule/VectorSpace... Let's me give some examples :

- I have a Matrix algebra (Hecke like) defined by a set of 5 matrices
of size factorial(5)*factorial(5) and I want to get a basis this
algebra as a VectorSpace over Q. For that, I start with the
VectorSpace empty and I had the generator, thus the product of length
2 over the generators, product on length 3, ... I stop when I have
stability of the product. (I won't speak about the optimizations of
this problem)

- Currently, for the ring of invariants multivariate polynomials under
the action of a permutation group.
For the cyclic group of order 8, I have a Vector space of dimension
factorial(7) with a number of generators close to factorial(7) and
whose coefficients leave in a cyclotomic field of degree(8). The point
of the problem is : you have a graded algebra in which you know the
generators as VectorSpace degree by degree and now, you want the
generator as an algebra...
degree 0 : just the one --> one algebra generator
degree 1 : I take a basis --> new algebra generators
degree 2 : I compute all product v_1*v_2 with the algebra generator of
degree 1. I make a gauss reduction and to complete this degree, I take
a basis of this degree and check each vector is already inside,
otherwise I have to add them as algebra generators.
...
degree n : All products of generators less than n, first gauss
reduction and a search of missing generators for this degree.

Sorry for this two technical examples, The point is, in this case of
problems, the elementary operation (And very very expansive operation)
is the following one :

K is any field. and n an integer. (mind n is very big)

Data : A subspace `E` of K^n with a basis already echelonized and a
vector `v` of K^n.

What I want :
if `v` in `E` --> the coordinates of `v` in `E`
if `v` not in `E` --> I want to add it in `E` and I want to get back
the transformation of `v` once it is echelonized in `F` = `E`+.

Mathematically : It is possible to do that with a single
echelonization of `v`. I want also a possibility to skip the tests.

***
My first code was:
if v in E:
F = Ambient.Subspace(E.basis()+[v])
else:
E.coordinates(v)

# How many echelonization ? How many checks over an already
echelonized vector?
***
And now:
***
dimE = E.dimension()
F = Ambient.Subspace(E.basis()+[v])
if F.dimension() > DimE:
--> Some job
Else:
--> Other Job

# How many echelonization ? How many checks over an already
echelonized vector?
***

I need some advises about :
- How to do that in Sage ?
- Does I miss it ? perhaps it is already in sage...
- Advises for describing a ticket (if needed) and name of a such
method (E.add_new_generator(v), check=False) ?

Thanks in advanced,
Cheers,
Nicolas the little.

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