Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group!
The function reshape(M, p, q) returns an array of size p x q, formed from elements of the array M by their consistent sample columns. If the number of array elements M is not equal to the product p * q, an error message - see the attach
Matlab (Matrix Laboratory) has this function
Valery Ochkov wrote: The function reshape(M, p, q) returns an array of size p x q, formed from elements of the array M by their consistent sample columns. If the number of array elements M is not equal to the product p * q, an error message - see the attachPSMatlab (Matrix Laboratory) has this function
Valery Ochkov wrote:
I think the reshape function should form part of a true multi-dimensional array capability (MDA), as I've posted many, many, many times previously on the Collab - which would be more in keeping with the exact capability of the Matlab reshape function or that of the majority of matrix languages (eg, Mathematica).
That is a lovely, lovely function.
Right in the filling cabinet.
Mike Armstrong wrote:Valery,That is a lovely, lovely function.Right in the filling cabinet.Mike
Mike Armstrong wrote:
See a video in attach!
Thanks!See a video in attach!
I like it. Well done Valery.
As a long-time software engineer, I can't help but mess w code when I see it...and I started with this one /just/ to move the ERROR block to the outer level because I opine that it's best to determine at the outer-most level whether the code about to run might cause a fault, and handle it before any real work is done...
then, well, one thing led to another, "and the next thing you know" 😉
...here is the result, including an off-the-cuff speed test...
Oh, and I forgot to pre-allocate the destination matrix...so here is an update...and I added it to the original, too...
...and thanks to Mike's speed test example...better numbers and easier than all that enable/disable evaluation stuff that I was doing...
Nice work Richard, definately an improvement.
Slightly more complex speed test included.
As part of my updating of my library of utility functions, I'm attempting to introduce a slight degree of commonality between my standard library and my multi-dimensional array (MDA) library as far as names and overall intent goes. One of the functions is reshape (used primarily in my MDA library). As usual, the behaviour of the functions is driven by experience and laziness, so my latest incarnation of the standard reshape function doesn't return an error if the reshaped array doesn't have the same number of elements as the original; if the new array is smaller than the original, reshape only takes (in column order) as many elements as it needs and discards the rest, if the new array is larger then reshape pads the end of the new array with NaNs.
The attached worksheet also includes one my standard timer functions to ease performance testing, plus an MDA reshape example.
We are archiving your idea as part of a general review. This action is based on the age of your idea and the total number of votes received, as per this announcement.
You can always post a new idea with all the details required in the form.
Thank you for your participation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.