[Matrix-SIG] I have working code that implements active-castingconcept.
Rob W. W. Hooft
rob@hooft.net
Thu, 20 Jan 2000 10:24:37 +0100 (MET)
>>>>> "TO" == Travis Oliphant <Oliphant.Travis@mayo.edu> writes:
>> 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?
TO> Let me see if I understand: You want to be able to catch that you
TO> are casting the passive array on every function call (presumably
TO> so you can change it and cast once)?
TO> Right now you have to check the output type, correct?
Right now I know I have a problem when the program slows down to 0 Kelvin.
Then I start looking for a d-array that makes everything go d.
TO> With the current changes in CVS, the result would be of type
TO> 'active-f' which is not the type of the small input array, so you
TO> could just check to make sure the types are the same. What am I
TO> missing?
You're speaking about the program checking, I used to detect the
problems using "wall-clock-profiling".
TO> Another person wanted two "active" arrays of different types to
TO> raise an exception, so with that change you would make both
TO> arrays active and if they were not the same type an error would
TO> occur. What do you think?
That would be one way to do it, but most tricks require me to think
whenever I use a new array, and if I am thinking, I can just as well
add ",'f'" to the instantiation in the first place..... I'm trying
to catch thinkos.
Dumb alternative suggestions:
- active=-1 means complain if you need to down-cast another array
(i.e. non-scalar).
- in some sort of debugging mode, keep a count of the number of times
each array is down-casted, and raise InefficientCode("Frequent
down-cast") if this happens often.
Don't get me wrong here: I really think your code is a great improvement,
and the point I'm raising is really of secondary importance (even to me).
Rob
--
===== rob@hooft.net http://www.xs4all.nl/~hooft/rob/ =====
===== R&D, Nonius BV, Delft http://www.nonius.nl/ =====
===== PGPid 0xFA19277D ========================== Use Linux! =========