www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgtabgradconstraint/private/pGetWorkingStore.m

    function StoreData = pGetWorkingStore(obj, AxisValues, StoreProperty)
%PGETWORKINGSTORE Retrieve data that infrequently changes
%
%   STOREDATA = PGETWORKINGSTORE(OBJ, AXISVALUES, 'SURFACEGENDATA')
%   retrieves the cached data required to evaluate the surface generation
%   function in OBJ.
%
%   STOREDATA = PGETWORKINGSTORE(OBJ, AXISVALUES, 'DIFFOPANDBOUND')
%   retrieves the cached data pertaining to the difference operator and
%   gradient bounds in OBJ.
%
%   STOREDATA = PGETWORKINGSTORE(OBJ, AXISVALUES, 'AXISVALUES') retrieves
%   the currently cached AXISVALUES.
%
%   STOREDATA = PGETWORKINGSTORE(OBJ, AXISVALUES) retrieves all the
%   above cached data. STOREDATA is returned as a structure, with fields
%   SurfaceGenData, DiffOpAndBound and AxisValues.
%
%   See also PEVALUATERUN

%   Copyright 2007 The MathWorks, Inc.

% Update the working store if required
AxisValuesStruct = obj.WorkingStore.getAxisValues();
if ~isequal(AxisValues, AxisValuesStruct.AxisValues)

    % Axis values
    NewWorkingStore.AxisValues.AxisValues = AxisValues;
    NewWorkingStore.AxisValues.ISEDGE = i_CheckEdgeCases(AxisValues);
    if NewWorkingStore.AxisValues.ISEDGE
        obj = pInitEdgeCase(obj);
    end
    
    % Data for surface generation function
    NewWorkingStore.SurfaceGenData = obj.SurfaceGenFcn(...
        obj.ScaledAxisBreakpoints, AxisValues, [], 'FixedData');
    
    % Data for difference operator
    [D, g] = pGetDG(obj);
    [D, g, idxReq, idxReqCon] = pFilterGridPts(obj, AxisValues, D, g);
    NewWorkingStore.DiffOpAndBound.D = D;
    NewWorkingStore.DiffOpAndBound.g = g;
    NewWorkingStore.DiffOpAndBound.idxReq = idxReq;
    NewWorkingStore.DiffOpAndBound.idxReqCon = idxReqCon;
        
    % Update the working store
    obj.WorkingStore.setWorkingStore(NewWorkingStore);

end

% Return the required data 
if nargin < 3
    StoreProperty = 'all';
end
if strcmpi(StoreProperty, 'surfacegendata')
    StoreData = obj.WorkingStore.getSurfaceGenData();
elseif strcmpi(StoreProperty, 'diffopandbound')
    StoreData = obj.WorkingStore.getDiffOpAndBound();
elseif strcmpi(StoreProperty, 'axisvalues')
    StoreData = obj.WorkingStore.getAxisValues();
else
    StoreData = obj.WorkingStore.getWorkingStore();
end

%--------------------------------------------------------------------------
function ISEDGE = i_CheckEdgeCases(AxisValues)
%--------------------------------------------------------------------------

persistent fColinear

if isempty(fColinear)
    % store function handles for cgmathobjects function in persistent data
    % to avoid unnecessary construction of these handles
    fColinear = gethandle(cgmathsobject,'isColinear');
end


% Find the unique points
uniqueAxisValues = unique(AxisValues, 'rows');
szAxis = size(uniqueAxisValues);

% 2-d Edge cases
if szAxis(2) > 1 && (szAxis(1) < 4 || fColinear(AxisValues))
    ISEDGE = true;
else
    ISEDGE = false;
end