This is a static copy of a profile report

Home

cross (5 calls, 0.011 sec)
Generated 05-Aug-2011 13:01:32 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/specfun/cross.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
pointing_modelfunction5
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
30
if ~isequal(size(a),size(b)),
50.011 s100.0%
59
if rowvec, c = c.'; end
50 s0%
58
c = ipermute(c,perm);
50 s0%
55
c = reshape(c,size(a));
50 s0%
52
c = [a(2,:).*b(3,:)-a(3,:).*b(...
50 s0%
All other lines  0 s0%
Totals  0.011 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
ipermutefunction50 s0%
Self time (built-ins, overhead, etc.)  0.011 s100.0%
Totals  0.011 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function59
Non-code lines (comments, blank lines)35
Code lines (lines that can run)24
Code lines that did run18
Code lines that did not run6
Coverage (did run/can run)75.00 %
Function listing
   time   calls  line
1 function c = cross(a,b,dim)
2 %CROSS Vector cross product.
3 % C = CROSS(A,B) returns the cross product of the vectors
4 % A and B. That is, C = A x B. A and B must be 3 element
5 % vectors.
6 %
7 % C = CROSS(A,B) returns the cross product of A and B along the
8 % first dimension of length 3.
9 %
10 % C = CROSS(A,B,DIM), where A and B are N-D arrays, returns the cross
11 % product of vectors in the dimension DIM of A and B. A and B must
12 % have the same size, and both SIZE(A,DIM) and SIZE(B,DIM) must be 3.
13 %
14 % Class support for inputs A,B:
15 % float: double, single
16 %
17 % See also DOT.
18
19 % Copyright 1984-2010 The MathWorks, Inc.
20 % $Revision: 5.18.4.5 $ $Date: 2010/08/23 23:13:01 $
21
22 % Special case: A and B are vectors
5 23 rowvec = 0;
5 24 if ismatrix(a) && ismatrix(b) && nargin<3
5 25 if size(a,1)==1, a = a(:); rowvec = 1; end
5 26 if size(b,1)==1, b = b(:); rowvec = 1; end
5 27 end;
28
29 % Check dimensions
0.01 5 30 if ~isequal(size(a),size(b)),
31 error(message('MATLAB:cross:InputSizeMismatch'));
32 end
33
5 34 if nargin == 2
5 35 dim = find(size(a)==3,1);
5 36 if isempty(dim),
37 error(message('MATLAB:cross:InvalidDimAorB'));
38 end
5 39 end;
40
41 % Check dimensions
5 42 if (size(a,dim)~=3) || (size(b,dim)~=3),
43 error(message('MATLAB:cross:InvalidDimAorBForCrossProd'))
44 end
45
46 % Permute so that DIM becomes the row dimension
5 47 perm = [dim:max(length(size(a)),dim) 1:dim-1];
5 48 a = permute(a,perm);
5 49 b = permute(b,perm);
50
51 % Calculate cross product
5 52 c = [a(2,:).*b(3,:)-a(3,:).*b(2,:)
53 a(3,:).*b(1,:)-a(1,:).*b(3,:)
54 a(1,:).*b(2,:)-a(2,:).*b(1,:)];
5 55 c = reshape(c,size(a));
56
57 % Post-process.
5 58 c = ipermute(c,perm);
5 59 if rowvec, c = c.'; end