4 % lexicographic unit cube
24 % linear transformation
27 X = T*X0+rand(3,1)*ones(1,8);
30 [K, Fold, Jg, vol] = hexa(A,X,u);
33 eig_K=eig(K) % one eigenvalue zero
36 % for linear field mu with values V at nodes V*F should be -integral (grad mu) * u
40 exact = - gradmu*u*vol;
43 if exist('vrrotvec2mat')
44 % invariariant to random isometry
45 S=vrrotvec2mat(vrrotvec(randn(3,1),randn(3,1)))*diag(sign(randn(3,1)));
46 [K0, ~, ~] = hexa(A,X,u);
47 [K1, ~, ~] = hexa(A,S*X,u);
48 err_iso=norm(K0-K1,'fro')
50 warning(sprintf('err_iso %g too large',err_iso))
54 warning('No vrrotvec2mat, cannot test rotation invariance. Install Simulink 3D Animation.')
58 X3 = diag([1 1 2])*X0;
59 [K3, ~, ~] = hexa(A,X3,u);
61 % test same results from matlab and fortran
62 if exist('fortran/hexa_test.exe')
63 disp('testing if same result in fortran')
64 err=hexa_fortran(A,X3,u)
66 fprintf('error %g OK\n',err)
68 error(sprintf('error %g too large',err))
71 warning('fortran/hexa_test.exe not available')