summaryrefslogtreecommitdiff
path: root/modules/polynomials/macros/inv_coeff.sci
blob: f79a1db93557373890a9e93d234e795137ae50de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt


function [P]=inv_coeff(c,d,name)
    // inverse function of coeff
    rhs=argn(2);
    if rhs <= 2 ; name = "x";end

    [n,m]=size(c);
    if rhs <= 1 ; d = (m/n-1) ; end
    if d==m-1 then
        P=[];
        for l=1:n, P=[P;poly(c(l,:),name,"coeff")];end
        return,
    end
    if modulo(m,d+1) <> 0 then
        error(msprintf(_("%s: incompatible input arguments %d and %d\n"),"inv_coeff",1,2))
    end
    p=poly(0,name);
    P=p.^(0:d)';
    P=c*(P.*.eye(m/(d+1),m/(d+1)))
endfunction