Copy an array to a new shape
Array_Type _reshape (Array_Type A, Array_Type I)
The _reshape function creates a copy of an array A,
reshapes it to the form specified by I and returns the result.
The elements of I specify the new dimensions of the copy of
A and must be consistent with the number of elements A.
If A is a 100 element 1-d array, a new array 2-d array of
size 20 by 5 may be created from the elements of A
by
A = _reshape (A, [20, 5]);
In this example, the original array was no longer needed. Hence, it
is preferable to make use of the __tmp operator to avoid the
creation of a new array, i.e.,
A = _reshape (__tmp(A), [20,5]);
The reshape function performs a similar function to
_reshape. In fact, the _reshape function could have been
implemented via:
define _reshape (a, i)
{
a = @a; % Make a new copy
reshape (a, i);
return a;
}
- slangrtl
-
_typeof,
array_info,
array_map,
get_struct_field,
length,
max,
min,
reshape,
set_struct_field,
sum,
transpose,
typeof,
where
|