octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: surface cdata property restricted to double or uint8


From: Shai Ayal
Subject: Re: surface cdata property restricted to double or uint8
Date: Mon, 30 Aug 2010 07:21:29 +0300

On Mon, Aug 30, 2010 at 12:00 AM, John W. Eaton <address@hidden> wrote:
> On 29-Aug-2010, Shai Ayal wrote:
>
> | On Fri, Aug 27, 2010 at 7:02 PM, John W. Eaton <address@hidden> wrote:
> | >
> | > Why are the surface cdata and alphadata properties restricted to
> | > double or uint8 arrays?  I see that this restriction is documented for
> | > Matlab, but is there any reason we can't allow other data types for
> | > these properties?  At the very least, why isn't single allowed?
> | >
> | > See also bug #30877.
> |
> | I see no reason for the restriction, but relaxing it would have to be
> | reflected in the convert_cdata function in graphics.cc
> | I think that for the sake of optimization it accesses the underlaying
> | c-array for cdata. However this means it has to do all the type
> | conversions. How slower would it be if we access the cdata elements
> | using octave's element operator, which will do type conversions for us
> | auto-magically?
> |
> | John, can you please have a look at this function?
>
> Thanks for pointing out that this function would also need to be
> changed.
>
> Which element operator are you thinking of?
> octave_value::fast_elem_extract?  That returns an octave_value object,
> so that means for each element we would be constructing an
> octave_value object and then immediately extracting a double value
> from it.  That seems like a lot of overhead here.
>
> How about something like the following change, which always treats cdata
> as a double array internally?  That requires a data conversion to
> double for the entire array, even though it is only really necessary
> to convert one element at a time.  But at least it doesn't create a
> temporary octave_value object for each array element.
>
Maybe I'm misunderstanding the original code, but doesn't it also
convert the whole array to double? In this case we loose no
performance by converting beforehand when compared to the original
code.

Shai



reply via email to

[Prev in Thread] Current Thread [Next in Thread]