Moved routines and updated submodules dseries and dates.
parent
55e8c2319d
commit
6d2f049637
|
@ -1,30 +0,0 @@
|
||||||
function b = check_file_extension(file,type)
|
|
||||||
|
|
||||||
% Copyright (C) 2012 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr
|
|
||||||
|
|
||||||
% Clean-up path
|
|
||||||
file = strrep(file, '../', '');
|
|
||||||
file = strrep(file, './', '');
|
|
||||||
|
|
||||||
remain = file;
|
|
||||||
while ~isempty(remain)
|
|
||||||
[ext, remain] = strtok(remain,'.');
|
|
||||||
end
|
|
||||||
b = strcmp(ext,type);
|
|
|
@ -1,128 +0,0 @@
|
||||||
function [n,message] = common_strings_in_cell_arrays(a,b)
|
|
||||||
|
|
||||||
%@info:
|
|
||||||
%! @deftypefn {Function File} {[@var{n}, @var{message} ] =} common_strings_in_cell_arrays (@var{a}, @var{b})
|
|
||||||
%! @anchor{common_strings_in_cell_arrays}
|
|
||||||
%! @sp 1
|
|
||||||
%! Counts the number of common strings in two cell arrays of strings @var{a} and @var{b}.
|
|
||||||
%! @sp 2
|
|
||||||
%! @strong{Inputs}
|
|
||||||
%! @sp 1
|
|
||||||
%! @table @ @var
|
|
||||||
%! @item a
|
|
||||||
%! One dimensional cell array of strings.
|
|
||||||
%! @item b
|
|
||||||
%! One dimensional cell array of strings.
|
|
||||||
%! @end table
|
|
||||||
%! @sp 2
|
|
||||||
%! @strong{Outputs}
|
|
||||||
%! @sp 1
|
|
||||||
%! @table @ @var
|
|
||||||
%! @item n
|
|
||||||
%! Scalar integer, number of common strings.
|
|
||||||
%! @item message
|
|
||||||
%! String, formatted list of common strings.
|
|
||||||
%! @end table
|
|
||||||
%! @end deftypefn
|
|
||||||
%@eod:
|
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
common_strings = intersect(a,b);
|
|
||||||
n = numel(common_strings);
|
|
||||||
|
|
||||||
if nargout>1
|
|
||||||
switch n
|
|
||||||
case 0
|
|
||||||
message = [];
|
|
||||||
case 1
|
|
||||||
message = common_strings{1};
|
|
||||||
case 2
|
|
||||||
message = [common_strings{1} ' and ' common_strings{2}];
|
|
||||||
otherwise
|
|
||||||
message = common_strings{1};
|
|
||||||
for i = 2:n-1
|
|
||||||
message = [message ', ' common_strings{i}];
|
|
||||||
end
|
|
||||||
message = [message ' and ' common_strings{n}];
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
%@test:1
|
|
||||||
%$ % Define cell arrays of strings.
|
|
||||||
%$ A = {'A1'; 'A2'; 'A3'; 'A4'};
|
|
||||||
%$ B = {'B1'; 'B2'; 'B3'; 'B4'};
|
|
||||||
%$
|
|
||||||
%$ try
|
|
||||||
%$ n = common_strings_in_cell_arrays(A,B);
|
|
||||||
%$ [m,message] = common_strings_in_cell_arrays(A,B);
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ t = 0;
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if length(t)>1
|
|
||||||
%$ t(2) = dassert(n,m);
|
|
||||||
%$ t(3) = dassert(n,0);
|
|
||||||
%$ t(4) = dassert(isempty(message),1);
|
|
||||||
%$ end
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:1
|
|
||||||
|
|
||||||
%@test:2
|
|
||||||
%$ % Define cell arrays of strings.
|
|
||||||
%$ A = {'A1'; 'A2'; 'A3'; 'A4'};
|
|
||||||
%$ B = {'B1'; 'A2'; 'B3'; 'A4'};
|
|
||||||
%$
|
|
||||||
%$ try
|
|
||||||
%$ n = common_strings_in_cell_arrays(A,B);
|
|
||||||
%$ [m,message] = common_strings_in_cell_arrays(A,B);
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ t = 0;
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if length(t)>1
|
|
||||||
%$ t(2) = dassert(n,m);
|
|
||||||
%$ t(3) = dassert(n,2);
|
|
||||||
%$ t(4) = dassert(message,'A2 and A4');
|
|
||||||
%$ end
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:2
|
|
||||||
|
|
||||||
%@test:2
|
|
||||||
%$ % Define cell arrays of strings.
|
|
||||||
%$ A = {'A1'; 'A2'; 'A3'; 'A4'; 'A5'; 'A6'};
|
|
||||||
%$ B = {'B1'; 'A2'; 'B3'; 'A4'; 'A1'};
|
|
||||||
%$
|
|
||||||
%$ try
|
|
||||||
%$ n = common_strings_in_cell_arrays(A,B);
|
|
||||||
%$ [m,message] = common_strings_in_cell_arrays(A,B);
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ t = 0;
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if length(t)>1
|
|
||||||
%$ t(2) = dassert(n,m);
|
|
||||||
%$ t(3) = dassert(n,3);
|
|
||||||
%$ t(4) = dassert(message,'A2, A4 and A1');
|
|
||||||
%$ end
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:3
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
function str = get_random_string(n);
|
|
||||||
|
|
||||||
%@info:
|
|
||||||
%! @deftypefn {Function File} {@var{str} =} get_random_string (@var{n})
|
|
||||||
%! @anchor{get_random_string}
|
|
||||||
%! @sp 1
|
|
||||||
%! Builds a random string (starting with a letter).
|
|
||||||
%! @sp 2
|
|
||||||
%! @strong{Inputs}
|
|
||||||
%! @sp 1
|
|
||||||
%! @table @ @var
|
|
||||||
%! @item a
|
|
||||||
%! Scalar integer, number of characters in the generated string.
|
|
||||||
%! @end table
|
|
||||||
%! @sp 1
|
|
||||||
%! @strong{Outputs}
|
|
||||||
%! @sp 1
|
|
||||||
%! @table @ @var
|
|
||||||
%! @item str
|
|
||||||
%! Generated string
|
|
||||||
%! @end table
|
|
||||||
%! @sp 2
|
|
||||||
%! @strong{This function is called by:}
|
|
||||||
%! @sp 2
|
|
||||||
%! @strong{This function calls:}
|
|
||||||
%! @ref{set_time}
|
|
||||||
%!
|
|
||||||
%! @end deftypefn
|
|
||||||
%@eod:
|
|
||||||
|
|
||||||
% Copyright (C) 2012 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr
|
|
||||||
|
|
||||||
str0 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
||||||
|
|
||||||
m0 = 2*26;
|
|
||||||
m1 = m0+10;
|
|
||||||
|
|
||||||
str = str0(ceil(rand*m0)); % First character has to be a letter!
|
|
||||||
str = [str, str0(ceil(rand(1,n-1)*m1))];
|
|
|
@ -1,66 +0,0 @@
|
||||||
function matrix = insert_column_vector_in_a_matrix(matrix, vector, i) % --*-- Unitary tests --*--
|
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
if nargin<2
|
|
||||||
error('insert_column_vector_in_a_matrix: I need at least two input arguments!')
|
|
||||||
end
|
|
||||||
|
|
||||||
if ~isequal(ndims(matrix),2)
|
|
||||||
error(['insert_column_vector_in_a_matrix: First input ''' inputname(1) ''' must be a matrix!'])
|
|
||||||
end
|
|
||||||
|
|
||||||
[n,m] = size(matrix);
|
|
||||||
|
|
||||||
if nargin<3
|
|
||||||
i = m+1;
|
|
||||||
end
|
|
||||||
|
|
||||||
if ~isvector(vector) || ~isequal(numel(vector),size(vector,1)) || ~isequal(numel(vector),n)
|
|
||||||
error(['insert_column_vector_in_a_matrix: Second input argument ''' inputname(2) ''' must be a ' int2str(n) ' by 1 vector!'])
|
|
||||||
end
|
|
||||||
|
|
||||||
switch i
|
|
||||||
case m+1
|
|
||||||
matrix = [matrix, vector];
|
|
||||||
case 1
|
|
||||||
matrix = [vector, matrix];
|
|
||||||
otherwise
|
|
||||||
matrix = [matrix(:,1:i-1), vector, matrix(:,i:m)];
|
|
||||||
end
|
|
||||||
|
|
||||||
%@test:1
|
|
||||||
%$ % Define a datasets.
|
|
||||||
%$ A = rand(8,3); b = rand(8,1);
|
|
||||||
%$
|
|
||||||
%$ try
|
|
||||||
%$ A4 = insert_column_vector_in_a_matrix(A, b);
|
|
||||||
%$ A1 = insert_column_vector_in_a_matrix(A, b, 1);
|
|
||||||
%$ A2 = insert_column_vector_in_a_matrix(A, b, 2);
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ t(1) = 0;
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if t(1)
|
|
||||||
%$ t(2) = dassert(A4,[A,b],1e-15);
|
|
||||||
%$ t(3) = dassert(A1,[b,A],1e-15);
|
|
||||||
%$ t(4) = dassert(A2,[A(:,1), b, A(:,2:end)],1e-15);
|
|
||||||
%$ end
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:1
|
|
|
@ -1,73 +0,0 @@
|
||||||
function one_dimensional_cell_array = insert_object_in_a_one_dimensional_cell_array(one_dimensional_cell_array, object, i) % --*-- Unitary tests --*--
|
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
if nargin<2
|
|
||||||
error('insert_object_in_a_one_dimensional_cell_array: I need at least two input arguments!')
|
|
||||||
end
|
|
||||||
|
|
||||||
if ~iscell(one_dimensional_cell_array)
|
|
||||||
error(['insert_column_vector_in_a_matrix: First input ''' inputname(1) ''' must be a cell array!'])
|
|
||||||
end
|
|
||||||
|
|
||||||
[nr, nc] = size(one_dimensional_cell_array);
|
|
||||||
|
|
||||||
if ~isequal(nr*nc,numel(one_dimensional_cell_array))
|
|
||||||
error(['insert_column_vector_in_a_matrix: First input ''' inputname(1) ''' must be a one dimensional cell array!'])
|
|
||||||
end
|
|
||||||
|
|
||||||
n = numel(one_dimensional_cell_array);
|
|
||||||
|
|
||||||
if nargin<3
|
|
||||||
i = n+1;
|
|
||||||
end
|
|
||||||
|
|
||||||
one_dimensional_cell_array = one_dimensional_cell_array(:);
|
|
||||||
|
|
||||||
switch i
|
|
||||||
case n+1
|
|
||||||
one_dimensional_cell_array = [one_dimensional_cell_array; object];
|
|
||||||
case 1
|
|
||||||
one_dimensional_cell_array = [object; one_dimensional_cell_array];
|
|
||||||
otherwise
|
|
||||||
one_dimensional_cell_array = [one_dimensional_cell_array(1:i-1); object; one_dimensional_cell_array(i:n)];
|
|
||||||
end
|
|
||||||
|
|
||||||
if nc>nr
|
|
||||||
one_dimensional_cell_array = transpose(one_dimensional_cell_array);
|
|
||||||
end
|
|
||||||
|
|
||||||
%@test:1
|
|
||||||
%$ A = {'A1'; 'A2'; 'A3'}; b = [1, pi];
|
|
||||||
%$
|
|
||||||
%$ try
|
|
||||||
%$ C4 = insert_object_in_a_one_dimensional_cell_array(A, b);
|
|
||||||
%$ C1 = insert_object_in_a_one_dimensional_cell_array(A, b, 1);
|
|
||||||
%$ C2 = insert_object_in_a_one_dimensional_cell_array(A, b, 2);
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ t(1) = 0;
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if t(1)
|
|
||||||
%$ t(2) = dassert(C4,[A;b]);
|
|
||||||
%$ t(3) = dassert(C1,[b;A],1e-15);
|
|
||||||
%$ t(4) = dassert(C2,[A(1); b; A(2:3)]);
|
|
||||||
%$ end
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:1
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 46ea0bd1c30e7c76d823247689b6e59417f11c44
|
Subproject commit cb29cec352522cf2e8b029a2febe5ae502f86859
|
|
@ -1 +1 @@
|
||||||
Subproject commit b1abd7ab95bfc04f5b18850a18478af8b6fe5573
|
Subproject commit 73edfb1fd1964e44dc7afcf7d512a3e305e50828
|
|
@ -1,97 +0,0 @@
|
||||||
function one_dimensional_cell_array = replace_object_in_a_one_dimensional_cell_array(one_dimensional_cell_array, object, i)
|
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
if nargin<3
|
|
||||||
error('replace_object_in_a_one_dimensional_cell_array: I need at least three input arguments!')
|
|
||||||
end
|
|
||||||
|
|
||||||
if ~iscell(one_dimensional_cell_array)
|
|
||||||
error(['replace_column_vector_in_a_matrix: First input ''' inputname(1) ''' must be a cell array!'])
|
|
||||||
end
|
|
||||||
|
|
||||||
[nr, nc] = size(one_dimensional_cell_array);
|
|
||||||
|
|
||||||
if ~isequal(max([nr,nc]),numel(one_dimensional_cell_array))
|
|
||||||
error(['replace_column_vector_in_a_matrix: First input ''' inputname(1) ''' must be a one dimensional cell array!'])
|
|
||||||
end
|
|
||||||
|
|
||||||
n = numel(one_dimensional_cell_array);
|
|
||||||
|
|
||||||
if ~isint(i) || i<1 || i>n
|
|
||||||
error(['replace_column_vector_in_a_matrix: Last input ''' inputname(3) ''' must be a positive integer less than or equal to ' int2str(n) '!'])
|
|
||||||
end
|
|
||||||
|
|
||||||
one_dimensional_cell_array = one_dimensional_cell_array(:);
|
|
||||||
|
|
||||||
% Remove object i.
|
|
||||||
switch i
|
|
||||||
case n
|
|
||||||
one_dimensional_cell_array = one_dimensional_cell_array(1:n-1);
|
|
||||||
case 1
|
|
||||||
one_dimensional_cell_array = one_dimensional_cell_array(2:n);
|
|
||||||
otherwise
|
|
||||||
one_dimensional_cell_array = [one_dimensional_cell_array(1:i-1); one_dimensional_cell_array(i+1:n)];
|
|
||||||
end
|
|
||||||
|
|
||||||
% convert object to a cell array if needed.
|
|
||||||
if ~iscell(object)
|
|
||||||
object = {object};
|
|
||||||
end
|
|
||||||
|
|
||||||
% Insert object at position i
|
|
||||||
one_dimensional_cell_array = insert_object_in_a_one_dimensional_cell_array(one_dimensional_cell_array, object(:), i);
|
|
||||||
|
|
||||||
% transpose cell array if needed.
|
|
||||||
if nc>nr
|
|
||||||
one_dimensional_cell_array = transpose(one_dimensional_cell_array);
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
%@test:1
|
|
||||||
%$ A = {'A12'; 'A3'; 'A4'}; B = {'A1'; 'A2'};
|
|
||||||
%$
|
|
||||||
%$ try
|
|
||||||
%$ C = replace_object_in_a_one_dimensional_cell_array(A, B, 1);
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ t(1) = 0;
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if t(1)
|
|
||||||
%$ t(2) = dassert(C,[B; A(2:3)]);
|
|
||||||
%$ end
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:1
|
|
||||||
|
|
||||||
%@test:2
|
|
||||||
%$ A = {'A1'; 'A3'; 'A4'}; B = 'B1';
|
|
||||||
%$
|
|
||||||
%$ try
|
|
||||||
%$ C = replace_object_in_a_one_dimensional_cell_array(A, B, 2);
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ t(1) = 0;
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ D = {'A1';'B1';'A4'};
|
|
||||||
%$ if t(1)
|
|
||||||
%$ t(2) = dassert(C,D);
|
|
||||||
%$ end
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:2
|
|
|
@ -1,40 +0,0 @@
|
||||||
function a = iscellofchar(b)
|
|
||||||
|
|
||||||
% Copyright (C) 2012-2013 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
a = 1;
|
|
||||||
|
|
||||||
if ndims(b)>2
|
|
||||||
error(['iscellofchar: Input argument ''' inputname(1) ''' has to be a two dimensional cell array!'])
|
|
||||||
end
|
|
||||||
|
|
||||||
[n,m] = size(b);
|
|
||||||
p = numel(b);
|
|
||||||
q = 0;
|
|
||||||
|
|
||||||
for i=1:m
|
|
||||||
for j=1:n
|
|
||||||
if ischar(b{j,i})
|
|
||||||
q = q + 1;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if ~isequal(q,p)
|
|
||||||
a = 0;
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
function a = isglobalinbase(var)
|
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
tmp = whos('global');
|
|
||||||
if isempty(strmatch(var,{tmp.name}))
|
|
||||||
a = 0;
|
|
||||||
else
|
|
||||||
a = 1;
|
|
||||||
end
|
|
|
@ -1,196 +0,0 @@
|
||||||
function tex = name2tex(name, info) % --*-- Unitary tests --*--
|
|
||||||
|
|
||||||
% Converts plain text name into tex name.
|
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
|
||||||
%
|
|
||||||
% This file is part of Dynare.
|
|
||||||
%
|
|
||||||
% Dynare is free software: you can redistribute it and/or modify
|
|
||||||
% it under the terms of the GNU General Public License as published by
|
|
||||||
% the Free Software Foundation, either version 3 of the License, or
|
|
||||||
% (at your option) any later version.
|
|
||||||
%
|
|
||||||
% Dynare is distributed in the hope that it will be useful,
|
|
||||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
% GNU General Public License for more details.
|
|
||||||
%
|
|
||||||
% You should have received a copy of the GNU General Public License
|
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
if nargin<2
|
|
||||||
info = 0;
|
|
||||||
end
|
|
||||||
|
|
||||||
if info
|
|
||||||
if iscell(name)
|
|
||||||
nn = length(name);
|
|
||||||
else
|
|
||||||
nn = 1;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if isoctave
|
|
||||||
tex = regexprep(name, '_', '\_');
|
|
||||||
else
|
|
||||||
tex = regexprep(name, '_', '\\_');
|
|
||||||
end
|
|
||||||
|
|
||||||
if info
|
|
||||||
for i=1:nn
|
|
||||||
if iscell(name)
|
|
||||||
texname = tex{i};
|
|
||||||
else
|
|
||||||
texname = tex;
|
|
||||||
end
|
|
||||||
idx = strfind(texname,'_');
|
|
||||||
ndx = length(idx);
|
|
||||||
ntx = length(texname);
|
|
||||||
if ndx
|
|
||||||
gotonextcondition = 1;
|
|
||||||
if isequal(ndx,1) && ~isequal(idx,2) && ~isequal(idx,ntx)
|
|
||||||
texname = [ texname(1:idx-2) '_{' texname(idx+1:end) '}'];
|
|
||||||
gotonextcondition = 0;
|
|
||||||
end
|
|
||||||
if gotonextcondition && isequal(ndx,2) && ~isequal(idx(1),2) && isequal(idx(2),ntx)
|
|
||||||
texname = [ texname(1:idx(1)-2) '_{' texname(idx(1)+1:end) '}' ];
|
|
||||||
gotonextcondition = 0;
|
|
||||||
end
|
|
||||||
if gotonextcondition && isequal(ndx,2) && idx(2)<ntx
|
|
||||||
texname = [ texname(1:idx(2)-2) '_{' texname(idx(2)+1:end) '}' ];
|
|
||||||
gotonextcondition = 0;
|
|
||||||
end
|
|
||||||
if gotonextcondition && ndx>2
|
|
||||||
if idx(end)<ntx
|
|
||||||
texname = [ texname(1:idx(end)-2) '_{' texname(idx(end)+1:end) '}' ];
|
|
||||||
else
|
|
||||||
texname = [ texname(1:idx(end-1)-2) '_{' texname(idx(end-1)+1:end) '}' ];
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if iscell(name)
|
|
||||||
tex(i) = { texname };
|
|
||||||
else
|
|
||||||
tex = texname;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
%@test:1
|
|
||||||
%$ t = zeros(16,1);
|
|
||||||
%$ t1 = name2tex('_azert');
|
|
||||||
%$ t2 = name2tex('azert_');
|
|
||||||
%$ t3 = name2tex('_azert_');
|
|
||||||
%$ t4 = name2tex('azert_uiop');
|
|
||||||
%$ t5 = name2tex('azert_uiop_qsdfg');
|
|
||||||
%$ t6 = name2tex('azert_uiop_qsdfg_');
|
|
||||||
%$ t7 = name2tex('_azert_uiop_qsdfg');
|
|
||||||
%$ t8 = name2tex('_azert_uiop_qsdfg_');
|
|
||||||
%$ t11 = name2tex('_azert',1);
|
|
||||||
%$ t12 = name2tex('azert_',1);
|
|
||||||
%$ t13 = name2tex('_azert_',1);
|
|
||||||
%$ t14 = name2tex('azert_uiop',1);
|
|
||||||
%$ t15 = name2tex('azert_uiop_qsdfg',1);
|
|
||||||
%$ t16 = name2tex('azert_uiop_qsdfg_',1);
|
|
||||||
%$ t17 = name2tex('_azert_uiop_qsdfg',1);
|
|
||||||
%$ t18 = name2tex('_azert_uiop_qsdfg_',1);
|
|
||||||
%$
|
|
||||||
%$ t(1) = dassert(strcmp(t1,'\\_azert'),true);
|
|
||||||
%$ t(2) = dassert(strcmp(t2,'azert\\_'),true);
|
|
||||||
%$ t(3) = dassert(strcmp(t3,'\\_azert\\_'),true);
|
|
||||||
%$ t(4) = dassert(strcmp(t4,'azert\\_uiop'),true);
|
|
||||||
%$ t(5) = dassert(strcmp(t5,'azert\\_uiop\\_qsdfg'),true);
|
|
||||||
%$ t(6) = dassert(strcmp(t6,'azert\\_uiop\\_qsdfg\\_'),true);
|
|
||||||
%$ t(7) = dassert(strcmp(t7,'\\_azert\\_uiop\\_qsdfg'),true);
|
|
||||||
%$ t(8) = dassert(strcmp(t8,'\\_azert\\_uiop\\_qsdfg\\_'),true);
|
|
||||||
%$ t(9) = dassert(strcmp(t11,'\\_azert'),true);
|
|
||||||
%$ t(10) = dassert(strcmp(t12,'azert\\_'),true);
|
|
||||||
%$ t(11) = dassert(strcmp(t13,'\\_azert\\_'),true);
|
|
||||||
%$ t(12) = dassert(strcmp(t14,'azert_{uiop}'),true);
|
|
||||||
%$ t(13) = dassert(strcmp(t15,'azert\\_uiop_{qsdfg}'),true);
|
|
||||||
%$ t(14) = dassert(strcmp(t16,'azert\\_uiop_{qsdfg\\_}'),true);
|
|
||||||
%$ t(15) = dassert(strcmp(t17,'\\_azert\\_uiop_{qsdfg}'),true);
|
|
||||||
%$ t(16) = dassert(strcmp(t18,'\\_azert\\_uiop_{qsdfg\\_}'),true);
|
|
||||||
%$
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:1
|
|
||||||
|
|
||||||
%@test:2
|
|
||||||
%$ t = zeros(16,1);
|
|
||||||
%$ t1 = name2tex({'_azert'});
|
|
||||||
%$ t2 = name2tex({'azert_'});
|
|
||||||
%$ t3 = name2tex({'_azert_'});
|
|
||||||
%$ t4 = name2tex({'azert_uiop'});
|
|
||||||
%$ t5 = name2tex({'azert_uiop_qsdfg'});
|
|
||||||
%$ t6 = name2tex({'azert_uiop_qsdfg_'});
|
|
||||||
%$ t7 = name2tex({'_azert_uiop_qsdfg'});
|
|
||||||
%$ t8 = name2tex({'_azert_uiop_qsdfg_'});
|
|
||||||
%$ t11 = name2tex({'_azert'},1);
|
|
||||||
%$ t12 = name2tex({'azert_'},1);
|
|
||||||
%$ t13 = name2tex({'_azert_'},1);
|
|
||||||
%$ t14 = name2tex({'azert_uiop'},1);
|
|
||||||
%$ t15 = name2tex({'azert_uiop_qsdfg'},1);
|
|
||||||
%$ t16 = name2tex({'azert_uiop_qsdfg_'},1);
|
|
||||||
%$ t17 = name2tex({'_azert_uiop_qsdfg'},1);
|
|
||||||
%$ t18 = name2tex({'_azert_uiop_qsdfg_'},1);
|
|
||||||
%$
|
|
||||||
%$ t(1) = dassert(t1,{'\\_azert'});
|
|
||||||
%$ t(2) = dassert(t2,{'azert\\_'});
|
|
||||||
%$ t(3) = dassert(t3,{'\\_azert\\_'});
|
|
||||||
%$ t(4) = dassert(t4,{'azert\\_uiop'});
|
|
||||||
%$ t(5) = dassert(t5,{'azert\\_uiop\\_qsdfg'});
|
|
||||||
%$ t(6) = dassert(t6,{'azert\\_uiop\\_qsdfg\\_'});
|
|
||||||
%$ t(7) = dassert(t7,{'\\_azert\\_uiop\\_qsdfg'});
|
|
||||||
%$ t(8) = dassert(t8,{'\\_azert\\_uiop\\_qsdfg\\_'});
|
|
||||||
%$ t(9) = dassert(t11,{'\\_azert'});
|
|
||||||
%$ t(10) = dassert(t12,{'azert\\_'});
|
|
||||||
%$ t(11) = dassert(t13,{'\\_azert\\_'});
|
|
||||||
%$ t(12) = dassert(t14,{'azert_{uiop}'});
|
|
||||||
%$ t(13) = dassert(t15,{'azert\\_uiop_{qsdfg}'});
|
|
||||||
%$ t(14) = dassert(t16,{'azert\\_uiop_{qsdfg\\_}'});
|
|
||||||
%$ t(15) = dassert(t17,{'\\_azert\\_uiop_{qsdfg}'});
|
|
||||||
%$ t(16) = dassert(t18,{'\\_azert\\_uiop_{qsdfg\\_}'});
|
|
||||||
%$
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:2
|
|
||||||
|
|
||||||
%@test:3
|
|
||||||
%$ t = zeros(4,1);
|
|
||||||
%$ try
|
|
||||||
%$ t1 = name2tex({'_azert';'azert_';'_azert_';'azert_uiop';'azert_uiop_qsdfg';'azert_uiop_qsdfg_'});
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ % Nothing to do here.
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if t(1)
|
|
||||||
%$ try
|
|
||||||
%$ t2 = name2tex({'_azert';'azert_';'_azert_';'azert_uiop';'azert_uiop_qsdfg';'azert_uiop_qsdfg_'},1);
|
|
||||||
%$ t(2) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ % Nothing to do here.
|
|
||||||
%$ end
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if t(1)
|
|
||||||
%$ t(3) = dassert(t1,{'\\_azert';'azert\\_';'\\_azert\\_';'azert\\_uiop';'azert\\_uiop\\_qsdfg';'azert\\_uiop\\_qsdfg\\_'});
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ if t(2)
|
|
||||||
%$ t(4) = dassert(t2,{'\\_azert';'azert\\_';'\\_azert\\_';'azert_{uiop}';'azert\\_uiop_{qsdfg}';'azert\\_uiop_{qsdfg\\_}'});
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:3
|
|
||||||
|
|
||||||
%@test:4
|
|
||||||
%$ try
|
|
||||||
%$ db = dseries('csv/dd.csv');
|
|
||||||
%$ t(1) = 1;
|
|
||||||
%$ catch
|
|
||||||
%$ t(1) = 0;
|
|
||||||
%$ end
|
|
||||||
%$
|
|
||||||
%$ T = all(t);
|
|
||||||
%@eof:4
|
|
Loading…
Reference in New Issue