1 |
function NDFUN |
---|
2 |
%NDFUN Matrix operations on N-D matrices |
---|
3 |
% NDFUN treats an N-D matrix of double precision values as a set of pages |
---|
4 |
% of 2D matrices, and performs various matrix operations on those pages. |
---|
5 |
% The BLAS and LAPACK routines compiled into MATLAB are used for all these |
---|
6 |
% operations, so results will be very close, and are usually identical, to |
---|
7 |
% "native MATLAB results". Available commands are: |
---|
8 |
% |
---|
9 |
% C = NDFUN('mult', A, B) |
---|
10 |
% C = NDFUN('backslash', A, B) |
---|
11 |
% C = NDFUN('inv', A) |
---|
12 |
% C = NDFUN('version') |
---|
13 |
% |
---|
14 |
% The two-argument commands perform operations equivalent to: |
---|
15 |
% for i=1:N |
---|
16 |
% C(:,:,i) = A(:,:,i) * B(:,:,i); |
---|
17 |
% end |
---|
18 |
% The one-argument command |
---|
19 |
% for i=1:N |
---|
20 |
% C(:,:,i) = inv(A(:,:,i)); |
---|
21 |
% end |
---|
22 |
% |
---|
23 |
% Any number of dimensions is supported, but dimensions > 2 must match: |
---|
24 |
% C = ndfun('mult', rand(4,3,2,2,2), rand(3,1,2,2,2)) |
---|
25 |
% C will have size = [4 1 2 2 2] |
---|
26 |
% |
---|
27 |
% NDFUN will reuse 2D arguments when needed, much like scalar |
---|
28 |
% operations. A single 2D matrix can be multiplied (or solved with) |
---|
29 |
% each 2D page of the other argument. For instance: |
---|
30 |
% A = rand(4,3); B = rand(3,10,100); |
---|
31 |
% C = ndfun('mult', A, B); |
---|
32 |
% is equivalent to: |
---|
33 |
% for i=1:100 |
---|
34 |
% C(:,:,i) = A * B(:,:,i); |
---|
35 |
% end |
---|
36 |
% The reverse also works. These types of operations are especially |
---|
37 |
% efficient for the backslash operator. |
---|
38 |
% |
---|
39 |
% |
---|
40 |
% Author: Peter Boettcher <boettcher@ll.mit.edu> |
---|
41 |
|
---|
42 |
% Last modified: <Wed Mar 27 13:10:26 2002 by pwb> |
---|
43 |
|
---|
44 |
error('MEX file not found. Try ''mex ndfun.c'' to compile.'); |
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|