Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.5.0 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Linear Algebra > Linear Equations > linsolve

linsolve

linear equation solver

Calling Sequence

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

Arguments

A

a na x ma real matrix (possibly sparse)

b

a na x 1 vector (same row dimension as A)

x0

a real vector

kerA

a ma x k real matrix

Description

linsolve computes all the solutions to A*x+b=0.

x0 is a particular solution (if any) and kerA=nullspace of A. Any x=x0+kerA*w with arbitrary w satisfies A*x+b=0.

If compatible x0 is given on entry, x0 is returned. If not a compatible x0, if any, is returned.

Examples

A=rand(5,3)*rand(3,8);
b=A*ones(8,1);[x,kerA]=linsolve(A,b);A*x+b   //compatible b
b=ones(5,1);[x,kerA]=linsolve(A,b);A*x+b   //uncompatible b
A=rand(5,5);[x,kerA]=linsolve(A,b), -inv(A)*b  //x is unique

// Benchmark with other linear sparse solver:
[A,descr,ref,mtype] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa"); 

b = zeros(size(A,1),1);

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

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

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

See Also

  • inv — matrix inverse
  • pinv — pseudoinverse
  • colcomp — column compression, kernel, nullspace
  • im_inv — inverse image
  • umfpack — solve sparse linear system
  • backslash — (\) left matrix division.
Report an issue
<< inv Linear Equations lsq >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Fri Apr 11 14:06:50 CEST 2014