13
13
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:lang="en" xml:id="mtlb_sum">
15
<refname>mtlb_sum</refname>
16
<refpurpose>Matlab sum emulation function</refpurpose>
19
<title>Description</title>
21
Matlab and Scilab <literal>sum</literal> behave differently in some particular cases:
26
When called with one input: Matlab <literal>sum</literal> threts the values along the first
27
non-singleton dimension of input while Scilab <literal>sum</literal> threats all values of input.
32
When called with two inputs: Matlab <literal>sum</literal> can be used with second input giving
33
a non-existing dimension of first input while Scilab <literal>sum</literal> returns an error message.
38
The function <literal>mtlb_sum(A[,dim])</literal> is used by
39
<literal>mfile2sci</literal> to replace <literal>sum(A[,dim])</literal> when it was not
40
possible to know what were the inputs while porting Matlab code to Scilab. This function will
41
determine the correct semantic at run time. If you want to have a
42
more efficient code it is possible to replace <literal>mtlb_sum</literal> calls:
47
When called with one input, if <literal>A</literal> is an empty matrix, a scalar or a vector,
48
<literal>mtlb_sum(A)</literal> may be replaced by <literal>sum(A)</literal>
53
When called with one input, if <literal>A</literal> is a not-empty matrix,
54
<literal>mtlb_sum(A)</literal> may be replaced by <literal>sum(A,1)</literal>
59
When called with one input, if <literal>A</literal> is a multidimensional array,
60
<literal>mtlb_sum(A)</literal> may be replaced by <literal>sum(A,firstnonsingleton(A))</literal>
65
When called with two inputs, if <literal>dim</literal> is lesser than the number of dimensions of <literal>A</literal>
66
<literal>mtlb_sum(A,dim)</literal> may be replaced by <literal>sum(A,dim)</literal>
71
Caution: <literal>mtlb_sum</literal> has not to be used for hand coded functions.
74
<refsection role="see also">
75
<title>See Also</title>
76
<simplelist type="inline">
78
<link linkend="firstnonsingleton">firstnonsingleton</link>
15
<refname>mtlb_sum</refname>
16
<refpurpose>Matlab sum emulation function</refpurpose>
19
<title>Description</title>
21
Matlab and Scilab <literal>sum</literal> behave differently in some particular cases:
26
When called with one input: Matlab <literal>sum</literal> threts the values along the first
27
non-singleton dimension of input while Scilab <literal>sum</literal> threats all values of input.
32
When called with two inputs: Matlab <literal>sum</literal> can be used with second input giving
33
a non-existing dimension of first input while Scilab <literal>sum</literal> returns an error message.
38
The function <literal>mtlb_sum(A[,dim])</literal> is used by
39
<literal>mfile2sci</literal> to replace <literal>sum(A[,dim])</literal> when it was not
40
possible to know what were the inputs while porting Matlab code to Scilab. This function will
41
determine the correct semantic at run time. If you want to have a
42
more efficient code it is possible to replace <literal>mtlb_sum</literal> calls:
47
When called with one input, if <literal>A</literal> is an empty matrix, a scalar or a vector,
48
<literal>mtlb_sum(A)</literal> may be replaced by <literal>sum(A)</literal>
53
When called with one input, if <literal>A</literal> is a not-empty matrix,
54
<literal>mtlb_sum(A)</literal> may be replaced by <literal>sum(A,1)</literal>
59
When called with one input, if <literal>A</literal> is a multidimensional array,
60
<literal>mtlb_sum(A)</literal> may be replaced by <literal>sum(A,firstnonsingleton(A))</literal>
65
When called with two inputs, if <literal>dim</literal> is lesser than the number of dimensions of <literal>A</literal>
66
<literal>mtlb_sum(A,dim)</literal> may be replaced by <literal>sum(A,dim)</literal>
71
Caution: <literal>mtlb_sum</literal> has not to be used for hand coded functions.
74
<refsection role="see also">
75
<title>See Also</title>
76
<simplelist type="inline">
78
<link linkend="firstnonsingleton">firstnonsingleton</link>