Mercurial > octave-antonio
comparison scripts/linear-algebra/cross.m @ 11587:c792872f8942
all script files: untabify and strip trailing whitespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:35:29 -0500 |
parents | fd0a3ac60b0e |
children | ad05e1547398 |
comparison
equal
deleted
inserted
replaced
11586:12df7854fa7c | 11587:c792872f8942 |
---|---|
27 ## cross ([1,1,0], [0,1,1]) | 27 ## cross ([1,1,0], [0,1,1]) |
28 ## @result{} [ 1; -1; 1 ] | 28 ## @result{} [ 1; -1; 1 ] |
29 ## @end group | 29 ## @end group |
30 ## @end example | 30 ## @end example |
31 ## | 31 ## |
32 ## If @var{x} and @var{y} are matrices, the cross product is applied | 32 ## If @var{x} and @var{y} are matrices, the cross product is applied |
33 ## along the first dimension with 3 elements. The optional argument | 33 ## along the first dimension with 3 elements. The optional argument |
34 ## @var{dim} forces the cross product to be calculated along | 34 ## @var{dim} forces the cross product to be calculated along |
35 ## the specified dimension. | 35 ## the specified dimension. |
36 ## @seealso{dot} | 36 ## @seealso{dot} |
37 ## @end deftypefn | 37 ## @end deftypefn |
38 | 38 |
39 ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> | 39 ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> |
40 ## Created: 15 October 1994 | 40 ## Created: 15 October 1994 |
41 ## Adapted-By: jwe | 41 ## Adapted-By: jwe |
42 | 42 |
43 function z = cross (x, y, dim) | 43 function z = cross (x, y, dim) |
44 | 44 |
45 if (nargin != 2 && nargin != 3) | 45 if (nargin != 2 && nargin != 3) |
46 print_usage (); | 46 print_usage (); |
47 endif | 47 endif |
48 | 48 |
49 if (ndims (x) < 3 && ndims (y) < 3 && nargin < 3) | 49 if (ndims (x) < 3 && ndims (y) < 3 && nargin < 3) |
59 endif | 59 endif |
60 endif | 60 endif |
61 | 61 |
62 if (nargin == 2) | 62 if (nargin == 2) |
63 dim = find (size (x) == 3, 1); | 63 dim = find (size (x) == 3, 1); |
64 if (isempty (dim)) | 64 if (isempty (dim)) |
65 error ("cross: must have at least one dimension with 3 elements"); | 65 error ("cross: must have at least one dimension with 3 elements"); |
66 endif | 66 endif |
67 else | 67 else |
68 if (size (x, dim) != 3) | 68 if (size (x, dim) != 3) |
69 error ("cross: dimension DIM must have 3 elements"); | 69 error ("cross: dimension DIM must have 3 elements"); |