Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

reshape2D_undo.m 930 B

123456789101112131415161718192021222324252627282930
  1. function m = reshape2D_undo(f,dim,msize)
  2. % function m = reshape2D_undo(f,dim,msize)
  3. %
  4. % <f> has the same dimensions as the output of reshape2D
  5. % <dim> was the dimension of <m> that was used in reshape2D
  6. % <msize> was the size of <m>
  7. %
  8. % return <f> but with the same dimensions as passed to reshape2D.
  9. %
  10. % example:
  11. % a = randn(3,4,5);
  12. % b = reshape2D(a,2);
  13. % isequal(size(b),[4 15])
  14. % c = reshape2D_undo(b,2,size(a));
  15. % isequal(size(c),[3 4 5])
  16. % isequal(a,c)
  17. % figure out the permutation order that was used in reshape2D
  18. dimorder = [dim setdiff(1:max(length(msize),dim),dim)];
  19. % figure out the unsquished size
  20. if dim > length(msize) % if weird case (the dimension that was shifted was off the deep end), then handle directly
  21. reshapesize = [1 msize];
  22. else % otherwise, handle normally
  23. reshapesize = msize(dimorder);
  24. end
  25. % unsquish and the permute back to the original order
  26. m = ipermute(reshape(f,reshapesize),dimorder);