Octave – Gestione matrici – III – 84


Continuo con la gestione delle matrici, copiando qui.

Built-in Function: permute (A, perm)
Return the generalized transpose for an N-D array object A.
The permutation vector perm must contain the elements 1:ndims (A) (in any order, but each element must appear only once). The Nth dimension of A gets remapped to dimension PERM(N).


Built-in Function: ipermute (A, iperm)
The inverse of the permute function.
The expression ipermute (permute (A, perm), perm) returns the original array A.

Built-in Function: reshape (A, m, n, ...)
Built-in Function: reshape (A, [m n ...])
Built-in Function: reshape (A, ..., [], ...)
Built-in Function: reshape (A, size)

Return a matrix with the specified dimensions (m, n, ...) whose elements are taken from the matrix A.
The elements of the matrix are accessed in column-major order (like Fortran arrays are stored).
The following code demonstrates reshaping a 1×4 row vector into a 2×2 square matrix.


Note that the total number of elements in the original matrix (prod (size (A))) must match the total number of elements in the new matrix (prod ([m n ...])).
A single dimension of the return matrix may be left unspecified and Octave will determine its size automatically. An empty matrix ([]) is used to flag the unspecified dimension.

Built-in Function: resize (x, m)
Built-in Function: resize (x, m, n, ...)
Built-in Function: resize (x, [m n ...])

Resize x cutting off elements as necessary.
In the result, element with certain indices is equal to the corresponding element of x if the indices are within the bounds of x; otherwise, the element is set to zero.
In other words, the statement y = resize (x, dv) is equivalent to the following code:

y = zeros (dv, class (x));
sz = min (dv, size (x));
for i = 1:length (sz)
  idx{i} = 1:sz(i);
y(idx{:}) = x(idx{:});

but is performed more efficiently.

If only m is supplied, and it is a scalar, the dimension of the result is m-by-m. If m, n, ... are all scalars, then the dimensions of the result are m-by-n-by-…. If given a vector as input, then the dimensions of the result are given by the elements of that vector.
An object can be resized to more dimensions than it has; in such case the missing dimensions are assumed to be 1. Resizing an object to fewer dimensions is not possible.

Function File: y = circshift (x, n)
Circularly shift the values of the array x.
n must be a vector of integers no longer than the number of dimensions in x. The values of n can be either positive or negative, which determines the direction in which the values or x are shifted. If an element of n is zero, then the corresponding dimension of x will not be shifted.


Function File: shift (x, b)
Function File: shift (x, b, dim)

If x is a vector, perform a circular shift of length b of the elements of x.
If x is a matrix, do the same for each column of x.
If the optional dim argument is given, operate along this dimension.


Function File: y = shiftdim (x, n)
Function File: [y, ns] = shiftdim (x)

Shift the dimensions of x by n, where n must be an integer scalar.
When n is positive, the dimensions of x are shifted to the left, with the leading dimensions circulated to the end. If n is negative, then the dimensions of x are shifted to the right, with n leading singleton dimensions added.
Called with a single argument, shiftdim, removes the leading singleton dimensions, returning the number of dimensions removed in the second output argument ns.



Posta un commento o usa questo indirizzo per il trackback.



Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

Questo sito utilizza Akismet per ridurre lo spam. Scopri come vengono elaborati i dati derivati dai commenti.

%d blogger hanno fatto clic su Mi Piace per questo: