gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/+matlab/+bigdata/+internal/+lazyeval/ElementwiseOperation.m
%ElementwiseOperation % An operation that acts on each element of data. % Copyright 2015-2016 The MathWorks, Inc. classdef (Sealed) ElementwiseOperation < matlab.bigdata.internal.lazyeval.Operation properties (SetAccess = immutable) % The function handle for the operation. FunctionHandle; end methods % The main constructor. function obj = ElementwiseOperation(functionHandle, numInputs, numOutputs) supportsPreview = true; obj = obj@matlab.bigdata.internal.lazyeval.Operation(numInputs, numOutputs, supportsPreview); obj.FunctionHandle = functionHandle; end end % Methods overridden in the Operation interface. methods function task = createExecutionTasks(obj, taskDependencies, inputFutureMap, isInputReplicated) import matlab.bigdata.internal.executor.ExecutionTask; import matlab.bigdata.internal.lazyeval.ChunkwiseProcessor; processorFactory = ChunkwiseProcessor.createFactory(... obj.FunctionHandle, obj.NumOutputs, inputFutureMap, isInputReplicated, @iVerifySizeConstraint); task = ExecutionTask.createSimpleTask(taskDependencies, processorFactory); end end end % Verify that the size for all outputs matches the non-singleton size of the inputs. function err = iVerifySizeConstraint(inputs, outputs) expectedSize = size(inputs{1}); for ii = 2:numel(inputs) sz = size(inputs{ii}); expectedSize(end + 1 : numel(sz)) = 1; expectedSize(sz ~= 1) = sz(sz ~= 1); end for ii = 1:numel(outputs) actualSize = size(outputs{ii}); if ~isequal(actualSize, expectedSize) err = MException(message('MATLAB:bigdata:array:InvalidOutputSize', ... ii, mat2str(actualSize), mat2str(expectedSize))); return; end end err = []; end