What is the time and memory cost of reshaping a matrix?
Given a matrix M with N elements, and I reshape to any other
size having N elements, I would hope I'm only changing the
matrix shape parameters rather than *any* memcpy at all.
However I see no post or doc on this. Anyone know?
> What is the time and memory cost of reshaping a matrix?
>
> Given a matrix M with N elements, and I reshape to any other
> size having N elements, I would hope I'm only changing the
> matrix shape parameters rather than *any* memcpy at all.
>
> However I see no post or doc on this. Anyone know?
Run the following:
format debug
a=1:10
b=reshape(a,2,5)
pr has the same value, which means both share the same data block.
Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muyve27m6bm.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Jay " <jay.damask@mlp.com> writes:
>
> > What is the time and memory cost of reshaping a matrix?
> >
> > Given a matrix M with N elements, and I reshape to any other
> > size having N elements, I would hope I'm only changing the
> > matrix shape parameters rather than *any* memcpy at all.
> >
> > However I see no post or doc on this. Anyone know?
>
> Run the following:
>
> format debug
> a=1:10
> b=reshape(a,2,5)
>
> pr has the same value, which means both share the same
data block.
>
> -Peter
okay, super. I didn't know about the format debug. Thanks
for the help.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Disclaimer prior to use.