Mercurial > repos > public > sbplib
comparison +scheme/Schrodinger.m @ 1042:8d73fcdb07a5 feature/getBoundaryOp
Add asserts to boundary identifier inputs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Jan 2019 16:47:34 +0100 |
parents | 337c4d1dcef5 |
children | 5afc774fb7c4 |
comparison
equal
deleted
inserted
replaced
1007:9c8ed00732fd | 1042:8d73fcdb07a5 |
---|---|
112 | 112 |
113 % Returns the boundary operator op for the boundary specified by the string boundary. | 113 % Returns the boundary operator op for the boundary specified by the string boundary. |
114 % op -- string or a cell array of strings | 114 % op -- string or a cell array of strings |
115 % boundary -- string | 115 % boundary -- string |
116 function varargout = getBoundaryOperator(obj, op, boundary) | 116 function varargout = getBoundaryOperator(obj, op, boundary) |
117 assertIsMember(boundary, {'l', 'r'}) | |
117 | 118 |
118 if ~iscell(op) | 119 if ~iscell(op) |
119 op = {op}; | 120 op = {op}; |
120 end | 121 end |
121 | 122 |
125 switch boundary | 126 switch boundary |
126 case 'l' | 127 case 'l' |
127 e = obj.e_l; | 128 e = obj.e_l; |
128 case 'r' | 129 case 'r' |
129 e = obj.e_r; | 130 e = obj.e_r; |
130 otherwise | |
131 error('No such boundary: boundary = %s',boundary); | |
132 end | 131 end |
133 varargout{i} = e; | 132 varargout{i} = e; |
134 | 133 |
135 case 'd' | 134 case 'd' |
136 switch boundary | 135 switch boundary |
137 case 'l' | 136 case 'l' |
138 d = obj.d1_l; | 137 d = obj.d1_l; |
139 case 'r' | 138 case 'r' |
140 d = obj.d1_r; | 139 d = obj.d1_r; |
141 otherwise | |
142 error('No such boundary: boundary = %s',boundary); | |
143 end | 140 end |
144 varargout{i} = d; | 141 varargout{i} = d; |
145 end | 142 end |
146 end | 143 end |
147 end | 144 end |
148 | 145 |
149 % Returns the boundary sign. The right boundary is considered the positive boundary | 146 % Returns the boundary sign. The right boundary is considered the positive boundary |
150 % boundary -- string | 147 % boundary -- string |
151 function s = getBoundarySign(obj, boundary) | 148 function s = getBoundarySign(obj, boundary) |
149 assertIsMember(boundary, {'l', 'r'}) | |
150 | |
152 switch boundary | 151 switch boundary |
153 case {'r'} | 152 case {'r'} |
154 s = 1; | 153 s = 1; |
155 case {'l'} | 154 case {'l'} |
156 s = -1; | 155 s = -1; |
157 otherwise | |
158 error('No such boundary: boundary = %s',boundary); | |
159 end | 156 end |
160 end | 157 end |
161 | 158 |
162 function N = size(obj) | 159 function N = size(obj) |
163 N = obj.m; | 160 N = obj.m; |