1function [error_flag, message] = check(o)
2
3% Copyright (C) 2013-2017 Dynare Team
4%
5% This file is part of Dynare.
6%
7% Dynare is free software: you can redistribute it and/or modify
8% it under the terms of the GNU General Public License as published by
9% the Free Software Foundation, either version 3 of the License, or
10% (at your option) any later version.
11%
12% Dynare is distributed in the hope that it will be useful,
13% but WITHOUT ANY WARRANTY; without even the implied warranty of
14% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15% GNU General Public License for more details.
16%
17% You should have received a copy of the GNU General Public License
18% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
19
20error_flag = 0;
21
22[n,m] = size(o.data);
23
24if ~isequal(m, vobs(o));
25    error_flag = 1;
26    if nargout>1
27        message = ['dseries: Wrong number of variables in dseries object ''' inputname(1) '''!'];
28    end
29    return
30end
31
32if ~isequal(n,nobs(o));
33    error_flag = 1;
34    if nargout>1
35        message = ['dseries: Wrong number of observations in dseries object ''' inputname(1) '''!'];
36    end
37    return
38end
39
40if ~isequal(m,numel(o.name));
41    error_flag = 1;
42    if nargout>1
43        message = ['dseries: Wrong number of variable names in dseries object ''' inputname(1) '''!'];
44    end
45    return
46end
47
48if ~isequal(m,numel(o.tex));
49    error_flag = 1;
50    if nargout>1
51        message = ['dseries: Wrong number of variable tex names in dseries object ''' inputname(1) '''!'];
52    end
53    return
54end
55
56if ~isequal(numel(o.name), numel(o.tex));
57    error_flag = 1;
58    if nargout>1
59        message = ['dseries: The number of variable tex names has to be equal to the number of variable names in dseries object ''' inputname(1) '''!'];
60    end
61    return
62end
63
64if ~isequal(numel(unique(o.name)), numel(o.name));
65    error_flag = 1;
66    if nargout>1
67        message = ['dseries: The variable names in dseries object ''' inputname(1) ''' are not unique!'];
68    end
69    return
70end
71
72if ~isequal(numel(unique(o.tex)), numel(o.tex));
73    error_flag = 1;
74    if nargout>1
75        message = ['dseries: The variable tex names in dseries object ''' inputname(1) ''' are not unique!'];
76    end
77    return
78end
79
80if ~isequal(o.dates, firstdate(o):firstdate(o)+nobs(o))
81    error_flag = 1;
82    if nargout>1
83        message = ['dseries: Wrong definition of the dates member in dseries object ''' inputname(1) '''!'];
84    end
85    return
86end