Rev | Line | |
---|
[37] | 1 | function d = mdot(a, b) |
---|
| 2 | % Matrix dot (scalar) product. Like dot, but matrix not elementwise. |
---|
| 3 | |
---|
| 4 | % Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan. |
---|
| 5 | % See the file : Copyright.m for further details. |
---|
| 6 | |
---|
| 7 | error(nargchk(2, 2, nargin)), error(nargoutchk(0, 1, nargout)) |
---|
| 8 | |
---|
| 9 | if ~isa(a, 'quaternion') | ~isa(b, 'quaternion') |
---|
| 10 | error('mdot product is not defined for a quaternion and a non-quaternion.') |
---|
| 11 | end |
---|
| 12 | |
---|
| 13 | % This function is defined for full and pure quaternions, and combinations |
---|
| 14 | % of full and pure, in which case we assume a zero scalar part for the pure |
---|
| 15 | % argument. |
---|
| 16 | |
---|
| 17 | if ispure(a) | ispure(b) |
---|
| 18 | % This covers the case where either or both are pure. We can ignore the |
---|
| 19 | % scalar part of the other, since it is implicitly multiplied by zero. |
---|
| 20 | |
---|
| 21 | d = x(a) * x(b) + y(a) * y(b) + z(a) * z(b); |
---|
| 22 | else |
---|
| 23 | d = s(a) * s(b) + x(a) * x(b) + y(a) * y(b) + z(a) * z(b); |
---|
| 24 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.