-
Notifications
You must be signed in to change notification settings - Fork 0
/
numeric_t.m
63 lines (61 loc) · 2.51 KB
/
numeric_t.m
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function r = numeric_t(expression)
% This file is part of GPCCA.
%
% Copyright (c) 2018, 2017 Bernhard Reuter
%
% If you use this code or parts of it, cite the following reference:
%
% Reuter, B., Weber, M., Fackeldey, K., Röblitz, S., & Garcia, M. E. (2018). Generalized
% Markov State Modeling Method for Nonequilibrium Biomolecular Dynamics: Exemplified on
% Amyloid β Conformational Dynamics Driven by an Oscillating Electric Field. Journal of
% Chemical Theory and Computation, 14(7), 3579–3594. https://doi.org/10.1021/acs.jctc.8b00079
%
% GPCCA is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as published
% by the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program 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 Lesser General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
% -------------------------------------------------------------------------
% flexible wrapper function to unify work with different numeric types
%
% function r = numeric_t(expression)
%
% Input:
% expression An expression like 'pi/2' or a float like '2.0'
% (Quotes are important!). '2' and '2.0' are
% equivalent.
% Also float matrices (user defined or elementary
% ones like eye(), ones(), zeros() can be passed but
% WITHOUT QUOTES!
%
% Output:
% r Either the result of the input expression or the
% passed float or Matrix of floats but in any case of
% datatype class_t (as defined in main.m!).
%
% Written by Bernhard Reuter, Theoretical Physics II,
% University of Kassel, 2017 -- based on example code by Pavel
% Holoborodko
% from https://www.advanpix.com/2016/07/21/how-to-write-precision ...
% -independent-code-in-matlab/
global class_t;
if (nargin > 0)
if(strcmpi(class_t,'mp')), r = mp(expression);
else
if isnumeric(expression)
r = expression;
else
r = eval(expression);
end;
end;
else
r = class_t;
end;
end