Skip to content

Commit

Permalink
n with several outputs
Browse files Browse the repository at this point in the history
`n` with more than one output (or one output different than the first)
gives the size along those dimensions.

`&` is defined for `n` as specifying a number of outputs equal to the
number of dimensions. So `&n` gives the size split in numbers.
  • Loading branch information
lmendo committed Jul 20, 2016
1 parent e0a3be7 commit 2ae5052
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 2 deletions.
Binary file modified doc/MATL_spec.pdf
Binary file not shown.
Binary file modified doc/function_table.pdf
Binary file not shown.
Binary file modified funDef.mat
Binary file not shown.
6 changes: 5 additions & 1 deletion funDef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,11 @@ Zm 1 2 2 1 1 1 1 true true true true if numel(in)==1, x=1; for t=in{1}(:).', x=
clear nd sz1 sz2 rm1 rm2 insx1 insx2
end
end
n 1 1 1 1 1 1 true true true true out{1} = numel(in{:}); number of elements in array \matlab+numel+
n 1 1 1 1 inf 1 ndims(in{1}) true true true true if numel(out)==1 number of elements in array / size along each dimension \matlab+numel+. For several outputs, or a single output other than the first, gives \matlab+size+ along those dimensions
out{1} = numel(in{:});
else
[out{:}] = size(in{:});
end
Xn 1 2 2 1 1 1 1 true true true true if numel(in)==2 binomial coefficient (number of combinations) (i) If $2$ inputs: \matlab+nchoosek+. This interprets first input as number(s). If the inputs are arrays, the function is computed element-wise with singleton expansion. For values \matlab+n+ and \matlab+k+ in first and second inputs, if \matlab+n+ is less than \matlab+k+ the result is \matlab+0+. (ii) If $1$ input: multinomial coefficient. The input contains the lower terms; their sum is the upper term. \sa \matl|XN|
nd = max(ndims(in{1}), ndims(in{2})); sz1 = arrayfun(@(n)size(in{1},n), 1:nd); sz2 = arrayfun(@(n)size(in{2},n), 1:nd);
assert(all(sz1==sz2 | sz1==1 | sz2==1), 'MATL:runtime', 'MATL run-time error: inputs have incompatible sizes')
Expand Down
4 changes: 3 additions & 1 deletion genHelp.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@
case {'[false true]' '[false,true]' '[false, true]'}
altOutStr = '2nd'; % It should be specified '2nd of 2'. But it's longer. Up to now its always "x-th
% up to the maximum number", so I don't specify
case {'[false true false]' '[false,true,false]' '[false, true, false]'}
case {'[false true false]' '[false,true,false]' '[false, true, false]'}
altOutStr = '2nd';
case {'ndims(in{1})'}
altOutStr = 'number of dimensions of first input';
otherwise
error('Unrecognized alternative number of outputs')
end
Expand Down
Binary file modified help.mat
Binary file not shown.

0 comments on commit 2ae5052

Please sign in to comment.