Name

linsolve — solucionador de equações lineares

Seqüência de Chamamento

[x0,kerA]=linsolve(A,b [,x0])

Parâmetros

A

uma matriz na x ma de reais (possivelmente esparsa)

b

um vetor na x 1 (mesma dimensão de linha de A)

x0

um vetor de reais

kerA

uma matriz ma x k de reais

Descrição

linsolve computa todas as soluções para A*x+b=0.

x0 é uma solução particular (se houver) e kerA= núcleo de A. Qualquer x=x0+kerA*w com w arbitrário satisfaz A*x+b=0.

Se um compatible x0 compatível é dado na entrada, x0 é retornado. Senão, um x0, compatível é retornado, se houver.

Exemplos

 
A=rand(5,3)*rand(3,8);
b=A*ones(8,1);[x,kerA]=linsolve(A,b);A*x+b   //b comatível
b=ones(5,1);[x,kerA]=linsolve(A,b);A*x+b   //b incompatível
A=rand(5,5);[x,kerA]=linsolve(A,b), -inv(A)*b  //x é único

// A benchmark of sparse linear solver

[A,descr,ref,mtype] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa"); 

b = 0*ones(size(A,1),1);

tic();
res = umfpack(A,'\',b);
printf('\ntime needed to solve the system with umfpack: %.3f\n',toc());

tic();
res = linsolve(A,b);
printf('\ntime needed to solve the system with linsolve: %.3f\n',toc());

tic();
res = A\b;
printf('\ntime needed to solve the system with the backslash operator: %.3f\n',toc());
 

Ver Também

inv, pinv, colcomp, im_inv, backslash, umfpack