Line | |
---|
1 | function t = sum(a, dim) |
---|
2 | % SUM Sum of elements. |
---|
3 | % (Quaternion overloading of standard Matlab function.) |
---|
4 | |
---|
5 | % Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan. |
---|
6 | % See the file : Copyright.m for further details. |
---|
7 | |
---|
8 | error(nargchk(1, 2, nargin)), error(nargoutchk(0, 1, nargout)) |
---|
9 | |
---|
10 | if nargin == 1 |
---|
11 | if ispure(a) |
---|
12 | t = quaternion(sum(x(a)), ... |
---|
13 | sum(y(a)),.... |
---|
14 | sum(z(a))); |
---|
15 | else |
---|
16 | t = quaternion(sum(s(a)), sum(v(a))); |
---|
17 | end |
---|
18 | else |
---|
19 | if dim == 'double' | dim == 'native' |
---|
20 | error('Parameters ''double'' or ''native'' are not implemented.'); |
---|
21 | else |
---|
22 | if ispure(a) |
---|
23 | t = quaternion(sum(x(a), dim), ... |
---|
24 | sum(y(a), dim), ... |
---|
25 | sum(z(a), dim)); |
---|
26 | else |
---|
27 | t = quaternion(sum(s(a), dim), sum(v(a), dim)); |
---|
28 | end |
---|
29 | end |
---|
30 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.