Mercurial > hg > ltpda
diff m-toolbox/classes/@matrix/rdivide.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@matrix/rdivide.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,106 @@ +% RDIVIDE implements division operator for matrix objects. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: RDIVIDE implements division operator for two matrix objects. +% +% CALL: obj = obj1./obj2 +% obj = rdivide(obj1,obj2); +% obj = rdivide(obj1,obj2,obj3) == rdivide(rdivide(obj1,obj2),obj3) +% +% REMARK: More than two inputs are handled with nested calls. +% (This doesn't work at the moment. Do we need this?) +% +% <a href="matlab:utils.helper.displayMethodInfo('matrix', 'rdivide')">Parameters Description</a> +% +% VERSION: $Id: rdivide.m,v 1.8 2011/04/08 08:56:31 hewitson Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = rdivide(varargin) + + callerIsMethod = utils.helper.callerIsMethod; + + % Check if this is a call for parameters + if utils.helper.isinfocall(varargin{:}) + varargout{1} = getInfo(varargin{3}); + return + end + + if nargout == 0 + error('### Division operator can not be used as a modifier.'); + end + + op = 'rdivide'; + opname = 'dividion'; + opsym = './'; + infoObj = getInfo('None'); + + % collect input variable names + in_names = cell(size(varargin)); + for ii = 1:nargin,if ~isa(varargin{ii}, 'plist'), in_names{ii} = inputname(ii); end, end + + % Collect all plists + [pl, pl_invars, rest] = utils.helper.collect_objects(varargin(:), 'plist', in_names); + + % Combine default plist + pl = combine(pl, getDefaultPlist()); + + mat = matrix.elementOp(callerIsMethod, op, opname, opsym, infoObj, pl, rest, in_names); + + %%%%%%%%%% Prepare output %%%%%%%%%% + if nargout == numel(mat) + for kk=1:numel(mat) + varargout{kk} = mat(kk); + end + else + varargout{1} = mat; + end + +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Local Functions % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% FUNCTION: getInfo +% +% DESCRIPTION: Get Info Object +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function ii = getInfo(varargin) + + if nargin == 1 && strcmpi(varargin{1}, 'None') + sets = {}; + pls = []; + else + sets = {'Default'}; + pls = getDefaultPlist; + end + % Build info object + ii = minfo(mfilename, 'matrix', 'ltpda', utils.const.categories.aop, '$Id: rdivide.m,v 1.8 2011/04/08 08:56:31 hewitson Exp $', sets, pls); + ii.setArgsmin(2); + ii.setModifier(false); +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% FUNCTION: getDefaultPlist +% +% DESCRIPTION: Get Default Plist +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function plout = getDefaultPlist() + persistent pl; + if exist('pl', 'var')==0 || isempty(pl) + pl = buildplist(); + end + plout = pl; +end + +function pl = buildplist() + pl = plist.EMPTY_PLIST; +end