Opened 8 years ago

Closed 7 years ago

#8670 closed enhancement (fixed)

Provide projections methods for word paths

Reported by: slabbe Owned by: slabbe
Priority: major Milestone: sage-4.7
Component: combinatorics Keywords:
Cc: abmasse, vdelecroix, robertwb, tjolivet, tmonteil Merged in: sage-4.7.alpha2
Authors: Sébastien Labbé Reviewers: Franco Saliola, Timo Jolivet
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by slabbe)

Nice mathematical objects can be obtained when projecting appropriately a discrete path (Rauzy fractals for instance).

This patch introduces 3 projection functions for word path. It also adds 2 functions to WordMorphism and 2 matrix rotation functions to sage/matrix/constructor.py.

The first 1000 points of the Rauzy fractal :

    sage: s = WordMorphism('1->12,2->13,3->1')
    sage: D = s.fixed_point('1')
    sage: v = s.pisot_vector()
    sage: P = WordPaths('123',[(1,0,0),(0,1,0),(0,0,1)])
    sage: w = P(D[:1000])
    sage: w.projected_plot(v)

See more examples in doctests.

Attachments (4)

trac_8670-word-path-projection-sl.patch (23.3 KB) - added by slabbe 8 years ago.
Does not depend on any known patch. Applies on 4.3.4.
trac_8670-review-sl.patch (4.4 KB) - added by slabbe 7 years ago.
Applies over the precedent patch
trac_8670_second_corrections-sl.patch (17.8 KB) - added by slabbe 7 years ago.
Applies over the precedent 2 patches
trac_8670_folded-sl.patch (25.6 KB) - added by slabbe 7 years ago.
Apply only this one.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 8 years ago by slabbe

  • Cc abmasse vdelecroix added
  • Status changed from new to needs_review

comment:2 Changed 8 years ago by slabbe

  • Status changed from needs_review to needs_work

There are some limit case problems :

sage: from sage.plot.plot3d.transform import *
sage: rotate_vector_on_axis((1,0,0), 0)
Traceback (most recent call last):
...
ZeroDivisionError: Rational division by zero

Will post a new patch soon.

comment:3 Changed 8 years ago by slabbe

  • Cc robertwb added
  • Status changed from needs_work to needs_review

I fixed the above problem in the updated patch. Needs review!

Since I am adding two functions to the file sage/plot/plot3d/transform.pyx, I am also adding Robert Bradshaw in cc of this ticket. He might have some comments to share.

Changed 8 years ago by slabbe

Does not depend on any known patch. Applies on 4.3.4.

comment:4 Changed 7 years ago by saliola

  • Status changed from needs_review to needs_work
  1. Your definition of Pisot eigenvector is ambiguous.
    Returns the left eigenvector of the incidence matrix associated
    to the largest eigenvalue (in absolute value).
    

It is possible that there are multiple eigenvalues with the same absolute value:

sage: mu = WordMorphism('a->c,b->c,c->ab')
sage: m = matrix(mu); m
[0 0 1]
[0 0 1]
[1 1 0]
sage: m.eigenvalues()
[0, -1.414213562373095?, 1.414213562373095?]

It is not clear which eigenvector gets returned here.

Also, there may be more than one eigenvector associated to your "maximal" eigenvalue, and your method only returns one eigenvector:

sage: mu = WordMorphism('a->a,b->b,c->abc')
sage: mu.pisot_eigenvector_left()
(1, -1, 0)
sage: m = matrix(mu); m
[1 0 1]
[0 1 1]
[0 0 1]
sage: m.eigenspaces_left()
[
(1, Vector space of degree 3 and dimension 2 over Rational Field
User basis matrix:
[ 1 -1  0]
[ 0  0  1])
]
  1. The method directive_vector should include a definition of what the directive vector is.
  1. In your functions rotate_ith_to_zero and rotate_vector_on_axis, you first construct the matrix and then coerce it into the ring specified by the user. Why is this preferable to doing the computations directly in the ring? What about making this an option compute_in_ring=False? I think all you need to do is add the following line at the beginning:
    if compute_in_ring is True:
        v = vector(ring, v)
    

comment:5 Changed 7 years ago by slabbe

  • Status changed from needs_work to needs_review

Needs review again!

Changed 7 years ago by slabbe

Applies over the precedent patch

comment:6 Changed 7 years ago by tjolivet

  • Cc tjolivet added

comment:7 Changed 7 years ago by tmonteil

  • Cc tmonteil added

comment:8 Changed 7 years ago by tjolivet

  • Description modified (diff)
  • Status changed from needs_review to needs_work

Hi,

Here are a few remarks:

(1) There is a doctest failure:

File "/home/timo/sage-4.6.1/devel/sage-trac_8670/sage/plot/plot3d/transform.pyx", line 325: sage: rotate_vector_on_axis(v, 0, ring=RealField(10)) * vExpected: (5.5, 0.0020, 0.0020, 0.00)Got: (5.5, 0.00098, 0.00098, 0.00)

This should be fixed by using "...", and could be done for the other occurrences of printed floats.

(2) I think that the rotations matrices should be in a file in sage/matrix/. I remember having looked for something like rotate_arbitrary, but I didn't find it because it was in plot3d/ and not in matrix/.

(3) The documentation for rotate_vector_on_axis could be a little bit clearer (the description).

Otherwise this is a nice and useful patch.

Changed 7 years ago by slabbe

Applies over the precedent 2 patches

comment:9 Changed 7 years ago by slabbe

  • Status changed from needs_work to needs_review

Thanks for the comments. I moved the two rotation matrix constructor to the file sage/matrix/constructor.py. I improved the docstrings and fixed the doctest failure (I was having the same).

Needs review.

comment:10 Changed 7 years ago by slabbe

  • Description modified (diff)

Changed 7 years ago by slabbe

Apply only this one.

comment:11 Changed 7 years ago by slabbe

For the patchbot :

Apply trac_8670_folded-sl.patch

comment:12 Changed 7 years ago by tjolivet

  • Authors set to Sébastien Labbé
  • Reviewers set to Franco Saliola, Timo Jolivet
  • Status changed from needs_review to positive_review

comment:13 Changed 7 years ago by jdemeyer

  • Milestone changed from sage-4.6.2 to sage-4.7

comment:14 Changed 7 years ago by jdemeyer

  • Merged in set to sage-4.7.alpha2
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.