Mercurial > hg > ddm
view lin_solve_dgr_3.m @ 2:e2b116f3b69b
fixed reallocate and pinv_2_fast to work on Octave
added short example very quickly, might not be working properly
author | smusevic |
---|---|
date | Thu, 25 Jul 2013 13:07:07 +0100 |
parents | a4a7e3405062 |
children |
line wrap: on
line source
% solve multiple 3rd degree linear systems at once - no pivoting! function dg3 = lin_solve_dgr_3(A,b,R) nrm = ... + A(1,3,:) .* A(2,2,:) .* A(3,1,:) ... - A(1,3,:) .* A(2,1,:) .* A(3,2,:) ... + A(1,2,:) .* A(2,1,:) .* A(3,3,:) ... - A(1,2,:) .* A(2,3,:) .* A(3,1,:) ... + A(1,1,:) .* A(2,3,:) .* A(3,2,:) ... - A(1,1,:) .* A(2,2,:) .* A(3,3,:); dg3 = zeros(3,R); dg3(1,:) = -(... +b(3,1,:) .* ( A(1,2,:) .* A(2,3,:) - A(1,3,:) .* A(2,2,:) ) ... -b(2,1,:) .* ( A(1,2,:) .* A(3,3,:) - A(1,3,:) .* A(3,2,:) ) ... +b(1,1,:) .* ( A(2,2,:) .* A(3,3,:) - A(2,3,:) .* A(3,2,:) ) ... ) ./ nrm; dg3(2,:) = (... +b(3,1,:) .* ( A(1,1,:) .* A(2,3,:) - A(1,3,:) .* A(2,1,:) ) ... -b(2,1,:) .* ( A(1,1,:) .* A(3,3,:) - A(1,3,:) .* A(3,1,:) ) ... +b(1,1,:) .* ( A(2,1,:) .* A(3,3,:) - A(2,3,:) .* A(3,1,:) ) ... ) ./ nrm; dg3(3,:) = -(... +b(3,1,:) .* ( A(1,1,:) .* A(2,2,:) - A(1,2,:) .* A(2,1,:) ) ... -b(2,1,:) .* ( A(1,1,:) .* A(3,2,:) - A(1,2,:) .* A(3,1,:) ) ... +b(1,1,:) .* ( A(2,1,:) .* A(3,2,:) - A(2,2,:) .* A(3,1,:) ) ... ) ./ nrm; end