View Reshape Function Code

1 回表示 (過去 30 日間)
Aidan Shek
Aidan Shek 2020 年 6 月 1 日
コメント済み: Steven Lord 2020 年 9 月 23 日
I would like to open and view the code for the reshape function, does anyone have a copy?

採用された回答

James Tursa
James Tursa 2020 年 6 月 1 日
All it basically does is replace the dimensions with the requested dimensions in the internal variable header. There wouldn't be much to see even if you could see the source code for that part. Most of the code is probably for the checking, e.g.,
  • Are the requested number of elements the same?
  • Are the requested dimension values all non-negative integers?
  • If there is a missing dimension, calculate this value and make sure it is an integer.
  • Can the result be a shared data copy? (e.g., for a full matrix)
  • Will the result need to be a deep data copy? (e.g., for a sparse matrix)
  • Etc.
  2 件のコメント
isamh
isamh 2020 年 9 月 23 日
what if I use reshape with negative decimal values? the output shows all the values but shows all negative values as positive.
Steven Lord
Steven Lord 2020 年 9 月 23 日
Can you show a small example that demonstrates this behavior?

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2020 年 6 月 1 日
We don't distribute the source code for that built-in function.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by