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
* This file must be used under the terms of the CeCILL.
7
* This source file is licensed as described in the file COPYING, which
8
* you should have received as part of this distribution. The terms
9
* are also available at
10
* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13
<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" version="5.0-subset Scilab" xml:lang="en" xml:id="linsolve">
15
<refname>linsolve</refname>
16
<refpurpose> linear equation solver</refpurpose>
19
<title>Calling Sequence</title>
20
<synopsis>[x0,kerA]=linsolve(A,b [,x0])</synopsis>
23
<title>Arguments</title>
29
a <literal>na x ma</literal> real matrix (possibly sparse)
37
a <literal>na x 1</literal> vector (same row dimension as <literal>A</literal>)
44
<para>a real vector</para>
51
a <literal>ma x k</literal> real matrix
58
<title>Description</title>
60
<literal>linsolve</literal> computes all the solutions to <literal> A*x+b=0</literal>.
63
<literal>x0</literal> is a particular solution (if any) and <literal> kerA= </literal>nullspace
64
of <literal>A</literal>. Any <literal>x=x0+kerA*w</literal> with arbitrary <literal>w</literal> satisfies
65
<literal> A*x+b=0</literal>.
68
If compatible <literal>x0</literal> is given on entry, <literal>x0</literal> is returned. If not
69
a compatible <literal>x0</literal>, if any, is returned.
73
<title>Examples</title>
74
<programlisting role="example"><![CDATA[
75
A=rand(5,3)*rand(3,8);
76
b=A*ones(8,1);[x,kerA]=linsolve(A,b);A*x+b //compatible b
77
b=ones(5,1);[x,kerA]=linsolve(A,b);A*x+b //uncompatible b
78
A=rand(5,5);[x,kerA]=linsolve(A,b), -inv(A)*b //x is unique
80
// Benchmark with other linear sparse solver:
81
[A,descr,ref,mtype] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa");
83
b = zeros(size(A,1),1);
86
res = umfpack(A,'\',b);
87
mprintf('\ntime needed to solve the system with umfpack: %.3f\n',toc());
91
mprintf('\ntime needed to solve the system with linsolve: %.3f\n',toc());
95
mprintf('\ntime needed to solve the system with the backslash operator: %.3f\n',toc());
98
<refsection role="see also">
99
<title>See Also</title>
100
<simplelist type="inline">
102
<link linkend="inv">inv</link>
105
<link linkend="pinv">pinv</link>
108
<link linkend="colcomp">colcomp</link>
111
<link linkend="im_inv">im_inv</link>
114
<link linkend="umfpack">umfpack</link>
117
<link linkend="backslash">backslash</link>