Code covered by the BSD License  

Highlights from
Toolbox diffc

image thumbnail
from Toolbox diffc by Gabriel Peyre
A toolbox to perform differential calculus on a matrix.

test_tensor_3d.m
% test for 3D tensor diagonalization

% boundary conditions
options.bound  = 'sym';
% order of the derivative
options.order = 2;  % centered differences

n = 30;
M = randn(n,n,n);
% compute hessian tensors
T = compute_hessian(M,options);


[U,Lambda,err] = perform_tensor_decomp_3d(T);
T1 = perform_tensor_decomp_3d(U,Lambda);

% reconstruction error, should be small
sqrt( mean( (T(:)-T1(:)).^2 ) )

Contact us at files@mathworks.com