~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to macros/calpol/determ.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [res]=determ(W,k)
 
2
// determinant of a polynomial or rational matrix by FFT
 
3
// W=square polynomial matrix
 
4
// k=``predicted'' degree of the determinant of W i.e. k is
 
5
// an integer larger or equal to the actual degree of W.
 
6
// Method: evaluate the determinant of W for the Fourier frequencies
 
7
// and apply inverse fft to the coefficients of the determinant.
 
8
// See also detr
 
9
//F.D.!
 
10
// Copyright INRIA
 
11
[lhs,rhs]=argn(0);
 
12
if W==[] then res=1;return;end;
 
13
[n1,n1]=size(W);maj=n1*maxi(degree(W))+1;
 
14
if n1==0 then res=1;return;end
 
15
if rhs==1 then 
 
16
  k=1;
 
17
  while k < maj
 
18
    k=2*k;
 
19
  end
 
20
end
 
21
if n1>8 then write(%io(2),'Computing determinant: Be patient...');end
 
22
//          DEFAULT VALUES 
 
23
epsa=1.d-10;epsr=1.d-10;
 
24
//
 
25
e=0*ones(k,1);e(2)=1;
 
26
if k==1 then ksi=1,else ksi=fft(e,-1);end
 
27
fi=[];
 
28
if norm(imag(coeff(W)),1) ~=0 then
 
29
  for kk=1:k,fi=[fi,det(horner(W,ksi(kk)))];end
 
30
  zzz=poly(fft(fi,1),varn(W),'c');
 
31
  res=clean(real(zzz),epsa,epsr)+%i*clean(imag(zzz),epsa,epsr);
 
32
  return
 
33
else
 
34
  for kk=1:k,fi=[fi,det(freq(W,ones(W),ksi(kk)))];end
 
35
  zzz=poly(fft(fi,1),varn(W),'c');
 
36
  res=clean(real(zzz),epsa,epsr);
 
37
end
 
38
//if 2*int(n1/2)<>n1 then res=-res;end
 
39
 
 
40
 
 
41
 
 
42
 
 
43
 
 
44