02-Dec-2013 1> A = [0 1 2; 1 1 0; 3 2 1] A = 0 1 2 1 1 0 3 2 1 2> % fattorizzazione PA = LU 2> help lu 'lu' is a function from the file C:\Octave\Octave3.6.4_gcc4.6.2\lib\octave\3.6.4\oct\i686-pc-mingw32\lu.oct -- Loadable Function: [L, U] = lu (A) -- Loadable Function: [L, U, P] = lu (A) -- Loadable Function: [L, U, P, Q] = lu (S) -- Loadable Function: [L, U, P, Q, R] = lu (S) -- Loadable Function: [...] = lu (S, THRES) -- Loadable Function: Y = lu (...) -- Loadable Function: [...] = lu (..., 'vector') Compute the LU decomposition of A. If A is full subroutines from LAPACK are used and if A is sparse then UMFPACK is used. The result is returned in a permuted form, according to the optional return value P. For example, given the matrix `a = [1, 2; 3, 4]', [l, u, p] = lu (A) returns l = 1.00000 0.00000 0.33333 1.00000 u = 3.00000 4.00000 0.00000 0.66667 p = 0 1 1 0 The matrix is not required to be square. When called with two or three output arguments and a spare input matrix, `lu' does not attempt to perform sparsity preserving column permutations. Called with a fourth output argument, the sparsity preserving column transformation Q is returned, such that `P * A * Q = L * U'. Called with a fifth output argument and a sparse input matrix, `lu' attempts to use a scaling factor R on the input matrix such that `P * (R \ A) * Q = L * U'. This typically leads to a sparser and more stable factorization. An additional input argument THRES, that defines the pivoting threshold can be given. THRES can be a scalar, in which case it defines the UMFPACK pivoting tolerance for both symmetric and unsymmetric cases. If THRES is a 2-element vector, then the first element defines the pivoting tolerance for the unsymmetric UMFPACK pivoting strategy and the second for the symmetric strategy. By default, the values defined by `spparms' are used ([0.1, 0.001]). Given the string argument 'vector', `lu' returns the values of P and Q as vector values, such that for full matrix, `A (P,:) = L * U', and `R(P,:) * A (:, Q) = L * U'. With two output arguments, returns the permuted forms of the upper and lower triangular matrices, such that `A = L * U'. With one output argument Y, then the matrix returned by the LAPACK routines is returned. If the input matrix is sparse then the matrix L is embedded into U to give a return value similar to the full case. For both full and sparse matrices, `lu' loses the permutation information. Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. 3> [L, U, P] = lu(A) L = 1.00000 0.00000 0.00000 0.00000 1.00000 0.00000 0.33333 0.33333 1.00000 U = 3 2 1 0 1 2 0 0 -1 P = Permutation Matrix 0 0 1 1 0 0 0 1 0 4> P*A - L*U ans = 0 0 0 0 0 0 0 0 0 5> help lugauss 'lugauss' is a function from the file C:\cygwin\home\achilles\programmi_matlab/Programmi_CS4a\lugauss.m LUGAUSS Fattorizzazione LU senza pivoting A = LUGAUSS(A) calcola la fattorizzazione LU di Gauss della matrice A, memorizzando nella parte triangolare inferiore stretta di A la matrice L (gli elementi diagonali di L sono tutti uguali a 1) ed in quella superiore il fattore U Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. 6> lugauss(A) error: Un elemento pivot si e' annullato error: called from: error: C:\cygwin\home\achilles\programmi_matlab/Programmi_CS4a\lugauss.m at line 15, column 6 6> P = eye(3,3)([2 1 3], :) P = Permutation Matrix 0 1 0 1 0 0 0 0 1 7> B = P * A B = 1 1 0 0 1 2 3 2 1 8> C = lugauss(B) C = 1 1 0 0 1 2 3 -1 3 9> U = triu(C) U = 1 1 0 0 1 2 0 0 3 10> tril(C) ans = 1 0 0 0 1 0 3 -1 3 11> tril(C,1) ans = 1 1 0 0 1 2 3 -1 3 12> tril(C,-1) ans = 0 0 0 0 0 0 3 -1 0 13> L = tril(C,-1) + eye(3) L = 1 0 0 0 1 0 3 -1 1 14> L * U ans = 1 1 0 0 1 2 3 2 1 15> L * U - B ans = 0 0 0 0 0 0 0 0 0 16> % trasformatadiscreta di Fourier (DFT) 16> x=2*pi/1025*[0:1024]; 17> f=inline('0.5*sin(112*x)-cos(58*x)'); 18> plot(x,f(x)) 19> c=fft(f(x)); 20> size(c) ans = 1 1025 21> z=abs(c); 22> plot(z) 23> plot(fftshift(z)) 24> find(z>1) ans = 59 113 914 968 25> % valore assoluto di c_0 25> z(1) ans = 1.0297e-013 26> s=load('signal1'); 27> % urlwrite('http://www.dm.unibo.it/~achilles/calc/Programmi_CS4a/signal1', 'signal.1'); 27> plot(s) 28> plot(abs(fft(s))); 29> quit