function [dp] = dict( dp, state ) % function [dp] = dict( dp, state ) % % Part of my kernel dictionary implementation. state is a column % vector, which may or may not be added to the dictionary, based on % whether or not its features are almost-linearly-dependent of % other points in the dictionary. % % INPUT: % dp - data structure representing problem setup, returned from % dict_init or subsequent calls to this function. % state - a new data point % % OUTPUT: % dp - an updated data structure. % % m = size( dp.Dict, 2 ); % number of entries ktt = feval( dp.kfunc, state, state, dp.kparam ); ktwid = feval( dp.kfunc, dp.Dict, state, dp.kparam ); at = dp.Kinv * ktwid; dt = ktt - ktwid' * at; dp.addedFlag = 0; if ( dt > dp.thresh ) % Not ALD; add to dictionary dp.Dict = [ dp.Dict , state ]; dp.K = [ dp.K, ktwid; ktwid', ktt ]; dp.Kinv = (1/dt) * [ dt*(dp.Kinv) + at*at', -at; -at', 1 ]; dp.addedFlag = 1; end; dp.at = at; dp.dt = dt; dp.ktwid = ktwid; kp.ktt = ktt; return;