[PYTHON MATRIX-SIG] type coercion one more time

James Hugunin jjh@Goldilocks.LCS.MIT.EDU
Thu, 25 Jan 96 11:40:49 EST


   From: "Perry A. Stoll" <stoll@atr-sw.atr.co.jp>

       JH> I do have one other possible set of rules that I would be
       JH> happy with.  These are basically the same as the last post,
       JH> except:

       JH> 4) Coercion to a higher precision is allowed within the main
       JH> groupings.

       JH> 5) The precision of a python scalar is allowed to change to
       JH> match the other arguments (3.14 can be either a float or a
       JH> double depending on which one is "desired").

       JH> Do people prefer this revised scheme?

   So you try to coerce a scalar to the type of the matrix, using
   the same idea as in 4)? Is the following right?

   Array_SomeIntType   * AnyIntType     =  Array_SomeIntType
   Array_SomeIntType   * SomeFloatType  =? Array_SomeFloatType
   Array_SomeFloatType * AnyIntType     =? Array_SomeFloatType
   Array_SomeFloatType * OtherFloatType =  Array_SomeFloatType

   That seems pretty reasonable. Do the '=?' cases sound ok? It should
   preserve coercions with the normal Python types. Users of specialized
   C type multiarrays must exercise a bit of caution that they don't
   cause overflow, but that isn't unreasonable.

   -Perry

This is exactly what I'm proposing (change the '=?' to '=').  The fact
that it seems to make sense to you is a good sign that it might be
reasonable.

-Jim

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================