[Matrix-SIG] I have working code that implements active-casting concept.
Rob W. W. Hooft
rob@hooft.net
Thu, 20 Jan 2000 07:52:18 +0100 (MET)
>>>>> "TO" == Travis Oliphant <Oliphant.Travis@mayo.edu> writes:
TO> When a universal function involving NumPy arrays is encountered,
TO> if all arrays are passive (active flag = 0) then the current
TO> coercion rules are used. If any of the arguments to the function
TO> are active arrays, then the active array with the largest
TO> typecode (enumerated types in arrayobject.h) determines the
Ah, so not the one with the greatest activity...
TO> output types. All other arrays are automatically cast (even if
TO> it means loss of precision) to that type, before the operation
TO> begins. The output arrays from the function are all active
TO> arrays.
This is a great idea, and it will certainly simplify my code. However,
I'd like to raise one point of concern:
I am using some functions that use 2 arrays: a small one, used repeatedly
and a big one that changes on every invocation. If the small array is
passive-d and the big one is active-f, this will cast the small one
to 'f' on every invocation. Without the active/passive patch, I'd find
out about this inefficiency because the result would be of type 'd'. Would
there be any way of warning the programmer for this kind of inefficient
casting with the new code?
Regards,
Rob Hooft
--
===== rob@hooft.net http://www.xs4all.nl/~hooft/rob/ =====
===== R&D, Nonius BV, Delft http://www.nonius.nl/ =====
===== PGPid 0xFA19277D ========================== Use Linux! =========