1 namespace dscomponents{
109 this =
this@dscomponents.ACoreFun(sys);
115 this.jend[nr], this.jrow[nr], this.jself[nr], this.
S[nr]*x, t);
132 this.jend[nr], this.jrow[nr], this.jself[nr], this.
S[nr]*x, t, mu);
152 this.jend[nr], this.jrow[nr], this.jself[nr],...
153 this.
S[nr]*x, t) * this.
S[nr];
183 this.jend[nr], this.jrow[nr], this.deriv[nr], ...
184 this.jself[nr], this.
S[nr]*x, t, this.dfxsel[nr]);
214 singlemu = size(mu,2) == 1;
223 t =
double.empty(0,size(x,2));
224 elseif length(t) == 1
225 t = ones(1,size(x,2))*
t;
231 J = zeros(length(this.deriv[nr]), m);
232 for idx = 1:size(x,2)
237 this.jend[nr], this.jrow[nr], this.deriv[nr], ...
238 this.jself[nr], this.
S[nr]*x(:,idx),
t(idx), this.dfxsel[nr]);
277 warning(
" KerMor:Devel ",[
" Point set numbering seems to " ...
278 " be used in a different context. 1-4 are safe to work "...
279 " with at this stage, make sure nothing gets overridden. "]);
285 if length(unique(pts)) ~= length(pts)
286 error(
" Points have to be unique. ");
291 jr = []; js =
logical.empty(0,1);
292 je = zeros(1,length(pts));
300 dfx_sel = sparse(length(pts),0);
303 sprow = SP(pts(i),:);
307 warning(
" setPointSet: Found all-zero Jacobian row for point %d. Using first state-space dof as 'dependency' ",pts(i));
311 js = [js inew == pts(i)];
319 full_mapping = [full_mapping sprow(des_der)];
324 [~, dpos, matchidx] = intersect(des_der, inew);
328 [~, sidx] =
sort(dpos);
329 pos =
reshape(matchidx(sidx),1,[]);
338 deri = [deri pos+offs];
342 requested_len = requested_len + length(des_der);
346 dfx_sel(i,(end+1):(end+length(inew))) = 1;
351 warning(
" Empty JSparsityPattern. DEIM approximation will not use any state space arguments. ");
361 this.
S[nr] = this.
V(sel,:);
363 this.
S[nr] = sparse(1:len,sel,ones(len,1),len,this.
xDim);
370 this.deriv[nr] = deri^
t;
373 at = find(full_mapping);
381 this.T[nr] = sparse(at,1:length(at),ones(length(at),1),...
382 requested_len,length(at));
384 this.dfxsel[nr] =
logical(dfx_sel);
404 target =
project@dscomponents.ACoreFun(
this, V, W, target);
407 for i=1:length(this.
S)
408 if ~isempty(this.
S[i])
409 target.S[i] = this.
S[i]*
V;
416 copy =
clone@dscomponents.ACoreFun(
this, copy);
419 copy.jrow= this.jrow;
420 copy.jend= this.jend;
421 copy.jself= this.jself;
422 copy.deriv= this.deriv;
423 copy.dfxsel= this.dfxsel;
429 #if 0 //mtoc++: 'get.PointSets'
440 error(
" Cannot run test for projected ACompEvalCoreFuns. ");
446 x = rand(this.
xDim,xsize);
457 s = RandStream(
" mt19937ar ",
" Seed ",2);
460 setsizes = s.randi(200, nsets, 1);
461 sets =
cell(nsets,1);
462 for i = 1:length(setsizes)
463 sets[i] = unique(s.randi(size(fx,1),1,setsizes(i)));
466 if size(fx,1) <= 10000
467 sets[end+1] = 1:size(fx,1);
471 for idx=1:length(sets)
476 err = abs((tmp-fxc)./tmp);
479 lres = isempty(d) || d < 1e-3;
480 if ~lres || d > 10*sqrt(eps)
481 fprintf(2,
" Warning! ACompEvalCoreFun evaluation test: Max rel. diff. for component wise vs. full evaluation: %e\n ",full(d));
503 X = repmat(x,1,d); T = repmat(t,1,d); MU = repmat(this.
mu,1,d);
507 - repmat(hlp,1,d))/dt;
542 X = repmat(x,1,d); T = repmat(t,1,d);
544 I = sparse(deriv,1:d,ones(1,d),size(x,1),d)*dt;
547 dfx = dfx(repmat(dfxsel(:,deriv),1,xd));
585 el =
reshape(repmat(1:xd,d,1),1,[]);
586 X = x(:,el); T =
t(el); MU =
mu(:,el);
587 I = repmat(sparse(deriv,1:d,ones(1,d),size(x,1),d)*dt,1,xd);
590 dfx = dfx(repmat(dfxsel(:,deriv),1,xd));
608 fx = zeros(length(pts),size(x,2));
664 obj.jself= from.jself;
665 obj.deriv= from.deriv;
666 obj.dfxsel= from.dfxsel;
668 obj =
loadobj@dscomponents.ACoreFun(obj, from);
670 obj =
loadobj@dscomponents.ACoreFun(obj);
function res = test_ComponentEvalMatch(xsize)
Tests if the local implementation of evaluateComponents matches the full evaluation.
function J = evaluateJacobianSet(integer nr,colvec< double > x,double t)
Returns the jacobian entries of the point set that have been specified using setPointSet's argument j...
function prepareSimulation(colvec< double > mu)
A method that allows parameter-dependent computations to be performed before a simulation using this ...
A MatLab cell array or matrix.
virtual function fx = evaluateComponents(rowvec< integer > pts,rowvec< integer > ends,rowvec< integer > idx,rowvec< integer > self,matrix< double > x,rowvec< double > t,colvec< double > mu)
This is the template method that actually evaluates the components at given points and values...
sort
ort the handle objects in any array in ascending or descending order.
function dfx = evaluateComponentPartialDerivatives(rowvec< integer > pts,rowvec< integer > ends,rowvec< integer > idx,rowvec< integer > deriv,rowvec< integer > self,colvec< double > x,double t, dfxsel)
Computes specified partial derivatives of of the components given by pts and the selected partial de...
reshape
hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape ...
function fx = evaluateComponentSetMulti(integer nr,matrix< double > x,rowvec< double > t,matrix< double > mu)
Computes the full component functions of the given point set.
matrix< double > S
The x-component selection matrices (precomputed on setting PointSet/AltPointSet). �S� is passed to ...
Basic interface for all dynamical system's core functions Inherits the AProjectable interface...
integer xDim
The current state space dimension of the function's argument .
function copy = clone(copy)
The interface method with returns a copy of the current class instance.
V
The matrix of the biorthogonal pair .
colvec< double > mu
The current model parameter mu for evaluations. Will not be persisted as only valid for runtime durin...
function setPointSet(nr, pts, jpd)
Parameters: pts: A row vector with the desired points jpd: ("Jacobian Partial Derivatives") A cell ar...
function target = project(V, W, target)
function matrix< double > dfx = evaluateComponentGradientsAt(rowvec< integer > pts,rowvec< integer > ends,rowvec< integer > idx,rowvec< integer > self,colvec< double > x,double t)
Default implementation of gradient computation via finite differences.
sparse< logical > JSparsityPattern
Sparsity pattern for the jacobian matrix.
function fx = evaluateComponentsMulti(pts, ends, idx, self,colvec< double > x,double t,colvec< double > mu)
ACompEvalCoreFun: A normal CoreFun which supports single-component evaluation.
function fx = evaluateMulti(colvec< double > x,double t,colvec< double > mu)
Evaluates this function on multiple locations and maybe multiple times and parameters.
static function obj = loadobj(obj, from)
function J = evaluateJacobianSetMulti(integer nr,matrix< double > x,rowvec< double > t,colvec< double > mu)
Returns the jacobian entries at multiple locations/times/parameters of the point set that have been s...
W
The matrix of the biorthogonal pair .
function dfx = evaluateComponentSetGradientsAt(integer nr,colvec< double > x,double t)
Computes the full/reduced gradients of all component functions of the given point set...
function dfx = evaluateComponentPartialDerivativesMulti(pts, ends, idx, deriv, self,colvec< double > x,double t,colvec< double > mu, dfxsel)
Multi-argument evaluation method for partial derivatives. Not used so far in KerMor, this is "legacy code" to keep around if needed at any stage as default finite difference-implementation.
function fx = evaluateComponentSet(integer nr,colvec< double > x,double t)
Computes the full or reduced component functions of the given point set.