Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#6005 closed defect (duplicate)

real and imaginary parts for quadratic number fields

Reported by: robertwb Owned by: davidloeffler
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: number fields Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description


Attachments (2)

6005-qnf-real-imag.patch (4.3 KB) - added by robertwb 12 years ago.
6005-qnf-real-imag-fix.patch (2.1 KB) - added by robertwb 12 years ago.

Download all attachments as: .zip

Change History (9)

Changed 12 years ago by robertwb

comment:1 Changed 12 years ago by was

  • Summary changed from [with patch, needs review] real and imaginary parts for quadratic number fields to [with patch, needs speedup] real and imaginary parts for quadratic number fields
sage: K.<i> = QuadraticField(-1) 
sage: i.imag()
1

The above is hundreds of times slower than i.real(). That needs to be fixed.

it's because of this line

Changed 12 years ago by robertwb

comment:2 Changed 12 years ago by robertwb

  • Summary changed from [with patch, needs speedup] real and imaginary parts for quadratic number fields to [with patch, needs review] real and imaginary parts for quadratic number fields

Now

sage: K.<i> = QuadraticField(-1)
sage: timeit("i.imag()")
625 loops, best of 3: 9.73 µs per loop

comment:3 Changed 12 years ago by was

  • Summary changed from [with patch, needs review] real and imaginary parts for quadratic number fields to [with patch, positive review] real and imaginary parts for quadratic number fields

comment:4 Changed 12 years ago by mabshoff

  • Summary changed from [with patch, positive review] real and imaginary parts for quadratic number fields to [with patch, needs work] real and imaginary parts for quadratic number fields

The two patches cause doctest failures in one file:

sage -t -long "devel/sage/sage/rings/number_field/number_field.py"
**********************************************************************
File "/scratch/mabshoff/sage-4.0.alpha0/devel/sage/sage/rings/number_field/number_field.py", line 5512:
    sage: F, F_into_L, _ = L.subfields(2)[0]; F  
Exception raised:
    Traceback (most recent call last):
      File "/scratch/mabshoff/sage-4.0.alpha0/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/scratch/mabshoff/sage-4.0.alpha0/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/scratch/mabshoff/sage-4.0.alpha0/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_124[42]>", line 1, in <module>
        F, F_into_L, _ = L.subfields(Integer(2))[Integer(0)]; F###line 5512:
    sage: F, F_into_L, _ = L.subfields(2)[0]; F  
      File "/scratch/mabshoff/sage-4.0.alpha0/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py", line 4676, in subfields
        both_maps=True, optimize=False)
      File "/scratch/mabshoff/sage-4.0.alpha0/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py", line 4733, in _subfields_helper
        K = NumberField(f, names=name + str(i), embedding=embedding)
      File "/scratch/mabshoff/sage-4.0.alpha0/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py", line 423, in NumberField
        K = NumberField_quadratic(polynomial, name, check, embedding)
      File "/scratch/mabshoff/sage-4.0.alpha0/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py", line 6852, in __init__
        self._standard_embedding = RDF(rootD) > 0
      File "parent.pyx", line 288, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:4121)
      File "coerce_maps.pyx", line 81, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3064)
      File "coerce_maps.pyx", line 76, in sage.structure.coerce_maps._call_ (sage/structure/coerce_maps.c:2955)
      File "real_double.pyx", line 525, in sage.rings.real_double.RealDoubleElement.__init__ (sage/rings/real_double.c:5668)
    TypeError: float() argument must be a string or a number
**********************************************************************
<SNIP>

Cheers,

Michaep

comment:5 Changed 12 years ago by davidloeffler

  • Component changed from number theory to number fields
  • Owner changed from was to davidloeffler

comment:6 Changed 11 years ago by robertwb

  • Milestone changed from sage-4.5.2 to sage-duplicate/invalid/wontfix
  • Report Upstream set to N/A
  • Resolution set to duplicate
  • Status changed from needs_work to closed

comment:7 Changed 11 years ago by mvngu

  • Summary changed from [with patch, needs work] real and imaginary parts for quadratic number fields to real and imaginary parts for quadratic number fields
Note: See TracTickets for help on using tickets.