Calculation of only necessary rows of matrix product

Suppose I have a large (but possibly rare) matrix Athat is K-by-K in dimension. I have another vector K-by-1 b,.

Let Ax=b. If I'm only interested in the first lines n, where n < K, from x, then one of the ways to deal with this in MATLAB is to calculate x=A\band take the first nelements.

If the dimension is Kso large that a full calculation is impossible, is there any other way to get these elements?

+4
source share
2 answers

, A x , x. [A, b] . , , , nxn A ( An), An * xn = bn, xn x, bn n b .

, - , x, .

+1

: : A = [A11, A12;A21, A22], A11 n x n, B = inv(A) = [B11, B12;B21, B22] . , , Schur, n x n. , , K, .

x(1:n) = [B11, B12]*b. - B21, B22. , , . , .

, A22, (K-n)x(K-n):

K = 100;
n = 10;
A = randn(K,K);
b = randn(K,1);
% reference version: full inverse
xfull = inv(A)*b;

% blocks of A
A11 = A(1:n,1:n);A12 = A(1:n,n+1:K);A21 = A(n+1:K,1:n);A22 = A(n+1:K,n+1:K);
% blocks of inverse
A22i = inv(A22);                % not sure if this can be avoided
B11 =  inv(A11 - A12*A22i*A21);
B12 = -B11*A12*A22i;

% solution
x_n = [B11,B12]*b;

disp(x_n - xfull(1:n))

edit. , "" , , , , LSE. , b, A.

+1

Source: https://habr.com/ru/post/1669948/


All Articles