On 1/12/07, David Cournapeau <[EMAIL PROTECTED]> wrote:
On 1/13/07, Christopher Barker <[EMAIL PROTECTED]> wrote: > I think it may have all been cleared up now, but just in case: > > but how do you get single strided? this is what always made it hard for > me to know how to write this kind of code.
<snip> Make a copy of the array. New copies are C_CONTIGUOUS by default. There is also the ascontiguousarray function: ascontiguousarray(a, dtype=None) Return 'a' as an array contiguous in memory (C order). Which makes a copy only when required. Since clip returns a new array anyway, this shouldn't be a problem except when clipping against another array, which you would also want to be contiguous. In practice, I don't think using ascontiguousarray for the clipping array would add much overhead as the array would likely be contiguous in the first place. You would probably want to match data types also. I think the needed ops are already implemented for the types at the c-level, __gt__ for instance, and in that case you can simply use the function pointer with some loss of speed. If you can determine the corresponding c-type, and I think you can, then it shouldn't be too much trouble to implement type specific clipping, but it might not be worth the effort. There are lots of code snippets in other functions similar to what you need that could be a good starting point. You just need to find them 8^) Chuck
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion