diff --git a/PIV_2D_wdef.m b/PIV_2D_wdef.m index a915cd55c872c8c5de7c680abd8e163582b270ad..fedce4c24696491ee07846b641514c316ac12d6a 100644 --- a/PIV_2D_wdef.m +++ b/PIV_2D_wdef.m @@ -79,7 +79,8 @@ function piv_result = PIV_2D_wdef(A, B, mask, piv_setup) 'win_x', empty, 'win_y', empty, ... 'ux', empty, 'uy', empty, ... 'nan_mask', empty, 'Q', empty, ... - 'peak_mag', empty, 'peak_choice', empty); + 'peak_mag', empty, 'peak_choice', empty, ... + 'dt', empty); %% ITERATE OVER PASSES for pass = 1 : n_passes @@ -305,7 +306,8 @@ function piv_result = PIV_2D_wdef(A, B, mask, piv_setup) 'nan_mask', nan_mask, ... 'Q', Q, ... 'peak_mag', peak_mag, ... - 'peak_choice', peak_choice); + 'peak_choice', peak_choice, ... + 'dt', piv_dt); %% save displacement field from this pass % into "old" displacement field structure diff --git a/ext/inpaintn/inpaint_nans.m b/ext/inpaintn/inpaint_nans.m new file mode 100644 index 0000000000000000000000000000000000000000..2460b512c670354cf221aef327b1bbae1da99757 --- /dev/null +++ b/ext/inpaintn/inpaint_nans.m @@ -0,0 +1 @@ +function B=inpaint_nans(A,method) % INPAINT_NANS: in-paints over nans in an array % usage: B=INPAINT_NANS(A) % default method % usage: B=INPAINT_NANS(A,method) % specify method used % % Solves approximation to one of several pdes to % interpolate and extrapolate holes in an array % % arguments (input): % A - nxm array with some NaNs to be filled in % % method - (OPTIONAL) scalar numeric flag - specifies % which approach (or physical metaphor to use % for the interpolation.) All methods are capable % of extrapolation, some are better than others. % There are also speed differences, as well as % accuracy differences for smooth surfaces. % % methods {0,1,2} use a simple plate metaphor. % method 3 uses a better plate equation, % but may be much slower and uses % more memory. % method 4 uses a spring metaphor. % method 5 is an 8 neighbor average, with no % rationale behind it compared to the % other methods. I do not recommend % its use. % % method == 0 --> (DEFAULT) see method 1, but % this method does not build as large of a % linear system in the case of only a few % NaNs in a large array. % Extrapolation behavior is linear. % % method == 1 --> simple approach, applies del^2 % over the entire array, then drops those parts % of the array which do not have any contact with % NaNs. Uses a least squares approach, but it % does not modify known values. % In the case of small arrays, this method is % quite fast as it does very little extra work. % Extrapolation behavior is linear. % % method == 2 --> uses del^2, but solving a direct % linear system of equations for nan elements. % This method will be the fastest possible for % large systems since it uses the sparsest % possible system of equations. Not a least % squares approach, so it may be least robust % to noise on the boundaries of any holes. % This method will also be least able to % interpolate accurately for smooth surfaces. % Extrapolation behavior is linear. % % Note: method 2 has problems in 1-d, so this % method is disabled for vector inputs. % % method == 3 --+ See method 0, but uses del^4 for % the interpolating operator. This may result % in more accurate interpolations, at some cost % in speed. % % method == 4 --+ Uses a spring metaphor. Assumes % springs (with a nominal length of zero) % connect each node with every neighbor % (horizontally, vertically and diagonally) % Since each node tries to be like its neighbors, % extrapolation is as a constant function where % this is consistent with the neighboring nodes. % % method == 5 --+ See method 2, but use an average % of the 8 nearest neighbors to any element. % This method is NOT recommended for use. % % % arguments (output): % B - nxm array with NaNs replaced % % % Example: % [x,y] = meshgrid(0:.01:1); % z0 = exp(x+y); % znan = z0; % znan(20:50,40:70) = NaN; % znan(30:90,5:10) = NaN; % znan(70:75,40:90) = NaN; % % z = inpaint_nans(znan); % % % See also: griddata, interp1 % % Author: John D'Errico % e-mail address: woodchips@rochester.rr.com % Release: 2 % Release date: 4/15/06 % I always need to know which elements are NaN, % and what size the array is for any method [n,m]=size(A); A=A(:); nm=n*m; k=isnan(A(:)); % list the nodes which are known, and which will % be interpolated nan_list=find(k); known_list=find(~k); % how many nans overall nan_count=length(nan_list); % convert NaN indices to (r,c) form % nan_list==find(k) are the unrolled (linear) indices % (row,column) form [nr,nc]=ind2sub([n,m],nan_list); % both forms of index in one array: % column 1 == unrolled index % column 2 == row index % column 3 == column index nan_list=[nan_list,nr,nc]; % supply default method if (nargin<2) || isempty(method) method = 0; elseif ~ismember(method,0:5) error 'If supplied, method must be one of: {0,1,2,3,4,5}.' end % for different methods switch method case 0 % The same as method == 1, except only work on those % elements which are NaN, or at least touch a NaN. % is it 1-d or 2-d? if (m == 1) || (n == 1) % really a 1-d case work_list = nan_list(:,1); work_list = unique([work_list;work_list - 1;work_list + 1]); work_list(work_list <= 1) = []; work_list(work_list >= nm) = []; nw = numel(work_list); u = (1:nw)'; fda = sparse(repmat(u,1,3),bsxfun(@plus,work_list,-1:1), ... repmat([1 -2 1],nw,1),nw,nm); else % a 2-d case % horizontal and vertical neighbors only talks_to = [-1 0;0 -1;1 0;0 1]; neighbors_list=identify_neighbors(n,m,nan_list,talks_to); % list of all nodes we have identified all_list=[nan_list;neighbors_list]; % generate sparse array with second partials on row % variable for each element in either list, but only % for those nodes which have a row index > 1 or < n L = find((all_list(:,2) > 1) & (all_list(:,2) < n)); nl=length(L); if nl>0 fda=sparse(repmat(all_list(L,1),1,3), ... repmat(all_list(L,1),1,3)+repmat([-1 0 1],nl,1), ... repmat([1 -2 1],nl,1),nm,nm); else fda=spalloc(n*m,n*m,size(all_list,1)*5); end % 2nd partials on column index L = find((all_list(:,3) > 1) & (all_list(:,3) < m)); nl=length(L); if nl>0 fda=fda+sparse(repmat(all_list(L,1),1,3), ... repmat(all_list(L,1),1,3)+repmat([-n 0 n],nl,1), ... repmat([1 -2 1],nl,1),nm,nm); end end % eliminate knowns rhs=-fda(:,known_list)*A(known_list); k=find(any(fda(:,nan_list(:,1)),2)); % and solve... B=A; B(nan_list(:,1))=fda(k,nan_list(:,1))\rhs(k); case 1 % least squares approach with del^2. Build system % for every array element as an unknown, and then % eliminate those which are knowns. % Build sparse matrix approximating del^2 for % every element in A. % is it 1-d or 2-d? if (m == 1) || (n == 1) % a 1-d case u = (1:(nm-2))'; fda = sparse(repmat(u,1,3),bsxfun(@plus,u,0:2), ... repmat([1 -2 1],nm-2,1),nm-2,nm); else % a 2-d case % Compute finite difference for second partials % on row variable first [i,j]=ndgrid(2:(n-1),1:m); ind=i(:)+(j(:)-1)*n; np=(n-2)*m; fda=sparse(repmat(ind,1,3),[ind-1,ind,ind+1], ... repmat([1 -2 1],np,1),n*m,n*m); % now second partials on column variable [i,j]=ndgrid(1:n,2:(m-1)); ind=i(:)+(j(:)-1)*n; np=n*(m-2); fda=fda+sparse(repmat(ind,1,3),[ind-n,ind,ind+n], ... repmat([1 -2 1],np,1),nm,nm); end % eliminate knowns rhs=-fda(:,known_list)*A(known_list); k=find(any(fda(:,nan_list),2)); % and solve... B=A; B(nan_list(:,1))=fda(k,nan_list(:,1))\rhs(k); case 2 % Direct solve for del^2 BVP across holes % generate sparse array with second partials on row % variable for each nan element, only for those nodes % which have a row index > 1 or < n % is it 1-d or 2-d? if (m == 1) || (n == 1) % really just a 1-d case error('Method 2 has problems for vector input. Please use another method.') else % a 2-d case L = find((nan_list(:,2) > 1) & (nan_list(:,2) < n)); nl=length(L); if nl>0 fda=sparse(repmat(nan_list(L,1),1,3), ... repmat(nan_list(L,1),1,3)+repmat([-1 0 1],nl,1), ... repmat([1 -2 1],nl,1),n*m,n*m); else fda=spalloc(n*m,n*m,size(nan_list,1)*5); end % 2nd partials on column index L = find((nan_list(:,3) > 1) & (nan_list(:,3) < m)); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,3), ... repmat(nan_list(L,1),1,3)+repmat([-n 0 n],nl,1), ... repmat([1 -2 1],nl,1),n*m,n*m); end % fix boundary conditions at extreme corners % of the array in case there were nans there if ismember(1,nan_list(:,1)) fda(1,[1 2 n+1])=[-2 1 1]; end if ismember(n,nan_list(:,1)) fda(n,[n, n-1,n+n])=[-2 1 1]; end if ismember(nm-n+1,nan_list(:,1)) fda(nm-n+1,[nm-n+1,nm-n+2,nm-n])=[-2 1 1]; end if ismember(nm,nan_list(:,1)) fda(nm,[nm,nm-1,nm-n])=[-2 1 1]; end % eliminate knowns rhs=-fda(:,known_list)*A(known_list); % and solve... B=A; k=nan_list(:,1); B(k)=fda(k,k)\rhs(k); end case 3 % The same as method == 0, except uses del^4 as the % interpolating operator. % del^4 template of neighbors talks_to = [-2 0;-1 -1;-1 0;-1 1;0 -2;0 -1; ... 0 1;0 2;1 -1;1 0;1 1;2 0]; neighbors_list=identify_neighbors(n,m,nan_list,talks_to); % list of all nodes we have identified all_list=[nan_list;neighbors_list]; % generate sparse array with del^4, but only % for those nodes which have a row & column index % >= 3 or <= n-2 L = find( (all_list(:,2) >= 3) & ... (all_list(:,2) <= (n-2)) & ... (all_list(:,3) >= 3) & ... (all_list(:,3) <= (m-2))); nl=length(L); if nl>0 % do the entire template at once fda=sparse(repmat(all_list(L,1),1,13), ... repmat(all_list(L,1),1,13) + ... repmat([-2*n,-n-1,-n,-n+1,-2,-1,0,1,2,n-1,n,n+1,2*n],nl,1), ... repmat([1 2 -8 2 1 -8 20 -8 1 2 -8 2 1],nl,1),nm,nm); else fda=spalloc(n*m,n*m,size(all_list,1)*5); end % on the boundaries, reduce the order around the edges L = find((((all_list(:,2) == 2) | ... (all_list(:,2) == (n-1))) & ... (all_list(:,3) >= 2) & ... (all_list(:,3) <= (m-1))) | ... (((all_list(:,3) == 2) | ... (all_list(:,3) == (m-1))) & ... (all_list(:,2) >= 2) & ... (all_list(:,2) <= (n-1)))); nl=length(L); if nl>0 fda=fda+sparse(repmat(all_list(L,1),1,5), ... repmat(all_list(L,1),1,5) + ... repmat([-n,-1,0,+1,n],nl,1), ... repmat([1 1 -4 1 1],nl,1),nm,nm); end L = find( ((all_list(:,2) == 1) | ... (all_list(:,2) == n)) & ... (all_list(:,3) >= 2) & ... (all_list(:,3) <= (m-1))); nl=length(L); if nl>0 fda=fda+sparse(repmat(all_list(L,1),1,3), ... repmat(all_list(L,1),1,3) + ... repmat([-n,0,n],nl,1), ... repmat([1 -2 1],nl,1),nm,nm); end L = find( ((all_list(:,3) == 1) | ... (all_list(:,3) == m)) & ... (all_list(:,2) >= 2) & ... (all_list(:,2) <= (n-1))); nl=length(L); if nl>0 fda=fda+sparse(repmat(all_list(L,1),1,3), ... repmat(all_list(L,1),1,3) + ... repmat([-1,0,1],nl,1), ... repmat([1 -2 1],nl,1),nm,nm); end % eliminate knowns rhs=-fda(:,known_list)*A(known_list); k=find(any(fda(:,nan_list(:,1)),2)); % and solve... B=A; B(nan_list(:,1))=fda(k,nan_list(:,1))\rhs(k); case 4 % Spring analogy % interpolating operator. % list of all springs between a node and a horizontal % or vertical neighbor hv_list=[-1 -1 0;1 1 0;-n 0 -1;n 0 1]; hv_springs=[]; for i=1:4 hvs=nan_list+repmat(hv_list(i,:),nan_count,1); k=(hvs(:,2)>=1) & (hvs(:,2)<=n) & (hvs(:,3)>=1) & (hvs(:,3)<=m); hv_springs=[hv_springs;[nan_list(k,1),hvs(k,1)]]; end % delete replicate springs hv_springs=unique(sort(hv_springs,2),'rows'); % build sparse matrix of connections, springs % connecting diagonal neighbors are weaker than % the horizontal and vertical springs nhv=size(hv_springs,1); springs=sparse(repmat((1:nhv)',1,2),hv_springs, ... repmat([1 -1],nhv,1),nhv,nm); % eliminate knowns rhs=-springs(:,known_list)*A(known_list); % and solve... B=A; B(nan_list(:,1))=springs(:,nan_list(:,1))\rhs; case 5 % Average of 8 nearest neighbors % generate sparse array to average 8 nearest neighbors % for each nan element, be careful around edges fda=spalloc(n*m,n*m,size(nan_list,1)*9); % -1,-1 L = find((nan_list(:,2) > 1) & (nan_list(:,3) > 1)); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,2), ... repmat(nan_list(L,1),1,2)+repmat([-n-1, 0],nl,1), ... repmat([1 -1],nl,1),n*m,n*m); end % 0,-1 L = find(nan_list(:,3) > 1); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,2), ... repmat(nan_list(L,1),1,2)+repmat([-n, 0],nl,1), ... repmat([1 -1],nl,1),n*m,n*m); end % +1,-1 L = find((nan_list(:,2) < n) & (nan_list(:,3) > 1)); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,2), ... repmat(nan_list(L,1),1,2)+repmat([-n+1, 0],nl,1), ... repmat([1 -1],nl,1),n*m,n*m); end % -1,0 L = find(nan_list(:,2) > 1); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,2), ... repmat(nan_list(L,1),1,2)+repmat([-1, 0],nl,1), ... repmat([1 -1],nl,1),n*m,n*m); end % +1,0 L = find(nan_list(:,2) < n); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,2), ... repmat(nan_list(L,1),1,2)+repmat([1, 0],nl,1), ... repmat([1 -1],nl,1),n*m,n*m); end % -1,+1 L = find((nan_list(:,2) > 1) & (nan_list(:,3) < m)); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,2), ... repmat(nan_list(L,1),1,2)+repmat([n-1, 0],nl,1), ... repmat([1 -1],nl,1),n*m,n*m); end % 0,+1 L = find(nan_list(:,3) < m); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,2), ... repmat(nan_list(L,1),1,2)+repmat([n, 0],nl,1), ... repmat([1 -1],nl,1),n*m,n*m); end % +1,+1 L = find((nan_list(:,2) < n) & (nan_list(:,3) < m)); nl=length(L); if nl>0 fda=fda+sparse(repmat(nan_list(L,1),1,2), ... repmat(nan_list(L,1),1,2)+repmat([n+1, 0],nl,1), ... repmat([1 -1],nl,1),n*m,n*m); end % eliminate knowns rhs=-fda(:,known_list)*A(known_list); % and solve... B=A; k=nan_list(:,1); B(k)=fda(k,k)\rhs(k); end % all done, make sure that B is the same shape as % A was when we came in. B=reshape(B,n,m); % ==================================================== % end of main function % ==================================================== % ==================================================== % begin subfunctions % ==================================================== function neighbors_list=identify_neighbors(n,m,nan_list,talks_to) % identify_neighbors: identifies all the neighbors of % those nodes in nan_list, not including the nans % themselves % % arguments (input): % n,m - scalar - [n,m]=size(A), where A is the % array to be interpolated % nan_list - array - list of every nan element in A % nan_list(i,1) == linear index of i'th nan element % nan_list(i,2) == row index of i'th nan element % nan_list(i,3) == column index of i'th nan element % talks_to - px2 array - defines which nodes communicate % with each other, i.e., which nodes are neighbors. % % talks_to(i,1) - defines the offset in the row % dimension of a neighbor % talks_to(i,2) - defines the offset in the column % dimension of a neighbor % % For example, talks_to = [-1 0;0 -1;1 0;0 1] % means that each node talks only to its immediate % neighbors horizontally and vertically. % % arguments(output): % neighbors_list - array - list of all neighbors of % all the nodes in nan_list if ~isempty(nan_list) % use the definition of a neighbor in talks_to nan_count=size(nan_list,1); talk_count=size(talks_to,1); nn=zeros(nan_count*talk_count,2); j=[1,nan_count]; for i=1:talk_count nn(j(1):j(2),:)=nan_list(:,2:3) + ... repmat(talks_to(i,:),nan_count,1); j=j+nan_count; end % drop those nodes which fall outside the bounds of the % original array L = (nn(:,1)<1)|(nn(:,1)>n)|(nn(:,2)<1)|(nn(:,2)>m); nn(L,:)=[]; % form the same format 3 column array as nan_list neighbors_list=[sub2ind([n,m],nn(:,1),nn(:,2)),nn]; % delete replicates in the neighbors list neighbors_list=unique(neighbors_list,'rows'); % and delete those which are also in the list of NaNs. neighbors_list=setdiff(neighbors_list,nan_list,'rows'); else neighbors_list=[]; end \ No newline at end of file diff --git a/ext/inpaintn/inpaint_nans_bc.m b/ext/inpaintn/inpaint_nans_bc.m new file mode 100644 index 0000000000000000000000000000000000000000..d6ae57ebfdf8b789146c3ae31ce73fd7749aa80e --- /dev/null +++ b/ext/inpaintn/inpaint_nans_bc.m @@ -0,0 +1 @@ +function B=inpaint_nans_bc(A,method,bcclass) % INPAINT_NANS_BC: in-paints over nans in an array, with spherical or toroidal boundary conditions % usage: B=inpaint_nsns_bc(A) % default method % usage: B=inpaint_nsns_bc(A,method) % specify method used % usage: B=inpaint_nsns_bc(A,method,bcclass) % specify class of boundary conditions applied % % Solves approximation to one of several pdes to % interpolate and extrapolate holes in an array. % Depending upon the boundary conditions specified, % the array will effectively be treated as if it lies % on either the surface of a sphere or a toroid. % % arguments (input): % A - nxm array with some NaNs to be filled in % % method - (OPTIONAL) scalar numeric flag - specifies % which approach (or physical metaphor to use % for the interpolation.) All methods are capable % of extrapolation, some are better than others. % There are also speed differences, as well as % accuracy differences for smooth surfaces. % % The methods employed here are a subset of the % methods of the original inpaint_nans. % % methods {0,1} use a simple plate metaphor. % method 4 uses a spring metaphor. % % method == 0 --> (DEFAULT) see method 1, but % this method does not build as large of a % linear system in the case of only a few % NaNs in a large array. % Extrapolation behavior is linear. % % method == 1 --> simple approach, applies del^2 % over the entire array, then drops those parts % of the array which do not have any contact with % NaNs. Uses a least squares approach, but it % does not modify known values. % In the case of small arrays, this method is % quite fast as it does very little extra work. % Extrapolation behavior is linear. % % method == 4 --> Uses a spring metaphor. Assumes % springs (with a nominal length of zero) % connect each node with every neighbor % (horizontally, vertically and diagonally) % Since each node tries to be like its neighbors, % extrapolation is as a constant function where % this is consistent with the neighboring nodes. % % DEFAULT: 0 % % bcclass - (OPTIONAL) character flag, indicating how % the array boundaries will be treated in the % inpainting operation. bcclass may be either % 'sphere' or 'toroid', or any simple contraction % of these words. % % bcclass = 'sphere' --> The first and last rows % of the array will be treated as if they are % at the North and South poles of a sphere. % Adjacent to those rows will be singular % phantom nodes at each pole. % % bcclass = 'toroid' --> The first and last rows % of the array will be treated as if they are % adjacent to ech other. As well, the first and % last columns will be adjacent to each other. % % DEFAULT: 'sphere' % % arguments (output): % B - nxm array with NaNs replaced % % % Example: % [x,y] = meshgrid(0:.01:1); % z0 = exp(x+y); % znan = z0; % znan(20:50,40:70) = NaN; % znan(30:90,5:10) = NaN; % znan(70:75,40:90) = NaN; % % z = inpaint_nans(znan); % % % See also: griddata, interp1 % % Author: John D'Errico % e-mail address: woodchips@rochester.rr.com % Release: 2 % Release date: 4/15/06 % I always need to know which elements are NaN, % and what size the array is for any method [n,m]=size(A); A=A(:); nm=n*m; k=isnan(A(:)); % list those nodes which are known, and which will % be interpolated nan_list=find(k); known_list=find(~k); % how many nans overall nan_count=length(nan_list); % convert NaN indices to (r,c) form % nan_list==find(k) are the unrolled (linear) indices % (row,column) form [nr,nc]=ind2sub([n,m],nan_list); % both forms of index in one array: % column 1 == unrolled index % column 2 == row index % column 3 == column index nan_list=[nan_list,nr,nc]; % supply default method if (nargin<2) || isempty(method) method = 0; elseif ~ismember(method,[0 1 4]) error('INPAINT_NANS_BC:improperargument', ... 'If supplied, method must be one of: {0,1,4}.') end % supply default value for bcclass if (nargin < 3) || isempty(bcclass) bcclass = 'sphere'; elseif ~ischar(bcclass) error('INPAINT_NANS_BC:improperargument', ... 'If supplied, bcclass must be ''sphere'' or ''toroid''') else % it was a character string valid = {'sphere' 'toroid'}; % check to see if it is valid [bcclass,errorclass] = validstring(arg,valid); if ~isempty(errorclass) error('INPAINT_NANS_BC:improperargument', ... 'If supplied, bcclass must be ''sphere'' or ''toroid''') end end % choice of methods switch method case 0 % The same as method == 1, except only work on those % elements which are NaN, or at least touch a NaN. % horizontal and vertical neighbors only talks_to = [-1 0;0 -1;1 0;0 1]; neighbors_list=identify_neighbors(n,m,nan_list,talks_to); % list of all nodes we have identified all_list=[nan_list;neighbors_list]; % generate sparse array with second partials on row % variable for each element in either list, but only % for those nodes which have a row index > 1 or < n L = find((all_list(:,2) > 1) & (all_list(:,2) < n)); nl=length(L); if nl>0 fda=sparse(repmat(all_list(L,1),1,3), ... repmat(all_list(L,1),1,3)+repmat([-1 0 1],nl,1), ... repmat([1 -2 1],nl,1),nm,nm); else fda=spalloc(n*m,n*m,size(all_list,1)*5); end % 2nd partials on column index L = find((all_list(:,3) > 1) & (all_list(:,3) < m)); nl=length(L); if nl>0 fda=fda+sparse(repmat(all_list(L,1),1,3), ... repmat(all_list(L,1),1,3)+repmat([-n 0 n],nl,1), ... repmat([1 -2 1],nl,1),nm,nm); end % eliminate knowns rhs=-fda(:,known_list)*A(known_list); k=find(any(fda(:,nan_list(:,1)),2)); % and solve... B=A; B(nan_list(:,1))=fda(k,nan_list(:,1))\rhs(k); case 1 % least squares approach with del^2. Build system % for every array element as an unknown, and then % eliminate those which are knowns. % Build sparse matrix approximating del^2 for % every element in A. % Compute finite difference for second partials % on row variable first [i,j]=ndgrid(1:n,1:m); ind=i(:)+(j(:)-1)*n; np=n*m; switch bcclass case 'sphere' % we need to have two phantom nodes at the poles np = np + 2; end fda=sparse(repmat(ind,1,3),[ind-1,ind,ind+1], ... repmat([1 -2 1],np,1),n*m,n*m); % now second partials on column variable [i,j]=ndgrid(1:n,2:(m-1)); ind=i(:)+(j(:)-1)*n; np=n*(m-2); fda=fda+sparse(repmat(ind,1,3),[ind-n,ind,ind+n], ... repmat([1 -2 1],np,1),nm,nm); % eliminate knowns rhs=-fda(:,known_list)*A(known_list); k=find(any(fda(:,nan_list),2)); % and solve... B=A; B(nan_list(:,1))=fda(k,nan_list(:,1))\rhs(k); case 4 % Spring analogy % interpolating operator. % list of all springs between a node and a horizontal % or vertical neighbor hv_list=[-1 -1 0;1 1 0;-n 0 -1;n 0 1]; hv_springs=[]; for i=1:4 hvs=nan_list+repmat(hv_list(i,:),nan_count,1); k=(hvs(:,2)>=1) & (hvs(:,2)<=n) & (hvs(:,3)>=1) & (hvs(:,3)<=m); hv_springs=[hv_springs;[nan_list(k,1),hvs(k,1)]]; end % delete replicate springs hv_springs=unique(sort(hv_springs,2),'rows'); % build sparse matrix of connections, springs % connecting diagonal neighbors are weaker than % the horizontal and vertical springs nhv=size(hv_springs,1); springs=sparse(repmat((1:nhv)',1,2),hv_springs, ... repmat([1 -1],nhv,1),nhv,nm); % eliminate knowns rhs=-springs(:,known_list)*A(known_list); % and solve... B=A; B(nan_list(:,1))=springs(:,nan_list(:,1))\rhs; end % all done, make sure that B is the same shape as % A was when we came in. B=reshape(B,n,m); end % mainline % ==================================================== % end of main function % ==================================================== % ==================================================== % begin subfunctions % ==================================================== function neighbors_list=identify_neighbors(n,m,nan_list,talks_to) % identify_neighbors: identifies all the neighbors of % those nodes in nan_list, not including the nans % themselves % % arguments (input): % n,m - scalar - [n,m]=size(A), where A is the % array to be interpolated % nan_list - array - list of every nan element in A % nan_list(i,1) == linear index of i'th nan element % nan_list(i,2) == row index of i'th nan element % nan_list(i,3) == column index of i'th nan element % talks_to - px2 array - defines which nodes communicate % with each other, i.e., which nodes are neighbors. % % talks_to(i,1) - defines the offset in the row % dimension of a neighbor % talks_to(i,2) - defines the offset in the column % dimension of a neighbor % % For example, talks_to = [-1 0;0 -1;1 0;0 1] % means that each node talks only to its immediate % neighbors horizontally and vertically. % % arguments(output): % neighbors_list - array - list of all neighbors of % all the nodes in nan_list if ~isempty(nan_list) % use the definition of a neighbor in talks_to nan_count=size(nan_list,1); talk_count=size(talks_to,1); nn=zeros(nan_count*talk_count,2); j=[1,nan_count]; for i=1:talk_count nn(j(1):j(2),:)=nan_list(:,2:3) + ... repmat(talks_to(i,:),nan_count,1); j=j+nan_count; end % form the same format 3 column array as nan_list neighbors_list=[sub2ind([n,m],nn(:,1),nn(:,2)),nn]; % delete replicates in the neighbors list neighbors_list=unique(neighbors_list,'rows'); % and delete those which are also in the list of NaNs. neighbors_list=setdiff(neighbors_list,nan_list,'rows'); else neighbors_list=[]; end end % function identify_neighbors function [str,errorclass] = validstring(arg,valid) % validstring: compares a string against a set of valid options % usage: [str,errorclass] = validstring(arg,valid) % % If a direct hit, or any unambiguous shortening is found, that % string is returned. Capitalization is ignored. % % arguments: (input) % arg - character string, to be tested against a list % of valid choices. Capitalization is ignored. % % valid - cellstring array of alternative choices % % Arguments: (output) % str - string - resulting choice resolved from the % list of valid arguments. If no unambiguous % choice can be resolved, then str will be empty. % % errorclass - string - A string argument that explains % the error. It will be one of the following % possibilities: % % '' --> No error. An unambiguous match for arg % was found among the choices. % % 'No match found' --> No match was found among % the choices provided in valid. % % 'Ambiguous argument' --> At least two ambiguous % matches were found among those provided % in valid. % % % Example: % valid = {'off' 'on' 'The sky is falling'} % % % See also: parse_pv_pairs, strmatch, strcmpi % % Author: John D'Errico % e-mail: woodchips@rochester.rr.com % Release: 1.0 % Release date: 3/25/2010 ind = strmatch(lower(arg),lower(valid)); if isempty(ind) % No hit found errorclass = 'No match found'; str = ''; elseif (length(ind) > 1) % Ambiguous arg, hitting more than one of the valid options errorclass = 'Ambiguous argument'; str = ''; return else errorclass = ''; str = valid{ind}; end end % function validstring \ No newline at end of file diff --git a/ext/inpaintn/inpaint_nans_demo.m b/ext/inpaintn/inpaint_nans_demo.m new file mode 100644 index 0000000000000000000000000000000000000000..2163cc078c2be660871c911c740c6fa6281b126c --- /dev/null +++ b/ext/inpaintn/inpaint_nans_demo.m @@ -0,0 +1,43 @@ +%% Surface Fit Artifact Removal + +%% Construct the Surface +[x,y] = meshgrid(0:.01:1); +z0 = exp(x+y); + +close all +figure +surf(z0) +title 'Original surface' + +znan = z0; +znan(20:50,40:70) = NaN; +znan(30:90,5:10) = NaN; +znan(70:75,40:90) = NaN; + +figure +surf(znan) +title 'Artifacts (large holes) in surface' + +%% In-paint Over NaNs +z = inpaint_nans(znan,3); +figure +surf(z) +title 'Inpainted surface' + +figure +surf(z-z0) +title 'Inpainting error surface (Note z-axis scale)' + +%% Comapre to GRIDDATA +k = isnan(znan); +zk = griddata(x(~k),y(~k),z(~k),x(k),y(k)); +zg = znan; +zg(k) = zk; + +figure +surf(zg) +title(['Griddata inpainting (',num2str(sum(isnan(zg(:)))),' NaNs remain)']) + +figure +surf(zg-z0) +title 'Griddata error surface' diff --git a/ext/mmx/build_mmx.m b/ext/mmx/build_mmx.m new file mode 100644 index 0000000000000000000000000000000000000000..f8aa64d94b0806cfe143e94a15f945f51543c158 --- /dev/null +++ b/ext/mmx/build_mmx.m @@ -0,0 +1,231 @@ +function build_mmx(verbose) +% BUILD_MMX - compiles mmx() for different platforms and provides help +% regarding compilation. +% +% BUILD_MMX will try to compile, in this order, 3 different builds of mmx: +% mmx_mkl_single - linked to Intel's single-threaded MKL library (usually fastest) +% mmx_mkl_multi - linked to the multithreaded BLAS/LAPACK libraries that come +% with Matlab. +% mmx_naive - does not link to anything, uses simple C-loops. +% +% The first time BUILD_MMX succeeds, it will compile again to 'mmx', so +% that the mex-file mmx should be the fastest possible build on your +% system. +% +% BUILD_MMX has been tested on Win32, Win64, OSX, Linux 64 +% + +% %% FOR LINUX OR MAC SYSTEMS: +% +% To properly link to Intel's MKL, user needs to repackage their libraries +% into one single statically linked library. The instructions are as +% follows: +% +% +% Download Intel MKL for Linux here: +% http://software.intel.com/en-us/articles/non-commercial-software-download/ +% +% Donwload Intel MKL for Mac here: +% https://registrationcenter.intel.com/RegCenter/AutoGen.aspx?ProductID=1518&AccountID=&EmailID=&ProgramID=&RequestDt=&rm=EVAL&lang= +% +% The Default installation directory for both Linux and Mac will be +% /opt/intel/ +% with the MKL libraries in /opt/intel/mkl +% +% %% To build needed static Library +% assuming default installation directory +% +% Run the following commands in Linux/Mac terminal: +% +% sudo -s +% cd /opt/intel/mkl/tools/builder +% cat blas_example_list > blas_lapack_list +% cat lapack_example_list >> blas_lapack_list +% +% For Linux 64 bit: +% make libintel64 interface=ilp64 export=blas_lapack_list name=libsingle_mkl_ilp64 threading=sequential +% For Linux 32 bit: +% make libia32 interface=lp64 export=blas_lapack_list name=libsingle_mkl_32 threading=sequential +% +% For Mac: +% make libuni interface=ilp64 export=blas_lapack_list name=libsingle_mkl_ilp64 threading=sequential +% +% A new libsingle_mkl_ilp64.so, libsingle_mkl_32.so, or +% libsingle_mkl_ilp64.dylib will appear. +% This needs to be copied to Matlab's external libraries directory. +% +% For Mac: +% cp libsingle_mkl_ilp64* MATLAB_ROOT/extern/lib/maci64 +% +% For Linux 64 bit: +% cp libsingle_mkl_ilp64* MATLAB_ROOT/extern/lib/glnxa64 +% For Linux 32 bit: +% cp libsingle_mkl_32* MATLAB_ROOT/extern/lib/glnx86 +% +% Where MATLAB_ROOT is the installation directory of your Matlab. + + +if nargin == 0 + verbose = false; +end + +clc + +build_names = {'mmx_mkl_single', 'mmx_mkl_multi','mmx_naive'}; + +built_mmx = false; + +arch = computer('arch'); + +for b = 2 + name = build_names{b}; + + [link, define] = deal({}); + [inc_dir, link_dir, Cflags, Lflags] = deal(''); + + switch arch + case {'win64','win32'} + switch name + case 'mmx_naive' + define = {'WIN_SYSTEM'}; + + case 'mmx_mkl_multi' + root = matlabroot; + if strcmp(arch,'win32') + inc_dir = [root '\extern\lib\win32\microsoft']; + else + inc_dir = [root '\extern\lib\win64\microsoft']; + end + link = {'libmwblas','libmwlapack'}; + define = {'WIN_SYSTEM','USE_BLAS'}; + + case 'mmx_mkl_single' + root = 'C:\Program Files (x86)\Intel\Composer XE 2011 SP1\mkl'; + inc_dir = [root '\include']; + if strcmp(arch,'win32') + link_dir = [root '\lib\ia32']; + link = {'mkl_intel_c','mkl_sequential','mkl_core'}; + define = {'WIN_SYSTEM','USE_BLAS','MKL_32'}; + else + link_dir = [root '\lib\intel64']; + link = {'mkl_intel_ilp64','mkl_sequential','mkl_core'}; + define = {'WIN_SYSTEM','USE_BLAS','MKL_ILP64'}; + end + end + case {'glnxa64','glnx86'} + switch name + case 'mmx_naive' + link = {'pthread'}; + define = {'UNIX_SYSTEM'}; + case 'mmx_mkl_multi' + if strcmp(arch,'glnx86') + inc_dir = [matlabroot '/extern/lib/glnx86']; + else + inc_dir = [matlabroot '/extern/lib/glnxa64']; + end + link = {'mwblas','mwlapack','pthread'}; + define = {'UNIX_SYSTEM','USE_BLAS'}; + case 'mmx_mkl_single' + root = '/opt/intel/mkl'; + inc_dir = [ root '/include']; + if strcmp(arch,'glnx86') + link_dir = [matlabroot '/extern/lib/glnx86']; + link = {'single_mkl_32','pthread'}; + define = {'UNIX_SYSTEM', 'USE_BLAS', 'MKL_32'}; + else + link_dir = [matlabroot '/extern/lib/glnxa64']; + link = {'small_mkl_ilp64','pthread'}; + define = {'UNIX_SYSTEM', 'USE_BLAS', 'MKL_ILP64'}; + end + end + case {'maci64'} + switch name + case 'mmx_naive' + link = {'pthread'}; + define = {'UNIX_SYSTEM'}; + + case 'mmx_mkl_multi' + root = matlabroot; + inc_dir = [root '/extern/lib/maci64']; + link = {'mwblas','mwlapack','pthread'}; + define = {'UNIX_SYSTEM','USE_BLAS'}; + + case 'mmx_mkl_single' + root = '/opt/intel/mkl'; + inc_dir = [ root '/include']; + link_dir = [matlabroot '/extern/lib/maci64']; + link = {'single_mkl_ilp64','pthread'}; + %link = {'small_mkl_ilp64','pthread'}; + define = {'UNIX_SYSTEM', 'USE_BLAS', 'MKL_ILP64'}; + end + + otherwise + error unsupported_architecture + end + + if ~isempty(link_dir) + if strcmp(arch,'glnxa64') || strcmp(arch,'maci64') + L_dir = {['LDFLAGS="\$LDFLAGS -L' link_dir ' ' Lflags '"']}; + else + L_dir = {['-L' link_dir]}; + end + else + L_dir = {}; + end + + if ~isempty(inc_dir) + if strcmp(arch,'glnxa64') || strcmp(arch,'maci64') + I_dir = {['CXXFLAGS="\$CXXFLAGS -I' inc_dir ' ' Cflags '"']}; + else + I_dir = {['-I' inc_dir]}; + end + else + I_dir = {}; + end + + prefix = @(pref,str_array) cellfun(@(x)[pref x],str_array,'UniformOutput',0); + l_link = prefix('-l',link); + D_define = prefix('-D',define); + + if verbose + verb = {'-v'}; + else + verb = {}; + end + + try + check_dir(link_dir, link) + check_dir(inc_dir) + clear(name) + command = {verb{:}, I_dir{:}, L_dir{:}, l_link{:}, D_define{:}}; %#ok<*CCAT> + fprintf('==========\nTrying to compile ''%s'', using \n',name); + fprintf('%s, ',command{:}) + fprintf('\n') + mex(command{:}, '-output', name, 'mmx.cpp'); + fprintf('Compilation of ''%s'' succeeded.\n',name); + if ~built_mmx + fprintf('Compiling again to ''mmx'' target using ''%s'' build.\n',name); + mex(command{:}, '-output','mmx','mmx.cpp'); + built_mmx = true; + end + catch err + fprintf('Compilation of ''%s'' failed with error:\n%s\n',name,err.message); + end +end + +function check_dir(dir,files) +if ~isempty(dir) + here = cd(dir); + if nargin == 2 + for i = 1:size(files) + if isempty(ls(['*' files{i} '.*'])) + cd(here); + error('could not find file %s', files{i}); + end + end + end + cd(here); +end + + + diff --git a/ext/mmx/compare_chol_flops.m b/ext/mmx/compare_chol_flops.m new file mode 100644 index 0000000000000000000000000000000000000000..afd6368e8f0feca23d241125bcb9ec39cf2cbdf2 --- /dev/null +++ b/ext/mmx/compare_chol_flops.m @@ -0,0 +1,81 @@ + +%% === compare timings for CHOL + +R = 20; % number of repeats (to increase accuracy) + +nn = 1:1:200; + +K = length(nn); + +time = zeros(K,3,R); +ops = zeros(K,1); + +fun = { + @(a)mmx('chol',a,[]),... + @(a)mmx_MMKL('chol',a,[]),... + @(a)mmx_C('chol',a,[])%,... +% @(a)ndfun('chol',a) + }; + +names = { + 'mmx Intel',... + 'mmx MKL',... + 'mmx Emo'%,... +% 'ndfun' + }; + +for i = 1:K + + n = nn(i); + + r1 = n; + c1 = n; + + N = round(1e6 / (r1*c1)); + + A = randn(n,n,N); + A = mmx('s',A,[]); + AA = A; + + ops(i) = (n^3/3 + n^2/2 +n/6)*N; + + fprintf('cholesky algorithm on %d SPD matrices of size [%dx%d]\n',N,n,n) + + for r = 1:R + for f = 1:length(fun) + tic; + C = fun{f}(AA); + time(i,f,r) = toc; + AA = A; + end + end +end + +%% + +gflops = 1e-6*bsxfun(@times, ops, 1./time); +mFLP = mean(mflops,3); + +clf +hold on +cols = get(gca,'ColorOrder'); + +for i = 1:size(mflops,2) + plot(nn,mFLP(:,i),'color',cols(i,:),'linewidth',3); +end + +for i = 1:size(mflops,2) + plot(nn,squeeze(mflops(:,i,:)),'.','color',cols(i,:),'linewidth',2) +end + +grid on +set(gca,'xlim',[nn(1) nn(end)]) +ylabel('Mflops') +xlabel('dimension') + +legend(names{:},'location','northwest') + +title('\bf Speed Comparison between mmx and ndfun. (in Mflops, bigger is better)') + +drawnow; + diff --git a/ext/mmx/compare_mult_flops.m b/ext/mmx/compare_mult_flops.m new file mode 100644 index 0000000000000000000000000000000000000000..c0c35a81705b39e9f6ce0a01a0513cbd3786d3a1 --- /dev/null +++ b/ext/mmx/compare_mult_flops.m @@ -0,0 +1,97 @@ +%% === compare timings for MULT + +choice = questdlg('Run full comparison (several minutes)?', ... + 'Performace Comparison', 'Yes','No','Yes'); + +if strcmp(choice,'No') + return +end + +% number of repeats (to increase measurement accuracy) +R = 10; + +% what sizes of (square) matrices do we want measure? (log spacing) +nn = unique(round(exp(linspace(log(1),log(120),100)))); + +% number of different sizes to try +N = length(nn); + +% size of the output C, in Megabytes +Mbytes = 10; + +time = zeros(N,3,R); +ops = zeros(N,1); + +candidates = {'mmx, single-threaded BLAS', 'mmx_mkl_single', @(a,b)mmx_mkl_single('m',a,b); + 'mmx, multi-threaded BLAS', 'mmx_mkl_multi', @(a,b)mmx_mkl_multi('m',a,b); + 'mmx, naive loops', 'mmx_naive', @(a,b)mmx_naive('m',a,b); + 'mtimesx', 'mtimesx', @(a,b)mtimesx(a,b,'speedomp'); + 'ndfun', 'ndfun', @(a,b)ndfun('mult',a,b); + 'Matlab ''for'' loop', 'matlab_mprod', @(a,b)matlab_mprod(a,b)... +}; + +funcs = cell(0,0); +for i=1:size(candidates,1) + found_it = ~isempty(which(candidates{i,2})); + if found_it + funcs(end+1,:) = candidates(i,[1 3]); %#ok<SAGROW> + else + fprintf('Could not find %s in your path, ignoring.\n',candidates{i,2}); + end +end +nf = length(funcs); + +for i = 1:N + + n = nn(i); + + r1 = n; + c1 = n; + r2 = c1; + c2 = n; + + pages = round(1e6*Mbytes / (8*r1*c2)); + + A = randn(r1,c1,pages); + B = randn(r2,c2,pages); + + ops(i) = r1*c2*(2*c1-1)*pages; + fprintf('multiplying %d*%d matrix pairs of dimension [%dx%d]\n',R*nf,pages,n,n) + + for r = 1:R + for f = 1:nf %nf:-1:1 + tstart = tic; + C = funcs{length(funcs)+1-f,2}(A,B); + time(i,length(funcs)+1-f,r) = toc(tstart); + pause(1/10000); + end + end +end + +%% graphics + +gflops = 1e-9*bsxfun(@times, ops, 1./time); +gFLP = mean(gflops,3); + +clf +hold on +cols = get(gca,'ColorOrder'); +for i = 1:size(gflops,2) + plot(nn,gFLP(:,i),'color',cols(i,:),'linewidth',3); +end +for i = 1:size(gflops,2) + plot(nn,squeeze(gflops(:,i,:)),'.','color',cols(i,:)) +end + +grid on +set(gca,'xlim',[1 max(nn)]) +ylabel('\bf Gigaflops') +xlabel('\bf dimension') + +legend(funcs{:,1},'location','northwest') + +title('\bf Comparison between mmx, ndfun, and mtimesx. (in Gflops, bigger is better)') + +%% make PDF +% set(gcf,'color','w') +% export_fig 'comparison' -png \ No newline at end of file diff --git a/ext/mmx/comparison.fig b/ext/mmx/comparison.fig new file mode 100644 index 0000000000000000000000000000000000000000..9fbe231332638a1d7be0cb954c704e2503bd61cf Binary files /dev/null and b/ext/mmx/comparison.fig differ diff --git a/ext/mmx/corei7.pdf b/ext/mmx/corei7.pdf new file mode 100644 index 0000000000000000000000000000000000000000..3ff34f3af37d8248a0a94e08c7a690da5a46229e Binary files /dev/null and b/ext/mmx/corei7.pdf differ diff --git a/ext/mmx/dualXeon.pdf b/ext/mmx/dualXeon.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7c13b3b50b9e1dd4fb90bc2eb58547b9ab59d760 Binary files /dev/null and b/ext/mmx/dualXeon.pdf differ diff --git a/ext/mmx/html/mmx_web.html b/ext/mmx/html/mmx_web.html new file mode 100644 index 0000000000000000000000000000000000000000..93d1728db8af60beb498cd014c88c6be93c27e7e --- /dev/null +++ b/ext/mmx/html/mmx_web.html @@ -0,0 +1,439 @@ + +<!DOCTYPE html + PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <!-- +This HTML was auto-generated from MATLAB code. +To make changes, update the MATLAB code and republish this document. + --><title>MMX - Multithreaded matrix operations on N-D matrices</title><meta name="generator" content="MATLAB 7.14"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2012-07-13"><meta name="DC.source" content="mmx_web.m"><style type="text/css"> +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0} + +html { min-height:100%; margin-bottom:1px; } +html body { height:100%; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000; line-height:140%; background:#fff none; overflow-y:scroll; } +html body td { vertical-align:top; text-align:left; } + +h1 { padding:0px; margin:0px 0px 25px; font-family:Arial, Helvetica, sans-serif; font-size:1.5em; color:#d55000; line-height:100%; font-weight:normal; } +h2 { padding:0px; margin:0px 0px 8px; font-family:Arial, Helvetica, sans-serif; font-size:1.2em; color:#000; font-weight:bold; line-height:140%; border-bottom:1px solid #d6d4d4; display:block; } +h3 { padding:0px; margin:0px 0px 5px; font-family:Arial, Helvetica, sans-serif; font-size:1.1em; color:#000; font-weight:bold; line-height:140%; } + +a { color:#005fce; text-decoration:none; } +a:hover { color:#005fce; text-decoration:underline; } +a:visited { color:#004aa0; text-decoration:none; } + +p { padding:0px; margin:0px 0px 20px; } +img { padding:0px; margin:0px 0px 20px; border:none; } +p img, pre img, tt img, li img { margin-bottom:0px; } + +ul { padding:0px; margin:0px 0px 20px 23px; list-style:square; } +ul li { padding:0px; margin:0px 0px 7px 0px; } +ul li ul { padding:5px 0px 0px; margin:0px 0px 7px 23px; } +ul li ol li { list-style:decimal; } +ol { padding:0px; margin:0px 0px 20px 0px; list-style:decimal; } +ol li { padding:0px; margin:0px 0px 7px 23px; list-style-type:decimal; } +ol li ol { padding:5px 0px 0px; margin:0px 0px 7px 0px; } +ol li ol li { list-style-type:lower-alpha; } +ol li ul { padding-top:7px; } +ol li ul li { list-style:square; } + +.content { font-size:1.2em; line-height:140%; padding: 20px; } + +pre, tt, code { font-size:12px; } +pre { margin:0px 0px 20px; } +pre.error { color:red; } +pre.codeinput { padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; } +pre.codeoutput { padding:10px 11px; margin:0px 0px 20px; color:#4c4c4c; } + +@media print { pre.codeinput, pre.codeoutput { word-wrap:break-word; width:100%; } } + +span.keyword { color:#0000FF } +span.comment { color:#228B22 } +span.string { color:#A020F0 } +span.untermstring { color:#B20000 } +span.syscmd { color:#B28C00 } + +.footer { width:auto; padding:10px 0px; margin:25px 0px 0px; border-top:1px dotted #878787; font-size:0.8em; line-height:140%; font-style:italic; color:#878787; text-align:left; float:none; } +.footer p { margin:0px; } + + </style></head><body><div class="content"><h1>MMX - Multithreaded matrix operations on N-D matrices</h1><!--introduction--><p>mmx treats an N-D matrix of double precision values as a set of pages of 2D matrices, and performs various matrix operations on those pages. mmx uses multithreading over the higher dimensions to achieve good performance. Full singleton expansion is available for most operations.</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Fast N-D Multiplication</a></li><li><a href="#4">Multi-threading along the pages</a></li><li><a href="#5">Full performance comparison</a></li><li><a href="#7">Singleton Expansion</a></li><li><a href="#8">Transpose Flags</a></li><li><a href="#9">Matrix Squaring</a></li><li><a href="#11">Cholesky factorization</a></li><li><a href="#13">Backslash</a></li><li><a href="#21">Thread control</a></li><li><a href="#24">Checking of special properties</a></li><li><a href="#25">Compilation</a></li><li><a href="#26">Rant</a></li></ul></div><h2>Fast N-D Multiplication<a name="1"></a></h2><pre class="codeinput">n = 80; <span class="comment">% rows</span> +m = 40; <span class="comment">% columns</span> +N = 10000; <span class="comment">% pages</span> +A = randn(n,m,N); +B = randn(m,n,N); +tic; +C = mmx(<span class="string">'mult'</span>, A, B); +toc +</pre><pre class="codeoutput">Elapsed time is 0.258383 seconds. +</pre><pre class="codeinput">C2 = zeros(n,n,N); +tic; +<span class="keyword">for</span> i=1:N + C2(:,:,i) = A(:,:,i)*B(:,:,i); +<span class="keyword">end</span> +toc +</pre><pre class="codeoutput">Elapsed time is 1.334189 seconds. +</pre><pre class="codeinput">dispx = @(x) fprintf(<span class="string">'difference = %g\n'</span>,x); +dispx(max(abs(C(:)-C2(:)))) +</pre><pre class="codeoutput">difference = 0 +</pre><h2>Multi-threading along the pages<a name="4"></a></h2><p>Other packages like Peter Boettcher's venerable <a href="http://www.mit.edu/~pwb/matlab/">ndfun</a> Or James Tursa's <a href="http://www.mathworks.com/matlabcentral/fileexchange/25977">mtimesx</a> rely on multithreading <b>inside the threads</b> using multithreaded BLAS libraries. It turns out that if you want to operate on many small matrices, it makes more sense to let each thread operate on a matrix independently. Actually it's possible <a href="http://www.mathworks.com/matlabcentral/fileexchange/25977">mtimesx</a> tries to do this using OMP but it doesn't seem to work that well.</p><pre class="codeinput">tic; +mtimesx(A, B, <span class="string">'speedomp'</span>); +toc +</pre><pre class="codeoutput">Elapsed time is 0.842090 seconds. +</pre><h2>Full performance comparison<a name="5"></a></h2><pre class="codeinput">compare_mult_flops; +</pre><pre class="codeoutput">multiplying 60*1250000 matrix pairs of dimension [1x1] +multiplying 60*312500 matrix pairs of dimension [2x2] +multiplying 60*138889 matrix pairs of dimension [3x3] +multiplying 60*78125 matrix pairs of dimension [4x4] +multiplying 60*50000 matrix pairs of dimension [5x5] +multiplying 60*34722 matrix pairs of dimension [6x6] +multiplying 60*25510 matrix pairs of dimension [7x7] +multiplying 60*19531 matrix pairs of dimension [8x8] +multiplying 60*15432 matrix pairs of dimension [9x9] +multiplying 60*12500 matrix pairs of dimension [10x10] +multiplying 60*10331 matrix pairs of dimension [11x11] +multiplying 60*8681 matrix pairs of dimension [12x12] +multiplying 60*7396 matrix pairs of dimension [13x13] +multiplying 60*6378 matrix pairs of dimension [14x14] +multiplying 60*5556 matrix pairs of dimension [15x15] +multiplying 60*4883 matrix pairs of dimension [16x16] +multiplying 60*4325 matrix pairs of dimension [17x17] +multiplying 60*3858 matrix pairs of dimension [18x18] +multiplying 60*3463 matrix pairs of dimension [19x19] +multiplying 60*3125 matrix pairs of dimension [20x20] +multiplying 60*2834 matrix pairs of dimension [21x21] +multiplying 60*2583 matrix pairs of dimension [22x22] +multiplying 60*2363 matrix pairs of dimension [23x23] +multiplying 60*2170 matrix pairs of dimension [24x24] +multiplying 60*1849 matrix pairs of dimension [26x26] +multiplying 60*1715 matrix pairs of dimension [27x27] +multiplying 60*1594 matrix pairs of dimension [28x28] +multiplying 60*1389 matrix pairs of dimension [30x30] +multiplying 60*1301 matrix pairs of dimension [31x31] +multiplying 60*1148 matrix pairs of dimension [33x33] +multiplying 60*1081 matrix pairs of dimension [34x34] +multiplying 60*965 matrix pairs of dimension [36x36] +multiplying 60*866 matrix pairs of dimension [38x38] +multiplying 60*822 matrix pairs of dimension [39x39] +multiplying 60*744 matrix pairs of dimension [41x41] +multiplying 60*676 matrix pairs of dimension [43x43] +multiplying 60*591 matrix pairs of dimension [46x46] +multiplying 60*543 matrix pairs of dimension [48x48] +multiplying 60*500 matrix pairs of dimension [50x50] +multiplying 60*445 matrix pairs of dimension [53x53] +multiplying 60*413 matrix pairs of dimension [55x55] +multiplying 60*372 matrix pairs of dimension [58x58] +multiplying 60*336 matrix pairs of dimension [61x61] +multiplying 60*305 matrix pairs of dimension [64x64] +multiplying 60*278 matrix pairs of dimension [67x67] +multiplying 60*255 matrix pairs of dimension [70x70] +multiplying 60*228 matrix pairs of dimension [74x74] +multiplying 60*205 matrix pairs of dimension [78x78] +multiplying 60*186 matrix pairs of dimension [82x82] +multiplying 60*169 matrix pairs of dimension [86x86] +multiplying 60*154 matrix pairs of dimension [90x90] +multiplying 60*141 matrix pairs of dimension [94x94] +multiplying 60*128 matrix pairs of dimension [99x99] +multiplying 60*116 matrix pairs of dimension [104x104] +multiplying 60*105 matrix pairs of dimension [109x109] +multiplying 60*96 matrix pairs of dimension [114x114] +multiplying 60*87 matrix pairs of dimension [120x120] +</pre><img vspace="5" hspace="5" src="mmx_web_01.png" alt=""> <p>You can see how around dimension 35, when the low-level multi-threading kicks in, the CPU get flooded with threads and efficiency drops.</p><h2>Singleton Expansion<a name="7"></a></h2><p>Singleton expansion is supported for <tt>dimensions > 2</tt></p><pre class="codeinput">A = randn(5,4,3,10,1); +B = randn(4,6,1,1 ,6); +C = zeros(5,6,3,10,6); + +<span class="keyword">for</span> i = 1:3 + <span class="keyword">for</span> j = 1:10 + <span class="keyword">for</span> k = 1:6 + C(:,:,i,j,k) = A(:,:,i,j,1) * B(:,:,1,1,k); + <span class="keyword">end</span> + <span class="keyword">end</span> +<span class="keyword">end</span> + +diff = C - mmx(<span class="string">'mult'</span>,A,B); + +dispx(norm(diff(:))) +</pre><pre class="codeoutput">difference = 0 +</pre><h2>Transpose Flags<a name="8"></a></h2><p><tt>C = MMX('mult', A, B, mod)</tt> where mod is a modifier string, will transpose one or both of A and B. Possible values for mod are 'tn', 'nt' and 'tt' where 't' stands for <b>transposed</b> and 'n' for <b>not-transposed</b> . For example</p><pre class="codeinput">A = randn(n,n); +B = randn(n,n); +dispx(norm(mmx(<span class="string">'mult'</span>,A,B) - A *B)); +dispx(norm(mmx(<span class="string">'mult'</span>,A,B,<span class="string">'tn'</span>) - A'*B)); +dispx(norm(mmx(<span class="string">'mult'</span>,A,B,<span class="string">'tt'</span>) - A'*B')); +dispx(norm(mmx(<span class="string">'mult'</span>,A,B,<span class="string">'nt'</span>) - A *B')); +</pre><pre class="codeoutput">difference = 0 +difference = 0 +difference = 0 +difference = 0 +</pre><h2>Matrix Squaring<a name="9"></a></h2><pre class="codeinput">A = randn(n,m); +B = randn(n,m); +dispx(norm(mmx(<span class="string">'square'</span>,A,[]) - A*A' )); +dispx(norm(mmx(<span class="string">'square'</span>,A, B) - 0.5*(A*B'+B*A') )); +dispx(norm(mmx(<span class="string">'square'</span>,A,[],<span class="string">'t'</span>) - A'*A )); +dispx(norm(mmx(<span class="string">'square'</span>,A, B,<span class="string">'t'</span>) - 0.5*(A'*B+B'*A) )); +</pre><pre class="codeoutput">difference = 2.25283e-14 +difference = 0 +difference = 5.22422e-14 +difference = 0 +</pre><p>Results do not always equal Matlab's results, but are within machine precision thereof.</p><h2>Cholesky factorization<a name="11"></a></h2><pre class="codeinput">A = randn(n,n); +A = A*A'; +dispx(norm(mmx(<span class="string">'chol'</span>,A,[]) - chol(A))); +</pre><pre class="codeoutput">difference = 0 +</pre><p>Timing comparison:</p><pre class="codeinput">A = randn(n,n,N); +A = mmx(<span class="string">'square'</span>,A,[]); +tic; +C = mmx(<span class="string">'chol'</span>,A,[]); +toc +C2 = zeros(n,n,N); +tic; +<span class="keyword">for</span> i=1:N + C2(:,:,i) = chol(A(:,:,i)); +<span class="keyword">end</span> +toc +</pre><pre class="codeoutput">Elapsed time is 0.002502 seconds. +Elapsed time is 0.012015 seconds. +</pre><h2>Backslash<a name="13"></a></h2><p>Unlike other commands, 'backslash' does not support singleton expansion. If A is square, mmx will use LU factorization, otherwise it will use QR factorization.</p><pre class="codeinput">B = randn(n,m); +A = randn(n,n); +</pre><p>General:</p><pre class="codeinput">dispx(norm(mmx(<span class="string">'backslash'</span>,A,B) - A\B)); +</pre><pre class="codeoutput">difference = 1.06155e-09 +</pre><p>Triangular:</p><pre class="codeinput"><span class="comment">% upper:</span> +Au = triu(A) + abs(diag(diag(A))) + eye(n); <span class="comment">%no small values on the diagonal</span> +dispx(norm(mmx(<span class="string">'backslash'</span>,Au,B,<span class="string">'u'</span>) - Au\B)); +<span class="comment">% lower:</span> +Al = tril(A) + abs(diag(diag(A))) + eye(n); <span class="comment">%no small values on the diagonal</span> +dispx(norm(mmx(<span class="string">'backslash'</span>,Al,B,<span class="string">'l'</span>) - Al\B)); +</pre><pre class="codeoutput">difference = 0.00065334 +difference = 7.69608e-06 +</pre><p>Symmetric Positive Definite:</p><pre class="codeinput">AA = A*A'; +dispx(norm(mmx(<span class="string">'backslash'</span>,AA,B,<span class="string">'p'</span>) - AA\B)); +</pre><pre class="codeoutput">difference = 0.000211305 +</pre><p>Cholesky/LU timing comparison:</p><pre class="codeinput">A = randn(n,n,N); +A = mmx(<span class="string">'square'</span>,A,[]); +B = randn(n,1,N); +tic; +mmx(<span class="string">'backslash'</span>,A,B); <span class="comment">% uses LU</span> +toc +tic; +mmx(<span class="string">'backslash'</span>,A,B,<span class="string">'p'</span>); <span class="comment">% uses Cholesky</span> +toc +</pre><pre class="codeoutput">Elapsed time is 0.040181 seconds. +Elapsed time is 0.005356 seconds. +</pre><p>Overdetermined:</p><pre class="codeinput">A = randn(n,m); +B = randn(n,m); + +dispx(norm(mmx(<span class="string">'backslash'</span>,A,B) - A\B)); +</pre><pre class="codeoutput">difference = 1.8724e-15 +</pre><p>Underdetermined:</p><pre class="codeinput">A = randn(m,n); +B = randn(m,n); + +dispx(norm(mmx(<span class="string">'backslash'</span>,A,B) - pinv(A)*B)); +</pre><pre class="codeoutput">difference = 7.84436e-15 +</pre><p>In the underdetermined case, (i.e. when <tt>size(A,1) < size(A,2))</tt>, mmx will give the least-norm solution which is equivalent to <tt>C = pinv(A)*B</tt>, unlike matlab's mldivide.</p><h2>Thread control<a name="21"></a></h2><p>mmx will automatically start a number of threads equal to the number of available processors, however the number can be set manually to n using the command <tt>mmx(n)</tt>. The command <tt>mmx(0)</tt> clears the threads from memory. Changing the threadcount quickly without computing anything, as in</p><pre>for i=1:5 + mmx(i); +end</pre><p>can cause problems. Don't do it.</p><h2>Checking of special properties<a name="24"></a></h2><p>The functions which assume special types of square matrices as input ('chol' and 'backslash' for 'U','L' or 'P' modifiers) do not check that the inputs are indeed what you say they are, and produce no error if they are not. Caveat computator.</p><h2>Compilation<a name="25"></a></h2><p>To compile run 'build_mmx'. Type 'help build_mmx' to read about compilation issues and options</p><h2>Rant<a name="26"></a></h2><p>Clearly there should be someone at Mathworks whose job it is to do this stuff. As someone who loves Matlab deeply, I hate to see its foundations left to rot. Please guys, allocate engineer-hours to the Matlab core, rather than the toolbox fiefdoms. We need full singleton expansion everywhere. Why isn't it the case that</p><pre>[1 2] + [0 1]' == [1 2;2 3] ?</pre><p>bsxfun() is a total hack, and polluting everybody's code. We need expansion on the pages like mmx(), but with transparent and smart use of <b>both</b> CPU and GPU. GPUArray? Are you kidding me? I shouldn't have to mess with that. Why is it that (for years now), the fastest implementation of repmat(), has been Minka's <a href="http://research.microsoft.com/en-us/um/people/minka/software/lightspeed/">Lightspeed toolbox</a>? Get your act together soon guys, or face obsolescence.</p><p class="footer"><br> + Published with MATLAB® 7.14<br></p></div><!-- +##### SOURCE BEGIN ##### +%% MMX - Multithreaded matrix operations on N-D matrices +% mmx treats an N-D matrix of double precision values as a set of pages +% of 2D matrices, and performs various matrix operations on those pages. +% mmx uses multithreading over the higher dimensions to achieve good +% performance. Full singleton expansion is available for most operations. + +%% Fast N-D Multiplication +n = 80; % rows +m = 40; % columns +N = 10000; % pages +A = randn(n,m,N); +B = randn(m,n,N); +tic; +C = mmx('mult', A, B); +toc +%% +C2 = zeros(n,n,N); +tic; +for i=1:N + C2(:,:,i) = A(:,:,i)*B(:,:,i); +end +toc +%% +dispx = @(x) fprintf('difference = %g\n',x); +dispx(max(abs(C(:)-C2(:)))) + +%% Multi-threading along the pages +% Other packages like Peter Boettcher's venerable <http://www.mit.edu/~pwb/matlab/ ndfun> +% Or James Tursa's +% <http://www.mathworks.com/matlabcentral/fileexchange/25977 mtimesx> rely +% on multithreading *inside the threads* using multithreaded BLAS +% libraries. It turns out that if you want to operate on many small +% matrices, it makes more sense to let each thread operate on a matrix +% independently. Actually it's possible +% <http://www.mathworks.com/matlabcentral/fileexchange/25977 mtimesx> tries +% to do this using OMP but it doesn't seem to work that well. +tic; +mtimesx(A, B, 'speedomp'); +toc + +%% Full performance comparison +compare_mult_flops; + +%% +% You can see how around dimension 35, when the low-level multi-threading +% kicks in, the CPU get flooded with threads and efficiency drops. + +%% Singleton Expansion +% Singleton expansion is supported for |dimensions > 2| + +A = randn(5,4,3,10,1); +B = randn(4,6,1,1 ,6); +C = zeros(5,6,3,10,6); + +for i = 1:3 + for j = 1:10 + for k = 1:6 + C(:,:,i,j,k) = A(:,:,i,j,1) * B(:,:,1,1,k); + end + end +end + +diff = C - mmx('mult',A,B); + +dispx(norm(diff(:))) + + +%% Transpose Flags +% |C = MMX('mult', A, B, mod)| where mod is a modifier string, will +% transpose one or both of A and B. Possible values for mod are +% 'tn', 'nt' and 'tt' where 't' stands for *transposed* and 'n' for +% *not-transposed* . For example +A = randn(n,n); +B = randn(n,n); +dispx(norm(mmx('mult',A,B) - A *B)); +dispx(norm(mmx('mult',A,B,'tn') - A'*B)); +dispx(norm(mmx('mult',A,B,'tt') - A'*B')); +dispx(norm(mmx('mult',A,B,'nt') - A *B')); + + +%% Matrix Squaring +A = randn(n,m); +B = randn(n,m); +dispx(norm(mmx('square',A,[]) - A*A' )); +dispx(norm(mmx('square',A, B) - 0.5*(A*B'+B*A') )); +dispx(norm(mmx('square',A,[],'t') - A'*A )); +dispx(norm(mmx('square',A, B,'t') - 0.5*(A'*B+B'*A) )); +%% +% Results do not always equal Matlab's results, but are within machine +% precision thereof. + + +%% Cholesky factorization +A = randn(n,n); +A = A*A'; +dispx(norm(mmx('chol',A,[]) - chol(A))); + +%% +% Timing comparison: +A = randn(n,n,N); +A = mmx('square',A,[]); +tic; +C = mmx('chol',A,[]); +toc +C2 = zeros(n,n,N); +tic; +for i=1:N + C2(:,:,i) = chol(A(:,:,i)); +end +toc + +%% Backslash +% Unlike other commands, 'backslash' does not support singleton +% expansion. If A is square, mmx will use LU factorization, otherwise it +% will use QR factorization. +B = randn(n,m); +A = randn(n,n); +%% +% General: +dispx(norm(mmx('backslash',A,B) - A\B)); +%% +% Triangular: + +% upper: +Au = triu(A) + abs(diag(diag(A))) + eye(n); %no small values on the diagonal +dispx(norm(mmx('backslash',Au,B,'u') - Au\B)); +% lower: +Al = tril(A) + abs(diag(diag(A))) + eye(n); %no small values on the diagonal +dispx(norm(mmx('backslash',Al,B,'l') - Al\B)); +%% +% Symmetric Positive Definite: +AA = A*A'; +dispx(norm(mmx('backslash',AA,B,'p') - AA\B)); +%% +% Cholesky/LU timing comparison: +A = randn(n,n,N); +A = mmx('square',A,[]); +B = randn(n,1,N); +tic; +mmx('backslash',A,B); % uses LU +toc +tic; +mmx('backslash',A,B,'p'); % uses Cholesky +toc + +%% +% Overdetermined: +A = randn(n,m); +B = randn(n,m); + +dispx(norm(mmx('backslash',A,B) - A\B)); + +%% +% Underdetermined: +A = randn(m,n); +B = randn(m,n); + +dispx(norm(mmx('backslash',A,B) - pinv(A)*B)); +%% +% In the underdetermined case, (i.e. when +% |size(A,1) < size(A,2))|, mmx will give the least-norm solution which +% is equivalent to |C = pinv(A)*B|, unlike matlab's mldivide. + +%%% Thread control +% mmx will automatically start a number of +% threads equal to the number of available processors, however the +% number can be set manually to n using the command |mmx(n)|. +% The command |mmx(0)| clears the threads from memory. Changing the +% threadcount quickly without computing anything, as in +%% +% +% for i=1:5 +% mmx(i); +% end +%% +% can cause problems. Don't do it. + +%% Checking of special properties +% The functions which assume special types of square +% matrices as input ('chol' and 'backslash' for 'U','L' or 'P' +% modifiers) do not check that the inputs are indeed what you say they +% are, and produce no error if they are not. Caveat computator. + +%% Compilation +% To compile run 'build_mmx'. Type 'help build_mmx' to read +% about compilation issues and options + +%% Rant +% Clearly there should be someone at Mathworks whose job it is to do this +% stuff. As someone who loves Matlab deeply, I hate to see its foundations +% left to rot. Please guys, allocate engineer-hours to the Matlab core, rather than the +% toolbox fiefdoms. We need full singleton expansion everywhere. Why isn't +% it the case that +%% +% +% [1 2] + [0 1]' == [1 2;2 3] ? +% +% bsxfun() is a total hack, and polluting +% everybody's code. We need expansion on the pages like mmx(), but +% with transparent and smart use of *both* CPU and GPU. GPUArray? Are you +% kidding me? I shouldn't have to mess with that. Why is it that (for years +% now), the fastest implementation of repmat(), has been Minka's +% <http://research.microsoft.com/en-us/um/people/minka/software/lightspeed/ +% Lightspeed toolbox>? Get your act together soon guys, or face +% obsolescence. +##### SOURCE END ##### +--></body></html> \ No newline at end of file diff --git a/ext/mmx/html/mmx_web.png b/ext/mmx/html/mmx_web.png new file mode 100644 index 0000000000000000000000000000000000000000..5f4585636d2496665b5756ab36e5d8ccaf61b728 Binary files /dev/null and b/ext/mmx/html/mmx_web.png differ diff --git a/ext/mmx/html/mmx_web_01.png b/ext/mmx/html/mmx_web_01.png new file mode 100644 index 0000000000000000000000000000000000000000..faed4fd802d83c62a78b04f63c3bc2098fc8db72 Binary files /dev/null and b/ext/mmx/html/mmx_web_01.png differ diff --git a/ext/mmx/license.txt b/ext/mmx/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..fbb33b1af98e3a2de737c8dccb4703f4f3d53d6a --- /dev/null +++ b/ext/mmx/license.txt @@ -0,0 +1,25 @@ +Copyright (c) 2012, Yuval +Copyright (c) 2011, James Tursa +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/ext/mmx/matlab_mprod.m b/ext/mmx/matlab_mprod.m new file mode 100644 index 0000000000000000000000000000000000000000..fd1fb5e1a55029125e7064ee2382f6c88c8b43bd --- /dev/null +++ b/ext/mmx/matlab_mprod.m @@ -0,0 +1,5 @@ +function c = matlab_mprod(a,b) +c = zeros(size(a,1),size(b,2),size(a,3)); +for i = 1:size(a,3) + c(:,:,i) = a(:,:,i)*b(:,:,i); +end \ No newline at end of file diff --git a/ext/mmx/matrix_fun.c b/ext/mmx/matrix_fun.c new file mode 100644 index 0000000000000000000000000000000000000000..9977a73c1258989a03db19666342f724e8dc2c84 --- /dev/null +++ b/ext/mmx/matrix_fun.c @@ -0,0 +1,293 @@ +// ================================================== +// straightforward implementations of matrix multiply +// ================================================== +void multAB(double* C, double* A, double* B, const int rA, const int cA, const int cB) { + int i, j, k; + double *a, *c, tmp; + for( i=0; i<cB; i++ ){ + for( k=0; k<cA; k++ ){ + tmp = B[i*cA+k]; + a = A + k*rA; + c = C + i*rA; + for( j=0; j<rA; j++ ){ + c[j] += tmp * a[j]; + } + } + } +} +void multAtB(double* C, double* A, double* B, const int rA, const int cA, const int cB) { + int i, j, k; + double *a, *b, *c; + for( i=0; i<cB; i++ ){ + for( k=0; k<cA; k++ ){ + a = A + k*rA; + b = B + i*rA; + c = C + i*cA + k; + for( j=0; j<rA; j++ ){ + (*c) += a[j]*b[j]; + } + } + } +} +void multABt(double* C, double* A, double* B, const int rA, const int cA, const int rB) { + int i, j, k; + double *a, *b; + for( j=0; j<cA; j++ ){ + a = A + j*rA; + b = B + j*rB; + for( i=0; i<rB; i++ ){ + for( k=0; k<rA; k++ ){ + C[i*rA + k] += a[k]*b[i]; + } + } + } +} +void multAtBt(double* C, double* A, double* B, const int rA, const int cA, const int rB) { + int i, j, k; + double *b, *c, tmp; + for( i=0; i<cA; i++ ){ + for( k=0; k<rA; k++ ){ + tmp = A[i*rA+k]; + b = B + k*rB; + c = C + i; + for( j=0; j<rB; j++ ){ + c[j*cA] += tmp * b[j]; + } + } + } +} + +// ============================= +// multiply: C = op(A) * op(B) +// ============================= +void mulMatMat(double* C, double* A, double* B, + const int rA, const int cA, const int rB, const int cB, const char *mod) { +#ifndef USE_BLAS // naive C implementations + + if ( (mod[0] == 'N') && (mod[1] == 'N') ) + multAB(C, A, B,rA, cA, cB); + else if ( (mod[0] == 'T') && (mod[1] == 'N') ) + multAtB(C, A, B, rA, cA, cB); + else if ( (mod[0] == 'N') && (mod[1] == 'T') ) + multABt(C, A, B, rA, cA, rB); + else if ( (mod[0] == 'T') && (mod[1] == 'T') ) + multAtBt(C, A, B, rA, cA, rB); + +#else + + // rows(Op(A)), columns(Op(A)), columns(Op(B)), rows(C) + ptrdiff_t ropA, copA, copB, rC; + // can't pass consts to fortran + ptrdiff_t rA0 = rA, rB0 = rB; + + char modA = mod[0], modB = mod[1]; + double one = 1.0, zero = 0.0; + + if (mod[0] != 'S'){ + if ( (mod[0] == 'N') && (mod[1] == 'N') ){ + ropA = rA; + copA = cA; + copB = cB; + rC = rA; + } else if ( (mod[0] == 'T') && (mod[1] == 'N') ){ + ropA = cA; + copA = rA; + copB = cB; + rC = cA; + } else if ( (mod[0] == 'N') && (mod[1] == 'T') ){ + ropA = rA; + copA = cA; + copB = rB; + rC = rA; + } else if ( (mod[0] == 'T') && (mod[1] == 'T') ){ + ropA = cA; + copA = rA; + copB = rB; + rC = cA; + } + dgemm(&modA, &modB, &ropA, &copB, &copA, &one, A, &rA0, B, &rB0, &zero, C, &rC); + } else { + char side='L', uplo = 'U'; + ropA = rA; + copB = cB; + dsymm(&side, &uplo, &ropA, &copB, &one, A, &rA0, B, &rB0, &zero, C, &rC); + // why the fuck does this not work ??? + } +#endif +} + +// ================================================ +// square: C = A * op(A) or C = 0.5*(A*B'+B*A') +// ================================================ +void squareMatMat(double* C, double* A, double* B, + const int rA, const int cA, const int rB, const int cB, const char *mod) { + // can't pass consts to BLAS + ptrdiff_t rA0 = rA, cA0 = cA, rB0 = rB; + // rows(Op(A)), columns(Op(A)), columns(Op(B)), rows(C) + ptrdiff_t copA, rC; + int i,j; + double temp; + + if ( (mod[0] == 'N') ){ + copA = cA; + rC = rA; + } else { + copA = rA; + rC = cA; + } + +#ifndef USE_BLAS // naive C implementations + + if ((rB == 0) || (cB == 0)){ // one input C = A*A' + if ( (mod[0] == 'N') ) + multABt(C, A, A, rA, cA, rA); + else + multAtB(C, A, A, rA, cA, cA); + }else{ + if ( (mod[0] == 'N') ) + multABt(C, A, B, rA, cA, rB); + else + multAtB(C, A, B, rA, cA, cB); + + // symmetrize + for( i=0; i<rC; i++ ) + for( j=i; j<rC; j++ ){ + temp = C[i*rC+j] + C[j*rC+i]; + C[i*rC+j] = C[j*rC+i] = 0.5*temp; + } + } + +#else + char modA = mod[0], modB = mod[1], uplo = 'U'; + double one = 1.0, zero = 0.0, half = 0.5; + + if ((!rB) && (!cB)) // one input C = A*A' + dsyrk(&uplo, &modA, &rC, &copA, &one, A, &rA0, &zero, C, &rC); + else // two inputs C = 0.5*(A*B'+B*A') + dsyr2k(&uplo, &modA, &rC, &copA, &half, A, &rA0, B, &rB0, &zero, C, &rC); + + // symmetrize + for( i=0; i<rC; i++ ) + for( j=i+1; j<rC; j++ ) + C[i*rC+j] = C[j*rC+i]; + +#endif +} + +// ===================================== +// cholesky decomposition: C = chol(A) +// ===================================== +double dot(const double* vec1, const double* vec2, const int n) +{ + int i; + double res = 0; + + for( i=0; i<n; i++ ) + res += vec1[i] * vec2[i]; + + return res; +} + + +int cholA(double* A, double* scratch, const int n) +{ + int i, j, rank=0; + double tmp; + + // in-place Cholesky factorization, store 1/L(j,j) in scratch + for( j=0; j<n; j++ ) + { + tmp = A[j*n+j]; + if( j ) + tmp -= dot(A+j*n, A+j*n, j); + + if( tmp < 0.000000001 ) + return rank; + else + { + scratch[j] = (double)(1.0/sqrt(tmp)); + rank++; + } + + // process off-diagonal entries, modify 'A' + for( i=j+1; i<n; i++ ) + { + A[i*n+j] -= dot(A+i*n, A+j*n, j); + A[i*n+j] *= scratch[j]; + } + } + + // copy 'scratch' to diagonal of A + for( j=0; j<n; j++ ) + A[j*n+j] = 1./scratch[j]; + + return rank; +} + + + +void chol(double* C, double* A, const int rA) { + int i,j, rank; + double temp; + + // copy upper triangle into C + for( i=0; i<rA; i++ ) + for( j=0; j<=i; j++ ) + C[i*rA+j] = A[i*rA+j]; + +#ifndef USE_BLAS // naive C implementations + temp = A[0]; + rank = cholA(C, A, rA); + // chol used A as scratch, now fix it + if (rank) A[0] = temp; + for( i=1; i<rank; i++ ) + A[i] = A[i*rA]; + //if decomposition failed put -1 in C + if (rank < rA) C[0] = -1; +#else + ptrdiff_t rA0 = rA; + ptrdiff_t info; + dpotrf("U", &rA0, C, &rA0, &info ); +#endif +} + + +// ================================ +// solve linear equations C = A\B +// ================================ +void solve(double* C, double* A, double* B, + const int rA, const int cA, const int rB, const int cB, + const char *mod, double *W, const int LW, ptrdiff_t *S) { +#ifdef USE_BLAS + int i, j, rank; + char uplo = 'U', side = 'L', trans = 'N', unit = 'N'; + double one = 1.0, rcond = 0.000000001; + ptrdiff_t rA0 = rA, cA0 = cA, cB0 = cB, Lwork=LW, info; + ptrdiff_t rC0 = (rA>cA) ? rA : cA; + //ptrdiff_t ptr_S = S; + + switch (mod[0]){ + case 'L': + case 'U': + uplo = mod[0]; + dtrsm(&side, &uplo, &trans, &unit, &rC0, &cB0, &one, A, &rA0, C, &rC0); + break; + case 'P': + dposv(&uplo, &rA0, &cB0, W, &rA0, C, &rA0, &info);// A has already been copied into W + break; + default: + if (rA == cA) { + //dgesv(&rA0, &cB0, W, &rA0, S, C, &rA0, &info);// A has already been copied into W + dgesv(&rA0, &cB0, W, &rA0, (ptrdiff_t*)S, C, &rA0, &info);// A has already been copied into W + } + else{ + for( i=0; i<cB; i++ ) + for( j=0; j<rB; j++ ) + C[i*rC0+j] = B[i*rB+j]; + //dgelsy(&rA0, &cA0, &cB0, A, &rA0, C, &rC0, S, &rcond, &rank, W, &Lwork, &info); + dgelsy(&rA0, &cA0, &cB0, A, &rA0, C, &rC0, + (ptrdiff_t*)S, &rcond, (ptrdiff_t*)&rank, W, &Lwork, &info); + } + } +#endif +} diff --git a/ext/mmx/mmx.cpp b/ext/mmx/mmx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4c698dd38270accfe8b72f9a312fa155da6abcc2 --- /dev/null +++ b/ext/mmx/mmx.cpp @@ -0,0 +1,589 @@ +// ======================= +// preprocessor directives +// ======================= +#include "mex.h" +#include "string.h" +#include <ctype.h> + +#ifdef UNIX_SYSTEM + #include <unistd.h> + #include <pthread.h> +#endif + +#ifdef WIN_SYSTEM + #include "windows.h" +#endif + +#include <math.h> + +#if defined(USE_BLAS) + #if defined(MKL_ILP64) or defined(MKL_32) + #include "mkl_blas.h" + #include "mkl_lapack.h" + #define ptrdiff_t MKL_INT + #else + #ifdef UNIX_SYSTEM + #include "blas.h" + #include "lapack.h" + #else + #include "my_blas.h" + #endif + #endif +#endif + +#define MAX_THREAD 64 + +// list of possible values for PARTASK +// positive values are matrix oprations +#define MATMUL 1 +#define SQUARE 2 +#define CHOL 3 +#define BSLASH 4 +// negative values are binary-elementwise functions (like bsxfun) + +// function declarations +#include "matrix_fun.c" + +//#define DEBUG + +// ================ +// global variables +// ================ + +// thread related +static bool INITIALIZED = false; +static int SCHEDULE[MAX_THREAD][2]; //start and stop index for each thread +static int NTHREAD = 0; + +#ifdef WIN_SYSTEM +static HANDLE THREAD[MAX_THREAD]; +static HANDLE TSTART[MAX_THREAD]; +static HANDLE TDONE[MAX_THREAD]; +#endif + + +// computation related +int PARTASK; +double *A, *B, *C, *WORK, *C2; +int rA, cA, rB ,cB, rC, cC, strideA, strideB, strideC, strideW, strideC2; +int *PAIRS = NULL; +ptrdiff_t *iScratch = NULL; +bool BSX; +//bool USED_DGELSY = false; +char MODIFY[2]; + +// ================================ +// teval() is called by each thread +// ================================ +#ifdef WIN_SYSTEM +DWORD _stdcall teval(void* pn) +#else +void* teval(void* pn) +#endif +{ + // get thread number + int i, n = *(int*)pn; + ptrdiff_t *Si; + double *Ai, *Bi, *Wi; + +#ifdef WIN_SYSTEM + while(1){ // thread will be terminated externally + WaitForSingleObject(TSTART[n], INFINITE); // wait for start signal +#endif + // loop over data + for( i=SCHEDULE[n][0]; i<SCHEDULE[n][1]; i++ ){ + // pointers to scheduled data + if (BSX){ //singleton expansion + Ai = A + strideA*PAIRS[2*i]; + Bi = B + strideB*PAIRS[2*i+1]; + } else { + Ai = A + strideA*i; + Bi = B + strideB*i; + } + // excecute the task + switch ( PARTASK ) { + case MATMUL: + mulMatMat(C + strideC*i, Ai, Bi , rA, cA, rB, cB, MODIFY); + //mexPrintf("%d strideC: %d A %f, B %f, C %f\n", i, strideC, Ai[0], Bi[0], *(C+strideC*i)); + break; + case SQUARE: + squareMatMat(C + strideC*i, Ai, Bi , rA, cA, rB, cB, MODIFY); + break; + case CHOL: + chol(C + strideC*i, Ai, rA); + break; + case BSLASH: + if (iScratch != NULL && WORK != NULL) { + Wi = WORK + strideW*i; + Si = iScratch + cA*i; + solve(C + strideC*i, Ai, Bi , rA, cA, rB, cB, MODIFY, Wi, strideW, Si); + } + break; + } + } +#ifdef WIN_SYSTEM + //signal that thread is finished + SetEvent(TDONE[n]); + } +#endif + + return 0; +} + + +// ============= +// mexFunction() +// ============= +void mexFunction(int n_out, mxArray *p_out[], int n_in, const mxArray *p_in[]) +{ + mwSize Andim, Bndim, Cndim; + mwSize *Adims, *Bdims, *Adims_full, *Bdims_full, *Cdims, *idx; + mxArray *tArray = NULL; + char chr; + char *commandStr; + int i, j, k, nt, N, iA, iB, iC, iC2, rC2 = 0; + static int tnum[MAX_THREAD]; + + // no input: print documentation + if( n_in==0 ) { + mexPrintf( "=======================================================\n" + "=== mmx(): fast, multithreaded, n-D multiplication ===\n" + "Basic usage:\nThe command C = mmx('mult',A,B);\n" + "is equivalent to the matlab loop\n" + " for i=1:N\n C(:,:,i) = A(:,:,i)*B(:,:,i);\n end\n" + "===== Type 'help mmx' for detailed information. =======\n" + "=======================================================\n"); + } + // =================== + // threading machinery + // =================== + + // single input mmx(nt): set number of threads + if( n_in==1 ){ + if((!mxIsNumeric(p_in[0]))||(mxGetN(p_in[0])!=1)||(mxGetM(p_in[0])!=1)) + mexErrMsgTxt("A single scalar input specifies the desired thread count. Type 'help mmx' for more info."); + nt = (int)mxGetScalar(p_in[0]); + } + else if (n_in==0 || !INITIALIZED) { +#ifdef WIN_SYSTEM + SYSTEM_INFO sysinfo; + GetSystemInfo( &sysinfo ); + nt = sysinfo.dwNumberOfProcessors; +#else + nt = sysconf(_SC_NPROCESSORS_ONLN); +#endif + } + else { + nt = NTHREAD; + } + + // if necessary, clear threads + if ((nt==0) || (INITIALIZED && (nt!=NTHREAD))){ +#ifdef WIN_SYSTEM + mexPrintf("Clearing threads.\n"); + for( i=0; i<NTHREAD; i++ ) { + TerminateThread(THREAD[i], 0); + CloseHandle(THREAD[i]); + CloseHandle(TSTART[i]); + CloseHandle(TDONE[i]); + } +#endif + NTHREAD = 0; + INITIALIZED = false; + } + + // start threads + if( !INITIALIZED && nt ) { + NTHREAD = (MAX_THREAD <= nt) ? MAX_THREAD : nt; // set global NTHREAD + // create events and threads + for( i=0; i<NTHREAD; i++ ) { + tnum[i] = i; // set tnum so CreateThread won't access i + //mexPrintf("tnum[%d]: %d\n", i, tnum[i]); + } +#ifdef WIN_SYSTEM + for( i=0; i<NTHREAD; i++ ) { + TSTART[i] = CreateEvent(0, FALSE, FALSE, 0); + TDONE[i] = CreateEvent(0, TRUE, FALSE, 0); + THREAD[i] = CreateThread(NULL, 0, teval, (void*)(tnum+i), 0, 0); + } +#endif + INITIALIZED = true; + if (n_in == 1) {//print this line only in single-input mode + mexPrintf("%d threads prepared.\n", NTHREAD); + } + } + + // just getting help or setting the thread count, exit now + if( n_in < 2 ) { + return; + } + + // ============== + // process inputs + // ============== + + // not enough inputs + if( n_in == 2 ) { + mexErrMsgTxt("Two is an invalid number of inputs."); + } + + if(mxGetClassID(p_in[0]) != mxCHAR_CLASS) { + mexErrMsgTxt("First argument must be a command. Type mmx() for more help."); + } + commandStr = mxArrayToString(p_in[0]); + + // process commands + PARTASK = 0; + switch (toupper(commandStr[0])){ + case 'M': + PARTASK = MATMUL; + break; + case 'S': + PARTASK = SQUARE; + break; + case 'C': + PARTASK = CHOL; + break; + case 'B': + PARTASK = BSLASH; +#ifndef USE_BLAS + mexErrMsgTxt("Recompile and link to BLAS to enable 'backslash' support"); +#endif + break; + default: + mexErrMsgTxt("Unknown command."); + } + mxFree((void*)commandStr); + + // type check + if ( (!mxIsDouble(p_in[1])) || (!mxIsDouble(p_in[2])) ) { + mexErrMsgTxt("Only inputs of type 'double' are supported."); + } + + // get rA, cA, rB, cB + A = mxGetPr(p_in[1]); + Andim = mxGetNumberOfDimensions(p_in[1]); + Adims = (mwSize *) mxGetDimensions(p_in[1]); + rA = Adims[0]; + cA = Adims[1]; + + B = mxGetPr(p_in[2]); + Bndim = mxGetNumberOfDimensions(p_in[2]); + Bdims = (mwSize *) mxGetDimensions(p_in[2]); + rB = Bdims[0]; + cB = Bdims[1]; + + // modifiers + MODIFY[0] = MODIFY[1] = 'N'; + if( n_in > 3 ){ + if(mxGetClassID(p_in[3]) != mxCHAR_CLASS) + mexErrMsgTxt("Fourth argument is a modifier string. Type 'help mmx'."); + char *modifierStr = mxArrayToString(p_in[3]); + chr = toupper(modifierStr[0]); + switch ( PARTASK ){ + case MATMUL: + case SQUARE: + if ((chr == 'N')||(chr == 'T')||(chr == 'S')) + MODIFY[0] = chr; + else if(chr!='\0') + mexErrMsgTxt("Unknown modifier."); + + chr = toupper(modifierStr[1]); + if ((chr == 'N')||(chr == 'T')) + MODIFY[1] = chr; + else if (chr!='\0') + mexErrMsgTxt("Unknown modifier."); + break; + case BSLASH: + if ((chr == 'L')||(chr == 'U')||(chr == 'P')) + MODIFY[0] = chr; + else if(chr!='\0') + mexErrMsgTxt("Unknown modifier for command BACKSLASH."); + break; + } + mxFree(modifierStr); + } + + // ================ + // dimension checks + // ================ + switch ( PARTASK ) { + case MATMUL: + if ( (MODIFY[0] == 'N') && (MODIFY[1] == 'N') && (cA != rB) ) + mexErrMsgTxt("size(A,2) == size(B,1) should be true."); + if ( (MODIFY[0] == 'T') && (MODIFY[1] == 'N') && (rA != rB) ) + mexErrMsgTxt("size(A,1) == size(B,1) should be true."); + if ( (MODIFY[0] == 'N') && (MODIFY[1] == 'T') && (cA != cB) ) + mexErrMsgTxt("size(A,2) == size(B,2) should be true."); + if ( (MODIFY[0] == 'T') && (MODIFY[1] == 'T') && (rA != cB) ) + mexErrMsgTxt("size(A,1) == size(B,2) should be true."); + break; + case SQUARE: + if ((rB !=0) && (cB != 0)) + if ( (rA != rB) || (cA != cB) ) + mexErrMsgTxt("For SQUARE size(A,1)==size(B,1) and size(A,2)==size(B,2) should be true."); + break; + case CHOL: + if (rA != cA) + mexErrMsgTxt("For CHOL size(A,1) == size(A,2) should be true."); + break; + case BSLASH: + if (rA != rB) + mexErrMsgTxt("For BACKSLASH size(A,1) == size(B,1) should be true."); + if ( ((MODIFY[0] == 'L')||(MODIFY[0] == 'U')||(MODIFY[0] == 'P')) && (rA != cA) ) + mexErrMsgTxt("For BACKSLASH size(A,1) == size(B,1) should be true."); + break; + } + + // =============== + // process outputs + // =============== + + Cndim = (Andim > Bndim) ? Andim : Bndim; + Cndim = (Cndim > 3) ? Cndim : 3; + Cdims = (mwSize *) mxMalloc( Cndim * sizeof(mwSize) ); + idx = (mwSize *) mxMalloc( Cndim * sizeof(mwSize) ); + + // set Cdims[0,1] + switch ( PARTASK ){ + case MATMUL: + rC = (MODIFY[0] == 'N') ? rA : cA; + cC = (MODIFY[1] == 'N') ? cB : rB; + break; + case SQUARE: + cC = rC = (MODIFY[0] == 'N') ? rA : cA; + break; + case CHOL: + cC = rC = rA; + break; + case BSLASH: + rC = (rA>cA) ? rA : cA; // if rA>cA, overallocate rows for dgelsy's in-place shenanigans + rC2 = (rA>cA) ? cA : 0; // rC2 saves the correct row count for C, we'll use it later to truncate + cC = cB; + } + Cdims[0] = rC; + Cdims[1] = cC; + + + // Adims_full and Bdims_full pad Adims and Bdims with 1s, if necessary + Adims_full = (mwSize *) mxMalloc( Cndim * sizeof(mwSize) ); + Bdims_full = (mwSize *) mxMalloc( Cndim * sizeof(mwSize) ); + + // get Cdims and check singleton dimensions + for( i=0; i<Cndim; i++ ) { + Adims_full[i] = (i < Andim) ? Adims[i] : 1; + Bdims_full[i] = (i < Bndim) ? Bdims[i] : 1; + if (i > 1){//check singleton-expanded dimensions + Cdims[i] = (Adims_full[i] > Bdims_full[i]) ? Adims_full[i] : Bdims_full[i]; + if ( ( Adims_full[i]!=1 ) && ( Bdims_full[i]!=1 ) && ( Adims_full[i]!=Bdims_full[i] ) ){ + mexErrMsgTxt("Non-singleton dimensions of the two input arrays must match each other."); + } + } + } + + + // stride sizes + strideA = rA*cA; + strideB = rB*cB; + strideC = rC*cC; + + // N is the total number of matrix operations + N = 1; + for( i=2; i<Cndim; i++ ) { + N *= Cdims[i]; + } + + // if one of the output dimensions is 0 we're done, goodbye + if ( Cdims[0]*Cdims[1]*N == 0 ) { + return; + } + + // ===================================== + // compute pairs for singleton expansion + // ===================================== + + // check if singleton expansion be be avoided + BSX = false; + if ( (rB != 0) && (cB != 0) ) { + for( j=2; j<Cndim; j++ ) { + if (Adims_full[j] != Bdims_full[j]) { + BSX = true; + } + } + } + + if (BSX) { + // initialze idx + for( j=2; j<Cndim; j++ ) { + idx[j] = 0; + } + + // init PAIRS + PAIRS = (int *) mxMalloc( 2 * N * sizeof(int) ); + PAIRS[0] = PAIRS[1] = 0; + + // compute PAIRS + // (is there a fast way to do this inside the threads ???) + for( i=1; i<N; i++ ){ + // idx = ind2sub(size(C), i) in C-style indexing + idx[2]++; + for( j=2; j<Cndim; j++ ) { + if (idx[j] > Cdims[j]-1){ + idx[j] = 0; + idx[j+1]++; + } + } + // {iA,iB} = sub2ind(size({A,B}), idx) while ignoring singletons + iA = iB = 0; + for( j=Cndim-1; j>1; j-- ){ + if (Adims_full[j] > 1) iA = iA*Adims_full[j] + idx[j]; + if (Bdims_full[j] > 1) iB = iB*Bdims_full[j] + idx[j]; + } + PAIRS[2*i] = iA; + PAIRS[2*i+1] = iB; + } +#ifdef DEBUG + for( i=0; i<N; i++ ) { + mexPrintf("%4d %4d %4d\n", i, PAIRS[2*i], PAIRS[2*i+1]); + } +#endif + } + + // ============================================= + // extra memory allocations for LAPACK functions + // ============================================= +#ifdef USE_BLAS + if (PARTASK == BSLASH){ + //USED_DGELSY=false; + if ((MODIFY[0] != 'L') && (MODIFY[0] != 'U') && (BSX)) + mexErrMsgTxt("Singleton expansion is not supported for LAPACK-based BACKSLASH."); + switch (MODIFY[0]) { + case 'P': // positive definite + strideW = strideA; + tArray = mxDuplicateArray(p_in[1]); + WORK = mxGetPr(tArray); + break; + default: // general, use LU (dgesv) or QR (dgelsy) + if (rA == cA) { // A is square + strideW = strideA; + tArray = mxDuplicateArray(p_in[1]); + WORK = mxGetPr(tArray); + iScratch = (ptrdiff_t *) mxMalloc( N * cA * sizeof(ptrdiff_t)); + } else { // A is not square, ask dgelsy how much scratch memory it needs + //USED_DGELSY = true; + double rcond = 0.000000001, worksize[10]; + ptrdiff_t rank; + ptrdiff_t info, m_one=-1; + ptrdiff_t rA0 = rA, cB0 = cB, cA0=cA; + ptrdiff_t rB0= (rA>cA) ? rA : cA; + dgelsy(&rA0, &cA0, &cB0, A, &rA0, B, &rB0, + iScratch, &rcond, &rank, + worksize, &m_one, &info); + + if (info != 0) { + mexPrintf("LAPACK memory allocation query failed.\n"); + } + + iScratch = (ptrdiff_t *) mxMalloc( N * cA * sizeof(ptrdiff_t)); + strideW = (int) worksize[0]; + WORK = (double *) mxMalloc( N * strideW * sizeof(double) ); + +#ifdef DEBUG + mexPrintf("mem required %f, query info = %d\n", WORK[0], info); +#endif + // duplicate A so it doesn't get corrupted + tArray = mxDuplicateArray(p_in[1]); + A = mxGetPr(tArray); + } + } + } +#endif + + + // allocate C + if ((PARTASK == BSLASH) && (rA==rC)) {// initialize C=B for in-place square BACKSLASH + p_out[0] = mxDuplicateArray(p_in[2]); + } + else { + p_out[0] = mxCreateNumericArray(Cndim, Cdims, mxDOUBLE_CLASS, mxREAL); + } + n_out = 1; + C = mxGetPr(p_out[0]); + + // ================================== + // make schedule, run threads, finish + // ================================== + + // set SCHEDULE + int blksz = N/NTHREAD; + int extra = N - blksz*NTHREAD; + //mexPrintf("matrix_ops: %d block: %d extra: %d\n", N, blksz, extra); + for( i=0; i<NTHREAD; i++ ) { + SCHEDULE[i][0] = ((i>0) ? SCHEDULE[i-1][1] : 0); + SCHEDULE[i][1] = SCHEDULE[i][0] + (blksz + (i<extra)); + //mexPrintf("SCHEDULE[%d] %d, %d\n", i, SCHEDULE[i][0], SCHEDULE[i][1]); + } + + // signal threads to start +#ifdef WIN_SYSTEM + for( i=0; i<NTHREAD; i++ ) { + SetEvent(TSTART[i]); + } + + // wait for all threads to finish + WaitForMultipleObjects(NTHREAD, TDONE, TRUE, INFINITE); + + // reset TDONE events + for( i=0; i<NTHREAD; i++ ) { + ResetEvent(TDONE[i]); + } +#else + + pthread_t p_threads[NTHREAD]; + + for( i=0; i<NTHREAD; i++ ) { + if (pthread_create(&p_threads[i], + NULL, teval, (void*)(tnum+i)) != 0) { + mexPrintf("Could not create thread %d\n", i); + } + } + + for( i=0; i<NTHREAD; i++ ) + { + if (pthread_join(p_threads[i], NULL) != 0) { + mexPrintf("Could not join thread %d\n", i); + } + } +#endif + + // if C was over-allocated, chop off the extra rows + if (rC2) { + Cdims[0] = rC2; + //mxDestroyArray(p_out[0]); + p_out[0] = mxCreateNumericArray(Cndim, Cdims, mxDOUBLE_CLASS, mxREAL); + C2 = mxGetPr(p_out[0]); + strideC2 = rC2*cC; + for( i=0; i<N; i++ ) { + for( j=0; j<cC; j++ ){ + iC = i*strideC+j*rC; + iC2 = i*strideC2+j*rC2; + for( k=0; k<rC2; k++ ) { + C2[iC2+k] = C[iC+k]; + } + } + } + } + + mxFree(Adims_full); + mxFree(Bdims_full); + if (BSX) { + mxFree(PAIRS); + } + mxFree(Cdims); + mxFree(idx); + + if (tArray != NULL) { + mxDestroyArray(tArray); + } +} + diff --git a/ext/mmx/mmx.m b/ext/mmx/mmx.m new file mode 100644 index 0000000000000000000000000000000000000000..4e2fabcc7956f757aa528e232e131d5f1b1705f0 --- /dev/null +++ b/ext/mmx/mmx.m @@ -0,0 +1,67 @@ +function fake_output = mmx(varargin) +%MMX - Multithreaded matrix operations on N-D matrices +% MMX treats an N-D matrix of double precision values as a set of pages +% of 2D matrices, and performs various matrix operations on those pages. +% MMX uses multithreading over the higher dimensions to achieve good +% performance. Full singleton expansion is available for most operations. +% +% C = MMX('mult', A, B) is equivalent to the matlab loop +% for i=1:N, +% C(:,:,i) = A(:,:,i) * B(:,:,i); +% end +% Singleton expansion is enabled on all dimensions so for example if +% A = randn(5,4,3,10,1); +% B = randn(4,6,3,1 ,6); +% C = zeros(5,6,3,10,6); +% then C = mmx('mult',A,B) equivalent to +% for i = 1:3 +% for j = 1:10 +% for k = 1:6 +% C(:,:,i,j,k) = A(:,:,i,j,1) * B(:,:,i,1,k); +% end +% end +% end +% +% C = MMX('mult', A, B, mod) and where mod is a modifier string, will +% transpose one or both of A and B. Possible values for mod are +% 'tn', 'nt' and 'tt' where 't' stands for 'transposed' and 'n' for +% 'not-transposed'. For example +% >> size(mmx('mult',randn(4,2),randn(4,2),'tn')) +% ans = 2 2 +% +% C = MMX('square', A, []) will perform C = A*A' +% C = MMX('square', A, [],'t') will perform C = A'*A +% +% C = MMX('square', A, B) will perform C = 0.5*(A*B'+B*A') +% C = MMX('square', A, B, 't') will perform C = 0.5*(A'*B+B'*A) +% +% C = MMX('chol', A, []) will perform C = chol(A) +% +% C = MMX('backslash', A, B) will perform C = A\B +% Unlike other commands, 'backslash' does not support singleton +% expansion. If A is square, mmx will use LU factorization, otherwise it +% will use QR factorization. In the underdetermined case, (i.e. when +% size(A,1) < size(A,2)), mmx will give the least-norm solution which +% is equivalent to C = pinv(A)*B, unlike matlab's mldivide. +% +% C = MMX('backslash', A, B, 'U') or MMX('backslash', A, B, 'L') will +% perform C = A\B assuming that A is upper or lower triangular, +% respectively. +% +% C = MMX('backslash', A, B, 'P') will perform C = A\B assuming that A +% is symmetric-positive-definite. +% +% MMX(n) does thread control: mmx will automatically start a number of +% threads equal to the number of available processors, however the +% number can be set manually to n using the command mmx(n). mmx(0) will +% clear the threads from memory. +% +% IMPORTANT NOTE: The functions which assume special types of square +% matrices as input ('chol' and 'backslash' for 'U','L' or 'P' +% modifiers) do not check that the inputs are indeed what you say they +% are, and produce no error if they are not. Caveat computator. +% +% COMPILATION: To compile run 'build_mmx'. Type 'help build_mmx' to read +% about compilation issues and options + +error(sprintf('MEX file not found.\nTry ''build_mmx''.\nType ''help mmx'' for details.')); \ No newline at end of file diff --git a/ext/mmx/mmx.mexa64 b/ext/mmx/mmx.mexa64 new file mode 100644 index 0000000000000000000000000000000000000000..cbb4830efc9048d393f7ee4167566f0a4e41057c Binary files /dev/null and b/ext/mmx/mmx.mexa64 differ diff --git a/ext/mmx/mmx.mexw64 b/ext/mmx/mmx.mexw64 new file mode 100644 index 0000000000000000000000000000000000000000..5d6ad8f7c7a1fd869ccbac6109b689d97d44c868 Binary files /dev/null and b/ext/mmx/mmx.mexw64 differ diff --git a/ext/mmx/mmx_mkl_multi.mexa64 b/ext/mmx/mmx_mkl_multi.mexa64 new file mode 100644 index 0000000000000000000000000000000000000000..59faec67d3820d1becb525776953b8042f462e90 Binary files /dev/null and b/ext/mmx/mmx_mkl_multi.mexa64 differ diff --git a/ext/mmx/mmx_mkl_multi.mexw64 b/ext/mmx/mmx_mkl_multi.mexw64 new file mode 100644 index 0000000000000000000000000000000000000000..59539d5fbf841d97efc906d09e4dedcd2b57c8af Binary files /dev/null and b/ext/mmx/mmx_mkl_multi.mexw64 differ diff --git a/ext/mmx/mmx_naive.mexa64 b/ext/mmx/mmx_naive.mexa64 new file mode 100644 index 0000000000000000000000000000000000000000..b530559e9c0290c4c130d10cf91446afd6ab5eec Binary files /dev/null and b/ext/mmx/mmx_naive.mexa64 differ diff --git a/ext/mmx/mmx_naive.mexw64 b/ext/mmx/mmx_naive.mexw64 new file mode 100644 index 0000000000000000000000000000000000000000..99cd4a507ea7177b2c1b4dba77931f1461f4da7f Binary files /dev/null and b/ext/mmx/mmx_naive.mexw64 differ diff --git a/ext/mmx/mmx_web.m b/ext/mmx/mmx_web.m new file mode 100644 index 0000000000000000000000000000000000000000..23d58f308582c1c569c3f8bfb17ed21665cc6d01 --- /dev/null +++ b/ext/mmx/mmx_web.m @@ -0,0 +1,205 @@ +%% MMX - Multithreaded matrix operations on N-D matrices +% mmx treats an N-D matrix of double precision values as a set of pages +% of 2D matrices, and performs various matrix operations on those pages. +% mmx uses multithreading over the higher dimensions to achieve good +% performance. Full singleton expansion is available for most operations. + +%% Fast N-D Multiplication +n = 80; % rows +m = 40; % columns +N = 10000; % pages +A = randn(n,m,N); +B = randn(m,n,N); +tic; +C = mmx('mult', A, B); +toc +%% +C2 = zeros(n,n,N); +tic; +for i=1:N + C2(:,:,i) = A(:,:,i)*B(:,:,i); +end +toc +%% +dispx = @(x) fprintf('difference = %g\n',x); +dispx(max(abs(C(:)-C2(:)))) + +%% Multi-threading along the pages +% Other packages like Peter Boettcher's venerable <http://www.mit.edu/~pwb/matlab/ ndfun> +% Or James Tursa's +% <http://www.mathworks.com/matlabcentral/fileexchange/25977 mtimesx> rely +% on multithreading *inside the threads* using multithreaded BLAS +% libraries. It turns out that if you want to operate on many small +% matrices, it makes more sense to let each thread operate on a matrix +% independently. Actually it's possible +% <http://www.mathworks.com/matlabcentral/fileexchange/25977 mtimesx> tries +% to do this using OMP but it doesn't seem to work that well. +tic; +mtimesx(A, B, 'speedomp'); +toc + +%% Full performance comparison +compare_mult_flops; + +%% +% You can see how around dimension 35, when the low-level multi-threading +% kicks in, the CPU get flooded with threads and efficiency drops. + +%% Singleton Expansion +% Singleton expansion is supported for |dimensions > 2| + +A = randn(5,4,3,10,1); +B = randn(4,6,1,1 ,6); +C = zeros(5,6,3,10,6); + +for i = 1:3 + for j = 1:10 + for k = 1:6 + C(:,:,i,j,k) = A(:,:,i,j,1) * B(:,:,1,1,k); + end + end +end + +diff = C - mmx('mult',A,B); + +dispx(norm(diff(:))) + + +%% Transpose Flags +% |C = MMX('mult', A, B, mod)| where mod is a modifier string, will +% transpose one or both of A and B. Possible values for mod are +% 'tn', 'nt' and 'tt' where 't' stands for *transposed* and 'n' for +% *not-transposed* . For example +A = randn(n,n); +B = randn(n,n); +dispx(norm(mmx('mult',A,B) - A *B)); +dispx(norm(mmx('mult',A,B,'tn') - A'*B)); +dispx(norm(mmx('mult',A,B,'tt') - A'*B')); +dispx(norm(mmx('mult',A,B,'nt') - A *B')); + + +%% Matrix Squaring +A = randn(n,m); +B = randn(n,m); +dispx(norm(mmx('square',A,[]) - A*A' )); +dispx(norm(mmx('square',A, B) - 0.5*(A*B'+B*A') )); +dispx(norm(mmx('square',A,[],'t') - A'*A )); +dispx(norm(mmx('square',A, B,'t') - 0.5*(A'*B+B'*A) )); +%% +% Results do not always equal Matlab's results, but are within machine +% precision thereof. + + +%% Cholesky factorization +A = randn(n,n); +A = A*A'; +dispx(norm(mmx('chol',A,[]) - chol(A))); + +%% +% Timing comparison: +A = randn(n,n,N); +A = mmx('square',A,[]); +tic; +C = mmx('chol',A,[]); +toc +C2 = zeros(n,n,N); +tic; +for i=1:N + C2(:,:,i) = chol(A(:,:,i)); +end +toc + +%% Backslash +% Unlike other commands, 'backslash' does not support singleton +% expansion. If A is square, mmx will use LU factorization, otherwise it +% will use QR factorization. +B = randn(n,m); +A = randn(n,n); +%% +% General: +dispx(norm(mmx('backslash',A,B) - A\B)); +%% +% Triangular: + +% upper: +Au = triu(A) + abs(diag(diag(A))) + eye(n); %no small values on the diagonal +dispx(norm(mmx('backslash',Au,B,'u') - Au\B)); +% lower: +Al = tril(A) + abs(diag(diag(A))) + eye(n); %no small values on the diagonal +dispx(norm(mmx('backslash',Al,B,'l') - Al\B)); +%% +% Symmetric Positive Definite: +AA = A*A'; +dispx(norm(mmx('backslash',AA,B,'p') - AA\B)); +%% +% Cholesky/LU timing comparison: +A = randn(n,n,N); +A = mmx('square',A,[]); +B = randn(n,1,N); +tic; +mmx('backslash',A,B); % uses LU +toc +tic; +mmx('backslash',A,B,'p'); % uses Cholesky +toc + +%% +% Overdetermined: +A = randn(n,m); +B = randn(n,m); + +dispx(norm(mmx('backslash',A,B) - A\B)); + +%% +% Underdetermined: +A = randn(m,n); +B = randn(m,n); + +dispx(norm(mmx('backslash',A,B) - pinv(A)*B)); +%% +% In the underdetermined case, (i.e. when +% |size(A,1) < size(A,2))|, mmx will give the least-norm solution which +% is equivalent to |C = pinv(A)*B|, unlike matlab's mldivide. + +%%% Thread control +% mmx will automatically start a number of +% threads equal to the number of available processors, however the +% number can be set manually to n using the command |mmx(n)|. +% The command |mmx(0)| clears the threads from memory. Changing the +% threadcount quickly without computing anything, as in +%% +% +% for i=1:5 +% mmx(i); +% end +%% +% can cause problems. Don't do it. + +%% Checking of special properties +% The functions which assume special types of square +% matrices as input ('chol' and 'backslash' for 'U','L' or 'P' +% modifiers) do not check that the inputs are indeed what you say they +% are, and produce no error if they are not. Caveat computator. + +%% Compilation +% To compile run 'build_mmx'. Type 'help build_mmx' to read +% about compilation issues and options + +%% Rant +% Clearly there should be someone at Mathworks whose job it is to do this +% stuff. As someone who loves Matlab deeply, I hate to see its foundations +% left to rot. Please guys, allocate engineer-hours to the Matlab core, rather than the +% toolbox fiefdoms. We need full singleton expansion everywhere. Why isn't +% it the case that +%% +% +% [1 2] + [0 1]' == [1 2;2 3] ? +% +% bsxfun() is a total hack, and polluting +% everybody's code. We need expansion on the pages like mmx(), but +% with transparent and smart use of *both* CPU and GPU. GPUArray? Are you +% kidding me? I shouldn't have to mess with that. Why is it that (for years +% now), the fastest implementation of repmat(), has been Minka's +% <http://research.microsoft.com/en-us/um/people/minka/software/lightspeed/ +% Lightspeed toolbox>? Get your act together soon guys, or face +% obsolescence. \ No newline at end of file diff --git a/ext/mmx/my_blas.h b/ext/mmx/my_blas.h new file mode 100644 index 0000000000000000000000000000000000000000..d26b9e6d10701ab75169651d3495a9ce9aad0cbb --- /dev/null +++ b/ext/mmx/my_blas.h @@ -0,0 +1,90 @@ +extern "C"{ + +void dpotrf(const char *UPLO, const ptrdiff_t *M, double A[], const ptrdiff_t *LDA, + ptrdiff_t *INFO); + +void dposv(const char *UPLO, const ptrdiff_t *N, const ptrdiff_t *NRHS, double A[], const ptrdiff_t *LDA, + double B[], const ptrdiff_t *LDB, const ptrdiff_t *INFO); + +void dgesv(const ptrdiff_t *N, const ptrdiff_t *NRHS, double A[], const ptrdiff_t *LDA, + const ptrdiff_t *IPIV, double B[], const ptrdiff_t *LDB, const ptrdiff_t *INFO); + +void dgelsy(const ptrdiff_t *M, const ptrdiff_t *N, const ptrdiff_t *NRHS, double A[], const ptrdiff_t *LDA, + double B[], const ptrdiff_t *LDB, const ptrdiff_t *JPVT, const double *rcond, const ptrdiff_t *rank, double work[], + const ptrdiff_t *lwork, const ptrdiff_t *INFO); + +extern void dgemm( + char *transa, + char *transb, + ptrdiff_t *m, + ptrdiff_t *n, + ptrdiff_t *k, + double *alpha, + double *a, + ptrdiff_t *lda, + double *b, + ptrdiff_t *ldb, + double *beta, + double *c, + ptrdiff_t *ldc + ); + +extern void dsymm( + char *side, + char *uplo, + ptrdiff_t *m, + ptrdiff_t *n, + double *alpha, + double *a, + ptrdiff_t *lda, + double *b, + ptrdiff_t *ldb, + double *beta, + double *c, + ptrdiff_t *ldc + ); + +extern void dsyrk( + char *uplo, + char *trans, + ptrdiff_t *n, + ptrdiff_t *k, + double *alpha, + double *a, + ptrdiff_t *lda, + double *beta, + double *c, + ptrdiff_t *ldc + ); + +extern void dsyr2k( + char *uplo, + char *trans, + ptrdiff_t *n, + ptrdiff_t *k, + double *alpha, + double *a, + ptrdiff_t *lda, + double *b, + ptrdiff_t *ldb, + double *beta, + double *c, + ptrdiff_t *ldc + ); + + +extern void dtrsm( + char *side, + char *uplo, + char *transa, + char *diag, + ptrdiff_t *m, + ptrdiff_t *n, + double *alpha, + double *a, + ptrdiff_t *lda, + double *b, + ptrdiff_t *ldb + ); + +} diff --git a/ext/mmx/small_list b/ext/mmx/small_list new file mode 100644 index 0000000000000000000000000000000000000000..bb0e4c8d7b32126b69e36ee5c8ea8bab1c3e7a94 --- /dev/null +++ b/ext/mmx/small_list @@ -0,0 +1,9 @@ +dpotrf_ +dposv_ +dgesv_ +dgelsy_ +dgemm_ +dsymm_ +dsyrk_ +dsyr2k_ +dtrsm_ diff --git a/ext/mtimesx/license.txt b/ext/mtimesx/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..32b41c67084f84168447c4babf15daf87113d4b8 --- /dev/null +++ b/ext/mtimesx/license.txt @@ -0,0 +1,24 @@ +Copyright (c) 2011, James Tursa +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/ext/mtimesx/mtimesx.c b/ext/mtimesx/mtimesx.c new file mode 100644 index 0000000000000000000000000000000000000000..0f9d8f1f88aa3f381866f092c8d9ff9f37faf650 --- /dev/null +++ b/ext/mtimesx/mtimesx.c @@ -0,0 +1,1481 @@ +/************************************************************************************* + * + * MATLAB (R) is a trademark of The Mathworks (R) Corporation + * + * Function: mtimesx + * Filename: mtimesx.c + * Programmer: James Tursa + * Version: 1.40 + * Date: October 4, 2010 + * Copyright: (c) 2009, 2010 by James Tursa, All Rights Reserved + * + * This code uses the BSD License: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Requires: mtimesx_RealTimesReal.c + * + * mtimesx is a multiply function that utilizes BLAS calls and custom code for + * matrix-matrix, matrix-vector, vector-vector, scalar-vector, scalar-matrix, + * and scalar-array calculations. Full support is given for transpose, conjugate + * transpose, and conjugate operations. Operands can be single, double, or + * sparse double. Sparse double matrices have direct support for scalar-matrix + * operations ... all other computations involving sparse matrices are done + * with calls to the MATLAB intrinsic functions. + * + * Building: + * + * mtimesx is typically self building. That is, the first time you call mtimesx, + * the mtimesx.m file recognizes that the mex routine needs to be compiled and + * then the compilation and linkage to the BLAS library will happen automatically. + * If the automatic compilation does not work, then you can do it manually as + * follows: + * - Put all of the files in one directory that is on the MATLAB path (but don't + * put them in a toolbox directory) + * - Make that directory the current directory. + * - Create a string variable with the pathname and filename of the BLAS library + * file to use. e.g. for microsoft it may be something like the following: + * + * - Issue the following command at the MATLAB prompt. + * >> mex('mtimesx.c',lib_blas) + * + * And if you are on a linux machine then you may need to add the string + * '-DEFINEUNIX' to the mex command argument list. + * + * The usage is as follows (arguments in brackets [ ] are optional): + * + * Syntax + * + * M = mtimesx( [mode] ) + * C = mtimesx(A [,transa] ,B [,transb] [,mode]) + * + * Description + * + * mtimesx performs the matrix calculation C = op(A) * op(B), where: + * A = A single or double or sparse scalar, matrix, or array. + * B = A single or double or sparse scalar, matrix, or array. + * transa = A character indicating a pre-operation on A (optional) + * transb = A character indicating a pre-operation on B (optional) + * The pre-operation can be any of: + * 'N' or 'n' = No operation (the default if trans_ is missing) + * 'T' or 't' = Transpose + * 'C' or 'c' = Conjugate Transpose + * 'G' or 'g' = Conjugate (no transpose) + * mode = 'MATLAB' or 'SPEED' (sets mode for current and future calculations, + * case insensitive, optional) + * M is a string indicating the current calculation mode, before setting the new one. + * C is the result of the matrix multiply operation. + * + * mtimesx uses a combination of BLAS library routine calls and custom code + * to optimize the matrix or scalar multiplies with respect to speed + * without sacrificing accuracy. As a result, some calculations are done in + * a different way than the equivalent MATLAB calculation, resulting in + * slightly different answers. Although slightly different, the mtimesx + * results are just as accurate as the MATLAB results. The general matrix + * multiply calculation uses the same BLAS calls as MATLAB, so there is no + * difference in speed or results for this case. For the scalar * matrix, + * scalar * vector, scalar * array, and matrix * vector cases there + * generally *will* be a difference between mtimesx and the MATLAB built in + * mtimes function. Usually, mtimesx will be faster that the equivalent + * MATLAB function, but some of these cases are slightly slower. + * + * M = mtimesx returns a string with the current calculation mode. The string + * will either be 'MATLAB' or 'SPEED' or one of the OMP modes. + * + * M = mtimesx(mode) sets the calculation mode to mode. The mode variable + * must be either the string 'MATLAB' or the string 'SPEED'. The return + * variable M is the previous mode setting prior to setting the new mode. + * The mode is case insensitive (lower or upper case is OK). You can also + * set one of the OMP modes if you have compiled with an OpenMP compiler. + * + * Mode: + * + * The 'MATLAB' mode uses the same sequence of BLAS calls that MATLAB does, + * and uses scalar multiply code that generates the same results as MATLAB. + * The purpose of this mode is to reproduce the exact same results as the + * same MATLAB operation. As such, there will often be no speed improvement + * by using mtimesx vs using the MATLAB intrinsic mtimes. + * + * The 'SPEED' mode uses different sequences of BLAS calls than MATLAB does + * whenever a speed improvement might be realized. Custom code for dot product + * calculations is used, and certain matrix-matrix and matrix-vector operations + * involving conjugates and/or transposes uses a series of dot product type + * calculations instead of calling BLAS routines if a speed improvement can + * be realized. This mode produces results that will sometimes differ slightly + * from the same MATLAB operation, but the results will still be accurate. + * + * The 'OMP' modes are basically the same as 'SPEED' mode except that some + * of the calculations are multi-threaded using OpenMP directives. + * + * Examples: + * + * C = mtimesx(A,B) % performs the calculation C = A * B + * C = mtimesx(A,'T',B) % performs the calculation C = A.' * B + * C = mtimesx(A,B,'G') % performs the calculation C = A * conj(B) + * C = mtimesx(A,'C',B,'C') % performs the calculation C = A' * B' + * mtimesx % returns the current calculation mode + * mtimesx('MATLAB') % sets calculation mode to match MATLAB + * + * Note: You cannot combine double sparse and single inputs, since MATLAB does not + * support a single sparse result. You also cannot combine sparse inputs with full + * nD (n > 2) inputs, since MATLAB does not support a sparse nD result. The only + * exception is a sparse scalar times an nD full array. In that special case, + * mtimesx will treat the sparse scalar as a full scalar and return a full nD result. + * + * Note: The �N�, �T�, and �C� have the same meanings as the direct inputs to the BLAS + * routines. The �G� input has no direct BLAS counterpart, but was relatively easy to + * implement in mtimesx and saves time (as opposed to computing conj(A) or conj(B) + * explicitly before calling mtimesx). + * + * mtimesx supports nD inputs. For these cases, the first two dimensions specify the + * matrix multiply involved. The remaining dimensions are duplicated and specify the + * number of individual matrix multiplies to perform for the result. i.e., mtimesx + * treats these cases as arrays of 2D matrices and performs the operation on the + * associated parings. For example: + * + * If A is (2,3,4,5) and B is (3,6,4,5), then + * mtimesx(A,B) would result in C(2,6,4,5) + * where C(:,:,i,j) = A(:,:,i,j) * B(:,:,i,j), i=1:4, j=1:5 + * + * which would be equivalent to the MATLAB m-code: + * C = zeros(2,6,4,5); + * for m=1:4 + * for n=1:5 + * C(:,:,m,n) = A(:,:,m,n) * B(:,:,m,n); + * end + * end + * + * The first two dimensions must conform using the standard matrix multiply rules + * taking the transa and transb pre-operations into account, and dimensions 3:end + * must match exactly or be singleton (equal to 1). If a dimension is singleton + * then it is virtually expanded to the required size (i.e., equivalent to a + * repmat operation to get it to a conforming size but without the actual data + * copy). For example: + * + * If A is (2,3,4,5) and B is (3,6,1,5), then + * mtimesx(A,B) would result in C(2,6,4,5) + * where C(:,:,i,j) = A(:,:,i,j) * B(:,:,1,j), i=1:4, j=1:5 + * + * which would be equivalent to the MATLAB m-code: + * C = zeros(2,6,4,5); + * for m=1:4 + * for n=1:5 + * C(:,:,m,n) = A(:,:,m,n) * B(:,:,1,n); + * end + * end + * + * When a transpose (or conjugate transpose) is involved, the first two dimensions + * are transposed in the multiply as you would expect. For example: + * + * If A is (3,2,4,5) and B is (3,6,4,5), then + * mtimesx(A,'C',B,'G') would result in C(2,6,4,5) + * where C(:,:,i,j) = A(:,:,i,j)' * conj( B(:,:,i,j) ), i=1:4, j=1:5 + * + * which would be equivalent to the MATLAB m-code: + * C = zeros(2,6,4,5); + * for m=1:4 + * for n=1:5 + * C(:,:,m,n) = A(:,:,m,n)' * conj( B(:,:,m,n) ); + * end + * end + * + * If A is a scalar (1,1) and B is (3,6,4,5), then + * mtimesx(A,'G',B,'C') would result in C(6,3,4,5) + * where C(:,:,i,j) = conj(A) * B(:,:,i,j)', i=1:4, j=1:5 + * + * which would be equivalent to the MATLAB m-code: + * C = zeros(6,3,4,5); + * for m=1:4 + * for n=1:5 + * C(:,:,m,n) = conj(A) * B(:,:,m,n)'; + * end + * end + * + * Change Log: + * 2009/Sep/27 --> 1.00, Initial Release + * 2009/Dec/10 --> 1.11, Fixed bug for empty transa & transb inputs + * 2010/Feb/23 --> 1.20, Fixed bug for dgemv and sgemv calls + * 2010/Aug/02 --> 1.30, Added (nD scalar) * (nD array) capability + * Replaced buggy mxRealloc with custom routine + * 2010/Oct/04 --> 1.40, Added OpenMP support for custom code + * Expanded sparse * single and sparse * nD support + * Fixed (nD complex scalar)C * (nD array) bug + * + ****************************************************************************/ + +/* OpenMP ------------------------------------------------------------- */ + +#ifdef _OPENMP +#include <omp.h> +#endif + +/* Includes ----------------------------------------------------------- */ + +#include <string.h> +#include <stddef.h> +#include <ctype.h> +#include <math.h> +#include <time.h> +#include "mex.h" + +/* Macros ------------------------------------------------------------- */ + +#ifndef MWSIZE_MAX +#define mwIndex int +#define mwSignedIndex int +#define mwSize int +#define mwSize_t size_t +#else +#define mwSize_t mwSize +#endif + +#define METHOD_BLAS 0 +#define METHOD_LOOPS 1 +#define METHOD_LOOPS_OMP 2 + +#define MTIMESX_NOT_SET 0 +#define MTIMESX_BLAS 1 +#define MTIMESX_LOOPS 2 +#define MTIMESX_LOOPS_OMP 3 +#define MTIMESX_MATLAB 4 +#define MTIMESX_SPEED 5 +#define MTIMESX_SPEED_OMP 6 + +#define STRINGIZE(name) #name +#define TOKENSTRING(name) STRINGIZE(name) + +#define DIRECTIVE_MAX 1000 + +#ifndef COMPILER +#define COMPILER (unknown) +#endif + +/* Prototypes --------------------------------------------------------- */ + +mxArray *DoubleTimesDouble(mxArray *, char, mxArray *, char); +mxArray *FloatTimesFloat(mxArray *, char, mxArray *, char); +mxArray *mxCreateSharedDataCopy(const mxArray *pr); +char mxArrayToTrans(const mxArray *mx); +void *myRealloc(void *vp, mwSize_t n); +void mtimesx_logo(void); +mxArray *modestring(int); + +/* Global Variables --------------------------------------------------- */ + +int mtimesx_mode = MTIMESX_MATLAB; +int max_threads = 0; +int threads_used = 0; +int debug = 0; +int debug_message = 0; + +/* Functions ect for OpenMP implementations ------- */ + +#ifdef _OPENMP + +#define OPENMP_ENABLED 1.0 + +/* Functions etc for non OpenMP implementations ----------------- */ + +/* The omp_get_num_procs() function is courtesy of Dirk-Jan Kroon */ +/* and is based on his FEX submission maxNumCompThreads --------- */ + +#else + +#define OPENMP_ENABLED 0.0 +#define omp_get_wtick() 0.0 +#define omp_get_wtime() ((double)clock()/((double)CLOCKS_PER_SEC)) + +#if defined(_WIN32) || defined(_WIN64) + +#include <windows.h> +int omp_get_num_procs( ) { + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + return sysinfo.dwNumberOfProcessors; +} + +#elif MACOS + +#include <sys/param.h> +#include <sys/sysctl.h> +int omp_get_num_procs( ) { + int nm[2]; + size_t len = 4; + uint32_t count; + + nm[0] = CTL_HW; nm[1] = HW_AVAILCPU; + sysctl(nm, 2, &count, &len, NULL, 0); + + if(count < 1) { + nm[1] = HW_NCPU; + sysctl(nm, 2, &count, &len, NULL, 0); + if(count < 1) { count = 1; } + } + return count; +} +#else + +#include <unistd.h> +int omp_get_num_procs( ) { + return sysconf(_SC_NPROCESSORS_ONLN); +} + +#endif + +#endif + +/*------------------------------------------------------------------------ */ +/*------------------------------------------------------------------------ */ +/*------------------------------------------------------------------------ */ +/*------------------------------------------------------------------------ */ + +void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[]) +{ + mxArray *A, *B, *C, *Araw, *Braw; + mxArray *rhs[4]; + char transa, transb; + char *directive, *cp; + char transstring[2] = "_"; + int unsupported = 0; + int i, j, k, got_directive, nrhs_old = nrhs; + int mtimesx_mode_new, max_threads_new, + already_set_mode, already_set_debug, already_set_threads; + mxArray *ans; + double threads; + +/*------------------------------------------------------------------------- + * Check for proper number of inputs and outputs + *------------------------------------------------------------------------- */ + + if( nlhs > 1 ) { + mexErrMsgTxt("Must have at most 1 output."); + } + +/*------------------------------------------------------------------------- + * If no inputs, just return the current mode + *------------------------------------------------------------------------- */ + + if( nrhs == 0 ) { + plhs[0] = modestring(mtimesx_mode); + return; + } + +/*------------------------------------------------------------------------- + * Find out if any input is a directive + *------------------------------------------------------------------------- */ + + i = 0; + mtimesx_mode_new = MTIMESX_NOT_SET; + max_threads_new = 0; + already_set_mode = 0; + already_set_debug = 0; + already_set_threads = 0; + while( i < nrhs ) { + if( mxIsChar(prhs[i]) ) { + if( mxGetNumberOfElements(prhs[i]) > DIRECTIVE_MAX ) { + mexErrMsgTxt("Unknown directive."); + } else if( cp = directive = mxArrayToString(prhs[i]) ) { + j = 0; + while( *cp ) { + if( *cp == '(' ) j++; + if( *cp == ')' ) j--; + if( j == 0 ) { + *cp = toupper( *cp ); + } + cp++; + } + k = cp - directive; + got_directive = 1; + if( strcmp(directive,"MATLAB") == 0 ) { + if( already_set_mode ) { + mexErrMsgTxt("Cannot set mode twice in same call."); + } + already_set_mode = 1; + mtimesx_mode_new = MTIMESX_MATLAB; + } else if( strcmp(directive,"SPEED") == 0 ) { + if( already_set_mode ) { + mexErrMsgTxt("Cannot set mode twice in same call."); + } + already_set_mode = 1; + mtimesx_mode_new = MTIMESX_SPEED; + } else if( strcmp(directive,"BLAS") == 0 ) { + if( already_set_mode ) { + mexErrMsgTxt("Cannot set mode twice in same call."); + } + already_set_mode = 1; + mtimesx_mode_new = MTIMESX_BLAS; + } else if( strcmp(directive,"LOOPS") == 0 ) { + if( already_set_mode ) { + mexErrMsgTxt("Cannot set mode twice in same call."); + } + already_set_mode = 1; + mtimesx_mode_new = MTIMESX_LOOPS; + } else if( strcmp(directive,"LOGO") == 0 ) { + if( nrhs_old > 1 ) { + mexErrMsgTxt("Cannot combine LOGO directive with other arguments."); + } + mtimesx_logo(); + return; + } else if( strcmp(directive,"HELP") == 0 ) { + if( nrhs_old > 1 ) { + mexErrMsgTxt("Cannot combine HELP directive with other arguments."); + } + mexEvalString("help mtimesx;"); + return; + } else if( strcmp(directive,"DEBUG") == 0 ) { + if( already_set_debug ) { + mexErrMsgTxt("Cannot set DEBUG/NODEBUG twice in same call."); + } + already_set_debug = 1; + debug = 1; + } else if( strcmp(directive,"NODEBUG") == 0 ) { + if( already_set_debug ) { + mexErrMsgTxt("Cannot set DEBUG/NODEBUG twice in same call."); + } + already_set_debug = 1; + debug = 0; + } else if( strcmp(directive,"OMP_GET_NUM_PROCS") == 0 || + strcmp(directive,"OMP_GET_NUM_PROCS()") == 0 ) { + if( nrhs > 1 ) { + mexErrMsgTxt("Cannot combine OMP_GET_NUM_PROCS directive with other arguments."); + } + plhs[0] = mxCreateDoubleScalar(omp_get_num_procs()); + return; + } else if( strcmp(directive,"OMP_GET_MAX_THREADS") == 0 || + strcmp(directive,"OMP_GET_MAX_THREADS()") == 0 ) { + if( nrhs > 1 ) { + mexErrMsgTxt("Cannot combine OMP_GET_MAX_THREADS directive with other arguments."); + } + plhs[0] = mxCreateDoubleScalar(max_threads); + return; + } else if( strcmp(directive,"OMP_GET_NUM_THREADS") == 0 || + strcmp(directive,"OMP_GET_NUM_THREADS") == 0 ) { + if( nrhs > 1 ) { + mexErrMsgTxt("Cannot combine OMP_GET_NUM_THREADS directive with other arguments."); + } + plhs[0] = mxCreateDoubleScalar(threads_used); + return; + } else if( strcmp(directive,"COMPILER") == 0 ) { + if( nrhs > 1 ) { + mexErrMsgTxt("Cannot combine COMPILER directive with other arguments."); + } + plhs[0] = mxCreateString(TOKENSTRING(COMPILER)); + return; + } else if( strcmp(directive,"OPENMP") == 0 ) { + if( nrhs > 1 ) { + mexErrMsgTxt("Cannot combine OPENMP directive with other arguments."); + } + plhs[0] = mxCreateDoubleScalar(OPENMP_ENABLED); + return; + } else if( strcmp(directive,"SPEEDOMP") == 0 ) { + if( already_set_mode ) { + mexErrMsgTxt("Cannot set mode twice in same call."); + } + already_set_mode = 1; +#ifdef _OPENMP + mtimesx_mode_new = MTIMESX_SPEED_OMP; + if( max_threads == 0 ) { + max_threads_new = omp_get_num_procs(); + } +#else + mtimesx_mode_new = MTIMESX_SPEED; +#endif + } else if( strcmp(directive,"LOOPSOMP") == 0 ) { + if( already_set_mode ) { + mexErrMsgTxt("Cannot set mode twice in same call."); + } + already_set_mode = 1; +#ifdef _OPENMP + mtimesx_mode_new = MTIMESX_LOOPS_OMP; + if( max_threads == 0 ) { + max_threads_new = omp_get_num_procs(); + } +#else + mtimesx_mode_new = MTIMESX_LOOPS; +#endif + } else if( strcmp(directive,"OMP_GET_WTICK") == 0 || + strcmp(directive,"OMP_GET_WTICK()") == 0 ) { + if( nrhs > 1 ) { + mexErrMsgTxt("Cannot combine OMP_GET_WTICK directive with other arguments."); + } + plhs[0] = mxCreateDoubleScalar(omp_get_wtick()); + return; + } else if( strcmp(directive,"OMP_GET_WTIME") == 0 || + strcmp(directive,"OMP_GET_WTIME()") == 0 ) { + if( nrhs > 1 ) { + mexErrMsgTxt("Cannot combine OMP_GET_WTIME directive with other arguments."); + } + plhs[0] = mxCreateDoubleScalar(omp_get_wtime()); + return; + } else if( strcmp(directive,"OMP") == 0 ) { +#ifdef _OPENMP + if( already_set_mode ) { + mexErrMsgTxt("Cannot set mode twice in same call."); + } + if( already_set_threads ) { + mexErrMsgTxt("Cannot set threads twice in same call."); + } + already_set_mode = 1; + already_set_threads = 1; + max_threads_new = omp_get_num_procs(); + mtimesx_mode_new = MTIMESX_SPEED_OMP; +#else + if( already_set_mode ) { + mexErrMsgTxt("Cannot set mode twice in same call."); + } + already_set_mode = 1; + mtimesx_mode_new = MTIMESX_SPEED; +#endif + } else if( strcmp(directive,"OMP_SET_NUM_THREADS") == 0 || + strcmp(directive,"OMP_SET_MAX_THREADS") == 0 ) { + if( already_set_threads ) { + mexErrMsgTxt("Cannot set threads twice in same call."); + } + already_set_threads = 1; +#ifdef _OPENMP + max_threads_new = omp_get_num_procs(); +#else + max_threads_new = -1; +#endif + } else if( k > 20 && directive[19] == '(' ) { + directive[19] = '\0'; + if( strcmp(directive,"OMP_SET_NUM_THREADS") == 0 || + strcmp(directive,"OMP_SET_MAX_THREADS") == 0 ) { + if( already_set_threads ) { + mexErrMsgTxt("Cannot set threads twice in same call."); + } + already_set_threads = 1; + directive[ 8] = 'N'; + directive[ 9] = 'U'; + directive[10] = 'M'; + directive[19] = '='; + cp = directive + 20; + j = 1; + while( *cp ) { + if( *cp == '(' ) { + j++; + } else if( *cp == ')' ) { + j--; + if( !j ) { + *cp = ';'; + break; + } + } + cp++; + } + if( j ) { + mexErrMsgTxt("Expression or statement is incorrect--possibly unbalanced ("); + } + if( mexEvalString(directive) ) { + mexErrMsgTxt("Unable to evaluate expression for number of threads"); + } + ans = mexGetVariablePtr("caller","OMP_SET_NUM_THREADS"); + if( ans == NULL ) { + mexErrMsgTxt("Unable to evaluate expression for number of threads"); + } + j = threads = mxGetScalar(ans); + mexEvalString("clear OMP_SET_NUM_THREADS;"); + if( j < 1 || j != threads ) { + mexErrMsgTxt("Number of threads must be a positive integer."); + } + if( j > omp_get_num_procs() ) j = omp_get_num_procs(); +#ifdef _OPENMP + max_threads_new = j; +#else + max_threads_new = -1; +#endif + } else { + got_directive = 0; + } + } else { + got_directive = 0; + } + mxFree(directive); + } else { + mexErrMsgTxt("Error allocating memory for directive string"); + } + if( got_directive ) { + for( j=i; j<nrhs-1; j++ ) { + prhs[j] = prhs[j+1]; + } + nrhs--; + } else { + i++; + } + } else { + i++; + } + } + if( mtimesx_mode_new > 0 ) { + mtimesx_mode = mtimesx_mode_new; + } + if( max_threads_new > 0 ) { + max_threads = max_threads_new; + } + if( nrhs == 0 ) { + if( mtimesx_mode_new || !max_threads_new ) { + plhs[0] = modestring(mtimesx_mode); + } else { + plhs[0] = mxCreateDoubleScalar(max_threads); + } + return; + } + + if( nrhs < 2 || nrhs > 4 ) { + mexErrMsgTxt("Must have 2 - 4 non-directive inputs for multiply function"); + } + +/*------------------------------------------------------------------------- + * Pick off the transpose character inputs. If they are missing or empty + * or blank, then use 'N' by default. + *------------------------------------------------------------------------- */ + + Araw = (mxArray *) prhs[0]; + if( nrhs == 2 ) { + transa = 'N'; + Braw = (mxArray *) prhs[1]; + transb = 'N'; + } else if( nrhs == 3 ) { + if( mxIsChar(prhs[1]) ) { + transa = mxArrayToTrans(prhs[1]); + Braw = (mxArray *) prhs[2]; + transb = 'N'; + } else if( mxIsChar(prhs[2]) ) { + transa = 'N'; + Braw = (mxArray *) prhs[1]; + transb = mxArrayToTrans(prhs[2]); + } else { + mexErrMsgTxt("2nd or 3rd input must be char."); + } + } else { /* nrhs == 4 */ + if( mxIsChar(prhs[1]) && mxIsChar(prhs[3]) ) { + transa = mxArrayToTrans(prhs[1]); + Braw = (mxArray *) prhs[2]; + transb = mxArrayToTrans(prhs[3]); + } else { + mexErrMsgTxt("2nd and 4th inputs must be char."); + } + } + +/*----------------------------------------------------------------------------- + * Check for valid TRANS characters + *----------------------------------------------------------------------------- */ + + if( transa == 'n' ) transa = 'N'; + if( transa == 't' ) transa = 'T'; + if( transa == 'c' ) transa = 'C'; + if( transa == 'g' ) transa = 'G'; + if( transb == 'n' ) transb = 'N'; + if( transb == 't' ) transb = 'T'; + if( transb == 'c' ) transb = 'C'; + if( transb == 'g' ) transb = 'G'; + if( (transa != 'N' && transa != 'T' && transa != 'C' && transa != 'G') || + (transb != 'N' && transb != 'T' && transb != 'C' && transb != 'G') ) { + mexErrMsgTxt("Invalid TRANS character. Expected N, T, C, or G."); + } + +/*----------------------------------------------------------------------------- + * Check for proper input type and call the appropriate multiply routine. + * To be similar to MATLAB for mixed single-double operations, convert + * single inputs to double, do the calc, then convert back to single. + *----------------------------------------------------------------------------- */ + +/* Future Enhancement: Put in special code for scalar multiplies, do calc in double */ + + if( mxIsDouble(Araw) ) { + if( mxIsDouble(Braw) ) { + /* + if( mxIsSparse(Araw) && !mxIsSparse(Braw) && + (mxGetNumberOfElements(Araw) != 1 || mxGetNumberOfDimensions(Braw) == 2) ) { + k = mexCallMATLAB(1, &B, 1, &Braw, "sparse"); + plhs[0] = DoubleTimesDouble(Araw, transa, B, transb); + mxDestroyArray(B); + } else if( !mxIsSparse(Araw) && mxIsSparse(Braw) && + (mxGetNumberOfElements(Braw) != 1 || mxGetNumberOfDimensions(Araw) == 2) ) { + k = mexCallMATLAB(1, &A, 1, &Araw, "sparse"); + plhs[0] = DoubleTimesDouble(A, transa, Braw, transb); + mxDestroyArray(A); + } else { + plhs[0] = DoubleTimesDouble(Araw, transa, Braw, transb); + } + */ + if( mxIsSparse(Araw) && !mxIsSparse(Braw) && + mxGetNumberOfElements(Araw) == 1 && mxGetNumberOfDimensions(Braw) == 2 ) { + k = mexCallMATLAB(1, &B, 1, &Braw, "sparse"); + plhs[0] = DoubleTimesDouble(Araw, transa, B, transb); + mxDestroyArray(B); + } else if( !mxIsSparse(Araw) && mxIsSparse(Braw) && + mxGetNumberOfElements(Braw) == 1 && mxGetNumberOfDimensions(Araw) == 2 ) { + k = mexCallMATLAB(1, &A, 1, &Araw, "sparse"); + plhs[0] = DoubleTimesDouble(A, transa, Braw, transb); + mxDestroyArray(A); + } else { + plhs[0] = DoubleTimesDouble(Araw, transa, Braw, transb); + } + } else if( mxIsSingle(Braw) ) { + if( mxIsSparse(Araw) ) { + if( mxGetNumberOfElements(Araw) == 1 ) { + k = mexCallMATLAB(1, &C, 1, &Araw, "full"); + k = mexCallMATLAB(1, &A, 1, &C, "single"); + mxDestroyArray(C); + plhs[0] = FloatTimesFloat(A, transa, Braw, transb); + mxDestroyArray(A); + } else { + k = mexCallMATLAB(1, &B, 1, &Braw, "double"); + plhs[0] = DoubleTimesDouble(Araw, transa, B, transb); + mxDestroyArray(B); + } + } else if( mxGetNumberOfElements(Araw) == 1 || mxGetNumberOfElements(Braw) == 1 ) { + k = mexCallMATLAB(1, &B, 1, &Braw, "double"); + C = DoubleTimesDouble(Araw, transa, B, transb); + mxDestroyArray(B); + k = mexCallMATLAB(1, plhs, 1, &C, "single"); + mxDestroyArray(C); + } else { + k = mexCallMATLAB(1, &A, 1, &Araw, "single"); + plhs[0] = FloatTimesFloat(A, transa, Braw, transb); + mxDestroyArray(A); + } + } else { + unsupported = 1; + } + } else if( mxIsSingle(Araw) ) { + if( mxIsDouble(Braw) ) { + if( mxIsSparse(Braw) ) { + if( mxGetNumberOfElements(Braw) == 1 ) { + k = mexCallMATLAB(1, &C, 1, &Braw, "full"); + k = mexCallMATLAB(1, &B, 1, &C, "single"); + mxDestroyArray(C); + plhs[0] = FloatTimesFloat(Araw, transa, B, transb); + mxDestroyArray(B); + } else { + k = mexCallMATLAB(1, &A, 1, &Araw, "double"); + plhs[0] = DoubleTimesDouble(A, transa, Braw, transb); + mxDestroyArray(A); + } + } else if( mxGetNumberOfElements(Araw) == 1 || mxGetNumberOfElements(Braw) == 1 ) { + k = mexCallMATLAB(1, &A, 1, &Araw, "double"); + C = DoubleTimesDouble(A, transa, Braw, transb); + mxDestroyArray(A); + k = mexCallMATLAB(1, plhs, 1, &C, "single"); + mxDestroyArray(C); + } else { + k = mexCallMATLAB(1, &B, 1, &Braw, "single"); + plhs[0] = FloatTimesFloat(Araw, transa, B, transb); + mxDestroyArray(B); + } + } else if( mxIsSingle(Braw) ) { + plhs[0] = FloatTimesFloat(Araw, transa, Braw, transb); + } else { + unsupported = 1; + } + } else { + unsupported = 1; + } + if( unsupported ) { + if( debug ) { + mexPrintf("MTIMESX: Unsupported types ... calling MATLAB intrinsic function mtimes\n"); + } + rhs[0] = Araw; + transstring[0] = transa; + rhs[1] = mxCreateString(transstring); + rhs[2] = Braw; + transstring[0] = transb; + rhs[3] = mxCreateString(transstring); + k = mexCallMATLAB(1, plhs, 4, rhs, "mtimesx_sparse"); + mxDestroyArray(rhs[3]); + mxDestroyArray(rhs[1]); + threads_used = 0; + } + + return; + +} + +/*------------------------------------------------------------------------------- + * + * Convert mxArray char input into trans character. + * + *------------------------------------------------------------------------------- */ + +char mxArrayToTrans(const mxArray *mx) +{ + mwSize n; + char *cp; + char trans; + + if( cp = mxArrayToString(mx) ) { + n = mxGetNumberOfElements(mx); + if( n == 0 ) { + trans = 'N'; /* Treat empty char strings the same as 'N' */ + } else { + trans = *cp; /* Pick off only the first character */ + } + mxFree(cp); + } else { + mexErrMsgTxt("Error allocating memory for trans string"); + } + return trans; +} + +/*------------------------------------------------------------------------------- + * + * Clean a real sparse matrix of zeros. The code is a bit ugly because it was + * highly optimized for speed. + * + *------------------------------------------------------------------------------- */ + +mwIndex spcleanreal(mxArray *mx) +{ + mwSize n, nrow; + mwIndex *ir, *jc, *iz; + mwIndex j, x, y, diff; + double *pr, *pz; + + n = mxGetN(mx); + pz = pr = mxGetData(mx); + ir = mxGetIr(mx); + jc = mxGetJc(mx); + + diff = 0; + for( y=0; y<n; y++ ) { + nrow = jc[y+1] - jc[y]; + for( x=0; x<nrow; x++ ) { + if( *pr == 0.0 ) { + iz = (ir += (pr - pz)); + pz = pr; + j = y + 1; + goto copydata; + } + pr++; + } + } + return jc[n]; + + for( y=0; y<n; y++ ) { + j = y + 1; + nrow = (jc[j] - diff) - jc[y]; + for( x=0; x<nrow; x++ ) { + if( *pr != 0.0 ) { + *pz++ = *pr; + *iz++ = *ir; + } else { + copydata: + diff++; + } + pr++; + ir++; + } + jc[j] -= diff; + } + return jc[n]; +} + +/*------------------------------------------------------------------------------- + * + * Clean a complex sparse matrix of zeros. The code is a bit ugly because it was + * highly optimized for speed. + * + *------------------------------------------------------------------------------- */ + +mwIndex spcleancomplex(mxArray *mx) +{ + mwSize n, nrow; + mwIndex *ir, *jc, *iz; + mwIndex j, x, y, diff; + double *pr, *pz; + double *pi, *py; + + n = mxGetN(mx); + pz = pr = mxGetData(mx); + py = pi = mxGetImagData(mx); + ir = mxGetIr(mx); + jc = mxGetJc(mx); + + diff = 0; + for( y=0; y<n; y++ ) { + nrow = jc[y+1] - jc[y]; + for( x=0; x<nrow; x++ ) { + if( *pr == 0.0 && *pi == 0.0 ) { + iz = (ir += (pr - pz)); + pz = pr; + py = pi; + j = y + 1; + goto copydata; + } + pr++; + pi++; + } + } + return jc[n]; + + for( y=0; y<n; y++ ) { + j = y + 1; + nrow = (jc[j] - diff) - jc[y]; + for( x=0; x<nrow; x++ ) { + if( *pr != 0.0 || *pi != 0.0 ) { + *pz++ = *pr; + *py++ = *pi; + *iz++ = *ir; + } else { + copydata: + diff++; + } + pr++; + pi++; + ir++; + } + jc[j] -= diff; + } + return jc[n]; +} + +/*------------------------------------------------------------------------------- */ + +mwIndex spclean(mxArray *mx) +{ + if( mxIsComplex(mx) ) { + return spcleancomplex(mx); + } else { + return spcleanreal(mx); + } +} + +/*------------------------------------------------------------------------------- + * myRealloc for use only in cases of decreasing a block size. Avoids using the + * buggy mxRealloc function for this case. + *------------------------------------------------------------------------------- */ + +void *myRealloc(void *vp, mwSize_t n) +{ + void *xp; + + if( xp = mxMalloc(n) ) { /* not really a necessary test for a mex routine */ + memcpy(xp, vp, n); + mxFree(vp); + return xp; + } else { + return vp; + } +} + +/*------------------------------------------------------------------------------- + * Logo. + *------------------------------------------------------------------------------- */ + +void mtimesx_logo(void) +{ + mxArray *rhs[9]; + double *x, *y, *z; + double r; + mwSize i, j; + + /* fh = figure */ + mexCallMATLAB(1, rhs, 0, NULL,"figure"); + + /* set(fh, 'Color', [1 1 1]) */ + rhs[1] = mxCreateString("Color"); + rhs[2] = mxCreateDoubleMatrix(1, 3, mxREAL); + x = mxGetPr(rhs[2]); + x[0] = x[1] = x[2] = 1.0; + mexCallMATLAB(0, NULL, 3, rhs, "set"); + mxDestroyArray(rhs[0]); + mxDestroyArray(rhs[1]); + mxDestroyArray(rhs[2]); + + /* [X Y] = meshgrid(-8:0.0625:8); */ + /* R = sqrt(X.^2 + Y.^2) + eps; */ + /* Z = sin(R)./R; */ + rhs[0] = mxCreateDoubleMatrix(257, 257, mxREAL); + rhs[1] = mxCreateDoubleMatrix(257, 257, mxREAL); + rhs[2] = mxCreateDoubleMatrix(257, 257, mxREAL); + x = mxGetPr(rhs[0]); + y = mxGetPr(rhs[1]); + z = mxGetPr(rhs[2]); + for( i=0; i<257; i++ ) { + for( j=0; j<257; j++ ) { + *x = -8.0 + i * 0.0625; + *y = -8.0 + j * 0.0625; + r = sqrt((*x)*(*x) + (*y)*(*y)) + 2.22e-16; + *z++ = sin(r) / r; + x++; + y++; + } + } + + /* surf(X,Y,Z,'FaceColor','interp',... */ + /* 'EdgeColor','none',... */ + /* 'FaceLighting','phong') */ + rhs[3] = mxCreateString("FaceColor"); + rhs[4] = mxCreateString("interp"); + rhs[5] = mxCreateString("EdgeColor"); + rhs[6] = mxCreateString("none"); + rhs[7] = mxCreateString("FaceLighting"); + rhs[8] = mxCreateString("phong"); + mexCallMATLAB(0, NULL, 9, rhs, "surf"); + for( i=0; i<9; i++ ) { + mxDestroyArray(rhs[i]); + } + + /* daspect([5 5 1]) */ + rhs[0] = mxCreateDoubleMatrix(1, 3, mxREAL); + x = mxGetPr(rhs[0]); + x[0] = 5.0; + x[1] = 5.0; + x[2] = 1.0; + mexCallMATLAB(0, NULL, 1, rhs, "daspect"); + mxDestroyArray(rhs[0]); + + /* axis('tight') */ + rhs[0] = mxCreateString("tight"); + mexCallMATLAB(0, NULL, 1, rhs, "axis"); + mxDestroyArray(rhs[0]); + + /* axis('off') */ + rhs[0] = mxCreateString("off"); + mexCallMATLAB(0, NULL, 1, rhs, "axis"); + mxDestroyArray(rhs[0]); + + /* view([-50 30]) */ + rhs[0] = mxCreateDoubleMatrix(1, 2, mxREAL); + x = mxGetPr(rhs[0]); + x[0] = -50.0; + x[1] = 30.0; + mexCallMATLAB(0, NULL, 1, rhs, "view"); + mxDestroyArray(rhs[0]); + + /* camlight('left') */ + rhs[0] = mxCreateString("left"); + mexCallMATLAB(0, NULL, 1, rhs, "camlight"); + mxDestroyArray(rhs[0]); +} + +/*------------------------------------------------------------------------------- + * Construct mode string. + *------------------------------------------------------------------------------- */ + +mxArray *modestring(int m) +{ + + switch( m ) + { + case MTIMESX_BLAS: + return mxCreateString("BLAS"); + case MTIMESX_LOOPS: + return mxCreateString("LOOPS"); + case MTIMESX_LOOPS_OMP: + return mxCreateString("LOOPSOMP"); + case MTIMESX_MATLAB: + return mxCreateString("MATLAB"); + case MTIMESX_SPEED: + return mxCreateString("SPEED"); + case MTIMESX_SPEED_OMP: + return mxCreateString("SPEEDOMP"); + } + return mxCreateString(""); +} + +/*------------------------------------------------------------------------------- + * Construct thread string. + *------------------------------------------------------------------------------- */ + +mxArray *threadstring(int t) +{ + char ompstring[] = "OMP_SET_NUM_THREADS(___)"; + int k; + + if( t > 999 ) { + return mxCreateString("OMP_SET_NUM_THREADS"); + } else { + k = 20; + if( max_threads > 99 ) { + ompstring[k++] = (t / 100) + '0'; + t /= 10; + } + if( t > 9 ) { + ompstring[k++] = (t / 10) + '0'; + t /= 10; + } + ompstring[k++] = t + '0'; + ompstring[k++] = ')'; + ompstring[k ] = '\0'; + return mxCreateString(ompstring); + } +} + +/*------------------------------------------------------------------------- + * Macros to define CAPITAL letters as the address of the lower case letter + * This will make the function calls look much cleaner + *------------------------------------------------------------------------- */ + +#define M &m +#define K &k +#define L &l +#define N &n +#define M1 &m1 +#define N1 &n1 +#define M2 &m2 +#define N2 &n2 +#define AR &ar +#define AI &ai +#define BI &bi +#define AIBI &aibi +#define LDA &lda +#define LDB &ldb +#define LDC &ldc +#define ZERO &Zero +#define ONE &One +#define MINUSONE &Minusone +#define TRANSA &transa +#define TRANSB &transb +#define TRANS &trans +#define PTRANSA &ptransa +#define PTRANSB &ptransb +#define INCX &inc +#define INCY &inc +#define ALPHA &alpha +#define UPLO &uplo + +/*------------------------------------------------------------------------- + * Number of bytes that a sparse matrix result has to drop by before a + * realloc will be performed on the data area(s). + *------------------------------------------------------------------------- */ + +#define REALLOCTOL 1024 + +/*------------------------------------------------------------------------- + * Number of elements in a dot product must be at least this much before + * the calculation will be multi-threaded even when OMP is enabled. + *------------------------------------------------------------------------- */ + +#ifdef __LCC__ +#define OMP_DOT_SMALL 182000 +#else +#define OMP_DOT_SMALL 126000 +#endif + +/*------------------------------------------------------------------------- + * Number of elements in the temporary dot product storage array. Used to + * ensure multi-threaded results are consistent from run to run. Prefer + * using this as opposed to using atomic or reduction methods which would + * not guarantee consistent results from run to run. + *------------------------------------------------------------------------- */ + +#define OMP_DOT_ARRAY_SIZE 256 + +/*------------------------------------------------------------------------- + * Number of elements in a scalar product must be at least this much before + * the calculation will be multi-threaded even when OMP is enabled. + *------------------------------------------------------------------------- */ + +#define OMP_SCALAR_SMALL 100000 + +/*------------------------------------------------------------------------- + * Number of elements in an outer product must be at least this much before + * the calculation will be multi-threaded even when OMP is enabled. + *------------------------------------------------------------------------- */ + +#define OMP_OUTER_SMALL 100000 + +/*------------------------------------------------------------------------- + * Number of loops in special multiply cases must be at least this much + * before the calculation will be multi-threaded even when OMP is enabled. + *------------------------------------------------------------------------- */ + +#define OMP_SPECIAL_SMALL 1000 + +/*------------------------------------------------------------------------- + * Macros for the double * double function. All of the generic function + * names and variable types in the file mtimesx_RealTimesReal.c are to be + * replace with these names specific to the double type. + *------------------------------------------------------------------------- */ + +#define MatlabReturnType mxDOUBLE_CLASS +#define RealTimesReal DoubleTimesDouble +#define RealTimesScalar DoubleTimesScalar +#define RealTimesScalarX DoubleTimesScalarX +#define AllRealZero AllDoubleZero +#define RealKindEqP1P0TimesRealKindN DoubleImagEqP1P0TimesDoubleImagN +#define RealKindEqP1P0TimesRealKindG DoubleImagEqP1P0TimesDoubleImagG +#define RealKindEqP1P0TimesRealKindT DoubleImagEqP1P0TimesDoubleImagT +#define RealKindEqP1P0TimesRealKindC DoubleImagEqP1P0TimesDoubleImagC +#define RealKindEqP1P1TimesRealKindN DoubleImagEqP1P1TimesDoubleImagN +#define RealKindEqP1P1TimesRealKindG DoubleImagEqP1P1TimesDoubleImagG +#define RealKindEqP1P1TimesRealKindT DoubleImagEqP1P1TimesDoubleImagT +#define RealKindEqP1P1TimesRealKindC DoubleImagEqP1P1TimesDoubleImagC +#define RealKindEqP1M1TimesRealKindN DoubleImagEqP1M1TimesDoubleImagN +#define RealKindEqP1M1TimesRealKindG DoubleImagEqP1M1TimesDoubleImagG +#define RealKindEqP1M1TimesRealKindT DoubleImagEqP1M1TimesDoubleImagT +#define RealKindEqP1M1TimesRealKindC DoubleImagEqP1M1TimesDoubleImagC +#define RealKindEqP1PxTimesRealKindN DoubleImagEqP1PxTimesDoubleImagN +#define RealKindEqP1PxTimesRealKindG DoubleImagEqP1PxTimesDoubleImagG +#define RealKindEqP1PxTimesRealKindT DoubleImagEqP1PxTimesDoubleImagT +#define RealKindEqP1PxTimesRealKindC DoubleImagEqP1PxTimesDoubleImagC +#define RealKindEqM1P1TimesRealKindN DoubleImagEqM1P1TimesDoubleImagN +#define RealKindEqM1P1TimesRealKindG DoubleImagEqM1P1TimesDoubleImagG +#define RealKindEqM1P1TimesRealKindT DoubleImagEqM1P1TimesDoubleImagT +#define RealKindEqM1P1TimesRealKindC DoubleImagEqM1P1TimesDoubleImagC +#define RealKindEqM1M1TimesRealKindN DoubleImagEqM1M1TimesDoubleImagN +#define RealKindEqM1M1TimesRealKindG DoubleImagEqM1M1TimesDoubleImagG +#define RealKindEqM1M1TimesRealKindT DoubleImagEqM1M1TimesDoubleImagT +#define RealKindEqM1M1TimesRealKindC DoubleImagEqM1M1TimesDoubleImagC +#define RealKindEqM1PxTimesRealKindN DoubleImagEqM1PxTimesDoubleImagN +#define RealKindEqM1PxTimesRealKindG DoubleImagEqM1PxTimesDoubleImagG +#define RealKindEqM1PxTimesRealKindT DoubleImagEqM1PxTimesDoubleImagT +#define RealKindEqM1PxTimesRealKindC DoubleImagEqM1PxTimesDoubleImagC +#define RealKindEqM1P0TimesRealKindN DoubleImagEqM1P0TimesDoubleImagN +#define RealKindEqM1P0TimesRealKindG DoubleImagEqM1P0TimesDoubleImagG +#define RealKindEqM1P0TimesRealKindT DoubleImagEqM1P0TimesDoubleImagT +#define RealKindEqM1P0TimesRealKindC DoubleImagEqM1P0TimesDoubleImagC +#define RealKindEqPxP1TimesRealKindN DoubleImagEqPxP1TimesDoubleImagN +#define RealKindEqPxP1TimesRealKindG DoubleImagEqPxP1TimesDoubleImagG +#define RealKindEqPxP1TimesRealKindT DoubleImagEqPxP1TimesDoubleImagT +#define RealKindEqPxP1TimesRealKindC DoubleImagEqPxP1TimesDoubleImagC +#define RealKindEqPxM1TimesRealKindN DoubleImagEqPxM1TimesDoubleImagN +#define RealKindEqPxM1TimesRealKindG DoubleImagEqPxM1TimesDoubleImagG +#define RealKindEqPxM1TimesRealKindT DoubleImagEqPxM1TimesDoubleImagT +#define RealKindEqPxM1TimesRealKindC DoubleImagEqPxM1TimesDoubleImagC +#define RealKindEqPxP0TimesRealKindN DoubleImagEqPxP0TimesDoubleImagN +#define RealKindEqPxP0TimesRealKindG DoubleImagEqPxP0TimesDoubleImagG +#define RealKindEqPxP0TimesRealKindT DoubleImagEqPxP0TimesDoubleImagT +#define RealKindEqPxP0TimesRealKindC DoubleImagEqPxP0TimesDoubleImagC +#define RealKindEqPxPxTimesRealKindN DoubleImagEqPxPxTimesDoubleImagN +#define RealKindEqPxPxTimesRealKindG DoubleImagEqPxPxTimesDoubleImagG +#define RealKindEqPxPxTimesRealKindT DoubleImagEqPxPxTimesDoubleImagT +#define RealKindEqPxPxTimesRealKindC DoubleImagEqPxPxTimesDoubleImagC + +#if defined(_WIN32) || defined(_WIN64) +#define xDOT ddot +#define xGEMV dgemv +#define xGEMM dgemm +#define xSYRK dsyrk +#define xSYR2K dsyr2k +#define xAXPY daxpy +#define xGER dger +#define xSYR dsyr +#define xSYR2 dsyr2 +#else +#define xDOT ddot_ +#define xGEMV dgemv_ +#define xGEMM dgemm_ +#define xSYRK dsyrk_ +#define xSYR2K dsyr2k_ +#define xAXPY daxpy_ +#define xGER dger_ +#define xSYR dsyr_ +#define xSYR2 dsyr2_ +#endif + +#define xFILLPOS dfillpos +#define xFILLNEG dfillneg +#define zero 0.0 +#define one 1.0 +#define minusone -1.0 +#define RealKind double +#define RealKindComplex doublecomplex +#define RealKindDotProduct doublecomplexdotproduct +#define RealKindDotProductX doublecomplexdotproductx +#define RealKindOuterProduct doublecomplexouterproduct +#define RealKindOuterProductX doublecomplexouterproductx +#define RealScalarTimesReal doublescalartimesdouble +#define RealKindZZ doubleZZ + +#include "mtimesx_RealTimesReal.c" + +/*---------------------------------------------------------------------- + * Undefine all of the double specific macros + *---------------------------------------------------------------------- */ + +#undef MatlabReturnType +#undef RealTimesReal +#undef RealTimesScalar +#undef RealTimesScalarX +#undef AllRealZero +#undef RealKindEqP1P0TimesRealKindN +#undef RealKindEqP1P0TimesRealKindG +#undef RealKindEqP1P0TimesRealKindT +#undef RealKindEqP1P0TimesRealKindC +#undef RealKindEqP1P1TimesRealKindN +#undef RealKindEqP1P1TimesRealKindG +#undef RealKindEqP1P1TimesRealKindT +#undef RealKindEqP1P1TimesRealKindC +#undef RealKindEqP1M1TimesRealKindN +#undef RealKindEqP1M1TimesRealKindG +#undef RealKindEqP1M1TimesRealKindT +#undef RealKindEqP1M1TimesRealKindC +#undef RealKindEqP1PxTimesRealKindN +#undef RealKindEqP1PxTimesRealKindG +#undef RealKindEqP1PxTimesRealKindT +#undef RealKindEqP1PxTimesRealKindC +#undef RealKindEqM1P1TimesRealKindN +#undef RealKindEqM1P1TimesRealKindG +#undef RealKindEqM1P1TimesRealKindT +#undef RealKindEqM1P1TimesRealKindC +#undef RealKindEqM1M1TimesRealKindN +#undef RealKindEqM1M1TimesRealKindG +#undef RealKindEqM1M1TimesRealKindT +#undef RealKindEqM1M1TimesRealKindC +#undef RealKindEqM1P0TimesRealKindN +#undef RealKindEqM1P0TimesRealKindG +#undef RealKindEqM1P0TimesRealKindT +#undef RealKindEqM1P0TimesRealKindC +#undef RealKindEqM1PxTimesRealKindN +#undef RealKindEqM1PxTimesRealKindG +#undef RealKindEqM1PxTimesRealKindT +#undef RealKindEqM1PxTimesRealKindC +#undef RealKindEqPxP1TimesRealKindN +#undef RealKindEqPxP1TimesRealKindG +#undef RealKindEqPxP1TimesRealKindT +#undef RealKindEqPxP1TimesRealKindC +#undef RealKindEqPxM1TimesRealKindN +#undef RealKindEqPxM1TimesRealKindG +#undef RealKindEqPxM1TimesRealKindT +#undef RealKindEqPxM1TimesRealKindC +#undef RealKindEqPxP0TimesRealKindN +#undef RealKindEqPxP0TimesRealKindG +#undef RealKindEqPxP0TimesRealKindT +#undef RealKindEqPxP0TimesRealKindC +#undef RealKindEqPxPxTimesRealKindN +#undef RealKindEqPxPxTimesRealKindG +#undef RealKindEqPxPxTimesRealKindT +#undef RealKindEqPxPxTimesRealKindC +#undef xDOT +#undef xGEMV +#undef xGEMM +#undef xSYRK +#undef xSYR2K +#undef xAXPY +#undef xGER +#undef xSYR +#undef xSYR2 +#undef xFILLPOS +#undef xFILLNEG +#undef zero +#undef one +#undef minusone +#undef RealKind +#undef RealKindComplex +#undef RealKindDotProduct +#undef RealKindDotProductX +#undef RealKindOuterProduct +#undef RealKindOuterProductX +#undef RealScalarTimesReal +#undef RealKindZZ + +/*------------------------------------------------------------------------- + * Macros for the single * single function. All of the generic function + * names and variable types in the file mtimesx_RealTimesReal.c are to be + * replaced with these names specific to the single type. + *------------------------------------------------------------------------- */ + +#define MatlabReturnType mxSINGLE_CLASS +#define RealTimesReal FloatTimesFloat +#define RealTimesScalar FloatTimesScalar +#define RealTimesScalarX FloatTimesScalarX +#define AllRealZero AllFloatZero +#define RealKindEqP1P0TimesRealKindN FloatImagEqP1P0TimesFloatImagN +#define RealKindEqP1P0TimesRealKindG FloatImagEqP1P0TimesFloatImagG +#define RealKindEqP1P0TimesRealKindT FloatImagEqP1P0TimesFloatImagT +#define RealKindEqP1P0TimesRealKindC FloatImagEqP1P0TimesFloatImagC +#define RealKindEqP1P1TimesRealKindN FloatImagEqP1P1TimesFloatImagN +#define RealKindEqP1P1TimesRealKindG FloatImagEqP1P1TimesFloatImagG +#define RealKindEqP1P1TimesRealKindT FloatImagEqP1P1TimesFloatImagT +#define RealKindEqP1P1TimesRealKindC FloatImagEqP1P1TimesFloatImagC +#define RealKindEqP1M1TimesRealKindN FloatImagEqP1M1TimesFloatImagN +#define RealKindEqP1M1TimesRealKindG FloatImagEqP1M1TimesFloatImagG +#define RealKindEqP1M1TimesRealKindT FloatImagEqP1M1TimesFloatImagT +#define RealKindEqP1M1TimesRealKindC FloatImagEqP1M1TimesFloatImagC +#define RealKindEqP1PxTimesRealKindN FloatImagEqP1PxTimesFloatImagN +#define RealKindEqP1PxTimesRealKindG FloatImagEqP1PxTimesFloatImagG +#define RealKindEqP1PxTimesRealKindT FloatImagEqP1PxTimesFloatImagT +#define RealKindEqP1PxTimesRealKindC FloatImagEqP1PxTimesFloatImagC +#define RealKindEqM1P1TimesRealKindN FloatImagEqM1P1TimesFloatImagN +#define RealKindEqM1P1TimesRealKindG FloatImagEqM1P1TimesFloatImagG +#define RealKindEqM1P1TimesRealKindT FloatImagEqM1P1TimesFloatImagT +#define RealKindEqM1P1TimesRealKindC FloatImagEqM1P1TimesFloatImagC +#define RealKindEqM1M1TimesRealKindN FloatImagEqM1M1TimesFloatImagN +#define RealKindEqM1M1TimesRealKindG FloatImagEqM1M1TimesFloatImagG +#define RealKindEqM1M1TimesRealKindT FloatImagEqM1M1TimesFloatImagT +#define RealKindEqM1M1TimesRealKindC FloatImagEqM1M1TimesFloatImagC +#define RealKindEqM1P0TimesRealKindN FloatImagEqM1P0TimesFloatImagN +#define RealKindEqM1P0TimesRealKindG FloatImagEqM1P0TimesFloatImagG +#define RealKindEqM1P0TimesRealKindT FloatImagEqM1P0TimesFloatImagT +#define RealKindEqM1P0TimesRealKindC FloatImagEqM1P0TimesFloatImagC +#define RealKindEqM1PxTimesRealKindN FloatImagEqM1PxTimesFloatImagN +#define RealKindEqM1PxTimesRealKindG FloatImagEqM1PxTimesFloatImagG +#define RealKindEqM1PxTimesRealKindT FloatImagEqM1PxTimesFloatImagT +#define RealKindEqM1PxTimesRealKindC FloatImagEqM1PxTimesFloatImagC +#define RealKindEqPxP1TimesRealKindN FloatImagEqPxP1TimesFloatImagN +#define RealKindEqPxP1TimesRealKindG FloatImagEqPxP1TimesFloatImagG +#define RealKindEqPxP1TimesRealKindT FloatImagEqPxP1TimesFloatImagT +#define RealKindEqPxP1TimesRealKindC FloatImagEqPxP1TimesFloatImagC +#define RealKindEqPxM1TimesRealKindN FloatImagEqPxM1TimesFloatImagN +#define RealKindEqPxM1TimesRealKindG FloatImagEqPxM1TimesFloatImagG +#define RealKindEqPxM1TimesRealKindT FloatImagEqPxM1TimesFloatImagT +#define RealKindEqPxM1TimesRealKindC FloatImagEqPxM1TimesFloatImagC +#define RealKindEqPxP0TimesRealKindN FloatImagEqPxP0TimesFloatImagN +#define RealKindEqPxP0TimesRealKindG FloatImagEqPxP0TimesFloatImagG +#define RealKindEqPxP0TimesRealKindT FloatImagEqPxP0TimesFloatImagT +#define RealKindEqPxP0TimesRealKindC FloatImagEqPxP0TimesFloatImagC +#define RealKindEqPxPxTimesRealKindN FloatImagEqPxPxTimesFloatImagN +#define RealKindEqPxPxTimesRealKindG FloatImagEqPxPxTimesFloatImagG +#define RealKindEqPxPxTimesRealKindT FloatImagEqPxPxTimesFloatImagT +#define RealKindEqPxPxTimesRealKindC FloatImagEqPxPxTimesFloatImagC + +#if defined(_WIN32) || defined(_WIN64) +#define xDOT sdot +#define xGEMV sgemv +#define xGEMM sgemm +#define xSYRK ssyrk +#define xSYR2K ssyr2k +#define xAXPY saxpy +#define xGER sger +#define xSYR ssyr +#define xSYR2 ssyr2 +#else +#define xDOT sdot_ +#define xGEMV sgemv_ +#define xGEMM sgemm_ +#define xSYRK ssyrk_ +#define xSYR2K ssyr2k_ +#define xAXPY saxpy_ +#define xGER sger_ +#define xSYR ssyr_ +#define xSYR2 ssyr2_ +#endif + +#define xFILLPOS sfillpos +#define xFILLNEG sfillneg +#define zero 0.0f +#define one 1.0f +#define minusone -1.0f +#define RealKind float +#define RealKindComplex floatcomplex +#define RealKindDotProduct floatcomplexdotproduct +#define RealKindDotProductX floatcomplexdotproductx +#define RealKindOuterProduct floatcomplexouterproduct +#define RealKindOuterProductX floatcomplexouterproductx +#define RealScalarTimesReal floatscalartimesfloat +#define RealKindZZ floatZZ + +#include "mtimesx_RealTimesReal.c" diff --git a/ext/mtimesx/mtimesx.m b/ext/mtimesx/mtimesx.m new file mode 100644 index 0000000000000000000000000000000000000000..2f02f3c1a952d43f63c7faf487fe6a7a41974ed1 --- /dev/null +++ b/ext/mtimesx/mtimesx.m @@ -0,0 +1,279 @@ +% mtimesx does a matrix multiply of two inputs (single, double, or sparse) +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx +% Filename: mtimesx.m +% Programmer: James Tursa +% Version: 1.10 +% Date: December 08, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +%-- +% +% mtimesx is a fast general purpose matrix and scalar multiply routine that utilizes +% BLAS calls and custom code to perform the calculations. mtimesx also has extended +% support for n-Dimensional (nD, n > 2) arrays, treating these as arrays of 2D matrices +% for the purposes of matrix operations. +% +% "Doesn't MATLAB already do this?" For 2D matrices, yes, it does. However, MATLAB does +% not always implement the most efficent algorithms for memory access, and MATLAB does not +% always take full advantage of symmetric cases. The mtimesx 'SPEED' mode attempts to do +% both of these to the fullest extent possible. For nD matrices, MATLAB does not have +% direct support for this. One is forced to write loops to accomplish the same thing that +% mtimesx can do faster. +% +% The usage is as follows (arguments in brackets [ ] are optional): +% +% Syntax +% +% M = mtimesx( [mode] ) +% C = mtimesx(A [,transa] ,B [,transb] [,mode]) +% +% Description +% +% mtimesx performs the matrix calculation op(A) * op(B), where: +% A = A single or double or sparse scalar, matrix, or array. +% B = A single or double or sparse scalar, matrix, or array. +% transa = A character indicating a pre-operation on A: +% transb = A character indicating a pre-operation on B: +% The pre-operation can be any of: +% 'N' or 'n' = No operation (the default if trans_ is missing) +% 'T' or 't' = Transpose +% 'C' or 'c' = Conjugate Transpose +% 'G' or 'g' = Conjugate (no transpose) +% mode = 'MATLAB' or 'SPEED' (sets mode for current and future calculations, +% case insensitive, optional) +% M is a string indicating the current calculation mode, before setting the new one. +% C is the result of the matrix multiply operation. +% +% Examples: +% +% C = mtimesx(A,B) % performs the calculation C = A * B +% C = mtimesx(A,'T',B) % performs the calculation C = A.' * B +% C = mtimesx(A,B,'G') % performs the calculation C = A * conj(B) +% C = mtimesx(A,'C',B,'C') % performs the calculation C = A' * B' +% +% mtimesx has two modes: +% +% 'MATLAB' mode: This mode attempts to reproduce the MATLAB intrinsic function mtimes +% results exactly. When there was a choice between faster code that did not match the +% MATLAB intrinsic mtimes function results exactly vs slower code that did match the +% MATLAB intrinsic mtimes function results exactly, the choice was made to use the +% slower code. Speed improvements were only made in cases that did not cause a mismatch. +% Caveat: I have only tested on a PC with later versions of MATLAB. But MATLAB may use +% different algorithms for mtimes in earlier versions or on other machines that I was +% unable to test, so even this mode may not match the MATLAB intrinsic mtimes function +% exactly in some cases. This is the default mode when mtimesx is first loaded and +% executed (i.e., the first time you use mtimesx in your MATLAB session and the first +% time you use mtimesx after clearing it). You can set this mode for all future +% calculations with the command mtimesx('MATLAB') (case insensitive). +% +% 'SPEED' mode: This mode attempts to reproduce the MATLAB intrinsic function mtimes +% results closely, but not necessarily exactly. When there was a choice between faster +% code that did not exactly match the MATLAB intrinsic mtimes function vs slower code +% that did match the MATLAB intrinsic mtimes function, the choice was made to use the +% faster code. Speed improvements were made in all cases that I could identify, even +% if they caused a slight mismatch with the MATLAB intrinsic mtimes results. +% NOTE: The mismatches are the results of doing calculations in a different order and +% are not indicative of being less accurate. You can set this mode for all future +% calculations with the command mtimesx('SPEED') (case insensitive). +% +% Note: You cannot combine double sparse and single inputs, since MATLAB does not +% support a single sparse result. You also cannot combine sparse inputs with full +% nD (n > 2) inputs, since MATLAB does not support a sparse nD result. The only +% exception is a sparse scalar times an nD full array. In that special case, +% mtimesx will treat the sparse scalar as a full scalar and return a full nD result. +% +% Note: The �N�, �T�, and �C� have the same meanings as the direct inputs to the BLAS +% routines. The �G� input has no direct BLAS counterpart, but was relatively easy to +% implement in mtimesx and saves time (as opposed to computing conj(A) or conj(B) +% explicitly before calling mtimesx). +% +% mtimesx supports nD inputs. For these cases, the first two dimensions specify the +% matrix multiply involved. The remaining dimensions are duplicated and specify the +% number of individual matrix multiplies to perform for the result. i.e., mtimesx +% treats these cases as arrays of 2D matrices and performs the operation on the +% associated parings. For example: +% +% If A is (2,3,4,5) and B is (3,6,4,5), then +% mtimesx(A,B) would result in C(2,6,4,5) +% where C(:,:,i,j) = A(:,:,i,j) * B(:,:,i,j), i=1:4, j=1:5 +% +% which would be equivalent to the MATLAB m-code: +% C = zeros(2,6,4,5); +% for m=1:4 +% for n=1:5 +% C(:,:,m,n) = A(:,:,m,n) * B(:,:,m,n); +% end +% end +% +% The first two dimensions must conform using the standard matrix multiply rules +% taking the transa and transb pre-operations into account, and dimensions 3:end +% must match exactly or be singleton (equal to 1). If a dimension is singleton +% then it is virtually expanded to the required size (i.e., equivalent to a +% repmat operation to get it to a conforming size but without the actual data +% copy). For example: +% +% If A is (2,3,4,5) and B is (3,6,1,5), then +% mtimesx(A,B) would result in C(2,6,4,5) +% where C(:,:,i,j) = A(:,:,i,j) * B(:,:,1,j), i=1:4, j=1:5 +% +% which would be equivalent to the MATLAB m-code: +% C = zeros(2,6,4,5); +% for m=1:4 +% for n=1:5 +% C(:,:,m,n) = A(:,:,m,n) * B(:,:,1,n); +% end +% end +% +% When a transpose (or conjugate transpose) is involved, the first two dimensions +% are transposed in the multiply as you would expect. For example: +% +% If A is (3,2,4,5) and B is (3,6,4,5), then +% mtimesx(A,'C',B,'G') would result in C(2,6,4,5) +% where C(:,:,i,j) = A(:,:,i,j)' * conj( B(:,:,i,j) ), i=1:4, j=1:5 +% +% which would be equivalent to the MATLAB m-code: +% C = zeros(2,6,4,5); +% for m=1:4 +% for n=1:5 +% C(:,:,m,n) = A(:,:,m,n)' * conj( B(:,:,m,n) ); +% end +% end +% +% If A is a scalar (1,1) and B is (3,6,4,5), then +% mtimesx(A,'G',B,'C') would result in C(6,3,4,5) +% where C(:,:,i,j) = conj(A) * B(:,:,i,j)', i=1:4, j=1:5 +% +% which would be equivalent to the MATLAB m-code: +% C = zeros(6,3,4,5); +% for m=1:4 +% for n=1:5 +% C(:,:,m,n) = conj(A) * B(:,:,m,n)'; +% end +% end +% +% --------------------------------------------------------------------------------------------------------------------------------- +% +% The BLAS routines used are DDOT, DGEMV, DGEMM, DSYRK, and DSYR2K for double +% variables, and SDOT, SGEMV, SGEMM, SSYRK, and SSYR2K for single variables. +% These routines are (description taken from www.netlib.org): +% +% DDOT and SDOT: +% +% * forms the dot product of two vectors. +% +% DGEMV and SGEMV: +% +% * DGEMV performs one of the matrix-vector operations +% * +% * y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, +% * +% * where alpha and beta are scalars, x and y are vectors and A is an +% * m by n matrix. +% +% DGEMM and SGEMM: +% +% * DGEMM performs one of the matrix-matrix operations +% * +% * C := alpha*op( A )*op( B ) + beta*C, +% * +% * where op( X ) is one of +% * +% * op( X ) = X or op( X ) = X', +% * +% * alpha and beta are scalars, and A, B and C are matrices, with op( A ) +% * an m by k matrix, op( B ) a k by n matrix and C an m by n matrix. +% +% DSYRK and SSYRK: +% +% * DSYRK performs one of the symmetric rank k operations +% * +% * C := alpha*A*A' + beta*C, +% * +% * or +% * +% * C := alpha*A'*A + beta*C, +% * +% * where alpha and beta are scalars, C is an n by n symmetric matrix +% * and A is an n by k matrix in the first case and a k by n matrix +% * in the second case. +% +% DSYR2K and SSYR2K: +% +% * DSYR2K performs one of the symmetric rank 2k operations +% * +% * C := alpha*A*B' + alpha*B*A' + beta*C, +% * +% * or +% * +% * C := alpha*A'*B + alpha*B'*A + beta*C, +% * +% * where alpha and beta are scalars, C is an n by n symmetric matrix +% * and A and B are n by k matrices in the first case and k by n +% * matrices in the second case. +% +% Double sparse matrix operations are supported, but not always directly. +% For (matrix) * (scalar) operations, custom code is used to produce a result +% that minimizes memory access times. All other operations, such as +% (matrix) * (vector) or (matrix) * (matrix), or any operation involving a transpose +% or conjugate transpose, are obtained with calls back to the MATLAB intrinsic +% mtimes function. Thus for most non-scalar sparse operations, mtimesx is +% simply a thin wrapper around the intrinsic MATLAB function and you will see +% no speed improvement. +% +% --------------------------------------------------------------------------------------------------------------------------------- +% +% Examples: +% +% C = mtimesx(A,B) % performs the calculation C = A * B +% C = mtimesx(A,'T',B,'speed') % performs the calculation C = A.' * B +% % using a fast algorithm that may not +% % match MATLAB results exactly +% mtimesx('matlab') % sets calculation mode to match MATLAB +% C = mtimesx(A,B,'g') % performs the calculation C = A * conj(B) +% C = mtimesx(A,'c',B,'C') % performs the calculation C = A' * B' +% +% --------------------------------------------------------------------------------------------------------------------------------- + +function varargout = mtimesx(varargin) + +%\ +% If you got here then mtimesx is not compiled yet, so go compile it first. +%/ + +mtimesx_build; + +%\ +% Call the mex routine mtimesx. +%/ + +[varargout{1:nargout}] = mtimesx(varargin{:}); + +end diff --git a/ext/mtimesx/mtimesx.mexa64 b/ext/mtimesx/mtimesx.mexa64 new file mode 100644 index 0000000000000000000000000000000000000000..8a4cf090127ebdf5986589ec3c2aa82234f13df0 Binary files /dev/null and b/ext/mtimesx/mtimesx.mexa64 differ diff --git a/ext/mtimesx/mtimesx.mexw64 b/ext/mtimesx/mtimesx.mexw64 new file mode 100644 index 0000000000000000000000000000000000000000..b68be82c9bf02d1dc940f8ca09edf57b464204cc Binary files /dev/null and b/ext/mtimesx/mtimesx.mexw64 differ diff --git a/ext/mtimesx/mtimesx_20110223.pdf b/ext/mtimesx/mtimesx_20110223.pdf new file mode 100644 index 0000000000000000000000000000000000000000..48144834fb9e7fed50c7c8a9627bab1a637f980c Binary files /dev/null and b/ext/mtimesx/mtimesx_20110223.pdf differ diff --git a/ext/mtimesx/mtimesx_RealTimesReal.c b/ext/mtimesx/mtimesx_RealTimesReal.c new file mode 100644 index 0000000000000000000000000000000000000000..7667902d63eb8198da0ca5f23d8baa9d05ace567 --- /dev/null +++ b/ext/mtimesx/mtimesx_RealTimesReal.c @@ -0,0 +1,7392 @@ +/************************************************************************************* + * + * MATLAB (R) is a trademark of The Mathworks (R) Corporation + * + * Filename: mtimesx_RealTimesReal.c + * Programmer: James Tursa + * Version: 1.41 + * Date: February 23, 2011 + * Copyright: (c) 2009, 2010, 2011 by James Tursa, All Rights Reserved + * + * This code uses the BSD License: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * mtimesx_RealTimesReal.c is a support file for the mtimesx.c mex routine. + * + * Change Log: + * 2009/Sep/27 --> 1.00, Initial Release + * 2009/Dec/03 --> 1.01, Fixed scalar * sparse for scalar with inf or NaN + * 2009/Dec/05 --> 1.02, Fixed bug, added line scalarmultiply = 0; + * 2009/Dec/08 --> 1.10, Added singleton expansion capability + * 2009/Dec/10 --> 1.11, Slight code simplification for singleton expansion + * 2010/Feb/23 --> 1.20, Fixed bug for dgemv and sgemv calls + * 2010/Aug/02 --> 1.30, Added (nD scalar) * (nD array) capability + * Replaced buggy mxRealloc with custom code + * 2010/Oct/04 --> 1.40, Added OpenMP support for custom code + * Expanded sparse * single and sparse * nD support + * Fixed (nD complex scalar)C * (nD array) bug. + * 2011/Feb/23 --> 1.41, Fixed typos in _syrk and _syr2k BLAS prototypes. + * + ****************************************************************************/ + +/*--------------------------------------------------------------------------------- + * Complex type for function return + *--------------------------------------------------------------------------------- */ + +struct RealKindComplex {RealKind r; RealKind i;}; + +/*--------------------------------------------------------------------------------- + * Function Prototypes + *--------------------------------------------------------------------------------- */ + +int AllRealZero(RealKind *x, mwSignedIndex n); +void RealKindEqP1P0TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqP1P0TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqP1P0TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqP1P0TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqP1P1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqP1P1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqP1P1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqP1P1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqP1M1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqP1M1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqP1M1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqP1M1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqP1PxTimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqP1PxTimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqP1PxTimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqP1PxTimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqM1P0TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqM1P0TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqM1P0TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqM1P0TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqM1P1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqM1P1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqM1P1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqM1P1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqM1M1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqM1M1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqM1M1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqM1M1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqM1PxTimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqM1PxTimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqM1PxTimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqM1PxTimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqPxP1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqPxP1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqPxP1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqPxP1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqPxM1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqPxM1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqPxM1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqPxM1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqPxP0TimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqPxP0TimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqPxP0TimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqPxP0TimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqPxPxTimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind ai, RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqPxPxTimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ar, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n); +void RealKindEqPxPxTimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ar, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealKindEqPxPxTimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ar, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p); +void RealTimesScalar(RealKind *Cpr, RealKind *Cpi, RealKind *Bpr, RealKind *Bpi, char transb, + mwSize m2, mwSize n2, RealKind ar, RealKind ai, mwSize n, mwSize p,int); +void RealTimesScalarX(RealKind *Cpr, RealKind *Cpi, RealKind *Bpr, RealKind *Bpi, char transb, + mwSize m2, mwSize n2, RealKind ar, RealKind ai, mwSize n, mwSize p, int); +void xFILLPOS(RealKind *Cpr, mwSignedIndex n); +void xFILLNEG(RealKind *Cpr, mwSignedIndex n); +RealKind xDOT(mwSignedIndex *, RealKind *, mwSignedIndex *, RealKind *, mwSignedIndex *); +void xGER(mwSignedIndex *, mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *, + RealKind *, mwSignedIndex *, RealKind *, mwSignedIndex *); +void xSYR(char *, mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *, + RealKind *, mwSignedIndex *); +void xSYR2(char *, mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *, + RealKind *, mwSignedIndex *, RealKind *, mwSignedIndex *); +void xGEMV(char *, mwSignedIndex *, mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *, + RealKind *, mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *); +void xGEMM(char *, char *, mwSignedIndex *, mwSignedIndex *, mwSignedIndex *, + RealKind *, RealKind *, mwSignedIndex *, RealKind *, mwSignedIndex *, + RealKind *, RealKind *, mwSignedIndex *); +void xSYRK(char *, char *, mwSignedIndex *, mwSignedIndex *, RealKind *, RealKind *, + mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *); +void xSYR2K(char *, char *, mwSignedIndex *, mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *, + RealKind *, mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *); +void xAXPY(mwSignedIndex *, RealKind *, RealKind *, mwSignedIndex *, RealKind *, mwSignedIndex *); +struct RealKindComplex RealKindDotProduct(mwSignedIndex, RealKind *, RealKind *, RealKind, + RealKind *, RealKind *, RealKind, int); +struct RealKindComplex RealKindDotProductX(mwSignedIndex, RealKind *, RealKind *, RealKind, + RealKind *, RealKind *, RealKind, int); +void RealKindOuterProduct(mwSignedIndex, mwSignedIndex, RealKind *, RealKind *, char, + RealKind *, RealKind *, char, RealKind *, RealKind *, int); +void RealKindOuterProductX(mwSignedIndex, mwSignedIndex, RealKind *, RealKind *, char, + RealKind *, RealKind *, char, RealKind *, RealKind *, int); +mxArray *RealScalarTimesReal(mxArray *, char, mwSize, mwSize, mxArray *, char, mwSize, mwSize); + +/*------------------------------------------------------------------------------------- + * Function for multiplying two MATLAB variables + *------------------------------------------------------------------------------------- */ + +mxArray *RealTimesReal(mxArray *A, char transa, mxArray *B, char transb) +{ + mwSignedIndex inc = 1; + RealKind Zero = zero; + RealKind One = one; + RealKind Minusone = minusone; + char uplo = 'L'; /* Arbitrary choice. Pick the symmetric case as lower triangular */ + + mwSize m1, n1, m2, n2, Andim, Bndim, Cndim, Ap, Bp, Cp, ip, p, Asize, Bsize, Csize, ndim; + mwSize Ablock, Bblock; + mwSize *Adims, *Bdims, *Cdims, *Adimz, *Bdimz, *Cindx; + register mwSignedIndex i, j; + mwSignedIndex m, n, k, l, lda, ldb, ldc; + mxArray *C, *result, *rhs[4]; + RealKind *Apr, *Api, *Bpr, *Bpi, *Cpr, *Cpi, *Apr0, *Api0, *Bpr0, *Bpi0; + RealKind *apr, *api, *bpr, *bpi, *cpr, *cpi; + RealKind ai, bi, sr, si, aibi; + RealKind Apr11, Apr12, Apr13, Apr14, + Apr21, Apr22, Apr23, Apr24, + Apr31, Apr32, Apr33, Apr34, + Apr41, Apr42, Apr43, Apr44; + RealKind Api11, Api12, Api13, Api14, + Api21, Api22, Api23, Api24, + Api31, Api32, Api33, Api34, + Api41, Api42, Api43, Api44; + RealKind Bpr11, Bpr12, Bpr13, Bpr14, + Bpr21, Bpr22, Bpr23, Bpr24, + Bpr31, Bpr32, Bpr33, Bpr34, + Bpr41, Bpr42, Bpr43, Bpr44; + RealKind Bpi11, Bpi12, Bpi13, Bpi14, + Bpi21, Bpi22, Bpi23, Bpi24, + Bpi31, Bpi32, Bpi33, Bpi34, + Bpi41, Bpi42, Bpi43, Bpi44; + char ptransa, ptransb; + char transstring[2] = "_"; + struct RealKindComplex z; + int scalarmultiply; + int scalar_method, dot_method, outer_method; + int singleton_expansion; + int destroyA = 0, destroyB = 0; + +/*-------------------------------------------------------------------------------- + * Get sizes. Note that in the multi-dimensional case, mxGetN returns the product + * of all of the dimension sizes 2 through end. + *-------------------------------------------------------------------------------- */ + + debug_message = debug; + threads_used = 0; + m1 = mxGetM(A); + n1 = mxGetN(A); + m2 = mxGetM(B); + n2 = mxGetN(B); + +/*-------------------------------------------------------------------------------- + * Get pointers to the data areas of the operands. + *-------------------------------------------------------------------------------- */ + + Apr0 = Apr = mxGetData(A); + Api0 = Api = mxGetImagData(A); + Bpr0 = Bpr = mxGetData(B); + Bpi0 = Bpi = mxGetImagData(B); + +/*-------------------------------------------------------------------------------- + * Simplify transa & transb if appropriate. + *-------------------------------------------------------------------------------- */ + + if( !Api ) { + if( transa == 'C' ) transa = 'T'; + if( transa == 'G' ) transa = 'N'; + } + if( !Bpi ) { + if( transb == 'C' ) transb = 'T'; + if( transb == 'G' ) transb = 'N'; + } + +/*-------------------------------------------------------------------------------- + * Scalar expansion cases (custom sparse array code for these cases only). + * If there is a inf or NaN in the scalar and the other variable is sparse, + * then don't do the custom code because the sparse zeros will not remain + * zero. So in that case just fall through and call mtimesx_sparse. + * (1 x 1) * (K x N) or (M x K) * (1 x 1) + *-------------------------------------------------------------------------------- */ + + scalarmultiply = 0; + if( m1 == 1 && n1 == 1 ) { + if( debug ) { + mexPrintf("MTIMESX: (1 x 1) * (array)\n"); + } + scalarmultiply = 1; + if( mxIsSparse(B) ) { + if( mxIsInf(*Apr) || mxIsNaN(*Apr) ) { + scalarmultiply = 0; + } else if( (Api != NULL) && (mxIsInf(*Api) || mxIsNaN(*Api)) ) { + scalarmultiply = 0; + } + } + } else if( m2 == 1 && n2 == 1 ) { + if( debug ) { + mexPrintf("MTIMESX: (array) * (1 x 1)\n"); + } + scalarmultiply = 1; + if( mxIsSparse(A) ) { + if( mxIsInf(*Bpr) || mxIsNaN(*Bpr) ) { + scalarmultiply = 0; + } else if( (Bpi != NULL) && (mxIsInf(*Bpi) || mxIsNaN(*Bpi)) ) { + scalarmultiply = 0; + } + } + } + if( scalarmultiply ) { + return RealScalarTimesReal(A, transa, m1, n1, B, transb, m2, n2); + } + +/*-------------------------------------------------------------------------------- + * Multi-dimensional sparse matrix results are not supported in MATLAB, so we are + * forced to convert the sparse matrix to a full matrix for these cases. Just hope + * the memory isn't blown. + *-------------------------------------------------------------------------------- */ + + if( mxIsSparse(A) && mxGetNumberOfDimensions(B) > 2 ) { + k = mexCallMATLAB(1, rhs, 1, &A, "full"); + A = rhs[0]; + m1 = mxGetM(A); + n1 = mxGetN(A); + Apr0 = Apr = mxGetData(A); + Api0 = Api = mxGetImagData(A); + destroyA = 1; + } + if( mxIsSparse(B) && mxGetNumberOfDimensions(A) > 2 ) { + k = mexCallMATLAB(1, rhs, 1, &B, "full"); + B = rhs[0]; + m2 = mxGetM(B); + n2 = mxGetN(B); + Bpr0 = Bpr = mxGetData(B); + Bpi0 = Bpi = mxGetImagData(B); + destroyB = 1; + } + +/*-------------------------------------------------------------------------------- + * Generic sparse matrix or vector operations are not directly supported. + * So just call an m-file to do the work. Won't save any time, but at least + * the function will be supported. + *-------------------------------------------------------------------------------- */ + + if( mxIsSparse(A) || mxIsSparse(B) ) { + if( debug ) { + mexPrintf("MTIMESX: Unsupported sparse operation ... calling MATLAB intrinsic function mtimes\n"); + } + rhs[0] = A; + transstring[0] = transa; + rhs[1] = mxCreateString(transstring); + rhs[2] = B; + transstring[0] = transb; + rhs[3] = mxCreateString(transstring); + mexCallMATLAB(1, &result, 4, rhs, "mtimesx_sparse"); + mxDestroyArray(rhs[3]); + mxDestroyArray(rhs[1]); + return result; + } + +/*------------------------------------------------------------------------------- + * Rename array sizes for convenience. Also makes sure that the integer arguments + * to the BLAS routines are of type mwSignedIndex. + *------------------------------------------------------------------------------- */ + + Andim = mxGetNumberOfDimensions(A); + Adims = (mwSize *) mxGetDimensions(A); + Bndim = mxGetNumberOfDimensions(B); + Bdims = (mwSize *) mxGetDimensions(B); + m1 = Adims[0]; + n1 = Adims[1]; + m2 = Bdims[0]; + n2 = Bdims[1]; + + if( transa == 'N' || transa == 'G' ) { + m = m1; + k = n1; + } else { + m = n1; + k = m1; + } + if( transb == 'N' || transb == 'G' ) { + l = m2; + n = n2; + } else { + l = n2; + n = m2; + } + lda = m1; + ldb = m2; + ldc = m; + +/*------------------------------------------------------------------------------- + * Check for conforming sizes. Allow nD scalar multiply. + *------------------------------------------------------------------------------- */ + + if( (k != l) && (m*k != 1) && (l*n != 1) ) { + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + mexErrMsgTxt("Inner matrix dimensions must agree."); + } + + ndim = (Andim <= Bndim) ? Andim : Bndim; + for( Cp=2; Cp<ndim; Cp++ ) { + if( Adims[Cp] != Bdims[Cp] && Adims[Cp] != 1 && Bdims[Cp] != 1 ) { + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + mexErrMsgTxt("Dimensions 3:end must agree or be 1 in ND case."); + } + } + +/*------------------------------------------------------------------------------- + * Check for nD scalar multiply. + *------------------------------------------------------------------------------- */ + + if( m*k == 1 ) { + scalarmultiply = 1; + } else if( l*n == 1 ) { + scalarmultiply = 2; + } else { + scalarmultiply = 0; + } + +/*------------------------------------------------------------------------------- + * Construct the dimensions of the result. Also use the p variable to keep track + * of the total number of individual matrix multiples that are involved. The + * first two dimensions are simply the result of a single matrix multiply, with + * accouting for the transa and transb pre-operations. The remaining dimensions + * are copied from A or B, whichever happens to be non-singleton. + *------------------------------------------------------------------------------- */ + + Cndim = (Andim > Bndim) ? Andim : Bndim; + Cindx = mxMalloc( Cndim * sizeof(*Cindx) ); + Cdims = mxMalloc( Cndim * sizeof(*Cdims) ); + if( scalarmultiply == 1 ) { + Cdims[0] = l; + Cdims[1] = n; + } else if( scalarmultiply == 2 ) { + Cdims[0] = m; + Cdims[1] = k; + } else { + Cdims[0] = m; + Cdims[1] = n; + } + Adimz = mxMalloc( Cndim * sizeof(*Adimz) ); + Adimz[0] = Adims[0]; + Adimz[1] = Adims[1]; + Bdimz = mxMalloc( Cndim * sizeof(*Bdimz) ); + Bdimz[0] = Bdims[0]; + Bdimz[1] = Bdims[1]; + p = 1; + for( Cp=2; Cp<Cndim; Cp++ ) { + Adimz[Cp] = (Cp < Andim) ? Adims[Cp] : 1; + Bdimz[Cp] = (Cp < Bndim) ? Bdims[Cp] : 1; + Cdims[Cp] = (Adimz[Cp] > Bdimz[Cp]) ? Adimz[Cp] : Bdimz[Cp]; + p *= Cdims[Cp]; + } + for( Cp=0; Cp<Cndim; Cp++ ) { + Cindx[Cp] = 0; + } + +/*------------------------------------------------------------------------------ + * Create output array + *------------------------------------------------------------------------------ */ + + if( mxGetNumberOfElements(A) == 0 || mxGetNumberOfElements(B) == 0 ) { + result = mxCreateNumericArray(Cndim, Cdims, MatlabReturnType, mxREAL); + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + if( mxIsComplex(A) || mxIsComplex(B) ) { + result = mxCreateNumericArray(Cndim, Cdims, MatlabReturnType, mxCOMPLEX); + } else { + result = mxCreateNumericArray(Cndim, Cdims, MatlabReturnType, mxREAL); + } + C = result; + Cpr = mxGetData(C); + Cpi = mxGetImagData(C); + +/*---------------------------------------------------------------------------- + * See if we can do a simple reshape to do the nD multiply all at once + *---------------------------------------------------------------------------- */ + + if( Andim == 2 && Bndim > 2 && !scalarmultiply && (k == 1 || n == 1 || transb == 'N' || transb == 'G') ) { + if( debug_message ) { + mexPrintf("MTIMESX: Reshaping nD multiply as a single multiply\n"); + } + if( transb == 'T' ) transb = 'N'; + if( transb == 'C' ) transb = 'G'; + m2 = k; + n2 = n * p; + n = n2; + p = 1; + ldb = m2; + } + + if( Bndim == 2 && Andim > 2 && !scalarmultiply && m == 1 ) { + if( debug_message ) { + mexPrintf("MTIMESX: Reshaping and reordering nD multiply as a single multiply\n"); + } + apr = Apr; Apr = Bpr; Bpr = apr; + api = Api; Api = Bpi; Bpi = api; + ptransa = transa; transa = transb; transb = ptransa; + if( transa == 'N' ) { + transa = 'T'; + } else if( transa == 'T' ) { + transa = 'N'; + } else if( transa == 'G' ) { + transa = 'C'; + } else { + transa = 'G'; + } + if( transb == 'C' ) { + transb = 'G'; + } else if( transb == 'T' ) { + transb = 'N'; + } + m1 = m2; + n1 = n2; + m2 = k; + n2 = m * p; + if( transa == 'N' || transa == 'G' ) { + m = m1; + } else { + m = n1; + } + l = k; + n = n2; + p = 1; + lda = m1; + ldb = k; + ldc = m; + } + +/*------------------------------------------------------------------------------ + * Set up conjugate factors + *------------------------------------------------------------------------------ */ + + ai = ( transa == 'C' || transa == 'G' ) ? -one : one; + bi = ( transb == 'C' || transb == 'G' ) ? -one : one; + aibi = - ai * bi; + +/*---------------------------------------------------------------------------- + * Individual matrix block sizes + *---------------------------------------------------------------------------- */ + + Asize = m1 * n1; + Bsize = m2 * n2; + Csize = Cdims[0] * Cdims[1]; + +#ifdef _OPENMP + +/*---------------------------------------------------------------------------- + * Check to see if singleton expansion is present + *---------------------------------------------------------------------------- */ + + singleton_expansion = 0; + for( i=2; i<Andim; i++ ) { + if( Adims[i] == 1 ) { + singleton_expansion = 1; + break; + } + } + if( !singleton_expansion ) { + for( i=2; i<Bndim; i++ ) { + if( Bdims[i] == 1 ) { + singleton_expansion = 1; + break; + } + } + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMP inline (1x1)*(KxN) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + scalarmultiply== 1 && p >= OMP_SPECIAL_SMALL && !singleton_expansion ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Ablock = Asize; + Bblock = Bsize; + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind sr_, si_; + RealKind *Apr_, *Bpr_, *Cpr_, *Api_, *Bpi_, *Cpi_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + Api_ = (Api?Api+offset*Asize:NULL); + Bpi_ = (Bpi?Bpi+offset*Bsize:NULL); + Cpi_ = (Cpi?Cpi+offset*Csize:NULL); + for( ip_=0; ip_<p_; ip_++ ) { + sr_ = *Apr_; + si_ = Api_ ? (transa=='N'||transa=='T'?*Api_:-*Api_) : zero; + RealTimesScalar(Cpr_, Cpi_, Bpr_, Bpi_, transb, m2, n2, sr_, si_, Bblock, 1, METHOD_LOOPS); + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + if( Api_ ) { + Api_ += Asize; + } + if( Bpi_ ) { + Bpi_ += Bsize; + } + if( Cpi_ ) { + Cpi_ += Csize; + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMP inline (MxK)*(1x1) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + scalarmultiply== 2 && p >= OMP_SPECIAL_SMALL && !singleton_expansion ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Ablock = Asize; + Bblock = Bsize; + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind sr_, si_; + RealKind *Apr_, *Bpr_, *Cpr_, *Api_, *Bpi_, *Cpi_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + Api_ = (Api?Api+offset*Asize:NULL); + Bpi_ = (Bpi?Bpi+offset*Bsize:NULL); + Cpi_ = (Cpi?Cpi+offset*Csize:NULL); + for( ip_=0; ip_<p_; ip_++ ) { + sr_ = *Bpr_; + si_ = Bpi_ ? (transb=='N'||transb=='T'?*Bpi_:-*Bpi_) : zero; + RealTimesScalar(Cpr_, Cpi_, Apr_, Api_, transa, m1, n1, sr_, si_, Ablock, 1, METHOD_LOOPS); + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + if( Api_ ) { + Api_ += Asize; + } + if( Bpi_ ) { + Bpi_ += Bsize; + } + if( Cpi_ ) { + Cpi_ += Csize; + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMP inline (2x2)*(2x2) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 2 && k == 2 && n == 2 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transa == 'T' ) { + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[2]; + Cpr_[1] = Apr_[2] * Bpr_[0] + Apr_[3] * Bpr_[2]; + Cpr_[2] = Apr_[0] * Bpr_[1] + Apr_[1] * Bpr_[3]; + Cpr_[3] = Apr_[2] * Bpr_[1] + Apr_[3] * Bpr_[3]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[1]; + Cpr_[1] = Apr_[2] * Bpr_[0] + Apr_[3] * Bpr_[1]; + Cpr_[2] = Apr_[0] * Bpr_[2] + Apr_[1] * Bpr_[3]; + Cpr_[3] = Apr_[2] * Bpr_[2] + Apr_[3] * Bpr_[3]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } else { + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[2] * Bpr_[2]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[3] * Bpr_[2]; + Cpr_[2] = Apr_[0] * Bpr_[1] + Apr_[2] * Bpr_[3]; + Cpr_[3] = Apr_[1] * Bpr_[1] + Apr_[3] * Bpr_[3]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[2] * Bpr_[1]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[3] * Bpr_[1]; + Cpr_[2] = Apr_[0] * Bpr_[2] + Apr_[2] * Bpr_[3]; + Cpr_[3] = Apr_[1] * Bpr_[2] + Apr_[3] * Bpr_[3]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMP inline (2x2)*(2x1) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 2 && k == 2 && l == 2 && n == 1 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transa == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[1]; + Cpr_[1] = Apr_[2] * Bpr_[0] + Apr_[3] * Bpr_[1]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[2] * Bpr_[1]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[3] * Bpr_[1]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMp inline (1x2)*(2x2) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 1 && k == 2 && n == 2 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[2]; + Cpr_[1] = Apr_[0] * Bpr_[1] + Apr_[1] * Bpr_[3]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[1]; + Cpr_[1] = Apr_[0] * Bpr_[2] + Apr_[1] * Bpr_[3]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMP inline (3x3)*(3x3) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 3 && k == 3 && n == 3 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transa == 'T' ) { + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[3] + Apr_[2] * Bpr_[6]; + Cpr_[1] = Apr_[3] * Bpr_[0] + Apr_[4] * Bpr_[3] + Apr_[5] * Bpr_[6]; + Cpr_[2] = Apr_[6] * Bpr_[0] + Apr_[7] * Bpr_[3] + Apr_[8] * Bpr_[6]; + Cpr_[3] = Apr_[0] * Bpr_[1] + Apr_[1] * Bpr_[4] + Apr_[2] * Bpr_[7]; + Cpr_[4] = Apr_[3] * Bpr_[1] + Apr_[4] * Bpr_[4] + Apr_[5] * Bpr_[7]; + Cpr_[5] = Apr_[6] * Bpr_[1] + Apr_[7] * Bpr_[4] + Apr_[8] * Bpr_[7]; + Cpr_[6] = Apr_[0] * Bpr_[2] + Apr_[1] * Bpr_[5] + Apr_[2] * Bpr_[8]; + Cpr_[7] = Apr_[3] * Bpr_[2] + Apr_[4] * Bpr_[5] + Apr_[5] * Bpr_[8]; + Cpr_[8] = Apr_[6] * Bpr_[2] + Apr_[7] * Bpr_[5] + Apr_[8] * Bpr_[8]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[1] + Apr_[2] * Bpr_[2]; + Cpr_[1] = Apr_[3] * Bpr_[0] + Apr_[4] * Bpr_[1] + Apr_[5] * Bpr_[2]; + Cpr_[2] = Apr_[6] * Bpr_[0] + Apr_[7] * Bpr_[1] + Apr_[8] * Bpr_[2]; + Cpr_[3] = Apr_[0] * Bpr_[3] + Apr_[1] * Bpr_[4] + Apr_[2] * Bpr_[5]; + Cpr_[4] = Apr_[3] * Bpr_[3] + Apr_[4] * Bpr_[4] + Apr_[5] * Bpr_[5]; + Cpr_[5] = Apr_[6] * Bpr_[3] + Apr_[7] * Bpr_[4] + Apr_[8] * Bpr_[5]; + Cpr_[6] = Apr_[0] * Bpr_[6] + Apr_[1] * Bpr_[7] + Apr_[2] * Bpr_[8]; + Cpr_[7] = Apr_[3] * Bpr_[6] + Apr_[4] * Bpr_[7] + Apr_[5] * Bpr_[8]; + Cpr_[8] = Apr_[6] * Bpr_[6] + Apr_[7] * Bpr_[7] + Apr_[8] * Bpr_[8]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } else { + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[3] * Bpr_[3] + Apr_[6] * Bpr_[6]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[4] * Bpr_[3] + Apr_[7] * Bpr_[6]; + Cpr_[2] = Apr_[2] * Bpr_[0] + Apr_[5] * Bpr_[3] + Apr_[8] * Bpr_[6]; + Cpr_[3] = Apr_[0] * Bpr_[1] + Apr_[3] * Bpr_[4] + Apr_[6] * Bpr_[7]; + Cpr_[4] = Apr_[1] * Bpr_[1] + Apr_[4] * Bpr_[4] + Apr_[7] * Bpr_[7]; + Cpr_[5] = Apr_[2] * Bpr_[1] + Apr_[5] * Bpr_[4] + Apr_[8] * Bpr_[7]; + Cpr_[6] = Apr_[0] * Bpr_[2] + Apr_[3] * Bpr_[5] + Apr_[6] * Bpr_[8]; + Cpr_[7] = Apr_[1] * Bpr_[2] + Apr_[4] * Bpr_[5] + Apr_[7] * Bpr_[8]; + Cpr_[8] = Apr_[2] * Bpr_[2] + Apr_[5] * Bpr_[5] + Apr_[8] * Bpr_[8]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[3] * Bpr_[1] + Apr_[6] * Bpr_[2]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[4] * Bpr_[1] + Apr_[7] * Bpr_[2]; + Cpr_[2] = Apr_[2] * Bpr_[0] + Apr_[5] * Bpr_[1] + Apr_[8] * Bpr_[2]; + Cpr_[3] = Apr_[0] * Bpr_[3] + Apr_[3] * Bpr_[4] + Apr_[6] * Bpr_[5]; + Cpr_[4] = Apr_[1] * Bpr_[3] + Apr_[4] * Bpr_[4] + Apr_[7] * Bpr_[5]; + Cpr_[5] = Apr_[2] * Bpr_[3] + Apr_[5] * Bpr_[4] + Apr_[8] * Bpr_[5]; + Cpr_[6] = Apr_[0] * Bpr_[6] + Apr_[3] * Bpr_[7] + Apr_[6] * Bpr_[8]; + Cpr_[7] = Apr_[1] * Bpr_[6] + Apr_[4] * Bpr_[7] + Apr_[7] * Bpr_[8]; + Cpr_[8] = Apr_[2] * Bpr_[6] + Apr_[5] * Bpr_[7] + Apr_[8] * Bpr_[8]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMP inline (3x3)*(3x1) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 3 && k == 3 && l == 3 && n == 1 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transa == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[1] + Apr_[2] * Bpr_[2]; + Cpr_[1] = Apr_[3] * Bpr_[0] + Apr_[4] * Bpr_[1] + Apr_[5] * Bpr_[2]; + Cpr_[2] = Apr_[6] * Bpr_[0] + Apr_[7] * Bpr_[1] + Apr_[8] * Bpr_[2]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[3] * Bpr_[1] + Apr_[6] * Bpr_[2]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[4] * Bpr_[1] + Apr_[7] * Bpr_[2]; + Cpr_[2] = Apr_[2] * Bpr_[0] + Apr_[5] * Bpr_[1] + Apr_[8] * Bpr_[2]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMp inline (1x3)*(3x3) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 1 && k == 3 && n == 3 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[3] + Apr_[2] * Bpr_[6]; + Cpr_[1] = Apr_[0] * Bpr_[1] + Apr_[1] * Bpr_[4] + Apr_[2] * Bpr_[7]; + Cpr_[2] = Apr_[0] * Bpr_[2] + Apr_[1] * Bpr_[5] + Apr_[2] * Bpr_[8]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[1] + Apr_[2] * Bpr_[2]; + Cpr_[1] = Apr_[0] * Bpr_[3] + Apr_[1] * Bpr_[4] + Apr_[2] * Bpr_[5]; + Cpr_[2] = Apr_[0] * Bpr_[6] + Apr_[1] * Bpr_[7] + Apr_[2] * Bpr_[8]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMP inline (4x4)*(4x4) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 4 && k == 4 && n == 4 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transa == 'T' ) { + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[ 0] * Bpr_[0] + Apr_[ 1] * Bpr_[4] + Apr_[ 2] * Bpr_[ 8] + Apr_[ 3] * Bpr_[12]; + Cpr_[1] = Apr_[ 4] * Bpr_[0] + Apr_[ 5] * Bpr_[4] + Apr_[ 6] * Bpr_[ 8] + Apr_[ 7] * Bpr_[12]; + Cpr_[2] = Apr_[ 8] * Bpr_[0] + Apr_[ 9] * Bpr_[4] + Apr_[10] * Bpr_[ 8] + Apr_[11] * Bpr_[12]; + Cpr_[3] = Apr_[12] * Bpr_[0] + Apr_[13] * Bpr_[4] + Apr_[14] * Bpr_[ 8] + Apr_[15] * Bpr_[12]; + Cpr_[4] = Apr_[ 0] * Bpr_[1] + Apr_[ 1] * Bpr_[5] + Apr_[ 2] * Bpr_[ 9] + Apr_[ 3] * Bpr_[13]; + Cpr_[5] = Apr_[ 4] * Bpr_[1] + Apr_[ 5] * Bpr_[5] + Apr_[ 6] * Bpr_[ 9] + Apr_[ 7] * Bpr_[13]; + Cpr_[6] = Apr_[ 8] * Bpr_[1] + Apr_[ 9] * Bpr_[5] + Apr_[10] * Bpr_[ 9] + Apr_[11] * Bpr_[13]; + Cpr_[7] = Apr_[12] * Bpr_[1] + Apr_[13] * Bpr_[5] + Apr_[14] * Bpr_[ 9] + Apr_[15] * Bpr_[13]; + Cpr_[8] = Apr_[ 0] * Bpr_[2] + Apr_[ 1] * Bpr_[6] + Apr_[ 2] * Bpr_[10] + Apr_[ 3] * Bpr_[14]; + Cpr_[9] = Apr_[ 4] * Bpr_[2] + Apr_[ 5] * Bpr_[6] + Apr_[ 6] * Bpr_[10] + Apr_[ 7] * Bpr_[14]; + Cpr_[10]= Apr_[ 8] * Bpr_[2] + Apr_[ 9] * Bpr_[6] + Apr_[10] * Bpr_[10] + Apr_[11] * Bpr_[14]; + Cpr_[11]= Apr_[12] * Bpr_[2] + Apr_[13] * Bpr_[6] + Apr_[14] * Bpr_[10] + Apr_[15] * Bpr_[14]; + Cpr_[12]= Apr_[ 0] * Bpr_[3] + Apr_[ 1] * Bpr_[7] + Apr_[ 2] * Bpr_[11] + Apr_[ 3] * Bpr_[15]; + Cpr_[13]= Apr_[ 4] * Bpr_[3] + Apr_[ 5] * Bpr_[7] + Apr_[ 6] * Bpr_[11] + Apr_[ 7] * Bpr_[15]; + Cpr_[14]= Apr_[ 8] * Bpr_[3] + Apr_[ 9] * Bpr_[7] + Apr_[10] * Bpr_[11] + Apr_[11] * Bpr_[15]; + Cpr_[15]= Apr_[12] * Bpr_[3] + Apr_[13] * Bpr_[7] + Apr_[14] * Bpr_[11] + Apr_[15] * Bpr_[15]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[ 0] * Bpr_[ 0] + Apr_[ 1] * Bpr_[ 1] + Apr_[ 2] * Bpr_[ 2] + Apr_[ 3] * Bpr_[ 3]; + Cpr_[1] = Apr_[ 4] * Bpr_[ 0] + Apr_[ 5] * Bpr_[ 1] + Apr_[ 6] * Bpr_[ 2] + Apr_[ 7] * Bpr_[ 3]; + Cpr_[2] = Apr_[ 8] * Bpr_[ 0] + Apr_[ 9] * Bpr_[ 1] + Apr_[10] * Bpr_[ 2] + Apr_[11] * Bpr_[ 3]; + Cpr_[3] = Apr_[12] * Bpr_[ 0] + Apr_[13] * Bpr_[ 1] + Apr_[14] * Bpr_[ 2] + Apr_[15] * Bpr_[ 3]; + Cpr_[4] = Apr_[ 0] * Bpr_[ 4] + Apr_[ 1] * Bpr_[ 5] + Apr_[ 2] * Bpr_[ 6] + Apr_[ 3] * Bpr_[ 7]; + Cpr_[5] = Apr_[ 4] * Bpr_[ 4] + Apr_[ 5] * Bpr_[ 5] + Apr_[ 6] * Bpr_[ 6] + Apr_[ 7] * Bpr_[ 7]; + Cpr_[6] = Apr_[ 8] * Bpr_[ 4] + Apr_[ 9] * Bpr_[ 5] + Apr_[10] * Bpr_[ 6] + Apr_[11] * Bpr_[ 7]; + Cpr_[7] = Apr_[12] * Bpr_[ 4] + Apr_[13] * Bpr_[ 5] + Apr_[14] * Bpr_[ 6] + Apr_[15] * Bpr_[ 7]; + Cpr_[8] = Apr_[ 0] * Bpr_[ 8] + Apr_[ 1] * Bpr_[ 9] + Apr_[ 2] * Bpr_[10] + Apr_[ 3] * Bpr_[11]; + Cpr_[9] = Apr_[ 4] * Bpr_[ 8] + Apr_[ 5] * Bpr_[ 9] + Apr_[ 6] * Bpr_[10] + Apr_[ 7] * Bpr_[11]; + Cpr_[10]= Apr_[ 8] * Bpr_[ 8] + Apr_[ 9] * Bpr_[ 9] + Apr_[10] * Bpr_[10] + Apr_[11] * Bpr_[11]; + Cpr_[11]= Apr_[12] * Bpr_[ 8] + Apr_[13] * Bpr_[ 9] + Apr_[14] * Bpr_[10] + Apr_[15] * Bpr_[11]; + Cpr_[12]= Apr_[ 0] * Bpr_[12] + Apr_[ 1] * Bpr_[13] + Apr_[ 2] * Bpr_[14] + Apr_[ 3] * Bpr_[15]; + Cpr_[13]= Apr_[ 4] * Bpr_[12] + Apr_[ 5] * Bpr_[13] + Apr_[ 6] * Bpr_[14] + Apr_[ 7] * Bpr_[15]; + Cpr_[14]= Apr_[ 8] * Bpr_[12] + Apr_[ 9] * Bpr_[13] + Apr_[10] * Bpr_[14] + Apr_[11] * Bpr_[15]; + Cpr_[15]= Apr_[12] * Bpr_[12] + Apr_[13] * Bpr_[13] + Apr_[14] * Bpr_[14] + Apr_[15] * Bpr_[15]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } else { + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[4] * Bpr_[4] + Apr_[8] * Bpr_[8] + Apr_[12]* Bpr_[12]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[5] * Bpr_[4] + Apr_[9] * Bpr_[8] + Apr_[13]* Bpr_[12]; + Cpr_[2] = Apr_[2] * Bpr_[0] + Apr_[6] * Bpr_[4] + Apr_[10]* Bpr_[8] + Apr_[14]* Bpr_[12]; + Cpr_[3] = Apr_[3] * Bpr_[0] + Apr_[7] * Bpr_[4] + Apr_[11]* Bpr_[8] + Apr_[15]* Bpr_[12]; + Cpr_[4] = Apr_[0] * Bpr_[1] + Apr_[4] * Bpr_[5] + Apr_[8] * Bpr_[9] + Apr_[12]* Bpr_[13]; + Cpr_[5] = Apr_[1] * Bpr_[1] + Apr_[5] * Bpr_[5] + Apr_[9] * Bpr_[9] + Apr_[13]* Bpr_[13]; + Cpr_[6] = Apr_[2] * Bpr_[1] + Apr_[6] * Bpr_[5] + Apr_[10]* Bpr_[9] + Apr_[14]* Bpr_[13]; + Cpr_[7] = Apr_[3] * Bpr_[1] + Apr_[7] * Bpr_[5] + Apr_[11]* Bpr_[9] + Apr_[15]* Bpr_[13]; + Cpr_[8] = Apr_[0] * Bpr_[2] + Apr_[4] * Bpr_[6] + Apr_[8] * Bpr_[10]+ Apr_[12]* Bpr_[14]; + Cpr_[9] = Apr_[1] * Bpr_[2] + Apr_[5] * Bpr_[6] + Apr_[9] * Bpr_[10]+ Apr_[13]* Bpr_[14]; + Cpr_[10]= Apr_[2] * Bpr_[2] + Apr_[6] * Bpr_[6] + Apr_[10]* Bpr_[10]+ Apr_[14]* Bpr_[14]; + Cpr_[11]= Apr_[3] * Bpr_[2] + Apr_[7] * Bpr_[6] + Apr_[11]* Bpr_[10]+ Apr_[15]* Bpr_[14]; + Cpr_[12]= Apr_[0] * Bpr_[3] + Apr_[4] * Bpr_[7] + Apr_[8] * Bpr_[11]+ Apr_[12]* Bpr_[15]; + Cpr_[13]= Apr_[1] * Bpr_[3] + Apr_[5] * Bpr_[7] + Apr_[9] * Bpr_[11]+ Apr_[13]* Bpr_[15]; + Cpr_[14]= Apr_[2] * Bpr_[3] + Apr_[6] * Bpr_[7] + Apr_[10]* Bpr_[11]+ Apr_[14]* Bpr_[15]; + Cpr_[15]= Apr_[3] * Bpr_[3] + Apr_[7] * Bpr_[7] + Apr_[11]* Bpr_[11]+ Apr_[15]* Bpr_[15]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[4] * Bpr_[1] + Apr_[8] * Bpr_[2] + Apr_[12]* Bpr_[3]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[5] * Bpr_[1] + Apr_[9] * Bpr_[2] + Apr_[13]* Bpr_[3]; + Cpr_[2] = Apr_[2] * Bpr_[0] + Apr_[6] * Bpr_[1] + Apr_[10]* Bpr_[2] + Apr_[14]* Bpr_[3]; + Cpr_[3] = Apr_[3] * Bpr_[0] + Apr_[7] * Bpr_[1] + Apr_[11]* Bpr_[2] + Apr_[15]* Bpr_[3]; + Cpr_[4] = Apr_[0] * Bpr_[4] + Apr_[4] * Bpr_[5] + Apr_[8] * Bpr_[6] + Apr_[12]* Bpr_[7]; + Cpr_[5] = Apr_[1] * Bpr_[4] + Apr_[5] * Bpr_[5] + Apr_[9] * Bpr_[6] + Apr_[13]* Bpr_[7]; + Cpr_[6] = Apr_[2] * Bpr_[4] + Apr_[6] * Bpr_[5] + Apr_[10]* Bpr_[6] + Apr_[14]* Bpr_[7]; + Cpr_[7] = Apr_[3] * Bpr_[4] + Apr_[7] * Bpr_[5] + Apr_[11]* Bpr_[6] + Apr_[15]* Bpr_[7]; + Cpr_[8] = Apr_[0] * Bpr_[8] + Apr_[4] * Bpr_[9] + Apr_[8] * Bpr_[10]+ Apr_[12]* Bpr_[11]; + Cpr_[9] = Apr_[1] * Bpr_[8] + Apr_[5] * Bpr_[9] + Apr_[9] * Bpr_[10]+ Apr_[13]* Bpr_[11]; + Cpr_[10]= Apr_[2] * Bpr_[8] + Apr_[6] * Bpr_[9] + Apr_[10]* Bpr_[10]+ Apr_[14]* Bpr_[11]; + Cpr_[11]= Apr_[3] * Bpr_[8] + Apr_[7] * Bpr_[9] + Apr_[11]* Bpr_[10]+ Apr_[15]* Bpr_[11]; + Cpr_[12]= Apr_[0] * Bpr_[12]+ Apr_[4] * Bpr_[13]+ Apr_[8] * Bpr_[14]+ Apr_[12]* Bpr_[15]; + Cpr_[13]= Apr_[1] * Bpr_[12]+ Apr_[5] * Bpr_[13]+ Apr_[9] * Bpr_[14]+ Apr_[13]* Bpr_[15]; + Cpr_[14]= Apr_[2] * Bpr_[12]+ Apr_[6] * Bpr_[13]+ Apr_[10]* Bpr_[14]+ Apr_[14]* Bpr_[15]; + Cpr_[15]= Apr_[3] * Bpr_[12]+ Apr_[7] * Bpr_[13]+ Apr_[11]* Bpr_[14]+ Apr_[15]* Bpr_[15]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMP inline (4x4)*(4x1) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 4 && k == 4 && l == 4 && n == 1 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transa == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[ 0] * Bpr_[0] + Apr_[ 1] * Bpr_[1] + Apr_[ 2] * Bpr_[2] + Apr_[ 3] * Bpr_[3]; + Cpr_[1] = Apr_[ 4] * Bpr_[0] + Apr_[ 5] * Bpr_[1] + Apr_[ 6] * Bpr_[2] + Apr_[ 7] * Bpr_[3]; + Cpr_[2] = Apr_[ 8] * Bpr_[0] + Apr_[ 9] * Bpr_[1] + Apr_[10] * Bpr_[2] + Apr_[11] * Bpr_[3]; + Cpr_[3] = Apr_[12] * Bpr_[0] + Apr_[13] * Bpr_[1] + Apr_[14] * Bpr_[2] + Apr_[15] * Bpr_[3]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[4] * Bpr_[1] + Apr_[ 8] * Bpr_[2] + Apr_[12] * Bpr_[3]; + Cpr_[1] = Apr_[1] * Bpr_[0] + Apr_[5] * Bpr_[1] + Apr_[ 9] * Bpr_[2] + Apr_[13] * Bpr_[3]; + Cpr_[2] = Apr_[2] * Bpr_[0] + Apr_[6] * Bpr_[1] + Apr_[10] * Bpr_[2] + Apr_[14] * Bpr_[3]; + Cpr_[3] = Apr_[3] * Bpr_[0] + Apr_[7] * Bpr_[1] + Apr_[11] * Bpr_[2] + Apr_[15] * Bpr_[3]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +/*---------------------------------------------------------------------------- + * Check to see if we can do a fast OpenMp inline (1x4)*(4x4) nD multiply + *---------------------------------------------------------------------------- */ + + if( (mtimesx_mode == MTIMESX_LOOPS_OMP || mtimesx_mode == MTIMESX_SPEED_OMP) && max_threads > 1 && + m == 1 && k == 4 && n == 4 && p >= OMP_SPECIAL_SMALL && !singleton_expansion && !Cpi ) { + if( debug_message ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS (unrolled into inline multiplies)\n"); + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + Asize *= (Andim > 2); + Bsize *= (Bndim > 2); + omp_set_dynamic(1); +#pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Bpr_, *Cpr_; + mwSize ip_, p_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + Apr_ = Apr + offset * Asize; + Bpr_ = Bpr + offset * Bsize; + Cpr_ = Cpr + offset * Csize; + if( transb == 'T' ) { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[0] + Apr_[1] * Bpr_[4] + Apr_[2] * Bpr_[ 8] + Apr_[3] * Bpr_[12]; + Cpr_[1] = Apr_[0] * Bpr_[1] + Apr_[1] * Bpr_[5] + Apr_[2] * Bpr_[ 9] + Apr_[3] * Bpr_[13]; + Cpr_[2] = Apr_[0] * Bpr_[2] + Apr_[1] * Bpr_[6] + Apr_[2] * Bpr_[10] + Apr_[3] * Bpr_[14]; + Cpr_[3] = Apr_[0] * Bpr_[3] + Apr_[1] * Bpr_[7] + Apr_[2] * Bpr_[11] + Apr_[3] * Bpr_[15]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } else { + for( ip_=0; ip_<p_; ip_++ ) { + Cpr_[0] = Apr_[0] * Bpr_[ 0] + Apr_[1] * Bpr_[ 1] + Apr_[2] * Bpr_[ 2] + Apr_[3] * Bpr_[ 3]; + Cpr_[1] = Apr_[0] * Bpr_[ 4] + Apr_[1] * Bpr_[ 5] + Apr_[2] * Bpr_[ 6] + Apr_[3] * Bpr_[ 7]; + Cpr_[2] = Apr_[0] * Bpr_[ 8] + Apr_[1] * Bpr_[ 9] + Apr_[2] * Bpr_[10] + Apr_[3] * Bpr_[11]; + Cpr_[3] = Apr_[0] * Bpr_[12] + Apr_[1] * Bpr_[13] + Apr_[2] * Bpr_[14] + Apr_[3] * Bpr_[15]; + Apr_ += Asize; + Bpr_ += Bsize; + Cpr_ += Csize; + } + } + } + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); +/* + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } +*/ + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + } + +#endif + +/*---------------------------------------------------------------------------- + * Get dot product method to use. + *---------------------------------------------------------------------------- */ + + if( mtimesx_mode == MTIMESX_BLAS || mtimesx_mode == MTIMESX_MATLAB ) { + dot_method = METHOD_BLAS; + } else if( mtimesx_mode == MTIMESX_LOOPS ) { + dot_method = METHOD_LOOPS; + } else if( mtimesx_mode == MTIMESX_LOOPS_OMP ) { + dot_method = METHOD_LOOPS_OMP; + } else { +#if !defined(_MSC_VER) || _MSC_VER < 1500 /* Version 2008, 9.0 */ + if( (Apr != Bpr) && !Api && !Bpi ) { + dot_method = METHOD_BLAS; + } else if( mtimesx_mode == MTIMESX_SPEED_OMP && max_threads > 1 ) { +#else + if( mtimesx_mode == MTIMESX_SPEED_OMP && max_threads > 1 ) { +#endif + if( Apr != Bpr ) { + if( Api && Bpi ) { + dot_method = METHOD_LOOPS_OMP; + } else { + dot_method = METHOD_LOOPS; + } + } else { + if( Api && (ai * bi == -one) ) { + dot_method = METHOD_BLAS; + } else { + dot_method = METHOD_LOOPS_OMP; + } + } + } else { +#ifdef __LCC__ + if( (Apr == Bpr && (!Api || (ai * bi == -one))) || omp_get_num_procs() > 2 ) { + dot_method = METHOD_BLAS; + } else { + dot_method = METHOD_LOOPS; + } +#else + if( Apr == Bpr && (!Api || (ai * bi == -one)) ) { + dot_method = METHOD_BLAS; + } else { + dot_method = METHOD_LOOPS; + } +#endif + } + } + +/*---------------------------------------------------------------------------- + * Get outer product method to use. + *---------------------------------------------------------------------------- */ + + switch( mtimesx_mode ) + { + case MTIMESX_BLAS: + outer_method = METHOD_BLAS; + break; + case MTIMESX_LOOPS: + outer_method = METHOD_LOOPS; + break; + case MTIMESX_LOOPS_OMP: + outer_method = METHOD_LOOPS_OMP; + break; + case MTIMESX_SPEED_OMP: + if( max_threads > 1 ) { + outer_method = METHOD_LOOPS_OMP; + break; + } + case MTIMESX_MATLAB: + case MTIMESX_SPEED: +#ifdef __LCC__ + if( Api && Bpi && omp_get_num_procs() <= 2 ) { +#else + if( (Apr == Bpr) || (Api && Bpi) ) { +#endif + outer_method = METHOD_LOOPS; + } else { + outer_method = METHOD_BLAS; + } + break; + } + +/*---------------------------------------------------------------------------- + * Get scalar product method to use. + *---------------------------------------------------------------------------- */ + + switch( mtimesx_mode ) + { + case MTIMESX_BLAS: + scalar_method = METHOD_BLAS; + break; + case MTIMESX_LOOPS: + scalar_method = METHOD_LOOPS; + break; + case MTIMESX_LOOPS_OMP: + scalar_method = METHOD_LOOPS_OMP; + break; + case MTIMESX_SPEED_OMP: + if( max_threads > 1 ) { + scalar_method = METHOD_LOOPS_OMP; + break; + } + case MTIMESX_MATLAB: + case MTIMESX_SPEED: + if( ai != zero && Bpi ) { + scalar_method = METHOD_LOOPS; + } else { + scalar_method = METHOD_BLAS; + } + break; + } + +/*---------------------------------------------------------------------------- + * Outer Loop to process all of the individual matrix multiplies + *---------------------------------------------------------------------------- */ + + if( debug ) { + mexPrintf("MTIMESX: Performing %d individual multiplies\n",p); + } + + for( ip=0; ip<p; ip++ ) { + ptransa = transa; /* Restore the original transa and transb, because */ + ptransb = transb; /* they might have been changed in previous iteration */ + if( debug_message ) { + mexPrintf("MTIMESX: (%d x %d) * (%d x %d)\n",m,k,l,n); + } + +/*---------------------------------------------------------------------------- + * Scalar product (1 x 1) * (K x N) + *---------------------------------------------------------------------------- */ + + if( scalarmultiply == 1 ) { + sr = *Apr; + si = Api ? (transa=='N'||transa=='T'?*Api:-*Api) : zero; + RealTimesScalar(Cpr, Cpi, Bpr, Bpi, transb, m2, n2, sr, si, Bsize, 1, scalar_method); + +/*---------------------------------------------------------------------------- + * Scalar product (M x K) * (1 x 1) + *---------------------------------------------------------------------------- */ + + } else if( scalarmultiply == 2 ) { + sr = *Bpr; + si = Bpi ? (transb=='N'||transb=='T'?*Bpi:-*Bpi) : zero; + RealTimesScalar(Cpr, Cpi, Apr, Api, transa, m1, n1, sr, si, Asize, 1, scalar_method); + +/*--------------------------------------------------------------------------------- + * Small matrix times small matrix (M x K) * (K x N) use inline code. Only use this + * method if running in the 'SPEED' mode and M, K, N are all <= 4. + *--------------------------------------------------------------------------------- */ + + } else if( mtimesx_mode != MTIMESX_BLAS && mtimesx_mode != MTIMESX_MATLAB && m <= 4 && k <= 4 && n <= 4 ) { + if( debug_message ) { + mexPrintf("MTIMESX: LOOPS (unrolled into inline switch statements)\n"); + } + /* Form B elements, taking size and transb into account */ + switch( k ) { + + case 1: /* (m x 1)*(1 x n) */ + switch( n ) { + case 1: + mexErrMsgTxt("Internal Error (m x 1)*(1 x 1), contact author."); + break; + + case 2: /* (m x 1)*(1 x 2) */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; + if( Bpi ) { + if( transb == 'N' || transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; + } else { /* transb == 'G' || transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; + } + } + break; + case 3: /* (m x 1)*(1 x 3) */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; Bpr13 = Bpr[2]; + if( Bpi ) { + if( transb == 'N' || transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; Bpi13 = Bpi[2]; + } else { /* transb == 'G' || transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; Bpi13 =-Bpi[2]; + } + } + break; + case 4: /* (m x 1)*(1 x 4) */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; Bpr13 = Bpr[2]; Bpr14 = Bpr[3]; + if( Bpi ) { + if( transb == 'N' || transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; Bpi13 = Bpi[2]; Bpi14 = Bpi[3]; + } else { /* transb == 'G' || transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; Bpi13 =-Bpi[2]; Bpi14 =-Bpi[3]; + } + } + break; + } + break; + + case 2: /* (m x 2)*(2 x n) */ + switch( n ) { + case 1: /* (m x 2)*(2 x 1) */ + Bpr11 = Bpr[0]; + Bpr21 = Bpr[1]; + if( Bpi ) { + if( transb == 'N' || transb == 'T' ) { + Bpi11 = Bpi[0]; + Bpi21 = Bpi[1]; + } else { /* transb == 'G' || transb == 'C' */ + Bpi11 =-Bpi[0]; + Bpi21 =-Bpi[1]; + } + } + break; + case 2: /* (m x 2)*(2 x 2) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[2]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[3]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; + Bpr21 = Bpr[2]; Bpr22 = Bpr[3]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[2]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[3]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[2]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[3]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; + Bpi21 = Bpi[2]; Bpi22 = Bpi[3]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; + Bpi21 =-Bpi[2]; Bpi22 =-Bpi[3]; + } + } + break; + case 3: /* (m x 2)*(2 x 3) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[2]; Bpr13 = Bpr[4]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[3]; Bpr23 = Bpr[5]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; Bpr13 = Bpr[2]; + Bpr21 = Bpr[3]; Bpr22 = Bpr[4]; Bpr23 = Bpr[5]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[2]; Bpi13 = Bpi[4]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[3]; Bpi23 = Bpi[5]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[2]; Bpi13 =-Bpi[4]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[3]; Bpi23 =-Bpi[5]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; Bpi13 = Bpi[2]; + Bpi21 = Bpi[3]; Bpi22 = Bpi[4]; Bpi23 = Bpi[5]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; Bpi13 =-Bpi[2]; + Bpi21 =-Bpi[3]; Bpi22 =-Bpi[4]; Bpi23 =-Bpi[5]; + } + } + break; + case 4: /* (m x 2)*(2 x 4) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[2]; Bpr13 = Bpr[4]; Bpr14 = Bpr[6]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[3]; Bpr23 = Bpr[5]; Bpr24 = Bpr[7]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; Bpr13 = Bpr[2]; Bpr14 = Bpr[3]; + Bpr21 = Bpr[4]; Bpr22 = Bpr[5]; Bpr23 = Bpr[6]; Bpr24 = Bpr[7]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[2]; Bpi13 = Bpi[4]; Bpi14 = Bpi[6]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[3]; Bpi23 = Bpi[5]; Bpi24 = Bpi[7]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[2]; Bpi13 =-Bpi[4]; Bpi14 =-Bpi[6]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[3]; Bpi23 =-Bpi[5]; Bpi24 =-Bpi[7]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; Bpi13 = Bpi[2]; Bpi14 = Bpi[3]; + Bpi21 = Bpi[4]; Bpi22 = Bpi[5]; Bpi23 = Bpi[6]; Bpi24 = Bpi[7]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; Bpi13 =-Bpi[2]; Bpi14 =-Bpi[3]; + Bpi21 =-Bpi[4]; Bpi22 =-Bpi[5]; Bpi23 =-Bpi[6]; Bpi24 =-Bpi[7]; + } + } + break; + } + break; + + case 3: /* (m x 3)*(3 x n) */ + switch( n ) { + case 1: /* (m x 3)*(3 x 1) */ + Bpr11 = Bpr[0]; + Bpr21 = Bpr[1]; + Bpr31 = Bpr[2]; + if( Bpi ) { + if( transb == 'N' || transb == 'T' ) { + Bpi11 = Bpi[0]; + Bpi21 = Bpi[1]; + Bpi31 = Bpi[2]; + } else { /* transb == 'G' || transb == 'C' */ + Bpi11 =-Bpi[0]; + Bpi21 =-Bpi[1]; + Bpi31 =-Bpi[2]; + } + } + break; + case 2: /* (m x 3)*(3 x 2) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[3]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[4]; + Bpr31 = Bpr[2]; Bpr32 = Bpr[5]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; + Bpr21 = Bpr[2]; Bpr22 = Bpr[3]; + Bpr31 = Bpr[4]; Bpr32 = Bpr[5]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[3]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[4]; + Bpi31 = Bpi[2]; Bpi32 = Bpi[5]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[3]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[4]; + Bpi31 =-Bpi[2]; Bpi32 =-Bpi[5]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; + Bpi21 = Bpi[2]; Bpi22 = Bpi[3]; + Bpi31 = Bpi[4]; Bpi32 = Bpi[5]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; + Bpi21 =-Bpi[2]; Bpi22 =-Bpi[3]; + Bpi31 =-Bpi[4]; Bpi32 =-Bpi[5]; + } + } + break; + case 3: /* (m x 3)*(3 x 3) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[3]; Bpr13 = Bpr[6]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[4]; Bpr23 = Bpr[7]; + Bpr31 = Bpr[2]; Bpr32 = Bpr[5]; Bpr33 = Bpr[8]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; Bpr13 = Bpr[2]; + Bpr21 = Bpr[3]; Bpr22 = Bpr[4]; Bpr23 = Bpr[5]; + Bpr31 = Bpr[6]; Bpr32 = Bpr[7]; Bpr33 = Bpr[8]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[3]; Bpi13 = Bpi[6]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[4]; Bpi23 = Bpi[7]; + Bpi31 = Bpi[2]; Bpi32 = Bpi[5]; Bpi33 = Bpi[8]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[3]; Bpi13 =-Bpi[6]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[4]; Bpi23 =-Bpi[7]; + Bpi31 =-Bpi[2]; Bpi32 =-Bpi[5]; Bpi33 =-Bpi[8]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; Bpi13 = Bpi[2]; + Bpi21 = Bpi[3]; Bpi22 = Bpi[4]; Bpi23 = Bpi[5]; + Bpi31 = Bpi[6]; Bpi32 = Bpi[7]; Bpi33 = Bpi[8]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; Bpi13 =-Bpi[2]; + Bpi21 =-Bpi[3]; Bpi22 =-Bpi[4]; Bpi23 =-Bpi[5]; + Bpi31 =-Bpi[6]; Bpi32 =-Bpi[7]; Bpi33 =-Bpi[8]; + } + } + break; + case 4: /* (m x 3)*(3 x 4) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[3]; Bpr13 = Bpr[6]; Bpr14 = Bpr[9]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[4]; Bpr23 = Bpr[7]; Bpr24 = Bpr[10]; + Bpr31 = Bpr[2]; Bpr32 = Bpr[5]; Bpr33 = Bpr[8]; Bpr34 = Bpr[11]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; Bpr13 = Bpr[2]; Bpr14 = Bpr[3]; + Bpr21 = Bpr[4]; Bpr22 = Bpr[5]; Bpr23 = Bpr[6]; Bpr24 = Bpr[7]; + Bpr31 = Bpr[8]; Bpr32 = Bpr[9]; Bpr33 = Bpr[10];Bpr34 = Bpr[11]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[3]; Bpi13 = Bpi[6]; Bpi14 = Bpi[9]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[4]; Bpi23 = Bpi[7]; Bpi24 = Bpi[10]; + Bpi31 = Bpi[2]; Bpi32 = Bpi[5]; Bpi33 = Bpi[8]; Bpi34 = Bpi[11]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[3]; Bpi13 =-Bpi[6]; Bpi14 =-Bpi[9]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[4]; Bpi23 =-Bpi[7]; Bpi24 =-Bpi[10]; + Bpi31 =-Bpi[2]; Bpi32 =-Bpi[5]; Bpi33 =-Bpi[8]; Bpi34 =-Bpi[11]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; Bpi13 = Bpi[2]; Bpi14 = Bpi[3]; + Bpi21 = Bpi[4]; Bpi22 = Bpi[5]; Bpi23 = Bpi[6]; Bpi24 = Bpi[7]; + Bpi31 = Bpi[8]; Bpi32 = Bpi[9]; Bpi33 = Bpi[10];Bpi34 = Bpi[11]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; Bpi13 =-Bpi[2]; Bpi14 =-Bpi[3]; + Bpi21 =-Bpi[4]; Bpi22 =-Bpi[5]; Bpi23 =-Bpi[6]; Bpi24 =-Bpi[7]; + Bpi31 =-Bpi[8]; Bpi32 =-Bpi[9]; Bpi33 =-Bpi[10];Bpi34 =-Bpi[11]; + } + } + break; + } + break; + + case 4: /* (m x 4)*(4 x n) */ + switch( n ) { + case 1: /* (m x 4)*(4 x 1) */ + Bpr11 = Bpr[0]; + Bpr21 = Bpr[1]; + Bpr31 = Bpr[2]; + Bpr41 = Bpr[3]; + if( Bpi ) { + if( transb == 'N' || transb == 'T' ) { + Bpi11 = Bpi[0]; + Bpi21 = Bpi[1]; + Bpi31 = Bpi[2]; + Bpi41 = Bpi[3]; + } else { /* transb == 'G' || transb == 'C' */ + Bpi11 =-Bpi[0]; + Bpi21 =-Bpi[1]; + Bpi31 =-Bpi[2]; + Bpi41 =-Bpi[3]; + } + } + break; + case 2: /* (m x 4)*(4 x 2) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[4]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[5]; + Bpr31 = Bpr[2]; Bpr32 = Bpr[6]; + Bpr41 = Bpr[3]; Bpr42 = Bpr[7]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; + Bpr21 = Bpr[2]; Bpr22 = Bpr[3]; + Bpr31 = Bpr[4]; Bpr32 = Bpr[5]; + Bpr41 = Bpr[6]; Bpr42 = Bpr[7]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[4]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[5]; + Bpi31 = Bpi[2]; Bpi32 = Bpi[6]; + Bpi41 = Bpi[3]; Bpi42 = Bpi[7]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[4]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[5]; + Bpi31 =-Bpi[2]; Bpi32 =-Bpi[6]; + Bpi41 =-Bpi[3]; Bpi42 =-Bpi[7]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; + Bpi21 = Bpi[2]; Bpi22 = Bpi[3]; + Bpi31 = Bpi[4]; Bpi32 = Bpi[5]; + Bpi41 = Bpi[6]; Bpi42 = Bpi[7]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; + Bpi21 =-Bpi[2]; Bpi22 =-Bpi[3]; + Bpi31 =-Bpi[4]; Bpi32 =-Bpi[5]; + Bpi41 =-Bpi[6]; Bpi42 =-Bpi[7]; + } + } + break; + case 3: /* (m x 4)*(4 x 3) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[4]; Bpr13 = Bpr[8]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[5]; Bpr23 = Bpr[9]; + Bpr31 = Bpr[2]; Bpr32 = Bpr[6]; Bpr33 = Bpr[10]; + Bpr41 = Bpr[3]; Bpr42 = Bpr[7]; Bpr43 = Bpr[11]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; Bpr13 = Bpr[2]; + Bpr21 = Bpr[3]; Bpr22 = Bpr[4]; Bpr23 = Bpr[5]; + Bpr31 = Bpr[6]; Bpr32 = Bpr[7]; Bpr33 = Bpr[8]; + Bpr41 = Bpr[9]; Bpr42 = Bpr[10];Bpr43 = Bpr[11]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[4]; Bpi13 = Bpi[8]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[5]; Bpi23 = Bpi[9]; + Bpi31 = Bpi[2]; Bpi32 = Bpi[6]; Bpi33 = Bpi[10]; + Bpi41 = Bpi[3]; Bpi42 = Bpi[7]; Bpi43 = Bpi[11]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[4]; Bpi13 =-Bpi[8]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[5]; Bpi23 =-Bpi[9]; + Bpi31 =-Bpi[2]; Bpi32 =-Bpi[6]; Bpi33 =-Bpi[10]; + Bpi41 =-Bpi[3]; Bpi42 =-Bpi[7]; Bpi43 =-Bpi[11]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; Bpi13 = Bpi[2]; + Bpi21 = Bpi[3]; Bpi22 = Bpi[4]; Bpi23 = Bpi[5]; + Bpi31 = Bpi[6]; Bpi32 = Bpi[7]; Bpi33 = Bpi[8]; + Bpi41 = Bpi[9]; Bpi42 = Bpi[10];Bpi43 = Bpi[11]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; Bpi13 =-Bpi[2]; + Bpi21 =-Bpi[3]; Bpi22 =-Bpi[4]; Bpi23 =-Bpi[5]; + Bpi31 =-Bpi[6]; Bpi32 =-Bpi[7]; Bpi33 =-Bpi[8]; + Bpi41 =-Bpi[9]; Bpi42 =-Bpi[10];Bpi43 =-Bpi[11]; + } + } + break; + case 4: /* (m x 4)*(4 x 4) */ + if( transb == 'N' || transb == 'G' ) { + Bpr11 = Bpr[0]; Bpr12 = Bpr[4]; Bpr13 = Bpr[8]; Bpr14 = Bpr[12]; + Bpr21 = Bpr[1]; Bpr22 = Bpr[5]; Bpr23 = Bpr[9]; Bpr24 = Bpr[13]; + Bpr31 = Bpr[2]; Bpr32 = Bpr[6]; Bpr33 = Bpr[10];Bpr34 = Bpr[14]; + Bpr41 = Bpr[3]; Bpr42 = Bpr[7]; Bpr43 = Bpr[11];Bpr44 = Bpr[15]; + } else { /* transa == 'T' || transa == 'C' */ + Bpr11 = Bpr[0]; Bpr12 = Bpr[1]; Bpr13 = Bpr[2]; Bpr14 = Bpr[3]; + Bpr21 = Bpr[4]; Bpr22 = Bpr[5]; Bpr23 = Bpr[6]; Bpr24 = Bpr[7]; + Bpr31 = Bpr[8]; Bpr32 = Bpr[9]; Bpr33 = Bpr[10];Bpr34 = Bpr[11]; + Bpr41 = Bpr[12];Bpr42 = Bpr[13];Bpr43 = Bpr[14];Bpr44 = Bpr[15]; + } + if( Bpi ) { + if( transb == 'N' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[4]; Bpi13 = Bpi[8]; Bpi14 = Bpi[12]; + Bpi21 = Bpi[1]; Bpi22 = Bpi[5]; Bpi23 = Bpi[9]; Bpi24 = Bpi[13]; + Bpi31 = Bpi[2]; Bpi32 = Bpi[6]; Bpi33 = Bpi[10];Bpi34 = Bpi[14]; + Bpi41 = Bpi[3]; Bpi42 = Bpi[7]; Bpi43 = Bpi[11];Bpi44 = Bpi[15]; + } else if( transb == 'G' ) { + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[4]; Bpi13 =-Bpi[8]; Bpi14 =-Bpi[12]; + Bpi21 =-Bpi[1]; Bpi22 =-Bpi[5]; Bpi23 =-Bpi[9]; Bpi24 =-Bpi[13]; + Bpi31 =-Bpi[2]; Bpi32 =-Bpi[6]; Bpi33 =-Bpi[10];Bpi34 =-Bpi[14]; + Bpi41 =-Bpi[3]; Bpi42 =-Bpi[7]; Bpi43 =-Bpi[11];Bpi44 =-Bpi[15]; + } else if( transb == 'T' ) { + Bpi11 = Bpi[0]; Bpi12 = Bpi[1]; Bpi13 = Bpi[2]; Bpi14 = Bpi[3]; + Bpi21 = Bpi[4]; Bpi22 = Bpi[5]; Bpi23 = Bpi[6]; Bpi24 = Bpi[7]; + Bpi31 = Bpi[8]; Bpi32 = Bpi[9]; Bpi33 = Bpi[10];Bpi34 = Bpi[11]; + Bpi41 = Bpi[12];Bpi42 = Bpi[13];Bpi43 = Bpi[14];Bpi44 = Bpi[15]; + } else {/* transb == 'C' */ + Bpi11 =-Bpi[0]; Bpi12 =-Bpi[1]; Bpi13 =-Bpi[2]; Bpi14 =-Bpi[3]; + Bpi21 =-Bpi[4]; Bpi22 =-Bpi[5]; Bpi23 =-Bpi[6]; Bpi24 =-Bpi[7]; + Bpi31 =-Bpi[8]; Bpi32 =-Bpi[9]; Bpi33 =-Bpi[10];Bpi34 =-Bpi[11]; + Bpi41 =-Bpi[12];Bpi42 =-Bpi[13];Bpi43 =-Bpi[14];Bpi44 =-Bpi[15]; + } + } + break; + } + break; + } + /* Form A elements and do the multiply */ + switch( m ) { + case 1: /* (1 x k)*(k x n) */ + switch( k ) { + case 1: /* (1 x 1)*(1 x n) */ + mexErrMsgTxt("Internal Error (1 x 1)*(1 x n), contact author."); + break; + + case 2: /* (1 x 2)*(2 x n) */ + Apr11 = Apr[0]; Apr12 = Apr[1]; + if( Api ) { + if( transa == 'N' || transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; + } else { /* transa == 'G' || transa == 'C' */ + Api11 =-Api[0]; Api12 =-Api[1]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[3] = Apr11 * Bpr14 + Apr12 * Bpr24 + - Api11 * Bpi14 - Api12 * Bpi24; + Cpi[3] = Apr11 * Bpi14 + Apr12 * Bpi24 + + Api11 * Bpr14 + Api12 * Bpr24; + case 3: + Cpr[2] = Apr11 * Bpr13 + Apr12 * Bpr23 + - Api11 * Bpi13 - Api12 * Bpi23; + Cpi[2] = Apr11 * Bpi13 + Apr12 * Bpi23 + + Api11 * Bpr13 + Api12 * Bpr23; + case 2: + Cpr[1] = Apr11 * Bpr12 + Apr12 * Bpr22 + - Api11 * Bpi12 - Api12 * Bpi22; + Cpi[1] = Apr11 * Bpi12 + Apr12 * Bpi22 + + Api11 * Bpr12 + Api12 * Bpr22; + case 1: + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + - Api11 * Bpi11 - Api12 * Bpi21; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + + Api11 * Bpr11 + Api12 * Bpr21; + } + } else { + switch( n ) { + case 4: + Cpr[3] = Apr11 * Bpr14 + Apr12 * Bpr24; + case 3: + Cpr[2] = Apr11 * Bpr13 + Apr12 * Bpr23; + case 2: + Cpr[1] = Apr11 * Bpr12 + Apr12 * Bpr22; + case 1: + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[3] = Api11 * Bpr14 + Api12 * Bpr24; + case 3: + Cpi[2] = Api11 * Bpr13 + Api12 * Bpr23; + case 2: + Cpi[1] = Api11 * Bpr12 + Api12 * Bpr22; + case 1: + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[3] = Apr11 * Bpi14 + Apr12 * Bpi24; + case 3: + Cpi[2] = Apr11 * Bpi13 + Apr12 * Bpi23; + case 2: + Cpi[1] = Apr11 * Bpi12 + Apr12 * Bpi22; + case 1: + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21; + } + } + } + break; + + case 3: /* (1 x 3)*(3 x n) */ + Apr11 = Apr[0]; Apr12 = Apr[1]; Apr13 = Apr[2]; + if( Api ) { + if( transa == 'N' || transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; Api13 = Api[2]; + } else { /* transa == 'G' || transa == 'C' */ + Api11 =-Api[0]; Api12 =-Api[1]; Api13 =-Api[2]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[3] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + - Api11 * Bpi14 - Api12 * Bpi24 - Api13 * Bpi34; + Cpi[3] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + + Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34; + case 3: + Cpr[2] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + - Api11 * Bpi13 - Api12 * Bpi23 - Api13 * Bpi33; + Cpi[2] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + + Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33; + case 2: + Cpr[1] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + - Api11 * Bpi12 - Api12 * Bpi22 - Api13 * Bpi32; + Cpi[1] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + + Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32; + case 1: + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + - Api11 * Bpi11 - Api12 * Bpi21 - Api13 * Bpi31; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + + Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31; + } + } else { + switch( n ) { + case 4: + Cpr[3] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34; + case 3: + Cpr[2] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33; + case 2: + Cpr[1] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32; + case 1: + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[3] = Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34; + case 3: + Cpi[2] = Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33; + case 2: + Cpi[1] = Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32; + case 1: + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[3] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34; + case 3: + Cpi[2] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33; + case 2: + Cpi[1] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32; + case 1: + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31; + } + } + } + break; + + case 4: /* (1 x 4)*(4 x n) */ + Apr11 = Apr[0]; Apr12 = Apr[1]; Apr13 = Apr[2]; Apr14 = Apr[3]; + if( Api ) { + if( transa == 'N' || transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; Api13 = Api[2]; Api14 = Api[3]; + } else { /* transa == 'G' || transa == 'C' */ + Api11 =-Api[0]; Api12 =-Api[1]; Api13 =-Api[2]; Api14 =-Api[3]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[3] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + Apr14 * Bpr44 + - Api11 * Bpi14 - Api12 * Bpi24 - Api13 * Bpi34 - Api14 * Bpi44; + Cpi[3] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + Apr14 * Bpi44 + + Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34 + Api14 * Bpr44; + case 3: + Cpr[2] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + Apr14 * Bpr43 + - Api11 * Bpi13 - Api12 * Bpi23 - Api13 * Bpi33 - Api14 * Bpi43; + Cpi[2] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + Apr14 * Bpi43 + + Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33 + Api14 * Bpr43; + case 2: + Cpr[1] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + Apr14 * Bpr42 + - Api11 * Bpi12 - Api12 * Bpi22 - Api13 * Bpi32 - Api14 * Bpi42; + Cpi[1] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + Apr14 * Bpi42 + + Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32 + Api14 * Bpr42; + case 1: + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + Apr14 * Bpr41 + - Api11 * Bpi11 - Api12 * Bpi21 - Api13 * Bpi31 - Api14 * Bpi41; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + Apr14 * Bpi41 + + Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31 + Api14 * Bpr41; + } + } else { + switch( n ) { + case 4: + Cpr[3] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + Apr14 * Bpr44; + case 3: + Cpr[2] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + Apr14 * Bpr43; + case 2: + Cpr[1] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + Apr14 * Bpr42; + case 1: + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + Apr14 * Bpr41; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[3] = Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34 + Api14 * Bpr44; + case 3: + Cpi[2] = Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33 + Api14 * Bpr43; + case 2: + Cpi[1] = Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32 + Api14 * Bpr42; + case 1: + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31 + Api14 * Bpr41; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[3] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + Apr14 * Bpi44; + case 3: + Cpi[2] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + Apr14 * Bpi43; + case 2: + Cpi[1] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + Apr14 * Bpi42; + case 1: + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + Apr14 * Bpi41; + } + } + } + break; + } + break; + + case 2: /* (2 x k)*(k x n) */ + switch( k ) { + case 1: /* (2 x 1)*(1 x n) */ + Apr11 = Apr[0]; + Apr21 = Apr[1]; + if( Api ) { + if( transa == 'N' || transa == 'T' ) { + Api11 = Api[0]; + Api21 = Api[1]; + } else { /* transa == 'G' || transa == 'C' */ + Api11 =-Api[0]; + Api21 =-Api[1]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[7] = Apr21 * Bpr14 + - Api21 * Bpi14; + Cpr[6] = Apr11 * Bpr14 + - Api11 * Bpi14; + Cpi[7] = Apr21 * Bpi14 + + Api21 * Bpr14; + Cpi[6] = Apr11 * Bpi14 + + Api11 * Bpr14; + case 3: + Cpr[5] = Apr21 * Bpr13 + - Api21 * Bpi13; + Cpr[4] = Apr11 * Bpr13 + - Api11 * Bpi13; + Cpi[5] = Apr21 * Bpi13 + + Api21 * Bpr13; + Cpi[4] = Apr11 * Bpi13 + + Api11 * Bpr13; + case 2: + Cpr[3] = Apr21 * Bpr12 + - Api21 * Bpi12; + Cpr[2] = Apr11 * Bpr12 + - Api11 * Bpi12; + Cpi[3] = Apr21 * Bpi12 + + Api21 * Bpr12; + Cpi[2] = Apr11 * Bpi12 + + Api11 * Bpr12; + case 1: + Cpr[1] = Apr21 * Bpr11 + - Api21 * Bpi11; + Cpr[0] = Apr11 * Bpr11 + - Api11 * Bpi11; + Cpi[1] = Apr21 * Bpi11 + + Api21 * Bpr11; + Cpi[0] = Apr11 * Bpi11 + + Api11 * Bpr11; + } + } else { + switch( n ) { + case 4: + Cpr[7] = Apr21 * Bpr14; + Cpr[6] = Apr11 * Bpr14; + case 3: + Cpr[5] = Apr21 * Bpr13; + Cpr[4] = Apr11 * Bpr13; + case 2: + Cpr[3] = Apr21 * Bpr12; + Cpr[2] = Apr11 * Bpr12; + case 1: + Cpr[1] = Apr21 * Bpr11; + Cpr[0] = Apr11 * Bpr11; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[7] = Api21 * Bpr14; + Cpi[6] = Api11 * Bpr14; + case 3: + Cpi[5] = Api21 * Bpr13; + Cpi[4] = Api11 * Bpr13; + case 2: + Cpi[3] = Api21 * Bpr12; + Cpi[2] = Api11 * Bpr12; + case 1: + Cpi[1] = Api21 * Bpr11; + Cpi[0] = Api11 * Bpr11; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[7] = Apr21 * Bpi14; + Cpi[6] = Apr11 * Bpi14; + case 3: + Cpi[5] = Apr21 * Bpi13; + Cpi[4] = Apr11 * Bpi13; + case 2: + Cpi[3] = Apr21 * Bpi12; + Cpi[2] = Apr11 * Bpi12; + case 1: + Cpi[1] = Apr21 * Bpi11; + Cpi[0] = Apr11 * Bpi11; + } + } + } + break; + + case 2: /* (2 x 2)*(2 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[2]; + Apr21 = Apr[1]; Apr22 = Apr[3]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; + Apr21 = Apr[2]; Apr22 = Apr[3]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[2]; + Api21 = Api[1]; Api22 = Api[3]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; + Api21 = Api[2]; Api22 = Api[3]; + } else if( transa == 'C' ) { + Api11 = -Api[0]; Api12 = -Api[1]; + Api21 = -Api[2]; Api22 = -Api[3]; + } else {/* transa == 'G' */ + Api11 = -Api[0]; Api12 = -Api[2]; + Api21 = -Api[1]; Api22 = -Api[3]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[7] = Apr21 * Bpr14 + Apr22 * Bpr24 + - Api21 * Bpi14 - Api22 * Bpi24; + Cpr[6] = Apr11 * Bpr14 + Apr12 * Bpr24 + - Api11 * Bpi14 - Api12 * Bpi24; + Cpi[7] = Apr21 * Bpi14 + Apr22 * Bpi24 + + Api21 * Bpr14 + Api22 * Bpr24; + Cpi[6] = Apr11 * Bpi14 + Apr12 * Bpi24 + + Api11 * Bpr14 + Api12 * Bpr24; + case 3: + Cpr[5] = Apr21 * Bpr13 + Apr22 * Bpr23 + - Api21 * Bpi13 - Api22 * Bpi23; + Cpr[4] = Apr11 * Bpr13 + Apr12 * Bpr23 + - Api11 * Bpi13 - Api12 * Bpi23; + Cpi[5] = Apr21 * Bpi13 + Apr22 * Bpi23 + + Api21 * Bpr13 + Api22 * Bpr23; + Cpi[4] = Apr11 * Bpi13 + Apr12 * Bpi23 + + Api11 * Bpr13 + Api12 * Bpr23; + case 2: + Cpr[3] = Apr21 * Bpr12 + Apr22 * Bpr22 + - Api21 * Bpi12 - Api22 * Bpi22; + Cpr[2] = Apr11 * Bpr12 + Apr12 * Bpr22 + - Api11 * Bpi12 - Api12 * Bpi22; + Cpi[3] = Apr21 * Bpi12 + Apr22 * Bpi22 + + Api21 * Bpr12 + Api22 * Bpr22; + Cpi[2] = Apr11 * Bpi12 + Apr12 * Bpi22 + + Api11 * Bpr12 + Api12 * Bpr22; + case 1: + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + - Api21 * Bpi11 - Api22 * Bpi21; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + - Api11 * Bpi11 - Api12 * Bpi21; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + + Api21 * Bpr11 + Api22 * Bpr21; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + + Api11 * Bpr11 + Api12 * Bpr21; + } + } else { + switch( n ) { + case 4: + Cpr[7] = Apr21 * Bpr14 + Apr22 * Bpr24; + Cpr[6] = Apr11 * Bpr14 + Apr12 * Bpr24; + case 3: + Cpr[5] = Apr21 * Bpr13 + Apr22 * Bpr23; + Cpr[4] = Apr11 * Bpr13 + Apr12 * Bpr23; + case 2: + Cpr[3] = Apr21 * Bpr12 + Apr22 * Bpr22; + Cpr[2] = Apr11 * Bpr12 + Apr12 * Bpr22; + case 1: + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[7] = Api21 * Bpr14 + Api22 * Bpr24; + Cpi[6] = Api11 * Bpr14 + Api12 * Bpr24; + case 3: + Cpi[5] = Api21 * Bpr13 + Api22 * Bpr23; + Cpi[4] = Api11 * Bpr13 + Api12 * Bpr23; + case 2: + Cpi[3] = Api21 * Bpr12 + Api22 * Bpr22; + Cpi[2] = Api11 * Bpr12 + Api12 * Bpr22; + case 1: + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[7] = Apr21 * Bpi14 + Apr22 * Bpi24; + Cpi[6] = Apr11 * Bpi14 + Apr12 * Bpi24; + case 3: + Cpi[5] = Apr21 * Bpi13 + Apr22 * Bpi23; + Cpi[4] = Apr11 * Bpi13 + Apr12 * Bpi23; + case 2: + Cpi[3] = Apr21 * Bpi12 + Apr22 * Bpi22; + Cpi[2] = Apr11 * Bpi12 + Apr12 * Bpi22; + case 1: + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21; + } + } + } + break; + + case 3: /* (2 x 3)*(3 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[2]; Apr13 = Apr[4]; + Apr21 = Apr[1]; Apr22 = Apr[3]; Apr23 = Apr[5]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; Apr13 = Apr[2]; + Apr21 = Apr[3]; Apr22 = Apr[4]; Apr23 = Apr[5]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[2]; Api13 = Api[4]; + Api21 = Api[1]; Api22 = Api[3]; Api23 = Api[5]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; Api13 = Api[2]; + Api21 = Api[3]; Api22 = Api[4]; Api23 = Api[5]; + } else if( transa == 'C' ) { + Api11 =-Api[0]; Api12 =-Api[1]; Api13 =-Api[2]; + Api21 =-Api[3]; Api22 =-Api[4]; Api23 =-Api[5]; + } else {/* transa == 'G' */ + Api11 =-Api[0]; Api12 =-Api[2]; Api13 =-Api[4]; + Api21 =-Api[1]; Api22 =-Api[3]; Api23 =-Api[5]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[7] = Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + - Api21 * Bpi14 - Api22 * Bpi24 - Api23 * Bpi34; + Cpr[6] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + - Api11 * Bpi14 - Api12 * Bpi24 - Api13 * Bpi34; + Cpi[7] = Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + + Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34; + Cpi[6] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + + Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34; + case 3: + Cpr[5] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + - Api21 * Bpi13 - Api22 * Bpi23 - Api23 * Bpi33; + Cpr[4] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + - Api11 * Bpi13 - Api12 * Bpi23 - Api13 * Bpi33; + Cpi[5] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + + Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33; + Cpi[4] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + + Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33; + case 2: + Cpr[3] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + - Api21 * Bpi12 - Api22 * Bpi22 - Api23 * Bpi32; + Cpr[2] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + - Api11 * Bpi12 - Api12 * Bpi22 - Api13 * Bpi32; + Cpi[3] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + + Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32; + Cpi[2] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + + Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32; + case 1: + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + - Api21 * Bpi11 - Api22 * Bpi21 - Api23 * Bpi31; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + - Api11 * Bpi11 - Api12 * Bpi21 - Api13 * Bpi31; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + + Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + + Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31; + } + } else { + switch( n ) { + case 4: + Cpr[7] = Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34; + Cpr[6] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34; + case 3: + Cpr[5] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33; + Cpr[4] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33; + case 2: + Cpr[3] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32; + Cpr[2] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32; + case 1: + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[7] = Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34; + Cpi[6] = Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34; + case 3: + Cpi[5] = Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33; + Cpi[4] = Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33; + case 2: + Cpi[3] = Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32; + Cpi[2] = Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32; + case 1: + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[7] = Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34; + Cpi[6] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34; + case 3: + Cpi[5] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33; + Cpi[4] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33; + case 2: + Cpi[3] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32; + Cpi[2] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32; + case 1: + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31; + } + } + } + break; + + case 4: /* (2 x 4)*(4 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[2]; Apr13 = Apr[4]; Apr14 = Apr[6]; + Apr21 = Apr[1]; Apr22 = Apr[3]; Apr23 = Apr[5]; Apr24 = Apr[7]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; Apr13 = Apr[2]; Apr14 = Apr[3]; + Apr21 = Apr[4]; Apr22 = Apr[5]; Apr23 = Apr[6]; Apr24 = Apr[7]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[2]; Api13 = Api[4]; Api14 = Api[6]; + Api21 = Api[1]; Api22 = Api[3]; Api23 = Api[5]; Api24 = Api[7]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; Api13 = Api[2]; Api14 = Api[3]; + Api21 = Api[4]; Api22 = Api[5]; Api23 = Api[6]; Api24 = Api[7]; + } else if( transa == 'G' ) { + Api11 =-Api[0]; Api12 =-Api[2]; Api13 =-Api[4]; Api14 =-Api[6]; + Api21 =-Api[1]; Api22 =-Api[3]; Api23 =-Api[5]; Api24 =-Api[7]; + } else { /* transa == 'C' */ + Api11 =-Api[0]; Api12 =-Api[1]; Api13 =-Api[2]; Api14 =-Api[3]; + Api21 =-Api[4]; Api22 =-Api[5]; Api23 =-Api[6]; Api24 =-Api[7]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[7] = Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + Apr24 * Bpr44 + - Api21 * Bpi14 - Api22 * Bpi24 - Api23 * Bpi34 - Api24 * Bpi44; + Cpr[6] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + Apr14 * Bpr44 + - Api11 * Bpi14 - Api12 * Bpi24 - Api13 * Bpi34 - Api14 * Bpi44; + Cpi[7] = Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + Apr24 * Bpi44 + + Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34 + Api24 * Bpr44; + Cpi[6] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + Apr14 * Bpi44 + + Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34 + Api14 * Bpr44; + case 3: + Cpr[5] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + Apr24 * Bpr43 + - Api21 * Bpi13 - Api22 * Bpi23 - Api23 * Bpi33 - Api24 * Bpi43; + Cpr[4] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + Apr14 * Bpr43 + - Api11 * Bpi13 - Api12 * Bpi23 - Api13 * Bpi33 - Api14 * Bpi43; + Cpi[5] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + Apr24 * Bpi43 + + Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33 + Api24 * Bpr43; + Cpi[4] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + Apr14 * Bpi43 + + Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33 + Api14 * Bpr43; + case 2: + Cpr[3] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + Apr24 * Bpr42 + - Api21 * Bpi12 - Api22 * Bpi22 - Api23 * Bpi32 - Api24 * Bpi42; + Cpr[2] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + Apr14 * Bpr42 + - Api11 * Bpi12 - Api12 * Bpi22 - Api13 * Bpi32 - Api14 * Bpi42; + Cpi[3] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + Apr24 * Bpi42 + + Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32 + Api24 * Bpr42; + Cpi[2] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + Apr14 * Bpi42 + + Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32 + Api14 * Bpr42; + case 1: + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + Apr24 * Bpr41 + - Api21 * Bpi11 - Api22 * Bpi21 - Api23 * Bpi31 - Api24 * Bpi41; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + Apr14 * Bpr41 + - Api11 * Bpi11 - Api12 * Bpi21 - Api13 * Bpi31 - Api14 * Bpi41; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + Apr24 * Bpi41 + + Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31 + Api24 * Bpr41; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + Apr14 * Bpi41 + + Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31 + Api14 * Bpr41; + } + } else { + switch( n ) { + case 4: + Cpr[7] = Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + Apr24 * Bpr44; + Cpr[6] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + Apr14 * Bpr44; + case 3: + Cpr[5] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + Apr24 * Bpr43; + Cpr[4] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + Apr14 * Bpr43; + case 2: + Cpr[3] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + Apr24 * Bpr42; + Cpr[2] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + Apr14 * Bpr42; + case 1: + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + Apr24 * Bpr41; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + Apr14 * Bpr41; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[7] = Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34 + Api24 * Bpr44; + Cpi[6] = Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34 + Api14 * Bpr44; + case 3: + Cpi[5] = Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33 + Api24 * Bpr43; + Cpi[4] = Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33 + Api14 * Bpr43; + case 2: + Cpi[3] = Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32 + Api24 * Bpr42; + Cpi[2] = Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32 + Api14 * Bpr42; + case 1: + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31 + Api24 * Bpr41; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31 + Api14 * Bpr41; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[7] = Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + Apr24 * Bpi44; + Cpi[6] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + Apr14 * Bpi44; + case 3: + Cpi[5] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + Apr24 * Bpi43; + Cpi[4] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + Apr14 * Bpi43; + case 2: + Cpi[3] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + Apr24 * Bpi42; + Cpi[2] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + Apr14 * Bpi42; + case 1: + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + Apr24 * Bpi41; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + Apr14 * Bpi41; + } + } + } + break; + } + break; + + case 3: /* (3 x k)*(k x n) */ + switch( k ) { + case 1: /* (3 x 1)*(1 x n) */ + Apr11 = Apr[0]; + Apr21 = Apr[1]; + Apr31 = Apr[2]; + if( Api ) { + if( transa == 'N' || transa == 'T' ) { + Api11 = Api[0]; + Api21 = Api[1]; + Api31 = Api[2]; + } else { /* transa == 'G' || transa == 'C' */ + Api11 =-Api[0]; + Api21 =-Api[1]; + Api31 =-Api[2]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[11]= Apr31 * Bpr14 + - Api31 * Bpi14; + Cpr[10]= Apr21 * Bpr14 + - Api21 * Bpi14; + Cpr[9] = Apr11 * Bpr14 + - Api11 * Bpi14; + Cpi[11]= Apr31 * Bpi14 + + Api31 * Bpr14; + Cpi[10]= Apr21 * Bpi14 + + Api21 * Bpr14; + Cpi[9] = Apr11 * Bpi14 + + Api11 * Bpr14; + case 3: + Cpr[8] = Apr31 * Bpr13 + - Api31 * Bpi13; + Cpr[7] = Apr21 * Bpr13 + - Api21 * Bpi13; + Cpr[6] = Apr11 * Bpr13 + - Api11 * Bpi13; + Cpi[8] = Apr31 * Bpi13 + + Api31 * Bpr13; + Cpi[7] = Apr21 * Bpi13 + + Api21 * Bpr13; + Cpi[6] = Apr11 * Bpi13 + + Api11 * Bpr13; + case 2: + Cpr[5] = Apr31 * Bpr12 + - Api31 * Bpi12; + Cpr[4] = Apr21 * Bpr12 + - Api21 * Bpi12; + Cpr[3] = Apr11 * Bpr12 + - Api11 * Bpi12; + Cpi[5] = Apr31 * Bpi12 + + Api31 * Bpr12; + Cpi[4] = Apr21 * Bpi12 + + Api21 * Bpr12; + Cpi[3] = Apr11 * Bpi12 + + Api11 * Bpr12; + case 1: + Cpr[2] = Apr31 * Bpr11 + - Api31 * Bpi11; + Cpr[1] = Apr21 * Bpr11 + - Api21 * Bpi11; + Cpr[0] = Apr11 * Bpr11 + - Api11 * Bpi11; + Cpi[2] = Apr31 * Bpi11 + + Api31 * Bpr11; + Cpi[1] = Apr21 * Bpi11 + + Api21 * Bpr11; + Cpi[0] = Apr11 * Bpi11 + + Api11 * Bpr11; + } + } else { + switch( n ) { + case 4: + Cpr[11]= Apr31 * Bpr14; + Cpr[10]= Apr21 * Bpr14; + Cpr[9] = Apr11 * Bpr14; + case 3: + Cpr[8] = Apr31 * Bpr13; + Cpr[7] = Apr21 * Bpr13; + Cpr[6] = Apr11 * Bpr13; + case 2: + Cpr[5] = Apr31 * Bpr12; + Cpr[4] = Apr21 * Bpr12; + Cpr[3] = Apr11 * Bpr12; + case 1: + Cpr[2] = Apr31 * Bpr11; + Cpr[1] = Apr21 * Bpr11; + Cpr[0] = Apr11 * Bpr11; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[11]= Api31 * Bpr14; + Cpi[10]= Api21 * Bpr14; + Cpi[9] = Api11 * Bpr14; + case 3: + Cpi[8] = Api31 * Bpr13; + Cpi[7] = Api21 * Bpr13; + Cpi[6] = Api11 * Bpr13; + case 2: + Cpi[5] = Api31 * Bpr12; + Cpi[4] = Api21 * Bpr12; + Cpi[3] = Api11 * Bpr12; + case 1: + Cpi[2] = Api31 * Bpr11; + Cpi[1] = Api21 * Bpr11; + Cpi[0] = Api11 * Bpr11; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[11]= Apr31 * Bpi14; + Cpi[10]= Apr21 * Bpi14; + Cpi[9] = Apr11 * Bpi14; + case 3: + Cpi[8] = Apr31 * Bpi13; + Cpi[7] = Apr21 * Bpi13; + Cpi[6] = Apr11 * Bpi13; + case 2: + Cpi[5] = Apr31 * Bpi12; + Cpi[4] = Apr21 * Bpi12; + Cpi[3] = Apr11 * Bpi12; + case 1: + Cpi[2] = Apr31 * Bpi11; + Cpi[1] = Apr21 * Bpi11; + Cpi[0] = Apr11 * Bpi11; + } + } + } + break; + + case 2: /* (3 x 2)*(2 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[3]; + Apr21 = Apr[1]; Apr22 = Apr[4]; + Apr31 = Apr[2]; Apr32 = Apr[5]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; + Apr21 = Apr[2]; Apr22 = Apr[3]; + Apr31 = Apr[4]; Apr32 = Apr[5]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[3]; + Api21 = Api[1]; Api22 = Api[4]; + Api31 = Api[2]; Api32 = Api[5]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; + Api21 = Api[2]; Api22 = Api[3]; + Api31 = Api[4]; Api32 = Api[5]; + } else if( transa == 'C' ) { + Api11 = -Api[0]; Api12 = -Api[1]; + Api21 = -Api[2]; Api22 = -Api[3]; + Api31 = -Api[4]; Api32 = -Api[5]; + } else {/* transa == 'G' */ + Api11 = -Api[0]; Api12 = -Api[3]; + Api21 = -Api[1]; Api22 = -Api[4]; + Api31 = -Api[2]; Api32 = -Api[5]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[11]= Apr31 * Bpr14 + Apr32 * Bpr24 + - Api31 * Bpi14 - Api32 * Bpi24; + Cpr[10]= Apr21 * Bpr14 + Apr22 * Bpr24 + - Api21 * Bpi14 - Api22 * Bpi24; + Cpr[9] = Apr11 * Bpr14 + Apr12 * Bpr24 + - Api11 * Bpi14 - Api12 * Bpi24; + Cpi[11]= Apr31 * Bpi14 + Apr32 * Bpi24 + + Api31 * Bpr14 + Api32 * Bpr24; + Cpi[10]= Apr21 * Bpi14 + Apr22 * Bpi24 + + Api21 * Bpr14 + Api22 * Bpr24; + Cpi[9] = Apr11 * Bpi14 + Apr12 * Bpi24 + + Api11 * Bpr14 + Api12 * Bpr24; + case 3: + Cpr[8] = Apr31 * Bpr13 + Apr32 * Bpr23 + - Api31 * Bpi13 - Api32 * Bpi23; + Cpr[7] = Apr21 * Bpr13 + Apr22 * Bpr23 + - Api21 * Bpi13 - Api22 * Bpi23; + Cpr[6] = Apr11 * Bpr13 + Apr12 * Bpr23 + - Api11 * Bpi13 - Api12 * Bpi23; + Cpi[8] = Apr31 * Bpi13 + Apr32 * Bpi23 + + Api31 * Bpr13 + Api32 * Bpr23; + Cpi[7] = Apr21 * Bpi13 + Apr22 * Bpi23 + + Api21 * Bpr13 + Api22 * Bpr23; + Cpi[6] = Apr11 * Bpi13 + Apr12 * Bpi23 + + Api11 * Bpr13 + Api12 * Bpr23; + case 2: + Cpr[5] = Apr31 * Bpr12 + Apr32 * Bpr22 + - Api31 * Bpi12 - Api32 * Bpi22; + Cpr[4] = Apr21 * Bpr12 + Apr22 * Bpr22 + - Api21 * Bpi12 - Api22 * Bpi22; + Cpr[3] = Apr11 * Bpr12 + Apr12 * Bpr22 + - Api11 * Bpi12 - Api12 * Bpi22; + Cpi[5] = Apr31 * Bpi12 + Apr32 * Bpi22 + + Api31 * Bpr12 + Api32 * Bpr22; + Cpi[4] = Apr21 * Bpi12 + Apr22 * Bpi22 + + Api21 * Bpr12 + Api22 * Bpr22; + Cpi[3] = Apr11 * Bpi12 + Apr12 * Bpi22 + + Api11 * Bpr12 + Api12 * Bpr22; + case 1: + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + - Api31 * Bpi11 - Api32 * Bpi21; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + - Api21 * Bpi11 - Api22 * Bpi21; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + - Api11 * Bpi11 - Api12 * Bpi21; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + + Api31 * Bpr11 + Api32 * Bpr21; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + + Api21 * Bpr11 + Api22 * Bpr21; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + + Api11 * Bpr11 + Api12 * Bpr21; + } + } else { + switch( n ) { + case 4: + Cpr[11]= Apr31 * Bpr14 + Apr32 * Bpr24; + Cpr[10]= Apr21 * Bpr14 + Apr22 * Bpr24; + Cpr[9] = Apr11 * Bpr14 + Apr12 * Bpr24; + case 3: + Cpr[8] = Apr31 * Bpr13 + Apr32 * Bpr23; + Cpr[7] = Apr21 * Bpr13 + Apr22 * Bpr23; + Cpr[6] = Apr11 * Bpr13 + Apr12 * Bpr23; + case 2: + Cpr[5] = Apr31 * Bpr12 + Apr32 * Bpr22; + Cpr[4] = Apr21 * Bpr12 + Apr22 * Bpr22; + Cpr[3] = Apr11 * Bpr12 + Apr12 * Bpr22; + case 1: + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[11]= Api31 * Bpr14 + Api32 * Bpr24; + Cpi[10]= Api21 * Bpr14 + Api22 * Bpr24; + Cpi[9] = Api11 * Bpr14 + Api12 * Bpr24; + case 3: + Cpi[8] = Api31 * Bpr13 + Api32 * Bpr23; + Cpi[7] = Api21 * Bpr13 + Api22 * Bpr23; + Cpi[6] = Api11 * Bpr13 + Api12 * Bpr23; + case 2: + Cpi[5] = Api31 * Bpr12 + Api32 * Bpr22; + Cpi[4] = Api21 * Bpr12 + Api22 * Bpr22; + Cpi[3] = Api11 * Bpr12 + Api12 * Bpr22; + case 1: + Cpi[2] = Api31 * Bpr11 + Api32 * Bpr21; + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[11]= Apr31 * Bpi14 + Apr32 * Bpi24; + Cpi[10]= Apr21 * Bpi14 + Apr22 * Bpi24; + Cpi[9] = Apr11 * Bpi14 + Apr12 * Bpi24; + case 3: + Cpi[8] = Apr31 * Bpi13 + Apr32 * Bpi23; + Cpi[7] = Apr21 * Bpi13 + Apr22 * Bpi23; + Cpi[6] = Apr11 * Bpi13 + Apr12 * Bpi23; + case 2: + Cpi[5] = Apr31 * Bpi12 + Apr32 * Bpi22; + Cpi[4] = Apr21 * Bpi12 + Apr22 * Bpi22; + Cpi[3] = Apr11 * Bpi12 + Apr12 * Bpi22; + case 1: + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21; + } + } + } + break; + + case 3: /* (3 x 3)*(3 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[3]; Apr13 = Apr[6]; + Apr21 = Apr[1]; Apr22 = Apr[4]; Apr23 = Apr[7]; + Apr31 = Apr[2]; Apr32 = Apr[5]; Apr33 = Apr[8]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; Apr13 = Apr[2]; + Apr21 = Apr[3]; Apr22 = Apr[4]; Apr23 = Apr[5]; + Apr31 = Apr[6]; Apr32 = Apr[7]; Apr33 = Apr[8]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[3]; Api13 = Api[6]; + Api21 = Api[1]; Api22 = Api[4]; Api23 = Api[7]; + Api31 = Api[2]; Api32 = Api[5]; Api33 = Api[8]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; Api13 = Api[2]; + Api21 = Api[3]; Api22 = Api[4]; Api23 = Api[5]; + Api31 = Api[6]; Api32 = Api[7]; Api33 = Api[8]; + } else if( transa == 'C' ) { + Api11 =-Api[0]; Api12 =-Api[1]; Api13 =-Api[2]; + Api21 =-Api[3]; Api22 =-Api[4]; Api23 =-Api[5]; + Api31 =-Api[6]; Api32 =-Api[7]; Api33 =-Api[8]; + } else {/* transa == 'G' */ + Api11 =-Api[0]; Api12 =-Api[3]; Api13 =-Api[6]; + Api21 =-Api[1]; Api22 =-Api[4]; Api23 =-Api[7]; + Api31 =-Api[2]; Api32 =-Api[5]; Api33 =-Api[8]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[11]= Apr31 * Bpr14 + Apr32 * Bpr24 + Apr33 * Bpr34 + - Api31 * Bpi14 - Api32 * Bpi24 - Api33 * Bpi34; + Cpr[10]= Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + - Api21 * Bpi14 - Api22 * Bpi24 - Api23 * Bpi34; + Cpr[9] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + - Api11 * Bpi14 - Api12 * Bpi24 - Api13 * Bpi34; + Cpi[11]= Apr31 * Bpi14 + Apr32 * Bpi24 + Apr33 * Bpi34 + + Api31 * Bpr14 + Api32 * Bpr24 + Api33 * Bpr34; + Cpi[10]= Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + + Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34; + Cpi[9] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + + Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34; + case 3: + Cpr[8] = Apr31 * Bpr13 + Apr32 * Bpr23 + Apr33 * Bpr33 + - Api31 * Bpi13 - Api32 * Bpi23 - Api33 * Bpi33; + Cpr[7] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + - Api21 * Bpi13 - Api22 * Bpi23 - Api23 * Bpi33; + Cpr[6] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + - Api11 * Bpi13 - Api12 * Bpi23 - Api13 * Bpi33; + Cpi[8] = Apr31 * Bpi13 + Apr32 * Bpi23 + Apr33 * Bpi33 + + Api31 * Bpr13 + Api32 * Bpr23 + Api33 * Bpr33; + Cpi[7] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + + Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33; + Cpi[6] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + + Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33; + case 2: + Cpr[5] = Apr31 * Bpr12 + Apr32 * Bpr22 + Apr33 * Bpr32 + - Api31 * Bpi12 - Api32 * Bpi22 - Api33 * Bpi32; + Cpr[4] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + - Api21 * Bpi12 - Api22 * Bpi22 - Api23 * Bpi32; + Cpr[3] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + - Api11 * Bpi12 - Api12 * Bpi22 - Api13 * Bpi32; + Cpi[5] = Apr31 * Bpi12 + Apr32 * Bpi22 + Apr33 * Bpi32 + + Api31 * Bpr12 + Api32 * Bpr22 + Api33 * Bpr32; + Cpi[4] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + + Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32; + Cpi[3] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + + Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32; + case 1: + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + Apr33 * Bpr31 + - Api31 * Bpi11 - Api32 * Bpi21 - Api33 * Bpi31; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + - Api21 * Bpi11 - Api22 * Bpi21 - Api23 * Bpi31; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + - Api11 * Bpi11 - Api12 * Bpi21 - Api13 * Bpi31; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + Apr33 * Bpi31 + + Api31 * Bpr11 + Api32 * Bpr21 + Api33 * Bpr31; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + + Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + + Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31; + } + } else { + switch( n ) { + case 4: + Cpr[11]= Apr31 * Bpr14 + Apr32 * Bpr24 + Apr33 * Bpr34; + Cpr[10]= Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34; + Cpr[9] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34; + case 3: + Cpr[8] = Apr31 * Bpr13 + Apr32 * Bpr23 + Apr33 * Bpr33; + Cpr[7] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33; + Cpr[6] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33; + case 2: + Cpr[5] = Apr31 * Bpr12 + Apr32 * Bpr22 + Apr33 * Bpr32; + Cpr[4] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32; + Cpr[3] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32; + case 1: + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + Apr33 * Bpr31; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[11]= Api31 * Bpr14 + Api32 * Bpr24 + Api33 * Bpr34; + Cpi[10]= Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34; + Cpi[9] = Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34; + case 3: + Cpi[8] = Api31 * Bpr13 + Api32 * Bpr23 + Api33 * Bpr33; + Cpi[7] = Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33; + Cpi[6] = Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33; + case 2: + Cpi[5] = Api31 * Bpr12 + Api32 * Bpr22 + Api33 * Bpr32; + Cpi[4] = Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32; + Cpi[3] = Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32; + case 1: + Cpi[2] = Api31 * Bpr11 + Api32 * Bpr21 + Api33 * Bpr31; + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[11]= Apr31 * Bpi14 + Apr32 * Bpi24 + Apr33 * Bpi34; + Cpi[10]= Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34; + Cpi[9] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34; + case 3: + Cpi[8] = Apr31 * Bpi13 + Apr32 * Bpi23 + Apr33 * Bpi33; + Cpi[7] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33; + Cpi[6] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33; + case 2: + Cpi[5] = Apr31 * Bpi12 + Apr32 * Bpi22 + Apr33 * Bpi32; + Cpi[4] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32; + Cpi[3] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32; + case 1: + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + Apr33 * Bpi31; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31; + } + } + } + break; + + case 4: /* (3 x 4)*(4 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[3]; Apr13 = Apr[6]; Apr14 = Apr[9]; + Apr21 = Apr[1]; Apr22 = Apr[4]; Apr23 = Apr[7]; Apr24 = Apr[10]; + Apr31 = Apr[2]; Apr32 = Apr[5]; Apr33 = Apr[8]; Apr34 = Apr[11]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; Apr13 = Apr[2]; Apr14 = Apr[3]; + Apr21 = Apr[4]; Apr22 = Apr[5]; Apr23 = Apr[6]; Apr24 = Apr[7]; + Apr31 = Apr[8]; Apr32 = Apr[9]; Apr33 = Apr[10];Apr34 = Apr[11]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[3]; Api13 = Api[6]; Api14 = Api[9]; + Api21 = Api[1]; Api22 = Api[4]; Api23 = Api[7]; Api24 = Api[10]; + Api31 = Api[2]; Api32 = Api[5]; Api33 = Api[8]; Api34 = Api[11]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; Api13 = Api[2]; Api14 = Api[3]; + Api21 = Api[4]; Api22 = Api[5]; Api23 = Api[6]; Api24 = Api[7]; + Api31 = Api[8]; Api32 = Api[9]; Api33 = Api[10];Api34 = Api[11]; + } else if( transa == 'G' ) { + Api11 =-Api[0]; Api12 =-Api[3]; Api13 =-Api[6]; Api14 =-Api[9]; + Api21 =-Api[1]; Api22 =-Api[4]; Api23 =-Api[7]; Api24 =-Api[10]; + Api31 =-Api[2]; Api32 =-Api[5]; Api33 =-Api[8]; Api34 =-Api[11]; + } else { /* transa == 'C' */ + Api11 =-Api[0]; Api12 =-Api[1]; Api13 =-Api[2]; Api14 =-Api[3]; + Api21 =-Api[4]; Api22 =-Api[5]; Api23 =-Api[6]; Api24 =-Api[7]; + Api31 =-Api[8]; Api32 =-Api[9]; Api33 =-Api[10];Api34 =-Api[11]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[11]= Apr31 * Bpr14 + Apr32 * Bpr24 + Apr33 * Bpr34 + Apr34 * Bpr44 + - Api31 * Bpi14 - Api32 * Bpi24 - Api33 * Bpi34 - Api34 * Bpi44; + Cpr[10]= Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + Apr24 * Bpr44 + - Api21 * Bpi14 - Api22 * Bpi24 - Api23 * Bpi34 - Api24 * Bpi44; + Cpr[9] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + Apr14 * Bpr44 + - Api11 * Bpi14 - Api12 * Bpi24 - Api13 * Bpi34 - Api14 * Bpi44; + Cpi[11]= Apr31 * Bpi14 + Apr32 * Bpi24 + Apr33 * Bpi34 + Apr34 * Bpi44 + + Api31 * Bpr14 + Api32 * Bpr24 + Api33 * Bpr34 + Api34 * Bpr44; + Cpi[10]= Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + Apr24 * Bpi44 + + Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34 + Api24 * Bpr44; + Cpi[9] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + Apr14 * Bpi44 + + Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34 + Api14 * Bpr44; + case 3: + Cpr[8] = Apr31 * Bpr13 + Apr32 * Bpr23 + Apr33 * Bpr33 + Apr34 * Bpr43 + - Api31 * Bpi13 - Api32 * Bpi23 - Api33 * Bpi33 - Api34 * Bpi43; + Cpr[7] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + Apr24 * Bpr43 + - Api21 * Bpi13 - Api22 * Bpi23 - Api23 * Bpi33 - Api24 * Bpi43; + Cpr[6] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + Apr14 * Bpr43 + - Api11 * Bpi13 - Api12 * Bpi23 - Api13 * Bpi33 - Api14 * Bpi43; + Cpi[8] = Apr31 * Bpi13 + Apr32 * Bpi23 + Apr33 * Bpi33 + Apr34 * Bpi43 + + Api31 * Bpr13 + Api32 * Bpr23 + Api33 * Bpr33 + Api34 * Bpr43; + Cpi[7] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + Apr24 * Bpi43 + + Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33 + Api24 * Bpr43; + Cpi[6] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + Apr14 * Bpi43 + + Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33 + Api14 * Bpr43; + case 2: + Cpr[5] = Apr31 * Bpr12 + Apr32 * Bpr22 + Apr33 * Bpr32 + Apr34 * Bpr42 + - Api31 * Bpi12 - Api32 * Bpi22 - Api33 * Bpi32 - Api34 * Bpi42; + Cpr[4] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + Apr24 * Bpr42 + - Api21 * Bpi12 - Api22 * Bpi22 - Api23 * Bpi32 - Api24 * Bpi42; + Cpr[3] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + Apr14 * Bpr42 + - Api11 * Bpi12 - Api12 * Bpi22 - Api13 * Bpi32 - Api14 * Bpi42; + Cpi[5] = Apr31 * Bpi12 + Apr32 * Bpi22 + Apr33 * Bpi32 + Apr34 * Bpi42 + + Api31 * Bpr12 + Api32 * Bpr22 + Api33 * Bpr32 + Api34 * Bpr42; + Cpi[4] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + Apr24 * Bpi42 + + Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32 + Api24 * Bpr42; + Cpi[3] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + Apr14 * Bpi42 + + Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32 + Api14 * Bpr42; + case 1: + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + Apr33 * Bpr31 + Apr34 * Bpr41 + - Api31 * Bpi11 - Api32 * Bpi21 - Api33 * Bpi31 - Api34 * Bpi41; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + Apr24 * Bpr41 + - Api21 * Bpi11 - Api22 * Bpi21 - Api23 * Bpi31 - Api24 * Bpi41; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + Apr14 * Bpr41 + - Api11 * Bpi11 - Api12 * Bpi21 - Api13 * Bpi31 - Api14 * Bpi41; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + Apr33 * Bpi31 + Apr34 * Bpi41 + + Api31 * Bpr11 + Api32 * Bpr21 + Api33 * Bpr31 + Api34 * Bpr41; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + Apr24 * Bpi41 + + Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31 + Api24 * Bpr41; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + Apr14 * Bpi41 + + Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31 + Api14 * Bpr41; + } + } else { + switch( n ) { + case 4: + Cpr[11]= Apr31 * Bpr14 + Apr32 * Bpr24 + Apr33 * Bpr34 + Apr34 * Bpr44; + Cpr[10]= Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + Apr24 * Bpr44; + Cpr[9] = Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + Apr14 * Bpr44; + case 3: + Cpr[8] = Apr31 * Bpr13 + Apr32 * Bpr23 + Apr33 * Bpr33 + Apr34 * Bpr43; + Cpr[7] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + Apr24 * Bpr43; + Cpr[6] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + Apr14 * Bpr43; + case 2: + Cpr[5] = Apr31 * Bpr12 + Apr32 * Bpr22 + Apr33 * Bpr32 + Apr34 * Bpr42; + Cpr[4] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + Apr24 * Bpr42; + Cpr[3] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + Apr14 * Bpr42; + case 1: + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + Apr33 * Bpr31 + Apr34 * Bpr41; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + Apr24 * Bpr41; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + Apr14 * Bpr41; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[11]= Api31 * Bpr14 + Api32 * Bpr24 + Api33 * Bpr34 + Api34 * Bpr44; + Cpi[10]= Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34 + Api24 * Bpr44; + Cpi[9] = Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34 + Api14 * Bpr44; + case 3: + Cpi[8] = Api31 * Bpr13 + Api32 * Bpr23 + Api33 * Bpr33 + Api34 * Bpr43; + Cpi[7] = Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33 + Api24 * Bpr43; + Cpi[6] = Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33 + Api14 * Bpr43; + case 2: + Cpi[5] = Api31 * Bpr12 + Api32 * Bpr22 + Api33 * Bpr32 + Api34 * Bpr42; + Cpi[4] = Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32 + Api24 * Bpr42; + Cpi[3] = Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32 + Api14 * Bpr42; + case 1: + Cpi[2] = Api31 * Bpr11 + Api32 * Bpr21 + Api33 * Bpr31 + Api34 * Bpr41; + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31 + Api24 * Bpr41; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31 + Api14 * Bpr41; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[11]= Apr31 * Bpi14 + Apr32 * Bpi24 + Apr33 * Bpi34 + Apr34 * Bpi44; + Cpi[10]= Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + Apr24 * Bpi44; + Cpi[9] = Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + Apr14 * Bpi44; + case 3: + Cpi[8] = Apr31 * Bpi13 + Apr32 * Bpi23 + Apr33 * Bpi33 + Apr34 * Bpi43; + Cpi[7] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + Apr24 * Bpi43; + Cpi[6] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + Apr14 * Bpi43; + case 2: + Cpi[5] = Apr31 * Bpi12 + Apr32 * Bpi22 + Apr33 * Bpi32 + Apr34 * Bpi42; + Cpi[4] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + Apr24 * Bpi42; + Cpi[3] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + Apr14 * Bpi42; + case 1: + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + Apr33 * Bpi31 + Apr34 * Bpi41; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + Apr24 * Bpi41; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + Apr14 * Bpi41; + } + } + } + break; + } + break; + + case 4: /* (4 x k)*(k x n) */ + switch( k ) { + case 1: /* (4 x 1)*(1 x n) */ + Apr11 = Apr[0]; + Apr21 = Apr[1]; + Apr31 = Apr[2]; + Apr41 = Apr[3]; + if( Api ) { + if( transa == 'N' || transa == 'T' ) { + Api11 = Api[0]; + Api21 = Api[1]; + Api31 = Api[2]; + Api41 = Api[3]; + } else { /* transa == 'G' || transa == 'C' */ + Api11 =-Api[0]; + Api21 =-Api[1]; + Api31 =-Api[2]; + Api41 =-Api[3]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[15]= Apr41 * Bpr14 + - Api41 * Bpi14; + Cpr[14]= Apr31 * Bpr14 + - Api31 * Bpi14; + Cpr[13]= Apr21 * Bpr14 + - Api21 * Bpi14; + Cpr[12]= Apr11 * Bpr14 + - Api11 * Bpi14; + Cpi[15]= Apr41 * Bpi14 + + Api41 * Bpr14; + Cpi[14]= Apr31 * Bpi14 + + Api31 * Bpr14; + Cpi[13]= Apr21 * Bpi14 + + Api21 * Bpr14; + Cpi[12]= Apr11 * Bpi14 + + Api11 * Bpr14; + case 3: + Cpr[11]= Apr41 * Bpr13 + - Api41 * Bpi13; + Cpr[10]= Apr31 * Bpr13 + - Api31 * Bpi13; + Cpr[9] = Apr21 * Bpr13 + - Api21 * Bpi13; + Cpr[8] = Apr11 * Bpr13 + - Api11 * Bpi13; + Cpi[11]= Apr41 * Bpi13 + + Api41 * Bpr13; + Cpi[10]= Apr31 * Bpi13 + + Api31 * Bpr13; + Cpi[9] = Apr21 * Bpi13 + + Api21 * Bpr13; + Cpi[8] = Apr11 * Bpi13 + + Api11 * Bpr13; + case 2: + Cpr[7] = Apr41 * Bpr12 + - Api41 * Bpi12; + Cpr[6] = Apr31 * Bpr12 + - Api31 * Bpi12; + Cpr[5] = Apr21 * Bpr12 + - Api21 * Bpi12; + Cpr[4] = Apr11 * Bpr12 + - Api11 * Bpi12; + Cpi[7] = Apr41 * Bpi12 + + Api41 * Bpr12; + Cpi[6] = Apr31 * Bpi12 + + Api31 * Bpr12; + Cpi[5] = Apr21 * Bpi12 + + Api21 * Bpr12; + Cpi[4] = Apr11 * Bpi12 + + Api11 * Bpr12; + case 1: + Cpr[3] = Apr41 * Bpr11 + - Api41 * Bpi11; + Cpr[2] = Apr31 * Bpr11 + - Api31 * Bpi11; + Cpr[1] = Apr21 * Bpr11 + - Api21 * Bpi11; + Cpr[0] = Apr11 * Bpr11 + - Api11 * Bpi11; + Cpi[3] = Apr41 * Bpi11 + + Api41 * Bpr11; + Cpi[2] = Apr31 * Bpi11 + + Api31 * Bpr11; + Cpi[1] = Apr21 * Bpi11 + + Api21 * Bpr11; + Cpi[0] = Apr11 * Bpi11 + + Api11 * Bpr11; + } + } else { + switch( n ) { + case 4: + Cpr[15]= Apr41 * Bpr14; + Cpr[14]= Apr31 * Bpr14; + Cpr[13]= Apr21 * Bpr14; + Cpr[12]= Apr11 * Bpr14; + case 3: + Cpr[11]= Apr41 * Bpr13; + Cpr[10]= Apr31 * Bpr13; + Cpr[9] = Apr21 * Bpr13; + Cpr[8] = Apr11 * Bpr13; + case 2: + Cpr[7] = Apr41 * Bpr12; + Cpr[6] = Apr31 * Bpr12; + Cpr[5] = Apr21 * Bpr12; + Cpr[4] = Apr11 * Bpr12; + case 1: + Cpr[3] = Apr41 * Bpr11; + Cpr[2] = Apr31 * Bpr11; + Cpr[1] = Apr21 * Bpr11; + Cpr[0] = Apr11 * Bpr11; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[15]= Api41 * Bpr14; + Cpi[14]= Api31 * Bpr14; + Cpi[13]= Api21 * Bpr14; + Cpi[12]= Api11 * Bpr14; + case 3: + Cpi[11]= Api41 * Bpr13; + Cpi[10]= Api31 * Bpr13; + Cpi[9] = Api21 * Bpr13; + Cpi[8] = Api11 * Bpr13; + case 2: + Cpi[7] = Api41 * Bpr12; + Cpi[6] = Api31 * Bpr12; + Cpi[5] = Api21 * Bpr12; + Cpi[4] = Api11 * Bpr12; + case 1: + Cpi[3] = Api41 * Bpr11; + Cpi[2] = Api31 * Bpr11; + Cpi[1] = Api21 * Bpr11; + Cpi[0] = Api11 * Bpr11; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[15]= Apr41 * Bpi14; + Cpi[14]= Apr31 * Bpi14; + Cpi[13]= Apr21 * Bpi14; + Cpi[12]= Apr11 * Bpi14; + case 3: + Cpi[11]= Apr41 * Bpi13; + Cpi[10]= Apr31 * Bpi13; + Cpi[9] = Apr21 * Bpi13; + Cpi[8] = Apr11 * Bpi13; + case 2: + Cpi[7] = Apr41 * Bpi12; + Cpi[6] = Apr31 * Bpi12; + Cpi[5] = Apr21 * Bpi12; + Cpi[4] = Apr11 * Bpi12; + case 1: + Cpi[3] = Apr41 * Bpi11; + Cpi[2] = Apr31 * Bpi11; + Cpi[1] = Apr21 * Bpi11; + Cpi[0] = Apr11 * Bpi11; + } + } + } + break; + + case 2: /* (4 x 2)*(2 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[4]; + Apr21 = Apr[1]; Apr22 = Apr[5]; + Apr31 = Apr[2]; Apr32 = Apr[6]; + Apr41 = Apr[3]; Apr42 = Apr[7]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; + Apr21 = Apr[2]; Apr22 = Apr[3]; + Apr31 = Apr[4]; Apr32 = Apr[5]; + Apr41 = Apr[6]; Apr42 = Apr[7]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[4]; + Api21 = Api[1]; Api22 = Api[5]; + Api31 = Api[2]; Api32 = Api[6]; + Api41 = Api[3]; Api42 = Api[7]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; + Api21 = Api[2]; Api22 = Api[3]; + Api31 = Api[4]; Api32 = Api[5]; + Api41 = Api[6]; Api42 = Api[7]; + } else if( transa == 'C' ) { + Api11 = -Api[0]; Api12 = -Api[1]; + Api21 = -Api[2]; Api22 = -Api[3]; + Api31 = -Api[4]; Api32 = -Api[5]; + Api41 = -Api[6]; Api42 = -Api[7]; + } else {/* transa == 'G' */ + Api11 = -Api[0]; Api12 = -Api[4]; + Api21 = -Api[1]; Api22 = -Api[5]; + Api31 = -Api[2]; Api32 = -Api[6]; + Api41 = -Api[3]; Api42 = -Api[7]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[15]= Apr41 * Bpr14 + Apr42 * Bpr24 + - Api41 * Bpi14 - Api42 * Bpi24; + Cpr[14]= Apr31 * Bpr14 + Apr32 * Bpr24 + - Api31 * Bpi14 - Api32 * Bpi24; + Cpr[13]= Apr21 * Bpr14 + Apr22 * Bpr24 + - Api21 * Bpi14 - Api22 * Bpi24; + Cpr[12]= Apr11 * Bpr14 + Apr12 * Bpr24 + - Api11 * Bpi14 - Api12 * Bpi24; + Cpi[15]= Apr41 * Bpi14 + Apr42 * Bpi24 + + Api41 * Bpr14 + Api42 * Bpr24; + Cpi[14]= Apr31 * Bpi14 + Apr32 * Bpi24 + + Api31 * Bpr14 + Api32 * Bpr24; + Cpi[13]= Apr21 * Bpi14 + Apr22 * Bpi24 + + Api21 * Bpr14 + Api22 * Bpr24; + Cpi[12]= Apr11 * Bpi14 + Apr12 * Bpi24 + + Api11 * Bpr14 + Api12 * Bpr24; + case 3: + Cpr[11]= Apr41 * Bpr13 + Apr42 * Bpr23 + - Api41 * Bpi13 - Api42 * Bpi23; + Cpr[10]= Apr31 * Bpr13 + Apr32 * Bpr23 + - Api31 * Bpi13 - Api32 * Bpi23; + Cpr[9] = Apr21 * Bpr13 + Apr22 * Bpr23 + - Api21 * Bpi13 - Api22 * Bpi23; + Cpr[8] = Apr11 * Bpr13 + Apr12 * Bpr23 + - Api11 * Bpi13 - Api12 * Bpi23; + Cpi[11]= Apr41 * Bpi13 + Apr42 * Bpi23 + + Api41 * Bpr13 + Api42 * Bpr23; + Cpi[10]= Apr31 * Bpi13 + Apr32 * Bpi23 + + Api31 * Bpr13 + Api32 * Bpr23; + Cpi[9] = Apr21 * Bpi13 + Apr22 * Bpi23 + + Api21 * Bpr13 + Api22 * Bpr23; + Cpi[8] = Apr11 * Bpi13 + Apr12 * Bpi23 + + Api11 * Bpr13 + Api12 * Bpr23; + case 2: + Cpr[7] = Apr41 * Bpr12 + Apr42 * Bpr22 + - Api41 * Bpi12 - Api42 * Bpi22; + Cpr[6] = Apr31 * Bpr12 + Apr32 * Bpr22 + - Api31 * Bpi12 - Api32 * Bpi22; + Cpr[5] = Apr21 * Bpr12 + Apr22 * Bpr22 + - Api21 * Bpi12 - Api22 * Bpi22; + Cpr[4] = Apr11 * Bpr12 + Apr12 * Bpr22 + - Api11 * Bpi12 - Api12 * Bpi22; + Cpi[7] = Apr41 * Bpi12 + Apr42 * Bpi22 + + Api41 * Bpr12 + Api42 * Bpr22; + Cpi[6] = Apr31 * Bpi12 + Apr32 * Bpi22 + + Api31 * Bpr12 + Api32 * Bpr22; + Cpi[5] = Apr21 * Bpi12 + Apr22 * Bpi22 + + Api21 * Bpr12 + Api22 * Bpr22; + Cpi[4] = Apr11 * Bpi12 + Apr12 * Bpi22 + + Api11 * Bpr12 + Api12 * Bpr22; + case 1: + Cpr[3] = Apr41 * Bpr11 + Apr42 * Bpr21 + - Api41 * Bpi11 - Api42 * Bpi21; + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + - Api31 * Bpi11 - Api32 * Bpi21; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + - Api21 * Bpi11 - Api22 * Bpi21; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + - Api11 * Bpi11 - Api12 * Bpi21; + Cpi[3] = Apr41 * Bpi11 + Apr42 * Bpi21 + + Api41 * Bpr11 + Api42 * Bpr21; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + + Api31 * Bpr11 + Api32 * Bpr21; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + + Api21 * Bpr11 + Api22 * Bpr21; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + + Api11 * Bpr11 + Api12 * Bpr21; + } + } else { + switch( n ) { + case 4: + Cpr[15]= Apr41 * Bpr14 + Apr42 * Bpr24; + Cpr[14]= Apr31 * Bpr14 + Apr32 * Bpr24; + Cpr[13]= Apr21 * Bpr14 + Apr22 * Bpr24; + Cpr[12]= Apr11 * Bpr14 + Apr12 * Bpr24; + case 3: + Cpr[11]= Apr41 * Bpr13 + Apr42 * Bpr23; + Cpr[10]= Apr31 * Bpr13 + Apr32 * Bpr23; + Cpr[9] = Apr21 * Bpr13 + Apr22 * Bpr23; + Cpr[8] = Apr11 * Bpr13 + Apr12 * Bpr23; + case 2: + Cpr[7] = Apr41 * Bpr12 + Apr42 * Bpr22; + Cpr[6] = Apr31 * Bpr12 + Apr32 * Bpr22; + Cpr[5] = Apr21 * Bpr12 + Apr22 * Bpr22; + Cpr[4] = Apr11 * Bpr12 + Apr12 * Bpr22; + case 1: + Cpr[3] = Apr41 * Bpr11 + Apr42 * Bpr21; + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[15]= Api41 * Bpr14 + Api42 * Bpr24; + Cpi[14]= Api31 * Bpr14 + Api32 * Bpr24; + Cpi[13]= Api21 * Bpr14 + Api22 * Bpr24; + Cpi[12]= Api11 * Bpr14 + Api12 * Bpr24; + case 3: + Cpi[11]= Api41 * Bpr13 + Api42 * Bpr23; + Cpi[10]= Api31 * Bpr13 + Api32 * Bpr23; + Cpi[9] = Api21 * Bpr13 + Api22 * Bpr23; + Cpi[8] = Api11 * Bpr13 + Api12 * Bpr23; + case 2: + Cpi[7] = Api41 * Bpr12 + Api42 * Bpr22; + Cpi[6] = Api31 * Bpr12 + Api32 * Bpr22; + Cpi[5] = Api21 * Bpr12 + Api22 * Bpr22; + Cpi[4] = Api11 * Bpr12 + Api12 * Bpr22; + case 1: + Cpi[3] = Api41 * Bpr11 + Api42 * Bpr21; + Cpi[2] = Api31 * Bpr11 + Api32 * Bpr21; + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[15]= Apr41 * Bpi14 + Apr42 * Bpi24; + Cpi[14]= Apr31 * Bpi14 + Apr32 * Bpi24; + Cpi[13]= Apr21 * Bpi14 + Apr22 * Bpi24; + Cpi[12]= Apr11 * Bpi14 + Apr12 * Bpi24; + case 3: + Cpi[11]= Apr41 * Bpi13 + Apr42 * Bpi23; + Cpi[10]= Apr31 * Bpi13 + Apr32 * Bpi23; + Cpi[9] = Apr21 * Bpi13 + Apr22 * Bpi23; + Cpi[8] = Apr11 * Bpi13 + Apr12 * Bpi23; + case 2: + Cpi[7] = Apr41 * Bpi12 + Apr42 * Bpi22; + Cpi[6] = Apr31 * Bpi12 + Apr32 * Bpi22; + Cpi[5] = Apr21 * Bpi12 + Apr22 * Bpi22; + Cpi[4] = Apr11 * Bpi12 + Apr12 * Bpi22; + case 1: + Cpi[3] = Apr41 * Bpi11 + Apr42 * Bpi21; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21; + } + } + } + break; + + case 3: /* (4 x 3)*(3 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[4]; Apr13 = Apr[8]; + Apr21 = Apr[1]; Apr22 = Apr[5]; Apr23 = Apr[9]; + Apr31 = Apr[2]; Apr32 = Apr[6]; Apr33 = Apr[10]; + Apr41 = Apr[3]; Apr42 = Apr[7]; Apr43 = Apr[11]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; Apr13 = Apr[2]; + Apr21 = Apr[3]; Apr22 = Apr[4]; Apr23 = Apr[5]; + Apr31 = Apr[6]; Apr32 = Apr[7]; Apr33 = Apr[8]; + Apr41 = Apr[9]; Apr42 = Apr[10];Apr43 = Apr[11]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[4]; Api13 = Api[8]; + Api21 = Api[1]; Api22 = Api[5]; Api23 = Api[9]; + Api31 = Api[2]; Api32 = Api[6]; Api33 = Api[10]; + Api41 = Api[3]; Api42 = Api[7]; Api43 = Api[11]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; Api13 = Api[2]; + Api21 = Api[3]; Api22 = Api[4]; Api23 = Api[5]; + Api31 = Api[6]; Api32 = Api[7]; Api33 = Api[8]; + Api41 = Api[9]; Api42 = Api[10];Api43 = Api[11]; + } else if( transa == 'C' ) { + Api11 =-Api[0]; Api12 =-Api[1]; Api13 =-Api[2]; + Api21 =-Api[3]; Api22 =-Api[4]; Api23 =-Api[5]; + Api31 =-Api[6]; Api32 =-Api[7]; Api33 =-Api[8]; + Api41 =-Api[9]; Api42 =-Api[10];Api43 =-Api[11]; + } else {/* transa == 'G' */ + Api11 =-Api[0]; Api12 =-Api[4]; Api13 =-Api[8]; + Api21 =-Api[1]; Api22 =-Api[5]; Api23 =-Api[9]; + Api31 =-Api[2]; Api32 =-Api[6]; Api33 =-Api[10]; + Api41 =-Api[3]; Api42 =-Api[7]; Api43 =-Api[11]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[15]= Apr41 * Bpr14 + Apr42 * Bpr24 + Apr43 * Bpr34 + - Api41 * Bpi14 - Api42 * Bpi24 - Api43 * Bpi34; + Cpr[14]= Apr31 * Bpr14 + Apr32 * Bpr24 + Apr33 * Bpr34 + - Api31 * Bpi14 - Api32 * Bpi24 - Api33 * Bpi34; + Cpr[13]= Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + - Api21 * Bpi14 - Api22 * Bpi24 - Api23 * Bpi34; + Cpr[12]= Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + - Api11 * Bpi14 - Api12 * Bpi24 - Api13 * Bpi34; + Cpi[15]= Apr41 * Bpi14 + Apr42 * Bpi24 + Apr43 * Bpi34 + + Api41 * Bpr14 + Api42 * Bpr24 + Api43 * Bpr34; + Cpi[14]= Apr31 * Bpi14 + Apr32 * Bpi24 + Apr33 * Bpi34 + + Api31 * Bpr14 + Api32 * Bpr24 + Api33 * Bpr34; + Cpi[13]= Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + + Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34; + Cpi[12]= Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + + Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34; + case 3: + Cpr[11]= Apr41 * Bpr13 + Apr42 * Bpr23 + Apr43 * Bpr33 + - Api41 * Bpi13 - Api42 * Bpi23 - Api43 * Bpi33; + Cpr[10]= Apr31 * Bpr13 + Apr32 * Bpr23 + Apr33 * Bpr33 + - Api31 * Bpi13 - Api32 * Bpi23 - Api33 * Bpi33; + Cpr[9] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + - Api21 * Bpi13 - Api22 * Bpi23 - Api23 * Bpi33; + Cpr[8] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + - Api11 * Bpi13 - Api12 * Bpi23 - Api13 * Bpi33; + Cpi[11]= Apr41 * Bpi13 + Apr42 * Bpi23 + Apr43 * Bpi33 + + Api41 * Bpr13 + Api42 * Bpr23 + Api43 * Bpr33; + Cpi[10]= Apr31 * Bpi13 + Apr32 * Bpi23 + Apr33 * Bpi33 + + Api31 * Bpr13 + Api32 * Bpr23 + Api33 * Bpr33; + Cpi[9] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + + Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33; + Cpi[8] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + + Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33; + case 2: + Cpr[7] = Apr41 * Bpr12 + Apr42 * Bpr22 + Apr43 * Bpr32 + - Api41 * Bpi12 - Api42 * Bpi22 - Api43 * Bpi32; + Cpr[6] = Apr31 * Bpr12 + Apr32 * Bpr22 + Apr33 * Bpr32 + - Api31 * Bpi12 - Api32 * Bpi22 - Api33 * Bpi32; + Cpr[5] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + - Api21 * Bpi12 - Api22 * Bpi22 - Api23 * Bpi32; + Cpr[4] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + - Api11 * Bpi12 - Api12 * Bpi22 - Api13 * Bpi32; + Cpi[7] = Apr41 * Bpi12 + Apr42 * Bpi22 + Apr43 * Bpi32 + + Api41 * Bpr12 + Api42 * Bpr22 + Api43 * Bpr32; + Cpi[6] = Apr31 * Bpi12 + Apr32 * Bpi22 + Apr33 * Bpi32 + + Api31 * Bpr12 + Api32 * Bpr22 + Api33 * Bpr32; + Cpi[5] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + + Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32; + Cpi[4] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + + Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32; + case 1: + Cpr[3] = Apr41 * Bpr11 + Apr42 * Bpr21 + Apr43 * Bpr31 + - Api41 * Bpi11 - Api42 * Bpi21 - Api43 * Bpi31; + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + Apr33 * Bpr31 + - Api31 * Bpi11 - Api32 * Bpi21 - Api33 * Bpi31; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + - Api21 * Bpi11 - Api22 * Bpi21 - Api23 * Bpi31; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + - Api11 * Bpi11 - Api12 * Bpi21 - Api13 * Bpi31; + Cpi[3] = Apr41 * Bpi11 + Apr42 * Bpi21 + Apr43 * Bpi31 + + Api41 * Bpr11 + Api42 * Bpr21 + Api43 * Bpr31; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + Apr33 * Bpi31 + + Api31 * Bpr11 + Api32 * Bpr21 + Api33 * Bpr31; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + + Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + + Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31; + } + } else { + switch( n ) { + case 4: + Cpr[15]= Apr41 * Bpr14 + Apr42 * Bpr24 + Apr43 * Bpr34; + Cpr[14]= Apr31 * Bpr14 + Apr32 * Bpr24 + Apr33 * Bpr34; + Cpr[13]= Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34; + Cpr[12]= Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34; + case 3: + Cpr[11]= Apr41 * Bpr13 + Apr42 * Bpr23 + Apr43 * Bpr33; + Cpr[10]= Apr31 * Bpr13 + Apr32 * Bpr23 + Apr33 * Bpr33; + Cpr[9] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33; + Cpr[8] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33; + case 2: + Cpr[7] = Apr41 * Bpr12 + Apr42 * Bpr22 + Apr43 * Bpr32; + Cpr[6] = Apr31 * Bpr12 + Apr32 * Bpr22 + Apr33 * Bpr32; + Cpr[5] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32; + Cpr[4] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32; + case 1: + Cpr[3] = Apr41 * Bpr11 + Apr42 * Bpr21 + Apr43 * Bpr31; + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + Apr33 * Bpr31; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[15]= Api41 * Bpr14 + Api42 * Bpr24 + Api43 * Bpr34; + Cpi[14]= Api31 * Bpr14 + Api32 * Bpr24 + Api33 * Bpr34; + Cpi[13]= Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34; + Cpi[12]= Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34; + case 3: + Cpi[11]= Api41 * Bpr13 + Api42 * Bpr23 + Api43 * Bpr33; + Cpi[10]= Api31 * Bpr13 + Api32 * Bpr23 + Api33 * Bpr33; + Cpi[9] = Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33; + Cpi[8] = Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33; + case 2: + Cpi[7] = Api41 * Bpr12 + Api42 * Bpr22 + Api43 * Bpr32; + Cpi[6] = Api31 * Bpr12 + Api32 * Bpr22 + Api33 * Bpr32; + Cpi[5] = Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32; + Cpi[4] = Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32; + case 1: + Cpi[3] = Api41 * Bpr11 + Api42 * Bpr21 + Api43 * Bpr31; + Cpi[2] = Api31 * Bpr11 + Api32 * Bpr21 + Api33 * Bpr31; + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[15]= Apr41 * Bpi14 + Apr42 * Bpi24 + Apr43 * Bpi34; + Cpi[14]= Apr31 * Bpi14 + Apr32 * Bpi24 + Apr33 * Bpi34; + Cpi[13]= Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34; + Cpi[12]= Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34; + case 3: + Cpi[11]= Apr41 * Bpi13 + Apr42 * Bpi23 + Apr43 * Bpi33; + Cpi[10]= Apr31 * Bpi13 + Apr32 * Bpi23 + Apr33 * Bpi33; + Cpi[9] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33; + Cpi[8] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33; + case 2: + Cpi[7] = Apr41 * Bpi12 + Apr42 * Bpi22 + Apr43 * Bpi32; + Cpi[6] = Apr31 * Bpi12 + Apr32 * Bpi22 + Apr33 * Bpi32; + Cpi[5] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32; + Cpi[4] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32; + case 1: + Cpi[3] = Apr41 * Bpi11 + Apr42 * Bpi21 + Apr43 * Bpi31; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + Apr33 * Bpi31; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31; + } + } + } + break; + + case 4: /* (4 x 4)*(4 x n) */ + if( transa == 'N' || transa == 'G' ) { + Apr11 = Apr[0]; Apr12 = Apr[4]; Apr13 = Apr[8]; Apr14 = Apr[12]; + Apr21 = Apr[1]; Apr22 = Apr[5]; Apr23 = Apr[9]; Apr24 = Apr[13]; + Apr31 = Apr[2]; Apr32 = Apr[6]; Apr33 = Apr[10];Apr34 = Apr[14]; + Apr41 = Apr[3]; Apr42 = Apr[7]; Apr43 = Apr[11];Apr44 = Apr[15]; + } else { /* transa == 'T' || transa == 'C' */ + Apr11 = Apr[0]; Apr12 = Apr[1]; Apr13 = Apr[2]; Apr14 = Apr[3]; + Apr21 = Apr[4]; Apr22 = Apr[5]; Apr23 = Apr[6]; Apr24 = Apr[7]; + Apr31 = Apr[8]; Apr32 = Apr[9]; Apr33 = Apr[10];Apr34 = Apr[11]; + Apr41 = Apr[12];Apr42 = Apr[13];Apr43 = Apr[14];Apr44 = Apr[15]; + } + if( Api ) { + if( transa == 'N' ) { + Api11 = Api[0]; Api12 = Api[4]; Api13 = Api[8]; Api14 = Api[12]; + Api21 = Api[1]; Api22 = Api[5]; Api23 = Api[9]; Api24 = Api[13]; + Api31 = Api[2]; Api32 = Api[6]; Api33 = Api[10];Api34 = Api[14]; + Api41 = Api[3]; Api42 = Api[7]; Api43 = Api[11];Api44 = Api[15]; + } else if( transa == 'T' ) { + Api11 = Api[0]; Api12 = Api[1]; Api13 = Api[2]; Api14 = Api[3]; + Api21 = Api[4]; Api22 = Api[5]; Api23 = Api[6]; Api24 = Api[7]; + Api31 = Api[8]; Api32 = Api[9]; Api33 = Api[10];Api34 = Api[11]; + Api41 = Api[12];Api42 = Api[13];Api43 = Api[14];Api44 = Api[15]; + } else if( transa == 'G' ) { + Api11 =-Api[0]; Api12 =-Api[4]; Api13 =-Api[8]; Api14 =-Api[12]; + Api21 =-Api[1]; Api22 =-Api[5]; Api23 =-Api[9]; Api24 =-Api[13]; + Api31 =-Api[2]; Api32 =-Api[6]; Api33 =-Api[10];Api34 =-Api[14]; + Api41 =-Api[3]; Api42 =-Api[7]; Api43 =-Api[11];Api44 =-Api[15]; + } else { /* transa == 'C' */ + Api11 =-Api[0]; Api12 =-Api[1]; Api13 =-Api[2]; Api14 =-Api[3]; + Api21 =-Api[4]; Api22 =-Api[5]; Api23 =-Api[6]; Api24 =-Api[7]; + Api31 =-Api[8]; Api32 =-Api[9]; Api33 =-Api[10];Api34 =-Api[11]; + Api41 =-Api[12];Api42 =-Api[13];Api43 =-Api[14];Api44 =-Api[15]; + } + } + if( Api && Bpi ) { + switch( n ) { + case 4: + Cpr[15]= Apr41 * Bpr14 + Apr42 * Bpr24 + Apr43 * Bpr34 + Apr44 * Bpr44 + - Api41 * Bpi14 - Api42 * Bpi24 - Api43 * Bpi34 - Api44 * Bpi44; + Cpr[14]= Apr31 * Bpr14 + Apr32 * Bpr24 + Apr33 * Bpr34 + Apr34 * Bpr44 + - Api31 * Bpi14 - Api32 * Bpi24 - Api33 * Bpi34 - Api34 * Bpi44; + Cpr[13]= Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + Apr24 * Bpr44 + - Api21 * Bpi14 - Api22 * Bpi24 - Api23 * Bpi34 - Api24 * Bpi44; + Cpr[12]= Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + Apr14 * Bpr44 + - Api11 * Bpi14 - Api12 * Bpi24 - Api13 * Bpi34 - Api14 * Bpi44; + Cpi[15]= Apr41 * Bpi14 + Apr42 * Bpi24 + Apr43 * Bpi34 + Apr44 * Bpi44 + + Api41 * Bpr14 + Api42 * Bpr24 + Api43 * Bpr34 + Api44 * Bpr44; + Cpi[14]= Apr31 * Bpi14 + Apr32 * Bpi24 + Apr33 * Bpi34 + Apr34 * Bpi44 + + Api31 * Bpr14 + Api32 * Bpr24 + Api33 * Bpr34 + Api34 * Bpr44; + Cpi[13]= Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + Apr24 * Bpi44 + + Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34 + Api24 * Bpr44; + Cpi[12]= Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + Apr14 * Bpi44 + + Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34 + Api14 * Bpr44; + case 3: + Cpr[11]= Apr41 * Bpr13 + Apr42 * Bpr23 + Apr43 * Bpr33 + Apr44 * Bpr43 + - Api41 * Bpi13 - Api42 * Bpi23 - Api43 * Bpi33 - Api44 * Bpi43; + Cpr[10]= Apr31 * Bpr13 + Apr32 * Bpr23 + Apr33 * Bpr33 + Apr34 * Bpr43 + - Api31 * Bpi13 - Api32 * Bpi23 - Api33 * Bpi33 - Api34 * Bpi43; + Cpr[9] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + Apr24 * Bpr43 + - Api21 * Bpi13 - Api22 * Bpi23 - Api23 * Bpi33 - Api24 * Bpi43; + Cpr[8] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + Apr14 * Bpr43 + - Api11 * Bpi13 - Api12 * Bpi23 - Api13 * Bpi33 - Api14 * Bpi43; + Cpi[11]= Apr41 * Bpi13 + Apr42 * Bpi23 + Apr43 * Bpi33 + Apr44 * Bpi43 + + Api41 * Bpr13 + Api42 * Bpr23 + Api43 * Bpr33 + Api44 * Bpr43; + Cpi[10]= Apr31 * Bpi13 + Apr32 * Bpi23 + Apr33 * Bpi33 + Apr34 * Bpi43 + + Api31 * Bpr13 + Api32 * Bpr23 + Api33 * Bpr33 + Api34 * Bpr43; + Cpi[9] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + Apr24 * Bpi43 + + Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33 + Api24 * Bpr43; + Cpi[8] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + Apr14 * Bpi43 + + Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33 + Api14 * Bpr43; + case 2: + Cpr[7] = Apr41 * Bpr12 + Apr42 * Bpr22 + Apr43 * Bpr32 + Apr44 * Bpr42 + - Api41 * Bpi12 - Api42 * Bpi22 - Api43 * Bpi32 - Api44 * Bpi42; + Cpr[6] = Apr31 * Bpr12 + Apr32 * Bpr22 + Apr33 * Bpr32 + Apr34 * Bpr42 + - Api31 * Bpi12 - Api32 * Bpi22 - Api33 * Bpi32 - Api34 * Bpi42; + Cpr[5] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + Apr24 * Bpr42 + - Api21 * Bpi12 - Api22 * Bpi22 - Api23 * Bpi32 - Api24 * Bpi42; + Cpr[4] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + Apr14 * Bpr42 + - Api11 * Bpi12 - Api12 * Bpi22 - Api13 * Bpi32 - Api14 * Bpi42; + Cpi[7] = Apr41 * Bpi12 + Apr42 * Bpi22 + Apr43 * Bpi32 + Apr44 * Bpi42 + + Api41 * Bpr12 + Api42 * Bpr22 + Api43 * Bpr32 + Api44 * Bpr42; + Cpi[6] = Apr31 * Bpi12 + Apr32 * Bpi22 + Apr33 * Bpi32 + Apr34 * Bpi42 + + Api31 * Bpr12 + Api32 * Bpr22 + Api33 * Bpr32 + Api34 * Bpr42; + Cpi[5] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + Apr24 * Bpi42 + + Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32 + Api24 * Bpr42; + Cpi[4] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + Apr14 * Bpi42 + + Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32 + Api14 * Bpr42; + case 1: + Cpr[3] = Apr41 * Bpr11 + Apr42 * Bpr21 + Apr43 * Bpr31 + Apr44 * Bpr41 + - Api41 * Bpi11 - Api42 * Bpi21 - Api43 * Bpi31 - Api44 * Bpi41; + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + Apr33 * Bpr31 + Apr34 * Bpr41 + - Api31 * Bpi11 - Api32 * Bpi21 - Api33 * Bpi31 - Api34 * Bpi41; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + Apr24 * Bpr41 + - Api21 * Bpi11 - Api22 * Bpi21 - Api23 * Bpi31 - Api24 * Bpi41; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + Apr14 * Bpr41 + - Api11 * Bpi11 - Api12 * Bpi21 - Api13 * Bpi31 - Api14 * Bpi41; + Cpi[3] = Apr41 * Bpi11 + Apr42 * Bpi21 + Apr43 * Bpi31 + Apr44 * Bpi41 + + Api41 * Bpr11 + Api42 * Bpr21 + Api43 * Bpr31 + Api44 * Bpr41; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + Apr33 * Bpi31 + Apr34 * Bpi41 + + Api31 * Bpr11 + Api32 * Bpr21 + Api33 * Bpr31 + Api34 * Bpr41; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + Apr24 * Bpi41 + + Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31 + Api24 * Bpr41; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + Apr14 * Bpi41 + + Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31 + Api14 * Bpr41; + } + } else { + switch( n ) { + case 4: + Cpr[15]= Apr41 * Bpr14 + Apr42 * Bpr24 + Apr43 * Bpr34 + Apr44 * Bpr44; + Cpr[14]= Apr31 * Bpr14 + Apr32 * Bpr24 + Apr33 * Bpr34 + Apr34 * Bpr44; + Cpr[13]= Apr21 * Bpr14 + Apr22 * Bpr24 + Apr23 * Bpr34 + Apr24 * Bpr44; + Cpr[12]= Apr11 * Bpr14 + Apr12 * Bpr24 + Apr13 * Bpr34 + Apr14 * Bpr44; + case 3: + Cpr[11]= Apr41 * Bpr13 + Apr42 * Bpr23 + Apr43 * Bpr33 + Apr44 * Bpr43; + Cpr[10]= Apr31 * Bpr13 + Apr32 * Bpr23 + Apr33 * Bpr33 + Apr34 * Bpr43; + Cpr[9] = Apr21 * Bpr13 + Apr22 * Bpr23 + Apr23 * Bpr33 + Apr24 * Bpr43; + Cpr[8] = Apr11 * Bpr13 + Apr12 * Bpr23 + Apr13 * Bpr33 + Apr14 * Bpr43; + case 2: + Cpr[7] = Apr41 * Bpr12 + Apr42 * Bpr22 + Apr43 * Bpr32 + Apr44 * Bpr42; + Cpr[6] = Apr31 * Bpr12 + Apr32 * Bpr22 + Apr33 * Bpr32 + Apr34 * Bpr42; + Cpr[5] = Apr21 * Bpr12 + Apr22 * Bpr22 + Apr23 * Bpr32 + Apr24 * Bpr42; + Cpr[4] = Apr11 * Bpr12 + Apr12 * Bpr22 + Apr13 * Bpr32 + Apr14 * Bpr42; + case 1: + Cpr[3] = Apr41 * Bpr11 + Apr42 * Bpr21 + Apr43 * Bpr31 + Apr44 * Bpr41; + Cpr[2] = Apr31 * Bpr11 + Apr32 * Bpr21 + Apr33 * Bpr31 + Apr34 * Bpr41; + Cpr[1] = Apr21 * Bpr11 + Apr22 * Bpr21 + Apr23 * Bpr31 + Apr24 * Bpr41; + Cpr[0] = Apr11 * Bpr11 + Apr12 * Bpr21 + Apr13 * Bpr31 + Apr14 * Bpr41; + } + if( Api ) { + switch( n ) { + case 4: + Cpi[15]= Api41 * Bpr14 + Api42 * Bpr24 + Api43 * Bpr34 + Api44 * Bpr44; + Cpi[14]= Api31 * Bpr14 + Api32 * Bpr24 + Api33 * Bpr34 + Api34 * Bpr44; + Cpi[13]= Api21 * Bpr14 + Api22 * Bpr24 + Api23 * Bpr34 + Api24 * Bpr44; + Cpi[12]= Api11 * Bpr14 + Api12 * Bpr24 + Api13 * Bpr34 + Api14 * Bpr44; + case 3: + Cpi[11]= Api41 * Bpr13 + Api42 * Bpr23 + Api43 * Bpr33 + Api44 * Bpr43; + Cpi[10]= Api31 * Bpr13 + Api32 * Bpr23 + Api33 * Bpr33 + Api34 * Bpr43; + Cpi[9] = Api21 * Bpr13 + Api22 * Bpr23 + Api23 * Bpr33 + Api24 * Bpr43; + Cpi[8] = Api11 * Bpr13 + Api12 * Bpr23 + Api13 * Bpr33 + Api14 * Bpr43; + case 2: + Cpi[7] = Api41 * Bpr12 + Api42 * Bpr22 + Api43 * Bpr32 + Api44 * Bpr42; + Cpi[6] = Api31 * Bpr12 + Api32 * Bpr22 + Api33 * Bpr32 + Api34 * Bpr42; + Cpi[5] = Api21 * Bpr12 + Api22 * Bpr22 + Api23 * Bpr32 + Api24 * Bpr42; + Cpi[4] = Api11 * Bpr12 + Api12 * Bpr22 + Api13 * Bpr32 + Api14 * Bpr42; + case 1: + Cpi[3] = Api41 * Bpr11 + Api42 * Bpr21 + Api43 * Bpr31 + Api44 * Bpr41; + Cpi[2] = Api31 * Bpr11 + Api32 * Bpr21 + Api33 * Bpr31 + Api34 * Bpr41; + Cpi[1] = Api21 * Bpr11 + Api22 * Bpr21 + Api23 * Bpr31 + Api24 * Bpr41; + Cpi[0] = Api11 * Bpr11 + Api12 * Bpr21 + Api13 * Bpr31 + Api14 * Bpr41; + } + } + if( Bpi ) { + switch( n ) { + case 4: + Cpi[15]= Apr41 * Bpi14 + Apr42 * Bpi24 + Apr43 * Bpi34 + Apr44 * Bpi44; + Cpi[14]= Apr31 * Bpi14 + Apr32 * Bpi24 + Apr33 * Bpi34 + Apr34 * Bpi44; + Cpi[13]= Apr21 * Bpi14 + Apr22 * Bpi24 + Apr23 * Bpi34 + Apr24 * Bpi44; + Cpi[12]= Apr11 * Bpi14 + Apr12 * Bpi24 + Apr13 * Bpi34 + Apr14 * Bpi44; + case 3: + Cpi[11]= Apr41 * Bpi13 + Apr42 * Bpi23 + Apr43 * Bpi33 + Apr44 * Bpi43; + Cpi[10]= Apr31 * Bpi13 + Apr32 * Bpi23 + Apr33 * Bpi33 + Apr34 * Bpi43; + Cpi[9] = Apr21 * Bpi13 + Apr22 * Bpi23 + Apr23 * Bpi33 + Apr24 * Bpi43; + Cpi[8] = Apr11 * Bpi13 + Apr12 * Bpi23 + Apr13 * Bpi33 + Apr14 * Bpi43; + case 2: + Cpi[7] = Apr41 * Bpi12 + Apr42 * Bpi22 + Apr43 * Bpi32 + Apr44 * Bpi42; + Cpi[6] = Apr31 * Bpi12 + Apr32 * Bpi22 + Apr33 * Bpi32 + Apr34 * Bpi42; + Cpi[5] = Apr21 * Bpi12 + Apr22 * Bpi22 + Apr23 * Bpi32 + Apr24 * Bpi42; + Cpi[4] = Apr11 * Bpi12 + Apr12 * Bpi22 + Apr13 * Bpi32 + Apr14 * Bpi42; + case 1: + Cpi[3] = Apr41 * Bpi11 + Apr42 * Bpi21 + Apr43 * Bpi31 + Apr44 * Bpi41; + Cpi[2] = Apr31 * Bpi11 + Apr32 * Bpi21 + Apr33 * Bpi31 + Apr34 * Bpi41; + Cpi[1] = Apr21 * Bpi11 + Apr22 * Bpi21 + Apr23 * Bpi31 + Apr24 * Bpi41; + Cpi[0] = Apr11 * Bpi11 + Apr12 * Bpi21 + Apr13 * Bpi31 + Apr14 * Bpi41; + } + } + } + break; + } + break; + } + +/*---------------------------------------------------------------------------- + * Vector dot product (1 x K) * (K x 1) + *---------------------------------------------------------------------------- */ + + } else if( m == 1 && n == 1 ) { + z = RealKindDotProduct(k, Apr, Api, ai, Bpr, Bpi, bi, dot_method); + *Cpr = z.r; + if( Cpi ) { + *Cpi = z.i; + } + +/*---------------------------------------------------------------------------- + * Vector outer product (M x 1) * (1 x N) + *---------------------------------------------------------------------------- */ + + } else if( k == 1 ) { + RealKindOuterProduct(m, n, Apr, Api, transa, Bpr, Bpi, transb, Cpr, Cpi, outer_method); + +/*---------------------------------------------------------------------------- + * Matrix times vector (M x K) * (K x 1) + *---------------------------------------------------------------------------- */ + + } else if( n == 1 ) { + +/*---------------------------------------------------------------------------- + * If the first matrix is not transposed, use calls to xGEMV. Also use this + * method if running in the 'MATLAB' or 'BLAS' mode, or the number of processors + * is greater than 2. + *---------------------------------------------------------------------------- */ + + if( transa == 'N' || transa == 'G' || mtimesx_mode == MTIMESX_BLAS || + mtimesx_mode == MTIMESX_MATLAB || omp_get_num_procs() > 2 ) { + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xGEMV) "\n"); + } + if( transa == 'G' ) ptransa = 'N'; + xGEMV(PTRANSA, M1, N1, ONE, Apr, LDA, Bpr, INCX, ZERO, Cpr, INCY); + if( Bpi ) { + xGEMV(PTRANSA, M1, N1, BI, Apr, LDA, Bpi, INCX, ZERO, Cpi, INCY); + if( Api ) { /* (complex matrix) * (complex vector) */ + xGEMV(PTRANSA, M1, N1, AIBI, Api, LDA, Bpi, INCX, ONE, Cpr, INCY); + xGEMV(PTRANSA, M1, N1, AI, Api, LDA, Bpr, INCX, ONE, Cpi, INCY); + } else { /* (real matrix) * (complex vector) + * already done */ + } + } else { + if( Api ) { /* (complex matrix) * (real vector) */ + xGEMV(PTRANSA, M1, N1, AI, Api, LDA, Bpr, INCX, ZERO, Cpi, INCY); + } else { /* (real matrix) * (real vector) + * already done */ + } + } + +/* Alternate method ... doesn't match MATLAB exactly ... not up to date + * + * if( transa == 'N' || transa == 'G' || matlab ) { + * if( transa == 'G' ) ptransa = 'N'; + * xGEMV(PTRANSA, M1, N1, ONE, Apr, LDA, Bpr, INCX, ZERO, Cpr, INCY); + * if( mxIsComplex(A) ) { + * xGEMV(PTRANSA, M1, N1, AI, Api, LDA, Bpr, INCX, ZERO, Cpi, INCY); + * if( mxIsComplex(B) ) { // (complex matrix) * (complex vector) + * xGEMV(PTRANSA, M1, N1, AIBI, Api, LDA, Bpi, INCX, ONE, Cpr, INCY); + * xGEMV(PTRANSA, M1, N1, BI, Apr, LDA, Bpi, INCX, ONE, Cpi, INCY); + * } else { // (complex matrix) * (real vector) + * // already done + * } + * } else { + * if( mxIsComplex(B) ) { // (real matrix) * (complex vector) + * xGEMV(PTRANSA, M1, N1, BI, Apr, LDA, Bpi, INCX, ZERO, Cpi, INCY); + * } else { // (real matrix) * (real vector) + * // already done + * } + * } */ + +/*----------------------------------------------------------------------------------------- + * Else if the first matrix is transposed, then use calls to xDOT instead (faster) because + * the matrix can be accessed as a series of contiguous column vectors. + *----------------------------------------------------------------------------------------- */ + + } else { /* transa == 'T' || transa == 'C' */ + apr = Apr; + api = Api; + if( Api ) { + for( i=0; i<m; i++ ) { /* (complex matrix) * (vector) */ + z = RealKindDotProduct(k, apr, api, ai, Bpr, Bpi, bi, dot_method); + Cpr[i] = z.r; + Cpi[i] = z.i; + apr += k; + api += k; + } + } else { /* (real matrix) * (complex vector) */ + if( Bpi ) { + for( i=0; i<m; i++ ) { + z = RealKindDotProduct(k, apr, Api, ai, Bpr, Bpi, bi, dot_method); + Cpr[i] = z.r; + Cpi[i] = z.i; + apr += k; + } + } else { /* (real matrix) * (real vector) */ + for( i=0; i<m; i++ ) { + z = RealKindDotProduct(k, apr, Api, ai, Bpr, Bpi, bi, dot_method); + Cpr[i] = z.r; + apr += k; + } + } + } + } + +/*---------------------------------------------------------------------------------------- + * Vector times matrix (1 x K) * (K x N) + *---------------------------------------------------------------------------------------- */ + + } else if( m == 1 ) { + +/*---------------------------------------------------------------------------------------- + * If the second matrix is transposed, then use calls to xGEMV with the arguments reversed. + * Also use this method if running in 'MATLAB' or 'BLAS' mode, or the number of processors + * is greater than 2. + *---------------------------------------------------------------------------------------- */ + + if( transb == 'C' || transb == 'T' || mtimesx_mode == MTIMESX_BLAS || + mtimesx_mode == MTIMESX_MATLAB || omp_get_num_procs() > 2 ) { + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xGEMV) "\n"); + } + if( transb == 'C' || transb == 'T' ) { + ptransb = 'N'; + } else { + ptransb = 'T'; + } + xGEMV(PTRANSB, M2, N2, ONE, Bpr, LDB, Apr, INCX, ZERO, Cpr, INCY); + if( Api ) { + xGEMV(PTRANSB, M2, N2, AI, Bpr, LDB, Api, INCX, ZERO, Cpi, INCY); + if( Bpi ) { /* (complex matrix) * (complex vector) */ + xGEMV(PTRANSB, M2, N2, AIBI, Bpi, LDB, Api, INCX, ONE, Cpr, INCY); + xGEMV(PTRANSB, M2, N2, BI, Bpi, LDB, Apr, INCX, ONE, Cpi, INCY); + } else { /* (complex matrix) * (real vector) + * already done */ + } + } else { + if( Bpi ) { /* (real matrix) * (complex vector) */ + xGEMV(PTRANSB, M2, N2, BI, Bpi, LDB, Apr, INCX, ZERO, Cpi, INCY); + } else { /* (real matrix) * (real vector) + * already done */ + } + } + +/* Alternate method ... doesn't match MATLAB exactly ... not up to date + * + * if( transb == 'C' || transb == 'T' || matlab ) { + * if( transb == 'C' || transb == 'T' ) { + * ptransb = 'N'; + * } else { + * ptransb = 'T'; + * } + * xGEMV(PTRANSB, M2, N2, ONE, Bpr, LDB, Apr, INCX, ZERO, Cpr, INCY); + * if( mxIsComplex(B) ) { + * xGEMV(PTRANSB, M2, N2, BI, Bpi, LDB, Apr, INCX, ZERO, Cpi, INCY); + * if( mxIsComplex(A) ) { // (complex matrix) * (complex vector) + * xGEMV(PTRANSB, M2, N2, AIBI, Bpi, LDB, Api, INCX, ONE, Cpr, INCY); + * xGEMV(PTRANSB, M2, N2, AI, Bpr, LDB, Api, INCX, ONE, Cpi, INCY); + * } else { // (real matrix) * (complex vector) + * // already done + * } + * } else { + * if( mxIsComplex(A) ) { // (complex matrix) * (real vector) + * xGEMV(PTRANSB, M2, N2, AI, Bpr, LDB, Api, INCX, ZERO, Cpi, INCY); + * } else { // (real matrix) * (real vector) + * // already done + * } + * } */ + +/*----------------------------------------------------------------------------------------- + * Else if the second matrix is not transposed, then use calls to dot product instead + * (faster) because the matrix can be accessed as a series of contiguous column vectors. + *----------------------------------------------------------------------------------------- */ + + } else { + bpr = Bpr; + bpi = Bpi; + if( Bpi ) { + for( i=0; i<n; i++ ) { + z = RealKindDotProduct(k, Apr, Api, ai, bpr, bpi, bi, dot_method); + Cpr[i] = z.r; + Cpi[i] = z.i; + bpr += k; + bpi += k; + } + } else { /* (complex vector) * (real matrix) */ + if( Api ) { + for( i=0; i<n; i++ ) { + z = RealKindDotProduct(k, Apr, Api, ai, bpr, Bpi, bi, dot_method); + Cpr[i] = z.r; + Cpi[i] = z.i; + bpr += k; + } + } else { /* (real vector) * (real matrix) */ + for( i=0; i<n; i++ ) { + z = RealKindDotProduct(k, Apr, Api, ai, bpr, Bpi, bi, dot_method); + Cpr[i] = z.r; + bpr += k; + } + } + } + } + +/*--------------------------------------------------------------------------------- + * Matrix times matrix (M x K) * (K x N) with N small and first matrix transposed. + * Use dot product (faster) because the 1st matrix can be accessed as a series of + * contiguous column vectors. When the column size reaches about 8 then the memory + * access efficiency of the BLAS routines increases and this custom method is no + * longer faster. The number 8 is likely machine / implementation dependent. Only + * use this method if running in one of the 'SPEED' or 'LOOPS' type modes. + *--------------------------------------------------------------------------------- */ + + } else if( !(mtimesx_mode == MTIMESX_BLAS || mtimesx_mode == MTIMESX_MATLAB) && + n < 7 && (transa == 'T' || transa == 'C') && (transb == 'N' || transb == 'G') ) { + bpr = Bpr; + bpi = Bpi; + cpr = Cpr; + cpi = Cpi; + for( j=0; j<n; j++ ) { + apr = Apr; + api = Api; + for( i=0; i<m; i++ ) { + z = RealKindDotProduct(k, apr, api, ai, bpr, bpi, bi, dot_method); + *cpr++ = z.r; + if( cpi ) *cpi++ = z.i; + apr += k; + if( api ) api += k; + } + bpr += k; + if( bpi ) bpi += k; + } + +/*--------------------------------------------------------------------------------------------- + * Matrix times matrix (M x K) *(K x N) + *--------------------------------------------------------------------------------------------- */ + + } else { + +/*/-------------------------------------------------------------------------------------------- + * If Matrix product is actually the same matrix, use calls to the symmetric routines xSYRK and + * xSYR2K where possible. These only work on the lower or upper triangle part of the matrix, so + * we will have to fill out the other half manually, but even so this will be faster. Some of + * these will not match MATLAB exactly, so only run them in cases where matching is not required. + *--------------------------------------------------------------------------------------------- */ + + if( Apr == Bpr && ((transa == 'N' && transb == 'T') || + (transa == 'T' && transb == 'N')) ) { + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYRK) " and " TOKENSTRING(xSYR2K) "\n"); + } + xSYRK(UPLO, TRANSA, N, K, ONE, Apr, LDA, ZERO, Cpr, LDC); + if( Api ) { + xSYRK(UPLO, TRANSA, N, K, MINUSONE, Api, LDA, ONE, Cpr, LDC); + xSYR2K(UPLO,TRANSA, N, K, ONE, Api, LDA, Apr, LDA, ZERO, Cpi, LDC); + xFILLPOS(Cpi, n); + } + xFILLPOS(Cpr, n); + + } else if( Apr == Bpr && (!(mtimesx_mode == MTIMESX_BLAS || mtimesx_mode == MTIMESX_MATLAB) || + (!Api && !Bpi)) && + ((transa == 'G' && transb == 'C') || + (transa == 'C' && transb == 'G')) ) { + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYRK) " and " TOKENSTRING(xSYR2K) "\n"); + } + if( transa == 'G') ptransa = 'N'; + xSYRK(UPLO, PTRANSA, N, K, ONE, Apr, LDA, ZERO, Cpr, LDC); + if( Api ) { + xSYRK(UPLO, PTRANSA, N, K, MINUSONE, Api, LDA, ONE, Cpr, LDC); + xSYR2K(UPLO,PTRANSA, N, K, MINUSONE, Apr, LDA, Api, LDA, ZERO, Cpi, LDC); + xFILLPOS(Cpi, n); + } + xFILLPOS(Cpr, n); + + } else if( Apr == Bpr && ((transa == 'N' && transb == 'C') || + (transa == 'T' && transb == 'G' && + (!(mtimesx_mode == MTIMESX_BLAS || mtimesx_mode == MTIMESX_MATLAB) || + (!Api && !Bpi)))) ) { + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYRK) " and " TOKENSTRING(xGEMM) "\n"); + } + if( transb == 'G' ) ptransb = 'N'; + xSYRK(UPLO, TRANSA, N, K, ONE, Apr, LDA, ZERO, Cpr, LDC); + if( Api ) { + xSYRK(UPLO, TRANSA, N, K, ONE, Api, LDA, ONE, Cpr, LDC); + xGEMM(TRANSA, PTRANSB, M, N, K, ONE, Api, LDA, Apr, LDA, ZERO, Cpi, LDC); + xFILLNEG(Cpi, n); + } + xFILLPOS(Cpr, n); + + } else if( Apr == Bpr && ((transa == 'C' && transb == 'N') || + (transa == 'G' && transb == 'T' && + (!(mtimesx_mode == MTIMESX_BLAS || mtimesx_mode == MTIMESX_MATLAB) || + (!Api && !Bpi)))) ) { + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYRK) " and " TOKENSTRING(xGEMM) "\n"); + } + if( transa == 'G' ) ptransa = 'N'; + xSYRK(UPLO, PTRANSA, N, K, ONE, Apr, LDA, ZERO, Cpr, LDC); + if( Api ) { + xSYRK(UPLO, PTRANSA, N, K, ONE, Api, LDA, ONE, Cpr, LDC); + xGEMM(PTRANSA, TRANSB, M, N, K, ONE, Apr, LDA, Api, LDA, ZERO, Cpi, LDC); + xFILLNEG(Cpi, n); + } + xFILLPOS(Cpr, n); + +/*------------------------------------------------------------------------------------------- + * Else this is not a symmetric case, so just call the general matrix multiply routine xGEMM. + *------------------------------------------------------------------------------------------- */ + + } else { + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xGEMM) "\n"); + } + if( transa == 'G' ) ptransa = 'N'; + if( transb == 'G' ) ptransb = 'N'; + xGEMM(PTRANSA, PTRANSB, M, N, K, ONE, Apr, LDA, Bpr, LDB, ZERO, Cpr, LDC); + if( Bpi ) { + xGEMM(PTRANSA, PTRANSB, M, N, K, BI, Apr, LDA, Bpi, LDB, ZERO, Cpi, LDC); + if( Api ) { /* (complex matrix) * (complex matrix) */ + xGEMM(PTRANSA, PTRANSB, M, N, K, AIBI, Api, LDA, Bpi, LDB, ONE, Cpr, LDC); + xGEMM(PTRANSA, PTRANSB, M, N, K, AI, Api, LDA, Bpr, LDB, ONE, Cpi, LDC); + } else { /* (real matrix) * (complex matrix) + * already done */ + } + } else { + if( Api ) { /* (complex matrix) * (real matrix) */ + xGEMM(PTRANSA, PTRANSB, M, N, K, AI, Api, LDA, Bpr, LDB, ZERO, Cpi, LDC); + } else { /* (real matrix) * (real matrix) + * already done */ + } + } + +/* Alternate method ... doesn't match MATLAB exactly ... not up to date + * + * } else { + * if( transa == 'G' ) ptransa = 'N'; + * if( transb == 'G' ) ptransb = 'N'; + * xGEMM(PTRANSA, PTRANSB, M, N, K, ONE, Apr, LDA, Bpr, LDB, ZERO, Cpr, LDC); + * if( mxIsComplex(A) ) { + * xGEMM(PTRANSA, PTRANSB, M, N, K, AI, Api, LDA, Bpr, LDB, ZERO, Cpi, LDC); + * if( mxIsComplex(B) ) { // (complex matrix) * (complex matrix) + * xGEMM(PTRANSA, PTRANSB, M, N, K, AIBI, Api, LDA, Bpi, LDB, ONE, Cpr, LDC); + * xGEMM(PTRANSA, PTRANSB, M, N, K, BI, Apr, LDA, Bpi, LDB, ONE, Cpi, LDC); + * } else { // (complex matrix) * (real matrix) + * // already done + * } + * } else { + * if( mxIsComplex(B) ) { // (real matrix) * (complex matrix) + * xGEMM(PTRANSA, PTRANSB, M, N, K, BI, Apr, LDA, Bpi, LDB, ZERO, Cpi, LDC); + * } else { // (real matrix) * (real matrix) + * // already done + * } + * } */ + + } + } + +/*---------------------------------------------------------------------------- + * End Outer Loop to process all of the individual matrix multiplies. Increment + * the matrix pointers to point to the next pair of matrices to be multiplied. + *---------------------------------------------------------------------------- */ + + if( ip < p-1 ) { + j = 2; + while( ++Cindx[j] == Cdims[j] ) Cindx[j++] = 0; + Ap = Bp = 0; + Ablock = Asize; + Bblock = Bsize; + for( j=2; j<Cndim; j++ ) { + if( Cindx[j] < Adimz[j] ) Ap += Cindx[j] * Ablock; + Ablock *= Adimz[j]; + if( Cindx[j] < Bdimz[j] ) Bp += Cindx[j] * Bblock; + Bblock *= Bdimz[j]; + } + Apr = Apr0 + Ap; + if( Api ) Api = Api0 + Ap; + Bpr = Bpr0 + Bp; + if( Bpi ) Bpi = Bpi0 + Bp; + Cpr += Csize; + if( Cpi ) Cpi += Csize; + } + debug_message = 0; + } + + mxFree(Cindx); + mxFree(Cdims); + mxFree(Adimz); + mxFree(Bdimz); + +/*--------------------------------------------------------------------------------- + * If the imaginary part is all zero, then free it and set the pointer to NULL. + *--------------------------------------------------------------------------------- */ + + Cpi = mxGetImagData(C); + if( AllRealZero(Cpi, m*n*p) ) { + mxFree(Cpi); + mxSetImagData(C, NULL); + } + +/*--------------------------------------------------------------------------------- + * Done. + *--------------------------------------------------------------------------------- */ + + if( destroyA ) mxDestroyArray(A); + if( destroyB ) mxDestroyArray(B); + return result; + +} + +/*-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- */ + +/*-------------------------------------------------------------------------------------- + * Returns 1 (true) if all of the elements are zero. Returns 0 (false) if at least one + * of the elements is non-zero, or if the pointer to the data is NULL. + *-------------------------------------------------------------------------------------- */ + +int AllRealZero(RealKind *x, mwSignedIndex n) +{ + register mwSignedIndex i; + if( x == NULL ) return 0; + for(i=0; i<n; i++) { + if( x[i] != zero ) return 0; + } + return 1; +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + 0*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1P0TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + Cpi[i] = Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + 0*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1P0TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + Cpi[i] = -Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + 0*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1P0TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + *Cpi++ = *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + 0*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1P0TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + *Cpi++ = -(*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + 1*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1P1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + Cpi[i] = Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i] - Bpi[i]; + Cpi[i] = Bpr[i] + Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + 1*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1P1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + Cpi[i] = Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i] + Bpi[i]; + Cpi[i] = Bpr[i] - Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + 1*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1P1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + *Cpi++ = *bpr; + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr - *bpi; + *Cpi++ = *bpr + *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + 1*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1P1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + *Cpi++ = *bpr; + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr + *bpi; + *Cpi++ = *bpr - *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 - 1*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1M1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + Cpi[i] = -Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i] + Bpi[i]; + Cpi[i] = Bpi[i] - Bpr[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 - 1*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1M1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + Cpi[i] = -Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i] - Bpi[i]; + Cpi[i] = -Bpi[i] - Bpr[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 - 1*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1M1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + *Cpi++ = -(*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr + *bpi; + *Cpi++ = *bpi - *bpr; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 - 1*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1M1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + *Cpi++ = -(*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr - *bpi; + *Cpi++ = - *bpr - *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + ai*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ +void RealKindEqP1PxTimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + Cpi[i] = ai * Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i] - ai * Bpi[i]; + Cpi[i] = ai * Bpr[i] + Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + ai*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1PxTimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i]; + Cpi[i] = ai * Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = Bpr[i] + ai * Bpi[i]; + Cpi[i] = ai * Bpr[i] - Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + ai*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1PxTimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + *Cpi++ = ai * (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr - ai * (*bpi); + *Cpi++ = ai * (*bpr) + *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (1 + ai*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqP1PxTimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr; + *Cpi++ = ai * (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = *bpr + ai * (*bpi); + *Cpi++ = ai * (*bpr) - *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + 1*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1P1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i]; + Cpi[i] = Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i] - Bpi[i]; + Cpi[i] = Bpr[i] - Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + 1*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1P1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i]; + Cpi[i] = Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i] + Bpi[i]; + Cpi[i] = Bpr[i] + Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + 1*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1P1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr); + *Cpi++ = *bpr; + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr) - (*bpi); + *Cpi++ = *bpr - (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + 1*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1P1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr); + *Cpi++ = *bpr; + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr) + (*bpi); + *Cpi++ = *bpr + (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 - 1*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1M1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i]; + Cpi[i] = -Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i] + Bpi[i]; + Cpi[i] = -Bpi[i] - Bpr[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 - 1*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1M1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i]; + Cpi[i] = -Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i] - Bpi[i]; + Cpi[i] = Bpi[i] - Bpr[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 - 1*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1M1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr); + *Cpi++ = -(*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr) + (*bpi); + *Cpi++ = -(*bpr) - (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 - 1*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ +void RealKindEqM1M1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr); + *Cpi++ = -(*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr) - (*bpi); + *Cpi++ = -(*bpr) + (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + 0*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1P0TimesRealKindN(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i]; + Cpi[i] = -Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + 0*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1P0TimesRealKindG(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i]; + Cpi[i] = Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + 0*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1P0TimesRealKindT(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr); + *Cpi++ = -(*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + 0*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1P0TimesRealKindC(RealKind *Cpr, RealKind *Cpi, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr); + *Cpi++ = *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + ai*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1PxTimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = - Bpr[i]; + Cpi[i] = ai * Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i] - ai * Bpi[i]; + Cpi[i] = ai * Bpr[i] - Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + ai*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1PxTimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = - Bpr[i]; + Cpi[i] = ai * Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = -Bpr[i] + ai * Bpi[i]; + Cpi[i] = ai * Bpr[i] + Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + ai*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1PxTimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = - (*bpr); + *Cpi++ = ai * (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr) - ai * (*bpi); + *Cpi++ = ai * (*bpr) - *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (-1 + ai*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqM1PxTimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = - (*bpr); + *Cpi++ = ai * (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = -(*bpr) + ai * (*bpi); + *Cpi++ = ai * (*bpr) + *bpi; + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + 1*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxP1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i] - Bpi[i]; + Cpi[i] = Bpr[i] + ar * Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + 1*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxP1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i] + Bpi[i]; + Cpi[i] = Bpr[i] - ar * Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + 1*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxP1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + *Cpi++ = *bpr; + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr) - (*bpi); + *Cpi++ = (*bpr) + ar * (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + 1*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxP1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + *Cpi++ = *bpr; + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr) + (*bpi); + *Cpi++ = (*bpr) - ar * (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar - 1*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxM1TimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = - Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i] + Bpi[i]; + Cpi[i] = -Bpr[i] + ar * Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar - 1*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxM1TimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = - Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i] - Bpi[i]; + Cpi[i] = -Bpr[i] - ar * Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar - 1*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxM1TimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + *Cpi++ = - (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr) + (*bpi); + *Cpi++ = -(*bpr) + ar * (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar - 1*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxM1TimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + *Cpi++ = - (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr) - (*bpi); + *Cpi++ = -(*bpr) - ar * (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + 0*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxP0TimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = ar * Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + 0*i) * (Bpr - Bpi * i) */ +void RealKindEqPxP0TimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = -ar * Bpi[i]; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + 0*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxP0TimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + *Cpi++ = ar * (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + 0*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxP0TimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ar, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + *Cpi++ = -ar * (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + ai*i) * (Bpr + Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxPxTimesRealKindN(RealKind *Cpr, RealKind *Cpi, RealKind ar, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + if( ai == zero ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = ai * Bpr[i]; + } + } + } else { + if( ai == zero ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = ar * Bpi[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i] - ai * Bpi[i]; + Cpi[i] = ai * Bpr[i] + ar * Bpi[i]; + } + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + ai*i) * (Bpr - Bpi * i) + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxPxTimesRealKindG(RealKind *Cpr, RealKind *Cpi, RealKind ar, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSignedIndex n) +{ + register mwSignedIndex i; + + if( Bpi == NULL ) { + if( ai == zero ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = ai * Bpr[i]; + } + } + } else { + if( ai == zero ) { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i]; + Cpi[i] = -ar * Bpi[i]; + } + } else { + for(i=0; i<n; i++) { + Cpr[i] = ar * Bpr[i] + ai * Bpi[i]; + Cpi[i] = ai * Bpr[i] - ar * Bpi[i]; + } + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + ai*i) * (Bpr + Bpi * i)T + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxPxTimesRealKindT(RealKind *Cpr, RealKind *Cpi, RealKind ar, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + *Cpi++ = ai * (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr) - ai * (*bpi); + *Cpi++ = ai * (*bpr) + ar * (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * C = (ar + ai*i) * (Bpr + Bpi * i)C + *-------------------------------------------------------------------------------------- */ + +void RealKindEqPxPxTimesRealKindC(RealKind *Cpr, RealKind *Cpi, RealKind ar, RealKind ai, + RealKind *Bpr, RealKind *Bpi, mwSize m2, mwSize n2, mwSignedIndex p) +{ + register mwSize i, j; + RealKind *bpr, *Br = Bpr; + RealKind *bpi, *Bi = Bpi; + register mwSignedIndex ip; + + if( Bpi == NULL ) { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr); + *Cpi++ = ai * (*bpr); + bpr += m2; + } + Bpr++; + } + Br += m2 * n2; + } + } else { + for( ip=0; ip<p; ip++ ) { + Bpr = Br; + Bpi = Bi; + for( i=0; i<m2; i++ ) { + bpr = Bpr; + bpi = Bpi; + for( j=0; j<n2; j++ ) { + *Cpr++ = ar * (*bpr) + ai * (*bpi); + *Cpi++ = ai * (*bpr) - ar * (*bpi); + bpr += m2; + bpi += m2; + } + Bpr++; + Bpi++; + } + Br += m2 * n2; + Bi += m2 * n2; + } + } +} + +/*-------------------------------------------------------------------------------------- + * Fill the upper triangle with contents of the lower triangle + *-------------------------------------------------------------------------------------- */ + +void xFILLPOS(RealKind *Cpr, mwSignedIndex n) +{ + RealKind *source, *target; + register mwSignedIndex i, j; + + source = Cpr + 1; + target = Cpr + n; + for( i=1; i<n; i++ ) { + for( j=i; j<n; j++ ) { + *target = *source; + target += n; + source++; + } + source += i + 1; + target = source + n - 1; + } +} + +/*-------------------------------------------------------------------------------------- + * Add the -Cpr transpose to the current array + *-------------------------------------------------------------------------------------- */ + +void xFILLNEG(RealKind *Cpr, mwSignedIndex n) +{ + RealKind *source, *target; + register mwSignedIndex i, j; + + source = Cpr; + target = Cpr; + for( i=0; i<n; i++ ) { + for( j=i; j<n; j++ ) { + *target -= *source; + if( i != j ) { + *source = -(*target); + } + target += n; + source++; + } + source += i + 1; + target = source; + } +} + +/*------------------------------------------------------------------------------------------ + * Dot Product type calculation. For conjugate cases, where ai == -1 or bi == -1, use custom + * loops instead of doing the actual multply by ai or bi. Also, use loop unrolling to speed + * up the calculations and improve the accuracy. For PC WinXP, the balance between speed and + * accuracy seemed to be optimal at a blocksize of 10. If the MATLAB mode is set, then just + * duplicate the BLAS calls that MATLAB uses (slower since it accesses the variables twice). + *------------------------------------------------------------------------------------------ */ + +#ifdef _OPENMP + +/*------------------------------------------------------------------------------------------ + * Interface for OpenMP enabled compiling. + *------------------------------------------------------------------------------------------ */ + +struct RealKindComplex RealKindDotProduct(mwSignedIndex k, + RealKind *Apr, RealKind *Api, RealKind ai, + RealKind *Bpr, RealKind *Bpi, RealKind bi, + int dot_method) +{ + struct RealKindComplex RealKindZZ[OMP_DOT_ARRAY_SIZE]; + struct RealKindComplex z; + struct RealKindComplex *zz; + int i, j, n; + + if( dot_method != METHOD_LOOPS_OMP || + (mtimesx_mode == MTIMESX_SPEED_OMP && k < OMP_DOT_SMALL) ) { + if( debug_message ) { + if( dot_method == METHOD_BLAS ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xDOT) "\n"); + } else { + mexPrintf("MTIMESX: LOOPS dot product\n"); + } + debug_message = 0; + } + z = RealKindDotProductX(k, Apr, Api, ai, Bpr, Bpi, bi, dot_method); + } else { + if( debug_message ) { + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS dot product\n"); + debug_message = 0; + } + if( max_threads <= OMP_DOT_ARRAY_SIZE ) { + zz = RealKindZZ; + } else { + zz = mxMalloc(max_threads * sizeof(*zz)); + } + omp_set_dynamic(1); + #pragma omp parallel num_threads(max_threads) + { + RealKind *Apr_, *Api_, *Bpr_, *Bpi_; + mwSize k_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = k / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + k_ = k - offset; + } else { + k_ = blocksize; + } + Apr_ = Apr + offset; + if( Api ) { + Api_ = Api + offset; + } else { + Api_ = NULL; + } + Bpr_ = Bpr + offset; + if( Bpi ) { + Bpi_ = Bpi + offset; + } else { + Bpi_ = NULL; + } + zz[thread_num] = RealKindDotProductX(k_, Apr_, Api_, ai, Bpr_, Bpi_, bi, dot_method); + } + +/* Combine thread results in a pre-determined order, so result with same inputs will be the */ +/* same regardless of the order in which the threads execute and complete. Use a binary */ +/* reduction scheme to maintain accuracy. */ + + n = threads_used - 1; + while( n ) { + if( !(n & 1) ) { + zz[n-1].r += zz[n].r; + zz[n-1].i += zz[n].i; + n--; + } + for( i=0, j=0; i<n; i+=2, j++ ) { + zz[j].r = zz[i].r + zz[i+1].r; + zz[j].i = zz[i].i + zz[i+1].i; + } + n >>= 1; + } + z = zz[0]; +/* + z.r = zero; + z.i = zero; + for( i=0; i<threads_used; i++ ) { + z.r += zz[i].r; + z.i += zz[i].i; + } + +*/ + if( zz != RealKindZZ ) { + mxFree(zz); + } + } + return z; +} + +struct RealKindComplex RealKindDotProductX(mwSignedIndex k, + RealKind *Apr, RealKind *Api, RealKind ai, + RealKind *Bpr, RealKind *Bpi, RealKind bi, + int dot_method) + +#else + +/*------------------------------------------------------------------------------------------ + * Interface for non-OpenMP enabled compiling. + *------------------------------------------------------------------------------------------ */ + +struct RealKindComplex RealKindDotProduct(mwSignedIndex k, + RealKind *Apr, RealKind *Api, RealKind ai, + RealKind *Bpr, RealKind *Bpi, RealKind bi, + int dot_method) + +#endif + +{ + register double sr = 0.0, si = 0.0; + register mwSignedIndex i; + struct RealKindComplex z; + mwSignedIndex k10, inc = 1; + + if( dot_method == METHOD_BLAS ) { +#ifndef _OPENMP + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xDOT) "\n"); + debug_message = 0; + } +#endif + sr = xDOT( &k, Apr, &inc, Bpr, &inc ); + if( Api != NULL ) { + if( Api != Bpi || ai == bi ) { + si = xDOT( &k, Api, &inc, Bpr, &inc ) * ai; + } + if( Bpi != NULL ) { + sr -= xDOT( &k, Api, &inc, Bpi, &inc ) * ai * bi; + if( Api != Bpi ) { + si += xDOT( &k, Apr, &inc, Bpi, &inc ) * bi; + } else if( ai == bi ){ + si += si; + } + } + } else if( Bpi != NULL ) { + si = xDOT( &k, Apr, &inc, Bpi, &inc ) * bi; + } + z.r = (RealKind) sr; + z.i = (RealKind) si; + return z; + } + +#ifndef _OPENMP + if( debug_message ) { + mexPrintf("MTIMESX: LOOPS dot product\n"); + debug_message = 0; + } +#endif + k10 = k % 10; + if( Api != NULL ) { + if( Bpi != NULL ) { /* (complex vector) dot (complex vector) */ + if( ai == one ) { + if( bi == one ) { + if( Apr == Bpr ) { + + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Apr[i] - Api[i] * Api[i]; + si += Api[i] * Apr[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Apr[i ] - Api[i ] * Api[i ] + + Apr[i+1] * Apr[i+1] - Api[i+1] * Api[i+1] + + Apr[i+2] * Apr[i+2] - Api[i+2] * Api[i+2] + + Apr[i+3] * Apr[i+3] - Api[i+3] * Api[i+3] + + Apr[i+4] * Apr[i+4] - Api[i+4] * Api[i+4] + + Apr[i+5] * Apr[i+5] - Api[i+5] * Api[i+5] + + Apr[i+6] * Apr[i+6] - Api[i+6] * Api[i+6] + + Apr[i+7] * Apr[i+7] - Api[i+7] * Api[i+7] + + Apr[i+8] * Apr[i+8] - Api[i+8] * Api[i+8] + + Apr[i+9] * Apr[i+9] - Api[i+9] * Api[i+9]; + si += Api[i ] * Apr[i ] + + Api[i+1] * Apr[i+1] + + Api[i+2] * Apr[i+2] + + Api[i+3] * Apr[i+3] + + Api[i+4] * Apr[i+4] + + Api[i+5] * Apr[i+5] + + Api[i+6] * Apr[i+6] + + Api[i+7] * Apr[i+7] + + Api[i+8] * Apr[i+8] + + Api[i+9] * Apr[i+9]; + } + si += si; + + } else { + + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Bpr[i] - Api[i] * Bpi[i]; + si += Api[i] * Bpr[i] + Apr[i] * Bpi[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Bpr[i ] - Api[i ] * Bpi[i ] + + Apr[i+1] * Bpr[i+1] - Api[i+1] * Bpi[i+1] + + Apr[i+2] * Bpr[i+2] - Api[i+2] * Bpi[i+2] + + Apr[i+3] * Bpr[i+3] - Api[i+3] * Bpi[i+3] + + Apr[i+4] * Bpr[i+4] - Api[i+4] * Bpi[i+4] + + Apr[i+5] * Bpr[i+5] - Api[i+5] * Bpi[i+5] + + Apr[i+6] * Bpr[i+6] - Api[i+6] * Bpi[i+6] + + Apr[i+7] * Bpr[i+7] - Api[i+7] * Bpi[i+7] + + Apr[i+8] * Bpr[i+8] - Api[i+8] * Bpi[i+8] + + Apr[i+9] * Bpr[i+9] - Api[i+9] * Bpi[i+9]; + si += Api[i ] * Bpr[i ] + Apr[i ] * Bpi[i ] + + Api[i+1] * Bpr[i+1] + Apr[i+1] * Bpi[i+1] + + Api[i+2] * Bpr[i+2] + Apr[i+2] * Bpi[i+2] + + Api[i+3] * Bpr[i+3] + Apr[i+3] * Bpi[i+3] + + Api[i+4] * Bpr[i+4] + Apr[i+4] * Bpi[i+4] + + Api[i+5] * Bpr[i+5] + Apr[i+5] * Bpi[i+5] + + Api[i+6] * Bpr[i+6] + Apr[i+6] * Bpi[i+6] + + Api[i+7] * Bpr[i+7] + Apr[i+7] * Bpi[i+7] + + Api[i+8] * Bpr[i+8] + Apr[i+8] * Bpi[i+8] + + Api[i+9] * Bpr[i+9] + Apr[i+9] * Bpi[i+9]; + } + + } + } else { + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Bpr[i] + Api[i] * Bpi[i]; + si += Api[i] * Bpr[i] - Apr[i] * Bpi[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Bpr[i ] + Api[i ] * Bpi[i ] + + Apr[i+1] * Bpr[i+1] + Api[i+1] * Bpi[i+1] + + Apr[i+2] * Bpr[i+2] + Api[i+2] * Bpi[i+2] + + Apr[i+3] * Bpr[i+3] + Api[i+3] * Bpi[i+3] + + Apr[i+4] * Bpr[i+4] + Api[i+4] * Bpi[i+4] + + Apr[i+5] * Bpr[i+5] + Api[i+5] * Bpi[i+5] + + Apr[i+6] * Bpr[i+6] + Api[i+6] * Bpi[i+6] + + Apr[i+7] * Bpr[i+7] + Api[i+7] * Bpi[i+7] + + Apr[i+8] * Bpr[i+8] + Api[i+8] * Bpi[i+8] + + Apr[i+9] * Bpr[i+9] + Api[i+9] * Bpi[i+9]; + si += Api[i ] * Bpr[i ] - Apr[i ] * Bpi[i ] + + Api[i+1] * Bpr[i+1] - Apr[i+1] * Bpi[i+1] + + Api[i+2] * Bpr[i+2] - Apr[i+2] * Bpi[i+2] + + Api[i+3] * Bpr[i+3] - Apr[i+3] * Bpi[i+3] + + Api[i+4] * Bpr[i+4] - Apr[i+4] * Bpi[i+4] + + Api[i+5] * Bpr[i+5] - Apr[i+5] * Bpi[i+5] + + Api[i+6] * Bpr[i+6] - Apr[i+6] * Bpi[i+6] + + Api[i+7] * Bpr[i+7] - Apr[i+7] * Bpi[i+7] + + Api[i+8] * Bpr[i+8] - Apr[i+8] * Bpi[i+8] + + Api[i+9] * Bpr[i+9] - Apr[i+9] * Bpi[i+9]; + } + } + } else { + if( bi == one ) { + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Bpr[i] + Api[i] * Bpi[i]; + si += Apr[i] * Bpi[i] - Api[i] * Bpr[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Bpr[i ] + Api[i ] * Bpi[i ] + + Apr[i+1] * Bpr[i+1] + Api[i+1] * Bpi[i+1] + + Apr[i+2] * Bpr[i+2] + Api[i+2] * Bpi[i+2] + + Apr[i+3] * Bpr[i+3] + Api[i+3] * Bpi[i+3] + + Apr[i+4] * Bpr[i+4] + Api[i+4] * Bpi[i+4] + + Apr[i+5] * Bpr[i+5] + Api[i+5] * Bpi[i+5] + + Apr[i+6] * Bpr[i+6] + Api[i+6] * Bpi[i+6] + + Apr[i+7] * Bpr[i+7] + Api[i+7] * Bpi[i+7] + + Apr[i+8] * Bpr[i+8] + Api[i+8] * Bpi[i+8] + + Apr[i+9] * Bpr[i+9] + Api[i+9] * Bpi[i+9]; + si += Apr[i ] * Bpi[i ] - Api[i ] * Bpr[i ] + + Apr[i+1] * Bpi[i+1] - Api[i+1] * Bpr[i+1] + + Apr[i+2] * Bpi[i+2] - Api[i+2] * Bpr[i+2] + + Apr[i+3] * Bpi[i+3] - Api[i+3] * Bpr[i+3] + + Apr[i+4] * Bpi[i+4] - Api[i+4] * Bpr[i+4] + + Apr[i+5] * Bpi[i+5] - Api[i+5] * Bpr[i+5] + + Apr[i+6] * Bpi[i+6] - Api[i+6] * Bpr[i+6] + + Apr[i+7] * Bpi[i+7] - Api[i+7] * Bpr[i+7] + + Apr[i+8] * Bpi[i+8] - Api[i+8] * Bpr[i+8] + + Apr[i+9] * Bpi[i+9] - Api[i+9] * Bpr[i+9]; + } + } else { + + if( Apr == Bpr ) { + + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Apr[i] - Api[i] * Api[i]; + si -= Api[i] * Apr[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Apr[i ] - Api[i ] * Api[i ] + + Apr[i+1] * Apr[i+1] - Api[i+1] * Api[i+1] + + Apr[i+2] * Apr[i+2] - Api[i+2] * Api[i+2] + + Apr[i+3] * Apr[i+3] - Api[i+3] * Api[i+3] + + Apr[i+4] * Apr[i+4] - Api[i+4] * Api[i+4] + + Apr[i+5] * Apr[i+5] - Api[i+5] * Api[i+5] + + Apr[i+6] * Apr[i+6] - Api[i+6] * Api[i+6] + + Apr[i+7] * Apr[i+7] - Api[i+7] * Api[i+7] + + Apr[i+8] * Apr[i+8] - Api[i+8] * Api[i+8] + + Apr[i+9] * Apr[i+9] - Api[i+9] * Api[i+9]; + si -= Api[i ] * Apr[i ] + + Api[i+1] * Apr[i+1] + + Api[i+2] * Apr[i+2] + + Api[i+3] * Apr[i+3] + + Api[i+4] * Apr[i+4] + + Api[i+5] * Apr[i+5] + + Api[i+6] * Apr[i+6] + + Api[i+7] * Apr[i+7] + + Api[i+8] * Apr[i+8] + + Api[i+9] * Apr[i+9]; + } + si += si; + + } else { + + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Bpr[i] - Api[i] * Bpi[i]; + si -= Api[i] * Bpr[i] + Apr[i] * Bpi[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Bpr[i ] - Api[i ] * Bpi[i ] + + Apr[i+1] * Bpr[i+1] - Api[i+1] * Bpi[i+1] + + Apr[i+2] * Bpr[i+2] - Api[i+2] * Bpi[i+2] + + Apr[i+3] * Bpr[i+3] - Api[i+3] * Bpi[i+3] + + Apr[i+4] * Bpr[i+4] - Api[i+4] * Bpi[i+4] + + Apr[i+5] * Bpr[i+5] - Api[i+5] * Bpi[i+5] + + Apr[i+6] * Bpr[i+6] - Api[i+6] * Bpi[i+6] + + Apr[i+7] * Bpr[i+7] - Api[i+7] * Bpi[i+7] + + Apr[i+8] * Bpr[i+8] - Api[i+8] * Bpi[i+8] + + Apr[i+9] * Bpr[i+9] - Api[i+9] * Bpi[i+9]; + si -= Api[i ] * Bpr[i ] + Apr[i ] * Bpi[i ] + + Api[i+1] * Bpr[i+1] + Apr[i+1] * Bpi[i+1] + + Api[i+2] * Bpr[i+2] + Apr[i+2] * Bpi[i+2] + + Api[i+3] * Bpr[i+3] + Apr[i+3] * Bpi[i+3] + + Api[i+4] * Bpr[i+4] + Apr[i+4] * Bpi[i+4] + + Api[i+5] * Bpr[i+5] + Apr[i+5] * Bpi[i+5] + + Api[i+6] * Bpr[i+6] + Apr[i+6] * Bpi[i+6] + + Api[i+7] * Bpr[i+7] + Apr[i+7] * Bpi[i+7] + + Api[i+8] * Bpr[i+8] + Apr[i+8] * Bpi[i+8] + + Api[i+9] * Bpr[i+9] + Apr[i+9] * Bpi[i+9]; + } + + } + } + } + z.i = (RealKind) si; + } else { /* (complex vector) dot (real vector) */ + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Bpr[i]; + si += Api[i] * Bpr[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Bpr[i ] + + Apr[i+1] * Bpr[i+1] + + Apr[i+2] * Bpr[i+2] + + Apr[i+3] * Bpr[i+3] + + Apr[i+4] * Bpr[i+4] + + Apr[i+5] * Bpr[i+5] + + Apr[i+6] * Bpr[i+6] + + Apr[i+7] * Bpr[i+7] + + Apr[i+8] * Bpr[i+8] + + Apr[i+9] * Bpr[i+9]; + si += Api[i ] * Bpr[i ] + + Api[i+1] * Bpr[i+1] + + Api[i+2] * Bpr[i+2] + + Api[i+3] * Bpr[i+3] + + Api[i+4] * Bpr[i+4] + + Api[i+5] * Bpr[i+5] + + Api[i+6] * Bpr[i+6] + + Api[i+7] * Bpr[i+7] + + Api[i+8] * Bpr[i+8] + + Api[i+9] * Bpr[i+9]; + } + z.i = (RealKind) (si * ai); + } + } else { + if( Bpi != NULL ) { /* (real vector) dot (complex vector) */ + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Bpr[i]; + si += Apr[i] * Bpi[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Bpr[i ] + + Apr[i+1] * Bpr[i+1] + + Apr[i+2] * Bpr[i+2] + + Apr[i+3] * Bpr[i+3] + + Apr[i+4] * Bpr[i+4] + + Apr[i+5] * Bpr[i+5] + + Apr[i+6] * Bpr[i+6] + + Apr[i+7] * Bpr[i+7] + + Apr[i+8] * Bpr[i+8] + + Apr[i+9] * Bpr[i+9]; + si += Apr[i ] * Bpi[i ] + + Apr[i+1] * Bpi[i+1] + + Apr[i+2] * Bpi[i+2] + + Apr[i+3] * Bpi[i+3] + + Apr[i+4] * Bpi[i+4] + + Apr[i+5] * Bpi[i+5] + + Apr[i+6] * Bpi[i+6] + + Apr[i+7] * Bpi[i+7] + + Apr[i+8] * Bpi[i+8] + + Apr[i+9] * Bpi[i+9]; + } + z.i = (RealKind) (si * bi); + } else { /* (real vector) dot (real vector) */ + for( i=0; i<k10; i++ ) { + sr += Apr[i] * Bpr[i]; + } + for( i=k10; i<k; i+=10 ) { + sr += Apr[i ] * Bpr[i ] + + Apr[i+1] * Bpr[i+1] + + Apr[i+2] * Bpr[i+2] + + Apr[i+3] * Bpr[i+3] + + Apr[i+4] * Bpr[i+4] + + Apr[i+5] * Bpr[i+5] + + Apr[i+6] * Bpr[i+6] + + Apr[i+7] * Bpr[i+7] + + Apr[i+8] * Bpr[i+8] + + Apr[i+9] * Bpr[i+9]; + } + } + } + z.r = (RealKind) sr; + return z; +} + +/*---------------------------------------------------------------------------------------- + * Outer Product calculation. Use custom loops for all of the special cases involving + * conjugates and transposes to minimize the total number of operations involved. + *---------------------------------------------------------------------------------------- */ + +#ifdef _OPENMP + +/*------------------------------------------------------------------------------------------ + * Interface for OpenMP enabled compiling. + *------------------------------------------------------------------------------------------ */ + +void RealKindOuterProduct(mwSignedIndex m, mwSignedIndex n, + RealKind *Apr, RealKind *Api, char transa, + RealKind *Bpr, RealKind *Bpi, char transb, + RealKind *Cpr, RealKind *Cpi, int outer_method) +{ + int t; + RealKind ai, bi; + + t = max_threads; + if( n < t ) t = n; + if( outer_method != METHOD_LOOPS_OMP || + (mtimesx_mode == MTIMESX_SPEED_OMP && m*n < OMP_OUTER_SMALL) ) { + if( debug_message ) { + if( outer_method == METHOD_BLAS ) { + if( debug_message ) { + if( Apr != Bpr || 1 ) { /* Force calls to generic xGER instead of xSYR */ + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xGER) "\n"); + } else { + if( Api ) { + ai = ( transa == 'G' || transa == 'C' ) ? -one : one; + bi = ( transb == 'G' || transb == 'C' ) ? -one : one; + if( ai == bi ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYR) " and " TOKENSTRING(xSYR2) "\n"); + } else { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYR) " and " TOKENSTRING(xGER) "\n"); + } + } else { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYR) "\n"); + } + } + debug_message = 0; + } + } else { + mexPrintf("MTIMESX: LOOPS outer product\n"); + } + debug_message = 0; + } + RealKindOuterProductX(m, n, Apr, Api, transa, Bpr, Bpi, transb, Cpr, Cpi, outer_method); + } else { + if( debug_message ) { + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS outer product\n"); + debug_message = 0; + } + omp_set_dynamic(1); + #pragma omp parallel num_threads(t) + { + RealKind *Bpr_, *Bpi_, *Cpr_, *Cpi_; + mwSize n_, blocksize, offset; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + blocksize = n / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + n_ = n - offset; + } else { + n_ = blocksize; + } + Bpr_ = Bpr + offset; + if( Bpi ) { + Bpi_ = Bpi + offset; + } else { + Bpi_ = NULL; + } + Cpr_ = Cpr + offset * m; + if( Cpi ) { + Cpi_ = Cpi + offset * m; + } else { + Cpi_ = NULL; + } + RealKindOuterProductX(m, n_, Apr, Api, transa, Bpr_, Bpi_, transb, Cpr_, Cpi_, outer_method); + } + } +} + +void RealKindOuterProductX(mwSignedIndex m, mwSignedIndex n, + RealKind *Apr, RealKind *Api, char transa, + RealKind *Bpr, RealKind *Bpi, char transb, + RealKind *Cpr, RealKind *Cpi, int outer_method) + +#else + +/*------------------------------------------------------------------------------------------ + * Interface for non-OpenMP enabled compiling. + *------------------------------------------------------------------------------------------ */ + +void RealKindOuterProduct(mwSignedIndex m, mwSignedIndex n, + RealKind *Apr, RealKind *Api, char transa, + RealKind *Bpr, RealKind *Bpi, char transb, + RealKind *Cpr, RealKind *Cpi, int outer_method) + +#endif + +{ + register mwSignedIndex i, j; + mwSignedIndex kk; + mwSignedIndex inc = 1; + RealKind One = one; + RealKind ai, bi, aibi; + char uplo = 'L'; + + if( outer_method == METHOD_BLAS ) { + ai = ( transa == 'G' || transa == 'C' ) ? -one : one; + bi = ( transb == 'G' || transb == 'C' ) ? -one : one; + aibi = - ai * bi; + if( Apr != Bpr || 1 ) { /* Force calls to generic xGER instead of xSYR */ +#ifndef _OPENMP + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xGER) "\n"); + debug_message = 0; + } +#endif + xGER( M, N, ONE, Apr, INCX, Bpr, INCY, Cpr, M ); + if( Api ) { + xGER( M, N, AI, Api, INCX, Bpr, INCY, Cpi, M ); + if( Bpi ) { + xGER( M, N, AIBI, Api, INCX, Bpi, INCY, Cpr, M ); + xGER( M, N, BI, Apr, INCX, Bpi, INCY, Cpi, M ); + } + } else if( Bpi ) { + xGER( M, N, BI, Apr, INCX, Bpi, INCY, Cpi, M ); + } + } else { + xSYR( UPLO, M, ONE, Apr, INCX, Cpr, M ); + if( Api ) { + xSYR( UPLO, M, AIBI, Api, INCX, Cpr, M ); + if( ai == bi ) { +#ifndef _OPENMP + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYR) " and " TOKENSTRING(xSYR2) "\n"); + debug_message = 0; + } +#endif + xSYR2( UPLO, M, AI, Apr, INCX, Api, INCY, Cpi, M ); + xFILLPOS(Cpi, m); + } else { +#ifndef _OPENMP + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYR) " and " TOKENSTRING(xGER) "\n"); + debug_message = 0; + } +#endif + xGER( M, N, BI, Apr, INCX, Api, INCY, Cpi, M ); + xFILLNEG(Cpi, m); + } +#ifndef _OPENMP + } else { + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xSYR) "\n"); + debug_message = 0; + } +#endif + } + xFILLPOS(Cpr, m); + } + return; + } + +#ifndef _OPENMP + if( debug_message ) { + mexPrintf("MTIMESX: LOOPS outer product\n"); + debug_message = 0; + } +#endif + kk = 0; + if( Api ) { + if( Bpi ) { + if( (transa == 'C' || transa == 'G') && (transb == 'C' || transb == 'G') ) { + for( j=0; j<n; j++ ) { /* (ar + bi*i)(C or G) * (br + bi*i)(C or G) */ + for( i=0; i<m; i++ ) { + Cpr[kk] = Apr[i] * Bpr[j] - Api[i] * Bpi[j]; + Cpi[kk] = - Apr[i] * Bpi[j] - Api[i] * Bpr[j]; + kk++; + } + } + } else if( (transa == 'C' || transa == 'G') && (transb == 'N' || transb == 'T') ) { + for( j=0; j<n; j++ ) { /* (ar + bi*i)(C or G) * (br + bi*i)(N or T) */ + for( i=0; i<m; i++ ) { + Cpr[kk] = Apr[i] * Bpr[j] + Api[i] * Bpi[j]; + Cpi[kk] = Apr[i] * Bpi[j] - Api[i] * Bpr[j]; + kk++; + } + } + } else if( (transa == 'N' || transa == 'T') && (transb == 'C' || transb == 'G') ) { + for( j=0; j<n; j++ ) { /* (ar + bi*i)(N or T) * (br + bi*i)(C or G) */ + for( i=0; i<m; i++ ) { + Cpr[kk] = Apr[i] * Bpr[j] + Api[i] * Bpi[j]; + Cpi[kk] = Api[i] * Bpr[j] - Apr[i] * Bpi[j]; + kk++; + } + } + } else { /* (ar + bi*i)(N or T) * (br + bi*i)(N or T) */ + for( j=0; j<n; j++ ) { + for( i=0; i<m; i++ ) { + Cpr[kk] = Apr[i] * Bpr[j] - Api[i] * Bpi[j]; + Cpi[kk] = Apr[i] * Bpi[j] + Api[i] * Bpr[j]; + kk++; + } + } + } + } else { + if( transa == 'C' || transa == 'G' ) { + for( j=0; j<n; j++ ) { /* (ar + bi*i)(C or G) * (br)(N or T or C or G) */ + for( i=0; i<m; i++ ) { + Cpr[kk] = Apr[i] * Bpr[j]; + Cpi[kk] = - Api[i] * Bpr[j]; + kk++; + } + } + } else { + for( j=0; j<n; j++ ) { /* (ar + bi*i)(N or T) * (br)(N or T or C or G) */ + for( i=0; i<m; i++ ) { + Cpr[kk] = Apr[i] * Bpr[j]; + Cpi[kk] = Api[i] * Bpr[j]; + kk++; + } + } + } + } + } else { + if( Bpi ) { + if( transb == 'C' || transb == 'G' ) { + for( j=0; j<n; j++ ) { /* (ar)(N or T or C or G) * (br + bi*i)(C or G) */ + for( i=0; i<m; i++ ) { + Cpr[kk] = Apr[i] * Bpr[j]; + Cpi[kk] = - Apr[i] * Bpi[j]; + kk++; + } + } + } else { + for( j=0; j<n; j++ ) { /* (ar)(N or T or C or G) * (br + bi*i)(N or T) */ + for( i=0; i<m; i++ ) { + Cpr[kk] = Apr[i] * Bpr[j]; + Cpi[kk] = Apr[i] * Bpi[j]; + kk++; + } + } + } + } else { + for( j=0; j<n; j++ ) { /* (ar)(N or T or C or G) * (br)(N or T or C or G) */ + for( i=0; i<m; i++ ) { + Cpr[kk++] = Apr[i] * Bpr[j]; + } + } + } + } +} + +/*-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- */ + +mxArray *RealScalarTimesReal(mxArray *A, char transa, mwSize m1, mwSize n1, + mxArray *B, char transb, mwSize m2, mwSize n2) +{ + mwSize nzmax, Bndim, Cndim, Cp, p; + mwSize *Bdims, *Cdims; + mwSignedIndex mn, n, k; + mxArray *C, *result, *Bt = NULL; + RealKind *Apr, *Api, *Bpr, *Bpi, *Cpr, *Cpi; + RealKind ar, ai, br, bi, sr, si; + char trans; + mxComplexity complexflag; + mwIndex *jc; + int scalar_method; +/*----- */ + if( m2 == 1 && n2 == 1 ) { /* Make sure scalar is A and array is B */ + if( m1 == 1 && n1 == 1 ) { /* Check for scalar * scalar */ + if( debug_message ) { + mexPrintf("MTIMESX: Inline (scalar * scalar) code\n"); + debug_message = 0; + } + Apr = mxGetData(A); + ar = *Apr; + Api = mxGetImagData(A); + ai = Api ? *Api : zero; + if( transa == 'C' || transa == 'G' ) { + ai = -ai; + } + Bpr = mxGetData(B); + br = *Bpr; + Bpi = mxGetImagData(B); + bi = Bpi ? *Bpi : zero; + if( transb == 'C' || transb == 'G' ) { + bi = -bi; + } + sr = (RealKind) (((double)ar) * ((double)br) - ((double)ai) * ((double)bi)); + si = (RealKind) (((double)ar) * ((double)bi) + ((double)ai) * ((double)br)); + complexflag = (si == zero) ? mxREAL : mxCOMPLEX; + if( mxIsSparse(A) || mxIsSparse(B) ) { + result = mxCreateSparse(1, 1, 1, complexflag); + *mxGetIr(result) = 0; + jc = mxGetJc(result); + jc[0] = 0; + jc[1] = 1; + } else { + result = mxCreateNumericMatrix(1, 1, MatlabReturnType, complexflag); + } + Cpr = mxGetData(result); + *Cpr = (RealKind) sr; + if( complexflag == mxCOMPLEX ) { + Cpi = mxGetImagData(result); + *Cpi = (RealKind) si; + } + return result; + } else { + C = A; + A = B; + B = C; + trans = transa; + transa = transb; + transb = trans; + } + } + +/*-------------------------------------------------------------------------------------- + * Check for multiplying by 1 and no actual transpose or conjugate is involved. In this + * case just return a shared data copy, which is very fast since no data copying is done. + * Also, if there *is* a transpose but the first two dimensions are a vector and there + * is no actual conjugate involved, we can return a shared data copy with a slight + * modification of the dimensions ... just switch the first two. + *-------------------------------------------------------------------------------------- */ + + Apr = mxGetData(A); + Api = mxGetImagData(A); + ar = *Apr; + ai = Api ? ((transa == 'C' || transa == 'G') ? -(*Api) :*Api) : zero; + + Bpr = mxGetData(B); + Bpi = mxGetImagData(B); + Bndim = mxGetNumberOfDimensions(B); + Bdims = (mwSize *) mxGetDimensions(B); + + if( ar == one && ai == zero ) { + if( transb == 'N' || (transb == 'G' && Bpi == NULL) ) { + if( debug_message ) { + mexPrintf("MTIMESX: Shared data copy\n"); + } + result = mxCreateSharedDataCopy(B); + return result; + } else if( (Bdims[0] == 1 || Bdims[1] == 1) && (transb == 'T' || (transb == 'C' && Bpi == NULL)) ) { + if( debug_message ) { + mexPrintf("MTIMESX: Shared data copy\n"); + } + result = mxCreateSharedDataCopy(B); + Cdims = mxMalloc( Bndim * sizeof(*Cdims) ); + for( Cp=2; Cp<Bndim; Cp++) { + Cdims[Cp] = Bdims[Cp]; + } + Cdims[0] = Bdims[1]; + Cdims[1] = Bdims[0]; + mxSetDimensions(result,Cdims,Bndim); + mxFree(Cdims); + return result; + } + } + +/*-------------------------------------------------------------------------------------- + * For sparse matrix, do the transpose now and then do the scalar multiply. That way if + * B is real and A is complex we are only doing the transpose work on one array. + *-------------------------------------------------------------------------------------- */ + + if( (transb == 'T' || transb == 'C') && mxIsSparse(B) ) { + if( debug_message ) { + mexPrintf("MTIMESX: Callback to MATLAB to transpose a sparse matrix\n"); + } + mexCallMATLAB(1, &Bt, 1, &B, "transpose"); + B = Bt; + transb = (transb == 'T') ? 'N' : 'G'; + } + + if( mxIsSparse(B) ) { + jc = mxGetJc(B); + n2 = mxGetN(B); + n = jc[n2]; + } else { + n = mxGetNumberOfElements(B); + } + if( n < 0 ) { + mexErrMsgTxt("Number of elements too large ... overflows a signed integer"); + } + + complexflag = (n > 0 && (mxIsComplex(A) || mxIsComplex(B))) ? mxCOMPLEX : mxREAL; + +/*------------------------------------------------------------------------------- + * Construct the dimensions of the result. Also use the p variable to keep track + * of the total number of individual matrix multiples that are involved. The + * first two dimensions are simply the result of a single matrix multiply, with + * accouting for the transb pre-operation. The remaining dimensions are simply + * copied from B. + *------------------------------------------------------------------------------- */ + + Cndim = Bndim; + Cdims = mxMalloc( Cndim * sizeof(*Cdims) ); + if( transb == 'N' || transb == 'G' ) { + Cdims[0] = Bdims[0]; + Cdims[1] = Bdims[1]; + } else { + Cdims[0] = Bdims[1]; + Cdims[1] = Bdims[0]; + } + p = 1; + for( Cp=2; Cp<Cndim; Cp++) { + p *= (Cdims[Cp] = Bdims[Cp]); + } + +/*------------------------------------------------------------------------------ + * Create output array + *------------------------------------------------------------------------------ */ + + if( mxIsSparse(B) ) { + result = mxCreateSparse(Cdims[0], Cdims[1], n, complexflag); + memcpy(mxGetIr(result), mxGetIr(B), n * sizeof(mwIndex)); + memcpy(mxGetJc(result), mxGetJc(B), (n2+1) * sizeof(mwIndex)); + } else if( mxGetNumberOfElements(B) == 0 ) { + result = mxCreateNumericArray(Cndim, Cdims, MatlabReturnType, mxREAL); + mxFree(Cdims); + return result; + } else { + result = mxCreateNumericArray(Cndim, Cdims, MatlabReturnType, complexflag); + } + mxFree(Cdims); + C = result; + Cpr = mxGetData(C); + Cpi = mxGetImagData(C); + + m2 = Bdims[0]; + n2 = Bdims[1]; + mn = m2 * n2; + + if( n == 0 ) { /* If result is empty, just return right now */ + return result; + } + C = result; + Cpr = mxGetData(C); + Cpi = mxGetImagData(C); + Bpr = mxGetData(B); + Bpi = mxGetImagData(B); + +/*------------------------------------------------------------------------------------------------ + * Check for matlab flag. If set, then use a BLAS call for this function. + *------------------------------------------------------------------------------------------------ */ + +/* if( matlab ) { + * Future upgrade ... insert BLAS calls here and return? + * } */ + +/*------------------------------------------------------------------------------------------------ + * If the matrix is really a vector, then there is no need to do an actual transpose. We can + * simply strip the transpose operation away and rely on the dimensions to do the transpose. + *------------------------------------------------------------------------------------------------ */ + + if( m2 ==1 || n2 == 1 ) { + if( transb == 'T' ) transb = 'N'; + if( transb == 'C' ) transb = 'G'; + } + +/*---------------------------------------------------------------------------- + * Get scalar product method to use. + *---------------------------------------------------------------------------- */ + + switch( mtimesx_mode ) + { + case MTIMESX_BLAS: + scalar_method = METHOD_BLAS; + break; + case MTIMESX_LOOPS: + scalar_method = METHOD_LOOPS; + break; + case MTIMESX_LOOPS_OMP: + scalar_method = METHOD_LOOPS_OMP; + break; + case MTIMESX_SPEED_OMP: + if( max_threads > 1 ) { + scalar_method = METHOD_LOOPS_OMP; + break; + } + case MTIMESX_MATLAB: + case MTIMESX_SPEED: + if( ai != zero && Bpi ) { + scalar_method = METHOD_LOOPS; + } else { + scalar_method = METHOD_BLAS; + } + break; + } + +/*------------------------------------------------------------------------------------------------ + * Do the scalar multiply. + *------------------------------------------------------------------------------------------------ */ + + RealTimesScalar(Cpr, Cpi, Bpr, Bpi, transb, m2, n2, ar, ai, n, p, scalar_method); + +/*------------------------------------------------------------------------------------------- + * If the imaginary part is all zero, then free it and set the pointer to NULL. + *------------------------------------------------------------------------------------------- */ + + if( AllRealZero(Cpi, n) ) { + mxFree(Cpi); + Cpi = NULL; + mxSetImagData(C, NULL); + } + +/*------------------------------------------------------------------------------------------- + * Clean up sparse matrix and realloc if appropriate. + *------------------------------------------------------------------------------------------- */ + + if( mxIsSparse(C) ) { + nzmax = mxGetNzmax(C); + k = spclean(C); + if( k == 0 ) k = 1; + if( nzmax - k > REALLOCTOL ) { + if( debug_message ) { + mexPrintf("MTIMESX: Reallocate sparse matrix\n"); + } + mxSetPr(C, myRealloc(Cpr, k * sizeof(RealKind))); + mxSetIr(C, myRealloc(mxGetIr(C), k * sizeof(mwIndex))); + if( Cpi != NULL ) { + mxSetPi(C, myRealloc(Cpi, k * sizeof(RealKind))); + } + mxSetNzmax(C, k); + } + } + if( Bt != NULL ) { + mxDestroyArray(Bt); + } + + return result; +} + +/*-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- + *-------------------------------------------------------------------------------------- */ + +/*------------------------------------------------------------------------------------------- + * Scalar times array slice. + *------------------------------------------------------------------------------------------- */ + +/*------------------------------------------------------------------------------------------- + * OpenMP interface. + *------------------------------------------------------------------------------------------- */ + +#ifdef _OPENMP + +void RealTimesScalar(RealKind *Cpr, RealKind *Cpi, RealKind *Bpr, RealKind *Bpi, char transb, + mwSize m2, mwSize n2, RealKind ar, RealKind ai, mwSize n, mwSize p, + int scalar_method) +{ + mwSize q; + + if( transb == 'N' || transb == 'G' ) { + q = n; + } else { + q = m2 * n2; + } + +/*------------------------------------------------------------------------------------------------ + * For small sizes, don't bother with the OpenMP overhead unless forced. + *------------------------------------------------------------------------------------------------ */ + + if( scalar_method != METHOD_LOOPS_OMP || + (mtimesx_mode == MTIMESX_SPEED_OMP && q < OMP_SCALAR_SMALL) ) { + if( debug_message ) { + if( scalar_method == METHOD_BLAS && (transb == 'N' || transb == 'G') ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xAXPY) "\n"); + } else { + mexPrintf("MTIMESX: LOOPS scalar multiply\n"); + } + debug_message = 0; + } + RealTimesScalarX(Cpr, Cpi, Bpr, Bpi, transb, m2, n2, ar, ai, n, p, scalar_method); + } else { + if( debug_message ) { + mexPrintf("MTIMESX: OpenMP multi-threaded LOOPS scalar multiply\n"); + debug_message = 0; + } + omp_set_dynamic(1); + #pragma omp parallel num_threads(max_threads) + { + RealKind *Cpr_, *Cpi_, *Bpr_, *Bpi_; + mwSize n_, p_, blocksize, offset, f; + int thread_num = omp_get_thread_num(); + int num_threads = omp_get_num_threads(); + #pragma omp master + { + threads_used = num_threads; + } + if( transb == 'N' || transb == 'G' ) { + blocksize = n / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + n_ = n - offset; + } else { + n_ = blocksize; + } + f = offset; + } else { + blocksize = p / num_threads; + offset = thread_num * blocksize; + if( thread_num == num_threads-1 ) { + p_ = p - offset; + } else { + p_ = blocksize; + } + f = offset * m2 * n2; + } + Cpr_ = Cpr + f; + if( Cpi ) { + Cpi_ = Cpi + f; + } else { + Cpi_ = NULL; + } + Bpr_ = Bpr + f; + if( Bpi ) { + Bpi_ = Bpi + f; + } else { + Bpi_ = NULL; + } + RealTimesScalarX(Cpr_, Cpi_, Bpr_, Bpi_, transb, m2, n2, ar, ai, n_, p_, scalar_method); + } + } +} + +void RealTimesScalarX(RealKind *Cpr, RealKind *Cpi, RealKind *Bpr, RealKind *Bpi, char transb, + mwSize m2, mwSize n2, RealKind ar, RealKind ai, mwSize n, mwSize p, + int scalar_method) + +#else + +/*------------------------------------------------------------------------------------------- + * Non-OpenMP interface. + *------------------------------------------------------------------------------------------- */ + +void RealTimesScalar(RealKind *Cpr, RealKind *Cpi, RealKind *Bpr, RealKind *Bpi, char transb, + mwSize m2, mwSize n2, RealKind ar, RealKind ai, mwSize n, mwSize p, + int scalar_method) + +#endif + +{ + mwSignedIndex inc = 1, k = n; + +/*------------------------------------------------------------------------------------------------ + * If scalar multiply mode is BLAS mode and there is no actual transpose involved then do the + * BLAS calls now. + *------------------------------------------------------------------------------------------------ */ + + if( scalar_method == METHOD_BLAS && (transb == 'N' || transb == 'G') ) { +#ifndef _OPENMP + if( debug_message ) { + mexPrintf("MTIMESX: BLAS calls to " TOKENSTRING(xAXPY) "\n"); + debug_message = 0; + } +#endif + xAXPY( K, AR, Bpr, INCX, Cpr, INCY ); + if( Cpi ) { + if( ai != zero ) { + xAXPY( K, AI, Bpr, INCX, Cpi, INCY ); + if( Bpi ) { + if( transb == 'N' ) ai = -ai; + xAXPY( K, AI, Bpi, INCX, Cpr, INCY ); + } + } + if( Bpi ) { + if( transb == 'G' ) ar = -ar; + xAXPY( K, AR, Bpi, INCX, Cpi, INCY ); + } + } + return; + } + +/*------------------------------------------------------------------------------------------------ + * Some specialized cases, no need to multiply by +1 or -1, we can program that directly into the + * calculations without a multiply. We do need to multiply by zero, however, so that the sign of + * any -0 that might be present gets carried over into the result, and also any inf or NaN that is + * present gets a proper result. So no special code for multiplying by zero. + *------------------------------------------------------------------------------------------------ */ + +#ifndef _OPENMP + if( debug_message ) { + mexPrintf("MTIMESX: LOOPS scalar multiply\n"); + debug_message = 0; + } +#endif + if( ar == one ) { + if( ai == one ) { + if( transb == 'N' ) { + RealKindEqP1P1TimesRealKindN(Cpr, Cpi, Bpr, Bpi, n); /* C = (1 + 1*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqP1P1TimesRealKindG(Cpr, Cpi, Bpr, Bpi, n); /* C = (1 + 1*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqP1P1TimesRealKindT(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (1 + 1*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqP1P1TimesRealKindC(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (1 + 1*i) * (Bpr + Bpi * i)C */ + } + } else if( ai == -one ) { + if( transb == 'N' ) { + RealKindEqP1M1TimesRealKindN(Cpr, Cpi, Bpr, Bpi, n); /* C = (1 - 1*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqP1M1TimesRealKindG(Cpr, Cpi, Bpr, Bpi, n); /* C = (1 - 1*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqP1M1TimesRealKindT(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (1 - 1*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqP1M1TimesRealKindC(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (1 - 1*i) * (Bpr + Bpi * i)C */ + } + } else if( ai == zero ) { + if( transb == 'N' ) { /* this case never reached ... it is the shared data copy above */ + RealKindEqP1P0TimesRealKindN(Cpr, Cpi, Bpr, Bpi, n); /* C = (1 + 0*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqP1P0TimesRealKindG(Cpr, Cpi, Bpr, Bpi, n); /* C = (1 + 0*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqP1P0TimesRealKindT(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (1 + 0*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqP1P0TimesRealKindC(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (1 + 0*i) * (Bpr + Bpi * i)C */ + } + } else { + if( transb == 'N' ) { + RealKindEqP1PxTimesRealKindN(Cpr, Cpi, ai, Bpr, Bpi, n); /* C = (1 + ai*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqP1PxTimesRealKindG(Cpr, Cpi, ai, Bpr, Bpi, n); /* C = (1 + ai*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqP1PxTimesRealKindT(Cpr, Cpi, ai, Bpr, Bpi, m2, n2, p); /* C = (1 + ai*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqP1PxTimesRealKindC(Cpr, Cpi, ai, Bpr, Bpi, m2, n2, p); /* C = (1 + ai*i) * (Bpr + Bpi * i)C */ + } + } + } else if( ar == -one ) { + if( ai == one ) { + if( transb == 'N' ) { + RealKindEqM1P1TimesRealKindN(Cpr, Cpi, Bpr, Bpi, n); /* C = (-1 + 1*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqM1P1TimesRealKindG(Cpr, Cpi, Bpr, Bpi, n); /* C = (-1 + 1*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqM1P1TimesRealKindT(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (-1 + 1*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqM1P1TimesRealKindC(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (-1 + 1*i) * (Bpr + Bpi * i)C */ + } + } else if( ai == -one ) { + if( transb == 'N' ) { + RealKindEqM1M1TimesRealKindN(Cpr, Cpi, Bpr, Bpi, n); /* C = (-1 - 1*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqM1M1TimesRealKindG(Cpr, Cpi, Bpr, Bpi, n); /* C = (-1 - 1*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqM1M1TimesRealKindT(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (-1 - 1*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqM1M1TimesRealKindC(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (-1 - 1*i) * (Bpr + Bpi * i)C */ + } + } else if( ai == zero ) { + if( transb == 'N' ) { + RealKindEqM1P0TimesRealKindN(Cpr, Cpi, Bpr, Bpi, n); /* C = (-1 + 0*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqM1P0TimesRealKindG(Cpr, Cpi, Bpr, Bpi, n); /* C = (-1 + 0*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqM1P0TimesRealKindT(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (-1 + 0*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqM1P0TimesRealKindC(Cpr, Cpi, Bpr, Bpi, m2, n2, p); /* C = (-1 + 0*i) * (Bpr + Bpi * i)C */ + } + } else { + if( transb == 'N' ) { + RealKindEqM1PxTimesRealKindN(Cpr, Cpi, ai, Bpr, Bpi, n); /* C = (-1 + ai*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqM1PxTimesRealKindG(Cpr, Cpi, ai, Bpr, Bpi, n); /* C = (-1 + ai*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqM1PxTimesRealKindT(Cpr, Cpi, ai, Bpr, Bpi, m2, n2, p); /* C = (-1 + ai*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqM1PxTimesRealKindC(Cpr, Cpi, ai, Bpr, Bpi, m2, n2, p); /* C = (-1 + ai*i) * (Bpr + Bpi * i)C */ + } + } + } else { /* ar != one && ar != -one */ + if( ai == one ) { + if( transb == 'N' ) { + RealKindEqPxP1TimesRealKindN(Cpr, Cpi, ar, Bpr, Bpi, n); /* C = (ar + 1*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqPxP1TimesRealKindG(Cpr, Cpi, ar, Bpr, Bpi, n); /* C = (ar + 1*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqPxP1TimesRealKindT(Cpr, Cpi, ar, Bpr, Bpi, m2, n2, p); /* C = (ar + 1*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqPxP1TimesRealKindC(Cpr, Cpi, ar, Bpr, Bpi, m2, n2, p); /* C = (ar + 1*i) * (Bpr + Bpi * i)C */ + } + } else if( ai == -one ) { + if( transb == 'N' ) { + RealKindEqPxM1TimesRealKindN(Cpr, Cpi, ar, Bpr, Bpi, n); /* C = (ar - 1*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqPxM1TimesRealKindG(Cpr, Cpi, ar, Bpr, Bpi, n); /* C = (ar - 1*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqPxM1TimesRealKindT(Cpr, Cpi, ar, Bpr, Bpi, m2, n2, p); /* C = (ar - 1*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqPxM1TimesRealKindC(Cpr, Cpi, ar, Bpr, Bpi, m2, n2, p); /* C = (ar - 1*i) * (Bpr + Bpi * i)C */ + } + } else if( ai == zero ) { + if( transb == 'N' ) { + RealKindEqPxP0TimesRealKindN(Cpr, Cpi, ar, Bpr, Bpi, n); /* C = (ar + 0*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqPxP0TimesRealKindG(Cpr, Cpi, ar, Bpr, Bpi, n); /* C = (ar + 0*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqPxP0TimesRealKindT(Cpr, Cpi, ar, Bpr, Bpi, m2, n2, p); /* C = (ar + 0*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqPxP0TimesRealKindC(Cpr, Cpi, ar, Bpr, Bpi, m2, n2, p); /* C = (ar + 0*i) * (Bpr + Bpi * i)C */ + } + } else { + if( transb == 'N' ) { + RealKindEqPxPxTimesRealKindN(Cpr, Cpi, ar, ai, Bpr, Bpi, n); /* C = (ar + ai*i) * (Bpr + Bpi * i) */ + } else if( transb == 'G' ) { + RealKindEqPxPxTimesRealKindG(Cpr, Cpi, ar, ai, Bpr, Bpi, n); /* C = (ar + ai*i) * (Bpr - Bpi * i) */ + } else if( transb == 'T' ) { + RealKindEqPxPxTimesRealKindT(Cpr, Cpi, ar, ai, Bpr, Bpi, m2, n2, p); /* C = (ar + ai*i) * (Bpr + Bpi * i)T */ + } else { /* if( transb == 'C' ) { */ + RealKindEqPxPxTimesRealKindC(Cpr, Cpi, ar, ai, Bpr, Bpi, m2, n2, p); /* C = (ar + ai*i) * (Bpr + Bpi * i)C */ + } + } + } +} diff --git a/ext/mtimesx/mtimesx_build.m b/ext/mtimesx/mtimesx_build.m new file mode 100644 index 0000000000000000000000000000000000000000..94d858405a5a0ed46dc6e07f2175410b80cd05ef --- /dev/null +++ b/ext/mtimesx/mtimesx_build.m @@ -0,0 +1,475 @@ +% mtimesx_build compiles mtimesx.c with BLAS libraries +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_build +% Filename: mtimesx_build.m +% Programmer: James Tursa +% Version: 1.40 +% Date: October 4, 2010 +% Copyright: (c) 2009, 2010 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +%-- +% +% mtimesx_build compiles mtimesx.c and mtimesx_RealTimesReal.c with the BLAS +% libraries libmwblas.lib (if present) or libmwlapack.lib (if libmwblas.lib +% is not present). This function basically works as follows: +% +% - Opens the current mexopts.bat file in the directory [prefdir], and +% checks to make sure that the compiler selected is cl or lcc. If it +% is not, then a warning is issued and the compilation continues with +% the assumption that the microsoft BLAS libraries will work. +% +% - Looks for the file libmwblas.lib or libmwlapack.lib files in the +% appropriate directory: [matlabroot '\extern\lib\win32\microsoft'] +% or [matlabroot '\extern\lib\win32\lcc'] +% or [matlabroot '\extern\lib\win64\microsoft'] +% or [matlabroot '\extern\lib\win64\lcc'] +% +% - Changes directory to the directory of the file mtimesx.m. +% +% - Compiles mtimesx.c (which includes mtimesx_RealTimesReal.c) along with +% either libmwblas.lib or libmwlapack.lib depending on the version of +% MATLAB. The resulting exedcutable mex file is placed in the same +% directory as the source code. The files mtimesx.m, mtimesx.c, and +% mtimesx_RealTimesReal.c must all be in the same directory. +% +% - Changes the directory back to the original directory. +% +% Change Log: +% 2009/Sep/27 --> 1.00, Initial Release +% 2010/Feb/15 --> 1.10, Fixed largearrardims typo to largeArrayDims +% 2010/Oct/04 --> 1.40, Updated support for OpenMP compiling +% +%************************************************************************** + +function mtimesx_build(x) +disp(' '); +disp('... Build routine for mtimesx'); + +TRUE = 1; +FALSE = 0; + +%\ +% Check for number of inputs & outputs +%/ + +noopenmp = FALSE; +if( nargin == 1 ) + if( isequal(upper(x),'NOOPENMP') ) + noopenmp = TRUE; + else + error('Invalid input.'); + end +elseif( nargin ~= 0 ) + error('Too many inputs. Expected none.'); +end +if( nargout ~= 0 ) + error('Too many outputs. Expected none.'); +end + +%\ +% Check for non-PC +%/ + +disp('... Checking for PC'); +try + % ispc does not appear in MATLAB 5.3 + pc = ispc ; +catch + % if ispc fails, assume we are on a Windows PC if it's not unix + pc = ~isunix ; +end + +if( ~pc ) + disp('Non-PC auto build is not currently supported. You will have to'); + disp('manually compile the mex routine. E.g., as follows:'); + disp(' '); + disp('>> blas_lib = ''the_actual_path_and_name_of_your_systems_BLAS_library'''); + disp('>> mex(''-DDEFINEUNIX'',''mtimesx.c'',blas_lib)'); + disp(' '); + disp('or'); + disp(' '); + disp('>> mex(''-DDEFINEUNIX'',''-largeArrayDims'',''mtimesx.c'',blas_lib)'); + disp(' '); + error('Unable to compile mtimesx.c'); +end + +%\ +% Check to see that mtimesx.c source code is present +%/ + +disp('... Finding path of mtimesx C source code files'); +try + mname = mfilename('fullpath'); +catch + mname = mfilename; +end +cname = [mname(1:end-6) '.c']; +if( isempty(dir(cname)) ) + disp('Cannot find the file mtimesx.c in the same directory as the'); + disp('file mtimesx_build.m. Please ensure that they are in the same'); + disp('directory and try again. The following file was not found:'); + disp(' '); + disp(cname); + disp(' '); + error('Unable to compile mtimesx.c'); +end +disp(['... Found file mtimesx.c in ' cname]); + +%\ +% Check to see that mtimesx_RealTimesReal.c source code is present +%/ + +rname = [mname(1:end-13) 'mtimesx_RealTimesReal.c']; +if( isempty(dir(rname)) ) + disp('Cannot find the file mtimesx_RealTimesReal.c in the same'); + disp('directory as the file mtimesx_build.m. Please ensure that'); + disp('they are in the same directory and try again. The'); + disp('following file was not found:'); + disp(' '); + disp(rname); + disp(' '); + error('Unable to compile mtimesx.c'); +end +disp(['... Found file mtimesx_RealTimesReal.c in ' rname]); + +%\ +% Open the current mexopts.bat file +%/ + +mexopts = [prefdir '\mexopts.bat']; +fid = fopen(mexopts); +if( fid == -1 ) + error('A C/C++ compiler has not been selected with mex -setup'); +end +disp(['... Opened the mexopts.bat file in ' mexopts]); +disp('... Reading the mexopts.bat file to find the compiler and options used.'); + +%\ +% Check for the correct compiler selected. +%/ + +ok_cl = FALSE; +ok_lcc = FALSE; +omp_option = ''; +compiler = '(unknown)'; +compilername = ''; +while( TRUE ) + tline = fgets(fid); + if( isequal(tline,-1) ) + break; + else + if( isempty(compilername) ) + y = findstr(tline,'OPTS.BAT'); + if( ~isempty(y) ) + x = findstr(tline,'rem '); + if( ~isempty(x) ) + compilername = tline(x+4:y-1); + end + end + end + x = findstr(tline,'COMPILER=lcc'); + if( ~isempty(x) ) + ok_lcc = TRUE; + libdir = 'lcc'; + compiler = 'LCC'; + disp(['... ' compiler ' is the selected compiler']); + break; + end + x = findstr(tline,'COMPILER=cl'); + if( ~isempty(x) ) + ok_cl = TRUE; + libdir = 'microsoft'; + compiler = ['Microsoft_' compilername '_cl']; + omp_option = ' /openmp'; + disp(['... ' compiler ' is the selected compiler']); + break; + end + x = findstr(tline,'COMPILER=bcc32'); + if( ~isempty(x) ) + ok_cl = TRUE; + libdir = 'microsoft'; + compiler = ['Borland_' compilername '_bcc32']; + disp(['... ' compiler ' is the selected compiler']); + disp('... Assuming that Borland will link with Microsoft libraries'); + break; + end + x = findstr(tline,'COMPILER=icl'); + if( ~isempty(x) ) + ok_cl = TRUE; + if( pc ) + omp_option = ' -Qopenmp'; + else + omp_option = ' -openmp'; + end + libdir = 'microsoft'; + compiler = ['Intel_' compilername '_icl']; + disp(['... ' compiler ' is the selected compiler']); + disp('... Assuming that Intel will link with Microsoft libraries'); + break; + end + x = findstr(tline,'COMPILER=wc1386'); + if( ~isempty(x) ) + ok_cl = TRUE; + libdir = 'microsoft'; + compiler = ['Watcom_' compilername '_wc1386']; + disp(['... ' compiler ' is the selected compiler']); + disp('... Assuming that Watcom will link with Microsoft libraries'); + break; + end + x = findstr(tline,'COMPILER=gcc'); + if( ~isempty(x) ) + ok_cl = TRUE; + libdir = 'microsoft'; + omp_option = ' -fopenmp'; + compiler = 'GCC'; + disp(['... ' compiler ' is the selected compiler']); + disp('... Assuming that GCC will link with Microsoft libraries'); + break; + end + end +end +fclose(fid); + +%\ +% MS Visual C/C++ or lcc compiler has not been selected +%/ + +if( ~(ok_cl | ok_lcc) ) + warning('... Supported C/C++ compiler has not been selected with mex -setup'); + warning('... Assuming that Selected Compiler will link with Microsoft libraries'); + warning('... Continuing at risk ...'); + libdir = 'microsoft'; +end + +%\ +% If an OpenMP supported compiler is potentially present, make sure that the +% necessary compile option is present in the mexopts.bat file on the COMPFLAGS +% line. If necessary, build a new mexopts.bat file with the correct option +% added to the COMPFLAGS line. +%/ + +while( TRUE ) +ok_openmp = FALSE; +ok_compflags = FALSE; +xname = ''; +if( isempty(omp_option) ) + disp('... OpenMP compiler not detected ... you may want to check this website:'); + disp(' http://openmp.org/wp/openmp-compilers/'); +elseif( noopenmp ) + disp(['... OpenMP compiler potentially detected, but not checking for ''' omp_option ''' compile option']); +else + disp('... OpenMP compiler potentially detected'); + disp(['... Checking to see that the ''' omp_option ''' compile option is present']); + fid = fopen(mexopts); + while( TRUE ) + tline = fgets(fid); + if( isequal(tline,-1) ) + break; + else + x = findstr(tline,'set COMPFLAGS'); + if( ~isempty(x) ) + ok_compflags = TRUE; + x = findstr(tline,omp_option); + if( ~isempty(x) ) + ok_openmp = TRUE; + end + break; + end + end + end + fclose(fid); + if( ~ok_compflags ) + warning(['... COMPFLAGS line not found ... ''' omp_option ''' will not be added.']); + elseif( ~ok_openmp ) + disp(['... The ''' omp_option ''' compile option is not present ... adding it']); + xname = [mname(1:end-6) '_mexopts.bat']; + disp(['... Creating custom options file ' xname ' with the ''' omp_option ''' option added.']); + fid = fopen(mexopts); + fidx = fopen(xname,'w'); + if( fidx == -1 ) + xname = ''; + warning(['... Unable to create custom mexopts.bat file ... ''' omp_option ''' will not be added']); + else + while( TRUE ) + tline = fgets(fid); + if( isequal(tline,-1) ) + break; + else + x = findstr(tline,'set COMPFLAGS'); + if( ~isempty(x) ) + n = numel(tline); + e = n; + while( tline(e) < 32 ) + e = e - 1; + end + tline = [tline(1:e) omp_option tline(e+1:n)]; + end + fwrite(fidx,tline); + end + end + fclose(fidx); + end + fclose(fid); + end +end + +%\ +% Construct full file name of libmwblas.lib and libmwlapack.lib. Note that +% not all versions have both files. Earlier versions only had the lapack +% file, which contained both blas and lapack routines. +%/ + +comp = computer; +mext = mexext; +lc = length(comp); +lm = length(mext); +cbits = comp(max(1:lc-1):lc); +mbits = mext(max(1:lm-1):lm); +if( isequal(cbits,'64') | isequal(mbits,'64') ) + compdir = 'win64'; + largearraydims = '-largeArrayDims'; +else + compdir = 'win32'; + largearraydims = ''; +end + +lib_blas = [matlabroot '\extern\lib\' compdir '\' libdir '\libmwblas.lib']; +d = dir(lib_blas); +if( isempty(d) ) + disp('... BLAS library file not found, so linking with the LAPACK library'); + lib_blas = [matlabroot '\extern\lib\' compdir '\' libdir '\libmwlapack.lib']; +end +disp(['... Using BLAS library lib_blas = ''' lib_blas '''']); + +%\ +% Save old directory and change to source code directory +%/ + +cdold = cd; +if( length(mname) > 13 ) + cd(mname(1:end-13)); +end + +%\ +% Do the compile +%/ + +disp('... Now attempting to compile ...'); +disp(' '); +try + if( isunix ) + if( isempty(largearraydims) ) + if( isempty(xname) ) + disp(['mex(''-DDEFINEUNIX'',''' cname ''',lib_blas,''-DCOMPILER=' compiler ''')']); + disp(' '); + mex('-DDEFINEUNIX',cname,lib_blas,['-DCOMPILER=' compiler]); + else + disp(['mex(''-f'',''' xname ''',''-DDEFINEUNIX'',''' cname ''',lib_blas,''-DCOMPILER=' compiler ''')']); + disp(' '); + mex('-f',xname,'-DDEFINEUNIX',cname,lib_blas,['-DCOMPILER=' compiler]); + end + else + if( isempty(xname) ) + disp(['mex(''-DDEFINEUNIX'',''' cname ''',''' largearraydims ''',lib_blas,''-DCOMPILER=' compiler ''')']); + disp(' '); + mex('-DDEFINEUNIX',largearraydims,cname,lib_blas,['-DCOMPILER=' compiler]); + else + disp(['mex(''-f'',''' xname ''',''-DDEFINEUNIX'',''' cname ''',''' largearraydims ''',lib_blas,''-DCOMPILER=' compiler ''')']); + disp(' '); + mex('-f',xname,'-DDEFINEUNIX',largearraydims,cname,lib_blas,['-DCOMPILER=' compiler]); + end + end + else + if( isempty(largearraydims) ) + if( isempty(xname) ) + disp(['mex(''' cname ''',lib_blas,''-DCOMPILER=' compiler ''')']); + disp(' '); + mex(cname,lib_blas,['-DCOMPILER=' compiler]); + else + disp(['mex(''-f'',''' xname ''',''' cname ''',lib_blas,''-DCOMPILER=' compiler ''')']); + disp(' '); + mex('-f',xname,cname,lib_blas,['-DCOMPILER=' compiler]); + end + else + if( isempty(xname) ) + disp(['mex(''' cname ''',''' largearraydims ''',lib_blas,''-DCOMPILER=' compiler ''')']); + disp(' '); + mex(cname,largearraydims,lib_blas,['-DCOMPILER=' compiler]); + else + disp(['mex(''-f'',''' xname ''',''' cname ''',''' largearraydims ''',lib_blas,''-DCOMPILER=' compiler ''')']); + disp(' '); + mex('-f',xname,cname,largearraydims,lib_blas,['-DCOMPILER=' compiler]); + end + end + end + disp('... mex mtimesx.c build completed ... you may now use mtimesx.'); + disp(' '); + mtimesx; + break; +catch + if( noopenmp ) + cd(cdold); + disp(' '); + disp('... Well, *that* didn''t work either!'); + disp(' '); + disp('The mex command failed. This may be because you have already run'); + disp('mex -setup and selected a non-C compiler, such as Fortran. If this'); + disp('is the case, then rerun mex -setup and select a C/C++ compiler.'); + disp(' '); + error('Unable to compile mtimesx.c'); + else + disp(' '); + disp('... Well, *that* didn''t work ...'); + disp(' '); + if( isequal(omp_option,' /openmp') ) + disp('This may be because an OpenMP compile option was added that the'); + disp('compiler did not like. For example, the Standard versions of the'); + disp('Microsoft C/C++ compilers do not support OpenMP, only the'); + disp('Professional versions do. Attempting to compile again but this'); + disp(['time will not add the ''' omp_option ''' option.']) + else + disp('This may be because an OpenMP compile option was added that the'); + disp('compiler did not like. Attempting to compile again, but this time'); + disp(['will not add the ''' omp_option ''' option.']) + end + disp(' '); + noopenmp = TRUE; + end +end +end + +%\ +% Restore old directory +%/ + +cd(cdold); + +return +end diff --git a/ext/mtimesx/mtimesx_mexopts.bat b/ext/mtimesx/mtimesx_mexopts.bat new file mode 100644 index 0000000000000000000000000000000000000000..1f748432fc9db10a060e1b10f8a4ceb7faffb333 --- /dev/null +++ b/ext/mtimesx/mtimesx_mexopts.bat @@ -0,0 +1,64 @@ +@echo off +rem MSVC110OPTS.BAT +rem +rem Compile and link options used for building MEX-files +rem using the Microsoft Visual C++ compiler version 11.0 +rem +rem $Revision: 1.1.6.1 $ $Date: 2012/09/25 18:20:24 $ +rem Copyright 2007-2012 The MathWorks, Inc. +rem +rem StorageVersion: 1.0 +rem C++keyFileName: MSVC110OPTS.BAT +rem C++keyName: Microsoft Visual C++ 2012 +rem C++keyManufacturer: Microsoft +rem C++keyVersion: 11.0 +rem C++keyLanguage: C++ +rem C++keyLinkerName: Microsoft Visual C++ 2012 +rem C++keyLinkerVer: 11.0 +rem +rem ******************************************************************** +rem General parameters +rem ******************************************************************** + +set MATLAB=%MATLAB% +set VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 11.0 +set VCINSTALLDIR=%VSINSTALLDIR%\VC +rem In this case, LINKERDIR is being used to specify the location of the SDK +set LINKERDIR=C:\Program Files (x86)\Windows Kits\8.0\ +set PATH=%VCINSTALLDIR%\bin\amd64;%VCINSTALLDIR%\bin;%VCINSTALLDIR%\VCPackages;%VSINSTALLDIR%\Common7\IDE;%VSINSTALLDIR%\Common7\Tools;%LINKERDIR%\bin\x64;%LINKERDIR%\bin;%MATLAB_BIN%;%PATH% +set INCLUDE=%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\ATLMFC\INCLUDE;%LINKERDIR%\include\um;%LINKERDIR%\include\shared;%LINKERDIR%\include\winrt;%INCLUDE% +set LIB=%VCINSTALLDIR%\LIB\amd64;%VCINSTALLDIR%\ATLMFC\LIB\amd64;%LINKERDIR%\lib\win8\um\x64;%MATLAB%\extern\lib\win64;%LIB% +set MW_TARGET_ARCH=win64 + +rem ******************************************************************** +rem Compiler parameters +rem ******************************************************************** +set COMPILER=cl +set COMPFLAGS=/c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /openmp +set OPTIMFLAGS=/O2 /Oy- /DNDEBUG +set DEBUGFLAGS=/Z7 +set NAME_OBJECT=/Fo + +rem ******************************************************************** +rem Linker parameters +rem ******************************************************************** +set LIBLOC=%MATLAB%\extern\lib\win64\microsoft +set LINKER=link +set LINKFLAGS=/dll /export:%ENTRYPOINT% /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"%LIB_NAME%.x" /MAP:"%OUTDIR%%MEX_NAME%%MEX_EXT%.map" +set LINKOPTIMFLAGS= +set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb" +set LINK_FILE= +set LINK_LIB= +set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%" +set RSP_FILE_INDICATOR=@ + +rem ******************************************************************** +rem Resource compiler parameters +rem ******************************************************************** +set RC_COMPILER=rc /fo "%OUTDIR%mexversion.res" +set RC_LINKER= + +set POSTLINK_CMDS=del "%LIB_NAME%.x" "%LIB_NAME%.exp" +set POSTLINK_CMDS1=mt -outputresource:"%OUTDIR%%MEX_NAME%%MEX_EXT%;2" -manifest "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest" +set POSTLINK_CMDS2=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest" +set POSTLINK_CMDS3=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.map" diff --git a/ext/mtimesx/mtimesx_sparse.m b/ext/mtimesx/mtimesx_sparse.m new file mode 100644 index 0000000000000000000000000000000000000000..474bccf35d1fcabf26641458a655c35c90d5339f --- /dev/null +++ b/ext/mtimesx/mtimesx_sparse.m @@ -0,0 +1,86 @@ +% mtimesx_sparse does sparse matrix multiply of two inputs +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_sparse +% Filename: mtimesx_sparse.m +% Programmer: James Tursa +% Version: 1.00 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +%-- +% +% mtimesx_sparse is a helper function for mtimesx and is not intended to be called +% directly by the user. +% +% --------------------------------------------------------------------------------------------------------------------------------- + +function result = mtimesx_sparse(a,transa,b,transb) +if( transa == 'N' ) + if( transb == 'N' ) + result = a * b; + elseif( transb == 'G' ) + result = a * conj(b); + elseif( transb == 'T' ) + result = a * b.'; + else + result = a * b'; + end +elseif( transa == 'G' ) + if( transb == 'N' ) + result = conj(a) * b; + elseif( transb == 'G' ) + result = conj(a) * conj(b); + elseif( transb == 'T' ) + result = conj(a) * b.'; + else + result = conj(a) * b'; + end +elseif( transa == 'T' ) + if( transb == 'N' ) + result = a.' * b; + elseif( transb == 'G' ) + result = a.' * conj(b); + elseif( transb == 'T' ) + result = a.' * b.'; + else + result = a.' * b'; + end +else + if( transb == 'N' ) + result = a' * b; + elseif( transb == 'G' ) + result = a' * conj(b); + elseif( transb == 'T' ) + result = a' * b.'; + else + result = a' * b'; + end +end +end diff --git a/ext/mtimesx/mtimesx_test_ddequal.m b/ext/mtimesx/mtimesx_test_ddequal.m new file mode 100644 index 0000000000000000000000000000000000000000..6ce12146529c2e9a26439f5dc48730aa021d3446 --- /dev/null +++ b/ext/mtimesx/mtimesx_test_ddequal.m @@ -0,0 +1,4121 @@ +% Test routine for mtimesx, op(double) * op(double) equality vs MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_ddequal +% Filename: mtimesx_test_ddequal.m +% Programmer: James Tursa +% Version: 1.0 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax: +% +% T = mtimesx_test_ddequal +% +% Output: +% +% T = A character array containing a summary of the results. +% +%-------------------------------------------------------------------------- + +function dtable = mtimesx_test_ddequal + +global mtimesx_dtable + +disp(' '); +disp('****************************************************************************'); +disp('* *'); +disp('* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *'); +disp('* *'); +disp('* This test program can take an hour or so to complete. It is suggested *'); +disp('* that you close all applications and run this program during your lunch *'); +disp('* break or overnight to minimize impacts to your computer usage. *'); +disp('* *'); +disp('* The program will be done when you see the message: DONE ! *'); +disp('* *'); +disp('****************************************************************************'); +disp(' '); +input('Press Enter to start test, or Ctrl-C to exit ','s'); + +start_time = datenum(clock); + +compver = [computer ', ' version ', mtimesx mode ' mtimesx]; +k = length(compver); +RC = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +mtimesx_dtable = char([]); +mtimesx_dtable(162,74) = ' '; +mtimesx_dtable(1,1:k) = compver; +mtimesx_dtable(2,:) = RC; +for r=3:162 +mtimesx_dtable(r,:) = ' -- -- -- --'; +end + +disp(' '); +disp(compver); +disp('Test program for function mtimesx:') +disp('----------------------------------'); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real)'); +disp(' '); + +rsave = 2; + +r = rsave; + +%if( false ) % debug jump + +if( isequal([]*[],mtimesx([],[])) ) + disp('Empty * Empty EQUAL'); +else + disp('Empty * Empty NOT EQUAL <---'); +end + +r = r + 1; +A = rand(1,1); +B = rand(1,10000); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = rand(1,1); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = rand(1,1); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNN('Matrix * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real).'''); +disp(' '); + +if( isequal([]*[].',mtimesx([],[],'T')) ) + disp('Empty * Empty.'' EQUAL'); +else + disp('Empty * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(10000,1); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real)'''); +disp(' '); + +if( isequal([]*[]',mtimesx([],[],'C')) ) + disp('Empty * Empty'' EQUAL'); +else + disp('Empty * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(10000,1); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * conj(real)'); +disp(' '); + +%if( false ) % debug jump + +if( isequal([]*conj([]),mtimesx([],[],'G')) ) + disp('Empty * conj(Empty) EQUAL'); +else + disp('Empty * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = rand(1,1); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj((real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = rand(1,1); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real)'); +disp(' '); + +if( isequal([]'*[],mtimesx([],'C',[])) ) + disp('Empty.'' * Empty EQUAL'); +else + disp('Empty.'' * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real).'''); +disp(' '); + +if( isequal([].'*[]',mtimesx([],'T',[],'C')) ) + disp('Empty.'' * Empty.'' EQUAL'); +else + disp('Empty.'' * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(10000,1); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real)'''); +disp(' '); + +if( isequal([].'*[]',mtimesx([],'T',[],'C')) ) + disp('Empty.'' * Empty'' EQUAL'); +else + disp('Empty.'' * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(10000,1); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * conj(real)'); +disp(' '); + +if( isequal([]'*conj([]),mtimesx([],'C',[],'G')) ) + disp('Empty.'' * conj(Empty) EQUAL'); +else + disp('Empty.'' * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real)'); +disp(' '); + +if( isequal([]'*[],mtimesx([],'C',[])) ) + disp('Empty'' * Empty EQUAL'); +else + disp('Empty'' * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real).'''); +disp(' '); + +if( isequal([]'*[]',mtimesx([],'C',[],'C')) ) + disp('Empty'' * Empty.'' EQUAL'); +else + disp('Empty'' * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(10000,1); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real)'''); +disp(' '); + +if( isequal([]'*[]',mtimesx([],'C',[],'C')) ) + disp('Empty'' * Empty'' EQUAL'); +else + disp('Empty'' * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(10000,1); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * conj(real)'); +disp(' '); + +if( isequal([]'*conj([]),mtimesx([],'C',[],'G')) ) + disp('Empty'' * conj(Empty) EQUAL'); +else + disp('Empty'' * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real)'); +disp(' '); + +if( isequal(conj([])*[],mtimesx([],'G',[])) ) + disp('conj(Empty) * Empty EQUAL'); +else + disp('conj(Empty) * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = rand(1,1); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = rand(1,1); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real).'''); +disp(' '); + +if( isequal(conj([])*[].',mtimesx([],'G',[],'T')) ) + disp('conj(Empty) * Empty.'' EQUAL'); +else + disp('conj(Empty) * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(10000,1); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real)'''); +disp(' '); + +if( isequal(conj([])*[]',mtimesx([],'G',[],'C')) ) + disp('conj(Empty) * Empty'' EQUAL'); +else + disp('conj(Empty) * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(10000,1); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * conj(real)'); +disp(' '); + +if( isequal(conj([])*conj([]),mtimesx([],'G',[],'G')) ) + disp('conj(Empty) * conj(Empty) EQUAL'); +else + disp('conj(Empty) * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = rand(1,1); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = rand(1,1); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ... symmetric cases op(A) * op(A)'); +disp(' '); +disp('real'); + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(2000); +maxdiffsymCN('Matrix'' * Same ',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymNC('Matrix * Same''',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymTN('Matrix.'' * Same ',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymNT('Matrix * Same.''',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymGC('conj(Matrix) * Same''',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymCG('Matrix'' * conj(Same)',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymGT('conj(Matrix) * Same.'' ',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymTG('Matrix.'' * conj(Same)',A,r); + +r = rsave; + +disp(' ' ); +disp('complex'); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymCN('Matrix'' * Same ',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymNC('Matrix * Same''',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymTN('Matrix.'' * Same ',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymNT('Matrix * Same.''',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymGC('conj(Matrix) * Same''',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymCG('Matrix'' * conj(Same)',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymGT('conj(Matrix) * Same.''',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymTG('Matrix.'' * conj(Same)',A,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ... special scalar cases'); +disp(' '); +disp('(scalar) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_dtable(r,:) = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +rsave = r; + +r = r + 1; +A = 1; +B = rand(2500); +maxdiffNN('( 1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500); +maxdiffNN('( 1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500); +maxdiffNN('( 1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500); +maxdiffNN('( 1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = -1; +B = rand(2500); +maxdiffNN('(-1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500); +maxdiffNN('(-1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500); +maxdiffNN('(-1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500); +maxdiffNN('(-1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500); +maxdiffNN('( 2+1i) * Matrix ',A,B,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500); +maxdiffNN('( 2-1i) * Matrix ',A,B,r); + +disp(' '); +disp('(scalar) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = 1; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = -1; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('(-1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('(-1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('(-1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('(-1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 2+1i) * Matrix ',A,B,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 2-1i) * Matrix ',A,B,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +%r = rsave; + +r = r + 1; +A = 1; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 1+0i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 1+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 1-1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 1+2i) * Matrix'' ',A,B,r); + +r = r + 1; +A = -1; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('(-1+0i) * Matrix'' ',A,B,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('(-1+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('(-1-1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('(-1+2i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 2+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 2-1i) * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ... special (scalar) * (sparse) cases'); +disp('Real * Real, Real * Cmpx, Cmpx * Real, Cmpx * Cmpx'); +disp(' '); + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +% rsave = r; + +r = r + 1; +A = rand(1,1); +B = sprand(5000,5000,.1); +maxdiffNN('Scalar * Sparse',A,B,r); + +A = rand(1,1); +B = sprand(5000,5000,.1); B = B + B*2i; +maxdiffNN('Scalar * Sparse',A,B,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); +maxdiffNN('Scalar * Sparse',A,B,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); B = B + B*2i; +maxdiffNN('Scalar * Sparse',A,B,r); + +r = r + 1; +A = rand(1,1); +B = sprand(5000,5000,.1); +maxdiffNT('Scalar * Sparse.''',A,B,r); + +A = rand(1,1); +B = sprand(5000,5000,.1); B = B + B*2i; +maxdiffNT('Scalar * Sparse.''',A,B,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); +maxdiffNT('Scalar * Sparse.''',A,B,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); B = B + B*2i; +maxdiffNT('Scalar * Sparse.''',A,B,r); + +r = r + 1; +A = rand(1,1); +B = sprand(5000,5000,.1); +maxdiffNC('Scalar * Sparse''',A,B,r); + +A = rand(1,1); +B = sprand(5000,5000,.1); B = B + B*2i; +maxdiffNC('Scalar * Sparse''',A,B,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); +maxdiffNC('Scalar * Sparse''',A,B,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); B = B + B*2i; +maxdiffNC('Scalar * Sparse''',A,B,r); + +r = r + 1; +A = rand(1,1); +B = sprand(5000,5000,.1); +maxdiffNG('Scalar * conj(Sparse)',A,B,r); + +A = rand(1,1); +B = sprand(5000,5000,.1); B = B + B*2i; +maxdiffNG('Scalar * conj(Sparse)',A,B,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); +maxdiffNG('Scalar * conj(Sparse)',A,B,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); B = B + B*2i; +maxdiffNG('Scalar * conj(Sparse)',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(' --- DONE ! ---'); +disp(' '); +disp('Summary of Numerical Comparison Tests, max relative element difference:'); +disp(' '); +mtimesx_dtable(1,1:k) = compver; +disp(mtimesx_dtable); +disp(' '); + +dtable = mtimesx_dtable; + +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNN(T,A,B,r) +Cm = A*B; +Cx = mtimesx(A,B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCN(T,A,B,r) +Cm = A'*B; +Cx = mtimesx(A,'C',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTN(T,A,B,r) +Cm = A.'*B; +Cx = mtimesx(A,'T',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGN(T,A,B,r) +Cm = conj(A)*B; +Cx = mtimesx(A,'G',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNC(T,A,B,r) +Cm = A*B'; +Cx = mtimesx(A,B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCC(T,A,B,r) +Cm = A'*B'; +Cx = mtimesx(A,'C',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTC(T,A,B,r) +Cm = A.'*B'; +Cx = mtimesx(A,'T',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGC(T,A,B,r) +Cm = conj(A)*B'; +Cx = mtimesx(A,'G',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNT(T,A,B,r) +Cm = A*B.'; +Cx = mtimesx(A,B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCT(T,A,B,r) +Cm = A'*B.'; +Cx = mtimesx(A,'C',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTT(T,A,B,r) +Cm = A.'*B.'; +Cx = mtimesx(A,'T',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGT(T,A,B,r) +Cm = conj(A)*B.'; +Cx = mtimesx(A,'G',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNG(T,A,B,r) +Cm = A*conj(B); +Cx = mtimesx(A,B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCG(T,A,B,r) +Cm = A'*conj(B); +Cx = mtimesx(A,'C',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTG(T,A,B,r) +Cm = A.'*conj(B); +Cx = mtimesx(A,'T',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGG(T,A,B,r) +Cm = conj(A)*conj(B); +Cx = mtimesx(A,'G',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymCN(T,A,r) +Cm = A'*A; +Cx = mtimesx(A,'C',A); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymNC(T,A,r) +Cm = A*A'; +Cx = mtimesx(A,A,'C'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymTN(T,A,r) +Cm = A.'*A; +Cx = mtimesx(A,'T',A); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymNT(T,A,r) +Cm = A*A.'; +Cx = mtimesx(A,A,'T'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymTG(T,A,r) +Cm = A.'*conj(A); +Cx = mtimesx(A,'T',A,'G'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymGT(T,A,r) +Cm = conj(A)*A.'; +Cx = mtimesx(A,'G',A,'T'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymCG(T,A,r) +Cm = A'*conj(A); +Cx = mtimesx(A,'C',A,'G'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymGC(T,A,r) +Cm = conj(A)*A'; +Cx = mtimesx(A,'G',A,'C'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffout(T,A,B,Cm,Cx,r) +global mtimesx_dtable +lt = length(T); +b = repmat(' ',1,30-lt); +if( isequal(Cm,Cx) ) + disp([T b ' EQUAL']); + d = 0; +else + Cm = Cm(:); + Cx = Cx(:); + if( isreal(Cm) && isreal(Cx) ) + rx = Cx ~= Cm; + d = max(abs((Cx(rx)-Cm(rx))./Cm(rx))); + else + Cmr = real(Cm); + Cmi = imag(Cm); + Cxr = real(Cx); + Cxi = imag(Cx); + rx = Cxr ~= Cmr; + ix = Cxi ~= Cmi; + dr = max(abs((Cxr(rx)-Cmr(rx))./max(abs(Cmr(rx)),abs(Cmr(rx))))); + di = max(abs((Cxi(ix)-Cmi(ix))./max(abs(Cmi(ix)),abs(Cxi(ix))))); + if( isempty(dr) ) + d = di; + elseif( isempty(di) ) + d = dr; + else + d = max(dr,di); + end + end + disp([T b ' NOT EQUAL <--- Max relative difference: ' num2str(d)]); +end +mtimesx_dtable(r,1:length(T)) = T; +if( isreal(A) && isreal(B) ) + if( d == 0 ) + x = [T b ' 0']; + else + x = [T b sprintf('%11.2e',d)]; + end + mtimesx_dtable(r,1:length(x)) = x; +elseif( isreal(A) && ~isreal(B) ) + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,42:41+length(x)) = x; +elseif( ~isreal(A) && isreal(B) ) + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,53:52+length(x)) = x; +else + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymout(T,A,Cm,Cx,r) +global mtimesx_dtable +lt = length(T); +b = repmat(' ',1,30-lt); +if( isequal(Cm,Cx) ) + disp([T b ' EQUAL']); + d = 0; +else + Cm = Cm(:); + Cx = Cx(:); + if( isreal(Cm) && isreal(Cx) ) + rx = Cx ~= Cm; + d = max(abs((Cx(rx)-Cm(rx))./Cm(rx))); + else + Cmr = real(Cm); + Cmi = imag(Cm); + Cxr = real(Cx); + Cxi = imag(Cx); + rx = Cxr ~= Cmr; + ix = Cxi ~= Cmi; + dr = max(abs((Cxr(rx)-Cmr(rx))./max(abs(Cmr(rx)),abs(Cmr(rx))))); + di = max(abs((Cxi(ix)-Cmi(ix))./max(abs(Cmi(ix)),abs(Cxi(ix))))); + if( isempty(dr) ) + d = di; + elseif( isempty(di) ) + d = dr; + else + d = max(dr,di); + end + end + disp([T b ' NOT EQUAL <--- Max relative difference: ' num2str(d)]); +end +if( isreal(A) ) + if( d == 0 ) + x = [T b ' 0']; + else + x = [T b sprintf('%11.2e',d)]; + end + mtimesx_dtable(r,1:length(x)) = x; +else + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,1:length(T)) = T; + mtimesx_dtable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function running_time(d) +h = 24*d; +hh = floor(h); +m = 60*(h - hh); +mm = floor(m); +s = 60*(m - mm); +ss = floor(s); +disp(' '); +rt = sprintf('Running time hh:mm:ss = %2.0f:%2.0f:%2.0f',hh,mm,ss); +if( rt(28) == ' ' ) + rt(28) = '0'; +end +if( rt(31) == ' ' ) + rt(31) = '0'; +end +disp(rt); +disp(' '); +return +end diff --git a/ext/mtimesx/mtimesx_test_ddspeed.m b/ext/mtimesx/mtimesx_test_ddspeed.m new file mode 100644 index 0000000000000000000000000000000000000000..023b346d0b473efca7ec750d75ccf256bf18f045 --- /dev/null +++ b/ext/mtimesx/mtimesx_test_ddspeed.m @@ -0,0 +1,5127 @@ +% Test routine for mtimesx, op(double) * op(double) speed vs MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_ddspeed +% Filename: mtimesx_test_ddspeed.m +% Programmer: James Tursa +% Version: 1.0 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax (arguments in brackets [ ] are optional): +% +% T = mtimesx_test_ddspeed( [N [,D]] ) +% +% Inputs: +% +% N = Number of runs to make for each individual test. The test result will +% be the median of N runs. N must be even. If N is odd, it will be +% automatically increased to the next even number. The default is 10, +% which can take *hours* to run. Best to run this program overnight. +% D = The string 'details'. If present, this will cause all of the +% individual intermediate run results to print as they happen. +% +% Output: +% +% T = A character array containing a summary of the results. +% +%-------------------------------------------------------------------------- + +function ttable = mtimesx_test_ddspeed(nn,details) + +global mtimesx_ttable + +disp(' '); +disp('****************************************************************************'); +disp('* *'); +disp('* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *'); +disp('* *'); +disp('* This test program can take several *hours* to complete, particularly *'); +disp('* when using the default number of runs as 10. It is strongly suggested *'); +disp('* to close all applications and run this program overnight to get the *'); +disp('* best possible result with minimal impacts to your computer usage. *'); +disp('* *'); +disp('* The program will be done when you see the message: DONE ! *'); +disp('* *'); +disp('****************************************************************************'); +disp(' '); +try + input('Press Enter to start test, or Ctrl-C to exit ','s'); +catch + ttable = ''; + return +end + +start_time = datenum(clock); + +if nargin >= 1 + n = nn; +else + n = 10; +end +if nargin < 2 + details = false; +else + if( isempty(details) ) % code to get rid of the lint message + details = true; + else + details = true; + end +end + +RC = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +compver = [computer ', ' version ', mtimesx mode ' mtimesx ', median of ' num2str(n) ' runs']; +k = length(compver); + +nl = 199; + +mtimesx_ttable = char([]); +mtimesx_ttable(1:nl,1:74) = ' '; +mtimesx_ttable(1,1:k) = compver; +mtimesx_ttable(2,:) = RC; +for r=3:(nl-2) +mtimesx_ttable(r,:) = ' -- -- -- --'; +end +mtimesx_ttable(nl,1:6) = 'DONE !'; + +disp(' '); +disp(compver); +disp('Test program for function mtimesx:') +disp('----------------------------------'); + +rsave = 2; + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = rand(1,1); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = rand(1,1); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real).'''); +disp(' '); + +rsave = r; + +mtimesx_ttable(r,:) = RC; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = rand(1,1); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = rand(1,1); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = rand(1,1); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = rand(1,1); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = rand(1,1); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = rand(1,1); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = rand(1,1); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = rand(1,1) + rand(1,1)*1i; +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... symmetric cases op(A) * op(A)']); +disp(' '); +disp('real'); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(2000); +maxtimesymCN('Matrix'' * Same ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymNC('Matrix * Same'' ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymTN('Matrix.'' * Same ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymNT('Matrix * Same.'' ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymGC('conj(Matrix) * Same'' ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymCG('Matrix'' * conj(Same)',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymGT('conj(Matrix) * Same.'' ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymTG('Matrix.'' * conj(Same)',A,n,details,r); + +r = rsave; + +disp(' '); +disp('complex'); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymCN('Matrix'' * Same ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymNC('Matrix * Same'' ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymTN('Matrix.'' * Same ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymNT('Matrix * Same.'' ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymGC('conj(Matrix) * Same'' ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymCG('Matrix'' * conj(Same)',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymGT('conj(Matrix) * Same.'' ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymTG('Matrix.'' * conj(Same)',A,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... special scalar cases']); +disp(' '); +disp('(scalar) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = 1; +B = rand(2500); +maxtimeNN('( 1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500); +maxtimeNN('( 1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500); +maxtimeNN('( 1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500); +maxtimeNN('( 1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1; +B = rand(2500); +maxtimeNN('(-1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500); +maxtimeNN('(-1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500); +maxtimeNN('(-1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500); +maxtimeNN('(-1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500); +maxtimeNN('( 2+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500); +maxtimeNN('( 2-1i) * Matrix ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = 1; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('(-1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('(-1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('(-1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('(-1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 2+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 2-1i) * Matrix ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = 1; +B = rand(2500); +maxtimeNT('( 1+0i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500); +maxtimeNT('( 1+1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500); +maxtimeNT('( 1-1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500); +maxtimeNT('( 1+2i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = -1; +B = rand(2500); +maxtimeNT('(-1+0i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500); +maxtimeNT('(-1+1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500); +maxtimeNT('(-1-1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500); +maxtimeNT('(-1+2i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500); +maxtimeNT('( 2+1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500); +maxtimeNT('( 2-1i) * Matrix.''',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = 1; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('( 1+0i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('( 1+1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('( 1-1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('( 1+2i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = -1; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('(-1+0i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('(-1+1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('(-1-1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('(-1+2i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('( 2+1i) * Matrix.''',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNT('( 2-1i) * Matrix.''',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = 1; +B = rand(2500); +maxtimeNC('( 1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500); +maxtimeNC('( 1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500); +maxtimeNC('( 1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500); +maxtimeNC('( 1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1; +B = rand(2500); +maxtimeNC('(-1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500); +maxtimeNC('(-1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500); +maxtimeNC('(-1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500); +maxtimeNC('(-1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500); +maxtimeNC('( 2+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500); +maxtimeNC('( 2-1i) * Matrix'' ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = 1; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('(-1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('(-1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('(-1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('(-1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 2+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 2-1i) * Matrix'' ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = 1; +B = rand(2500); +maxtimeNG('( 1+0i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500); +maxtimeNG('( 1+1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500); +maxtimeNG('( 1-1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500); +maxtimeNG('( 1+2i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = -1; +B = rand(2500); +maxtimeNG('(-1+0i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500); +maxtimeNG('(-1+1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500); +maxtimeNG('(-1-1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500); +maxtimeNG('(-1+2i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500); +maxtimeNG('( 2+1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500); +maxtimeNG('( 2-1i) * conj(Matrix)',A,B,n,details,r); + +disp(' '); +disp('(scalar) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = 1; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('( 1+0i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('( 1+1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('( 1-1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('( 1+2i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = -1; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('(-1+0i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('(-1+1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('(-1-1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('(-1+2i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('( 2+1i) * conj(Matrix)',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = rand(2500) + rand(2500)*1i; +maxtimeNG('( 2-1i) * conj(Matrix)',A,B,n,details,r); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... special sparse cases']); +disp('Real * Real, Real * Cmpx, Cmpx * Real, Cmpx * Cmpx'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = sprand(5000,5000,.1); +maxtimeNN('Scalar * Sparse',A,B,n,details,r); + +A = rand(1,1); +B = sprand(5000,5000,.1); B = B + B*2i; +maxtimeNN('Scalar * Sparse',A,B,n,details,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); +maxtimeNN('Scalar * Sparse',A,B,n,details,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); B = B + B*2i; +maxtimeNN('Scalar * Sparse',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = sprand(5000,5000,.1); +maxtimeNT('Scalar * Sparse.''',A,B,n,details,r); + +A = rand(1,1); +B = sprand(5000,5000,.1); B = B + B*2i; +maxtimeNT('Scalar * Sparse.''',A,B,n,details,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); +maxtimeNT('Scalar * Sparse.''',A,B,n,details,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); B = B + B*2i; +maxtimeNT('Scalar * Sparse.''',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = sprand(5000,5000,.1); +maxtimeNC('Scalar * Sparse''',A,B,n,details,r); + +A = rand(1,1); +B = sprand(5000,5000,.1); B = B + B*2i; +maxtimeNC('Scalar * Sparse''',A,B,n,details,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); +maxtimeNC('Scalar * Sparse''',A,B,n,details,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); B = B + B*2i; +maxtimeNC('Scalar * Sparse''',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = sprand(5000,5000,.1); +maxtimeNG('Scalar * conj(Sparse)',A,B,n,details,r); + +A = rand(1,1); +B = sprand(5000,5000,.1); B = B + B*2i; +maxtimeNG('Scalar * conj(Sparse)',A,B,n,details,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); +maxtimeNG('Scalar * conj(Sparse)',A,B,n,details,r); + +A = rand(1,1) + rand(1,1)*1i; +B = sprand(5000,5000,.1); B = B + B*2i; +maxtimeNG('Scalar * conj(Sparse)',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(' --- DONE ! ---'); +disp(' '); +disp(['Summary of Timing Tests, ' num2str(n) ' runs, + = percent faster, - = percent slower:']); +disp(' '); +mtimesx_ttable(1,1:k) = compver; +disp(mtimesx_ttable); +disp(' '); + +ttable = mtimesx_ttable; + +running_time(datenum(clock) - start_time); + +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B; + mtoc(k) = toc; + tic; + mtimesx(A,B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B'; + mtoc(k) = toc; + tic; + mtimesx(A,B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymCN(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*A; + mtoc(k) = toc; + tic; + mtimesx(A,'C',A); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymNC(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*A'; + mtoc(k) = toc; + tic; + mtimesx(A,A,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymTN(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*A; + mtoc(k) = toc; + tic; + mtimesx(A,'T',A); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymNT(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*A.'; + mtoc(k) = toc; + tic; + mtimesx(A,A,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymCG(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*conj(A); + mtoc(k) = toc; + tic; + mtimesx(A,'C',A,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymGC(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*A'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',A,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymTG(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*conj(A); + mtoc(k) = toc; + tic; + mtimesx(A,'T',A,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymGT(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*A.'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',A,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeout(T,A,B,p,r) +global mtimesx_ttable +mtimesx_ttable(r,1:length(T)) = T; +if( isreal(A) && isreal(B) ) + lt = length(T); + b = repmat(' ',1,30-lt); + x = [T b sprintf('%10.0f%%',-p)]; + mtimesx_ttable(r,1:length(x)) = x; +elseif( isreal(A) && ~isreal(B) ) + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,42:41+length(x)) = x; +elseif( ~isreal(A) && isreal(B) ) + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,53:52+length(x)) = x; +else + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymout(T,A,p,r) +global mtimesx_ttable +if( isreal(A) ) + lt = length(T); + b = repmat(' ',1,30-lt); + x = [T b sprintf('%10.0f%%',-p)]; + mtimesx_ttable(r,1:length(x)) = x; +else + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,1:length(T)) = T; + mtimesx_ttable(r,64:63+length(x)) = x; +end +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function running_time(d) +h = 24*d; +hh = floor(h); +m = 60*(h - hh); +mm = floor(m); +s = 60*(m - mm); +ss = floor(s); +disp(' '); +rt = sprintf('Running time hh:mm:ss = %2.0f:%2.0f:%2.0f',hh,mm,ss); +if( rt(28) == ' ' ) + rt(28) = '0'; +end +if( rt(31) == ' ' ) + rt(31) = '0'; +end +disp(rt); +disp(' '); +return +end diff --git a/ext/mtimesx/mtimesx_test_dsequal.m b/ext/mtimesx/mtimesx_test_dsequal.m new file mode 100644 index 0000000000000000000000000000000000000000..52fba193ee56510e5e513674dfe91c37bdab31d4 --- /dev/null +++ b/ext/mtimesx/mtimesx_test_dsequal.m @@ -0,0 +1,4041 @@ +% Test routine for mtimesx, op(double) * op(single) equality vs MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_dsequal +% Filename: mtimesx_test_dsequal.m +% Programmer: James Tursa +% Version: 1.0 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax: +% +% T = mtimesx_test_ddequal +% +% Output: +% +% T = A character array containing a summary of the results. +% +%-------------------------------------------------------------------------- + +function dtable = mtimesx_test_dsequal + +global mtimesx_dtable + +disp(' '); +disp('****************************************************************************'); +disp('* *'); +disp('* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *'); +disp('* *'); +disp('* This test program can take an hour or so to complete. It is suggested *'); +disp('* that you close all applications and run this program during your lunch *'); +disp('* break or overnight to minimize impacts to your computer usage. *'); +disp('* *'); +disp('* The program will be done when you see the message: DONE ! *'); +disp('* *'); +disp('****************************************************************************'); +disp(' '); +try + input('Press Enter to start test, or Ctrl-C to exit ','s'); +catch + dtable = ''; + return +end + +start_time = datenum(clock); + +compver = [computer ', ' version ', mtimesx mode ' mtimesx]; +k = length(compver); +RC = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +mtimesx_dtable = char([]); +mtimesx_dtable(157,74) = ' '; +mtimesx_dtable(1,1:k) = compver; +mtimesx_dtable(2,:) = RC; +for r=3:157 +mtimesx_dtable(r,:) = ' -- -- -- --'; +end + +disp(' '); +disp(compver); +disp('Test program for function mtimesx:') +disp('----------------------------------'); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real)'); +disp(' '); + +rsave = 2; + +r = rsave; + +%if( false ) % debug jump + +if( isequal([]*[],mtimesx([],[])) ) + disp('Empty * Empty EQUAL'); +else + disp('Empty * Empty NOT EQUAL <---'); +end + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000)); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = single(rand(1,1)); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40)); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1)); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1)); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500)); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000)); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1)); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = single(rand(1,1)); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40)); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1)); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500)); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000)); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1)); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNN('Matrix * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real).'''); +disp(' '); + +if( isequal([]*[].',mtimesx([],[],'T')) ) + disp('Empty * Empty.'' EQUAL'); +else + disp('Empty * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(10000,1)); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1)); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000)); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1)); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000)); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000)); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000)); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1)); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000)); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000)); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real)'''); +disp(' '); + +if( isequal([]*[]',mtimesx([],[],'C')) ) + disp('Empty * Empty'' EQUAL'); +else + disp('Empty * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(10000,1)); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1)); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000)); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1)); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000)); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000)); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000)); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1)); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000)); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000)); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * conj(real)'); +disp(' '); + +%if( false ) % debug jump + +if( isequal([]*conj([]),mtimesx([],[],'G')) ) + disp('Empty * conj(Empty) EQUAL'); +else + disp('Empty * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000)); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = single(rand(1,1)); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40)); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1)); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1)); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500)); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000)); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1)); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj((real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = single(rand(1,1)); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40)); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1)); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500)); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000)); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1)); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real)'); +disp(' '); + +if( isequal([]'*[],mtimesx([],'C',[])) ) + disp('Empty.'' * Empty EQUAL'); +else + disp('Empty.'' * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000)); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40)); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1)); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500)); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000)); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1)); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40)); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1)); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500)); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000)); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1)); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real).'''); +disp(' '); + +if( isequal([].'*[]',mtimesx([],'T',[],'C')) ) + disp('Empty.'' * Empty.'' EQUAL'); +else + disp('Empty.'' * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(10000,1)); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000)); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1)); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000)); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000)); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000)); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1)); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000)); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000)); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real)'''); +disp(' '); + +if( isequal([].'*[]',mtimesx([],'T',[],'C')) ) + disp('Empty.'' * Empty'' EQUAL'); +else + disp('Empty.'' * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(10000,1)); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000)); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1)); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000)); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000)); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000)); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1)); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000)); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000)); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * conj(real)'); +disp(' '); + +if( isequal([]'*conj([]),mtimesx([],'C',[],'G')) ) + disp('Empty.'' * conj(Empty) EQUAL'); +else + disp('Empty.'' * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000)); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40)); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1)); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500)); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000)); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1)); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40)); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1)); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500)); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000)); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1)); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real)'); +disp(' '); + +if( isequal([]'*[],mtimesx([],'C',[])) ) + disp('Empty'' * Empty EQUAL'); +else + disp('Empty'' * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000)); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40)); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1)); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500)); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000)); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1)); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40)); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1)); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500)); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000)); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1)); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real).'''); +disp(' '); + +if( isequal([]'*[]',mtimesx([],'C',[],'C')) ) + disp('Empty'' * Empty.'' EQUAL'); +else + disp('Empty'' * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(10000,1)); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000)); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1)); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000)); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000)); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000)); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1)); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000)); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000)); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real)'''); +disp(' '); + +if( isequal([]'*[]',mtimesx([],'C',[],'C')) ) + disp('Empty'' * Empty'' EQUAL'); +else + disp('Empty'' * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(10000,1)); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000)); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1)); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000)); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000)); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000)); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1)); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000)); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000)); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * conj(real)'); +disp(' '); + +if( isequal([]'*conj([]),mtimesx([],'C',[],'G')) ) + disp('Empty'' * conj(Empty) EQUAL'); +else + disp('Empty'' * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000)); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40)); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1)); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500)); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000)); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1)); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40)); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1)); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500)); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000)); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1)); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1) + rand(1000,1)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real)'); +disp(' '); + +if( isequal(conj([])*[],mtimesx([],'G',[])) ) + disp('conj(Empty) * Empty EQUAL'); +else + disp('conj(Empty) * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000)); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = single(rand(1,1)); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40)); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1)); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1)); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500)); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000)); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1)); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = single(rand(1,1)); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40)); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1)); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500)); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000)); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1)); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real).'''); +disp(' '); + +if( isequal(conj([])*[].',mtimesx([],'G',[],'T')) ) + disp('conj(Empty) * Empty.'' EQUAL'); +else + disp('conj(Empty) * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(10000,1)); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1)); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000)); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1)); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000)); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000)); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000)); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1)); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000)); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000)); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real)'''); +disp(' '); + +if( isequal(conj([])*[]',mtimesx([],'G',[],'C')) ) + disp('conj(Empty) * Empty'' EQUAL'); +else + disp('conj(Empty) * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(10000,1)); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1)); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1)); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000)); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1)); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000)); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000)); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1)); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000)); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1)); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000)); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000)); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(10000,1)+ rand(10000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * conj(real)'); +disp(' '); + +if( isequal(conj([])*conj([]),mtimesx([],'G',[],'G')) ) + disp('conj(Empty) * conj(Empty) EQUAL'); +else + disp('conj(Empty) * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000)); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = single(rand(1,1)); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40)); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1)); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1)); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500)); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000)); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1)); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000)); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000)); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = single(rand(1,1)); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40)); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1)); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500)); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000)); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1)); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000)); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,10000)+ rand(1,10000)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1,1000) + rand(1,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = rand(1000,1000) + rand(1000,1000)*1i; +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ... symmetric cases op(A) * op(A)'); +disp(' '); +disp('real'); + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = rand(2000); +maxdiffsymCN('Matrix'' * Same ',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymNC('Matrix * Same''',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymTN('Matrix.'' * Same ',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymNT('Matrix * Same.''',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymGC('conj(Matrix) * Same''',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymCG('Matrix'' * conj(Same)',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymGT('conj(Matrix) * Same.'' ',A,r); + +r = r + 1; +A = rand(2000); +maxdiffsymTG('Matrix.'' * conj(Same)',A,r); + +r = rsave; + +disp(' ' ); +disp('complex'); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymCN('Matrix'' * Same ',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymNC('Matrix * Same''',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymTN('Matrix.'' * Same ',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymNT('Matrix * Same.''',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymGC('conj(Matrix) * Same''',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymCG('Matrix'' * conj(Same)',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymGT('conj(Matrix) * Same.''',A,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxdiffsymTG('Matrix.'' * conj(Same)',A,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ... special scalar cases'); +disp(' '); +disp('(scalar) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_dtable(r,:) = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +rsave = r; + +r = r + 1; +A = 1; +B = single(rand(2500)); +maxdiffNN('( 1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 + 1i; +B = single(rand(2500)); +maxdiffNN('( 1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 - 1i; +B = single(rand(2500)); +maxdiffNN('( 1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 + 2i; +B = single(rand(2500)); +maxdiffNN('( 1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = -1; +B = single(rand(2500)); +maxdiffNN('(-1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 + 1i; +B = single(rand(2500)); +maxdiffNN('(-1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 - 1i; +B = single(rand(2500)); +maxdiffNN('(-1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 + 2i; +B = single(rand(2500)); +maxdiffNN('(-1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = 2 + 1i; +B = single(rand(2500)); +maxdiffNN('( 2+1i) * Matrix ',A,B,r); + +r = r + 1; +A = 2 - 1i; +B = single(rand(2500)); +maxdiffNN('( 2-1i) * Matrix ',A,B,r); + +disp(' '); +disp('(scalar) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = 1; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = 1 + 2i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = -1; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('(-1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('(-1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('(-1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = -1 + 2i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('(-1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = 2 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 2+1i) * Matrix ',A,B,r); + +r = r + 1; +A = 2 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 2-1i) * Matrix ',A,B,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +%r = rsave; + +r = r + 1; +A = 1; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 1+0i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 1 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 1+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 1 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 1-1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 1 + 2i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 1+2i) * Matrix'' ',A,B,r); + +r = r + 1; +A = -1; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('(-1+0i) * Matrix'' ',A,B,r); + +r = r + 1; +A = -1 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('(-1+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = -1 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('(-1-1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = -1 + 2i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('(-1+2i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 2 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 2+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = 2 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 2-1i) * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(' --- DONE ! ---'); +disp(' '); +disp('Summary of Numerical Comparison Tests, max relative element difference:'); +disp(' '); +mtimesx_dtable(1,1:k) = compver; +disp(mtimesx_dtable); +disp(' '); + +dtable = mtimesx_dtable; + +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNN(T,A,B,r) +Cm = A*B; +Cx = mtimesx(A,B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCN(T,A,B,r) +Cm = A'*B; +Cx = mtimesx(A,'C',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTN(T,A,B,r) +Cm = A.'*B; +Cx = mtimesx(A,'T',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGN(T,A,B,r) +Cm = conj(A)*B; +Cx = mtimesx(A,'G',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNC(T,A,B,r) +Cm = A*B'; +Cx = mtimesx(A,B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCC(T,A,B,r) +Cm = A'*B'; +Cx = mtimesx(A,'C',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTC(T,A,B,r) +Cm = A.'*B'; +Cx = mtimesx(A,'T',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGC(T,A,B,r) +Cm = conj(A)*B'; +Cx = mtimesx(A,'G',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNT(T,A,B,r) +Cm = A*B.'; +Cx = mtimesx(A,B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCT(T,A,B,r) +Cm = A'*B.'; +Cx = mtimesx(A,'C',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTT(T,A,B,r) +Cm = A.'*B.'; +Cx = mtimesx(A,'T',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGT(T,A,B,r) +Cm = conj(A)*B.'; +Cx = mtimesx(A,'G',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNG(T,A,B,r) +Cm = A*conj(B); +Cx = mtimesx(A,B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCG(T,A,B,r) +Cm = A'*conj(B); +Cx = mtimesx(A,'C',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTG(T,A,B,r) +Cm = A.'*conj(B); +Cx = mtimesx(A,'T',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGG(T,A,B,r) +Cm = conj(A)*conj(B); +Cx = mtimesx(A,'G',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymCN(T,A,r) +Cm = A'*A; +Cx = mtimesx(A,'C',A); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymNC(T,A,r) +Cm = A*A'; +Cx = mtimesx(A,A,'C'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymTN(T,A,r) +Cm = A.'*A; +Cx = mtimesx(A,'T',A); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymNT(T,A,r) +Cm = A*A.'; +Cx = mtimesx(A,A,'T'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymTG(T,A,r) +Cm = A.'*conj(A); +Cx = mtimesx(A,'T',A,'G'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymGT(T,A,r) +Cm = conj(A)*A.'; +Cx = mtimesx(A,'G',A,'T'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymCG(T,A,r) +Cm = A'*conj(A); +Cx = mtimesx(A,'C',A,'G'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymGC(T,A,r) +Cm = conj(A)*A'; +Cx = mtimesx(A,'G',A,'C'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffout(T,A,B,Cm,Cx,r) +global mtimesx_dtable +lt = length(T); +b = repmat(' ',1,30-lt); +if( isequal(Cm,Cx) ) + disp([T b ' EQUAL']); + d = 0; +else + Cm = Cm(:); + Cx = Cx(:); + if( isreal(Cm) && isreal(Cx) ) + rx = Cx ~= Cm; + d = max(abs((Cx(rx)-Cm(rx))./Cm(rx))); + else + Cmr = real(Cm); + Cmi = imag(Cm); + Cxr = real(Cx); + Cxi = imag(Cx); + rx = Cxr ~= Cmr; + ix = Cxi ~= Cmi; + dr = max(abs((Cxr(rx)-Cmr(rx))./max(abs(Cmr(rx)),abs(Cmr(rx))))); + di = max(abs((Cxi(ix)-Cmi(ix))./max(abs(Cmi(ix)),abs(Cxi(ix))))); + if( isempty(dr) ) + d = di; + elseif( isempty(di) ) + d = dr; + else + d = max(dr,di); + end + end + disp([T b ' NOT EQUAL <--- Max relative difference: ' num2str(d)]); +end +mtimesx_dtable(r,1:length(T)) = T; +if( isreal(A) && isreal(B) ) + if( d == 0 ) + x = [T b ' 0']; + else + x = [T b sprintf('%11.2e',d)]; + end + mtimesx_dtable(r,1:length(x)) = x; +elseif( isreal(A) && ~isreal(B) ) + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,42:41+length(x)) = x; +elseif( ~isreal(A) && isreal(B) ) + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,53:52+length(x)) = x; +else + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymout(T,A,Cm,Cx,r) +global mtimesx_dtable +lt = length(T); +b = repmat(' ',1,30-lt); +if( isequal(Cm,Cx) ) + disp([T b ' EQUAL']); + d = 0; +else + Cm = Cm(:); + Cx = Cx(:); + if( isreal(Cm) && isreal(Cx) ) + rx = Cx ~= Cm; + d = max(abs((Cx(rx)-Cm(rx))./Cm(rx))); + else + Cmr = real(Cm); + Cmi = imag(Cm); + Cxr = real(Cx); + Cxi = imag(Cx); + rx = Cxr ~= Cmr; + ix = Cxi ~= Cmi; + dr = max(abs((Cxr(rx)-Cmr(rx))./max(abs(Cmr(rx)),abs(Cmr(rx))))); + di = max(abs((Cxi(ix)-Cmi(ix))./max(abs(Cmi(ix)),abs(Cxi(ix))))); + if( isempty(dr) ) + d = di; + elseif( isempty(di) ) + d = dr; + else + d = max(dr,di); + end + end + disp([T b ' NOT EQUAL <--- Max relative difference: ' num2str(d)]); +end +if( isreal(A) ) + if( d == 0 ) + x = [T b ' 0']; + else + x = [T b sprintf('%11.2e',d)]; + end + mtimesx_dtable(r,1:length(x)) = x; +else + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,1:length(T)) = T; + mtimesx_dtable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function running_time(d) +h = 24*d; +hh = floor(h); +m = 60*(h - hh); +mm = floor(m); +s = 60*(m - mm); +ss = floor(s); +disp(' '); +rt = sprintf('Running time hh:mm:ss = %2.0f:%2.0f:%2.0f',hh,mm,ss); +if( rt(28) == ' ' ) + rt(28) = '0'; +end +if( rt(31) == ' ' ) + rt(31) = '0'; +end +disp(rt); +disp(' '); +return +end diff --git a/ext/mtimesx/mtimesx_test_dsspeed.m b/ext/mtimesx/mtimesx_test_dsspeed.m new file mode 100644 index 0000000000000000000000000000000000000000..bb34c46fa4ec0de2bedf2ad2016cdd5e64f9feac --- /dev/null +++ b/ext/mtimesx/mtimesx_test_dsspeed.m @@ -0,0 +1,4754 @@ +% Test routine for mtimesx, op(double) * op(single) speed vs MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_dsspeed +% Filename: mtimesx_test_dsspeed.m +% Programmer: James Tursa +% Version: 1.0 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax (arguments in brackets [ ] are optional): +% +% T = mtimesx_test_ddspeed( [N [,D]] ) +% +% Inputs: +% +% N = Number of runs to make for each individual test. The test result will +% be the median of N runs. N must be even. If N is odd, it will be +% automatically increased to the next even number. The default is 10, +% which can take *hours* to run. Best to run this program overnight. +% D = The string 'details'. If present, this will cause all of the +% individual intermediate run results to print as they happen. +% +% Output: +% +% T = A character array containing a summary of the results. +% +%-------------------------------------------------------------------------- + +function ttable = mtimesx_test_dsspeed(nn,details) + +global mtimesx_ttable + +disp(' '); +disp('****************************************************************************'); +disp('* *'); +disp('* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *'); +disp('* *'); +disp('* This test program can take several *hours* to complete, particularly *'); +disp('* when using the default number of runs as 10. It is strongly suggested *'); +disp('* to close all applications and run this program overnight to get the *'); +disp('* best possible result with minimal impacts to your computer usage. *'); +disp('* *'); +disp('* The program will be done when you see the message: DONE ! *'); +disp('* *'); +disp('****************************************************************************'); +disp(' '); +try + input('Press Enter to start test, or Ctrl-C to exit ','s'); +catch + ttable = ''; + return +end + +start_time = datenum(clock); + +if nargin >= 1 + n = nn; +else + n = 10; +end +if nargin < 2 + details = false; +else + if( isempty(details) ) % code to get rid of the lint message + details = true; + else + details = true; + end +end + +RC = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +compver = [computer ', ' version ', mtimesx mode ' mtimesx ', median of ' num2str(n) ' runs']; +k = length(compver); + +mtimesx_ttable = char([]); +mtimesx_ttable(100,74) = ' '; +mtimesx_ttable(1,1:k) = compver; +mtimesx_ttable(2,:) = RC; +for r=3:170 +mtimesx_ttable(r,:) = ' -- -- -- --'; +end + +disp(' '); +disp(compver); +disp('Test program for function mtimesx:') +disp('----------------------------------'); + +rsave = 2; + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = single(rand(1,1)); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400)); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1)); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1)); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500)); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000)); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1)); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = single(rand(1,1)); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400)); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1)); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1)); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500)); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000)); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1)); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real).'''); +disp(' '); + +rsave = r; + +mtimesx_ttable(r,:) = RC; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1)); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000)); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1)); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000)); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000)); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000)); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1)); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000)); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000)); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1)); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000)); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1)); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000)); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000)); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000)); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1)); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000)); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000)); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = single(rand(1,1)); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400)); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1)); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1)); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500)); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000)); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1)); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = single(rand(1,1)); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400)); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1)); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1)); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500)); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000)); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1)); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400)); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1)); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500)); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000)); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1)); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400)); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1)); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500)); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000)); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1)); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000)); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1)); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000)); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000)); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000)); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1)); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000)); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000)); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000)); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1)); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000)); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000)); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000)); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1)); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000)); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000)); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400)); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1)); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500)); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000)); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1)); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400)); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1)); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500)); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000)); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1)); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400)); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1)); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500)); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000)); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1)); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400)); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1)); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500)); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000)); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1)); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000)); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1)); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000)); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000)); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000)); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1)); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000)); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000)); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000)); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1)); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000)); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000)); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000)); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1)); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000)); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000)); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400)); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1)); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500)); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000)); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1)); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400)); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1)); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500)); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000)); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1)); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10000000,1) + rand(10000000,1)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2500) + rand(1,2500)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,1) + rand(2000,1)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = single(rand(1,1)); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400)); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1)); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1)); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500)); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000)); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1)); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = single(rand(1,1)); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400)); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1)); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1)); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500)); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000)); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1)); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1)); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000)); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1)); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000)); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000)); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000)); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1)); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000)); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000)); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1)); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1)); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000)); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1)); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000)); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000)); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1)); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,40) + rand(10,20,30,40)*1i; +B = single(rand(1,1)); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000)); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1)); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000)); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000)); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1000000,1) + rand(1000000,1)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000)); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = single(rand(1,1)); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400)); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1)); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1)); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500)); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000)); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1)); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000)); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000)); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = single(rand(1,1)); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400)); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1)); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1)); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500)); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000)); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1)); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000)); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1000000) + rand(1,1000000)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,1) + rand(1,1)*1i; +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = rand(10,20,30,400) + rand(10,20,30,400)*1i; +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,10000000) + rand(1,10000000)*1i; +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2500,1) + rand(2500,1)*1i; +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(1,2000) + rand(1,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = rand(2000,2000) + rand(2000,2000)*1i; +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... symmetric cases op(A) * op(A)']); +disp(' '); +disp('real'); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = rand(2000); +maxtimesymCN('Matrix'' * Same ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymNC('Matrix * Same'' ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymTN('Matrix.'' * Same ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymNT('Matrix * Same.'' ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymGC('conj(Matrix) * Same'' ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymCG('Matrix'' * conj(Same)',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymGT('conj(Matrix) * Same.'' ',A,n,details,r); + +r = r + 1; +A = rand(2000); +maxtimesymTG('Matrix.'' * conj(Same)',A,n,details,r); + +r = rsave; + +disp(' '); +disp('complex'); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymCN('Matrix'' * Same ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymNC('Matrix * Same'' ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymTN('Matrix.'' * Same ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymNT('Matrix * Same.'' ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymGC('conj(Matrix) * Same'' ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymCG('Matrix'' * conj(Same)',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymGT('conj(Matrix) * Same.'' ',A,n,details,r); + +r = r + 1; +A = rand(2000) + rand(2000)*1i; +maxtimesymTG('Matrix.'' * conj(Same)',A,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... special scalar cases']); +disp(' '); +disp('(scalar) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = 1; +B = single(rand(2500)); +maxtimeNN('( 1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = single(rand(2500)); +maxtimeNN('( 1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = single(rand(2500)); +maxtimeNN('( 1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = single(rand(2500)); +maxtimeNN('( 1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1; +B = single(rand(2500)); +maxtimeNN('(-1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = single(rand(2500)); +maxtimeNN('(-1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = single(rand(2500)); +maxtimeNN('(-1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = single(rand(2500)); +maxtimeNN('(-1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = single(rand(2500)); +maxtimeNN('( 2+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = single(rand(2500)); +maxtimeNN('( 2-1i) * Matrix ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = 1; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('(-1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('(-1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('(-1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('(-1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 2+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 2-1i) * Matrix ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +%r = rsave; + +r = r + 1; +A = 1; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 1 + 2i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('(-1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('(-1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('(-1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = -1 + 2i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('(-1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 2 + 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 2+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = 2 - 1i; +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 2-1i) * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(' --- DONE ! ---'); +disp(' '); +disp(['Summary of Timing Tests, ' num2str(n) ' runs, + = percent faster, - = percent slower:']); +disp(' '); +mtimesx_ttable(1,1:k) = compver; +disp(mtimesx_ttable); +disp(' '); + +ttable = mtimesx_ttable; + +running_time(datenum(clock) - start_time); + +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B; + mtoc(k) = toc; + tic; + mtimesx(A,B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B'; + mtoc(k) = toc; + tic; + mtimesx(A,B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymCN(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*A; + mtoc(k) = toc; + tic; + mtimesx(A,'C',A); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymNC(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*A'; + mtoc(k) = toc; + tic; + mtimesx(A,A,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymTN(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*A; + mtoc(k) = toc; + tic; + mtimesx(A,'T',A); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymNT(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*A.'; + mtoc(k) = toc; + tic; + mtimesx(A,A,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymCG(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*conj(A); + mtoc(k) = toc; + tic; + mtimesx(A,'C',A,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymGC(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*A'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',A,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymTG(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*conj(A); + mtoc(k) = toc; + tic; + mtimesx(A,'T',A,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymGT(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*A.'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',A,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeout(T,A,B,p,r) +global mtimesx_ttable +mtimesx_ttable(r,1:length(T)) = T; +if( isreal(A) && isreal(B) ) + lt = length(T); + b = repmat(' ',1,30-lt); + x = [T b sprintf('%10.0f%%',-p)]; + mtimesx_ttable(r,1:length(x)) = x; +elseif( isreal(A) && ~isreal(B) ) + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,42:41+length(x)) = x; +elseif( ~isreal(A) && isreal(B) ) + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,53:52+length(x)) = x; +else + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymout(T,A,p,r) +global mtimesx_ttable +if( isreal(A) ) + lt = length(T); + b = repmat(' ',1,30-lt); + x = [T b sprintf('%10.0f%%',-p)]; + mtimesx_ttable(r,1:length(x)) = x; +else + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,1:length(T)) = T; + mtimesx_ttable(r,64:63+length(x)) = x; +end +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function running_time(d) +h = 24*d; +hh = floor(h); +m = 60*(h - hh); +mm = floor(m); +s = 60*(m - mm); +ss = floor(s); +disp(' '); +rt = sprintf('Running time hh:mm:ss = %2.0f:%2.0f:%2.0f',hh,mm,ss); +if( rt(28) == ' ' ) + rt(28) = '0'; +end +if( rt(31) == ' ' ) + rt(31) = '0'; +end +disp(rt); +disp(' '); +return +end diff --git a/ext/mtimesx/mtimesx_test_nd.m b/ext/mtimesx/mtimesx_test_nd.m new file mode 100644 index 0000000000000000000000000000000000000000..0ef4814c956246b9dd12bbe838afe10b923ad285 --- /dev/null +++ b/ext/mtimesx/mtimesx_test_nd.m @@ -0,0 +1,493 @@ +% Test routine for mtimesx, multi-dimensional speed and equality to MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_nd +% Filename: mtimesx_test_nd.m +% Programmer: James Tursa +% Version: 1.40 +% Date: October 4, 2010 +% Copyright: (c) 2009,2010 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax: +% +% A = mtimesx_test_nd % default n=4 is used +% A = mtimesx_test_nd(n) +% +% where n = number of repetitions (should be 4 <= n <= 100) +% +% Output: +% +% Prints out speed and equality test results. +% A = cell array with tabled results. +% +% 2010/Oct/04 --> 1.40, Added OpenMP support for custom code +% Expanded sparse * single and sparse * nD support +% +%-------------------------------------------------------------------------- + +function Cr = mtimesx_test_nd(n) +mtimesx; % load the mex routine into memory +if( nargin == 0 ) + n = 4; +else + n = floor(n); + if( ~(n >= 4 && n <= 100) ) + n = 4; + end +end +cn = sprintf('%g',n); + +disp(' '); +disp('MTIMESX multi-dimensional equality and speed tests'); +disp('--------------------------------------------------'); +disp(' '); +disp('(M x K) * ( K x N) equality tests, SPEED mode, M,K,N <= 4'); +trans = 'NGTC'; +cmpx = {'real ','cmpx '}; +mtimesx('speed'); +smallok = true; +for m=1:4 + for k=1:4 + for n=1:4 + for transa=1:4 + if( transa <= 2 ) + ma = m; + ka = k; + else + ma = k; + ka = m; + end + for transb=1:4 + if( transb <= 2 ) + kb = k; + nb = n; + else + kb = n; + nb = k; + end + for cmplxa=1:2 + if( cmplxa == 1 ) + A = floor(rand(ma,ka)*100+1); + else + A = floor(rand(ma,ka)*100+1) + floor(rand(ma,ka)*100+1)*1i; + end + for cmplxb=1:2 + if( cmplxb == 1 ) + B = floor(rand(kb,nb)*100+1); + else + B = floor(rand(kb,nb)*100+1) + floor(rand(kb,nb)*100+1)*1i; + end + Cm = mtimesx_sparse(A,trans(transa),B,trans(transb)); + Cx = mtimesx(A,trans(transa),B,trans(transb)); + if( isequal(Cm,Cx) ) + disp(['(' cmpx{cmplxa} num2str(m) ' x ' num2str(k) ')' trans(transa) ... + ' * (' cmpx{cmplxb} num2str(k) ' x ' num2str(n) ')' trans(transb) ' EQUAL']); + else + disp(['(' cmpx{cmplxa} num2str(m) ' x ' num2str(k) ')' trans(transa) ... + ' * (' cmpx{cmplxb} num2str(k) ' x ' num2str(n) ')' trans(transb) ' NOT EQUAL']); + smallok = false; + end + end + end + end + end + end + end +end + +if( mtimesx('openmp') ) +disp(' '); +disp('(M x K) * ( K x N) equality tests, SPEEDOMP mode, M,K,N <= 4'); +mtimesx('speedomp'); +smallokomp = true; +for m=1:4 + for k=1:4 + for n=1:4 + for transa=1:4 + if( transa <= 2 ) + ma = m; + ka = k; + else + ma = k; + ka = m; + end + for transb=1:4 + if( transb <= 2 ) + kb = k; + nb = n; + else + kb = n; + nb = k; + end + for cmplxa=1:2 + if( cmplxa == 1 ) + A = floor(rand(ma,ka)*100+1); + else + A = floor(rand(ma,ka)*100+1) + floor(rand(ma,ka)*100+1)*1i; + end + A = reshape(repmat(A,1000,1),ma,ka,1000); + for cmplxb=1:2 + if( cmplxb == 1 ) + B = floor(rand(kb,nb)*100+1); + else + B = floor(rand(kb,nb)*100+1) + floor(rand(kb,nb)*100+1)*1i; + end + B = reshape(repmat(B,1000,1),kb,nb,1000); + Cm = mtimesx_sparse(A(:,:,1),trans(transa),B(:,:,1),trans(transb)); + Cx = mtimesx(A,trans(transa),B,trans(transb)); + if( isequal(Cm,Cx(:,:,1)) ) + disp(['(' cmpx{cmplxa} num2str(m) ' x ' num2str(k) ')' trans(transa) ... + ' * (' cmpx{cmplxb} num2str(k) ' x ' num2str(n) ')' trans(transb) ' EQUAL']); + else + disp(['(' cmpx{cmplxa} num2str(m) ' x ' num2str(k) ')' trans(transa) ... + ' * (' cmpx{cmplxb} num2str(k) ' x ' num2str(n) ')' trans(transb) ' NOT EQUAL']); + smallokomp = false; + end + end + end + end + end + end + end +end +end + +disp(' '); +if( smallok ) + disp('All small matrix multiplies are OK in SPEED mode'); +else + disp('ERROR --> One or more of the small matrix multiplies was not equal in SPEED mode'); +end +if( mtimesx('openmp') ) +if( smallokomp ) + disp('All small matrix multiplies are OK in SPEEDOMP mode'); +else + disp('ERROR --> One or more of the small matrix multiplies was not equal in SPEEDOMP mode'); +end +end + +disp(' '); +disp(['mtimesx multi-dimensional test routine using ' cn ' repetitions']); + +if( mtimesx('OPENMP') ) + topm = 6; +else + topm = 4; +end +Cr = cell(6,topm+1); +Cr{1,1} = 'All operands real'; + +for m=2:topm+1 +if( m == 2 ) + mtimesx('BLAS'); +elseif( m == 3 ) + mtimesx('LOOPS'); +elseif( m == 4 ) + mtimesx('MATLAB'); +elseif( m == 5 ) + mtimesx('SPEED'); +elseif( m == 6 ) + mtimesx('LOOPSOMP'); +else + mtimesx('SPEEDOMP'); +end +Cr{1,m} = mtimesx; + +disp(' '); +disp('--------------------------------------------------------------'); +disp('--------------------------------------------------------------'); +disp(' '); +disp(['MTIMESX mode: ' mtimesx]); +disp(' '); +disp('(real 3x5x1x4x3x2x1x8) * (real 5x7x3x1x3x2x5) example'); +Cr{2,1} = '(3x5xND) *(5x7xND)'; +A = rand(3,5,1,4,3,2,1,8); +B = rand(5,7,3,1,3,2,5); +% mtimes +tm = zeros(1,n); +for k=1:n +clear Cm +A(1) = 2*A(1); +B(1) = 2*B(1); +tic +Cm = zeros(3,7,3,4,3,2,5,8); +for k1=1:3 + for k2=1:4 + for k3=1:3 + for k4=1:2 + for k5=1:5 + for k6=1:8 + Cm(:,:,k1,k2,k3,k4,k5,k6) = A(:,:,1,k2,k3,k4,1,k6) * B(:,:,k1,1,k3,k4,k5); + end + end + end + end + end +end +tm(k) = toc; +end +% mtimesx +tx = zeros(1,n); +for k=1:n +clear Cx +tic +Cx = mtimesx(A,B); +tx(k) = toc; +end +% results +tm = median(tm); +tx = median(tx); +if( tx < tm ) + faster = sprintf('%7.1f',100*(tm)/tx-100); + slower = ''; +else + faster = sprintf('%7.1f',-(100*(tx)/tm-100)); + slower = ' (i.e., slower)'; +end +Cr{2,m} = faster; +disp(' '); +disp(['mtimes Elapsed time ' num2str(tm) ' seconds.']); +disp(['MTIMESX Elapsed time ' num2str(tx) ' seconds.']); +disp(['MTIMESX ' mtimesx ' mode is ' faster '% faster than MATLAB mtimes' slower]) +if( isequal(Cx,Cm) ) + disp(['MTIMESX ' mtimesx ' mode result matches mtimes: EQUAL']) +else + dx = max(abs(Cx(:)-Cm(:))); + disp(['MTIMESX ' mtimesx ' mode result does not match mtimes: NOT EQUAL , max diff = ' num2str(dx)]) +end + +disp(' '); +disp('--------------------------------------------------------------'); +disp('(real 3x3x1000000) * (real 3x3x1000000) example'); +Cr{3,1} = '(3x3xN) *(3x3xN)'; +A = rand(3,3,1000000); +B = rand(3,3,1000000); +% mtimes +tm = zeros(1,n); +for k=1:n +clear Cm +A(1) = 2*A(1); +B(1) = 2*B(1); +tic +Cm = zeros(3,3,1000000); +for k1=1:1000000 + Cm(:,:,k1) = A(:,:,k1) * B(:,:,k1); +end +tm(k) = toc; +end +% mtimesx +tx = zeros(1,n); +for k=1:n +clear Cx +tic +Cx = mtimesx(A,B); +tx(k) = toc; +end +% results +tm = median(tm); +tx = median(tx); +if( tx < tm ) + faster = sprintf('%7.1f',100*(tm)/tx-100); + slower = ''; +else + faster = sprintf('%7.1f',-(100*(tx)/tm-100)); + slower = ' (i.e., slower)'; +end +Cr{3,m} = faster; +disp(' '); +disp(['mtimes Elapsed time ' num2str(tm) ' seconds.']); +disp(['MTIMESX Elapsed time ' num2str(tx) ' seconds.']); +disp(['MTIMESX ' mtimesx ' mode is ' faster '% faster than MATLAB mtimes' slower]) +if( isequal(Cx,Cm) ) + disp(['MTIMESX ' mtimesx ' mode result matches mtimes: EQUAL']) +else + dx = max(abs(Cx(:)-Cm(:))); + disp(['MTIMESX ' mtimesx ' mode result does not match mtimes: NOT EQUAL , max diff = ' num2str(dx)]) +end + +disp(' '); +disp('--------------------------------------------------------------'); +disp('(real 2x2x2000000) * (real 2x2x2000000) example'); +Cr{4,1} = '(2x2xN) *(2x2xN)'; +A = rand(2,2,2000000); +B = rand(2,2,2000000); +% mtimes +tm = zeros(1,n); +for k=1:n +clear Cm +A(1) = 2*A(1); +B(1) = 2*B(1); +tic +Cm = zeros(2,2,2000000); +for k1=1:2000000 + Cm(:,:,k1) = A(:,:,k1) * B(:,:,k1); +end +tm(k) = toc; +end +% mtimesx +tx = zeros(1,n); +for k=1:n +clear Cx +tic +Cx = mtimesx(A,B); +tx(k) = toc; +end +% results +tm = median(tm); +tx = median(tx); +if( tx < tm ) + faster = sprintf('%7.1f',100*(tm)/tx-100); + slower = ''; +else + faster = sprintf('%7.1f',-(100*(tx)/tm-100)); + slower = ' (i.e., slower)'; +end +Cr{4,m} = faster; +disp(' '); +disp(['mtimes Elapsed time ' num2str(tm) ' seconds.']); +disp(['MTIMESX Elapsed time ' num2str(tx) ' seconds.']); +disp(['MTIMESX ' mtimesx ' mode is ' faster '% faster than MATLAB mtimes' slower]) +if( isequal(Cx,Cm) ) + disp(['MTIMESX ' mtimesx ' mode result matches mtimes: EQUAL']) +else + dx = max(abs(Cx(:)-Cm(:))); + disp(['MTIMESX ' mtimesx ' mode result does not match mtimes: NOT EQUAL , max diff = ' num2str(dx)]) +end + +disp(' '); +disp('--------------------------------------------------------------'); +disp('(real 2x2x2000000) * (real 1x1x2000000) example'); +Cr{5,1} = '(2x2xN) *(1x1xN)'; +A = rand(2,2,2000000); +B = rand(1,1,2000000); +% mtimes +tm = zeros(1,n); +for k=1:n +clear Cm +A(1) = 2*A(1); +B(1) = 2*B(1); +tic +Cm = zeros(2,2,2000000); +for k1=1:2000000 + Cm(:,:,k1) = A(:,:,k1) * B(:,:,k1); +end +tm(k) = toc; +end +% mtimesx +tx = zeros(1,n); +for k=1:n +clear Cx +tic +Cx = mtimesx(A,B); +tx(k) = toc; +end +% results +tm = median(tm); +tx = median(tx); +if( tx < tm ) + faster = sprintf('%7.1f',100*(tm)/tx-100); + slower = ''; +else + faster = sprintf('%7.1f',-(100*(tx)/tm-100)); + slower = ' (i.e., slower)'; +end +Cr{5,m} = faster; +disp(' '); +disp(['mtimes Elapsed time ' num2str(tm) ' seconds.']); +disp(['MTIMESX Elapsed time ' num2str(tx) ' seconds.']); +disp(['MTIMESX ' mtimesx ' mode is ' faster '% faster than MATLAB mtimes' slower]) +if( isequal(Cx,Cm) ) + disp(['MTIMESX ' mtimesx ' mode result matches mtimes: EQUAL']) +else + dx = max(abs(Cx(:)-Cm(:))); + disp(['MTIMESX ' mtimesx ' mode result does not match mtimes: NOT EQUAL , max diff = ' num2str(dx)]) +end + +try +bsxfun(@times,1,1); +Cr{6,1} = 'above vs bsxfun'; +A = rand(2,2,2000000); +B = rand(1,1,2000000); +% bsxfun +tm = zeros(1,n); +for k=1:n +clear Cm +A(1) = 2*A(1); +B(1) = 2*B(1); +tic +Cm = bsxfun(@times,A,B); +tm(k) = toc; +end +% mtimesx +tx = zeros(1,n); +for k=1:n +clear Cx +tic +Cx = mtimesx(A,B); +tx(k) = toc; +end +% results +tm = median(tm); +tx = median(tx); +if( tx < tm ) + faster = sprintf('%7.1f',100*(tm)/tx-100); + slower = ''; +else + faster = sprintf('%7.1f',-(100*(tx)/tm-100)); + slower = ' (i.e., slower)'; +end +Cr{6,m} = faster; +disp(' '); +disp(['bsxfun Elapsed time ' num2str(tm) ' seconds.']); +disp(['MTIMESX Elapsed time ' num2str(tx) ' seconds.']); +disp(['MTIMESX ' mtimesx ' mode is ' faster '% faster than MATLAB bsxfun with @times' slower]) +if( isequal(Cx,Cm) ) + disp(['MTIMESX ' mtimesx ' mode result matches bsxfun with @times: EQUAL']) +else + dx = max(abs(Cx(:)-Cm(:))); + disp(['MTIMESX ' mtimesx ' mode result does not match bsxfun with @times: NOT EQUAL , max diff = ' num2str(dx)]) +end +catch + disp('Could not perform comparison with bsxfun, possibly because your version of'); + disp('MATLAB does not have it. You can download a substitute for bsxfun from the'); + disp('FEX here: http://www.mathworks.com/matlabcentral/fileexchange/23005-bsxfun-substitute'); +end + +end + +disp(' '); +disp('Percent Faster Results Table'); +disp(' '); +disp(Cr); + +disp(' '); +disp('Done'); +disp(' '); + +end diff --git a/ext/mtimesx/mtimesx_test_sdequal.m b/ext/mtimesx/mtimesx_test_sdequal.m new file mode 100644 index 0000000000000000000000000000000000000000..80906c4c0f65f05e66b115ac31b1361bb1697b9c --- /dev/null +++ b/ext/mtimesx/mtimesx_test_sdequal.m @@ -0,0 +1,4041 @@ +% Test routine for mtimesx, op(single) * op(double) equality vs MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_sdequal +% Filename: mtimesx_test_sdequal.m +% Programmer: James Tursa +% Version: 1.0 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax: +% +% T = mtimesx_test_ddequal +% +% Output: +% +% T = A character array containing a summary of the results. +% +%-------------------------------------------------------------------------- + +function dtable = mtimesx_test_sdequal + +global mtimesx_dtable + +disp(' '); +disp('****************************************************************************'); +disp('* *'); +disp('* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *'); +disp('* *'); +disp('* This test program can take an hour or so to complete. It is suggested *'); +disp('* that you close all applications and run this program during your lunch *'); +disp('* break or overnight to minimize impacts to your computer usage. *'); +disp('* *'); +disp('* The program will be done when you see the message: DONE ! *'); +disp('* *'); +disp('****************************************************************************'); +disp(' '); +try + input('Press Enter to start test, or Ctrl-C to exit ','s'); +catch + dtable = ''; + return +end + +start_time = datenum(clock); + +compver = [computer ', ' version ', mtimesx mode ' mtimesx]; +k = length(compver); +RC = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +mtimesx_dtable = char([]); +mtimesx_dtable(157,74) = ' '; +mtimesx_dtable(1,1:k) = compver; +mtimesx_dtable(2,:) = RC; +for r=3:157 +mtimesx_dtable(r,:) = ' -- -- -- --'; +end + +disp(' '); +disp(compver); +disp('Test program for function mtimesx:') +disp('----------------------------------'); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real)'); +disp(' '); + +rsave = 2; + +r = rsave; + +%if( false ) % debug jump + +if( isequal([]*[],mtimesx([],[])) ) + disp('Empty * Empty EQUAL'); +else + disp('Empty * Empty NOT EQUAL <---'); +end + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = rand(1,1); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = rand(1,1); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNN('Matrix * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real).'''); +disp(' '); + +if( isequal([]*[].',mtimesx([],[],'T')) ) + disp('Empty * Empty.'' EQUAL'); +else + disp('Empty * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(10000,1); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real)'''); +disp(' '); + +if( isequal([]*[]',mtimesx([],[],'C')) ) + disp('Empty * Empty'' EQUAL'); +else + disp('Empty * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(10000,1); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * conj(real)'); +disp(' '); + +%if( false ) % debug jump + +if( isequal([]*conj([]),mtimesx([],[],'G')) ) + disp('Empty * conj(Empty) EQUAL'); +else + disp('Empty * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = rand(1,1); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj((real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = rand(1,1); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real)'); +disp(' '); + +if( isequal([]'*[],mtimesx([],'C',[])) ) + disp('Empty.'' * Empty EQUAL'); +else + disp('Empty.'' * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real).'''); +disp(' '); + +if( isequal([].'*[]',mtimesx([],'T',[],'C')) ) + disp('Empty.'' * Empty.'' EQUAL'); +else + disp('Empty.'' * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(10000,1); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real)'''); +disp(' '); + +if( isequal([].'*[]',mtimesx([],'T',[],'C')) ) + disp('Empty.'' * Empty'' EQUAL'); +else + disp('Empty.'' * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(10000,1); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * conj(real)'); +disp(' '); + +if( isequal([]'*conj([]),mtimesx([],'C',[],'G')) ) + disp('Empty.'' * conj(Empty) EQUAL'); +else + disp('Empty.'' * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real)'); +disp(' '); + +if( isequal([]'*[],mtimesx([],'C',[])) ) + disp('Empty'' * Empty EQUAL'); +else + disp('Empty'' * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real).'''); +disp(' '); + +if( isequal([]'*[]',mtimesx([],'C',[],'C')) ) + disp('Empty'' * Empty.'' EQUAL'); +else + disp('Empty'' * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(10000,1); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real)'''); +disp(' '); + +if( isequal([]'*[]',mtimesx([],'C',[],'C')) ) + disp('Empty'' * Empty'' EQUAL'); +else + disp('Empty'' * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(10000,1); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * conj(real)'); +disp(' '); + +if( isequal([]'*conj([]),mtimesx([],'C',[],'G')) ) + disp('Empty'' * conj(Empty) EQUAL'); +else + disp('Empty'' * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real)'); +disp(' '); + +if( isequal(conj([])*[],mtimesx([],'G',[])) ) + disp('conj(Empty) * Empty EQUAL'); +else + disp('conj(Empty) * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = rand(1,1); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = rand(1,1); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real).'''); +disp(' '); + +if( isequal(conj([])*[].',mtimesx([],'G',[],'T')) ) + disp('conj(Empty) * Empty.'' EQUAL'); +else + disp('conj(Empty) * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(10000,1); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real)'''); +disp(' '); + +if( isequal(conj([])*[]',mtimesx([],'G',[],'C')) ) + disp('conj(Empty) * Empty'' EQUAL'); +else + disp('conj(Empty) * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(10000,1); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1,1000) + rand(1,1000)*1i; +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * conj(real)'); +disp(' '); + +if( isequal(conj([])*conj([]),mtimesx([],'G',[],'G')) ) + disp('conj(Empty) * conj(Empty) EQUAL'); +else + disp('conj(Empty) * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = rand(1,1); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = rand(1,1); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,10000) + rand(1,10000)*1i; +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,40) + rand(10,20,30,40)*1i; +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1) + rand(1000,1)*1i; +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = rand(1000,1000) + rand(1000,1000)*1i; +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ... symmetric cases op(A) * op(A)'); +disp(' '); +disp('real'); + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(2000)); +maxdiffsymCN('Matrix'' * Same ',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymNC('Matrix * Same''',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymTN('Matrix.'' * Same ',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymNT('Matrix * Same.''',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymGC('conj(Matrix) * Same''',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymCG('Matrix'' * conj(Same)',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymGT('conj(Matrix) * Same.'' ',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymTG('Matrix.'' * conj(Same)',A,r); + +r = rsave; + +disp(' ' ); +disp('complex'); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymCN('Matrix'' * Same ',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymNC('Matrix * Same''',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymTN('Matrix.'' * Same ',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymNT('Matrix * Same.''',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymGC('conj(Matrix) * Same''',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymCG('Matrix'' * conj(Same)',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymGT('conj(Matrix) * Same.''',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymTG('Matrix.'' * conj(Same)',A,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ... special scalar cases'); +disp(' '); +disp('(scalar) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_dtable(r,:) = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +rsave = r; + +r = r + 1; +A = single(1); +B = rand(2500); +maxdiffNN('( 1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 + 1i); +B = rand(2500); +maxdiffNN('( 1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 - 1i); +B = rand(2500); +maxdiffNN('( 1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 + 2i); +B = rand(2500); +maxdiffNN('( 1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1); +B = rand(2500); +maxdiffNN('(-1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 + 1i); +B = rand(2500); +maxdiffNN('(-1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 - 1i); +B = rand(2500); +maxdiffNN('(-1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 + 2i); +B = rand(2500); +maxdiffNN('(-1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = single(2 + 1i); +B = rand(2500); +maxdiffNN('( 2+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(2 - 1i); +B = rand(2500); +maxdiffNN('( 2-1i) * Matrix ',A,B,r); + +disp(' '); +disp('(scalar) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(1); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 + 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 - 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 + 2i); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('(-1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 + 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('(-1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 - 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('(-1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 + 2i); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('(-1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = single(2 + 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 2+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(2 - 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNN('( 2-1i) * Matrix ',A,B,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +%r = rsave; + +r = r + 1; +A = single(1); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 1+0i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(1 + 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 1+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(1 - 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 1-1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(1 + 2i); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 1+2i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(-1); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('(-1+0i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(-1 + 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('(-1+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(-1 - 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('(-1-1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(-1 + 2i); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('(-1+2i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(2 + 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 2+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(2 - 1i); +B = rand(2500) + rand(2500)*1i; +maxdiffNC('( 2-1i) * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(' --- DONE ! ---'); +disp(' '); +disp('Summary of Numerical Comparison Tests, max relative element difference:'); +disp(' '); +mtimesx_dtable(1,1:k) = compver; +disp(mtimesx_dtable); +disp(' '); + +dtable = mtimesx_dtable; + +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNN(T,A,B,r) +Cm = A*B; +Cx = mtimesx(A,B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCN(T,A,B,r) +Cm = A'*B; +Cx = mtimesx(A,'C',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTN(T,A,B,r) +Cm = A.'*B; +Cx = mtimesx(A,'T',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGN(T,A,B,r) +Cm = conj(A)*B; +Cx = mtimesx(A,'G',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNC(T,A,B,r) +Cm = A*B'; +Cx = mtimesx(A,B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCC(T,A,B,r) +Cm = A'*B'; +Cx = mtimesx(A,'C',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTC(T,A,B,r) +Cm = A.'*B'; +Cx = mtimesx(A,'T',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGC(T,A,B,r) +Cm = conj(A)*B'; +Cx = mtimesx(A,'G',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNT(T,A,B,r) +Cm = A*B.'; +Cx = mtimesx(A,B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCT(T,A,B,r) +Cm = A'*B.'; +Cx = mtimesx(A,'C',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTT(T,A,B,r) +Cm = A.'*B.'; +Cx = mtimesx(A,'T',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGT(T,A,B,r) +Cm = conj(A)*B.'; +Cx = mtimesx(A,'G',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNG(T,A,B,r) +Cm = A*conj(B); +Cx = mtimesx(A,B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCG(T,A,B,r) +Cm = A'*conj(B); +Cx = mtimesx(A,'C',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTG(T,A,B,r) +Cm = A.'*conj(B); +Cx = mtimesx(A,'T',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGG(T,A,B,r) +Cm = conj(A)*conj(B); +Cx = mtimesx(A,'G',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymCN(T,A,r) +Cm = A'*A; +Cx = mtimesx(A,'C',A); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymNC(T,A,r) +Cm = A*A'; +Cx = mtimesx(A,A,'C'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymTN(T,A,r) +Cm = A.'*A; +Cx = mtimesx(A,'T',A); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymNT(T,A,r) +Cm = A*A.'; +Cx = mtimesx(A,A,'T'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymTG(T,A,r) +Cm = A.'*conj(A); +Cx = mtimesx(A,'T',A,'G'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymGT(T,A,r) +Cm = conj(A)*A.'; +Cx = mtimesx(A,'G',A,'T'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymCG(T,A,r) +Cm = A'*conj(A); +Cx = mtimesx(A,'C',A,'G'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymGC(T,A,r) +Cm = conj(A)*A'; +Cx = mtimesx(A,'G',A,'C'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffout(T,A,B,Cm,Cx,r) +global mtimesx_dtable +lt = length(T); +b = repmat(' ',1,30-lt); +if( isequal(Cm,Cx) ) + disp([T b ' EQUAL']); + d = 0; +else + Cm = Cm(:); + Cx = Cx(:); + if( isreal(Cm) && isreal(Cx) ) + rx = Cx ~= Cm; + d = max(abs((Cx(rx)-Cm(rx))./Cm(rx))); + else + Cmr = real(Cm); + Cmi = imag(Cm); + Cxr = real(Cx); + Cxi = imag(Cx); + rx = Cxr ~= Cmr; + ix = Cxi ~= Cmi; + dr = max(abs((Cxr(rx)-Cmr(rx))./max(abs(Cmr(rx)),abs(Cmr(rx))))); + di = max(abs((Cxi(ix)-Cmi(ix))./max(abs(Cmi(ix)),abs(Cxi(ix))))); + if( isempty(dr) ) + d = di; + elseif( isempty(di) ) + d = dr; + else + d = max(dr,di); + end + end + disp([T b ' NOT EQUAL <--- Max relative difference: ' num2str(d)]); +end +mtimesx_dtable(r,1:length(T)) = T; +if( isreal(A) && isreal(B) ) + if( d == 0 ) + x = [T b ' 0']; + else + x = [T b sprintf('%11.2e',d)]; + end + mtimesx_dtable(r,1:length(x)) = x; +elseif( isreal(A) && ~isreal(B) ) + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,42:41+length(x)) = x; +elseif( ~isreal(A) && isreal(B) ) + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,53:52+length(x)) = x; +else + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymout(T,A,Cm,Cx,r) +global mtimesx_dtable +lt = length(T); +b = repmat(' ',1,30-lt); +if( isequal(Cm,Cx) ) + disp([T b ' EQUAL']); + d = 0; +else + Cm = Cm(:); + Cx = Cx(:); + if( isreal(Cm) && isreal(Cx) ) + rx = Cx ~= Cm; + d = max(abs((Cx(rx)-Cm(rx))./Cm(rx))); + else + Cmr = real(Cm); + Cmi = imag(Cm); + Cxr = real(Cx); + Cxi = imag(Cx); + rx = Cxr ~= Cmr; + ix = Cxi ~= Cmi; + dr = max(abs((Cxr(rx)-Cmr(rx))./max(abs(Cmr(rx)),abs(Cmr(rx))))); + di = max(abs((Cxi(ix)-Cmi(ix))./max(abs(Cmi(ix)),abs(Cxi(ix))))); + if( isempty(dr) ) + d = di; + elseif( isempty(di) ) + d = dr; + else + d = max(dr,di); + end + end + disp([T b ' NOT EQUAL <--- Max relative difference: ' num2str(d)]); +end +if( isreal(A) ) + if( d == 0 ) + x = [T b ' 0']; + else + x = [T b sprintf('%11.2e',d)]; + end + mtimesx_dtable(r,1:length(x)) = x; +else + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,1:length(T)) = T; + mtimesx_dtable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function running_time(d) +h = 24*d; +hh = floor(h); +m = 60*(h - hh); +mm = floor(m); +s = 60*(m - mm); +ss = floor(s); +disp(' '); +rt = sprintf('Running time hh:mm:ss = %2.0f:%2.0f:%2.0f',hh,mm,ss); +if( rt(28) == ' ' ) + rt(28) = '0'; +end +if( rt(31) == ' ' ) + rt(31) = '0'; +end +disp(rt); +disp(' '); +return +end diff --git a/ext/mtimesx/mtimesx_test_sdspeed.m b/ext/mtimesx/mtimesx_test_sdspeed.m new file mode 100644 index 0000000000000000000000000000000000000000..ef8336e4b03f995816873fefb69a77a382c68840 --- /dev/null +++ b/ext/mtimesx/mtimesx_test_sdspeed.m @@ -0,0 +1,4754 @@ +% Test routine for mtimesx, op(single) * op(double) speed vs MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_sdspeed +% Filename: mtimesx_test_sdspeed.m +% Programmer: James Tursa +% Version: 1.0 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax (arguments in brackets [ ] are optional): +% +% T = mtimesx_test_ddspeed( [N [,D]] ) +% +% Inputs: +% +% N = Number of runs to make for each individual test. The test result will +% be the median of N runs. N must be even. If N is odd, it will be +% automatically increased to the next even number. The default is 10, +% which can take *hours* to run. Best to run this program overnight. +% D = The string 'details'. If present, this will cause all of the +% individual intermediate run results to print as they happen. +% +% Output: +% +% T = A character array containing a summary of the results. +% +%-------------------------------------------------------------------------- + +function ttable = mtimesx_test_sdspeed(nn,details) + +global mtimesx_ttable + +disp(' '); +disp('****************************************************************************'); +disp('* *'); +disp('* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *'); +disp('* *'); +disp('* This test program can take several *hours* to complete, particularly *'); +disp('* when using the default number of runs as 10. It is strongly suggested *'); +disp('* to close all applications and run this program overnight to get the *'); +disp('* best possible result with minimal impacts to your computer usage. *'); +disp('* *'); +disp('* The program will be done when you see the message: DONE ! *'); +disp('* *'); +disp('****************************************************************************'); +disp(' '); +try + input('Press Enter to start test, or Ctrl-C to exit ','s'); +catch + ttable = ''; + return +end + +start_time = datenum(clock); + +if nargin >= 1 + n = nn; +else + n = 10; +end +if nargin < 2 + details = false; +else + if( isempty(details) ) % code to get rid of the lint message + details = true; + else + details = true; + end +end + +RC = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +compver = [computer ', ' version ', mtimesx mode ' mtimesx ', median of ' num2str(n) ' runs']; +k = length(compver); + +mtimesx_ttable = char([]); +mtimesx_ttable(100,74) = ' '; +mtimesx_ttable(1,1:k) = compver; +mtimesx_ttable(2,:) = RC; +for r=3:170 +mtimesx_ttable(r,:) = ' -- -- -- --'; +end + +disp(' '); +disp(compver); +disp('Test program for function mtimesx:') +disp('----------------------------------'); + +rsave = 2; + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = rand(1,1); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = rand(1,1); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real).'''); +disp(' '); + +rsave = r; + +mtimesx_ttable(r,:) = RC; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = rand(1,1); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = rand(1,1); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = rand(1,1); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = rand(1,1); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = rand(1,1); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(1,10000000) + rand(1,10000000)*1i; +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(2500,1) + rand(2500,1)*1i; +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(1,2000) + rand(1,2000)*1i; +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = rand(1,1); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = rand(1,1); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(1,1000000) + rand(1,1000000)*1i; +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = rand(10,20,30,400) + rand(10,20,30,400)*1i; +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = rand(1,1) + rand(1,1)*1i; +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = rand(10000000,1) + rand(10000000,1)*1i; +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = rand(1,2500) + rand(1,2500)*1i; +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,1) + rand(2000,1)*1i; +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = rand(2000,2000) + rand(2000,2000)*1i; +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... symmetric cases op(A) * op(A)']); +disp(' '); +disp('real'); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(2000)); +maxtimesymCN('Matrix'' * Same ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymNC('Matrix * Same'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymTN('Matrix.'' * Same ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymNT('Matrix * Same.'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymGC('conj(Matrix) * Same'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymCG('Matrix'' * conj(Same)',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymGT('conj(Matrix) * Same.'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymTG('Matrix.'' * conj(Same)',A,n,details,r); + +r = rsave; + +disp(' '); +disp('complex'); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymCN('Matrix'' * Same ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymNC('Matrix * Same'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymTN('Matrix.'' * Same ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymNT('Matrix * Same.'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymGC('conj(Matrix) * Same'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymCG('Matrix'' * conj(Same)',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymGT('conj(Matrix) * Same.'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymTG('Matrix.'' * conj(Same)',A,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... special scalar cases']); +disp(' '); +disp('(scalar) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(1); +B = rand(2500); +maxtimeNN('( 1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = rand(2500); +maxtimeNN('( 1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = rand(2500); +maxtimeNN('( 1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = rand(2500); +maxtimeNN('( 1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = rand(2500); +maxtimeNN('(-1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = rand(2500); +maxtimeNN('(-1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = rand(2500); +maxtimeNN('(-1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = rand(2500); +maxtimeNN('(-1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = rand(2500); +maxtimeNN('( 2+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = rand(2500); +maxtimeNN('( 2-1i) * Matrix ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(1); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('(-1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('(-1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('(-1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('(-1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 2+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNN('( 2-1i) * Matrix ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +%r = rsave; + +r = r + 1; +A = single(1); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('(-1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('(-1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('(-1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('(-1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 2+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = rand(2500) + rand(2500)*1i; +maxtimeNC('( 2-1i) * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(' --- DONE ! ---'); +disp(' '); +disp(['Summary of Timing Tests, ' num2str(n) ' runs, + = percent faster, - = percent slower:']); +disp(' '); +mtimesx_ttable(1,1:k) = compver; +disp(mtimesx_ttable); +disp(' '); + +ttable = mtimesx_ttable; + +running_time(datenum(clock) - start_time); + +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B; + mtoc(k) = toc; + tic; + mtimesx(A,B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B'; + mtoc(k) = toc; + tic; + mtimesx(A,B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymCN(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*A; + mtoc(k) = toc; + tic; + mtimesx(A,'C',A); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymNC(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*A'; + mtoc(k) = toc; + tic; + mtimesx(A,A,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymTN(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*A; + mtoc(k) = toc; + tic; + mtimesx(A,'T',A); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymNT(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*A.'; + mtoc(k) = toc; + tic; + mtimesx(A,A,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymCG(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*conj(A); + mtoc(k) = toc; + tic; + mtimesx(A,'C',A,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymGC(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*A'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',A,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymTG(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*conj(A); + mtoc(k) = toc; + tic; + mtimesx(A,'T',A,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymGT(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*A.'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',A,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeout(T,A,B,p,r) +global mtimesx_ttable +mtimesx_ttable(r,1:length(T)) = T; +if( isreal(A) && isreal(B) ) + lt = length(T); + b = repmat(' ',1,30-lt); + x = [T b sprintf('%10.0f%%',-p)]; + mtimesx_ttable(r,1:length(x)) = x; +elseif( isreal(A) && ~isreal(B) ) + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,42:41+length(x)) = x; +elseif( ~isreal(A) && isreal(B) ) + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,53:52+length(x)) = x; +else + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymout(T,A,p,r) +global mtimesx_ttable +if( isreal(A) ) + lt = length(T); + b = repmat(' ',1,30-lt); + x = [T b sprintf('%10.0f%%',-p)]; + mtimesx_ttable(r,1:length(x)) = x; +else + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,1:length(T)) = T; + mtimesx_ttable(r,64:63+length(x)) = x; +end +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function running_time(d) +h = 24*d; +hh = floor(h); +m = 60*(h - hh); +mm = floor(m); +s = 60*(m - mm); +ss = floor(s); +disp(' '); +rt = sprintf('Running time hh:mm:ss = %2.0f:%2.0f:%2.0f',hh,mm,ss); +if( rt(28) == ' ' ) + rt(28) = '0'; +end +if( rt(31) == ' ' ) + rt(31) = '0'; +end +disp(rt); +disp(' '); +return +end diff --git a/ext/mtimesx/mtimesx_test_ssequal.m b/ext/mtimesx/mtimesx_test_ssequal.m new file mode 100644 index 0000000000000000000000000000000000000000..d206c2c3b6dc24cbb9c16fbb250589f850e73541 --- /dev/null +++ b/ext/mtimesx/mtimesx_test_ssequal.m @@ -0,0 +1,4041 @@ +% Test routine for mtimesx, op(single) * op(single) equality vs MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_ssequal +% Filename: mtimesx_test_ssequal.m +% Programmer: James Tursa +% Version: 1.0 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax: +% +% T = mtimesx_test_ssequal +% +% Output: +% +% T = A character array containing a summary of the results. +% +%-------------------------------------------------------------------------- + +function dtable = mtimesx_test_ssequal + +global mtimesx_dtable + +disp(' '); +disp('****************************************************************************'); +disp('* *'); +disp('* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *'); +disp('* *'); +disp('* This test program can take an hour or so to complete. It is suggested *'); +disp('* that you close all applications and run this program during your lunch *'); +disp('* break or overnight to minimize impacts to your computer usage. *'); +disp('* *'); +disp('* The program will be done when you see the message: DONE ! *'); +disp('* *'); +disp('****************************************************************************'); +disp(' '); +try + input('Press Enter to start test, or Ctrl-C to exit ','s'); +catch + dtable = ''; + return +end + +start_time = datenum(clock); + +compver = [computer ', ' version ', mtimesx mode ' mtimesx]; +k = length(compver); +RC = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +mtimesx_dtable = char([]); +mtimesx_dtable(157,74) = ' '; +mtimesx_dtable(1,1:k) = compver; +mtimesx_dtable(2,:) = RC; +for r=3:157 +mtimesx_dtable(r,:) = ' -- -- -- --'; +end + +disp(' '); +disp(compver); +disp('Test program for function mtimesx:') +disp('----------------------------------'); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real)'); +disp(' '); + +rsave = 2; + +r = rsave; + +%if( false ) % debug jump + +if( isequal([]*[],mtimesx([],[])) ) + disp('Empty * Empty EQUAL'); +else + disp('Empty * Empty NOT EQUAL <---'); +end + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000)); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = single(rand(1,1)); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40)); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1)); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1)); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500)); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000)); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1)); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = single(rand(1,1)); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40)); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1)); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500)); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000)); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1)); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffNN('Matrix * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNN('Scalar * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNN('Vector * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffNN('Scalar * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNN('Array * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffNN('Vector i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffNN('Vector o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNN('Vector * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffNN('Matrix * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNN('Matrix * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real).'''); +disp(' '); + +if( isequal([]*[].',mtimesx([],[],'T')) ) + disp('Empty * Empty.'' EQUAL'); +else + disp('Empty * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10000,1)); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1)); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000)); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1)); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000)); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000)); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000)); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1)); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000)); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000)); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNT('Scalar * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNT('Vector * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNT('Array * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffNT('Vector i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffNT('Vector o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNT('Vector * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffNT('Matrix * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNT('Matrix * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * (real)'''); +disp(' '); + +if( isequal([]*[]',mtimesx([],[],'C')) ) + disp('Empty * Empty'' EQUAL'); +else + disp('Empty * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10000,1)); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1)); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000)); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1)); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000)); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000)); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000)); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1)); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000)); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000)); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNC('Scalar * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNC('Vector * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNC('Array * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffNC('Vector i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffNC('Vector o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNC('Vector * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffNC('Matrix * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNC('Matrix * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real) * conj(real)'); +disp(' '); + +%if( false ) % debug jump + +if( isequal([]*conj([]),mtimesx([],[],'G')) ) + disp('Empty * conj(Empty) EQUAL'); +else + disp('Empty * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000)); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = single(rand(1,1)); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40)); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1)); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1)); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500)); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000)); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1)); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj((real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = single(rand(1,1)); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40)); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1)); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500)); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000)); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1)); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffNG('Scalar * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNG('Vector * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffNG('Scalar * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffNG('Array * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffNG('Vector i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffNG('Vector o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNG('Vector * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffNG('Matrix * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffNG('Matrix * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real)'); +disp(' '); + +if( isequal([]'*[],mtimesx([],'C',[])) ) + disp('Empty.'' * Empty EQUAL'); +else + disp('Empty.'' * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000)); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40)); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1)); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500)); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000)); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1)); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40)); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1)); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500)); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000)); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1)); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTN('Scalar.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTN('Vector.'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffTN('Scalar.'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffTN('Vector.'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffTN('Vector.'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTN('Vector.'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffTN('Matrix.'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTN('Matrix.'' * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real).'''); +disp(' '); + +if( isequal([].'*[]',mtimesx([],'T',[],'C')) ) + disp('Empty.'' * Empty.'' EQUAL'); +else + disp('Empty.'' * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10000,1)); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000)); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1)); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000)); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000)); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000)); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1)); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000)); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000)); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTT('Scalar.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTT('Vector.'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffTT('Vector.'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffTT('Vector.'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTT('Vector.'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffTT('Matrix.'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTT('Matrix.'' * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * (real)'''); +disp(' '); + +if( isequal([].'*[]',mtimesx([],'T',[],'C')) ) + disp('Empty.'' * Empty'' EQUAL'); +else + disp('Empty.'' * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10000,1)); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000)); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1)); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000)); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000)); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000)); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1)); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000)); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000)); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTC('Scalar.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTC('Vector.'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffTC('Vector.'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffTC('Vector.'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTC('Vector.'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffTC('Matrix.'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTC('Matrix.'' * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real).'' * conj(real)'); +disp(' '); + +if( isequal([]'*conj([]),mtimesx([],'C',[],'G')) ) + disp('Empty.'' * conj(Empty) EQUAL'); +else + disp('Empty.'' * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000)); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40)); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1)); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500)); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000)); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1)); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40)); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1)); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500)); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000)); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1)); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffTG('Scalar.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffTG('Vector.'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffTG('Scalar.'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffTG('Vector.'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffTG('Vector.'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTG('Vector.'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffTG('Matrix.'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffTG('Matrix.'' * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real)'); +disp(' '); + +if( isequal([]'*[],mtimesx([],'C',[])) ) + disp('Empty'' * Empty EQUAL'); +else + disp('Empty'' * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000)); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40)); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1)); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500)); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000)); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1)); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40)); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1)); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500)); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000)); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1)); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCN('Scalar'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCN('Vector'' * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffCN('Scalar'' * Array ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffCN('Vector'' i Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffCN('Vector'' o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCN('Vector'' * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffCN('Matrix'' * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCN('Matrix'' * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real).'''); +disp(' '); + +if( isequal([]'*[]',mtimesx([],'C',[],'C')) ) + disp('Empty'' * Empty.'' EQUAL'); +else + disp('Empty'' * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10000,1)); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000)); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1)); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000)); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000)); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000)); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1)); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000)); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000)); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCT('Scalar'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCT('Vector'' * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffCT('Vector'' i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffCT('Vector'' o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCT('Vector'' * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffCT('Matrix'' * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCT('Matrix'' * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * (real)'''); +disp(' '); + +if( isequal([]'*[]',mtimesx([],'C',[],'C')) ) + disp('Empty'' * Empty'' EQUAL'); +else + disp('Empty'' * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10000,1)); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000)); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1)); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000)); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000)); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000)); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1)); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000)); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000)); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCC('Scalar'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCC('Vector'' * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffCC('Vector'' i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffCC('Vector'' o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCC('Vector'' * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffCC('Matrix'' * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCC('Matrix'' * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('(real)'' * conj(real)'); +disp(' '); + +if( isequal([]'*conj([]),mtimesx([],'C',[],'G')) ) + disp('Empty'' * conj(Empty) EQUAL'); +else + disp('Empty'' * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000)); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40)); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1)); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500)); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000)); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1)); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(real)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40)); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1)); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500)); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000)); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1)); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffCG('Scalar'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffCG('Vector'' * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffCG('Scalar'' * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffCG('Vector'' i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffCG('Vector'' o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1) + rand(1000,1)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCG('Vector'' * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffCG('Matrix'' * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffCG('Matrix'' * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real)'); +disp(' '); + +if( isequal(conj([])*[],mtimesx([],'G',[])) ) + disp('conj(Empty) * Empty EQUAL'); +else + disp('conj(Empty) * Empty NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000)); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = single(rand(1,1)); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40)); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1)); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1)); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500)); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000)); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1)); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = single(rand(1,1)); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40)); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1)); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500)); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000)); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1)); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGN('conj(Scalar) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGN('conj(Vector) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffGN('conj(Scalar) * Array ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGN('conj(Array) * Scalar ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffGN('conj(Vector) i Vector ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffGN('conj(Vector) o Vector ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGN('conj(Vector) * Matrix ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffGN('conj(Matrix) * Vector ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGN('conj(Matrix) * Matrix ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real).'''); +disp(' '); + +if( isequal(conj([])*[].',mtimesx([],'G',[],'T')) ) + disp('conj(Empty) * Empty.'' EQUAL'); +else + disp('conj(Empty) * Empty.'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10000,1)); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1)); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000)); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1)); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000)); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000)); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000)); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1)); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000)); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000)); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGT('conj(Scalar) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGT('conj(Vector) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGT('conj(Array) * Scalar.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffGT('conj(Vector) i Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffGT('conj(Vector) o Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGT('conj(Vector) * Matrix.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffGT('conj(Matrix) * Vector.'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGT('conj(Matrix) * Matrix.'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * (real)'''); +disp(' '); + +if( isequal(conj([])*[]',mtimesx([],'G',[],'C')) ) + disp('conj(Empty) * Empty'' EQUAL'); +else + disp('conj(Empty) * Empty'' NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10000,1)); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1)); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1)); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000)); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1)); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000)); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000)); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1)); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000)); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1)); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000)); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000)); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGC('conj(Scalar) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(10000,1)+ rand(10000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGC('conj(Vector) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGC('conj(Array) * Scalar'' ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxdiffGC('conj(Vector) i Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxdiffGC('conj(Vector) o Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGC('conj(Vector) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1,1000) + rand(1,1000)*1i); +maxdiffGC('conj(Matrix) * Vector'' ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGC('conj(Matrix) * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ...'); +disp(' '); +disp('conj(real) * conj(real)'); +disp(' '); + +if( isequal(conj([])*conj([]),mtimesx([],'G',[],'G')) ) + disp('conj(Empty) * conj(Empty) EQUAL'); +else + disp('conj(Empty) * conj(Empty) NOT EQUAL <---'); +end + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000)); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = single(rand(1,1)); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40)); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1)); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1)); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500)); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000)); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1)); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000)); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40)); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000)); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000)); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = single(rand(1,1)); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40)); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1)); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500)); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000)); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1)); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000)); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,10000) + rand(1,10000)*1i); +maxdiffGG('conj(Scalar) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000)+ rand(1,10000)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGG('conj(Vector) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +maxdiffGG('conj(Scalar) * conj(Array) ',A,B,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxdiffGG('conj(Array) * conj(Scalar) ',A,B,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxdiffGG('conj(Vector) i conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxdiffGG('conj(Vector) o conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1,1000) + rand(1,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGG('conj(Vector) * conj(Matrix) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1) + rand(1000,1)*1i); +maxdiffGG('conj(Matrix) * conj(Vector) ',A,B,r); + +r = r + 1; +A = single(rand(1000,1000) + rand(1000,1000)*1i); +B = single(rand(1000,1000) + rand(1000,1000)*1i); +maxdiffGG('conj(Matrix) * conj(Matrix) ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp('----------------------------------'); +disp(' '); +disp('Numerical Comparison Tests ... symmetric cases op(A) * op(A)'); +disp(' '); +disp('real'); + +r = r + 1; +mtimesx_dtable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(rand(2000)); +maxdiffsymCN('Matrix'' * Same ',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymNC('Matrix * Same''',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymTN('Matrix.'' * Same ',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymNT('Matrix * Same.''',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymGC('conj(Matrix) * Same''',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymCG('Matrix'' * conj(Same)',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymGT('conj(Matrix) * Same.'' ',A,r); + +r = r + 1; +A = single(rand(2000)); +maxdiffsymTG('Matrix.'' * conj(Same)',A,r); + +r = rsave; + +disp(' '); +disp('complex'); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymCN('Matrix'' * Same ',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymNC('Matrix * Same''',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymTN('Matrix.'' * Same ',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymNT('Matrix * Same.''',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymGC('conj(Matrix) * Same''',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymCG('Matrix'' * conj(Same)',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymGT('conj(Matrix) * Same.''',A,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxdiffsymTG('Matrix.'' * conj(Same)',A,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +%end % debug jump + +disp(' '); +disp('Numerical Comparison Tests ... special scalar cases'); +disp(' '); +disp('(scalar) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_dtable(r,:) = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +rsave = r; + +r = r + 1; +A = single(1); +B = single(rand(2500)); +maxdiffNN('( 1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500)); +maxdiffNN('( 1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500)); +maxdiffNN('( 1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500)); +maxdiffNN('( 1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500)); +maxdiffNN('(-1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500)); +maxdiffNN('(-1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500)); +maxdiffNN('(-1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500)); +maxdiffNN('(-1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500)); +maxdiffNN('( 2+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500)); +maxdiffNN('( 2-1i) * Matrix ',A,B,r); + +disp(' '); +disp('(scalar) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(1); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('(-1+0i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('(-1+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('(-1-1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('(-1+2i) * Matrix ',A,B,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 2+1i) * Matrix ',A,B,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNN('( 2-1i) * Matrix ',A,B,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +%r = rsave; + +r = r + 1; +A = single(1); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 1+0i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 1+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 1-1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 1+2i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('(-1+0i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('(-1+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('(-1-1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('(-1+2i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 2+1i) * Matrix'' ',A,B,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxdiffNC('( 2-1i) * Matrix'' ',A,B,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(' --- DONE ! ---'); +disp(' '); +disp('Summary of Numerical Comparison Tests, max relative element difference:'); +disp(' '); +mtimesx_dtable(1,1:k) = compver; +disp(mtimesx_dtable); +disp(' '); + +dtable = mtimesx_dtable; + +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNN(T,A,B,r) +Cm = A*B; +Cx = mtimesx(A,B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCN(T,A,B,r) +Cm = A'*B; +Cx = mtimesx(A,'C',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTN(T,A,B,r) +Cm = A.'*B; +Cx = mtimesx(A,'T',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGN(T,A,B,r) +Cm = conj(A)*B; +Cx = mtimesx(A,'G',B); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNC(T,A,B,r) +Cm = A*B'; +Cx = mtimesx(A,B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCC(T,A,B,r) +Cm = A'*B'; +Cx = mtimesx(A,'C',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTC(T,A,B,r) +Cm = A.'*B'; +Cx = mtimesx(A,'T',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGC(T,A,B,r) +Cm = conj(A)*B'; +Cx = mtimesx(A,'G',B,'C'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNT(T,A,B,r) +Cm = A*B.'; +Cx = mtimesx(A,B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCT(T,A,B,r) +Cm = A'*B.'; +Cx = mtimesx(A,'C',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTT(T,A,B,r) +Cm = A.'*B.'; +Cx = mtimesx(A,'T',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGT(T,A,B,r) +Cm = conj(A)*B.'; +Cx = mtimesx(A,'G',B,'T'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffNG(T,A,B,r) +Cm = A*conj(B); +Cx = mtimesx(A,B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffCG(T,A,B,r) +Cm = A'*conj(B); +Cx = mtimesx(A,'C',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffTG(T,A,B,r) +Cm = A.'*conj(B); +Cx = mtimesx(A,'T',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffGG(T,A,B,r) +Cm = conj(A)*conj(B); +Cx = mtimesx(A,'G',B,'G'); +maxdiffout(T,A,B,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymCN(T,A,r) +Cm = A'*A; +Cx = mtimesx(A,'C',A); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymNC(T,A,r) +Cm = A*A'; +Cx = mtimesx(A,A,'C'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymTN(T,A,r) +Cm = A.'*A; +Cx = mtimesx(A,'T',A); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymNT(T,A,r) +Cm = A*A.'; +Cx = mtimesx(A,A,'T'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymTG(T,A,r) +Cm = A.'*conj(A); +Cx = mtimesx(A,'T',A,'G'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymGT(T,A,r) +Cm = conj(A)*A.'; +Cx = mtimesx(A,'G',A,'T'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymCG(T,A,r) +Cm = A'*conj(A); +Cx = mtimesx(A,'C',A,'G'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymGC(T,A,r) +Cm = conj(A)*A'; +Cx = mtimesx(A,'G',A,'C'); +maxdiffsymout(T,A,Cm,Cx,r); +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffout(T,A,B,Cm,Cx,r) +global mtimesx_dtable +lt = length(T); +b = repmat(' ',1,30-lt); +if( isequal(Cm,Cx) ) + disp([T b ' EQUAL']); + d = 0; +else + Cm = Cm(:); + Cx = Cx(:); + if( isreal(Cm) && isreal(Cx) ) + rx = Cx ~= Cm; + d = max(abs((Cx(rx)-Cm(rx))./Cm(rx))); + else + Cmr = real(Cm); + Cmi = imag(Cm); + Cxr = real(Cx); + Cxi = imag(Cx); + rx = Cxr ~= Cmr; + ix = Cxi ~= Cmi; + dr = max(abs((Cxr(rx)-Cmr(rx))./max(abs(Cmr(rx)),abs(Cmr(rx))))); + di = max(abs((Cxi(ix)-Cmi(ix))./max(abs(Cmi(ix)),abs(Cxi(ix))))); + if( isempty(dr) ) + d = di; + elseif( isempty(di) ) + d = dr; + else + d = max(dr,di); + end + end + disp([T b ' NOT EQUAL <--- Max relative difference: ' num2str(d)]); +end +mtimesx_dtable(r,1:length(T)) = T; +if( isreal(A) && isreal(B) ) + if( d == 0 ) + x = [T b ' 0']; + else + x = [T b sprintf('%11.2e',d)]; + end + mtimesx_dtable(r,1:length(x)) = x; +elseif( isreal(A) && ~isreal(B) ) + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,42:41+length(x)) = x; +elseif( ~isreal(A) && isreal(B) ) + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,53:52+length(x)) = x; +else + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxdiffsymout(T,A,Cm,Cx,r) +global mtimesx_dtable +lt = length(T); +b = repmat(' ',1,30-lt); +if( isequal(Cm,Cx) ) + disp([T b ' EQUAL']); + d = 0; +else + Cm = Cm(:); + Cx = Cx(:); + if( isreal(Cm) && isreal(Cx) ) + rx = Cx ~= Cm; + d = max(abs((Cx(rx)-Cm(rx))./Cm(rx))); + else + Cmr = real(Cm); + Cmi = imag(Cm); + Cxr = real(Cx); + Cxi = imag(Cx); + rx = Cxr ~= Cmr; + ix = Cxi ~= Cmi; + dr = max(abs((Cxr(rx)-Cmr(rx))./max(abs(Cmr(rx)),abs(Cmr(rx))))); + di = max(abs((Cxi(ix)-Cmi(ix))./max(abs(Cmi(ix)),abs(Cxi(ix))))); + if( isempty(dr) ) + d = di; + elseif( isempty(di) ) + d = dr; + else + d = max(dr,di); + end + end + disp([T b ' NOT EQUAL <--- Max relative difference: ' num2str(d)]); +end +if( isreal(A) ) + if( d == 0 ) + x = [T b ' 0']; + else + x = [T b sprintf('%11.2e',d)]; + end + mtimesx_dtable(r,1:length(x)) = x; +else + if( d == 0 ) + x = ' 0'; + else + x = sprintf('%11.2e',d); + end + mtimesx_dtable(r,1:length(T)) = T; + mtimesx_dtable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function running_time(d) +h = 24*d; +hh = floor(h); +m = 60*(h - hh); +mm = floor(m); +s = 60*(m - mm); +ss = floor(s); +disp(' '); +rt = sprintf('Running time hh:mm:ss = %2.0f:%2.0f:%2.0f',hh,mm,ss); +if( rt(28) == ' ' ) + rt(28) = '0'; +end +if( rt(31) == ' ' ) + rt(31) = '0'; +end +disp(rt); +disp(' '); +return +end diff --git a/ext/mtimesx/mtimesx_test_ssspeed.m b/ext/mtimesx/mtimesx_test_ssspeed.m new file mode 100644 index 0000000000000000000000000000000000000000..b64dadb692d08d13088eff588403b7c7aab9fc3f --- /dev/null +++ b/ext/mtimesx/mtimesx_test_ssspeed.m @@ -0,0 +1,5044 @@ +% Test routine for mtimesx, op(single) * op(single) speed vs MATLAB +%****************************************************************************** +% +% MATLAB (R) is a trademark of The Mathworks (R) Corporation +% +% Function: mtimesx_test_ssspeed +% Filename: mtimesx_test_ssspeed.m +% Programmer: James Tursa +% Version: 1.0 +% Date: September 27, 2009 +% Copyright: (c) 2009 by James Tursa, All Rights Reserved +% +% This code uses the BSD License: +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are +% met: +% +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in +% the documentation and/or other materials provided with the distribution +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Syntax (arguments in brackets [ ] are optional): +% +% T = mtimesx_test_ddspeed( [N [,D]] ) +% +% Inputs: +% +% N = Number of runs to make for each individual test. The test result will +% be the median of N runs. N must be even. If N is odd, it will be +% automatically increased to the next even number. The default is 10, +% which can take *hours* to run. Best to run this program overnight. +% D = The string 'details'. If present, this will cause all of the +% individual intermediate run results to print as they happen. +% +% Output: +% +% T = A character array containing a summary of the results. +% +%-------------------------------------------------------------------------- + +function ttable = mtimesx_test_ssspeed(nn,details) + +global mtimesx_ttable + +disp(' '); +disp('****************************************************************************'); +disp('* *'); +disp('* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *'); +disp('* *'); +disp('* This test program can take several *hours* to complete, particularly *'); +disp('* when using the default number of runs as 10. It is strongly suggested *'); +disp('* to close all applications and run this program overnight to get the *'); +disp('* best possible result with minimal impacts to your computer usage. *'); +disp('* *'); +disp('* The program will be done when you see the message: DONE ! *'); +disp('* *'); +disp('****************************************************************************'); +disp(' '); +try + input('Press Enter to start test, or Ctrl-C to exit ','s'); +catch + ttable = ''; + return +end + +start_time = datenum(clock); + +if nargin >= 1 + n = nn; +else + n = 10; +end +if nargin < 2 + details = false; +else + if( isempty(details) ) % code to get rid of the lint message + details = true; + else + details = true; + end +end + +RC = ' Real*Real Real*Cplx Cplx*Real Cplx*Cplx'; + +compver = [computer ', ' version ', mtimesx mode ' mtimesx ', median of ' num2str(n) ' runs']; +k = length(compver); + +nl = 199; + +mtimesx_ttable = char([]); +mtimesx_ttable(1:nl,1:74) = ' '; +mtimesx_ttable(1,1:k) = compver; +mtimesx_ttable(2,:) = RC; +for r=3:(nl-2) +mtimesx_ttable(r,:) = ' -- -- -- --'; +end +mtimesx_ttable(nl,1:6) = 'DONE !'; + +disp(' '); +disp(compver); +disp('Test program for function mtimesx:') +disp('----------------------------------'); + +rsave = 2; + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = single(rand(1,1)); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400)); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1)); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1)); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500)); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000)); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1)); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = single(rand(1,1)); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400)); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1)); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1)); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500)); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000)); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1)); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNN('Scalar * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNN('Vector * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeNN('Scalar * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNN('Array * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeNN('Vector i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeNN('Vector o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNN('Vector * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeNN('Matrix * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNN('Matrix * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real).'''); +disp(' '); + +rsave = r; + +mtimesx_ttable(r,:) = RC; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1)); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000)); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1)); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000)); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000)); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000)); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1)); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000)); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000)); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNT('Scalar * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNT('Vector * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNT('Array * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeNT('Vector i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeNT('Vector o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNT('Vector * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeNT('Matrix * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNT('Matrix * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1)); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000)); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1)); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000)); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000)); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000)); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1)); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000)); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000)); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNC('Scalar * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNC('Vector * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNC('Array * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeNC('Vector i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeNC('Vector o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNC('Vector * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeNC('Matrix * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNC('Matrix * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = single(rand(1,1)); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400)); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1)); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1)); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500)); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000)); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1)); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = single(rand(1,1)); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400)); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1)); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1)); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500)); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000)); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1)); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeNG('Scalar * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNG('Vector * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeNG('Scalar * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeNG('Array * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeNG('Vector i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeNG('Vector o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNG('Vector * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeNG('Matrix * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeNG('Matrix * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400)); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1)); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500)); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000)); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1)); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400)); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1)); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500)); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000)); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1)); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTN('Scalar.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTN('Vector.'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeTN('Scalar.'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeTN('Vector.'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeTN('Vector.'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTN('Vector.'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeTN('Matrix.'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTN('Matrix.'' * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000)); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1)); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000)); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000)); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000)); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1)); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000)); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000)); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTT('Scalar.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTT('Vector.'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeTT('Vector.'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeTT('Vector.'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTT('Vector.'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeTT('Matrix.'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTT('Matrix.'' * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000)); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1)); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000)); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000)); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000)); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1)); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000)); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000)); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTC('Scalar.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTC('Vector.'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeTC('Vector.'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeTC('Vector.'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTC('Vector.'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeTC('Matrix.'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTC('Matrix.'' * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real).'' * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400)); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1)); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500)); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000)); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1)); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400)); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1)); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500)); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000)); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1)); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex).'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeTG('Scalar.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeTG('Vector.'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeTG('Scalar.'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeTG('Vector.'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeTG('Vector.'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTG('Vector.'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeTG('Matrix.'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeTG('Matrix.'' * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400)); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1)); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500)); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000)); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1)); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400)); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1)); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500)); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000)); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1)); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCN('Scalar'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCN('Vector'' * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeCN('Scalar'' * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeCN('Vector'' i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeCN('Vector'' o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCN('Vector'' * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeCN('Matrix'' * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCN('Matrix'' * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000)); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1)); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000)); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000)); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000)); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1)); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000)); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000)); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCT('Scalar'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCT('Vector'' * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeCT('Vector'' i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeCT('Vector'' o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCT('Vector'' * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeCT('Matrix'' * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCT('Matrix'' * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000)); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1)); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000)); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000)); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000)); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1)); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000)); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000)); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCC('Scalar'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCC('Vector'' * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeCC('Vector'' i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeCC('Vector'' o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCC('Vector'' * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeCC('Matrix'' * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCC('Matrix'' * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('(real)'' * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400)); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1)); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500)); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000)); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1)); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('(real)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400)); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1)); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500)); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000)); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1)); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('(complex)'' * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeCG('Scalar'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeCG('Vector'' * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeCG('Scalar'' * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10000000,1) + rand(10000000,1)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeCG('Vector'' i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2500) + rand(1,2500)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeCG('Vector'' o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,1) + rand(2000,1)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCG('Vector'' * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeCG('Matrix'' * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeCG('Matrix'' * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = single(rand(1,1)); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400)); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1)); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1)); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500)); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000)); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1)); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = single(rand(1,1)); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400)); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1)); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1)); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500)); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000)); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1)); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGN('conj(Scalar) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGN('conj(Vector) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeGN('conj(Scalar) * Array ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGN('conj(Array) * Scalar ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeGN('conj(Vector) i Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeGN('conj(Vector) o Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGN('conj(Vector) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeGN('conj(Matrix) * Vector ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGN('conj(Matrix) * Matrix ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1)); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000)); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1)); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000)); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000)); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000)); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1)); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000)); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000)); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGT('conj(Scalar) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGT('conj(Vector) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGT('conj(Array) * Scalar.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeGT('conj(Vector) i Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeGT('conj(Vector) o Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGT('conj(Vector) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeGT('conj(Matrix) * Vector.'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGT('conj(Matrix) * Matrix.'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1)); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1)); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000)); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1)); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000)); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000)); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (real)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1)); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,40) + rand(10,20,30,40)*1i); +B = single(rand(1,1)); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000)); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1)); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000)); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000)); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGC('conj(Scalar) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1000000,1) + rand(1000000,1)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGC('conj(Vector) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGC('conj(Array) * Scalar'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(1,10000000) + rand(1,10000000)*1i); +maxtimeGC('conj(Vector) i Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(2500,1) + rand(2500,1)*1i); +maxtimeGC('conj(Vector) o Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGC('conj(Vector) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(1,2000) + rand(1,2000)*1i); +maxtimeGC('conj(Matrix) * Vector'' ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGC('conj(Matrix) * Matrix'' ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs']); +disp(' '); +disp('conj(real) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000)); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = single(rand(1,1)); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400)); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1)); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1)); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500)); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000)); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1)); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000)); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- + +disp(' '); +disp('conj(real) * conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1)); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400)); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000)); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1)); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000)); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(real)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000)); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = single(rand(1,1)); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400)); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1)); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1)); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500)); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000)); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1)); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000)); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +%-------------------------------------------------------------------------- +disp(' '); +disp('conj(complex)* conj(complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(1,1000000) + rand(1,1000000)*1i); +maxtimeGG('conj(Scalar) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1000000) + rand(1,1000000)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGG('conj(Vector) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,1) + rand(1,1)*1i); +B = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +maxtimeGG('conj(Scalar) * conj(Array) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(10,20,30,400) + rand(10,20,30,400)*1i); +B = single(rand(1,1) + rand(1,1)*1i); +maxtimeGG('conj(Array) * conj(Scalar) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,10000000) + rand(1,10000000)*1i); +B = single(rand(10000000,1) + rand(10000000,1)*1i); +maxtimeGG('conj(Vector) i conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2500,1) + rand(2500,1)*1i); +B = single(rand(1,2500) + rand(1,2500)*1i); +maxtimeGG('conj(Vector) o conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(1,2000) + rand(1,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGG('conj(Vector) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,1) + rand(2000,1)*1i); +maxtimeGG('conj(Matrix) * conj(Vector) ',A,B,n,details,r); + +r = r + 1; +A = single(rand(2000,2000) + rand(2000,2000)*1i); +B = single(rand(2000,2000) + rand(2000,2000)*1i); +maxtimeGG('conj(Matrix) * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... symmetric cases op(A) * op(A)']); +disp(' '); +disp('real'); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = rsave; + +r = r + 1; +A = single(rand(2000)); +maxtimesymCN('Matrix'' * Same ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymNC('Matrix * Same'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymTN('Matrix.'' * Same ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymNT('Matrix * Same.'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymGC('conj(Matrix) * Same'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymCG('Matrix'' * conj(Same)',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymGT('conj(Matrix) * Same.'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000)); +maxtimesymTG('Matrix.'' * conj(Same)',A,n,details,r); + +r = rsave; + +disp(' '); +disp('complex'); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymCN('Matrix'' * Same ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymNC('Matrix * Same'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymTN('Matrix.'' * Same ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymNT('Matrix * Same.'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymGC('conj(Matrix) * Same'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymCG('Matrix'' * conj(Same)',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymGT('conj(Matrix) * Same.'' ',A,n,details,r); + +r = r + 1; +A = single(rand(2000) + rand(2000)*1i); +maxtimesymTG('Matrix.'' * conj(Same)',A,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(['Timing Tests ... median of ' num2str(n) ' runs ... special scalar cases']); +disp(' '); +disp('(scalar) * (real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(1); +B = single(rand(2500)); +maxtimeNN('( 1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500)); +maxtimeNN('( 1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500)); +maxtimeNN('( 1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500)); +maxtimeNN('( 1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500)); +maxtimeNN('(-1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500)); +maxtimeNN('(-1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500)); +maxtimeNN('(-1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500)); +maxtimeNN('(-1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500)); +maxtimeNN('( 2+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500)); +maxtimeNN('( 2-1i) * Matrix ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(1); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('(-1+0i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('(-1+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('(-1-1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('(-1+2i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 2+1i) * Matrix ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNN('( 2-1i) * Matrix ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (real)'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(1); +B = single(rand(2500)); +maxtimeNC('( 1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500)); +maxtimeNC('( 1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500)); +maxtimeNC('( 1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500)); +maxtimeNC('( 1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500)); +maxtimeNC('(-1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500)); +maxtimeNC('(-1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500)); +maxtimeNC('(-1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500)); +maxtimeNC('(-1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500)); +maxtimeNC('( 2+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500)); +maxtimeNC('( 2-1i) * Matrix'' ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(1); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('(-1+0i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('(-1+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('(-1-1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('(-1+2i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 2+1i) * Matrix'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNC('( 2-1i) * Matrix'' ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (real).'''); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(1); +B = single(rand(2500)); +maxtimeNT('( 1+0i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500)); +maxtimeNT('( 1+1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500)); +maxtimeNT('( 1-1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500)); +maxtimeNT('( 1+2i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500)); +maxtimeNT('(-1+0i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500)); +maxtimeNT('(-1+1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500)); +maxtimeNT('(-1-1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500)); +maxtimeNT('(-1+2i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500)); +maxtimeNT('( 2+1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500)); +maxtimeNT('( 2-1i) * Matrix.'' ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex).'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(1); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('( 1+0i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('( 1+1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('( 1-1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('( 1+2i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('(-1+0i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('(-1+1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('(-1-1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('(-1+2i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('( 2+1i) * Matrix.'' ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNT('( 2-1i) * Matrix.'' ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * conj(real)'); +disp(' '); + +r = r + 1; +mtimesx_ttable(r,:) = RC; + +rsave = r; + +r = r + 1; +A = single(1); +B = single(rand(2500)); +maxtimeNG('( 1+0i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500)); +maxtimeNG('( 1+1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500)); +maxtimeNG('( 1-1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500)); +maxtimeNG('( 1+2i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500)); +maxtimeNG('(-1+0i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500)); +maxtimeNG('(-1+1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500)); +maxtimeNG('(-1-1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500)); +maxtimeNG('(-1+2i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500)); +maxtimeNG('( 2+1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500)); +maxtimeNG('( 2-1i) * conj(Matrix) ',A,B,n,details,r); + +disp(' '); +disp('(scalar) * (complex)'''); +disp(' '); + +r = rsave; + +r = r + 1; +A = single(1); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('( 1+0i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('( 1+1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('( 1-1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('( 1+2i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(-1); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('(-1+0i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('(-1+1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(-1 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('(-1-1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(-1 + 2i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('(-1+2i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(2 + 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('( 2+1i) * conj(Matrix) ',A,B,n,details,r); + +r = r + 1; +A = single(2 - 1i); +B = single(rand(2500) + rand(2500)*1i); +maxtimeNG('( 2-1i) * conj(Matrix) ',A,B,n,details,r); + +running_time(datenum(clock) - start_time); + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +disp(' '); +disp(' --- DONE ! ---'); +disp(' '); +disp(['Summary of Timing Tests, ' num2str(n) ' runs, + = percent faster, - = percent slower:']); +disp(' '); +mtimesx_ttable(1,1:k) = compver; +disp(mtimesx_ttable); +disp(' '); + +ttable = mtimesx_ttable; + +running_time(datenum(clock) - start_time); + +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B; + mtoc(k) = toc; + tic; + mtimesx(A,B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*B'; + mtoc(k) = toc; + tic; + mtimesx(A,B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeNG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeTG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'T',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeCG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'C',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGN(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGT(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B.'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGC(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*B'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeGG(T,A,B,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*conj(B); + mtoc(k) = toc; + tic; + mtimesx(A,'G',B,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing + B(1,1) = 2*B(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimeout(T,A,B,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymCN(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*A; + mtoc(k) = toc; + tic; + mtimesx(A,'C',A); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymNC(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*A'; + mtoc(k) = toc; + tic; + mtimesx(A,A,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymTN(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*A; + mtoc(k) = toc; + tic; + mtimesx(A,'T',A); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymNT(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A*A.'; + mtoc(k) = toc; + tic; + mtimesx(A,A,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymCG(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A'*conj(A); + mtoc(k) = toc; + tic; + mtimesx(A,'C',A,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymGC(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*A'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',A,'C'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymTG(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + A.'*conj(A); + mtoc(k) = toc; + tic; + mtimesx(A,'T',A,'G'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymGT(T,A,n,details,r) +pp(n) = 0; +mtoc(n) = 0; +xtoc(n) = 0; +for k=1:n + tic; + conj(A)*A.'; + mtoc(k) = toc; + tic; + mtimesx(A,'G',A,'T'); + xtoc(k) = toc; + pp(k) = (100 * (xtoc(k) - mtoc(k)) / min(mtoc(k),xtoc(k))); + A(1,1) = 2*A(1,1); % prevent JIT accelerator from interfering with timing +end +if( details ) + disp('MATLAB mtimes times:'); + disp(mtoc); + disp('mtimesx times:') + disp(xtoc); + disp('mtimesx percent faster times (+ = faster, - = slower)'); + disp(-pp); +end +p = median(pp); +ap = abs(p); +sp = sprintf('%6.1f',ap); +if( ap < 5 ) + c = '(not significant)'; +else + c = ''; +end +if( p < 0 ) + a = [' <' repmat('-',[1,floor((ap+5)/10)])]; + disp([T ' mtimesx is ' sp '% faster than MATLAB mtimes' a c]); +else + disp([T ' mtimesx is ' sp '% slower than MATLAB mtimes ' c]); +end + +maxtimesymout(T,A,p,r); + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimeout(T,A,B,p,r) +global mtimesx_ttable +mtimesx_ttable(r,1:length(T)) = T; +if( isreal(A) && isreal(B) ) + lt = length(T); + b = repmat(' ',1,30-lt); + x = [T b sprintf('%10.0f%%',-p)]; + mtimesx_ttable(r,1:length(x)) = x; +elseif( isreal(A) && ~isreal(B) ) + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,42:41+length(x)) = x; +elseif( ~isreal(A) && isreal(B) ) + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,53:52+length(x)) = x; +else + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,64:63+length(x)) = x; +end + +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function maxtimesymout(T,A,p,r) +global mtimesx_ttable +if( isreal(A) ) + lt = length(T); + b = repmat(' ',1,30-lt); + x = [T b sprintf('%10.0f%%',-p)]; + mtimesx_ttable(r,1:length(x)) = x; +else + x = sprintf('%10.0f%%',-p); + mtimesx_ttable(r,1:length(T)) = T; + mtimesx_ttable(r,64:63+length(x)) = x; +end +return +end + +%-------------------------------------------------------------------------- +%-------------------------------------------------------------------------- + +function running_time(d) +h = 24*d; +hh = floor(h); +m = 60*(h - hh); +mm = floor(m); +s = 60*(m - mm); +ss = floor(s); +disp(' '); +rt = sprintf('Running time hh:mm:ss = %2.0f:%2.0f:%2.0f',hh,mm,ss); +if( rt(28) == ' ' ) + rt(28) = '0'; +end +if( rt(31) == ' ' ) + rt(31) = '0'; +end +disp(rt); +disp(' '); +return +end diff --git a/ext/readimx/Buffer.dll b/ext/readimx/Buffer.dll new file mode 100644 index 0000000000000000000000000000000000000000..71a0ae23100c3008e7cced7b907cd557578f3885 Binary files /dev/null and b/ext/readimx/Buffer.dll differ diff --git a/ext/readimx/Common.dll b/ext/readimx/Common.dll new file mode 100644 index 0000000000000000000000000000000000000000..95344004198fad0406e3e45849f2ea06ff201732 Binary files /dev/null and b/ext/readimx/Common.dll differ diff --git a/ext/readimx/DataObjects.dll b/ext/readimx/DataObjects.dll new file mode 100644 index 0000000000000000000000000000000000000000..e851916d4d3c77aa6698f2ab993be1f8389f5450 Binary files /dev/null and b/ext/readimx/DataObjects.dll differ diff --git a/ext/readimx/MakeFrameInfo.m b/ext/readimx/MakeFrameInfo.m new file mode 100644 index 0000000000000000000000000000000000000000..88111e1cecc04fa6b3330152515c063885a59f2b --- /dev/null +++ b/ext/readimx/MakeFrameInfo.m @@ -0,0 +1,28 @@ +function [frameInfo]=MakeFrameInfo(Frame) + +Names = Frame.ComponentNames; +frameInfo.choices = zeros(12,1); +for i=1:size(Names,1), + if strcmp(Names{i},'U0')==1, frameInfo.choices( 1) = i; end; + if strcmp(Names{i},'V0')==1, frameInfo.choices( 2) = i; end; + if strcmp(Names{i},'W0')==1, frameInfo.choices( 3) = i; end; + if strcmp(Names{i},'U1')==1, frameInfo.choices( 4) = i; end; + if strcmp(Names{i},'V1')==1, frameInfo.choices( 5) = i; end; + if strcmp(Names{i},'W1')==1, frameInfo.choices( 6) = i; end; + if strcmp(Names{i},'U2')==1, frameInfo.choices( 7) = i; end; + if strcmp(Names{i},'V2')==1, frameInfo.choices( 8) = i; end; + if strcmp(Names{i},'W2')==1, frameInfo.choices( 9) = i; end; + if strcmp(Names{i},'U3')==1, frameInfo.choices(10) = i; end; + if strcmp(Names{i},'V3')==1, frameInfo.choices(11) = i; end; + if strcmp(Names{i},'W3')==1, frameInfo.choices(12) = i; end; + if strcmp(Names{i},'ACTIVE_CHOICE')== 1, frameInfo.best = i; end; + if strcmp(Names{i},'ENABLED') == 1, frameInfo.enable = i; end; + if strcmp(Names{i},'MASK') == 1, frameInfo.mask = i; end; +end +frameInfo.Grids = Frame.Grids; +frameInfo.Scales.X = Frame.Scales.X; +frameInfo.Scales.Y = Frame.Scales.Y; +frameInfo.Scales.Z = Frame.Scales.Z; +frameInfo.Scales.I = Frame.Scales.I; +frameInfo.is3D = (frameInfo.choices(3) > 0); +frameInfo.hasChoices = (frameInfo.choices(4) > 0); \ No newline at end of file diff --git a/ext/readimx/Qt 5.7.0.txt b/ext/readimx/Qt 5.7.0.txt new file mode 100644 index 0000000000000000000000000000000000000000..f8d7409c444823db4c3efd484e96951bce735e79 --- /dev/null +++ b/ext/readimx/Qt 5.7.0.txt @@ -0,0 +1,866 @@ +See the end of this document for further assistance from LaVision related to the LGPLv3 licencing of Qt 5.7.0. GENERAL +------- + +Qt is available under a commercial license with various pricing models and packages that meet a variety of needs. Commercial Qt license keeps your code proprietary where only you can control and monetize on your end product�s development, user experience and distribution. You also get great perks like additional functionality, productivity enhancing tools, world-class support and a close strategic relationship with The Qt Company to make sure your product and development goals are met. + +Qt has been created under the belief of open development and providing freedom and choice to developers. To support that, The Qt Company also licenses Qt under open source licenses, where most of the functionality is available under LGPLv3. It should be noted that the tools as well as some add-on components are available only under GPLv3. In order to preserve the true meaning of open development and uphold the spirit of free software, it is imperative that the rules and regulations of open source licenses are followed. If you use Qt under open-source licenses, you need to make sure that you comply with all the licenses of the components you use. + +Qt also contains some 3rd party components that are available under different open-source licenses. Please refer to the documentation for more details on 3rd party licenses used in Qt. + + +GPLv3 and LGPLv3 +---------------- + + GNU LESSER GENERAL PUBLIC LICENSE + + The Qt Toolkit is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). + Contact: http://www.qt.io/licensing + + You may use, distribute and copy the Qt GUI Toolkit under the terms of + GNU Lesser General Public License version 3, which supplements GNU General + Public License Version 3. Both of the licenses are displayed below. + +------------------------------------------------------------------------- + + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. + + +------------------------------------------------------------------------- + + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright � 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies of this + license document, but changing it is not allowed. + +This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + +0. Additional Definitions. + + As used herein, �this License� refers to version 3 of the GNU Lesser +General Public License, and the �GNU GPL� refers to version 3 of the +GNU General Public License. + + �The Library� refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An �Application� is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A �Combined Work� is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the �Linked +Version�. + + The �Minimal Corresponding Source� for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The �Corresponding Application Code� for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + +1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + +2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort + to ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + +3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this + license document. + +4. Combined Works. + + You may convey a Combined Work under terms of your choice that, taken +together, effectively do not restrict modification of the portions of +the Library contained in the Combined Work and reverse engineering for +debugging such modifications, if you also do each of the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this + license document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of + this License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with + the Library. A suitable mechanism is one that (a) uses at run + time a copy of the Library already present on the user's + computer system, and (b) will operate properly with a modified + version of the Library that is interface-compatible with the + Linked Version. + + e) Provide Installation Information, but only if you would + otherwise be required to provide such information under section 6 + of the GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the Application + with a modified version of the Linked Version. (If you use option + 4d0, the Installation Information must accompany the Minimal + Corresponding Source and Corresponding Application Code. If you + use option 4d1, you must provide the Installation Information in + the manner specified by section 6 of the GNU GPL for conveying + Corresponding Source.) + +5. Combined Libraries. + + You may place library facilities that are a work based on the Library +side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities, conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of + it is a work based on the Library, and explaining where to find + the accompanying uncombined form of the same work. + +6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +as you received it specifies that a certain numbered version of the +GNU Lesser General Public License �or any later version� applies to +it, you have the option of following the terms and conditions either +of that published version or of any later version published by the +Free Software Foundation. If the Library as you received it does not +specify a version number of the GNU Lesser General Public License, +you may choose any version of the GNU Lesser General Public License +ever published by the Free Software Foundation. + +If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the Library. + ---------------------------------------------------------------------------------- Support from LaVision: ---------------------- LPGLv3 allows the user to replace Qt libraries by binary-compatible versions if closed-source products use dynamically linked LGPLv3-licensed libraries. For LaVision software products we do not recommend to change Qt libraries as our software was thoroughly tested with the shipped Qt libraries and we don't ensure a stable working system if other library versions are used. Nevertheless in case you need assistance or support for changing Qt library versions or you want to obtain the source code of the Qt libraries used by our software products please contact our service department. diff --git a/ext/readimx/Qt5Core.dll b/ext/readimx/Qt5Core.dll new file mode 100644 index 0000000000000000000000000000000000000000..aa61e5a6832b059d10ccf14a76c727cc7d4c5b5a Binary files /dev/null and b/ext/readimx/Qt5Core.dll differ diff --git a/ext/readimx/Set.dll b/ext/readimx/Set.dll new file mode 100644 index 0000000000000000000000000000000000000000..ec20787a3873fc800557bef31259c302e228f31c Binary files /dev/null and b/ext/readimx/Set.dll differ diff --git a/ext/readimx/TestImages/2D-PIV simple.vec b/ext/readimx/TestImages/2D-PIV simple.vec new file mode 100644 index 0000000000000000000000000000000000000000..f667f299c71b3ec5c49f10d393e28c74253c4609 Binary files /dev/null and b/ext/readimx/TestImages/2D-PIV simple.vec differ diff --git a/ext/readimx/TestImages/2D-PIV with choices.vec b/ext/readimx/TestImages/2D-PIV with choices.vec new file mode 100644 index 0000000000000000000000000000000000000000..8fad82b02bafa8a2e30ea8a4a3125ed20bedb653 Binary files /dev/null and b/ext/readimx/TestImages/2D-PIV with choices.vec differ diff --git a/ext/readimx/TestImages/2D-PIV-Particles.imx b/ext/readimx/TestImages/2D-PIV-Particles.imx new file mode 100644 index 0000000000000000000000000000000000000000..83f70a2790bba868ea4db19c39f91cba73568458 Binary files /dev/null and b/ext/readimx/TestImages/2D-PIV-Particles.imx differ diff --git a/ext/readimx/TestImages/3D-3C.VC7 b/ext/readimx/TestImages/3D-3C.VC7 new file mode 100644 index 0000000000000000000000000000000000000000..906ff3888ab078a4de3a9260cdbe6d1b210c51f1 Binary files /dev/null and b/ext/readimx/TestImages/3D-3C.VC7 differ diff --git a/ext/readimx/TestImages/3D-PIV one plane.vc7 b/ext/readimx/TestImages/3D-PIV one plane.vc7 new file mode 100644 index 0000000000000000000000000000000000000000..a3fa5a8e4bd2ddc3319bb5e837505fb037900aa5 Binary files /dev/null and b/ext/readimx/TestImages/3D-PIV one plane.vc7 differ diff --git a/ext/readimx/TestImages/3D-PIV-SinglePlane.vc7 b/ext/readimx/TestImages/3D-PIV-SinglePlane.vc7 new file mode 100644 index 0000000000000000000000000000000000000000..a3fa5a8e4bd2ddc3319bb5e837505fb037900aa5 Binary files /dev/null and b/ext/readimx/TestImages/3D-PIV-SinglePlane.vc7 differ diff --git a/ext/readimx/TestImages/Turbulence.imx b/ext/readimx/TestImages/Turbulence.imx new file mode 100644 index 0000000000000000000000000000000000000000..b83955deb19ed71a6cd21156e86d4a788ae81081 Binary files /dev/null and b/ext/readimx/TestImages/Turbulence.imx differ diff --git a/ext/readimx/TestImages/Volume.im7 b/ext/readimx/TestImages/Volume.im7 new file mode 100644 index 0000000000000000000000000000000000000000..b12cdc88b4b940104a9f40746eac3e4f4decb81e Binary files /dev/null and b/ext/readimx/TestImages/Volume.im7 differ diff --git a/ext/readimx/boost 1.62.0.txt b/ext/readimx/boost 1.62.0.txt new file mode 100644 index 0000000000000000000000000000000000000000..36b7cd93cdfbac762f5be4c6ce276df2ea6305c2 --- /dev/null +++ b/ext/readimx/boost 1.62.0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/ext/readimx/boost_chrono-vc140-mt-1_62.dll b/ext/readimx/boost_chrono-vc140-mt-1_62.dll new file mode 100644 index 0000000000000000000000000000000000000000..6bb553fc9a2c284ee4e27b7785240fe29178c186 Binary files /dev/null and b/ext/readimx/boost_chrono-vc140-mt-1_62.dll differ diff --git a/ext/readimx/boost_date_time-vc140-mt-1_62.dll b/ext/readimx/boost_date_time-vc140-mt-1_62.dll new file mode 100644 index 0000000000000000000000000000000000000000..06efcaff9941d75132d2546ad7818fba9918fad2 Binary files /dev/null and b/ext/readimx/boost_date_time-vc140-mt-1_62.dll differ diff --git a/ext/readimx/boost_filesystem-vc140-mt-1_62.dll b/ext/readimx/boost_filesystem-vc140-mt-1_62.dll new file mode 100644 index 0000000000000000000000000000000000000000..37dc1cd165d76f2284367ad930b434d82c123c69 Binary files /dev/null and b/ext/readimx/boost_filesystem-vc140-mt-1_62.dll differ diff --git a/ext/readimx/boost_regex-vc140-mt-1_62.dll b/ext/readimx/boost_regex-vc140-mt-1_62.dll new file mode 100644 index 0000000000000000000000000000000000000000..d141134272e914772ff673c76235f34cadfad4b0 Binary files /dev/null and b/ext/readimx/boost_regex-vc140-mt-1_62.dll differ diff --git a/ext/readimx/boost_serialization-vc140-mt-1_62.dll b/ext/readimx/boost_serialization-vc140-mt-1_62.dll new file mode 100644 index 0000000000000000000000000000000000000000..2cd8ddac04d4be7778cefd852d5371d51f1b51be Binary files /dev/null and b/ext/readimx/boost_serialization-vc140-mt-1_62.dll differ diff --git a/ext/readimx/boost_system-vc140-mt-1_62.dll b/ext/readimx/boost_system-vc140-mt-1_62.dll new file mode 100644 index 0000000000000000000000000000000000000000..e4ed0397ecec45c273e6b82c99d68bf48172ce4a Binary files /dev/null and b/ext/readimx/boost_system-vc140-mt-1_62.dll differ diff --git a/ext/readimx/boost_thread-vc140-mt-1_62.dll b/ext/readimx/boost_thread-vc140-mt-1_62.dll new file mode 100644 index 0000000000000000000000000000000000000000..8e498c9434c0be495c286fb5e7bcfaedb2c07562 Binary files /dev/null and b/ext/readimx/boost_thread-vc140-mt-1_62.dll differ diff --git a/ext/readimx/copyit.m b/ext/readimx/copyit.m new file mode 100644 index 0000000000000000000000000000000000000000..845b9c684b2100e62735b2313e8210f835cf771d --- /dev/null +++ b/ext/readimx/copyit.m @@ -0,0 +1,27 @@ +folder = 'B:\davis\multiscale\U10test'; +outdir = 'J:\FEE\EFMRL\John\190509'; + +%% get latest folder +dir_list= dir(folder); +dir_list(~[dir_list.isdir]) = []; + +%% +for k = 3 : length(dir_list) + %% get name + dname = dir_list(k).name; + xi = sscanf(dname, 'U10_x-axis=%f_x-axis=%f_x-axis=%f'); + if length(xi) ~= 3 + continue; + end + fname = sprintf('%s/%s/B00001.im7', dir_list(k).folder, dname); + disp(xi); + disp(fname); + disp(exist(fname,'file')); + + %% copy + idx = round((xi(1) - 83) / (100/12)); + outfile = sprintf('%s/X%02d.im7', outdir, idx); + disp(outfile); + + copyfile(fname, outfile); +end \ No newline at end of file diff --git a/ext/readimx/create2DVec.m b/ext/readimx/create2DVec.m new file mode 100644 index 0000000000000000000000000000000000000000..e979383e140fdb732f0fb403424b28eedebc9080 --- /dev/null +++ b/ext/readimx/create2DVec.m @@ -0,0 +1,32 @@ +function [D] = create2DVec( Frame ) + +Components = Frame.Components; +frameInfo = MakeFrameInfo(Frame); +%Compile vector data +if (frameInfo.hasChoices), + D.C = Components{ frameInfo.best }.Planes{1}; + D.U = zeros(size(D.C)); + D.V = zeros(size(D.C)); + for i=0:4, + mask = (D.C==i); + j = min(i,3); + choiceU = frameInfo.choices(j*3+1); + choiceV = frameInfo.choices(j*3+2); + D.U(mask) = Components{ choiceU }.Planes{1}(mask); + D.V(mask) = Components{ choiceV }.Planes{1}(mask); + end +else + D.U = Components{frameInfo.choices(1)}.Planes{1}; + D.V = Components{frameInfo.choices(2)}.Planes{1}; +end +Grids = frameInfo.Grids; +scaleX = frameInfo.Scales.X; +scaleY = frameInfo.Scales.Y; +scaleI = frameInfo.Scales.I; +D.U = double(D.U)*scaleI.Slope + scaleI.Offset; +D.V = double(D.V)*scaleI.Slope + scaleI.Offset; +if scaleY.Slope < 0.0, D.V = -D.V; end +%Compile location data +Rx = (1:size(D.U,1))-0.5; +Ry = (1:size(D.U,2))-0.5; +[D.X,D.Y] = ndgrid(Rx*Grids.X*scaleX.Slope + scaleX.Offset, Ry*Grids.Y*scaleY.Slope + scaleY.Offset); diff --git a/ext/readimx/create3DStack.m b/ext/readimx/create3DStack.m new file mode 100644 index 0000000000000000000000000000000000000000..acfc8208bdae2db2236fa52f417e7f6218d2196b --- /dev/null +++ b/ext/readimx/create3DStack.m @@ -0,0 +1,10 @@ +function st = create3DStack (Component) + +planes = Component.Planes; +nz = size(planes,1); +if nz >0, + nx = size(planes{1},1); + ny = size(planes{1},2); + st = zeros(nx,ny,nz); + for i=1:nz, st(:,:,i) = planes{i}; end +end \ No newline at end of file diff --git a/ext/readimx/create3DVec.m b/ext/readimx/create3DVec.m new file mode 100644 index 0000000000000000000000000000000000000000..2be701afe3a088270d02e945e6537c592e6f55d5 --- /dev/null +++ b/ext/readimx/create3DVec.m @@ -0,0 +1,43 @@ +function [D] = create3DVec( Frame ) + +Components = Frame.Components; +frameInfo = MakeFrameInfo(Frame); +%Compile best vector data +if (frameInfo.hasChoices), + D.C = create3DStack(Components{ frameInfo.best }); + D.U = zeros(size(D.C)); + D.V = zeros(size(D.C)); + D.W = zeros(size(D.C)); + for i=0:5, + mask = (D.C==i); + j = min(i,3); + choiceU = frameInfo.choices(j*3+1); + choiceV = frameInfo.choices(j*3+2); + choiceW = frameInfo.choices(j*3+3); + x = create3DStack(Components{ choiceU }); + D.U(mask) = x(mask); + x = create3DStack(Components{ choiceV }); + D.V(mask) = x(mask); + x = create3DStack(Components{ choiceW }); + D.W(mask) = x(mask); + end +else + D.U = create3DStack(Components{frameInfo.choices(1)}); + D.V = create3DStack(Components{frameInfo.choices(2)}); + D.W = create3DStack(Components{frameInfo.choices(3)}); +end +scaleI = frameInfo.Scales.I; +D.U = double(D.U)*scaleI.Slope + scaleI.Offset; +D.V = double(D.V)*scaleI.Slope + scaleI.Offset; +D.W = double(D.W)*scaleI.Slope + scaleI.Offset; +scaleY = frameInfo.Scales.Y; +if scaleY.Slope < 0.0, D.V = -D.V; end +%Complile location data +Grids = frameInfo.Grids; +scaleX = frameInfo.Scales.X; scaleZ = frameInfo.Scales.Z; +Rx = (1:size(D.U,1))-0.5; +Ry = (1:size(D.U,2))-0.5; +Rz = (1:size(D.U,3))-1.0; +[D.X,D.Y,D.Z] = ndgrid( Rx*Grids.X*scaleX.Slope + scaleX.Offset,... + Ry*Grids.Y*scaleY.Slope + scaleY.Offset,... + Rz*Grids.Z*scaleZ.Slope + scaleZ.Offset); \ No newline at end of file diff --git a/ext/readimx/createPlane.m b/ext/readimx/createPlane.m new file mode 100644 index 0000000000000000000000000000000000000000..8ec8fd98974d7ee05179ad13f143e17ff4f7aa1e --- /dev/null +++ b/ext/readimx/createPlane.m @@ -0,0 +1,8 @@ +function [D]=createPlane( plane, scales ) + +%Create image data +nx = size(plane,1); +ny = size(plane,2); +D.X = double(1:nx) * scales.X.Slope + scales.X.Offset ; +D.Y = double(1:ny) * scales.Y.Slope + scales.Y.Offset ; +D.I = double(plane) * scales.I.Slope + scales.I.Offset ; diff --git a/ext/readimx/createVolume.m b/ext/readimx/createVolume.m new file mode 100644 index 0000000000000000000000000000000000000000..f4be99ac34fa14f68c6077e7e33322be74193856 --- /dev/null +++ b/ext/readimx/createVolume.m @@ -0,0 +1,16 @@ +function [D]=createVolume( planeCells, scales ) + +nz = size(planeCells,1); +if nz < 1, error('invalid number of planes'); end; +nx = size(planeCells{1},1); +ny = size(planeCells{1},2); +%Create location data from scales +rx = double(1:nx) * scales.X.Slope + scales.X.Offset ; +ry = double(1:ny) * scales.Y.Slope + scales.Y.Offset ; +rz = double(1:nz) * scales.Z.Slope + scales.Z.Offset ; +[D.X,D.Y,D.Z] = meshgrid(rx,ry,rz); +%Create volume data from planes +D.I = zeros(nx,ny,nz); +for i=1:nz, + D.I(:,:,i) = planeCells{i}* scales.I.Slope + scales.I.Offset; +end; diff --git a/ext/readimx/lvsetsize.mexw64 b/ext/readimx/lvsetsize.mexw64 new file mode 100644 index 0000000000000000000000000000000000000000..4770cd0000a208d8d71db68ec045f6ebd087b2ec Binary files /dev/null and b/ext/readimx/lvsetsize.mexw64 differ diff --git a/ext/readimx/readimx.mexw64 b/ext/readimx/readimx.mexw64 new file mode 100644 index 0000000000000000000000000000000000000000..2dab62d1c5fd0eff57f8be4cd1ec5949690fc8c9 Binary files /dev/null and b/ext/readimx/readimx.mexw64 differ diff --git a/ext/readimx/readimxUI.m b/ext/readimx/readimxUI.m new file mode 100644 index 0000000000000000000000000000000000000000..4077dba5ae1fcfdeb31e2621762375f22ce3dc48 --- /dev/null +++ b/ext/readimx/readimxUI.m @@ -0,0 +1,8 @@ +function [A] = readimxUI( ) +A='no file'; +%Display located vector field +[f,p] = uigetfile('*.im?'); +if ischar(f), + A = readimx([p f]); + showimx(A.Frames{1}); +end diff --git a/ext/readimx/readimxdemo.m b/ext/readimx/readimxdemo.m new file mode 100644 index 0000000000000000000000000000000000000000..6a4ea58a902ee23983726fcaa383096c6f126337 --- /dev/null +++ b/ext/readimx/readimxdemo.m @@ -0,0 +1,13 @@ +[lv_pathstr]= fileparts(which('readimx')); +lv_dirlist = dir([lv_pathstr '/TestImages']); +lv_j=1; +clear A; +for lv_i=1:size(lv_dirlist,1), + if ( ~lv_dirlist(lv_i).isdir) + disp(['Load and display ' lv_dirlist(lv_i).name ' ...'] ); + A(lv_j) = readimx([lv_pathstr '/TestImages/' lv_dirlist(lv_i).name]); + figure; showimx(A(lv_j).Frames{1});title(['Image ' num2str(lv_j) ': ' lv_dirlist(lv_i).name]); + lv_j = lv_j+1; + end +end +clear lv_*; \ No newline at end of file diff --git a/ext/readimx/show2DVec.m b/ext/readimx/show2DVec.m new file mode 100644 index 0000000000000000000000000000000000000000..e792a0ef31d0ce7b2adf6da377c841e3ae1caedc --- /dev/null +++ b/ext/readimx/show2DVec.m @@ -0,0 +1,4 @@ +function [D] = show2DVec( Frame ) +%Display located vector field +D = create2DVec( Frame ); +quiver( D.X, D.Y, D.U, D.V); diff --git a/ext/readimx/show3DVec.m b/ext/readimx/show3DVec.m new file mode 100644 index 0000000000000000000000000000000000000000..7fe9d254353f1903eef4f3037ce6b0bd81946bca --- /dev/null +++ b/ext/readimx/show3DVec.m @@ -0,0 +1,6 @@ +function [D] = show3DVec( Frame ) +%Display located vector field +D = create3DVec( Frame ); +disp 'quiver3d is to slow' +quiver3(D.X,D.Y,D.Z,D.U,D.V,D.W); + diff --git a/ext/readimx/showPlane.m b/ext/readimx/showPlane.m new file mode 100644 index 0000000000000000000000000000000000000000..acabaebf4e106fc09f3f33098218b42dbb7e4cb9 --- /dev/null +++ b/ext/readimx/showPlane.m @@ -0,0 +1,15 @@ +function [D]=showPlane( plane, scales ) + +D = createPlane( plane, scales ); + +%Display image data +imagesc(D.X,D.Y,D.I'); +%Setup display +xlabel([scales.X.Description ' ' scales.X.Unit]); +ylabel([scales.Y.Description ' ' scales.Y.Unit]); +title ([scales.I.Description ' ' scales.I.Unit]); +if scales.Y.Slope >=0.0, + axis ij; +else + axis xy; +end diff --git a/ext/readimx/showVolume.m b/ext/readimx/showVolume.m new file mode 100644 index 0000000000000000000000000000000000000000..e7f4264e44df49ecc26957e736f568729b56f54b --- /dev/null +++ b/ext/readimx/showVolume.m @@ -0,0 +1,13 @@ +function [D]=showVolume( planeCells, scales ) + +nz = size(planeCells,1); +if nz < 1, error('invalid number of planes'); end; +nx = size(planeCells{1},1); +ny = size(planeCells{1},2); +%Create location data from scales +rx = double(1:nx) * scales.X.Slope + scales.X.Offset ; +ry = double(1:ny) * scales.Y.Slope + scales.Y.Offset ; +rz = double(1:nz) * scales.Z.Slope + scales.Z.Offset ; +% Display volume slizes +D = createVolume( planeCells, scales ); +slice(D.X,D.Y,D.Z,D.I,[rx(nx/2)],[ry(ny/2)],rz(1:nz/4:nz) ); diff --git a/ext/readimx/showimx.m b/ext/readimx/showimx.m new file mode 100644 index 0000000000000000000000000000000000000000..b3cfbe6658dafff977eadbde486f517c4981bdab --- /dev/null +++ b/ext/readimx/showimx.m @@ -0,0 +1,38 @@ +function [D]=showimx( Frame ) +% CALL: []=showimx(Frame); +% +% FUNCTION: Displaying data of LaVision's IMX structure +% (one vector field, all image frames or only single image frame) +% +% ARGUMENTS: Frame = frames structure created by readimx2 function +% +% RETURN: in case of images (image type=0): + +if nargin==0, + help showimx, return +end + +if ~(isfield(Frame,'Components') & isfield(Frame,'Attributes') & isfield(Frame,'Scales') & isfield(Frame,'ComponentNames') & isfield(Frame,'IsVector') ) , + help showimx, return +end + +Components = Frame.Components; +if Frame.IsVector, + frameInfo = MakeFrameInfo(Frame); + if ( frameInfo.is3D ), + D = show3DVec(Frame); + else + D = show2DVec(Frame); + end + +else + Planes = Components{1}.Planes; % assume image in component 1, ignore mask in component 2 + nz = size(Planes,1); + if nz==0, + disp('no Planes') + elseif nz==1, + D = showPlane( Planes{1}, Frame.Scales ); + else + D = showVolume( Planes, Frame.Scales ); + end +end \ No newline at end of file diff --git a/ext/readimx/showlatest.m b/ext/readimx/showlatest.m new file mode 100644 index 0000000000000000000000000000000000000000..1b0b4c416ba4829ff4aeec8da71d5702d68938f9 --- /dev/null +++ b/ext/readimx/showlatest.m @@ -0,0 +1,49 @@ +folder = 'B:\davis\multiscale\Gen1_12\U10\'; +cmap = gray * diag([0 1 0]); +cmap(end,:)=[1 0 0]; +c_lim = [0 128]; +wsize = [11 11]; + + +%% get latest folder +dir_list= dir(folder); +dir_list(~[dir_list.isdir]) = []; +[~,idx] = sort([dir_list.datenum], 'ascend'); +latest_dir = dir_list(idx(end)); +latest_dir = [latest_dir.folder '/' latest_dir.name]; + +disp(latest_dir); + +%% get latest file +file_list = dir(latest_dir); +file_list([file_list.isdir]) = []; +[~,idx] = sort([file_list.datenum], 'ascend'); +latest_imx = file_list(idx(end-1)); +latest_imx = [latest_imx.folder '/' latest_imx.name]; + +disp(latest_imx); + +%% read +img = readimx(latest_imx); +im_ary = cellfun(@(f) f.Components{1}.Planes{1}, img.Frames, 'UniformOutput', false); +% subtract bg +%im_ary = cellfun(@(im) im - min(min(im)), im_ary, 'UniformOutput', false); +im_ary = cellfun(@(im) im - movmin(movmin(im, wsize, 2), 1), im_ary, 'UniformOutput', false); + + +%% plot +figure(1); +clf; +ax = [0 0 0 0]; +for k = 1 : 4 + ax(k) = subplot(1,4,k); + im = im_ary{k};% - bg_ary{k}; + imagesc(im'); + axis equal tight ij; + colormap(cmap); + set(gca,'clim',c_lim); +end + +linkaxes(ax([1 2]), 'xy'); +linkaxes(ax([3 4]), 'xy'); + \ No newline at end of file diff --git a/ext/readimx/writeimx.mexw64 b/ext/readimx/writeimx.mexw64 new file mode 100644 index 0000000000000000000000000000000000000000..60e890b944c66c09dcff2fb8d2fd7a048112eb49 Binary files /dev/null and b/ext/readimx/writeimx.mexw64 differ diff --git a/ext/readimx/zlibwapi.dll b/ext/readimx/zlibwapi.dll new file mode 100644 index 0000000000000000000000000000000000000000..3ccf37aa2f457062e42260fd7ca8987819a12b4c Binary files /dev/null and b/ext/readimx/zlibwapi.dll differ diff --git a/misc/redblue.m b/ext/redblue.m similarity index 100% rename from misc/redblue.m rename to ext/redblue.m diff --git a/job_create.m b/job_create.m index edcf8db82850ea3bdb023b5a2e073196f1460ed7..579a157fbe9244a38417ad50466ecfaa153d5060 100644 --- a/job_create.m +++ b/job_create.m @@ -9,28 +9,28 @@ addpath(genpath(fileparts(mfilename('fullpath')))); %% input parameters: file paths % where to save jobs -job_idx = 2; +%job_idx = 1; job_dir = 'H:\davis\multiscale\Gen1_12\jobs\'; job_pat = '%s/job%03d.mat'; % path of images to process -src_dir = 'H:\davis\multiscale\Gen1_12\U10\U10_x-axis=257.988_x-axis=257.987_x-axis=229.986\'; +%src_dir = 'H:\davis\multiscale\Gen1_12\U10\U10_x-axis=257.988_x-axis=257.987_x-axis=229.986\'; src_pat = '%s/B%05d.im7'; % source image to process -src_range = 2:2; % range of source images to process +src_range = 1:1000; % range of source images to process % background & mask bg_dir = src_dir; % background image directory bg_pat = '%s/minmax.mat'; % background image (ignore if not using) msk_dir = [src_dir '/MASK/']; % mask image directory msk_pat = '%s/B0001.im7'; % pattern for mask image input (ignore if not using) % where to save result -vec_dir = [src_dir '/C12']; % directory to save vector fields to +%vec_dir = [src_dir '/C12']; % directory to save vector fields to vec_pat = '%s/B%05d.mat'; % output vector field file pattern %% input parameters: processing % processing flags b_use_mask = true; % use mask file? b_overwrite = true; % overwrite existing vector fields? -b_execute_now = true; % start processing now? +b_execute_now = false; % start processing now? % PIV correlation settings i_frames = {[1 2],[3 4]}; % indices of frame pairs to cross-correlate diff --git a/job_execute.m b/job_execute.m index 49b648b0607733def0b765cca6b9c6492a012ab0..3c25f31b8f117011fa1be148e2e12fb694f364a9 100644 --- a/job_execute.m +++ b/job_execute.m @@ -144,7 +144,9 @@ function job_execute(job_file) % only save final pass for c = 1 : n_correl vname = sprintf('C%d',c); - fs.(vname) = piv_result{c}(end); + VC = piv_result{c}(end); + VC.attributes= atts; + fs.(vname) = VC; end if exist(vec_name, 'file') warning('%s already exists, overwriting result', vec_name); diff --git a/misc/loadimx.m b/misc/loadimx.m new file mode 100644 index 0000000000000000000000000000000000000000..633143f58bdec4fe73c5a7e28b658aac3ba3e426 --- /dev/null +++ b/misc/loadimx.m @@ -0,0 +1,33 @@ +imx_dir = 'H:\davis\multiscale\Gen1\U10\U10_x-axis=382.988_x-axis=382.985_x-axis=354.987'; +imx_pat = '%s/B00001.im7'; +frame = [2 4]; +c_lim = [0 256]; + +%% load +fn = sprintf(imx_pat, imx_dir); +imx = readimx(fn); +imA = imx.Frames{frame(1)}.Components{1}.Planes{1}; +imB = imx.Frames{frame(2)}.Components{1}.Planes{1}; +im_size = size(imA); +i_axis = 0 : im_size(1)-1; +j_axis = 0 : im_size(2)-1; + +%% plot +figure(11); +clf; + +% left image with markers +subplot(1,2,1); +imagesc(i_axis,j_axis,imA'); +axis equal tight ij; +hold on; +set(gca,'clim',c_lim); +title('Camera 1'); + +% right image with markers +subplot(1,2,2); +imagesc(i_axis,j_axis,imB'); +axis equal tight ij; +hold on; +title('Camera 2'); +set(gca,'clim',c_lim); \ No newline at end of file diff --git a/misc/quiver3sc.m b/misc/quiver3sc.m new file mode 100644 index 0000000000000000000000000000000000000000..fe379500abedbf25a8908516692c565bf71517a3 --- /dev/null +++ b/misc/quiver3sc.m @@ -0,0 +1,9 @@ +function hquiv = quiver3sc(x, y, z, u, v, w, scale, varargin) + % draw quiver plot with sensibly scaled arrows + % quiversc(x,y,u,v,scale,varargin) + hquiv = quiver3(x, y, z, u, v, w, scale, varargin{:}); + set(hquiv, 'Autoscale', 'off'); + set(hquiv, 'UData', scale * get(hquiv, 'UData')); + set(hquiv, 'VData', scale * get(hquiv, 'VData')); + set(hquiv, 'WData', scale * get(hquiv, 'WData')); +end \ No newline at end of file diff --git a/misc/readAttributes.m b/misc/readAttributes.m new file mode 100644 index 0000000000000000000000000000000000000000..0a203a3f145637787ae395abe8e8d68c41bdfa96 --- /dev/null +++ b/misc/readAttributes.m @@ -0,0 +1,40 @@ +function attr_map = readAttributes(imx) + % read attributes into a dictionary + + %% extract name/value pairs + attr_names = cellfun(@(a) a.Name, imx.Attributes, 'UniformOutput', false); + attr_values = cellfun(@(a) a.Value, imx.Attributes, 'UniformOutput', false); + + %% create map + attr_map = containers.Map; + + %% read default keys + n_sources = str2num(readpair(attr_names, attr_values, 'DevDataSources')); + key_list = {'_FrameScale', '_Title', '_DavisVersion', '_Time', '_Date', 'AcqTimeSeries'}; + for k = 1 : length(key_list) + attr_map(key_list{k}) = readpair(attr_names, attr_values, key_list{k}); + end + + %% read device data sources + for n = 0 : n_sources-1 + % read properties of data source + name = readpair(attr_names, attr_values, sprintf('DevDataName%d', n)); + s = struct(); + s.name = name; + s.alias = readpair(attr_names, attr_values, sprintf('DevDataAlias%d', n)); + s.scale = readpair(attr_names, attr_values, sprintf('DevDataScale%d', n)); + s.class = readpair(attr_names, attr_values, sprintf('DevDataClass%d', n)); + s.value = readpair(attr_names, attr_values, sprintf('DevDataTrace%d', n)); + + % save in hash table + attr_map(name) = s; + end +end + +function val = readpair(names, values, key) + i_key = strcmp(names, key); + val = []; + if any(i_key) + val = values{i_key}; + end +end \ No newline at end of file diff --git a/misc/rescaleVec.m b/misc/rescaleVec.m new file mode 100644 index 0000000000000000000000000000000000000000..13213cb513d044cd05cc63ae1a3e7a0f21fd838d --- /dev/null +++ b/misc/rescaleVec.m @@ -0,0 +1,4 @@ +function V = rescale_field(V, scale) + V.U = V.U * scale; + V.V = V.V * scale; +end \ No newline at end of file diff --git a/misc/unitvector.m b/misc/unitvector.m new file mode 100644 index 0000000000000000000000000000000000000000..23935949b368607a8c340f078d303cbb0c7ccda7 --- /dev/null +++ b/misc/unitvector.m @@ -0,0 +1,7 @@ +function [x,x2] = unitvector(x, dim) + if nargin < 2 + dim=1; + end + x2 = sqrt(sum(x.^2,dim)); + x = bsxfun(@rdivide, x, x2); +end \ No newline at end of file diff --git a/pinhole/back_project_line.m b/pinhole/back_project_line.m new file mode 100644 index 0000000000000000000000000000000000000000..4ad5618290cef835d188a3a7d6ac426312fc4692 --- /dev/null +++ b/pinhole/back_project_line.m @@ -0,0 +1,42 @@ +function [e_s, x0] = back_project_line(camA, camB, lineA, lineB) + % [e_s,x0] = back_project_line(camA, camB, lineA, lineB) + % + % reconstruct the line + % x = s*e_s + x0 + % which projects onto the lines lineA and lineB observed in images A and B + % + % the solution is unique up to a translation in x0 along the line + % and the direction of e_s + % + % Input: + % camA calibration structure, camera A + % camB calibration structure, camera B + % lineA image coordinates of line in camera A [x0 y0; x1 y1] + % lineB image coordinates of line in camera B [x0 y0; x1 y1] + + %% correct for distortion + im_line_A = inverse_radial_distortion(lineA, camA.ic, camA.kr); + im_line_B = inverse_radial_distortion(lineB, camB.ic, camB.kr); + + %% reconstruct epipolar planes + % camera A + GR_A = camA.G * camA.R; + e_1A = GR_A \ [im_line_A(:,1); 1]; % parallel to plane + e_2A = GR_A \ [im_line_A(:,2); 1]; % parallel to plane + n_A = cross(e_1A, e_2A); + n_A = n_A / norm(n_A); + d_A = -dot(camA.xc, n_A); % use known point on plane to get offset + % camera B + GR_B = camB.G * camB.R; + e_1B = GR_B \ [im_line_B(:,1); 1]; % parallel to plane + e_2B = GR_B \ [im_line_B(:,2); 1]; % parallel to plane + n_B = cross(e_1B, e_2B); + n_B = n_B / norm(n_B); + d_B = -dot(camB.xc, n_B); % use known point on plane to get offset + + %% reconstruct line + e_s = cross(n_A, n_B); + e_s = e_s / norm(e_s); + x0 = [n_A(:).'; n_B(:).'; e_s(:).'] \ [-d_A; -d_B; 0]; +end + \ No newline at end of file diff --git a/pinhole/back_project_roi.m b/pinhole/back_project_roi.m new file mode 100644 index 0000000000000000000000000000000000000000..e3bb68398a50f9fbba0c0b44131e6b79c577b361 --- /dev/null +++ b/pinhole/back_project_roi.m @@ -0,0 +1,49 @@ +function [pl_corners, re_corners] = back_project_roi(c_A, c_B, P) + % re_corners = back_project_roi(c_A, c_B, P) + % + % determine corners of ROI in object space for the stereo back-projection + % of images in cameras A and B onto the plane P + % + % the corners form a bounding rectangle over a mutually visible ROI + % in the plane P, of minimum size to + % + % Input: + % c_A Camera A calibration struct + % c_B Camera B calibration struct + % P 3 x 4 transformation matrix mapping plane to world + % coords + % [x;y;z] = P * [u;v;w;1] + + %% extract equation of plane + M = [P(:,3); -dot(P(:,4),P(:,3))]'; + x_0 = P(:,4); + pl_to_re = P(:,1:3); + + %% back-project corners for camera A + ij_corners_A = [c_A.i_axis([1 1 end end]); c_A.j_axis([1 end end 1])]; + re_corners_A = back_project_1c(c_A.calib, M, ij_corners_A, true); + + %% back-project corners for camera B + ij_corners_B = [c_B.i_axis([1 1 end end]); c_B.j_axis([1 end end 1])]; + re_corners_B = back_project_1c(c_B.calib, M, ij_corners_B, true); + + %% project corners onto plane coordinate system + % in this coordinate system points all lie on plane with w = 0 + pl_corners_A = pl_to_re \ bsxfun(@minus, re_corners_A, x_0(:)); + pl_corners_B = pl_to_re \ bsxfun(@minus, re_corners_B, x_0(:)); + + %% create intersection of two ROIs + poly_A = polyshape(pl_corners_A(1,:), pl_corners_A(2,:)); + poly_B = polyshape(pl_corners_B(1,:), pl_corners_B(2,:)); + poly_ROI = intersect(poly_A, poly_B); + + %% find bounding box + pl_corners = poly_ROI.Vertices'; + pl_lim = [ min(pl_corners, [], 2) max(pl_corners, [], 2) ]; + pl_corners = [ pl_lim(1, [1 1 2 2]); + pl_lim(2, [1 2 2 1]); + 0 0 0 0]; + + %% map back to world coordinates + re_corners = bsxfun(@plus, x_0, pl_to_re * pl_corners); +end \ No newline at end of file diff --git a/pinhole/dlt33.m b/pinhole/dlt33.m new file mode 100644 index 0000000000000000000000000000000000000000..991d23dd4101e80acdb8fdc701aa1f2a8babc0a7 --- /dev/null +++ b/pinhole/dlt33.m @@ -0,0 +1,65 @@ +function P = dlt33(xk, yk) + % solve the set of similarity relations + % xk ~ Pyk + % + % for xk = [x1k x2k x3k]' is a 3x1 vector + % yk = [y1k y2k y3k]' is a 3x1 vector + % + % to find the 3x3 matrix P + % subject to |P| = 1, where |P| is the Froebenius norm + + % set up the problem as solving + % xk' * H * P * yk = 0 + % + % leveraging xk'*H*xk = 0 + % however, for xk on R^3, the dimension of H_m is 3 + % i.e. there are three basis-matrices H_m that can satisfy xk'*H*xk = 0 + % these are: + % H1 = [0 0 0; 0 0 -1; 0 1 0] + % H2 = [0 0 1; 0 0 0; -1 0 0] + % H3 = [0 -1 0; 1 0 0; 0 0 0] + % + % so we get three sets of equations + % bk' * p = [0 0 0]' + % + % 0 = P2_1*x3*y1 + P2_2*x3*y2 + P2_3*x3*y3 - P3_1*x2*y1 - P3_2*x2*y2 - P3_3*x2*y3 + % 0 = P3_1*x1*y1 - P1_2*x3*y2 - P1_3*x3*y3 - P1_1*x3*y1 + P3_2*x1*y2 + P3_3*x1*y3 + % 0 = P1_1*x2*y1 + P1_2*x2*y2 + P1_3*x2*y3 - P2_1*x1*y1 - P2_2*x1*y2 - P2_3*x1*y3 + + % number of similarity relations we have + N = size(xk, 2); + assert(size(yk,2) == N); + + % set up matrix B + % with rows b_k + % that satisfy b_k * p = 0 + B = zeros(N*3, 9); + for k = 1 : N + x = xk(:, k); + y = yk(:, k); + B(3*(k-1)+1, :) = [ 0; x(3)*y(1); -x(2)*y(1); 0; x(3)*y(2); -x(2)*y(2); 0; x(3)*y(3); -x(2)*y(3)]; + B(3*(k-1)+2, :) = [ -x(3)*y(1); 0; +x(1)*y(1); -x(3)*y(2); 0; +x(1)*y(2); -x(3)*y(3); 0; +x(1)*y(3)]; + B(3*(k-1)+3, :) = [ +x(2)*y(1); -x(1)*y(1); 0; +x(2)*y(2); -x(1)*y(2); 0; +x(2)*y(3); -x(1)*y(3); 0]; + end + + % now our solution p is the solution of + % B*p = 0 + % i.e. p is in the null space of B + % but due to errors, this is not exact, so we seek a solution in the + % least squares sense + % + % i.e. minimise |Bp| subject to |p| = 1 + % this can be solved with SVD + % + % p is the unit singular vector of B corresponding to the last column of + % V, when the elements in S are ranked in decreasing size + % which, helpfully, matlab does by default + [U,S,V] = svd(B); + sigma = diag(S); + p = V(:, end); + + P = reshape(p, [3 3]); +end + + + \ No newline at end of file diff --git a/pinhole/dlt34.m b/pinhole/dlt34.m new file mode 100644 index 0000000000000000000000000000000000000000..b742824e4de67b3dd046b3ca004786ea869b5b79 --- /dev/null +++ b/pinhole/dlt34.m @@ -0,0 +1,61 @@ +function P = dlt34(xk, yk) + % solve the set of similarity relations + % xk ~ Pyk + % + % for xk = [x1k x2k x3k]' is a 3x1 vector + % yk = [y1k y2k y3k y4k]' is a 4x1 vector + % + % to find the 3x4 matrix P + + % set up the problem as solving + % xk' * H * P * yk = 0 + % + % leveraging xk'*H*xk = 0 + % however, for xk on R^3, the dimension of H_m is 3 + % i.e. there are three basis-matrices H_m that can satisfy xk'*H*xk = 0 + % these are: + % H1 = [0 0 0; 0 0 -1; 0 1 0] + % H2 = [0 0 1; 0 0 0; -1 0 0] + % H3 = [0 -1 0; 1 0 0; 0 0 0] + % + % so we get three sets of equations + % bk' * p = [0 0 0]' + + % number of similarity relations we have + N = size(xk, 2); + assert(size(yk,2) == N); + assert(size(xk,1) == 3); + assert(size(yk,1) == 4); + + % set up matrix B + % with rows b_k + % that satisfy b_k * p = 0 + B = zeros(N*3, 12); + for k = 1 : N + x = xk(:, k); + y = yk(:, k); + B(3*(k-1)+1, :)= [ 0; +x(3)*y(1); -x(2)*y(1); 0; +x(3)*y(2); -x(2)*y(2); 0; +x(3)*y(3); -x(2)*y(3); 0; +x(3)*y(4); -x(2)*y(4)]; + B(3*(k-1)+2, :)= [ -x(3)*y(1); 0; +x(1)*y(1); -x(3)*y(2); 0; +x(1)*y(2); -x(3)*y(3); 0; +x(1)*y(3); -x(3)*y(4); 0; +x(1)*y(4)]; + B(3*(k-1)+3, :)= [ +x(2)*y(1); -x(1)*y(1); 0; +x(2)*y(2); -x(1)*y(2); 0; +x(2)*y(3); -x(1)*y(3); 0; +x(2)*y(4); -x(1)*y(4); 0]; + end + + % now our solution p is the solution of + % B*p = 0 + % i.e. p is in the null space of B + % can be solved with SVD + % + % we add the additional constraint that |p| = 1 + % to find the minimal P + % + % p is the unit singular vector of A corresponding to the last column of + % V, when the elements in S are ranked in decreasing size + % which, helpfully, matlab does by default + [Q,D] = eig(B.' * B); + D = diag(D); + [~,idx] = min(abs(D)); + p = Q(:, idx); + P = reshape(p, [3 4]); +end + + + \ No newline at end of file diff --git a/pinhole/inverse_radial_distortion.m b/pinhole/inverse_radial_distortion.m new file mode 100644 index 0000000000000000000000000000000000000000..7bcafc2fc4f9ee7d3b2d5a60bc78ebb75041770f --- /dev/null +++ b/pinhole/inverse_radial_distortion.m @@ -0,0 +1,36 @@ +function y = inverse_radial_distortion(yprime, p, k) + % y = inverse_radial_distortion(yprime, p, k) + % + % reverse radial distortion, to map from + % (distorted) real world image coordinates y' + % (undistorted) pinhole image coordinates y + % + % these are related according to + % y' - p = (y-p)(1 + k(1)*|y-p|^2 + k(2)*|y-p|^4) + % + % yprime is 2 x N matrix + % p is 1x2 vector, representing the principal point + % k is 1x2 vector, representing distortion coefficients + + % let z' = y' - p + % z = y - p + % r' = |z'| + % r = |z| + % then solve + % r' = r*(1 + k(1)r^2 + k(2)*r^4) + % for r, for the root nearest r' + zprime = bsxfun(@minus, yprime, p(:)); + rprime = sqrt(sum(zprime.^2, 1)); + + % use newton-raphson method, just a few iterations are sufficient + r = rprime; + f = @(r) k(2)*r.^5 + k(1)*r.^3 + r - rprime; + fprime = @(r) 5*k(2)*r.^4 + 3*k(1)*r.^2 + 1; + for it = 1 : 3 + r = r - f(r) ./ fprime(r); + end + + % now calculate y + z = bsxfun(@rdivide, zprime, 1 + k(1)*r.^2 + k(2)*r.^4); + y = bsxfun(@plus, z, p(:)); +end \ No newline at end of file diff --git a/pinhole/p2d_fit.m b/pinhole/p2d_fit.m new file mode 100644 index 0000000000000000000000000000000000000000..025734c81e4e667c123e378c3d08b8b32d655856 --- /dev/null +++ b/pinhole/p2d_fit.m @@ -0,0 +1,29 @@ +function [P2D, ij_res] = p2d_fit(xy_mark, ij_mark) + % P2D, res = p2d_fit(xy_mark, ij_mark) + % + % fit a simple 2D pinhole model to map the x-y plane in object space + % to the i-j plane in image space + % + % input: + % xy_mark 2 x N array of marker locations in object space + % which lie on the x-y plane + % ij_mark 2 x N array of marker locations in image space + % which lie on the i-j plane + % + % output: + % P2D a matrix representing the pinhole model + % ij_res residual displacement between model and marker + % locations in image space + + % fit pinhole + n_mark = size(xy_mark, 2); + xy_tilde = [xy_mark;ones(1,n_mark)]; + P2D = dlt33([ij_mark;ones(1,n_mark)], xy_tilde); + % calculate residuals + if nargout > 1 + ij_model = P2D * xy_tilde; + ij_model = [ij_model(1,:) ./ ij_model(3,:); + ij_model(2,:) ./ ij_model(3,:)]; + ij_res = ij_mark - ij_model; + end +end diff --git a/pinhole/p2d_map_im2obj.m b/pinhole/p2d_map_im2obj.m new file mode 100644 index 0000000000000000000000000000000000000000..a1d9c3a9f8f41e5ada2b9b79c253f6061fddb229 --- /dev/null +++ b/pinhole/p2d_map_im2obj.m @@ -0,0 +1,18 @@ +function xy = p2d_map_im2obj(P2D, ij) + % xy = p2d_map_im2obj(P2D, ij) + % + % using the 2D pinhole model P2D + % map image space coordinates ij to object space coordinates xy + % + % input: + % P2D 3 x 3 matrix representing 2D pinhole model + % ij 2 x N array of marker locations in image space + % which lie on the i-j plane + % output: + % xy 2 x N array of marker locations in object space + % which lie on the x-y plane + + xy_tilde = P2D \ [ij; ones(1,size(ij,2))]; + xy = [xy_tilde(1,:) ./ xy_tilde(3,:); + xy_tilde(2,:) ./ xy_tilde(3,:)]; +end diff --git a/pinhole/p2d_map_obj2im.m b/pinhole/p2d_map_obj2im.m new file mode 100644 index 0000000000000000000000000000000000000000..4951194568a7e5a5fbc0e3e7bd533fb14257795f --- /dev/null +++ b/pinhole/p2d_map_obj2im.m @@ -0,0 +1,18 @@ +function ij = p2d_map_obj2im(P2D, xy) + % xy = p2d_map_im2obj(P2D, ij) + % + % using the 2D pinhole model P2D + % map object space coordinates xy to image space coordinates ij + % + % input: + % P2D 3 x 3 matrix representing 2D pinhole model + % xy 2 x N array of marker locations in object space + % which lie on the x-y plane + % output: + % ij 2 x N array of marker locations in image space + % which lie on the i-j plane + + ij_tilde = P2D * [xy; ones(1,size(xy,2))]; + ij = [ij_tilde(1,:) ./ ij_tilde(3,:); + ij_tilde(2,:) ./ ij_tilde(3,:)]; +end diff --git a/pinhole/pinhole_camera_fit.m b/pinhole/pinhole_camera_fit.m new file mode 100644 index 0000000000000000000000000000000000000000..29ec24057d73c3d46106c27e7e481ed2f9ee987a --- /dev/null +++ b/pinhole/pinhole_camera_fit.m @@ -0,0 +1,36 @@ +function [calib,ij_res] = pinhole_camera_fit(setup) + % using the information provided in setup + % which describes the camera and traverse setup + % as well as measured positions of calibration markers + % + % find a pinhole camera model that describes each camera + pl_to_gl_mat = setup.pl_to_gl_mat; + gl_plate_pos = setup.gl_plate_pos; + n_cameras = setup.n_cameras; + n_views = setup.n_views; + calib = struct('P', [], 'G', [], 'R', [], 'xc', [], 'kr', [], 'ic', [], 'diag', [], 'gl_markers', [], 'ij_markers', []); + calib(1:n_cameras)= calib; + ij_res = cell(1,n_cameras); + + for n = 1 : n_cameras + %% load coordinates of markers from setup + camera = setup.camera(n); + [gl_markers, ij_markers] = plate_to_world(camera, setup); + n_markers_total= size(gl_markers, 2); + + %% find best fit model + [cal, ij_res{n}] = ... + pinhole_fit_3d(ij_markers, gl_markers); + + %% transfer to structure + calib(n).P = cal.P; + calib(n).G = cal.G; + calib(n).R = cal.R; + calib(n).xc = cal.xc; + calib(n).kr = cal.kr; + calib(n).ic = cal.ic; + calib(n).diag = cal.diag; + calib(n).gl_markers = gl_markers; + calib(n).ij_markers = ij_markers; + end +end diff --git a/pinhole/pinhole_fit_3d.m b/pinhole/pinhole_fit_3d.m new file mode 100644 index 0000000000000000000000000000000000000000..00d003079a37e022fa2fbff5f9ea2593d4adbd67 --- /dev/null +++ b/pinhole/pinhole_fit_3d.m @@ -0,0 +1,246 @@ +function [new_model, ij_res] = pinhole_fit_3d(ij, uvw, opts) + % fit a set of points u,v,w to a pinhole model with radial distortion + % a standard pinhole model maps u,v,w to distorted image plane + % coordinates + % i_d u + % j_d ~ P * v + % 1 w + % + % then distorted image plane coordinates are mapped to undistorted + % coordinates using + % + % i_u = i_p + (i_d - i_p) * (1 + k1*r^2 + k2*r^4) + % j_u = j_p + (j_d - j_p) * (1 + k1*r^2 + k2*r^4) + % r = (i_d - i_p)^2 + (j_d - j_p)^2 + % where i_p and j_p are the coordinates of the principal point, which is + % determined by P, and k1 and k2 are radial distortion parameters + % + % in the first step, we solve for P using a direct linear transform + % as an initial guess. in the second, we apply a least squares model + % to solve for P and the radial distortion parameters + % which minimises disparity between model and data + % + + %% preliminary fit + % solve using direct linear transform + N = size(uvw, 2); + assert(size(ij ,2) == N); + assert(size(uvw,1) == 3); + assert(size(ij ,1) == 2); + + uvw1 = [uvw; ones(1,N)]; + P = dlt34([ij; ones(1,N)], uvw1); + + %% construct options structure for fitting + % get approximate diagonal of sensor + % used in normalisation stage + diag_px = norm(max(ij,[],2) - min(ij,[],2)); + if nargin < 3 + opts = struct( 'square', false, ... + 'skew', true, ... + 'distortion', true, ... + 'diag', diag_px); + else + opts.diag = diag_px; + end + + %% decompose pinhole model + % P ~ G*R*[eye(3) -xc] + % xc is in the null space of p + % G is upper triangular + % [alpha_x gamma -f*alpha_x + % alpha_y -f*alpha_y + % 1 ] + % R is a rotation matrix + xc = null(P); + xc = xc(1:3) / xc(4); + xc = xc(:); + % RQ decomposition to find upper triangular G and orthogonal R + GR = P(1:3, 1:3); + [G,R] = rq(GR); + % intial guess for G + G_fg = G / G(3,3); + + % ensure G has positive focal length in both directions + perm = diag(sign(diag(G_fg))); + G_fg = G_fg * perm; + R = perm * R; + + %% constrained linear-least squares to solve G + % with square pixel and or zero skewness constraints + Xp = R*[eye(3),-xc(:)] * uvw1; + lambda = Xp(3,:); + % markers in physical coordinates on image plane + xp = Xp(1,:)./lambda; + yp = Xp(2,:)./lambda; + % construct the linear least-squares problem + % minimise || C*beta - d ||^2 + % beta = [fx tau fy cx cy] + C_x = [xp(:) yp(:) zeros(N,1) ones(N,1) zeros(N,1)]; + C_y = [zeros(N,1) zeros(N,1) yp(:) zeros(N,1) ones(N,1)]; + C = [C_x; C_y]; + d = [ij(1,:) ij(2,:)].'; + % add constraints + Aeq = []; + beq = []; + if opts.square + Aeq = [1 0 -1 0 0]; % enforce f_x = f_y + beq = 0; + end + if ~opts.skew + Aeq = [Aeq; 0 1 0 0 0]; % enforce tau = 0 + beq = [beq; 0]; + end + beta = lsqlin(C, d, [], [], Aeq, beq, [], [], [], optimset('display','off')); + % extract coefficients + G = [beta(1) beta(2) beta(4); 0 beta(3) beta(5); 0 0 1]; + + %% construct initial guess of projection matrix + % this is now subject to the square pixel and skewness constraints (if + % applied) + + % ensure R is right handed + perm = [sign(det(R)) 0 0; 0 1 0; 0 0 1]; + G = G*perm; + R = perm*R; + P = G*R*[eye(3), -xc(:)]; + + %% estimate radial distortion + % we fit a radial distortion model to the residuals of the pinhole model + % fit + lambda = P(3,:) * uvw1; + ij_model = [P(1,:) * uvw1 ./ lambda; + P(2,:) * uvw1 ./ lambda]; + X0 = [mean(ij(1,:)) mean(ij(2,:)) 0 0]; + + fitopts = optimset('Display', 'off', 'TolX', 1E-9); + [X,n,ij_res,flag] = lsqcurvefit(@radial_distortion_model, X0, ij_model, ij, [], [], fitopts); + ic0 = X(1); + jc0 = X(2); + kr0 = X(3:4); + + %% incorporate into preliminary model + model = struct('P', P, 'G', G, 'R', R, 'xc', xc, 'kr', kr0, 'ic', [ic0 jc0], 'diag', diag_px); + new_model = model; + + %% least squares fit + % we wish to incorporate radial distortion into the pinhole model + % this is non-linear and requires a least squares fit + % start fit + X0 = pack_model(model, opts); + fitopts = optimset('Display', 'off', 'TolX', 1E-9); + [X, ~, ij_res] = lsqcurvefit(@(X,uvw)fitfun(X,uvw,opts), X0, uvw, ij, [], [], fitopts); + new_model = unpack_model(X, opts); + + %% save markers in model + new_model.ij_markers = ij; + new_model.gl_markers = uvw; +end + +function ij_dist = radial_distortion_model(X, ij_undist) + % X(1) = ic + % X(2) = jc + % X(3) = k1 + % X(4) = k2 + iprime = ij_undist(1,:) - X(1); + jprime = ij_undist(2,:) - X(2); + rsq = iprime.^2 + jprime.^2; + ij_dist = [X(1) + iprime .* (1 + X(3)*rsq + X(4)*rsq.^2); + X(2) + jprime .* (1 + X(3)*rsq + X(4)*rsq.^2)]; +end + +function X = pack_model(model, opts) + %% extract intrinsic parameters from intrinsic parameter matrix + G = model.G; + G = G/G(3,3); + fx = G(1,1); + fy = G(2,2); + f = (fx+fy)/2; + tau = G(1,2); + ox = G(1,3); + oy = G(2,3); + diag = model.diag; + + %% pack extrinsic parameters + % these are non-optional + r_vec = vrrotmat2vec(model.R); + X = []; + X(1:3) = r_vec(1:3) * r_vec(4); % orientation + X(4:6) = model.xc(:)'; % pinhole position + + %% pack intrinsic parameters + % center + X(7) = ox / diag; % x center of image + X(8) = oy / diag; % y center of image + % magnification + if opts.square + X(end+1)= f; + else + X(end+1)= fx; + X(end+1)= fy; + end + % skew + if opts.skew + X(end+1) = tau; + end + % radial distortion + if opts.distortion + X(end+1)= model.ic(1) / diag; % x center of distortion + X(end+1)= model.ic(2) / diag; % y center of distortion + X(end+1)= model.kr(1) * diag^2; % first order distortion coefficient + X(end+1)= model.kr(2) * diag^4; % second order distortion coefficient + end +end + +function model = unpack_model(X, opts) + %% extrinsic parameters + r_vec = X(1:3); + R = vrrotvec2mat([r_vec(:)/(eps+norm(r_vec)); norm(r_vec)]); + xc = X(4:6)'; + + %% non-optional intrinsic parameters + diag_px = opts.diag; + ox = X(7) * diag_px; % x center of image + oy = X(8) * diag_px; % y center of image + + %% start consuming optional intrinsic parameters + % magnification + X = X(9:end); + if opts.square + fx = X(1); + fy = X(1); + X = X(2:end); + else + fx = X(1); + fy = X(2); + X = X(3:end); + end + % skew + tau = 0; + if opts.skew + tau = X(1); + X = X(2:end); + end + % radial distortion + ic = [0,0]; + kr = [0,0]; + if opts.distortion + ic = X(1:2) * diag_px; + kr = [X(3)/diag_px^2 X(4)/diag_px^4]; + end + + %% put in structure + G = [fx tau ox; + 0 fy oy; + 0 0 1]; + P = G*R*[eye(3), -xc(:)]; + + model = struct('P', P, 'G', G, 'R', R, 'xc', xc, ... + 'kr', kr, 'ic', ic, 'diag', diag_px); +end + +function ij = fitfun(X, uvw, opts) + model = unpack_model(X, opts); + ij = pinhole_model(uvw, model); +end + diff --git a/pinhole/pinhole_fit_constrained.m b/pinhole/pinhole_fit_constrained.m new file mode 100644 index 0000000000000000000000000000000000000000..58a1ec7285333ec34a419a9048cdc537764e2dd5 --- /dev/null +++ b/pinhole/pinhole_fit_constrained.m @@ -0,0 +1,53 @@ +function [new_cal, new_res, exit_flag] = pinhole_fit_constrained(old_cal, ij_pos, gl_pos, flags) + % new_cal = pinhole_fit_constrained(old_cal, ij_pos, gl_pos, flags) + % + % given a previous pinhole model, fit a new pinhole model to the data + % ij_pos and gl_pos, which are image and object space coordinates of + % points + % + % the new model will be constrained to be similar to the previous model + % in a manner specified by flags + % + % flags: + % b_move_camera allows camera position to be changed + % b_rotate_camera allows camera orientation to be changed + % + + %% apply least squares minimisation + X0 = empty_perturbation(flags); + opts = optimset('Display', 'off'); + model_fun = @(X, obj_pos) pinhole_model(obj_pos, perturb_model(old_cal, flags, X), false); + [X,~,new_res, exit_flag] = lsqcurvefit(model_fun, X0, gl_pos, ij_pos, [], [], opts); + new_cal = perturb_model(old_cal, flags, X); +end + +function X0 = empty_perturbation(flags) + n_vars = flags.b_move_camera*3 ... + + flags.b_rotate_camera * 3; + X0 = zeros(1, n_vars); +end + +function new_cal = perturb_model(old_cal, flags, X) + %% unpack perturbation + Y = X; + % unpack shift in pinhole position + d_xc = [0 0 0]'; + if flags.b_move_camera + d_xc = Y(1:3)'; + Y = Y(4:end); + end + + % unpack rotation + omega = [0 0 0]; + if flags.b_rotate_camera + omega = Y(1:3); + end + omega = [omega / (eps+norm(omega)), norm(omega)]; + Omega = vrrotvec2mat(omega); + + %% apply perturbation + new_cal = old_cal; + new_cal.xc = old_cal.xc + d_xc; + new_cal.R = old_cal.R * Omega; + new_cal.P = new_cal.G*new_cal.R*[eye(3), -new_cal.xc]; +end diff --git a/pinhole/pinhole_model.m b/pinhole/pinhole_model.m new file mode 100644 index 0000000000000000000000000000000000000000..0eabe67622980f3855ce2fa458083fc1fc7ba23b --- /dev/null +++ b/pinhole/pinhole_model.m @@ -0,0 +1,71 @@ +function [ij, jacobian] = pinhole_model(xyz, model, b_distort) + % ij = pinhole_model(xyz, model, b_distort) + % + % use pinhole model specified in struct model + % to map points in object space xyz + % onto points on image plane + % + % xyz is 3 x N + % ij is 2 x N + % + % default is to apply radial disortion, but this can be turned off + % by setting b_distort =false + + if nargin < 3 + b_distort = true; + end + + %% model parameters + P = model.P; + ic = model.ic(1); + jc = model.ic(2); + kr = model.kr; + + %% pinhole projection onto distorted coordinates + N = size(xyz, 2); + %lambda = P(3,1:3) * xyz + P(3,4); + lambda_recip= 1 ./ (P(3,1:3) * xyz + P(3,4)); + ij = [(P(1,1:3) * xyz + P(1,4)) .* lambda_recip; + (P(2,1:3) * xyz + P(2,4)) .* lambda_recip]; + %% memory management + clear xyz; + if nargout < 2 + clear lambda_recip; + end + + %% apply distortion + if b_distort + % undistort + rsq = (ij(1,:) - ic).^2 + (ij(2,:) - jc).^2; + rscale = (1 + kr(1)*rsq + kr(2)*rsq.^2); + %yprime = bsxfun(@minus, ij, [ic; jc]); + yprime = [ij(1,:)-ic; ij(2,:)-jc]; + ij(1,:) = ic + yprime(1,:).*rscale; + ij(2,:) = jc + yprime(2,:).*rscale; + end + + %% compute jacobian if requested + if nargout > 1 + % Jacobian in undistorted coordinates + Tjk = P(1:2, 1:3); + Lambda = P(3, 1:3); + % dyj/dxk = (Tjk - y_j*Lambda_k)/lambda + dyj_dxk = bsxfun(@minus, Tjk, bsxfun(@times, reshape(ij,[2 1 N]), Lambda)); + dyj_dxk = bsxfun(@times, dyj_dxk, reshape(lambda_recip,[1 1 N]) ); + + % correct Jacobian for distortion + if b_distort + yiyj_prime = bsxfun(@times, reshape(yprime, [2 1 N]), ... + reshape(yprime, [1 2 N])); + dypi_dyj = bsxfun(@times, yiyj_prime, reshape(rsq, [1 1 N])*2*kr(2) + kr(1)); + dypi_dyj(1,1,:)= dypi_dyj(1,1,:) + reshape(rscale, [1 1 N]); + dypi_dyj(2,2,:)= dypi_dyj(2,2,:) + reshape(rscale, [1 1 N]); + + %dypi_dyj = bsxfun(@times, eye(2), reshape(rscale, [1 1 N])) ... + % + bsxfun(@times, yiyj_prime, reshape(rsq, [1 1 N])*2*kr(2) + kr(1)); + jacobian = mmx('mult', dypi_dyj, dyj_dxk); + else + jacobian = dyj_dxk; + end + end +end diff --git a/pinhole/pinholemap_2d.m b/pinhole/pinholemap_2d.m new file mode 100644 index 0000000000000000000000000000000000000000..f1f313a75ddf5dbdfa67cab53ddb801f65173f4a --- /dev/null +++ b/pinhole/pinholemap_2d.m @@ -0,0 +1,19 @@ +function [i,j] = pinholemap_2d(u, v, P, kr, ic, jc) + if nargin < 4 + kr = [0 0]; + ic = 512; + jc = 512; + end + + S = size(u); + N = numel(u); + uv_tilde = [u(:) v(:) ones(N,1)]'; + ij_tilde = P * uv_tilde; + i = reshape(ij_tilde(1,:) ./ ij_tilde(3,:), S); + j = reshape(ij_tilde(2,:) ./ ij_tilde(3,:), S); + + % undistort + rsq = (i - ic).^2 + (j - jc).^2; + i = ic + (i - ic).*(1 + kr(1)*rsq + kr(2)*rsq.^2); + j = jc + (j - jc).*(1 + kr(1)*rsq + kr(2)*rsq.^2); +end \ No newline at end of file diff --git a/pinhole/plate_to_world.m b/pinhole/plate_to_world.m new file mode 100644 index 0000000000000000000000000000000000000000..be4fb304445b3d3cc91fb36deca4f340e1a90e28 --- /dev/null +++ b/pinhole/plate_to_world.m @@ -0,0 +1,28 @@ +function [gl_markers, ij_markers] = plate_to_world(camera, setup) + % given a camera setup and plate setup, + % calculate the location of calibration markers in world coordinates + + %% position and orientation of calibration plate + pl_to_gl_mat = setup.pl_to_gl_mat; + gl_plate_pos = setup.gl_plate_pos; + + %% load coordinates of markers from setup + % clear + ij_markers = []; + gl_markers = []; + n_views = setup.n_views; + + % iterate over views + for v = 1 : n_views + pl_to_gl = pl_to_gl_mat(:,:,v); + gl_pos = gl_plate_pos(:,v); + uv_mark = camera.view(v).uv_markers; + n_mark = size(uv_mark, 2); + gl_mark = bsxfun(@plus, gl_pos, pl_to_gl*[uv_mark; zeros(1,n_mark)]); + ij_mark = camera.view(v).ij_markers; + + %% append to vectors + gl_markers = [gl_markers, gl_mark]; + ij_markers = [ij_markers, ij_mark]; + end +end diff --git a/pinhole/radial_distortion.m b/pinhole/radial_distortion.m new file mode 100644 index 0000000000000000000000000000000000000000..57fec6034c167638e3cd266447aadb8d8ff581dd --- /dev/null +++ b/pinhole/radial_distortion.m @@ -0,0 +1,22 @@ +function ij = radial_distortion(ijstar, ic, kr) + % apply radial distortion, to map from + % (undistorted) pinhole image coordinates i* and j* + % (distorted) real world image coordinates i and j + % + % r^2 = (i* - i0)^2 + (j* - j0)^2 + % i = i0 + (i* - i0)*(1 + k1*r^2 + k2*r^4) + % j = j0 + (j* - j0)*(1 + k1*r^2 + k2*r^4) + + i0 = ic(1); + j0 = ic(2); + k1 = kr(1); + k2 = kr(2); + istar = ijstar(1,:); + jstar = ijstar(2,:); + + rsq = (istar - i0).^2 + (jstar - j0).^2; + i = i0 + (istar - i0).*(1 + k1*rsq + k2*rsq.^2); + j = j0 + (jstar - j0).*(1 + k1*rsq + k2*rsq.^2); + + ij = [i; j]; +end \ No newline at end of file diff --git a/pinhole/rq.m b/pinhole/rq.m new file mode 100644 index 0000000000000000000000000000000000000000..ef94ccfea5b9c7c2ee62e59c17ffde8ea7a1179f --- /dev/null +++ b/pinhole/rq.m @@ -0,0 +1,21 @@ +function [R Q]=rq(A) +% function [R Q]=rq(A) +% A [m x n] with m<=n +% return R [m x n] triangular and +% Q [n x n] unitary (i.e., Q'*Q=I) +% such that A=R*Q +% Author: Bruno Luong +% Last Update: 04/Oct/2008 + +[m n]=size(A); +if m>n + error('RQ: Number of rows must be smaller than column'); +end + +[Q R]=qr(flipud(A).'); +R=flipud(R.'); +R(:,1:m)=R(:,m:-1:1); +Q=Q.'; +Q(1:m,:)=Q(m:-1:1,:); + +end \ No newline at end of file diff --git a/pinhole/test_pinhole_camera_fit.m b/pinhole/test_pinhole_camera_fit.m new file mode 100644 index 0000000000000000000000000000000000000000..d8399f7063680bb379d319ed1ba519a98dbfa8cb --- /dev/null +++ b/pinhole/test_pinhole_camera_fit.m @@ -0,0 +1,56 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% test pinhole camera fit routine + +%% pinhole model to test +G = [7715.9132 8.9361442 -443.64006 + 0 -7774.5787 468.7479 + 0 0 1]; +r_vec = [-0.6550 0.0087 0.7555 3.1363]; +R = vrrotvec2mat(r_vec); +xc = [1098.6917 -14.767852 -20.153438]'; + +kr = [5E-8 -2E-15]; +ic = [512 512]; + +P = G*R*[eye(3), -xc(:)]; + +calib = struct('P', P, 'G', G, 'R', R, 'xc', xc, 'kr', kr, 'ic', ic); + +%% project points in object space +x_vec = -10 : 10 : 10; +y_vec = -60 : 10 : 60; +z_vec = -60 : 10 : 60; + +[xmat,ymat,zmat] = ndgrid(x_vec, y_vec, z_vec); +gl_mark = [xmat(:) ymat(:) zmat(:)]'; +ij_mark = pinhole_model(gl_mark, calib); + +%% apply fit +fprintf('fitting ... '); +[calib_fit, ij_res] = pinhole_fit_3d(ij_mark, gl_mark); +fprintf('done\n'); +%{ + +calib_fit=calib; +calib_fit.kr = [0 0]; +%} +ij_fit = pinhole_model(gl_mark, calib_fit); +ij_res = ij_mark - ij_fit; + +%% plot +figure(1); +clf; +subplot(1,2,1); +cla; +hold on; +plot( ij_mark(1,:), ij_mark(2,:), 'k.', ... + ij_fit(1,:), ij_fit(2,:), 'kx'); +quiver(ij_mark(1,:), ij_mark(2,:), ... + ij_res(1,:), ij_res(2,:), 'k-'); +axis equal tight xy; + +subplot(1,2,2); +cla; +plot3(gl_mark(1,:), gl_mark(2,:), gl_mark(3,:), 'r.'); +axis equal tight xy; +view(3); diff --git a/pinhole/traverse_error_fit.m b/pinhole/traverse_error_fit.m new file mode 100644 index 0000000000000000000000000000000000000000..6626f0cd5a44e31c22b4a63f0e6891ba8ed9e492 --- /dev/null +++ b/pinhole/traverse_error_fit.m @@ -0,0 +1,119 @@ +function [new_setup, ij_res] = traverse_error_fit(setup) + % try and model the error in traverse position + % and calibration plate orientation + % + % we are given the setup of the calibration plate and traverse + % and a model of the camera calibration + % + % we seek a small perturbation to the calibration plate's position and + % orientation, that helps explain the discrepancy between the pinhole + % camera model and observation + + %% extract basic information + n_cameras = setup.n_cameras; + n_views = setup.n_views; + + %% initialise perturbation model + setup.gl_plate_omega = zeros(3, n_views); + setup.gl_plate_dx = zeros(3, n_views); + + %% fill arrays for least squares fitting + % uv_data should be n_total x 4 array of [u, v, cam, view] + % ij_data should be n_total x 2 array of [i, j] position of markers + n_total = 0; + uv_data = []; + ij_data = []; + for c = 1 : n_cameras + camera = setup.camera(c); + for v = 1 : n_views + %% extract marker position in plate coord sys and image + % xdata contains (u,v) coord of marker on plate + % as well as the index of the plate position and camera + % that the projection of this marker in image space corresponds to + uv_mark = camera.view(v).uv_markers; + ij_mark = camera.view(v).ij_markers; + n_mark = size(uv_mark,2); + + uv_mark = [uv_mark; c*ones(1,n_mark); v*ones(1,n_mark)]; + uv_data = [uv_data; uv_mark']; + ij_data = [ij_data; ij_mark']; + n_total = n_total + n_mark; + end + end + + %% least squares fitting operation + X0 = pack_model(setup); + NX = length(X0); + opts = optimset('MaxFunEvals', NX*100, 'MaxIter', 400, 'Display', 'on'); + X = lsqcurvefit(@(X,xdata) bundle_model(X,xdata,setup),... + X0, uv_data, ij_data, [], [], opts); + new_setup = unpack_model(X, setup); +end + +function ij_mark = bundle_model(perturb_vec, uv_mark, setup) + % given a perturbation (packed into perturbation vector) + % project markers with perturbed model + setup = unpack_model(perturb_vec, setup); + + %% perturbed position and orientation of plate + gl_plate_pos = setup.gl_plate_pos + setup.gl_plate_dx; + %pl_to_gl = setup.omega * setup.pl_to_gl; + n_views = setup.n_views; + gl_plate_omega = setup.gl_plate_omega; + pl_to_gl_mat = zeros(3,3,n_views); + for v = 1 : n_views + omega_vec = gl_plate_omega(:,v); + Omega = vrrotvec2mat([omega_vec(:)/(norm(omega_vec)+eps); norm(omega_vec)]); + pl_to_gl_mat(:,:,v) = Omega * setup.pl_to_gl_mat(:,:,v); + end + + %% project markers + n_cameras = setup.n_cameras; + n_markers = size(uv_mark, 1); + cam = uv_mark(:, 3); + view = uv_mark(:, 4); + pl_mark = [uv_mark(:, 1:2), zeros(n_markers,1)]'; + pl_mark = reshape(pl_mark, [3 1 n_markers]); + gl_mark = squeeze(mtimesx(pl_to_gl_mat(:,:,view), pl_mark)) ... + + gl_plate_pos(:, view); + % gl_mark should be 3xn_markers matrix + + % project markers + ij_mark = zeros(n_markers, 2); + for c = 1 : n_cameras + this_cam = cam == c; + ij_mark(this_cam,:) = pinhole_model(gl_mark(:, this_cam), setup.camera(c).calib)'; + end +end + +function X = pack_model(setup) + % function to pack a representation of the internal + % camera and scene model into a vector for least squares optimisation + % routine + + %% plate perturbation model + % plate perturbation consists of a displacement and rotation + X_plate = setup.gl_plate_dx([1 2 3], :); +% omega_vec = vrrotmat2vec(setup.omega); + X_rot = setup.gl_plate_omega; + + X = [X_plate(:); X_rot(:)]'; +end + +function setup = unpack_model(X, setup) + % extract the perturbation model specified in X + % and update setup structure + n_views = setup.n_views; + + %% extract + off = 1; + X_plate = reshape(X(off : off-1 + n_views*3), [3 n_views]); + off = off + n_views*3; + X_rot = reshape(X(off : off-1 + n_views*3), [3 n_views]); + + %% update plate position parameters + %omega_vec = [X_rot(:)/(eps+norm(X_rot)); norm(X_rot)]; + %setup.omega = vrrotvec2mat(omega_vec); + setup.gl_plate_omega = X_rot; + setup.gl_plate_dx = X_plate;%[X_plate(1,:); zeros(1,n_views); X_plate(2,:)]; +end diff --git a/pinhole/triangulate.m b/pinhole/triangulate.m new file mode 100644 index 0000000000000000000000000000000000000000..a5473edea96c69697ceffcd02128e6054fd0a570 --- /dev/null +++ b/pinhole/triangulate.m @@ -0,0 +1,113 @@ +function [gl_pos, gl_dist, ij_dist] = triangulate(camera, ij_pos, b_dewarp) + % [gl_pos, gl_dist, ij_dist] = triangulate(camera, ij_pos) + % + % triangulate the location of points in object space + % given their projections in image space in N cameras + % + % input: + % camera structure containing calibration information + % for each of N cameras + % ij_pos 2 x M x N array of positions of points in the image + % space of each of N cameras + % b_dewarp flag; if true, apply dewarping + % + % output: + % gl_pos 3 x M array of positions of points in object space + % which minimises the sum of squared distances of + % each point p to its back projection along line l + % gl_dist M x N array of distances between points and the + % back-projected rays from each camera + % ij_dist M x N array of distances between points and their + % projection on each camera + % + % + % for more details, see: + % Mann 1999: Experimental Study of Relative, Turbulent Diffusion + % pages 26-27 + + %% sanity checking + n_cameras = length(camera); + n_points = size(ij_pos, 2); + if n_points < 1 + gl_pos = zeros(3, 0, n_cameras); + gl_dist = zeros(0, n_cameras); + ij_dist = zeros(0, n_cameras); + return; + end + + if size(ij_pos, 3) ~= n_cameras + error('size(ij_pos,3) must match number of cameras'); + end + if size(ij_pos, 1) ~= 2 + error('size(ij_pos,1) must be 2'); + end + if nargin < 3 + b_dewarp = false; + end + + %% undo radial distortion + ij_dewarped = ij_pos; + if b_dewarp + for c = 1 : n_cameras + ic = camera(c).calib.ic; + kr = camera(c).calib.kr; + ij_dewarped(:,:,c)= inverse_radial_distortion(ij_pos(:,:,c), ic, kr); + end + end + + %% calculate ray vectors + % these are unit vectors which correspond to the direction of rays + % back-projected from the location of each point on each camera + b_mat = zeros(3, n_points, n_cameras); + xc_mat = zeros(3, 1, 1, n_cameras); + for c = 1 : n_cameras + % unit vector + G = camera(c).calib.G; + R = camera(c).calib.R; + GR = G*R; + b = GR \ [ij_dewarped(:,:,c); ones(1,n_points)]; + b_norm = sqrt(sum(b.^2, 1)); + b_mat(:,:,c) = bsxfun(@rdivide, b, b_norm); + xc_mat(:,1,1,c) = camera(c).calib.xc; + end + xc_mat = repmat(xc_mat, [1 1 n_points 1]); + + %% find projection tensor + % Pb_{ij} = d_{ij} - b_i b_j + b_outer = bsxfun(@times, reshape(b_mat, [3 1 n_points n_cameras]), ... + reshape(b_mat, [1 3 n_points n_cameras])); + Pb_mat = bsxfun(@minus, eye(3), b_outer); + Pb_sum = sum(Pb_mat, 4); + + %% project origin + Pb_x0_mat = mmx('mult', Pb_mat, xc_mat); + Pb_x0_sum = sum(Pb_x0_mat, 4); + + %% solve for 3D position + gl_pos = mmx('backslash', Pb_sum, Pb_x0_sum); + gl_pos = squeeze(gl_pos); + + %% calculate ray-point distance in object space + if nargout > 1 + gl_dist = zeros(n_points, n_cameras); + for c = 1 : n_cameras + gl_pos_rel = gl_pos - camera(c).calib.xc; % position of particle relative to camera + ray_component = sum(b_mat(:,:,c) .* gl_pos_rel, 1); % measure component along ray + ray_component = bsxfun(@times, ray_component, b_mat(:,:,c)); % project component along ray + residual = gl_pos_rel - ray_component; % measure residual + gl_dist(:,c) = sqrt(sum(residual.^2,1))'; % this gives distance + end + end + + %% calculate distance to projection in image space + if nargout > 2 + % project + ij_proj = zeros(2, n_points, n_cameras); + for c = 1 : n_cameras + ij_proj(:,:,c) = pinhole_model(gl_pos, camera(c).calib, b_dewarp); + end + % calculate residual + ij_res = ij_proj - ij_pos; + ij_dist = reshape(sqrt(sum(ij_res.^2, 1)), [n_points n_cameras]); + end +end \ No newline at end of file diff --git a/pinhole/triangulate3.m b/pinhole/triangulate3.m new file mode 100644 index 0000000000000000000000000000000000000000..3f5c2f01e9af949b00bfd084ea6e1e9915804b47 --- /dev/null +++ b/pinhole/triangulate3.m @@ -0,0 +1,54 @@ +function [gl_pos, gl_dist, ij_dist] = triangulate(camera, ij_pos) + % [gl_pos, gl_dist, ij_dist] = triangulate(cae + % + % given pairs of points yA and yB in image coordinates + % on cameras A and B, triangulate the position of these particles + % by minimising the least-squares distance in object space + % between the particle and the back-projected rays from either camera + % + % inputs: + % camA calibration struct for camera A + % camB calibration struct for camera B + % yA 2xN array of position in A, undistorted image coords + % yB 2xN array of position in B, undistorted image coords + % + % output: + % gl_pos 3xN array of position in object space that is the best fit + % to the true particle position, given its two projections + % gl_dist 2xN array of distance in object space between particle + % and either ray + % ij_dist 2xN array of distance in image space between particle + % and its projection + + + %% calculate ray vectors + % these are unit vectors which correspond to the direction of rays + % back-projected from the location of each point on each camera + b_mat = zeros(3, n_points, n_cameras); + xc_mat = zeros(3, 1, 1, n_cameras); + for c = 1 : n_cameras + % unit vector + G = camera(c).calib.G; + R = camera(c).calib.R; + GR = G*R; + b = GR \ [ij_dewarped(:,:,c); ones(1,n_points)]; + b_norm = sqrt(sum(b.^2, 1)); + b_mat(:,:,c) = bsxfun(@rdivide, b, b_norm); + xc_mat(:,1,1,c) = camera(c).calib.xc; + end + xc_mat = repmat(xc_mat, [1 1 n_points 1]); + + %% find projection tensor + % Pb_{ij} = d_{ij} - b_i b_j + b_outer = bsxfun(@times, reshape(b_mat, [3 1 n_points n_cameras]), ... + reshape(b_mat, [1 3 n_points n_cameras])); + Pb_mat = bsxfun(@minus, eye(3), b_outer); + Pb_sum = sum(Pb_mat, 4); + + %% project origin + Pb_x0_mat = mmx('mult', Pb_mat, xc_mat); + Pb_x0_sum = sum(Pb_x0_mat, 4); + %% solve for 3D position + gl_pos = mmx('backslash', Pb_sum, Pb_x0_sum); + gl_pos = squeeze(gl_pos); +end