summaryrefslogtreecommitdiff
path: root/modules/polynomials/macros/hrmt.sci
blob: 9cff1de0c7695f3f07cb649da868b2e7b5ef75df (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
// 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 [pg,U]=hrmt(v)
    // Syntax: [pg,U]=hrmt(v)
    // Finds unimodular U and pg = gcd of a row of polynomials v
    // such that v*U = [pg,0]
    //!
    [n,m]=size(v)
    if n>1 then
        error(msprintf(gettext("%s: Wrong size for input argument #%d: A row vector expected.\n"),"hrmt",1))
    end
    pg=v(1)
    U=eye(m,m)
    for k=2:m
        [pg,uk]=bezout(pg,v(k))
        U(:,k-1:k)=U(:,k-1:k)*uk(:,[2 1])
    end
endfunction