Opened 10 years ago

Last modified 7 years ago

#11596 needs_work defect

Cached eigenstuff is mutable

Reported by: rbeezer Owned by: jason, was
Priority: major Milestone: sage-6.4
Component: linear algebra Keywords:
Cc: jason, simonking Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Ooops.

sage: A = matrix(QQ, 2, 2, range(4))
sage: ev = A.eigenvalues()          
sage: ev
[-0.5615528128088302?, 3.561552812808830?]
sage: ev[0]=300                     
sage: A.eigenvalues()                
[300, 3.561552812808830?]

I suspect eigenspaces and eigenmatrices might also need a look.

Attachments (2)

trac-11596-copy-cache-data.patch (2.4 KB) - added by jason 9 years ago.
Not tested; definitely needs work
trac_11596-immutable.patch (3.4 KB) - added by jhpalmieri 9 years ago.
a different take

Download all attachments as: .zip

Change History (15)

comment:1 Changed 9 years ago by jason

  • Cc jason added

comment:2 Changed 9 years ago by jason

Change this in the def eigenvalues():

        x = self.fetch('eigenvalues')
        if not x is None:
            if not extend:
                x1=Sequence([])
                for i in x:
                    if i in self.base_ring():
                        x1.append(i)
                x=x1
            return x

to this (add an else...)

        x = self.fetch('eigenvalues')
        if not x is None:
            if not extend:
                x1=Sequence([])
                for i in x:
                    if i in self.base_ring():
                        x1.append(i)
                x=x1
            else:
                x = copy(x)
            return x

comment:3 Changed 9 years ago by jason

(that's in matrix/matrix2.pyx)

comment:4 Changed 9 years ago by jason

And also change at the bottom of the function to return a copy of V

Changed 9 years ago by jason

Not tested; definitely needs work

comment:5 Changed 9 years ago by jason

  • Status changed from new to needs_review

comment:6 Changed 9 years ago by jason

  • Status changed from needs_review to needs_work

comment:7 Changed 9 years ago by jhpalmieri

I just noticed this ticket, too. Here's my version of a patch. Maybe we can combine the best of the two of them to get a single patch.

Changed 9 years ago by jhpalmieri

a different take

comment:8 Changed 9 years ago by jhpalmieri

(I searched for cached information in matrix2.pyx and tried to fix anything which was not already immutable.)

comment:9 Changed 9 years ago by jason

  • Cc simonking added

Ah, I forgot that you can have an immutable sequence. Nice.

Also, I wonder if we can use Simon King's work on cached methods? CCing him to get his thoughts.

comment:10 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:11 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:12 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:13 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.