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
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2021 - Samuel GOUGEON - Le Mans Université
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"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
18 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
19 xml:lang="en" xml:id="det">
21 <refname>det</refname>
22 <refpurpose>determinant of a square matrix</refpurpose>
32 <title>Arguments</title>
37 square matrix of real or complex numbers, polynomials, or rationals.
38 Sparse-encoded matrices accepted.
45 Scalar of the <varname>X</varname>'s type: the determinant of
46 <varname>X</varname>. If <varname>X</varname> is sparse-encoded,
47 <varname>d</varname> is dense.
54 real or complex number: the determinant base 10 mantissa, with
55 <literal>abs(m) ∈ [1,10)</literal>. Not supported for <varname>X</varname>
56 polynomial or rational.
63 integer: the determinant base 10 exponent, such that
64 <literal>d = m * 10<superscript>e</superscript></literal>.
65 Not supported for <varname>X</varname> polynomial or rational.
72 <title>Description</title>
74 <emphasis role="bold">d = det(X)</emphasis> yields the determinant of the matrix
78 For a polynomial or rational matrix, <literal>d=det(X)</literal> uses <literal>determ(..)</literal>
79 whose algorithm is based on the FFT.
80 <literal>d=detr(X)</literal> can be alternatively used, based on the Leverrier algorithm.
81 Both methods yield equivalent results. For rational matrices, turning off <code>simp_mode(%f)</code>
82 might be required to get identical results.
85 <emphasis role="bold">[e, m] = det(X)</emphasis> can be used only for a matrix of numbers.
86 This syntax allows to overcome computation's underflow or overflow, when <literal>abs(d)</literal>
88 <literal>number_properties("tiny")</literal> ≈ 2.23 10<superscript>-308</superscript> or
89 bigger than <literal>number_properties("huge")</literal> ≈ 1.80 10<superscript>308</superscript>.
92 For denses matrices, <literal>det(..)</literal> is based on the Lapack routines
93 DGETRF for real matrices and ZGETRF for the complex case.
96 For sparse matrices, the determinant is obtained from LU factorization thanks to the umfpack library.
100 <title>Examples</title>
101 <programlisting role="example"><![CDATA[
106 // Matrix of complex numbers:
107 // A = grand(3,3,"uin",0,10) + grand(3,3,"uin",0,10)*%i
108 A = [3+%i, 9+%i*3, 9+%i ; 8+%i*8, 4+%i*3, 7+%i*7 ; 4, 6+%i*2, 6+%i*9]
125 --> // Matrix of complex numbers:
126 --> A = [3+%i, 9+%i*3, 9+%i ; 8+%i*8, 4+%i*3, 7+%i*7 ; 4, 6+%i*2, 6+%i*9]
128 3. + i 9. + 3.i 9. + i
129 8. + 8.i 4. + 3.i 7. + 7.i
130 4. + 0.i 6. + 2.i 6. + 9.i
142 --> abs(m) // in [1, 10)
148 Very big or small determinants: underflow and overflow handling:
150 <programlisting role="example"><![CDATA[
151 // Very big determinant:
157 // Very small determinant (of a sparse-encoded matrix):
158 A = (triu(sprand(n,n,1)) + diag(rand(1,n)))/1.5;
167 --> // Very big determinant:
173 --> [e, m] = det(A) // -3.1199e743
179 --> // Very small determinant (of a sparse-encoded matrix):
181 --> A = (triu(sprand(n,n,1)) + diag(rand(1,n)))/1.5;
209 Determinant of a polynomial matrix:
211 <programlisting role="example"><![CDATA[
213 det([s, 1+s ; 2-s, s^2])
216 roots(det(systmat(w))),trzeros(w) //zeros of linear system
219 --> det([s, 1+s ; 2-s, s^2])
223 --> w = ssrand(2,2,4);
224 --> roots(det(systmat(w))),trzeros(w)
234 <refsection role="see also">
235 <title>See also</title>
236 <simplelist type="inline">
238 <link linkend="detr">detr</link>
241 <link linkend="determ">determ</link>
244 <link linkend="simp_mode">simp_mode</link>
248 <refsection role="history">
249 <title>History</title>
252 <revnumber>6.1.1</revnumber>
254 [e,m]=det(X) syntax extended to sparse matrices.