wolffd@0: function [errorcode, rows, columns] = rndcheck(nargs,nparms,arg1,arg2,arg3,arg4,arg5) wolffd@0: %RNDCHECK error checks the argument list for the random number generators. wolffd@0: wolffd@0: % B.A. Jones 1-22-93 wolffd@0: % Copyright (c) 1993-98 by The MathWorks, Inc. wolffd@0: % $Revision: 1.1.1.1 $ $Date: 2005/04/26 02:29:22 $ wolffd@0: wolffd@0: sizeinfo = nargs - nparms; wolffd@0: errorcode = 0; wolffd@0: wolffd@0: if nparms == 3 wolffd@0: [r1 c1] = size(arg1); wolffd@0: [r2 c2] = size(arg2); wolffd@0: [r3 c3] = size(arg3); wolffd@0: end wolffd@0: wolffd@0: if nparms == 2 wolffd@0: [r1 c1] = size(arg1); wolffd@0: [r2 c2] = size(arg2); wolffd@0: end wolffd@0: wolffd@0: if sizeinfo == 0 wolffd@0: if nparms == 1 wolffd@0: [rows columns] = size(arg1); wolffd@0: end wolffd@0: wolffd@0: if nparms == 2 wolffd@0: scalararg1 = (prod(size(arg1)) == 1); wolffd@0: scalararg2 = (prod(size(arg2)) == 1); wolffd@0: if ~scalararg1 & ~scalararg2 wolffd@0: if r1 ~= r2 | c1 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: if ~scalararg1 wolffd@0: [rows columns] = size(arg1); wolffd@0: elseif ~scalararg2 wolffd@0: [rows columns] = size(arg2); wolffd@0: else wolffd@0: [rows columns] = size(arg1); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if nparms == 3 wolffd@0: scalararg1 = (prod(size(arg1)) == 1); wolffd@0: scalararg2 = (prod(size(arg2)) == 1); wolffd@0: scalararg3 = (prod(size(arg3)) == 1); wolffd@0: wolffd@0: if ~scalararg1 & ~scalararg2 wolffd@0: if r1 ~= r2 | c1 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~scalararg1 & ~scalararg3 wolffd@0: if r1 ~= r3 | c1 ~= c3 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~scalararg3 & ~scalararg2 wolffd@0: if r3 ~= r2 | c3 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: if ~scalararg1 wolffd@0: [rows columns] = size(arg1); wolffd@0: elseif ~scalararg2 wolffd@0: [rows columns] = size(arg2); wolffd@0: else wolffd@0: [rows columns] = size(arg3); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if sizeinfo == 1 wolffd@0: scalararg1 = (prod(size(arg1)) == 1); wolffd@0: if nparms == 1 wolffd@0: if prod(size(arg2)) ~= 2 wolffd@0: errorcode = 2; wolffd@0: return; wolffd@0: end wolffd@0: if ~scalararg1 & arg2 ~= size(arg1) wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: if (arg2(1) < 0 | arg2(2) < 0 | arg2(1) ~= round(arg2(1)) | arg2(2) ~= round(arg2(2))), wolffd@0: errorcode = 4; wolffd@0: return; wolffd@0: end wolffd@0: rows = arg2(1); wolffd@0: columns = arg2(2); wolffd@0: end wolffd@0: wolffd@0: if nparms == 2 wolffd@0: if prod(size(arg3)) ~= 2 wolffd@0: errorcode = 2; wolffd@0: return; wolffd@0: end wolffd@0: scalararg2 = (prod(size(arg2)) == 1); wolffd@0: if ~scalararg1 & ~scalararg2 wolffd@0: if r1 ~= r2 | c1 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: if (arg3(1) < 0 | arg3(2) < 0 | arg3(1) ~= round(arg3(1)) | arg3(2) ~= round(arg3(2))), wolffd@0: errorcode = 4; wolffd@0: return; wolffd@0: end wolffd@0: if ~scalararg1 wolffd@0: if any(arg3 ~= size(arg1)) wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: [rows columns] = size(arg1); wolffd@0: elseif ~scalararg2 wolffd@0: if any(arg3 ~= size(arg2)) wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: [rows columns] = size(arg2); wolffd@0: else wolffd@0: rows = arg3(1); wolffd@0: columns = arg3(2); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if nparms == 3 wolffd@0: if prod(size(arg4)) ~= 2 wolffd@0: errorcode = 2; wolffd@0: return; wolffd@0: end wolffd@0: scalararg1 = (prod(size(arg1)) == 1); wolffd@0: scalararg2 = (prod(size(arg2)) == 1); wolffd@0: scalararg3 = (prod(size(arg3)) == 1); wolffd@0: wolffd@0: if (arg4(1) < 0 | arg4(2) < 0 | arg4(1) ~= round(arg4(1)) | arg4(2) ~= round(arg4(2))), wolffd@0: errorcode = 4; wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: if ~scalararg1 & ~scalararg2 wolffd@0: if r1 ~= r2 | c1 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~scalararg1 & ~scalararg3 wolffd@0: if r1 ~= r3 | c1 ~= c3 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~scalararg3 & ~scalararg2 wolffd@0: if r3 ~= r2 | c3 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: if ~scalararg1 wolffd@0: if any(arg4 ~= size(arg1)) wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: [rows columns] = size(arg1); wolffd@0: elseif ~scalararg2 wolffd@0: if any(arg4 ~= size(arg2)) wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: [rows columns] = size(arg2); wolffd@0: elseif ~scalararg3 wolffd@0: if any(arg4 ~= size(arg3)) wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: [rows columns] = size(arg3); wolffd@0: else wolffd@0: rows = arg4(1); wolffd@0: columns = arg4(2); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if sizeinfo == 2 wolffd@0: if nparms == 1 wolffd@0: scalararg1 = (prod(size(arg1)) == 1); wolffd@0: if ~scalararg1 wolffd@0: [rows columns] = size(arg1); wolffd@0: if rows ~= arg2 | columns ~= arg3 wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: if (arg2 < 0 | arg3 < 0 | arg2 ~= round(arg2) | arg3 ~= round(arg3)), wolffd@0: errorcode = 4; wolffd@0: return; wolffd@0: end wolffd@0: rows = arg2; wolffd@0: columns = arg3; wolffd@0: end wolffd@0: wolffd@0: if nparms == 2 wolffd@0: scalararg1 = (prod(size(arg1)) == 1); wolffd@0: scalararg2 = (prod(size(arg2)) == 1); wolffd@0: if ~scalararg1 & ~scalararg2 wolffd@0: if r1 ~= r2 | c1 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: if ~scalararg1 wolffd@0: [rows columns] = size(arg1); wolffd@0: if rows ~= arg3 | columns ~= arg4 wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: elseif ~scalararg2 wolffd@0: [rows columns] = size(arg2); wolffd@0: if rows ~= arg3 | columns ~= arg4 wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: else wolffd@0: if (arg3 < 0 | arg4 < 0 | arg3 ~= round(arg3) | arg4 ~= round(arg4)), wolffd@0: errorcode = 4; wolffd@0: return; wolffd@0: end wolffd@0: rows = arg3; wolffd@0: columns = arg4; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if nparms == 3 wolffd@0: scalararg1 = (prod(size(arg1)) == 1); wolffd@0: scalararg2 = (prod(size(arg2)) == 1); wolffd@0: scalararg3 = (prod(size(arg3)) == 1); wolffd@0: wolffd@0: if ~scalararg1 & ~scalararg2 wolffd@0: if r1 ~= r2 | c1 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~scalararg1 & ~scalararg3 wolffd@0: if r1 ~= r3 | c1 ~= c3 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~scalararg3 & ~scalararg2 wolffd@0: if r3 ~= r2 | c3 ~= c2 wolffd@0: errorcode = 1; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~scalararg1 wolffd@0: [rows columns] = size(arg1); wolffd@0: if rows ~= arg4 | columns ~= arg5 wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: elseif ~scalararg2 wolffd@0: [rows columns] = size(arg2); wolffd@0: if rows ~= arg4 | columns ~= arg5 wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: elseif ~scalararg3 wolffd@0: [rows columns] = size(arg3); wolffd@0: if rows ~= arg4 | columns ~= arg5 wolffd@0: errorcode = 3; wolffd@0: return; wolffd@0: end wolffd@0: else wolffd@0: if (arg4 < 0 | arg5 < 0 | arg4 ~= round(arg4) | arg5 ~= round(arg5)), wolffd@0: errorcode = 4; wolffd@0: return; wolffd@0: end wolffd@0: rows = arg4; wolffd@0: columns = arg5; wolffd@0: end wolffd@0: end wolffd@0: end