ऊपर दिए गए सुझावों के आधार पर FLOPS काउंट:
LU, कोई धुरी नहीं:
- मुल = 11, दिवि / प्रतिप = 6, जोड़ / उप = 11, कुल = 28; या
- मुल = 16, दिवा / प्रतिप = 3, जोड़ / उप = 11, कुल = 30
बैक-प्रतिस्थापन के साथ गॉसियन उन्मूलन, कोई धुरी नहीं:
- मुल = 11, दिवि / प्रतिप = 6, जोड़ / उप = 11, कुल = 28; या
- मुल = 16, दिवा / प्रतिप = 3, जोड़ / उप = 11, कुल = 30
कोफ़ेक्टर विस्तार के माध्यम से क्रैमर का शासन
- मुल = 24, दिवि = 3, जोड़ / उप = 15, कुल = 42; या
- मुल = २ =, दीव = १, जोड़ / उप = १५, कुल = ४३
स्पष्ट व्युत्क्रम फिर गुणा करें:
- मूल = 30, दिवि = 3, जोड़ें / उप = 17, कुल = 50; या
- मुल = 33, दिवि = 1, जोड़ / उप = 17, कुल = 51
MATLAB सबूत की अवधारणाएं:
Cofactor विस्तार के माध्यम से Cramer का नियम :
function k = CramersRule(A, m)
%
% FLOPS:
%
% Multiplications: 24
% Subtractions/Additions: 15
% Divisions: 3
%
% Total: 42
a = A(1,1);
b = A(1,2);
c = A(1,3);
d = A(2,1);
e = A(2,2);
f = A(2,3);
g = A(3,1);
h = A(3,2);
i = A(3,3);
x = m(1);
y = m(2);
z = m(3);
ei = e*i;
fh = f*h;
di = d*i;
fg = f*g;
dh = d*h;
eg = e*g;
ei_m_fh = ei - fh;
di_m_fg = di - fg;
dh_m_eg = dh - eg;
yi = y*i;
fz = f*z;
yh = y*h;
ez = e*z;
yi_m_fz = yi - fz;
yh_m_ez = yh - ez;
dz = d*z;
yg = y*g;
dz_m_yg = dz - yg;
ez_m_yh = ez - yh;
det_a = a*ei_m_fh - b*di_m_fg + c*dh_m_eg;
det_1 = x*ei_m_fh - b*yi_m_fz + c*yh_m_ez;
det_2 = a*yi_m_fz - x*di_m_fg + c*dz_m_yg;
det_3 = a*ez_m_yh - b*dz_m_yg + x*dh_m_eg;
p = det_1 / det_a;
q = det_2 / det_a;
r = det_3 / det_a;
k = [p;q;r];
LU (कोई धुरी नहीं) और बैक-प्रतिस्थापन:
function [x, y, L, U] = LUSolve(A, b)
% Total FLOPS count: (w/ Mods)
%
% Multiplications: 11 16
% Divisions/Recip: 6 3
% Add/Subtractions: 11 11
% Total = 28 30
%
A11 = A(1,1);
A12 = A(1,2);
A13 = A(1,3);
A21 = A(2,1);
A22 = A(2,2);
A23 = A(2,3);
A31 = A(3,1);
A32 = A(3,2);
A33 = A(3,3);
b1 = b(1);
b2 = b(2);
b3 = b(3);
L11 = 1;
L22 = 1;
L33 = 1;
U11 = A11;
U12 = A12;
U13 = A13;
L21 = A21 / U11;
L31 = A31 / U11;
U22 = (A22 - L21*U12);
L32 = (A32 - L31*U12) / U22;
U23 = (A23 - L21*U13);
U33 = (A33 - L31*U13 - L32*U23);
y1 = b1;
y2 = b2 - L21*y1;
y3 = b3 - L31*y1 - L32*y2;
x3 = (y3 ) / U33;
x2 = (y2 - U23*x3) / U22;
x1 = (y1 - U12*x2 - U13*x3) / U11;
L = [ ...
L11, 0, 0;
L21, L22, 0;
L31, L32, L33];
U = [ ...
U11, U12, U13;
0, U22, U23;
0, 0, U33];
x = [x1;x2;x3];
y = [y1;y2;y3];
स्पष्ट उलटा तब गुणा करें:
function x = ExplicitInverseMultiply(A, m)
%
% FLOPS count: Alternative
%
% Multiplications: 30 33
% Divisions: 3 1
% Additions/Subtractions: 17 17
% Total: 50 51
a = A(1,1);
b = A(1,2);
c = A(1,3);
d = A(2,1);
e = A(2,2);
f = A(2,3);
g = A(3,1);
h = A(3,2);
i = A(3,3);
ae = a*e;
af = a*f;
ah = a*h;
ai = a*i;
bd = b*d;
bf = b*f;
bg = b*g;
bi = b*i;
cd = c*d;
ce = c*e;
cg = c*g;
ch = c*h;
dh = d*h;
di = d*i;
eg = e*g;
ei = e*i;
fg = f*g;
fh = f*h;
dh_m_eg = (dh - eg);
ei_m_fh = (ei - fh);
fg_m_di = (fg - di);
A = ei_m_fh;
B = fg_m_di;
C = dh_m_eg;
D = (ch - bi);
E = (ai - cg);
F = (bg - ah);
G = (bf - ce);
H = (cd - af);
I = (ae - bd);
det_A = a*ei_m_fh + b*fg_m_di + c*dh_m_eg;
x1 = (A*m(1) + D*m(2) + G*m(3)) / det_A;
x2 = (B*m(1) + E*m(2) + H*m(3)) / det_A;
x3 = (C*m(1) + F*m(2) + I*m(3)) / det_A;
x = [x1;x2;x3];
गाउस विलोपन:
function x = GaussianEliminationSolve(A, m)
%
% FLOPS Count: Min Alternate
%
% Multiplications: 11 16
% Divisions: 6 3
% Add/Subtractions: 11 11
% Total: 28 30
%
a = A(1,1);
b = A(1,2);
c = A(1,3);
d = A(2,1);
e = A(2,2);
f = A(2,3);
g = A(3,1);
h = A(3,2);
i = A(3,3);
b1 = m(1);
b2 = m(2);
b3 = m(3);
% Get to echelon form
op1 = d/a;
e_dash = e - op1*b;
f_dash = f - op1*c;
b2_dash = b2 - op1*b1;
op2 = g/a;
h_dash = h - op2*b;
i_dash = i - op2*c;
b3_dash = b3 - op2*b1;
op3 = h_dash / e_dash;
i_dash2 = i_dash - op3*f_dash;
b3_dash2 = b3_dash - op3*b2_dash;
% Back substitution
x3 = (b3_dash2 ) / i_dash2;
x2 = (b2_dash - f_dash*x3) / e_dash;
x1 = (b1 - b*x2 - c*x3) / a;
x = [x1 ; x2 ; x3];
नोट: कृपया इस पोस्ट में अपनी स्वयं की विधियों और गिनती को जोड़ने के लिए स्वतंत्र महसूस करें।