[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fast copy of buffer data into a matrix
From: |
David Bateman |
Subject: |
Re: Fast copy of buffer data into a matrix |
Date: |
Fri, 09 Feb 2007 15:29:22 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
John Swensen wrote:
> Muthiah Annamalai wrote:
>
>> I think theres something like a
>>
>> double *val = ret_img.fortran_vec(); // in this case for Matrix,
>> what I gather from looking at liboctave/Marray2.cc|h &
>> liboctave/MArray-defs.h (where operator macros live).
>>
>> -Muthiah
>>
>>
>>
>>> I have searched around a bit, but can't find a way of just doing a
>>> memcpy into the Matrix object, rather than my slow existing
>>> implementation. Any suggestions?
>>>
>>> John Swensen
>>> _______________________________________________
>>> Help-octave mailing list
>>> address@hidden
>>> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>>>
>>>
> FYI, here is how I ended up copying a unsigned char buffer into a Matrix
> of type uint8. It ended up taking about 50% of the time of doing it
> element by element.
>
> static Matrix m1(settings.width, settings.height);
> static uint8NDArray m = octave_value(m1).uint8_array_value();
> static octave_uint8* tmp = m.fortran_vec();
> memcpy( tmp, capturebuffer, settings.height*settings.width );
> return octave_value(m.transpose());
>
>
Shouldn't that be
static unit8NDArray m (dim_vector(settings.width, settings.height));
static octave_uint8* tmp = m.fortran_vec();
memcpy( tmp, capturebuffer, settings.height*settings.width );
return octave_value(m.transpose());
You might be able to do away with the transpose as well, as the
transpose means that there is a second copy of m in memory at the same
time. However, for it to be efficient, it would have to be some sort of
blocked algorithm so that cache limitations are taken into account..
D.
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
- Fast copy of buffer data into a matrix, John Swensen, 2007/02/08
- Re: Fast copy of buffer data into a matrix, Nicolas Pettiaux, 2007/02/08
- Re: Fast copy of buffer data into a matrix, Muthiah Annamalai, 2007/02/08
- Re: Fast copy of buffer data into a matrix, John W. Eaton, 2007/02/09
- Re: Fast copy of buffer data into a matrix, John Swensen, 2007/02/09
- Re: Fast copy of buffer data into a matrix, John W. Eaton, 2007/02/09