1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) DIGITEO - 2011 - Allan CORNET
4 // Copyright (C) Scilab Enterprises - 2011 - Calixte DENIZET
5 // Copyright (C) 2017 - Samuel GOUGEON
7 // Copyright (C) 2012 - 2016 - Scilab Enterprises
9 // This file is hereby licensed under the terms of the GNU GPL v2.0,
10 // pursuant to article 5.3.4 of the CeCILL v.2.1.
11 // This file was originally licensed under the terms of the CeCILL v2.1,
12 // and continues to be available under such terms.
13 // For more information, see the COPYING file which you should have received
14 // along with this program.
16 function a = toeplitz(c, r)
17 // a = toeplitz(c,r) returns the Toepliz matrix whose first row
18 // is r and first column is c .( r(1) = c(1) is assumed).
20 // Checking input arguments
21 // ------------------------
24 msg = _("%s: Wrong number of input argument(s): %d to %d expected.\n");
25 error(msprintf(msg, "toeplitz", 1, 2));
31 if isempty(c) | isempty(r) then
35 // Checking types compatibility & upper left common corner:
38 tmp = [c(1,1) r(1,1)];
39 if tmp(1,1) <> tmp(1,2) then
40 msg = _("%s: Wrong values for input arguments #%d and #%d: c(1) must be equal to r(1).\n");
41 error(msprintf(msg, "toeplitz", 1, 2));
48 index = ones(1, nr) .*. ((nc - 1):-1:0)' + (1:nr) .*. ones(nc, 1);
50 a = matrix(b(1,index(:)'), nc, nr);