1% @file gsTHBSpline.m 2% 3% @brief Matlab wrapper for gsTHBSpline class 4% 5% This file is part of the G+Smo library. 6% 7% This Source Code Form is subject to the terms of the Mozilla Public 8% License, v. 2.0. If a copy of the MPL was not distributed with this 9% file, You can obtain one at http://mozilla.org/MPL/2.0/. 10% 11% Author(s): O. Chanon, A. Mantzaflaris 12 13classdef gsTHBSpline < handle 14 15 properties (SetAccess = private, Hidden = true) 16 objectHandle; % Handle to the underlying C++ class instance 17 end 18 19 methods(Access = public) 20 21 % Constructor - Create a new C++ class instance 22 function this = gsTHBSpline(varargin) 23 %gsTHBSpline - construct a gsTHBSpline object 24 % 25 %Usage: 26 % thb = gsTHBSpline( file ) 27 % 28 %Input: 29 % file: char, [1 x numChar]. 30 % Name of input file from which to read/construct the 31 % gsTHBSpline. 32 % 33 %Output: 34 % thb: gsTHBSpline, [1 x 1]. 35 % The gsTHBSpline object. 36 37 if (nargin~=1 || nargout>1) 38 error('Invalid number of input and/or output arguments.') 39 end 40 if (~(isa(varargin{1},'char'))) 41 error('Input argument no. 1 should be of type ''char''.') 42 elseif (~exist(varargin{1},'file')) 43 error('File does not exist: %s.',varargin{1}) 44 end 45 this.objectHandle = mex_gsTHBSpline('constructor', class(varargin{1}), varargin{:}); 46 end 47 48 % Destructor - Destroy the C++ class instance 49 function delete(this) 50 %delete - delete a gsTHBSpline object 51 % 52 %Usage: 53 % thb.delete() 54 % 55 %Input: 56 % thb: gsTHBSpline, [1 x 1]. 57 % The gsTHBSpline object. 58 % 59 %Output: 60 % (none) 61 62 mex_gsTHBSpline('destructor', this.objectHandle); 63 end 64 65 % dim - call class method 66 function varargout = dim(this, varargin) 67 %dim - dimension of the parameter space of a gsTHBSpline object 68 % 69 %Usage: 70 % val = thb.dim() 71 % 72 %Input: 73 % thb: gsTHBSpline, [1 x 1]. 74 % The gsTHBSpline object. 75 % 76 %Output: 77 % val: double, [1 x 1]. 78 % Dimension of the parameter space of the gsTHBSpline. 79 80 if (nargin~=1 || nargout>1) 81 error('Invalid number of input and/or output arguments.') 82 end 83 [varargout{1:nargout}] = mex_gsTHBSpline('accessor', this.objectHandle, 'dim', varargin{:}); 84 end 85 86 % support - call class method 87 function varargout = support(this, varargin) 88 %support - support of a gsTHBSpline object 89 % 90 %Usage: 91 % supp = thb.support() 92 % 93 %Input: 94 % thb: gsTHBSpline, [1 x 1]. 95 % The gsTHBSpline object. 96 % 97 %Output: 98 % supp: double, [1 x 2*d]. 99 % Support of the gsTHBSpline, ordered like 100 % [u1_min, ..., ud_min, u1_max, ..., ud_max] 101 % where d is the parametric dimension of the 102 % gsTHBSpline. 103 104 if (nargin~=1 || nargout>1) 105 error('Invalid number of input and/or output arguments.') 106 end 107 [varargout{1:nargout}] = mex_gsTHBSpline('accessor', this.objectHandle, 'support', varargin{:}); 108 end 109 110 % size - call class method 111 function varargout = size(this, varargin) 112 %size - size of a gsTHBSpline object 113 % 114 %Usage: 115 % num = thb.size() 116 % 117 %Input: 118 % thb: gsTHBSpline, [1 x 1]. 119 % The gsTHBSpline object. 120 % 121 %Output: 122 % num: double, [1 x 1]. 123 % Size of the gsTHBSpline. 124 125 if (nargin~=1 || nargout>1) 126 error('Invalid number of input and/or output arguments.') 127 end 128 [varargout{1:nargout}] = mex_gsTHBSpline('accessor', this.objectHandle, 'size', varargin{:}); 129 end 130 131 % eval - call class method 132 function [varargout] = eval(this, varargin) 133 %eval - evaluate a gsTHBSpline object 134 % 135 %Usage: 136 % val = thb.eval( pts ) 137 % 138 %Input: 139 % thb: gsTHBSpline, [1 x 1]. 140 % The gsTHBSpline object. 141 % pts: double, [d x numPts]. 142 % Points in which to evaluate the gsTHBSpline. 143 % 144 %Output: 145 % val: double, [numFun x numPts]. 146 % Value of all active functions in each of the specified 147 % points. 148 149 if (nargin~=2 || nargout>1) 150 error('Invalid number of input and/or output arguments.') 151 end 152 if (~isa(varargin{1},'numeric') || ~ismatrix(varargin{1}) || ~isequal(size(varargin{1},1),this.dim())) 153 error('Input argument no. 1 must be numeric, 2-dimensional, and with d rows.') 154 end 155 [varargout{1:nargout}] = mex_gsTHBSpline('eval', this.objectHandle, varargin{:}); 156 end 157 158 % deriv - call class method 159 function [varargout] = deriv(this, varargin) 160 %deriv - evaluate the jacobian of a gsTHBSpline object 161 % 162 %Usage: 163 % val = thb.deriv( pts ) 164 % 165 %Input: 166 % thb: gsTHBSpline, [1 x 1]. 167 % The gsTHBSpline object. 168 % pts: double, [d x numPts]. 169 % Points in which to evaluate the gsTHBSpline. 170 % 171 %Output: 172 % val: double, [numFun x numPts]. 173 % Value of the jacobian of all active functions in each of 174 % the specified points. 175 176 if (nargin~=2 || nargout>1) 177 error('Invalid number of input and/or output arguments.') 178 end 179 if (~isa(varargin{1},'numeric') || ~ismatrix(varargin{1}) || ~isequal(size(varargin{1},1),this.dim())) 180 error('Input argument no. 1 must be numeric, 2-dimensional, and with d rows.') 181 end 182 [varargout{1:nargout}] = mex_gsTHBSpline('deriv', this.objectHandle, varargin{:}); 183 end 184 185 % hess - call class method 186 function [varargout] = hess(this, varargin) 187 %deriv - evaluate the hessian of a gsTHBSpline object in one 188 %direction 189 % 190 %Usage: 191 % val = thb.hess( pts, dir ) 192 % 193 %Input: 194 % thb: gsTHBSpline, [1 x 1]. 195 % The gsTHBSpline object. 196 % pts: double, [d x numPts]. 197 % Points in which to evaluate the gsTHBSpline. 198 % dir: int 199 % Direction of space on which to compute the hessian. 200 % 201 %Output: 202 % val: double, [numFun x numPts]. 203 % Value of the hessian matrix in direction dir of all active 204 % functions in each of the specified points. 205 206 if (nargin~=3 || nargout>1) 207 error('Invalid number of input and/or output arguments.') 208 end 209 if (~isa(varargin{1},'numeric') || ~ismatrix(varargin{1}) || ~isequal(size(varargin{1},1),this.dim())) 210 error('Input argument no. 1 must be numeric, 2-dimensional, and with %d rows.', this.dim()) 211 end 212 if (~isa(varargin{2},'numeric') || ~(mod(varargin{2},1)==0) || varargin{2}>this.dim()) 213 error('Input argument no. 2 must be an integer smaller than %d.', this.dim()) 214 end 215 [varargout{1:nargout}] = mex_gsTHBSpline('hess', this.objectHandle, varargin{:}); 216 end 217 218 % active - call class method 219 function [varargout] = active(this, varargin) 220 %active - active functions of a gsTHBSpline object 221 % 222 %Usage: 223 % act = thb.active( pts ) 224 % 225 %Input: 226 % thb: gsTHBSpline, [1 x 1]. 227 % The gsTHBSpline object. 228 % pts: double, [d x numPts]. 229 % Points in which to evaluate the function. 230 % 231 %Output: 232 % act: double, [numFun x numPts]. 233 % Index of active functions in each of the specified points. 234 235 if (nargin~=2 || nargout>1) 236 error('Invalid number of input and/or output arguments.') 237 end 238 if (~isa(varargin{1},'numeric') || ~ismatrix(varargin{1}) || ~isequal(size(varargin{1},1),this.dim())) 239 error('Input argument no. 1 must be numeric, 2-dimensional, and with d rows.') 240 end 241 [varargout{1:nargout}] = mex_gsTHBSpline('active', this.objectHandle, varargin{:}); 242 end 243 244 % basis - call class method 245 function [varargout] = basis(this, varargin) 246 %basis - returns the gsTHBSplineBasis object linked to a 247 % gsTHBSpline object 248 % 249 %Usage: 250 % act = thb.basis() 251 % 252 %Input: 253 % thb: gsTHBSpline, [1 x 1]. 254 % The gsTHBSpline object. 255 % 256 %Output: 257 % basis: gsTHBSplineBasis. 258 259 if (nargin~=1 || nargout>1) 260 error('Invalid number of input and/or output arguments.') 261 end 262 basis_ptr = mex_gsTHBSpline('basis', this.objectHandle, varargin{:}); 263 [varargout{1:nargout}] = gsTHBSplineBasis(basis_ptr); 264 end 265 266 end 267end 268