what is the time complexity of function 'reshape'
Show older comments
anyone knows what is the time complexity of function 'reshape'?
Accepted Answer
More Answers (1)
John D'Errico
on 10 Apr 2022
Edited: John D'Errico
on 10 Apr 2022
1 vote
Essentially, almost zero time (a small constant amount that is almost negligable.) All reshape itself does is modify a flag attached to the array, that tells MATLAB what shape the array is. NO elements are moved around by a reshape. Of course, if you will then be doing something with that reshaped array, perhaps creating a new variable, that is different. But there, the time will be spent allocating a new variable, and copying elements, etc. But the reshape itself is virtually instantaneous.
1 Comment
warnerchang
on 11 Apr 2022
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!