On Thu, May 15, 2008 at 8:16 AM, kcrisman <[EMAIL PROTECTED]> wrote:
>
>
>
> On May 15, 10:55 am, "William Stein" <[EMAIL PROTECTED]> wrote:
>> On Thu, May 15, 2008 at 7:48 AM, Jason Grout
>>
>>
>>
>> <[EMAIL PROTECTED]> wrote:
>>
>> > Jason Grout wrote:
>> >> Based on some conversations with linear algebra people and classroom
>> >> demonstrations in a linear algebra class, people are confused that when
>> >> they create a matrix with matrix(3, range(9)), for example, that the
>> >> echelon_form is not the rref output that they get from most any other
>> >> program they have ever used, and certainly not what is taught in an
>> >> undergrad linear algebra class.  There is additional confusion if the
>> >> entries specified have a fraction in them; then the matrix defaults to
>> >> being over QQ, and the echelon_form functino gives the expected naive
>> >> rref!  The problem, of course, lies in the matrix defaulting to having
>> >> base_ring == ZZ (i.e., non-field).
>>
>> >> What do people think about making the default ring for matrices QQ?
>> >> Additionally, if the ring R is determined from the elements provided,
>> >> then the matrix would be over R.fraction_field().  Of course, the
>> >> documentation for matrix() would clearly indicate what is happening if
>> >> the ring is not specified.
>>
>> > More concisely, this proposal could be worded:
>>
>> > What do people think of making matrix() return a matrix over a field by
>> > default, unless a ring is explicitly specified.  The default field would
>> > either be the fraction field of the ring containing the specified
>> > elements, or would be QQ if no elements are specified.  This logic would
>> > *only* be applied if a ring is not specified.  The documentation of
>> > matrix() would also be changed accordingly.
>>
>> +1
>>
>> I suggested this idea.  I would never do this is Sage were "just for me",
>> but Sage isn't.  Please keep that in mind when reading the above proposal...
>>
>>  -- William
>
> I was just discussing this very issue with my chair yesterday.  He had
> created some wrappers to make using the elementary operations a little
> easier for linear algebra students (though I think ended up sticking
> with Octave for this semester for unrelated reasons), and then noticed
> this with scaling rows under his first implementation.
>
> What happens if you start with something like matrix(3, range(9)), but
> then want to turn it into a complex matrix and scale a row by (say) i/
> 2?

That would work fine.  What you're really asking about is making
the function rescale row on an *integer* or rational matrix automatically
change the base ring to complex.  I think that is very reasonable and
would be fine with that.  It is somewhat orthogonal to Jason's proposal
though.

> Under the current scaling code, this happens:
>
> sage: N.rescale_col(2,i/2)
> ---------------------------------------------------------------------------
> <type 'exceptions.TypeError'>             Traceback (most recent call
> last)
> <snip>
> <type 'exceptions.TypeError'>: unable to convert I/2 to a rational
>
> I certainly have no problem with matrices starting off as rational
> ones - a great idea!  But it doesn't directly affect this sort of
> issue - one could still start with a matrix over ZZ and then want to
> multiply it later on by 1/2 without using change_ring().

Yep, this is orthogonal.  You're just suggesting that scale_row
be improved.

>
> What I am wondering is whether throwing an exception of TypeError
> under the current code should be replaced by a try statement first
> attempting N.changering(??) . The problem is I have no idea what to
> use for ??, because unfortunately i/2 lives in Symbolic Ring, not in
> CC, so I can't just put in ??=parent(i/2).

The Sequence constructor is the canonical answer to this question.
Given any list v of Sage object it will find a canonical place to put
them all:

sage: v = [3, I/2]
sage: w = Sequence(v)
sage: w
[3, I/2]
sage: w.universe()
Symbolic Ring

>  It would sort of be beside
> of the point of making Sage easier to use in the linear algebra
> classroom if we had to explicitly type CC(i/2) everytime we wanted to
> use i/2.
>
> In any case, what "should" happen in the scaling context when scaling
> by something mathematically legitimate, but not in the ring the matrix
> is defined over in Sage?
>
> - kcrisman
>
> (By the way, the wrapper code is nice and well-documented, at
> https://sage.math.gordon.edu/home/pub/1/)

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to