1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="linsolve">
18 <refname>linsolve</refname>
19 <refpurpose>linear equation solver</refpurpose>
23 <synopsis>[x0,kerA]=linsolve(A,b [,x0])</synopsis>
26 <title>Arguments</title>
32 a <literal>na x ma</literal> real matrix (possibly sparse)
40 a <literal>na x 1</literal> vector (same row dimension as <literal>A</literal>)
47 <para>a real vector</para>
54 a <literal>ma x k</literal> real matrix
61 <title>Description</title>
63 <literal>linsolve</literal> computes all the solutions to <literal> A*x+b=0</literal>.
66 <literal>x0</literal> is a particular solution (if any) and <literal> kerA= </literal>nullspace
67 of <literal>A</literal>. Any <literal>x=x0+kerA*w</literal> with arbitrary <literal>w</literal> satisfies
68 <literal> A*x+b=0</literal>.
71 If compatible <literal>x0</literal> is given on entry, <literal>x0</literal> is returned. If not
72 a compatible <literal>x0</literal>, if any, is returned.
76 <title>Examples</title>
77 <programlisting role="example"><![CDATA[
78 A=rand(5,3)*rand(3,8);
79 b=A*ones(8,1);[x,kerA]=linsolve(A,b);A*x+b //compatible b
80 b=ones(5,1);[x,kerA]=linsolve(A,b);A*x+b //uncompatible b
81 A=rand(5,5);[x,kerA]=linsolve(A,b), -inv(A)*b //x is unique
83 // Benchmark with other linear sparse solver:
84 [A,descr,ref,mtype] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa");
86 b = zeros(size(A,1),1);
89 res = umfpack(A,'\',b);
90 mprintf('\ntime needed to solve the system with umfpack: %.3f\n',toc());
94 mprintf('\ntime needed to solve the system with linsolve: %.3f\n',toc());
98 mprintf('\ntime needed to solve the system with the backslash operator: %.3f\n',toc());
101 <refsection role="see also">
102 <title>See also</title>
103 <simplelist type="inline">
105 <link linkend="inv">inv</link>
108 <link linkend="pinv">pinv</link>
111 <link linkend="colcomp">colcomp</link>
114 <link linkend="im_inv">im_inv</link>
117 <link linkend="umfpack">umfpack</link>
120 <link linkend="backslash">backslash</link>