plateform
stringclasses
1 value
repo_name
stringlengths
13
113
name
stringlengths
3
74
ext
stringclasses
1 value
path
stringlengths
12
229
size
int64
23
843k
source_encoding
stringclasses
9 values
md5
stringlengths
32
32
text
stringlengths
23
843k
github
zhuhan1236/dhn-caffe-master
matcaffe_demo_vgg_mean_pix.m
.m
dhn-caffe-master/matlab/caffe/matcaffe_demo_vgg_mean_pix.m
3,069
utf_8
04b831d0f205ef0932c4f3cfa930d6f9
function scores = matcaffe_demo_vgg_mean_pix(im, use_gpu, model_def_file, model_file) % scores = matcaffe_demo_vgg(im, use_gpu, model_def_file, model_file) % % Demo of the matlab wrapper based on the networks used for the "VGG" entry % in the ILSVRC-2014 competition and described in the tech. report % "Very Deep Convolutional Networks for Large-Scale Image Recognition" % http://arxiv.org/abs/1409.1556/ % % INPUT % im - color image as uint8 HxWx3 % use_gpu - 1 to use the GPU, 0 to use the CPU % model_def_file - network configuration (.prototxt file) % model_file - network weights (.caffemodel file) % % OUTPUT % scores 1000-dimensional ILSVRC score vector % % EXAMPLE USAGE % model_def_file = 'zoo/deploy.prototxt'; % model_file = 'zoo/model.caffemodel'; % use_gpu = true; % im = imread('../../examples/images/cat.jpg'); % scores = matcaffe_demo_vgg(im, use_gpu, model_def_file, model_file); % % NOTES % mean pixel subtraction is used instead of the mean image subtraction % % PREREQUISITES % You may need to do the following before you start matlab: % $ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:/usr/local/cuda/lib64 % $ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 % Or the equivalent based on where things are installed on your system % init caffe network (spews logging info) matcaffe_init(use_gpu, model_def_file, model_file); % mean BGR pixel mean_pix = [103.939, 116.779, 123.68]; % prepare oversampled input % input_data is Height x Width x Channel x Num tic; input_data = {prepare_image(im, mean_pix)}; toc; % do forward pass to get scores % scores are now Width x Height x Channels x Num tic; scores = caffe('forward', input_data); toc; scores = scores{1}; % size(scores) scores = squeeze(scores); % scores = mean(scores,2); % [~,maxlabel] = max(scores); % ------------------------------------------------------------------------ function images = prepare_image(im, mean_pix) % ------------------------------------------------------------------------ IMAGE_DIM = 256; CROPPED_DIM = 224; % resize to fixed input size im = single(im); if size(im, 1) < size(im, 2) im = imresize(im, [IMAGE_DIM NaN]); else im = imresize(im, [NaN IMAGE_DIM]); end % RGB -> BGR im = im(:, :, [3 2 1]); % oversample (4 corners, center, and their x-axis flips) images = zeros(CROPPED_DIM, CROPPED_DIM, 3, 10, 'single'); indices_y = [0 size(im,1)-CROPPED_DIM] + 1; indices_x = [0 size(im,2)-CROPPED_DIM] + 1; center_y = floor(indices_y(2) / 2)+1; center_x = floor(indices_x(2) / 2)+1; curr = 1; for i = indices_y for j = indices_x images(:, :, :, curr) = ... permute(im(i:i+CROPPED_DIM-1, j:j+CROPPED_DIM-1, :), [2 1 3]); images(:, :, :, curr+5) = images(end:-1:1, :, :, curr); curr = curr + 1; end end images(:,:,:,5) = ... permute(im(center_y:center_y+CROPPED_DIM-1,center_x:center_x+CROPPED_DIM-1,:), ... [2 1 3]); images(:,:,:,10) = images(end:-1:1, :, :, curr); % mean BGR pixel subtraction for c = 1:3 images(:, :, c, :) = images(:, :, c, :) - mean_pix(c); end
github
willamowius/openmcu-master
echo_diagnostic.m
.m
openmcu-master/libs/speex/libspeex/echo_diagnostic.m
2,076
utf_8
8d5e7563976fbd9bd2eda26711f7d8dc
% Attempts to diagnose AEC problems from recorded samples % % out = echo_diagnostic(rec_file, play_file, out_file, tail_length) % % Computes the full matrix inversion to cancel echo from the % recording 'rec_file' using the far end signal 'play_file' using % a filter length of 'tail_length'. The output is saved to 'out_file'. function out = echo_diagnostic(rec_file, play_file, out_file, tail_length) F=fopen(rec_file,'rb'); rec=fread(F,Inf,'short'); fclose (F); F=fopen(play_file,'rb'); play=fread(F,Inf,'short'); fclose (F); rec = [rec; zeros(1024,1)]; play = [play; zeros(1024,1)]; N = length(rec); corr = real(ifft(fft(rec).*conj(fft(play)))); acorr = real(ifft(fft(play).*conj(fft(play)))); [a,b] = max(corr); if b > N/2 b = b-N; end printf ("Far end to near end delay is %d samples\n", b); if (b > .3*tail_length) printf ('This is too much delay, try delaying the far-end signal a bit\n'); else if (b < 0) printf ('You have a negative delay, the echo canceller has no chance to cancel anything!\n'); else printf ('Delay looks OK.\n'); end end end N2 = round(N/2); corr1 = real(ifft(fft(rec(1:N2)).*conj(fft(play(1:N2))))); corr2 = real(ifft(fft(rec(N2+1:end)).*conj(fft(play(N2+1:end))))); [a,b1] = max(corr1); if b1 > N2/2 b1 = b1-N2; end [a,b2] = max(corr2); if b2 > N2/2 b2 = b2-N2; end drift = (b1-b2)/N2; printf ('Drift estimate is %f%% (%d samples)\n', 100*drift, b1-b2); if abs(b1-b2) < 10 printf ('A drift of a few (+-10) samples is normal.\n'); else if abs(b1-b2) < 30 printf ('There may be (not sure) excessive clock drift. Is the capture and playback done on the same soundcard?\n'); else printf ('Your clock is drifting! No way the AEC will be able to do anything with that. Most likely, you''re doing capture and playback from two different cards.\n'); end end end acorr(1) = .001+1.00001*acorr(1); AtA = toeplitz(acorr(1:tail_length)); bb = corr(1:tail_length); h = AtA\bb; out = (rec - filter(h, 1, play)); F=fopen(out_file,'w'); fwrite(F,out,'short'); fclose (F);
github
themattinthehatt/rlvm-master
myProcessOptions.m
.m
rlvm-master/lib/minConf/myProcessOptions.m
674
utf_8
b94d252a960faa95a3074129247619e6
function [varargout] = myProcessOptions(options,varargin) % Similar to processOptions, but case insensitive and % using a struct instead of a variable length list options = toUpper(options); for i = 1:2:length(varargin) if isfield(options,upper(varargin{i})) v = getfield(options,upper(varargin{i})); if isempty(v) varargout{(i+1)/2}=varargin{i+1}; else varargout{(i+1)/2}=v; end else varargout{(i+1)/2}=varargin{i+1}; end end end function [o] = toUpper(o) if ~isempty(o) fn = fieldnames(o); for i = 1:length(fn) o = setfield(o,upper(fn{i}),getfield(o,fn{i})); end end end
github
themattinthehatt/rlvm-master
minConf_PQN.m
.m
rlvm-master/lib/minConf/minConf_PQN.m
8,246
utf_8
982955326f59fecc4cf6993c3b7428aa
function [x,f,funEvals] = minConf_PQN(funObj,x,funProj,options) % function [x,f] = minConf_PQN(funObj,funProj,x,options) % % Function for using a limited-memory projected quasi-Newton to solve problems of the form % min funObj(x) s.t. x in C % % The projected quasi-Newton sub-problems are solved the spectral projected % gradient algorithm % % @funObj(x): function to minimize (returns gradient as second argument) % @funProj(x): function that returns projection of x onto C % % options: % verbose: level of verbosity (0: no output, 1: final, 2: iter (default), 3: % debug) % optTol: tolerance used to check for optimality (default: 1e-5) % progTol: tolerance used to check for progress (default: 1e-9) % maxIter: maximum number of calls to funObj (default: 500) % maxProject: maximum number of calls to funProj (default: 100000) % numDiff: compute derivatives numerically (0: use user-supplied % derivatives (default), 1: use finite differences, 2: use complex % differentials) % suffDec: sufficient decrease parameter in Armijo condition (default: 1e-4) % corrections: number of lbfgs corrections to store (default: 10) % adjustStep: use quadratic initialization of line search (default: 0) % bbInit: initialize sub-problem with Barzilai-Borwein step (default: 1) % SPGoptTol: optimality tolerance for SPG direction finding (default: 1e-6) % SPGiters: maximum number of iterations for SPG direction finding (default:10) nVars = length(x); % Set Parameters if nargin < 4 options = []; end [verbose,numDiff,optTol,progTol,maxIter,maxProject,suffDec,corrections,adjustStep,... SPGoptTol,SPGprogTol,SPGiters,SPGtestOpt] = ... myProcessOptions(... options,'verbose',2,'numDiff',0,'optTol',1e-5,'progTol',1e-9,'maxIter',500,'maxProject',100000,'suffDec',1e-4,... 'corrections',10,'adjustStep',0,'SPGoptTol',1e-6,'SPGprogTol',1e-10,'SPGiters',10,'SPGtestOpt',0); % Output Parameter Settings if verbose >= 3 fprintf('Running PQN...\n'); fprintf('Number of L-BFGS Corrections to store: %d\n',corrections); fprintf('Maximum number of SPG iterations: %d\n',SPGiters); fprintf('SPG optimality tolerance: %.2e\n',SPGoptTol); fprintf('SPG progress tolerance: %.2e\n',SPGprogTol); fprintf('PQN optimality tolerance: %.2e\n',optTol); fprintf('PQN progress tolerance: %.2e\n',progTol); fprintf('Quadratic initialization of line search: %d\n',adjustStep); fprintf('Maximum number of function evaluations: %d\n',maxIter); fprintf('Maximum number of projections: %d\n',maxProject); end % Output Log if verbose >= 2 fprintf('%10s %10s %10s %15s %15s %15s\n','Iteration','FunEvals','Projections','Step Length','Function Val','Opt Cond'); end % Make objective function (if using numerical derivatives) funEvalMultiplier = 1; if numDiff if numDiff == 2 useComplex = 1; else useComplex = 0; end funObj = @(x)autoGrad(x,useComplex,funObj); funEvalMultiplier = nVars+1-useComplex; end % Project initial parameter vector x = funProj(x); projects = 1; % Evaluate initial parameters [f,g] = funObj(x); funEvals = 1; % Check Optimality of Initial Point projects = projects+1; if max(abs(funProj(x-g)-x)) < optTol if verbose >= 1 fprintf('First-Order Optimality Conditions Below optTol at Initial Point\n'); end return; end i = 1; while funEvals <= maxIter % Compute Step Direction if i == 1 p = funProj(x-g); projects = projects+1; S = zeros(nVars,0); Y = zeros(nVars,0); Hdiag = 1; else y = g-g_old; s = x-x_old; [S,Y,Hdiag] = lbfgsUpdate(y,s,corrections,verbose==3,S,Y,Hdiag); % Make Compact Representation k = size(Y,2); L = zeros(k); for j = 1:k L(j+1:k,j) = S(:,j+1:k)'*Y(:,j); end N = [S/Hdiag Y]; M = [S'*S/Hdiag L;L' -diag(diag(S'*Y))]; HvFunc = @(v)lbfgsHvFunc2(v,Hdiag,N,M); % Solve Sub-problem [p,subProjects] = solveSubProblem(x,g,HvFunc,funProj,SPGoptTol,SPGprogTol,SPGiters,SPGtestOpt); projects = projects+subProjects; end d = p-x; g_old = g; x_old = x; % Check that Progress can be made along the direction gtd = g'*d; if gtd > -progTol if verbose >= 1 fprintf('Directional Derivative below progTol\n'); end break; end % Select Initial Guess to step length if i == 1 || adjustStep == 0 t = 1; else t = min(1,2*(f-f_old)/gtd); end % Bound Step length on first iteration if i == 1 t = min(1,1/sum(abs(g))); end % Evaluate the Objective and Gradient at the Initial Step if t == 1 x_new = p; else x_new = x + t*d; end [f_new,g_new] = funObj(x_new); funEvals = funEvals+1; % Backtracking Line Search f_old = f; while f_new > f + suffDec*g'*(x_new-x) || ~isLegal(f_new) temp = t; % Backtrack to next trial value if ~isLegal(f_new) || ~isLegal(g_new) if verbose == 3 fprintf('Halving Step Size\n'); end t = t/2; else if verbose == 3 fprintf('Cubic Backtracking\n'); end t = polyinterp([0 f gtd; t f_new g_new'*d]); end % Adjust if change is too small/large if t < temp*1e-3 if verbose == 3 fprintf('Interpolated value too small, Adjusting\n'); end t = temp*1e-3; elseif t > temp*0.6 if verbose == 3 fprintf('Interpolated value too large, Adjusting\n'); end t = temp*0.6; end % Check whether step has become too small if max(abs(t*d)) < progTol || t == 0 if verbose == 3 fprintf('Line Search failed\n'); end t = 0; f_new = f; g_new = g; break; end % Evaluate New Point f_prev = f_new; t_prev = temp; x_new = x + t*d; [f_new,g_new] = funObj(x_new); funEvals = funEvals+1; end % Take Step x = x_new; f = f_new; g = g_new; optCond = max(abs(funProj(x-g)-x)); projects = projects+1; % Output Log if verbose >= 2 fprintf('%10d %10d %10d %15.5e %15.5e %15.5e\n',i,funEvals*funEvalMultiplier,projects,t,f,optCond); end % Check optimality if optCond < optTol if verbose >= 1 fprintf('First-Order Optimality Conditions Below optTol\n'); end break; end if max(abs(t*d)) < progTol if verbose >= 1 fprintf('Step size below progTol\n'); end break; end if abs(f-f_old) < progTol if verbose >= 1 fprintf('Function value changing by less than progTol\n'); end break; end if funEvals*funEvalMultiplier > maxIter if verbose >= 1 fprintf('Function Evaluations exceeds maxIter\n'); end break; end if projects > maxProject if verbose >= 1 fprintf('Number of projections exceeds maxProject\n'); end break; end i = i + 1; % pause end end function [p,subProjects] = solveSubProblem(x,g,H,funProj,optTol,progTol,maxIter,testOpt) % Uses SPG to solve for projected quasi-Newton direction options.verbose = 0; options.optTol = optTol; options.progTol = progTol; options.maxIter = maxIter; options.testOpt = testOpt; options.feasibleInit = 1; funObj = @(p)subHv(p,x,g,H); [p,f,funEvals,subProjects] = minConf_SPG(funObj,x,funProj,options); end function [f,g] = subHv(p,x,g,HvFunc) d = p-x; Hd = HvFunc(d); f = g'*d + (1/2)*d'*Hd; g = g + Hd; end
github
themattinthehatt/rlvm-master
minConf_QNST.m
.m
rlvm-master/lib/minConf/minConf_QNST.m
5,460
utf_8
d3af055fa412ac52b199c8238fc83783
function [x,f,funEvals] = minConf_QNST(funObj1,funObj2,x,funProj,options) nVars = length(x); if nargin < 5 options = []; end [verbose,numDiff,optTol,progTol,maxIter,maxProject,suffDec,corrections,adjustStep,bbInit,... BBSToptTol,BBSTprogTol,BBSTiters,BBSTtestOpt] = ... myProcessOptions(... options,'verbose',2,'numDiff',0,'optTol',1e-5,'progTol',1e-9,'maxIter',500,'maxProject',100000,'suffDec',1e-4,... 'corrections',10,'adjustStep',0,'bbInit',0,'BBSToptTol',1e-6,'BBSTprogTol',1e-10,'BBSTiters',10,'BBSTtestOpt',0); % Output Parameter Settings if verbose >= 3 fprintf('Running QNST...\n'); fprintf('Number of L-BFGS Corrections to store: %d\n',corrections); fprintf('Spectral initialization of BBST: %d\n',bbInit); fprintf('Maximum number of BBST iterations: %d\n',BBSTiters); fprintf('BBST optimality tolerance: %.2e\n',BBSToptTol); fprintf('BBST progress tolerance: %.2e\n',BBSTprogTol); fprintf('PQN optimality tolerance: %.2e\n',optTol); fprintf('PQN progress tolerance: %.2e\n',progTol); fprintf('Quadratic initialization of line search: %d\n',adjustStep); fprintf('Maximum number of function evaluations: %d\n',maxIter); fprintf('Maximum number of projections: %d\n',maxProject); end if verbose fprintf('%10s %10s %10s %15s %15s\n','Iteration','FunEvals','Projections','Step Length','Function Val'); end % Evaluate Initial Objective [f1,g] = funObj1(x); f = f1+funObj2(x); funEvals = 1; projects = 0; % Check optimality optCond = max(abs(x-funProj(x-g,1))); projects = 1; if optCond < optTol if verbose >= 1 fprintf('First-Order Optimality Conditions Below optTol at Initial Point\n'); end return; end i = 1; while 1 if 0 % BBST if i == 1 alpha = 1; else y = g-g_old; s = x-x_old; alpha = (s'*s)/(s'*y); if alpha <= 1e-10 || alpha > 1e10 alpha = min(1,1/sum(abs(g))); end end p = funProj(x-alpha*g,alpha); projects = projects+1; else % QNST if i == 1 p = funProj(x-g,1); projects = projects+1; S = zeros(nVars,0); Y = zeros(nVars,0); Hdiag = 1; else y = g-g_old; s = x-x_old; [S,Y,Hdiag] = lbfgsUpdate(y,s,corrections,verbose==3,S,Y,Hdiag); % Make Compact Representation k = size(Y,2); L = zeros(k); for j = 1:k L(j+1:k,j) = S(:,j+1:k)'*Y(:,j); end N = [S/Hdiag Y]; M = [S'*S/Hdiag L;L' -diag(diag(S'*Y))]; HvFunc = @(v)lbfgsHvFunc2(v,Hdiag,N,M); if bbInit % Use Barzilai-Borwein step to initialize sub-problem alpha = (s'*s)/(s'*y); if alpha <= 1e-10 || alpha > 1e10 alpha = 1/norm(g); end % Solve Sub-problem xSubInit = funProj(x-alpha*g,alpha); projects = projects+1; else xSubInit = x; end % Solve Sub-problem [p,subProjects] = solveSubProblem(x,g,HvFunc,funObj2,funProj,BBSToptTol,BBSTprogTol,BBSTiters,BBSTtestOpt,xSubInit); projects = projects+subProjects; end end d = p-x; g_old = g; x_old = x; % Bound Step length on first iteration t = 1; if i == 1 t = min(1,1/sum(abs(g))); end if t == 1 x_new = p; else x_new = x+t*d; end [f1_new,g_new] = funObj1(x_new); f_new = f1_new + funObj2(x_new); funEvals = funEvals+1; f_old = f; while f_new > f if verbose fprintf('Backtracking\n'); end t = t/2; x_new = x+t*d; [f1_new,g_new] = funObj1(x_new); f_new = f1_new + funObj2(x_new); funEvals = funEvals+1; end x = x_new; f = f_new; g = g_new; % Check Optimality optCond = max(abs(x-funProj(x-g,1))); projects = projects+1; if verbose fprintf('%10d %10d %10d %15.5e %15.5e %15.5e\n',i,funEvals,projects,t,f,optCond); end if optCond < optTol if verbose fprintf('First-order optimality below optTol\n'); end break; end if max(abs(x-x_old)) < progTol if verbose >= 1 fprintf('Step size below progTol\n'); end break; end if abs(f-f_old) < progTol if verbose >= 1 fprintf('Function value changing by less than progTol\n'); end break; end if funEvals > maxIter if verbose fprintf('Exceeded maxIter funEvals\n'); end break end i = i + 1; end end function [p,subProjects] = solveSubProblem(x,g,H,funObj2,funProj,optTol,progTol,maxIter,testOpt,x_init) % Uses BBST to solve for quasi-Newton soft-threshold direction options.verbose = 0; options.optTol = optTol; options.progTol = progTol; options.maxIter = maxIter; options.testOpt = testOpt; funObj = @(p)subHv(p,x,g,H); [p,f,funEvals,subProjects] = minConf_BBST(funObj,funObj2,x_init,funProj,options); end function [f,g] = subHv(p,x,g,HvFunc) d = p-x; Hd = HvFunc(d); f = g'*d + (1/2)*d'*Hd; g = g + Hd; end
github
themattinthehatt/rlvm-master
WolfeLineSearch.m
.m
rlvm-master/lib/minFunc_2012/minFunc/WolfeLineSearch.m
10,590
utf_8
f962bc5ae0a1e9f80202a9aaab106dab
function [t,f_new,g_new,funEvals,H] = WolfeLineSearch(... x,t,d,f,g,gtd,c1,c2,LS_interp,LS_multi,maxLS,progTol,debug,doPlot,saveHessianComp,funObj,varargin) % % Bracketing Line Search to Satisfy Wolfe Conditions % % Inputs: % x: starting location % t: initial step size % d: descent direction % f: function value at starting location % g: gradient at starting location % gtd: directional derivative at starting location % c1: sufficient decrease parameter % c2: curvature parameter % debug: display debugging information % LS_interp: type of interpolation % maxLS: maximum number of iterations % progTol: minimum allowable step length % doPlot: do a graphical display of interpolation % funObj: objective function % varargin: parameters of objective function % % Outputs: % t: step length % f_new: function value at x+t*d % g_new: gradient value at x+t*d % funEvals: number function evaluations performed by line search % H: Hessian at initial guess (only computed if requested % Evaluate the Objective and Gradient at the Initial Step if nargout == 5 [f_new,g_new,H] = funObj(x + t*d,varargin{:}); else [f_new,g_new] = funObj(x+t*d,varargin{:}); end funEvals = 1; gtd_new = g_new'*d; % Bracket an Interval containing a point satisfying the % Wolfe criteria LSiter = 0; t_prev = 0; f_prev = f; g_prev = g; gtd_prev = gtd; nrmD = max(abs(d)); done = 0; while LSiter < maxLS %% Bracketing Phase if ~isLegal(f_new) || ~isLegal(g_new) if debug fprintf('Extrapolated into illegal region, switching to Armijo line-search\n'); end t = (t + t_prev)/2; % Do Armijo if nargout == 5 [t,x_new,f_new,g_new,armijoFunEvals,H] = ArmijoBacktrack(... x,t,d,f,f,g,gtd,c1,LS_interp,LS_multi,progTol,debug,doPlot,saveHessianComp,... funObj,varargin{:}); else [t,x_new,f_new,g_new,armijoFunEvals] = ArmijoBacktrack(... x,t,d,f,f,g,gtd,c1,LS_interp,LS_multi,progTol,debug,doPlot,saveHessianComp,... funObj,varargin{:}); end funEvals = funEvals + armijoFunEvals; return; end if f_new > f + c1*t*gtd || (LSiter > 1 && f_new >= f_prev) bracket = [t_prev t]; bracketFval = [f_prev f_new]; bracketGval = [g_prev g_new]; break; elseif abs(gtd_new) <= -c2*gtd bracket = t; bracketFval = f_new; bracketGval = g_new; done = 1; break; elseif gtd_new >= 0 bracket = [t_prev t]; bracketFval = [f_prev f_new]; bracketGval = [g_prev g_new]; break; end temp = t_prev; t_prev = t; minStep = t + 0.01*(t-temp); maxStep = t*10; if LS_interp <= 1 if debug fprintf('Extending Braket\n'); end t = maxStep; elseif LS_interp == 2 if debug fprintf('Cubic Extrapolation\n'); end t = polyinterp([temp f_prev gtd_prev; t f_new gtd_new],doPlot,minStep,maxStep); elseif LS_interp == 3 t = mixedExtrap(temp,f_prev,gtd_prev,t,f_new,gtd_new,minStep,maxStep,debug,doPlot); end f_prev = f_new; g_prev = g_new; gtd_prev = gtd_new; if ~saveHessianComp && nargout == 5 [f_new,g_new,H] = funObj(x + t*d,varargin{:}); else [f_new,g_new] = funObj(x + t*d,varargin{:}); end funEvals = funEvals + 1; gtd_new = g_new'*d; LSiter = LSiter+1; end if LSiter == maxLS bracket = [0 t]; bracketFval = [f f_new]; bracketGval = [g g_new]; end %% Zoom Phase % We now either have a point satisfying the criteria, or a bracket % surrounding a point satisfying the criteria % Refine the bracket until we find a point satisfying the criteria insufProgress = 0; Tpos = 2; LOposRemoved = 0; while ~done && LSiter < maxLS % Find High and Low Points in bracket [f_LO LOpos] = min(bracketFval); HIpos = -LOpos + 3; % Compute new trial value if LS_interp <= 1 || ~isLegal(bracketFval) || ~isLegal(bracketGval) if debug fprintf('Bisecting\n'); end t = mean(bracket); elseif LS_interp == 2 if debug fprintf('Grad-Cubic Interpolation\n'); end t = polyinterp([bracket(1) bracketFval(1) bracketGval(:,1)'*d bracket(2) bracketFval(2) bracketGval(:,2)'*d],doPlot); else % Mixed Case %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nonTpos = -Tpos+3; if LOposRemoved == 0 oldLOval = bracket(nonTpos); oldLOFval = bracketFval(nonTpos); oldLOGval = bracketGval(:,nonTpos); end t = mixedInterp(bracket,bracketFval,bracketGval,d,Tpos,oldLOval,oldLOFval,oldLOGval,debug,doPlot); end % Test that we are making sufficient progress if min(max(bracket)-t,t-min(bracket))/(max(bracket)-min(bracket)) < 0.1 if debug fprintf('Interpolation close to boundary'); end if insufProgress || t>=max(bracket) || t <= min(bracket) if debug fprintf(', Evaluating at 0.1 away from boundary\n'); end if abs(t-max(bracket)) < abs(t-min(bracket)) t = max(bracket)-0.1*(max(bracket)-min(bracket)); else t = min(bracket)+0.1*(max(bracket)-min(bracket)); end insufProgress = 0; else if debug fprintf('\n'); end insufProgress = 1; end else insufProgress = 0; end % Evaluate new point if ~saveHessianComp && nargout == 5 [f_new,g_new,H] = funObj(x + t*d,varargin{:}); else [f_new,g_new] = funObj(x + t*d,varargin{:}); end funEvals = funEvals + 1; gtd_new = g_new'*d; LSiter = LSiter+1; armijo = f_new < f + c1*t*gtd; if ~armijo || f_new >= f_LO % Armijo condition not satisfied or not lower than lowest % point bracket(HIpos) = t; bracketFval(HIpos) = f_new; bracketGval(:,HIpos) = g_new; Tpos = HIpos; else if abs(gtd_new) <= - c2*gtd % Wolfe conditions satisfied done = 1; elseif gtd_new*(bracket(HIpos)-bracket(LOpos)) >= 0 % Old HI becomes new LO bracket(HIpos) = bracket(LOpos); bracketFval(HIpos) = bracketFval(LOpos); bracketGval(:,HIpos) = bracketGval(:,LOpos); if LS_interp == 3 if debug fprintf('LO Pos is being removed!\n'); end LOposRemoved = 1; oldLOval = bracket(LOpos); oldLOFval = bracketFval(LOpos); oldLOGval = bracketGval(:,LOpos); end end % New point becomes new LO bracket(LOpos) = t; bracketFval(LOpos) = f_new; bracketGval(:,LOpos) = g_new; Tpos = LOpos; end if ~done && abs(bracket(1)-bracket(2))*nrmD < progTol if debug fprintf('Line-search bracket has been reduced below progTol\n'); end break; end end %% if LSiter == maxLS if debug fprintf('Line Search Exceeded Maximum Line Search Iterations\n'); end end [f_LO LOpos] = min(bracketFval); t = bracket(LOpos); f_new = bracketFval(LOpos); g_new = bracketGval(:,LOpos); % Evaluate Hessian at new point if nargout == 5 && funEvals > 1 && saveHessianComp [f_new,g_new,H] = funObj(x + t*d,varargin{:}); funEvals = funEvals + 1; end end %% function [t] = mixedExtrap(x0,f0,g0,x1,f1,g1,minStep,maxStep,debug,doPlot); alpha_c = polyinterp([x0 f0 g0; x1 f1 g1],doPlot,minStep,maxStep); alpha_s = polyinterp([x0 f0 g0; x1 sqrt(-1) g1],doPlot,minStep,maxStep); if alpha_c > minStep && abs(alpha_c - x1) < abs(alpha_s - x1) if debug fprintf('Cubic Extrapolation\n'); end t = alpha_c; else if debug fprintf('Secant Extrapolation\n'); end t = alpha_s; end end %% function [t] = mixedInterp(bracket,bracketFval,bracketGval,d,Tpos,oldLOval,oldLOFval,oldLOGval,debug,doPlot); % Mixed Case %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nonTpos = -Tpos+3; gtdT = bracketGval(:,Tpos)'*d; gtdNonT = bracketGval(:,nonTpos)'*d; oldLOgtd = oldLOGval'*d; if bracketFval(Tpos) > oldLOFval alpha_c = polyinterp([oldLOval oldLOFval oldLOgtd bracket(Tpos) bracketFval(Tpos) gtdT],doPlot); alpha_q = polyinterp([oldLOval oldLOFval oldLOgtd bracket(Tpos) bracketFval(Tpos) sqrt(-1)],doPlot); if abs(alpha_c - oldLOval) < abs(alpha_q - oldLOval) if debug fprintf('Cubic Interpolation\n'); end t = alpha_c; else if debug fprintf('Mixed Quad/Cubic Interpolation\n'); end t = (alpha_q + alpha_c)/2; end elseif gtdT'*oldLOgtd < 0 alpha_c = polyinterp([oldLOval oldLOFval oldLOgtd bracket(Tpos) bracketFval(Tpos) gtdT],doPlot); alpha_s = polyinterp([oldLOval oldLOFval oldLOgtd bracket(Tpos) sqrt(-1) gtdT],doPlot); if abs(alpha_c - bracket(Tpos)) >= abs(alpha_s - bracket(Tpos)) if debug fprintf('Cubic Interpolation\n'); end t = alpha_c; else if debug fprintf('Quad Interpolation\n'); end t = alpha_s; end elseif abs(gtdT) <= abs(oldLOgtd) alpha_c = polyinterp([oldLOval oldLOFval oldLOgtd bracket(Tpos) bracketFval(Tpos) gtdT],... doPlot,min(bracket),max(bracket)); alpha_s = polyinterp([oldLOval sqrt(-1) oldLOgtd bracket(Tpos) bracketFval(Tpos) gtdT],... doPlot,min(bracket),max(bracket)); if alpha_c > min(bracket) && alpha_c < max(bracket) if abs(alpha_c - bracket(Tpos)) < abs(alpha_s - bracket(Tpos)) if debug fprintf('Bounded Cubic Extrapolation\n'); end t = alpha_c; else if debug fprintf('Bounded Secant Extrapolation\n'); end t = alpha_s; end else if debug fprintf('Bounded Secant Extrapolation\n'); end t = alpha_s; end if bracket(Tpos) > oldLOval t = min(bracket(Tpos) + 0.66*(bracket(nonTpos) - bracket(Tpos)),t); else t = max(bracket(Tpos) + 0.66*(bracket(nonTpos) - bracket(Tpos)),t); end else t = polyinterp([bracket(nonTpos) bracketFval(nonTpos) gtdNonT bracket(Tpos) bracketFval(Tpos) gtdT],doPlot); end end
github
themattinthehatt/rlvm-master
minFunc_processInputOptions.m
.m
rlvm-master/lib/minFunc_2012/minFunc/minFunc_processInputOptions.m
4,103
utf_8
8822581c3541eabe5ce7c7927a57c9ab
function [verbose,verboseI,debug,doPlot,maxFunEvals,maxIter,optTol,progTol,method,... corrections,c1,c2,LS_init,cgSolve,qnUpdate,cgUpdate,initialHessType,... HessianModify,Fref,useComplex,numDiff,LS_saveHessianComp,... Damped,HvFunc,bbType,cycle,... HessianIter,outputFcn,useMex,useNegCurv,precFunc,... LS_type,LS_interp,LS_multi,DerivativeCheck] = ... minFunc_processInputOptions(o) % Constants SD = 0; CSD = 1; BB = 2; CG = 3; PCG = 4; LBFGS = 5; QNEWTON = 6; NEWTON0 = 7; NEWTON = 8; TENSOR = 9; verbose = 1; verboseI= 1; debug = 0; doPlot = 0; method = LBFGS; cgSolve = 0; o = toUpper(o); if isfield(o,'DISPLAY') switch(upper(o.DISPLAY)) case 0 verbose = 0; verboseI = 0; case 'FINAL' verboseI = 0; case 'OFF' verbose = 0; verboseI = 0; case 'NONE' verbose = 0; verboseI = 0; case 'FULL' debug = 1; case 'EXCESSIVE' debug = 1; doPlot = 1; end end DerivativeCheck = 0; if isfield(o,'DERIVATIVECHECK') switch(upper(o.DERIVATIVECHECK)) case 1 DerivativeCheck = 1; case 'ON' DerivativeCheck = 1; end end LS_init = 0; LS_type = 1; LS_interp = 2; LS_multi = 0; Fref = 1; Damped = 0; HessianIter = 1; c2 = 0.9; if isfield(o,'METHOD') m = upper(o.METHOD); switch(m) case 'TENSOR' method = TENSOR; case 'NEWTON' method = NEWTON; case 'MNEWTON' method = NEWTON; HessianIter = 5; case 'PNEWTON0' method = NEWTON0; cgSolve = 1; case 'NEWTON0' method = NEWTON0; case 'QNEWTON' method = QNEWTON; Damped = 1; case 'LBFGS' method = LBFGS; case 'BB' method = BB; LS_type = 0; Fref = 20; case 'PCG' method = PCG; c2 = 0.2; LS_init = 2; case 'SCG' method = CG; c2 = 0.2; LS_init = 4; case 'CG' method = CG; c2 = 0.2; LS_init = 2; case 'CSD' method = CSD; c2 = 0.2; Fref = 10; LS_init = 2; case 'SD' method = SD; LS_init = 2; end end maxFunEvals = getOpt(o,'MAXFUNEVALS',1000); maxIter = getOpt(o,'MAXITER',500); optTol = getOpt(o,'OPTTOL',1e-5); progTol = getOpt(o,'PROGTOL',1e-9); corrections = getOpt(o,'CORRECTIONS',100); corrections = getOpt(o,'CORR',corrections); c1 = getOpt(o,'C1',1e-4); c2 = getOpt(o,'C2',c2); LS_init = getOpt(o,'LS_INIT',LS_init); cgSolve = getOpt(o,'CGSOLVE',cgSolve); qnUpdate = getOpt(o,'QNUPDATE',3); cgUpdate = getOpt(o,'CGUPDATE',2); initialHessType = getOpt(o,'INITIALHESSTYPE',1); HessianModify = getOpt(o,'HESSIANMODIFY',0); Fref = getOpt(o,'FREF',Fref); useComplex = getOpt(o,'USECOMPLEX',0); numDiff = getOpt(o,'NUMDIFF',0); LS_saveHessianComp = getOpt(o,'LS_SAVEHESSIANCOMP',1); Damped = getOpt(o,'DAMPED',Damped); HvFunc = getOpt(o,'HVFUNC',[]); bbType = getOpt(o,'BBTYPE',0); cycle = getOpt(o,'CYCLE',3); HessianIter = getOpt(o,'HESSIANITER',HessianIter); outputFcn = getOpt(o,'OUTPUTFCN',[]); useMex = getOpt(o,'USEMEX',1); useNegCurv = getOpt(o,'USENEGCURV',1); precFunc = getOpt(o,'PRECFUNC',[]); LS_type = getOpt(o,'LS_type',LS_type); LS_interp = getOpt(o,'LS_interp',LS_interp); LS_multi = getOpt(o,'LS_multi',LS_multi); end function [v] = getOpt(options,opt,default) if isfield(options,opt) if ~isempty(getfield(options,opt)) v = getfield(options,opt); else v = default; end else v = default; end end function [o] = toUpper(o) if ~isempty(o) fn = fieldnames(o); for i = 1:length(fn) o = setfield(o,upper(fn{i}),getfield(o,fn{i})); end end end
github
levyfan/bow-master
evalData.m
.m
bow-master/src/main/matlab/KISSME/toolbox/evalData.m
4,143
utf_8
fa4260fdbaa73509795057250201aece
function [ds,rocPlot] = evalData(pairs, ds, params) % EVALDATA Evaluate results and plot figures % % Input: % pairs - [1xN] struct. N is the number of pairs. Fields: pairs.fold % pairs.match, pairs.img1, pairs.img2. % ds - [1xF] data struct. F is the number of folds. % ds.method.dist is required to compute tpr, fpr, etc. % params - Parameter struct with the following fields: % params.title - Title for ROC plot. % params.saveDir - Directory to which all the plots are saved % % Output: % ds - Augmented result data struct % rocPlot - handle to the ROC figure % % copyright by Martin Koestinger (2011) % Graz University of Technology % contact [email protected] % % For more information, see <a href="matlab: % web('http://lrs.icg.tugraz.at/members/koestinger')">the ICG Web site</a>. % if ~isfield(params,'title') params.title = 'ROC'; end matches = logical([pairs.match]); %-- EVAL FOLDS --% un = unique([pairs.fold]); for c=1:length(un) testMask = [pairs.fold] == un(c); % eval fold names = fieldnames(ds(c)); for nameCounter=1:length(names) %tpr, fpr [ds(c).(names{nameCounter}).tpr, ds(c).(names{nameCounter}).fpr] = ... icg_roc(matches(testMask),-ds(c).(names{nameCounter}).dist); [ignore, ds(c).(names{nameCounter}).eerIdx] = min(abs(ds(c).(names{nameCounter}).tpr ... - (1-ds(c).(names{nameCounter}).fpr))); %eer ds(c).(names{nameCounter}).eer = ... ds(c).(names{nameCounter}).tpr(ds(c).(names{nameCounter}).eerIdx); end h = myplotroc(ds(c),matches(testMask),names,params); title(sprintf('%s Fold: %d',params.title, c)); %save figure if save dir is specified if isfield(params,'saveDir') exportAndCropFigure(h,sprintf('Fold%d',c),params.saveDir); end close; end %-- EVAL ALL --% names = fieldnames(ds); for nameCounter=1:length(names) s = [ds.(names{nameCounter})]; ms.(names{nameCounter}).std = std([s.eer]); ms.(names{nameCounter}).dist = [s.dist]; ms.(names{nameCounter}).se = ms.(names{nameCounter}).std/sqrt(length(un)); [ms.(names{nameCounter}).tpr, ms.(names{nameCounter}).fpr, ms.(names{nameCounter}).thresh] = icg_roc(matches,-[s.dist]); [ignore, ms.(names{nameCounter}).eerIdx] = min(abs(ms.(names{nameCounter}).tpr ... - (1-ms.(names{nameCounter}).fpr))); ms.(names{nameCounter}).eer = ms.(names{nameCounter}).tpr(ms.(names{nameCounter}).eerIdx); ms.(names{nameCounter}).type = names{nameCounter}; ms.(names{nameCounter}).roccolor = s(1).roccolor; end [rocPlot.h,rocPlot.hL] = myplotroc(ms,matches,names,params); if isfield(params,'saveDir') exportAndCropFigure(rocPlot.h,'overall.png',params.saveDir); end end %-------------------------------------------------------------------------- function [h,l] = myplotroc(ds,matches,names,params) legendEntries = cell(1,length(names)); rocColors = prism(length(names)); %hsv(length(names)) for nameCounter=1:length(names) roccolor = rocColors(nameCounter,:); if isfield(ds.(names{nameCounter}),'roccolor'); roccolor = ds.(names{nameCounter}).roccolor; end %plot roc if nameCounter==1 h = icg_plotroc(matches,-ds.(names{nameCounter}).dist); hold on; plot(ds.(names{nameCounter}).fpr,ds.(names{nameCounter}).tpr,'Color',roccolor,'LineWidth',2,'LineStyle','-'); hold off; else hold on; plot(ds.(names{nameCounter}).fpr,ds.(names{nameCounter}).tpr,'Color',roccolor,'LineWidth',2,'LineStyle','-'); hold off; end legendEntries{nameCounter} = sprintf('%s (%.3f)',upper(names{nameCounter}),ds.(names{nameCounter}).eer); end grid on; ha = get(gca); set(get(get(ha.Children(end),'Annotation'),'LegendInformation'),'IconDisplayStyle','off'); set(get(get(ha.Children(end-1),'Annotation'),'LegendInformation'),'IconDisplayStyle','off'); l = legend(legendEntries,'Location', 'SouthEast'); drawnow; end %--------------------------------------------------------------------------
github
levyfan/bow-master
LearnAlgoLMNN.m
.m
bow-master/src/main/matlab/KISSME/toolbox/learnAlgos/LearnAlgoLMNN.m
2,829
utf_8
f833d30dfe0476ecab72fc14f7cacc8a
%LEARNALGOLMNN Wrapper class to the actual LMNN code classdef LearnAlgoLMNN < LearnAlgo properties p %parameters s %struct available fhanlde end properties (Constant) type = 'lmnn' end methods function obj = LearnAlgoLMNN(p) if nargin < 1 p = struct(); end if ~isfield(p,'knn') p.knn = 1; end if ~isfield(p,'maxiter') p.maxiter = 1000; %std end if ~isfield(p,'validation') p.validation = 0; end if ~isfield(p,'roccolor') p.roccolor = 'k'; end if ~isfield(p,'quiet') p.quiet = 1; end obj.p = p; check(obj); end function bool = check(obj) bool = exist('lmnn.m') == 2; if ~bool fprintf('Sorry %s not available\n',obj.type); end obj.fhanlde = @lmnn; if isunix && exist('lmnn2.m') == 2; obj.fhanlde = @lmnn2; end obj.available = bool; end function s = learnPairwise(obj,X,idxa,idxb,matches) if ~obj.available s = struct(); return; end obj.p.knn = 1; X = X(:,[idxa(matches) idxb(matches)]); %m x d y = [1:sum(matches) 1:sum(matches)]; tic; [s.L, s.Det] = obj.fhanlde(X,consecutiveLabels(y),obj.p.knn, ... 'maxiter',obj.p.maxiter,'validation',obj.p.validation, ... 'quiet',obj.p.quiet); s.M = s.L'*s.L; s.t = toc; s.learnAlgo = obj; s.roccolor = obj.p.roccolor; end function s = learn(obj,X,y) if ~obj.available s = struct(); return; end tic; [s.L, s.Det] = obj.fhanlde(X,consecutiveLabels(y),obj.p.knn, ... 'maxiter', obj.p.maxiter,'validation',obj.p.validation, ... 'quiet',obj.p.quiet); s.M = s.L'*s.L; s.t = toc; s.learnAlgo = obj; s.roccolor = obj.p.roccolor; end function d = dist(obj, s, X, idxa,idxb) d = cdistM(s.M,X,idxa,idxb); end end end % lmnn2 needs consecutive integers as labels function ty = consecutiveLabels(y) uniqueLabels = unique(y); ty = zeros(size(y)); for cY=1:length(uniqueLabels) mask = y == uniqueLabels(cY); ty(mask ) = cY; end end
github
levyfan/bow-master
icg_roc.m
.m
bow-master/src/main/matlab/KISSME/toolbox/helper/icg_roc.m
1,425
utf_8
11d04e9c4c3db15aa1c3b9b771eff30e
function [tpr,fpr,thresh] = icg_roc(tp,confs) % ICG_ROC computes ROC measures (tpr,fpr) % % Input: % tp - [m x n] matrix of zero-one labels. one row per class. % confs - [m x n] matrix of classifier scores. one row per class. % % Output: % tpr - true positive rate in interval [0,1], [m x n+1] matrix % fpr - false positive rate in interval [0,1], [m x n+1] matrix % confs - thresholds over interval % % Example: % icg_plotroc([ones(1,10) zeros(1,10)],20:-1:1); % produces a perfect step curve % % copyright by Martin Koestinger (2011) % Graz University of Technology % contact [email protected] % % For more information, see <a href="matlab: % web('http://lrs.icg.tugraz.at/members/koestinger')">the ICG Web site</a>. % m = size(tp,1); n = size(tp,2); tpr = zeros(m,n+1); fpr = zeros(m,n+1); thresh = zeros(m,n); for c=1:m [tpr(c,:),fpr(c,:),thresh(c,:)] = icg_roc_one_class(tp(c,:),confs(c,:)); end end function [tpr,fpr,confs] = icg_roc_one_class(tp,confs) [confs,idx] = sort(confs,'descend'); tps = tp(idx); % calc recall/precision tpr = zeros(1,numel(tps)); fpr = zeros(1,numel(tps)); tp = 0; fp = 0; tn = sum(tps < 0.5); fn = numel(tps) - tn; for i=1:numel(tps) if tps(i) > 0.5 tp = tp + 1; fn = fn - 1; else fp = fp + 1; tn = tn - 1; end tpr(i) = tp/(tp+fn); fpr(i) = fp/(fp+tn); end fpr = [0 fpr]; tpr = [0 tpr]; end
github
levyfan/bow-master
lmnn.m
.m
bow-master/src/main/matlab/KISSME/toolbox/lib/LMNN/lmnn.m
15,400
utf_8
cb91112611f161bfe0a081b291878dea
function [L,Det]=lmnn(x,y,varargin); % % function [L,Det]=lmnn(maxiter,L,x,y,Kg,'Parameter1',Value1,'Parameter2',Value2,...); % % Input: % % x = input matrix (each column is an input vector) % y = labels % (*optional*) L = initial transformation matrix (e.g eye(size(x,1))) % (*optional*) Kg = attract Kg nearest similar labeled vectos % % Parameters: % stepsize = (default 1e-09) % tempid = (def 0) saves state every 10 iterations in temp#.mat % save = (def 0) save the initial computation % skip = (def 0) loads the initial computation instead of % recomputing (only works if previous run was on exactly the same data) % correction = (def 15) how many steps between each update % The number of impostors are fixed for until next "correction" % factor = (def 1.1) multiplicative factor by which the % "correction" gab increases % obj = (def 1) if 1, solver solves in L, if 0, solver solves in L'*L % thresho = (def 1e-9) cut off for change in objective function (if % improvement is less, stop) % thresha = (def 1e-22) cut off for stepsize, if stepsize is % smaller stop % validation = (def 0) fraction of training data to be used as % validation set (best output is stored in Det.bestL) % valcount = (def 50) every "valcount" steps do validation % maxiter = maximum number of iterations (default: 10000) % scale = (def. 0) if 1, all data gets re-scaled s.t. average % distance to closest neighbor is 1 % quiet = {0,1} surpress output (default=0) % % % Output: % % L = linear transformation xnew=L*x % % Det.obj = objective function over time % Det.nimp = number of impostors over time % Det.pars = all parameters used in run % Det.time = time needed for computation % Det.iter = number of iterations % Det.verify = verify (results of validation - if used) % % Version 1.0 % copyright by Kilian Q. Weinbergerr (2005) % University of Pennsylvania % contact [email protected] % tempnum=num2str(round(rand(1).*1000)); fprintf('Tempfile: %s\n',tempnum); fprintf('LMNN stable\n'); if(nargin==0) help lmnn; return; end; if(length(varargin)>0 & isnumeric(varargin{1})) % check if neighborhood or L have been passed on Kg=varargin{1}; fprintf('Setting neighborhood to k=%i\n',Kg); if(length(varargin)>1 & ~isstr(varargin{2})) L=varargin{2}; fprintf('Setting initial transformation!\n'); end; % skip Kgand L parameters newvarargin={};copy=0;j=1; for i=1:length(varargin) if(isstr(varargin{i})) copy=1;end; if(copy)newvarargin{j}=varargin{i};j=j+1;end; end; varargin=newvarargin; clear('newvarargin','copy'); else fprintf('Neigborhood size not specified. Setting k=3\n'); Kg=3; end; if(exist('L')~=1) fprintf(['Initial starting point not specified.\nStarting with identity matrix.\n']); L=eye(size(x,1)); end; tic % checks D=size(L,2); x=x(1:D,:); if(size(x,1)>length(L)) error('x and L must have matching dimensions!\n');end; % set parameters pars.stepsize=1e-07; pars.minstepsize=0; pars.tempid=-1; pars.save=0; pars.skip=0; pars.maxiter=10000; pars.factor=1.1; pars.correction=15; pars.thresho=1e-7; pars.thresha=1e-22; pars.ifraction=1; pars.scale=0; pars.obj=1; pars.union=1; pars.tabularasa=Inf; pars.quiet=0; pars.validation=0; pars.validationstep=50; pars.earlystopping=0; pars.aggressive=0; pars.valcount=50; pars.stepgrowth=1.01; pars.reg=0; pars.weight1=0.5; pars.maximp=100000; pars.fifo=0; pars.guard=0; pars.graphics=0; pars=extractpars(varargin,pars); % verification dataset %i=randperm(size(x,2)); i=1:size(x,2); tr=ceil(size(x,2)*(1-pars.validation)); ve=size(x,2)-tr; xo=x; yo=y; x=xo(:,i(1:tr)); y=yo(i(1:tr)); xv=xo(:,i(tr+1:end)); yv=yo(i(tr+1:end)); verify=[];besterr=inf; clear('xo','yo'); lowesterr=inf; verify=[]; bestL=L; if(~pars.quiet) pars end; tempname=sprintf('temp%i.mat',pars.tempid); % Initializationip [D,N]=size(x); fprintf('%i input vectors with %i dimensions\n',N,D); [gen,NN]=getGenLS(x,y,Kg,pars); obj=zeros(1,pars.maxiter); nimp=zeros(1,pars.maxiter); if(~pars.quiet) fprintf('Total number of genuine pairs: %i\n',size(gen,2));end; [imp]= checkup(L,x,y,NN(end,:),pars); if(~pars.quiet)fprintf('Total number of imposture pairs: %i\n',size(imp,2));end; if(pars.reg==1) dfG=vec(eye(D)); else dfG=vec(SOD(x,gen(1,:),gen(2,:))); end; % Fifo=zeros(1,size(imp,2)); if(pars.scale) Lx=L*x; sc=sqrt(mean(sum( ((Lx-Lx(:,NN(end,:)))).^2))); L=L./sc; end; df=zeros(D^2,1); correction=pars.correction; tabularasa=pars.tabularasa; ifraction=pars.ifraction; stepsize=pars.stepsize; lastcor=1; if(pars.graphics) hpl=scat(L*x,3,y+0,'size',120); end; for nnid=1:Kg; a1{nnid}=[];a2{nnid}=[];end; df=zeros(size(dfG)); % Main Loop for iter=1:pars.maxiter % save old position Lold=L;dfold=df; for nnid=1:Kg; a1old{nnid}=a1{nnid};a2old{nnid}=a2{nnid};end; if(iter>1)L=step(L,mat((dfG.*pars.weight1+df.*(1-pars.weight1))),stepsize,pars);end; if(~pars.quiet)fprintf('%i.',iter);end; Lx=L*x; %Lx2=sum(Lx.^2); totalactive=0; if(pars.graphics & mod(iter,10)==0) set(hpl,'XData',Lx(1,:),'YData',Lx(2,:)); set(hpl,'YData',Lx(3,:)); set(hpl,'CData',y); axis tight; drawnow; end; g0=cdist(Lx,imp(1,:),imp(2,:)); if(pars.guard) kk=Kg; else kk=1; end; for nnid=kk:Kg Ni(nnid,1:N)=(sum((Lx-Lx(:,NN(nnid,:))).^2)+1); end; g1=Ni(:,imp(1,:)); g2=Ni(:,imp(2,:)); act1=[];act2=[]; if(pars.validation>0 & (mod(iter,pars.validationstep)==0 | iter==1)) verify=[verify Ltest2in(Lx,y,L*xv,yv,Ni,Kg,pars)]; if(verify(end)<=besterr) fprintf('*');besterr=verify(end);bestL= ... L;Det.bestiter=iter; end; if(pars.earlystopping>0 & length(verify)>pars.earlystopping & all(verify(end-pars.earlystopping:end)>besterr)) ... fprintf('Validation error is no longer improving!\n');break; end; end; clear('Lx','Lx2'); % objv=dfG'*vec((L'*L)); for nnid=Kg:-1:kk act1=find(g0<g1(nnid,:)); act2=find(g0<g2(nnid,:)); active=[act1 act2]; if(~isempty(a1{nnid}) | ~isempty(a2{nnid})) try [plus1,minus1]=sd(act1(:)',a1{nnid}(:)'); [plus2,minus2]=sd(act2(:)',a2{nnid}(:)'); catch lasterr keyboard; end; else plus1=act1;plus2=act2; minus1=[];minus2=[]; end; % [isminus2,i]=sort(imp(1,minus2));minus2=minus2(i); MINUS1a=[imp(1,minus1) imp(2,minus2)]; MINUS1b=[imp(1,[plus1 plus2])]; MINUS2a=[NN(nnid,imp(1,minus1)) NN(nnid,imp(2,minus2))]; MINUS2b=[imp(2,[plus1 plus2])]; [isplus2,i]= sort(imp(2,plus2));plus2=plus2(i); PLUS1a=[imp(1,plus1) isplus2]; PLUS1b=[imp(1,[minus1 minus2])]; PLUS2a=[NN(nnid,imp(1,plus1)) NN(nnid,isplus2)]; PLUS2b=[imp(2,[minus1 minus2])]; loss1=max(g1(nnid,:)-g0,0); loss2=max(g2(nnid,:)-g0,0); % ; [PLUS ,pweight]=count([PLUS1a;PLUS2a]); [MINUS,mweight]=count([MINUS1a;MINUS2a]); df2=SODW(x,PLUS(1,:),PLUS(2,:),pweight)-SODW(x,MINUS(1,:),MINUS(2,:),mweight); df4=SOD(x,PLUS1b,PLUS2b)-SOD(x,MINUS1b,MINUS2b); df=df+vec(df2+df4); a1{nnid}=act1;a2{nnid}=act2; totalactive=totalactive+length(active); end; if(any(any(isnan(df)))) fprintf('Gradient has NaN value!\n'); keyboard; end; %obj(iter)=objv; obj(iter)=(dfG.*pars.weight1+df.*(1-pars.weight1))'*vec(L'*L)+totalactive.*(1-pars.weight1); if(isnan(obj(iter))) fprintf('Obj is NAN!\n'); keyboard; end; nimp(iter)=totalactive; delta=obj(iter)-obj(max(iter-1,1)); if(~pars.quiet)fprintf([' Obj:%2.2f Nimp:%i Delta:%2.4f max(G):' ... ' %2.4f' ... ' \n '],obj(iter),nimp(iter),delta,max(max(abs(df)))); end; if(iter>1 & delta>0 & correction~=pars.correction) stepsize=stepsize*0.5; fprintf('***correcting stepsize***\n'); if(stepsize<pars.minstepsize) stepsize=pars.minstepsize;end; if(~pars.aggressive) L=Lold; df=dfold; for nnid=1:Kg; a1{nnid}=a1old{nnid};a2{nnid}=a2old{nnid};end; obj(iter)=obj(iter-1); end; % correction=1; hitwall=1; else if(correction~=pars.correction)stepsize=stepsize*pars.stepgrowth;end; hitwall=0; end; if(iter>10 & (max(abs(diff(obj(iter-3:iter))))<pars.thresho*obj(iter) ... | stepsize<pars.thresha)) if(pars.correction-correction>=5) correction=1; else switch(pars.obj) case 0 if(~pars.quiet)fprintf('Stepsize too small. No more progress!\n');end; break; case 1 pars.obj=0; pars.correction=15; pars.stepsize=1e-9; correction=min(correction,pars.correction); if(~pars.quiet | 1) fprintf('\nVerifying solution! %i\n',obj(iter)); end; case 3 if(~pars.quiet)fprintf('Stepsize too small. No more progress!\n');end; break; end; end; end; if(pars.tempid>=0 & mod(iter,50)==0) time=toc;save(tempname,'L','iter','obj','pars','time','verify');end; correction=correction-1; if(correction==0) if(pars.quiet)fprintf('\n');end; [Vio]=checkup(L,x,y,NN(nnid,:),pars); Vio=setdiff(Vio',imp','rows')'; if(pars.maximp<inf) i=randperm(size(Vio,2)); Vio=Vio(:,i(1:min(pars.maximp,size(Vio,2)))); end; ol=size(imp,2); [imp i1 i2]=unique([imp Vio].','rows'); imp=imp.'; if(size(imp,2)~=ol) for nnid=1:Kg; a1{nnid}=i2(a1{nnid}); a2{nnid}=i2(a2{nnid}); end; end; fprintf('Added %i active constraints. New total: %i\n\n',size(imp,2)-ol,size(imp,2)); if(ifraction<1) i=1:size(imp,2); imp=imp(:,i(1:ceil(length(i)*ifraction))); if(~pars.quiet)fprintf('Only use %2.2f of them.\n',ifraction);end; ifraction=ifraction+pars.ifraction; end; % put next correction a little more into the future if no new impostors were added if(size(imp,2)-ol<=0) pars.correction=min(pars.correction*2+2,300); correction=pars.correction-1; else pars.correction=round(pars.correction*pars.factor); correction=pars.correction; end; lastcor=iter; end; end; % Output Det.obj=obj(1:iter); Det.nimp=nimp; Det.pars=pars; Det.time=toc; Det.iter=iter; Det.verify=verify; if(pars.validation>0) Det.minL=L; L=bestL; Det.verify=verify; end; function [err,yy,Value]=Ltest2in(Lx,y,LxT,yTest,Ni,Kg,pars); % function [err,yy,Value]=Ltest2(L,x,y,xTest,yTest,Kg,varargin); % % Initializationip [D,N]=size(Lx); Lx2=sum(Lx.^2); MM=min(y); y=y-MM+1; un=unique(y); Value=zeros(length(un),length(yTest)); B=500; NTe=size(LxT,2); for n=1:B:NTe nn=n:n+min(B-1,NTe-n); DD=distance(Lx,LxT(:,nn)); for i=1:length(un) % Main Loopfor iter=1:pars.maxiter testlabel=un(i); enemy=find(y~=testlabel); friend=find(y==testlabel); Df=mink(DD(friend,:),Kg); Value(i,nn)=sumiflessv2(DD,Ni(:,enemy),enemy)+sumiflessh2(DD,Df+1,enemy); if(pars.reg==0) Value(i,nn)=Value(i,nn)+sum(Df); end; end; end; fprintf('\n'); [temp,yy]=min(Value); yy=un(yy)+MM-1; err=sum(yy~=yTest)./length(yTest); fprintf('Energy error:%2.2f%%\n',err*100); function err=validation(Lx,y,LxT,yTest,Ni,Kg); if(isempty(LxT)) err=0;return;end; MM=min(y); y=y-MM+1; un=unique(y); Value=zeros(length(un),length(yTest)); B=500; if(size(Lx,2)>50000) B=250;end; NTe=size(LxT,2); for n=1:B:NTe fprintf('%2.2f%%: ',n/NTe*100); nn=n:n+min(B-1,NTe-n); DD=distance(Lx,LxT(:,nn)); for i=1:length(un) testlabel=un(i); fprintf('%i.',testlabel+MM-1); enemy=find(y~=testlabel); friend=find(y==testlabel); Df=sort(DD(friend,:)); Value(i,nn)=sum(Df(1:Kg,:))+sumiflessv(DD(enemy,:),Ni(enemy))+sumiflessh(DD(enemy,:),Df(Kg,:)); end; fprintf('\n'); end; fprintf('\n'); [temp,yy]=min(Value); yy=un(yy)+MM-1; err=sum(yy~=yTest)./length(yTest); fprintf('Energy error:%2.2f%%\n',err*100); function L=step(L,G,stepsize,pars); % do step in gradient direction if(size(L,1)~=size(L,2)) pars.obj=1;end; switch(pars.obj) case 0 % updating Q Q=L'*L; Q=Q-stepsize.*G; case 1 % updating L G=2.*(L*G); L=L-stepsize.*G; return; case 2 % multiplicative update Q=L'*L; Q=Q-stepsize.*G+stepsize^2/4.*G*inv(Q)*G; return; case 3 Q=L'*L; Q=Q-stepsize.*G; Q=diag(Q); L=diag(sqrt(max(Q,0))); return; otherwise error('Objective function has to be 0,1,2\n'); end; % decompose Q [L,dd]=eig(Q); dd=real(diag(dd)); L=real(L); % reassemble Q (ignore negative eigenvalues) j=find(dd<1e-10); if(~isempty(j)) if(~pars.quiet)fprintf('[%i]',length(j));end; end; dd(j)=0; [temp,ii]=sort(-dd); L=L(:,ii); dd=dd(ii); % Q=L*diag(dd)*L'; L=(L*diag(sqrt(dd)))'; %for i=1:size(L,1) % if(L(i,1)~=0) L(i,:)=L(i,:)./sign(L(i,1));end; %end; function imp=getImpLS(x,y,Kg,Ki,pars); [D,N]=size(x); filename=sprintf('.LSKInn%i.mat',pars.tempid); if(pars.skip) load(filename); else un=unique(y); Inn=zeros(Ki,N); for c=un fprintf('%i nearest imposture neighbors for class %i :',Ki,c); i=find(y==c); j=find(y~=c); nn=LSKnn(x(:,j),x(:,i),1:Ki); Inn(:,i)=j(nn); fprintf('\r'); end; fprintf('\n'); end; imp=[vec(Inn(1:Ki,:)')'; vec(repmat(1:N,Ki,1)')']; imp=unique(imp','rows')'; % Delete dublicates if(pars.save) save(filename,'Inn'); end; function [gen,NN]=getGenLS(x,y,Kg,pars); if(~pars.quiet)fprintf('Computing nearest neighbors ...\n');end; filename=sprintf('.LSKGnn%i.mat',pars.tempid); [D,N]=size(x); if(pars.skip) load(filename); else un=unique(y); Gnn=zeros(Kg,N); for c=un fprintf('%i nearest genuine neighbors for class %i:',Kg,c); i=find(y==c); nn=LSKnn(x(:,i),x(:,i),2:Kg+1); Gnn(:,i)=i(nn); fprintf('\r'); end; fprintf('\n'); NN=Gnn; gen1=vec(Gnn(1:Kg,:)')'; gen2=vec(repmat(1:N,Kg,1)')'; gen=[gen1;gen2]; if(pars.save) save(filename,'gen','NN'); end; end; function imp=checkup(L,x,y,NN,pars); if(~pars.quiet)fprintf('Computing nearest neighbors ...\n');end; [D,N]=size(x); Lx=L*x; Ni=sum((Lx-Lx(:,NN)).^2)+1; un=unique(y); imp=[]; index=1:N; for c=un(1:end-1) if(~pars.quiet)fprintf('All nearest impostor neighbors for class %i :',c);end; i=index(find(y(index)==c)); index=index(find(y(index)~=c)); limps=LSImps2(Lx(:,index),Lx(:,i),Ni(index),Ni(i),pars); if(size(limps,2)>pars.maximp) ip=randperm(size(limps,2)); ip=ip(1:pars.maximp); limps=limps(:,ip); end; imp=[imp [i(limps(2,:));index(limps(1,:))]]; if(~pars.quiet)fprintf('\r');end; end; try imp=unique(sort(imp)','rows')'; catch keyboard; end; function limps=LSImps2(X1,X2,Thresh1,Thresh2,pars); B=750; [D,N2]=size(X2); N1=size(X1,2); limps=[]; for i=1:B:N2 BB=min(B,N2-i); try newlimps=findimps3Dac(X1,X2(:,i:i+BB), Thresh1,Thresh2(i:i+BB)); if(~isempty(newlimps) & newlimps(end)==0) [minv,endpoint]=min(min(newlimps)); newlimps=newlimps(:,1:endpoint-1); end; newlimps=unique(newlimps','rows')'; % if(~all(all(newlimps==newlimps2))) keyboard;end; % newlimps2=findimps3D2(X1,X2(:,i:i+BB), Thresh1,Thresh2(i:i+BB)); % newlimps=unique((sort(newlimps))','rows')'; % if(length(newlimps2)~=length(newlimps) | ~all(all(newlimps2==newlimps))) % keyboard; %end; catch keyboard; end; newlimps(2,:)=newlimps(2,:)+i-1; limps=[limps newlimps]; if(~pars.quiet)fprintf('(%i%%) ',round((i+BB)/N2*100)); end; end; if(~pars.quiet)fprintf(' [%i] ',size(limps,2));end; function NN=LSKnn(X1,X2,ks,pars); B=750; [D,N]=size(X2); NN=zeros(length(ks),N); DD=zeros(length(ks),N); for i=1:B:N BB=min(B,N-i); fprintf('.'); Dist=distance(X1,X2(:,i:i+BB)); fprintf('.'); [dist,nn]=mink(Dist,max(ks)); clear('Dist'); fprintf('.'); NN(:,i:i+BB)=nn(ks,:); clear('nn','dist'); fprintf('(%i%%) ',round((i+BB)/N*100)); end;
github
levyfan/bow-master
knnclassify.m
.m
bow-master/src/main/matlab/KISSME/toolbox/lib/LMNN/knnclassify.m
2,559
utf_8
02d7cf7e68cc0dc6f86bc8765e02e66b
function [Eval,Details]=LSevaluate(L,xTr,lTr,xTe,lTe,KK); % function [Eval,Details]=LSevaluate(L,xTr,yTr,xTe,yTe,Kg); % % INPUT: % L : transformation matrix (learned by LMNN) % xTr : training vectors (each column is an instance) % yTr : training labels (row vector!!) % xTe : test vectors % yTe : test labels % Kg : number of nearest neighbors % % Good luck! % % copyright by Kilian Q. Weinberger, 2006 % % version 1.1 (04/13/07) % Little bugfix, couldn't handle single test vectors beforehand. % Thanks to Karim T. Abou-Moustafa for pointing it out to me. % MM=min([lTr lTe]); if(nargin<6) KK=1:2:3; end; if(length(KK)==1) outputK=ceil(KK/2);KK=1:2:KK;else outputK=1:length(KK);end; Kn=max(KK); D=length(L); xTr=L*xTr(1:D,:); xTe=L*xTe(1:D,:); B=700; [NTr]=size(xTr,2); [NTe]=size(xTe,2); Eval=zeros(2,length(KK)); lTr2=zeros(length(KK),NTr); lTe2=zeros(length(KK),NTe); iTr=zeros(Kn,NTr); iTe=zeros(Kn,NTe); sx1=sum(xTr.^2,1); sx2=sum(xTe.^2,1); for i=1:B:max(NTr,NTe) if(i<=NTr) BTr=min(B-1,NTr-i); %Dtr=distance(xTr,xTr(:,i:i+BTr)); Dtr=addh(addv(-2*xTr'*xTr(:,i:i+BTr),sx1),sx1(i:i+BTr)); % [dist,nn]=sort(Dtr); [dist,nn]=mink(Dtr,Kn+1); nn=nn(2:Kn+1,:); lTr2(:,i:i+BTr)=LSKnn2(lTr(nn),KK,MM); iTr(:,i:i+BTr)=nn; Eval(1,:)=sum((lTr2(:,1:i+BTr)~=repmat(lTr(1:i+BTr),length(KK),1))',1)./(i+BTr); end; if(i<=NTe) BTe=min(B-1,NTe-i); Dtr=addh(addv(-2*xTr'*xTe(:,i:i+BTe),sx1),sx2(i:i+BTe)); [dist,nn]=mink(Dtr,Kn); lTe2(:,i:i+BTe)=LSKnn2(reshape(lTr(nn),max(KK),BTe+1),KK,MM); iTe(:,i:i+BTe)=nn; Eval(2,:)=sum((lTe2(:,1:i+BTe)~=repmat(lTe(1:i+BTe),length(KK),1))',1)./(i+BTe); end; fprintf('%2.2f%%.:\n',(i+BTr)/max(NTr,NTe)*100); disp(Eval.*100); end; Details.lTe2=lTe2; Details.lTr2=lTr2; Details.iTe=iTe; Details.iTr=iTr; Eval=Eval(:,outputK); function yy=LSKnn2(Ni,KK,MM); % function yy=LSKnn2(Ni,KK,MM); % if(nargin<2) KK=1:2:3; end; N=size(Ni,2); Ni=Ni-MM+1; classes=unique(unique(Ni))'; %yy=zeros(1,size(Ni,2)); %for i=1:size(Ni,2) % n=zeros(max(un),1); % for j=1:size(Ni,1) % n(Ni(j,i))=n(Ni(j,i))+1; % end; % [temp,yy(i)]=max(n); %end; T=zeros(length(classes),N,length(KK)); for i=1:length(classes) c=classes(i); for k=KK % NNi=Ni(1:k,:)==c; % NNi=NNi+(Ni(1,:)==c).*0.01;% give first neighbor tiny advantage try T(i,:,k)=sum(Ni(1:k,:)==c,1); catch keyboard; end; end; end; yy=zeros(max(KK),N); for k=KK [temp,yy(k,1:N)]=max(T(:,:,k)+T(:,:,1).*0.01); yy(k,1:N)=classes(yy(k,:)); end; yy=yy(KK,:); yy=yy+MM-1;
github
levyfan/bow-master
energyclassify.m
.m
bow-master/src/main/matlab/KISSME/toolbox/lib/LMNN/energyclassify.m
2,926
utf_8
9155befdcfcd16052c23bbab1cf7b530
function [err,yy,Value]=energyclassify(L,x,y,xTest,yTest,Kg,varargin); % function [err,yy,Value]=energyclassify(L,xTr,yTr,xTe,yTe,Kg,varargin); % % INPUT: % L : transformation matrix (learned by LMNN) % xTr : training vectors (each column is an instance) % yTr : training labels (row vector!!) % xTe : test vectors % yTe : test labels % Kg : number of nearest neighbors % % Good luck! % % copyright by Kilian Q. Weinberger, 2006 % checks D=length(L); x=x(1:D,:); xTest=xTest(1:D,:); if(size(x,1)>length(L)) error('x and L must have matching dimensions!\n');end; % set parameters pars.alpha=1e-09; pars.tempid=0; pars.save=0; pars.speed=10; pars.skip=0; pars.factor=1; pars.correction=15; pars.prod=0; pars.thresh=1e-16; pars.ifraction=1; pars.scale=0; pars.obj=0; pars.union=1; pars.margin=0; pars.tabularasa=Inf; pars.blocksize=500; pars=extractpars(varargin,pars); pars tempname=sprintf('temp%i.mat',pars.tempid); % Initializationip [D,N]=size(x); [gen,NN]=getGenLS(x,y,Kg,pars); if(pars.scale) fprintf('Scaling input vectors!\n'); sc=sqrt(mean(sum( ((x-x(:,NN(end,:)))).^2))); x=x./sc; xTest=xTest./sc; end; Lx=L*x; Lx2=sum(Lx.^2); LxT=L*xTest; for inn=1:Kg Ni(inn,:)=sum((Lx-Lx(:,NN(inn,:))).^2)+1; end; MM=min(y); y=y-MM+1; un=unique(y); Value=zeros(length(un),length(yTest)); B=pars.blocksize; if(size(x,2)>50000) B=250;end; NTe=size(xTest,2); for n=1:B:NTe fprintf('%2.2f%%: ',n/NTe*100); nn=n:n+min(B-1,NTe-n); DD=distance(Lx,LxT(:,nn)); for i=1:length(un) % Main Loopfor iter=1:maxiter testlabel=un(i); fprintf('%i.',testlabel+MM-1); enemy=find(y~=testlabel); friend=find(y==testlabel); Df=mink(DD(friend,:),Kg); Value(i,nn)=sumiflessv2(DD,Ni(:,enemy),enemy)+sumiflessh2(DD,Df,enemy)+sum(Df); % Value(i,nn)=sumiflessh2(DD,Df+pars.margin,enemy)+sum(Df); end; fprintf('\n'); end; fprintf('\n'); [temp,yy]=min(Value); yy=un(yy)+MM-1; err=sum(yy~=yTest)./length(yTest); fprintf('Energy error:%2.2f%%\n',err*100); function [gen,NN]=getGenLS(x,y,Kg,pars); fprintf('Computing nearest neighbors ...\n'); [D,N]=size(x); if(pars.skip) load('.LSKGnn.mat'); else un=unique(y); Gnn=zeros(Kg,N); for c=un fprintf('%i nearest genuine neighbors for class %i:',Kg,c); i=find(y==c); nn=LSKnn(x(:,i),x(:,i),2:Kg+1); Gnn(:,i)=i(nn); fprintf('\n'); end; end; NN=Gnn; gen1=vec(Gnn(1:Kg,:)')'; gen2=vec(repmat(1:N,Kg,1)')'; gen=[gen1;gen2]; if(pars.save) save('.LSKGnn.mat','Gnn'); end; function NN=LSKnn(X1,X2,ks,pars); B=2000; [D,N]=size(X2); NN=zeros(length(ks),N); DD=zeros(length(ks),N); for i=1:B:N BB=min(B,N-i); fprintf('.'); Dist=distance(X1,X2(:,i:i+BB)); fprintf('.'); % [dist,nn]=sort(Dist); [dist,nn]=mink(Dist,max(ks)); clear('Dist'); fprintf('.'); % keyboard; NN(:,i:i+BB)=nn(ks,:); clear('nn','dist'); fprintf('(%i%%) ',round((i+BB)/N*100)); end; function v=vec(M); % vectorizes a matrix v=M(:);
github
fengweiigg/GRACE_Matlab_Toolbox-master
GRACE_Matlab_Toolbox.m
.m
GRACE_Matlab_Toolbox-master/GRACE_Matlab_Toolbox.m
5,933
utf_8
852fbc11927286fc4ac8b0d61dcc2624
function varargout = GRACE_Matlab_Toolbox(varargin) % GRACE_MATLAB_TOOLBOX MATLAB code for GRACE_Matlab_Toolbox.fig % GRACE_MATLAB_TOOLBOX, by itself, creates a new GRACE_MATLAB_TOOLBOX or raises the existing % singleton*. % % H = GRACE_MATLAB_TOOLBOX returns the handle to a new GRACE_MATLAB_TOOLBOX or the handle to % the existing singleton*. % % GRACE_MATLAB_TOOLBOX('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GRACE_MATLAB_TOOLBOX.M with the given input arguments. % % GRACE_MATLAB_TOOLBOX('Property','Value',...) creates a new GRACE_MATLAB_TOOLBOX or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GRACE_Matlab_Toolbox_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GRACE_Matlab_Toolbox_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GRACE_Matlab_Toolbox % Last Modified by GUIDE v2.5 04-Sep-2015 23:20:36 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GRACE_Matlab_Toolbox_OpeningFcn, ... 'gui_OutputFcn', @GRACE_Matlab_Toolbox_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before GRACE_Matlab_Toolbox is made visible. function GRACE_Matlab_Toolbox_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GRACE_Matlab_Toolbox (see VARARGIN) % Choose default command line output for GRACE_Matlab_Toolbox handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GRACE_Matlab_Toolbox wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = GRACE_Matlab_Toolbox_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % -------------------------------------------------------------------- function GSMGADProcessing_Callback(hObject, eventdata, handles) % open('GRACE_Matlab_Toolbox_preprocessing.fig'); %result?????????? run GRACE_Matlab_Toolbox_preprocessing % hObject handle to GSMGADProcessing (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function GSMGADProcessing_ClickedCallback(hObject, eventdata, handles) % open('GRACE_Matlab_Toolbox_preprocessing.fig'); %result?????????? run GRACE_Matlab_Toolbox_preprocessing % -------------------------------------------------------------------- function LeakageReductionSpatial_Callback(hObject, eventdata, handles) % hObject handle to LeakageReductionSpatial (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) run GRACE_Matlab_Toolbox_LeakageReductionSpatial % -------------------------------------------------------------------- function SHGrid_Callback(hObject, eventdata, handles) % hObject handle to SHGrid (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % open('GRACE_Matlab_Toolbox_SHGrid.fig'); %result?????????? run GRACE_Matlab_Toolbox_SHGrid % -------------------------------------------------------------------- function Grid2Series_Callback(hObject, eventdata, handles) % hObject handle to Grid2Series (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) run GRACE_Matlab_Toolbox_Grid2Series % -------------------------------------------------------------------- function HarmonicAnalysis_Callback(hObject, eventdata, handles) % hObject handle to HarmonicAnalysis (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % open('GRACE_Matlab_Toolbox_HarmonicAnalysis.fig'); %result?????????? run GRACE_Matlab_Toolbox_HarmonicAnalysis % -------------------------------------------------------------------- function GRACEProcessing_Callback(hObject, eventdata, handles) % hObject handle to GRACEProcessing (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function DataAnalysis_Callback(hObject, eventdata, handles) % hObject handle to DataAnalysis (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
github
fengweiigg/GRACE_Matlab_Toolbox-master
GRACE_Matlab_Toolbox_preprocessing.m
.m
GRACE_Matlab_Toolbox-master/GRACE_Matlab_Toolbox_preprocessing.m
29,614
utf_8
7ba0deb4a2a5efbfd17e13c6705230a4
function varargout = GRACE_Matlab_Toolbox_preprocessing(varargin) % GRACE_MATLAB_TOOLBOX_PREPROCESSING MATLAB code for GRACE_Matlab_Toolbox_preprocessing.fig % GRACE_MATLAB_TOOLBOX_PREPROCESSING, by itself, creates a new GRACE_MATLAB_TOOLBOX_PREPROCESSING or raises the existing % singleton*. % % H = GRACE_MATLAB_TOOLBOX_PREPROCESSING returns the handle to a new GRACE_MATLAB_TOOLBOX_PREPROCESSING or the handle to % the existing singleton*. % % GRACE_MATLAB_TOOLBOX_PREPROCESSING('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GRACE_MATLAB_TOOLBOX_PREPROCESSING.M with the given input arguments. % % GRACE_MATLAB_TOOLBOX_PREPROCESSING('Property','Value',...) creates a new GRACE_MATLAB_TOOLBOX_PREPROCESSING or raises % the existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GRACE_Matlab_Toolbox_preprocessing_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GRACE_Matlab_Toolbox_preprocessing_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GRACE_Matlab_Toolbox_preprocessing % Last Modified by GUIDE v2.5 23-Mar-2015 18:15:17 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GRACE_Matlab_Toolbox_preprocessing_OpeningFcn, ... 'gui_OutputFcn', @GRACE_Matlab_Toolbox_preprocessing_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before GRACE_Matlab_Toolbox_preprocessing is made visible. function GRACE_Matlab_Toolbox_preprocessing_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GRACE_Matlab_Toolbox_preprocessing (see VARARGIN) % Choose default command line output for GRACE_Matlab_Toolbox_preprocessing handles.output = hObject; guidata(hObject, handles); initialize_gui(hObject, handles, false); % --- Outputs from this function are returned to the command line. function varargout = GRACE_Matlab_Toolbox_preprocessing_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % -------------------------------------------------------------------- function initialize_gui(fig_handle, handles, isreset) % If the metricdata field is present and the reset flag is false, it means % we are we are just re-initializing a GUI by calling it from the cmd line % while it is up. So, bail out as we dont want to reset the data. if isfield(handles, 'metricdata') && ~isreset return; end % Update handles structure guidata(handles.figure1, handles); % --- Main Function in this Toolbox --- function PushbuttonCalculate_Callback(hObject, eventdata, handles) if ~isempty(get(handles.EditOpenControlFile,'String')) GRACE_Matlab_Toolbox_preprocessing_core(get(handles.EditOpenControlFile,'String')); return; elseif ~isempty(get(handles.EditSaveControlFile,'String')) GRACE_Matlab_Toolbox_preprocessing_core(get(handles.EditSaveControlFile,'String')); return; else warndlg('Control file should be specified in STEP3/STEP1!','Warning'); end % Specify the GRACE Level2 Files function PushButtonOpenFiles_Callback(hObject, eventdata, handles) % Open GRACE GSM Files [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*','GRACE-files (*)'; ... '*.gfc','ICGEM-files (*.gfc)'; ... '*.*', 'All Files (*.*)'}, ... 'Pick GRACE Level2 files', ... 'MultiSelect', 'on'); if filterindex==1 set(handles.InputFileListbox,'string',InputFilename);% Show the Files in the listbox handles.InputFilename=InputFilename; handles.InputPathname=InputPathname; guidata(hObject,handles); else warndlg('Input files should be specified!!!','Warning'); return; end function InputFileListbox_Callback(hObject, eventdata, handles) function InputFileListbox_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % Specify the Maximum Degree function EditMaxDegreeOutput_Callback(hObject, eventdata, handles) handles.MaxDegreeOutput=str2double(get(hObject,'String')); guidata(hObject, handles); function EditMaxDegreeOutput_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % Specify the Gaussin Filter Radius function EditFilterRadius_Callback(hObject, eventdata, handles) guidata(hObject, handles); function EditFilterRadius_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % Specify the path of C20, C21, S21, C22, S22 function CheckboxC20_Callback(hObject, eventdata, handles) if get(handles.CheckboxC20,'value')==1 [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.*', 'All Files (*.*)'}, ... 'Pick C20 file'); if filterindex==1 % file selected % Show the Directory and File in the textbox set(handles.EditC20, 'String', [InputPathname,InputFilename]); handles.PathC20=[InputPathname,InputFilename]; guidata(hObject, handles); else set(handles.CheckboxC20,'value',0); set(handles.EditC20, 'String', 'NAN'); end else set(handles.EditC20, 'String', 'NAN'); end function CheckboxC21S21_Callback(hObject, eventdata, handles) if get(handles.CheckboxC21S21,'value')==1 [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.*', 'All Files (*.*)'}, ... 'Pick C21 & S21 file'); if filterindex==1 % file selected % Show the Directory and File in the textbox set(handles.EditC21S21, 'String', [InputPathname,InputFilename]); handles.PathC21S21=[InputPathname,InputFilename]; guidata(hObject, handles); else set(handles.CheckboxC21S21,'value',0); set(handles.EditC21S21, 'String', 'NAN'); end else set(handles.EditC21S21, 'String', 'NAN'); end function CheckboxC22S22_Callback(hObject, eventdata, handles) if get(handles.CheckboxC22S22,'value')==1 [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.*', 'All Files (*.*)'}, ... 'Pick C22 & S22 file'); if filterindex==1 % file selected % Show the Directory and File in the textbox set(handles.EditC22S22, 'String', [InputPathname,InputFilename]); handles.PathC22S22=[InputPathname,InputFilename]; guidata(hObject, handles); else set(handles.CheckboxC22S22,'value',0); set(handles.EditC22S22, 'String', 'NAN'); end else set(handles.EditC22S22, 'String', 'NAN'); end function CheckboxDegree1_Callback(hObject, eventdata, handles) if get(handles.CheckboxDegree1,'value')==1 [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.*', 'All Files (*.*)'}, ... 'Pick Degree 1 file'); if filterindex==1 % file selected % Show the Directory and File in the textbox set(handles.EditDegree1, 'String', [InputPathname,InputFilename]); handles.PathDegree1=[InputPathname,InputFilename]; guidata(hObject, handles); else set(handles.CheckboxDegree1,'value',0); set(handles.EditDegree1, 'String', 'NAN'); end else set(handles.EditDegree1, 'String', 'NAN'); end function EditC20_Callback(hObject, eventdata, handles) function EditC20_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditC21S21_Callback(hObject, eventdata, handles) function EditC21S21_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditC22S22_Callback(hObject, eventdata, handles) function EditC22S22_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditDegree1_Callback(hObject, eventdata, handles) function EditDegree1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % Specify the Destriping method function RadiobuttonNonedestriping_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',1); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonSwenson_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',1); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonChambers2007_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',1); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonChambers2012_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',1); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonChenP3M6_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',1); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonChenP4M6_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',1); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonDuan_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',1); % Specify the GIA removed or not function RadiobuttonGIAnotRemoved_Callback(hObject, eventdata, handles) set(handles.RadiobuttonGIAnotRemoved, 'value', 1); set(handles.RadiobuttonGIARemovedGeru, 'value', 0); function RadiobuttonGIARemovedGeru_Callback(hObject, eventdata, handles) set(handles.RadiobuttonGIAnotRemoved, 'value', 0); set(handles.RadiobuttonGIARemovedGeru, 'value', 1); % Specify the Output Directory function PushbuttonOutputDirectory_Callback(hObject, eventdata, handles) OutputPathname= uigetdir('','Pick the output directory'); if OutputPathname==0 % set(handles.EditOutputDirectory, 'String', 'Output directry must be specified!!!'); warndlg('Output directry must be specified!!!','Warning'); else set(handles.EditOutputDirectory, 'String', OutputPathname); % show directory handles.OutputPathname=[OutputPathname,'/']; guidata(hObject, handles); end function EditOutputDirectory_Callback(hObject, eventdata, handles) function EditOutputDirectory_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % Specify the Output Format function EditOutputSHFilename_Callback(hObject, eventdata, handles) set(handles.RadiobuttonOutputFormatSH,'value',1); set(handles.RadiobuttonOutputFormatGrid1degree,'value',0); set(handles.RadiobuttonOutputFormatGrid025degree,'value',0); function EditOutputSHFilename_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditOutputGridFilename1degree_Callback(hObject, eventdata, handles) set(handles.RadiobuttonOutputFormatSH,'value',0); set(handles.RadiobuttonOutputFormatGrid1degree,'value',1); set(handles.RadiobuttonOutputFormatGrid025degree,'value',0); function EditOutputGridFilename1degree_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditOutputGridFilename025degree_Callback(hObject, eventdata, handles) set(handles.RadiobuttonOutputFormatSH,'value',0); set(handles.RadiobuttonOutputFormatGrid1degree,'value',0); set(handles.RadiobuttonOutputFormatGrid025degree,'value',1); function EditOutputGridFilename025degree_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function RadiobuttonOutputFormatSH_Callback(hObject, eventdata, handles) set(handles.EditOutputGridFilename1degree,'String',''); set(handles.EditOutputGridFilename025degree,'String',''); set(handles.RadiobuttonOutputFormatSH,'value',1); set(handles.RadiobuttonOutputFormatGrid1degree,'value',0); set(handles.RadiobuttonOutputFormatGrid025degree,'value',0); function RadiobuttonOutputFormatGrid1degree_Callback(hObject, eventdata, handles) set(handles.EditOutputSHFilename,'String',''); set(handles.EditOutputGridFilename025degree,'String',''); set(handles.RadiobuttonOutputFormatSH,'value',0); set(handles.RadiobuttonOutputFormatGrid1degree,'value',1); set(handles.RadiobuttonOutputFormatGrid025degree,'value',0); function RadiobuttonOutputFormatGrid025degree_Callback(hObject, eventdata, handles) set(handles.EditOutputSHFilename,'String',''); set(handles.EditOutputGridFilename1degree,'String',''); set(handles.RadiobuttonOutputFormatSH,'value',0); set(handles.RadiobuttonOutputFormatGrid1degree,'value',0); set(handles.RadiobuttonOutputFormatGrid025degree,'value',1); % Save the Control File function PushbuttonSaveControlFile_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,FilterIndex] = uiputfile('GMT_Control_File.txt','Save control file'); if FilterIndex==1 % file saved set(handles.EditSaveControlFile, 'String', [InputPathname,InputFilename]); set(handles.EditOpenControlFile, 'String', ''); handles.PathControlFile=[InputPathname,InputFilename]; guidata(hObject, handles); % Check the possible errors in Input Settings, Output Settings if isempty(get(handles.InputFileListbox,'String')) warndlg('Input files should be specified! Please select GRACE Level2 Files.','Warning'); return; end if isempty(get(handles.EditMaxDegreeOutput,'String')) warndlg('Maximun Output Degree should be specified!','Warning'); return; end if isnan(str2double(get(handles.EditMaxDegreeOutput,'String'))) warndlg('Maximun Output Degree should be a number!','Warning'); return; end if isempty(get(handles.EditFilterRadius,'String')) warndlg('Filter Radius should be specified!','Warning'); return; end if isnan(str2double(get(handles.EditFilterRadius,'String'))) warndlg('Gaussian Filter Radius should be a number!','Warning'); return; end if isempty(get(handles.EditOutputDirectory,'String')) warndlg('Output Directory should be specified!','Warning'); return; end if get(handles.RadiobuttonOutputFormatSH,'value') && isempty(get(handles.EditOutputSHFilename,'String')) warndlg('Name of SH output file should be specified!','Warning'); return; end if get(handles.RadiobuttonOutputFormatGrid1degree,'value') && isempty(get(handles.EditOutputGridFilename1degree,'String')) warndlg('Name of Grid output file should be specified!','Warning'); return; end if get(handles.RadiobuttonOutputFormatGrid025degree,'value') && isempty(get(handles.EditOutputGridFilename025degree,'String')) warndlg('Name of Grid output file should be specified!','Warning'); return; end % Get the destriping method option if get(handles.RadiobuttonNonedestriping,'value') option_destriping='NONE'; elseif get(handles.RadiobuttonSwenson,'value') option_destriping='SWENSON'; elseif get(handles.RadiobuttonChambers2007,'value') option_destriping='CHAMBERS2007'; elseif get(handles.RadiobuttonChambers2012,'value') option_destriping='CHAMBERS2012'; elseif get(handles.RadiobuttonChenP3M6,'value') option_destriping='CHENP3M6'; elseif get(handles.RadiobuttonChenP4M6,'value') option_destriping='CHENP4M6'; elseif get(handles.RadiobuttonDuan,'value') option_destriping='DUAN'; end % Get the GIA option if get(handles.RadiobuttonGIAnotRemoved,'value') option_gia='GIA_notRemoved'; elseif get(handles.RadiobuttonGIARemovedGeru,'value') option_gia='GIA_Removed_Geru'; end % Get the output format if get(handles.RadiobuttonOutputFormatSH,'value') OutputFileFormat=['SH_MAT ', get(handles.EditMaxDegreeOutput,'String'),' ', get(handles.EditOutputSHFilename,'String')]; elseif get(handles.RadiobuttonOutputFormatGrid1degree,'value') OutputFileFormat=['GRID_MAT ',get(handles.EditMaxDegreeOutput,'String'),' ',get(handles.EditOutputGridFilename1degree,'String'),' 1']; elseif get(handles.RadiobuttonOutputFormatGrid025degree,'value') OutputFileFormat=['GRID_MAT ',get(handles.EditMaxDegreeOutput,'String'),' ',get(handles.EditOutputGridFilename025degree,'String'),' 0.25']; end % Get the file extension and determine the format of input files handles.InputFilename=get(handles.InputFileListbox,'String'); if iscell(handles.InputFilename) % more than one input file [~, ~,FILE_TYPE]=fileparts([handles.InputPathname,handles.InputFilename{1}]); else % only one input file [~, ~,FILE_TYPE]=fileparts([handles.InputPathname,handles.InputFilename]); end if strcmp(FILE_TYPE,'.gfc') || strcmp(FILE_TYPE,'.GFC') InputFileFormat='ICGEM'; else InputFileFormat='GRACE'; end % Create Control File fid_write=fopen([InputPathname,InputFilename],'w'); if iscell(handles.InputFilename) % more than one input file fprintf(fid_write,'%d\n',length(handles.InputFilename)); else % only one input file fprintf(fid_write,'%d\n',1); end fprintf(fid_write,'%s\n',get(handles.EditFilterRadius,'String')); fprintf(fid_write,'%s\n',option_destriping); fprintf(fid_write,'%s\n',option_gia); fprintf(fid_write,'%s\n',InputFileFormat); fprintf(fid_write,'%s\n',OutputFileFormat); fprintf(fid_write,'%s\n',get(handles.EditC20, 'String')); fprintf(fid_write,'%s\n',get(handles.EditC21S21, 'String')); fprintf(fid_write,'%s\n',get(handles.EditC22S22, 'String')); fprintf(fid_write,'%s\n',get(handles.EditDegree1, 'String')); fprintf(fid_write,'%s\n',handles.InputPathname); fprintf(fid_write,'%s\n',strcat(get(handles.EditOutputDirectory,'String'),'/')); if iscell(handles.InputFilename) % more than one input file for jj=1:length(handles.InputFilename)-1 fprintf(fid_write,'%s',handles.InputFilename{jj}); fprintf(fid_write,'\n'); end fprintf(fid_write,'%s',handles.InputFilename{length(handles.InputFilename)}); fclose(fid_write); else % only one input file fprintf(fid_write,'%s',handles.InputFilename); fclose(fid_write); end end function EditSaveControlFile_Callback(hObject, eventdata, handles) function EditSaveControlFile_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % Read the Control File function PushbuttonOpenControlFile_Callback(hObject, eventdata, handles) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.*', 'All Files (*.*)'}, ... 'Pick control file'); if filterindex==1 % file selected % Show the Directory and File in the textbox set(handles.EditOpenControlFile, 'String', [InputPathname,InputFilename]); set(handles.EditSaveControlFile, 'String', ''); handles.PathControlFile=[InputPathname,InputFilename]; guidata(hObject, handles); % Update the data % Read the Control File fid=fopen(handles.PathControlFile,'r'); num_file = fscanf(fid,'%d',1); radius_filter = fscanf(fid,'%d',1); destrip_method = fscanf(fid,'%s',1); option_gia = fscanf(fid,'%s',1); InputFileFormat = fscanf(fid,'%s',1); OutputFileFormat_1= fscanf(fid,'%s',1); if strcmp(OutputFileFormat_1,'SH_MAT') OutputFileFormat_2= fscanf(fid,'%f',1); % max degree OutputFileFormat_3= fscanf(fid,'%s',1); % output name end if strcmp(OutputFileFormat_1,'GRID_MAT') OutputFileFormat_2= fscanf(fid,'%f',1); % max degree OutputFileFormat_3= fscanf(fid,'%s',1); % output name OutputFileFormat_4= fscanf(fid,'%f',1); % spatial resolution end dir_c20 = fscanf(fid,'%s',1); dir_c21_s21 = fscanf(fid,'%s',1); dir_c22_s22 = fscanf(fid,'%s',1); dir_degree_1 = fscanf(fid,'%s',1); dir_in = fscanf(fid,'%s',1); dir_out = fscanf(fid,'%s',1); file_name=cell(num_file,1);% Name list of input GRACE files for i = 1:num_file % read the name list of files in control file file_name{i} = fscanf(fid,'%s',1); end fclose(fid); handles.InputPathname=dir_in; % Show input files set(handles.InputFileListbox,'String',file_name); % Show C20 C21 S21 C22 S22 Degree 1 pathname if exist(dir_c20,'file') && ~strcmp(dir_c20,'NAN') set(handles.CheckboxC20,'Value',1); set(handles.EditC20,'String',dir_c20); end if exist(dir_c21_s21,'file') && ~strcmp(dir_c21_s21,'NAN') set(handles.CheckboxC21S21,'Value',1); set(handles.EditC21S21,'String',dir_c21_s21); end if exist(dir_c22_s22,'file') && ~strcmp(dir_c22_s22,'NAN') set(handles.CheckboxC22S22,'Value',1); set(handles.EditC22S22,'String',dir_c22_s22); end if exist(dir_degree_1,'file') && ~strcmp(dir_degree_1,'NAN') set(handles.CheckboxDegree1,'Value',1); set(handles.EditDegree1,'String',dir_degree_1); end % Show destriping option if strcmp(destrip_method,'NONE') set(handles.RadiobuttonNonedestriping,'Value',1); set(handles.RadiobuttonSwenson,'Value',0); set(handles.RadiobuttonChambers2007,'Value',0); set(handles.RadiobuttonChambers2012,'Value',0); set(handles.RadiobuttonChenP3M6,'Value',0); set(handles.RadiobuttonChenP4M6,'Value',0); set(handles.RadiobuttonDuan,'Value',0); elseif strcmp(destrip_method,'SWENSON') set(handles.RadiobuttonNonedestriping,'Value',0); set(handles.RadiobuttonSwenson,'Value',1); set(handles.RadiobuttonChambers2007,'Value',0); set(handles.RadiobuttonChambers2012,'Value',0); set(handles.RadiobuttonChenP3M6,'Value',0); set(handles.RadiobuttonChenP4M6,'Value',0); set(handles.RadiobuttonDuan,'Value',0); elseif strcmp(destrip_method,'CHAMBERS2007') set(handles.RadiobuttonNonedestriping,'Value',0); set(handles.RadiobuttonSwenson,'Value',0); set(handles.RadiobuttonChambers2007,'Value',1); set(handles.RadiobuttonChambers2012,'Value',0); set(handles.RadiobuttonChenP3M6,'Value',0); set(handles.RadiobuttonChenP4M6,'Value',0); set(handles.RadiobuttonDuan,'Value',0); elseif strcmp(destrip_method,'CHAMBERS2012') set(handles.RadiobuttonNonedestriping,'Value',0); set(handles.RadiobuttonSwenson,'Value',0); set(handles.RadiobuttonChambers2007,'Value',0); set(handles.RadiobuttonChambers2012,'Value',1); set(handles.RadiobuttonChenP3M6,'Value',0); set(handles.RadiobuttonChenP4M6,'Value',0); set(handles.RadiobuttonDuan,'Value',0); elseif strcmp(destrip_method,'CHENP3M6') set(handles.RadiobuttonNonedestriping,'Value',0); set(handles.RadiobuttonSwenson,'Value',0); set(handles.RadiobuttonChambers2007,'Value',0); set(handles.RadiobuttonChambers2012,'Value',0); set(handles.RadiobuttonChenP3M6,'Value',1); set(handles.RadiobuttonChenP4M6,'Value',0); set(handles.RadiobuttonDuan,'Value',0); elseif strcmp(destrip_method,'CHENP4M6') set(handles.RadiobuttonNonedestriping,'Value',0); set(handles.RadiobuttonSwenson,'Value',0); set(handles.RadiobuttonChambers2007,'Value',0); set(handles.RadiobuttonChambers2012,'Value',0); set(handles.RadiobuttonChenP3M6,'Value',0); set(handles.RadiobuttonChenP4M6,'Value',1); set(handles.RadiobuttonDuan,'Value',0); elseif strcmp(destrip_method,'DUAN') set(handles.RadiobuttonNonedestriping,'Value',0); set(handles.RadiobuttonSwenson,'Value',0); set(handles.RadiobuttonChambers2007,'Value',0); set(handles.RadiobuttonChambers2012,'Value',0); set(handles.RadiobuttonChenP3M6,'Value',0); set(handles.RadiobuttonChenP4M6,'Value',0); set(handles.RadiobuttonDuan,'Value',1); end % Show GIA option if strcmp(option_gia,'GIA_notRemoved') set(handles.RadiobuttonGIAnotRemoved,'Value',1); set(handles.RadiobuttonGIARemovedGeru,'Value',0); elseif strcmp(option_gia,'GIA_Removed_Geru') set(handles.RadiobuttonGIAnotRemoved,'Value',0); set(handles.RadiobuttonGIARemovedGeru,'Value',1); end % Show filter radius set(handles.EditFilterRadius,'string',radius_filter); % Show output directory if exist(dir_out,'dir') set(handles.EditOutputDirectory,'String',dir_out); end % Show output format if strcmp(OutputFileFormat_1,'SH_MAT') set(handles.RadiobuttonOutputFormatSH,'value',1); set(handles.RadiobuttonOutputFormatGrid1degree,'value',0); set(handles.RadiobuttonOutputFormatGrid025degree,'value',0); set(handles.EditMaxDegreeOutput,'String',OutputFileFormat_2); set(handles.EditOutputSHFilename,'String',OutputFileFormat_3); elseif strcmp(OutputFileFormat_1,'GRID_MAT') && OutputFileFormat_4==1 set(handles.RadiobuttonOutputFormatSH,'value',0); set(handles.RadiobuttonOutputFormatGrid1degree,'value',1); set(handles.RadiobuttonOutputFormatGrid025degree,'value',0); set(handles.EditMaxDegreeOutput,'String',OutputFileFormat_2); set(handles.EditOutputGridFilename1degree,'String',OutputFileFormat_3); elseif strcmp(OutputFileFormat_1,'GRID_MAT') && OutputFileFormat_4==0.25 set(handles.RadiobuttonOutputFormatSH,'value',0); set(handles.RadiobuttonOutputFormatGrid1degree,'value',0); set(handles.RadiobuttonOutputFormatGrid025degree,'value',1); set(handles.EditMaxDegreeOutput,'String',OutputFileFormat_2); set(handles.EditOutputGridFilename025degree,'String',OutputFileFormat_3); end guidata(hObject, handles); end function EditOpenControlFile_Callback(hObject, eventdata, handles) function EditOpenControlFile_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
github
fengweiigg/GRACE_Matlab_Toolbox-master
GRACE_Matlab_Toolbox_HarmonicAnalysis.m
.m
GRACE_Matlab_Toolbox-master/GRACE_Matlab_Toolbox_HarmonicAnalysis.m
22,263
utf_8
160d792627938e5f0f3ba354c01c48a6
function varargout = GRACE_Matlab_Toolbox_HarmonicAnalysis(varargin) % GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS MATLAB code for GRACE_Matlab_Toolbox_HarmonicAnalysis.fig % GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS, by itself, creates a new GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS or raises the existing % singleton*. % % H = GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS returns the handle to a new GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS or the handle to % the existing singleton*. % % GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS.M with the given input arguments. % % GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS('Property','Value',...) creates a new GRACE_MATLAB_TOOLBOX_HARMONICANALYSIS or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GRACE_Matlab_Toolbox_HarmonicAnalysis_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GRACE_Matlab_Toolbox_HarmonicAnalysis_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GRACE_Matlab_Toolbox_HarmonicAnalysis % Last Modified by GUIDE v2.5 25-Mar-2015 21:59:55 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GRACE_Matlab_Toolbox_HarmonicAnalysis_OpeningFcn, ... 'gui_OutputFcn', @GRACE_Matlab_Toolbox_HarmonicAnalysis_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before GRACE_Matlab_Toolbox_HarmonicAnalysis is made visible. function GRACE_Matlab_Toolbox_HarmonicAnalysis_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GRACE_Matlab_Toolbox_HarmonicAnalysis (see VARARGIN) % Choose default command line output for GRACE_Matlab_Toolbox_HarmonicAnalysis handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GRACE_Matlab_Toolbox_HarmonicAnalysis wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = GRACE_Matlab_Toolbox_HarmonicAnalysis_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function EditOpenSeries_Callback(hObject, eventdata, handles) % hObject handle to EditOpenSeries (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditOpenSeries as text % str2double(get(hObject,'String')) returns contents of EditOpenSeries as a double % --- Executes during object creation, after setting all properties. function EditOpenSeries_CreateFcn(hObject, eventdata, handles) % hObject handle to EditOpenSeries (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in PushbuttonOpenSeries. function PushbuttonOpenSeries_Callback(hObject, eventdata, handles) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.mat','Matlab-files (*.mat)'}, ... 'Pick series file'); if filterindex==1 % file selected set(handles.EditOpenSeries,'string',strcat(InputPathname,InputFilename)); [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') load(strcat(InputPathname,InputFilename)); if exist('time_series_grace','var') time_series=time_series_grace; end if ~exist('time_series','var') warndlg('There is no ''time_series'' or ''time_series_grace'' variable in .mat file!','Warning'); return; end if exist('time_grace','var') time=time_grace; end if ~exist('time','var') warndlg('There is no ''time'' or ''time_grace'' variable in .mat file!','Warning'); return; end grid_data(1,1,:)=time_series; [ Amplitude1, Amplitude1_std, Phase1,Phase1_std, Amplitude2,... Amplitude2_std, Phase2, Phase2_std, Trend, Trend_std,... ~, ~, ~] = gmt_harmonic(time,[],grid_data); set(handles.EditAnnualAmplitude,'string',strcat(num2str(Amplitude1,'%3.2e'),'+/-',num2str(Amplitude1_std,'%3.2e'))); set(handles.EditAnnualPhase,'string',strcat(num2str(Phase1,'%4.1f'),'+/-',num2str(Phase1_std,'%4.1f'))); set(handles.EditSemiannualAmplitude,'string',strcat(num2str(Amplitude2,'%3.2e'),'+/-',num2str(Amplitude2_std,'%3.2e'))); set(handles.EditSemiannualPhase,'string',strcat(num2str(Phase2,'%4.1f'),'+/-',num2str(Phase2_std,'%4.1f'))); set(handles.EditTrend,'string',strcat(num2str(Trend,'%3.2e'),'+/-',num2str(Trend_std,'%3.2e'))); end end function EditAnnualAmplitude_Callback(hObject, eventdata, handles) % hObject handle to EditAnnualAmplitude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditAnnualAmplitude as text % str2double(get(hObject,'String')) returns contents of EditAnnualAmplitude as a double % --- Executes during object creation, after setting all properties. function EditAnnualAmplitude_CreateFcn(hObject, eventdata, handles) % hObject handle to EditAnnualAmplitude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditSemiannualAmplitude_Callback(hObject, eventdata, handles) % hObject handle to EditSemiannualAmplitude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditSemiannualAmplitude as text % str2double(get(hObject,'String')) returns contents of EditSemiannualAmplitude as a double % --- Executes during object creation, after setting all properties. function EditSemiannualAmplitude_CreateFcn(hObject, eventdata, handles) % hObject handle to EditSemiannualAmplitude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditTrend_Callback(hObject, eventdata, handles) % hObject handle to EditTrend (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditTrend as text % str2double(get(hObject,'String')) returns contents of EditTrend as a double % --- Executes during object creation, after setting all properties. function EditTrend_CreateFcn(hObject, eventdata, handles) % hObject handle to EditTrend (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditAnnualPhase_Callback(hObject, eventdata, handles) % hObject handle to EditAnnualPhase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditAnnualPhase as text % str2double(get(hObject,'String')) returns contents of EditAnnualPhase as a double % --- Executes during object creation, after setting all properties. function EditAnnualPhase_CreateFcn(hObject, eventdata, handles) % hObject handle to EditAnnualPhase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditSemiannualPhase_Callback(hObject, eventdata, handles) % hObject handle to EditSemiannualPhase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditSemiannualPhase as text % str2double(get(hObject,'String')) returns contents of EditSemiannualPhase as a double % --- Executes during object creation, after setting all properties. function EditSemiannualPhase_CreateFcn(hObject, eventdata, handles) % hObject handle to EditSemiannualPhase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditSaveSemiannualphase_Callback(hObject, eventdata, handles) % hObject handle to EditSaveSemiannualphase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditSaveSemiannualphase as text % str2double(get(hObject,'String')) returns contents of EditSaveSemiannualphase as a double % --- Executes during object creation, after setting all properties. function EditSaveSemiannualphase_CreateFcn(hObject, eventdata, handles) % hObject handle to EditSaveSemiannualphase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditSaveAnnualphase_Callback(hObject, eventdata, handles) % hObject handle to EditSaveAnnualphase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditSaveAnnualphase as text % str2double(get(hObject,'String')) returns contents of EditSaveAnnualphase as a double % --- Executes during object creation, after setting all properties. function EditSaveAnnualphase_CreateFcn(hObject, eventdata, handles) % hObject handle to EditSaveAnnualphase (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditSaveTrend_Callback(hObject, eventdata, handles) % hObject handle to EditSaveTrend (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditSaveTrend as text % str2double(get(hObject,'String')) returns contents of EditSaveTrend as a double % --- Executes during object creation, after setting all properties. function EditSaveTrend_CreateFcn(hObject, eventdata, handles) % hObject handle to EditSaveTrend (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditSaveSemiannualamplitude_Callback(hObject, eventdata, handles) % hObject handle to EditSaveSemiannualamplitude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditSaveSemiannualamplitude as text % str2double(get(hObject,'String')) returns contents of EditSaveSemiannualamplitude as a double % --- Executes during object creation, after setting all properties. function EditSaveSemiannualamplitude_CreateFcn(hObject, eventdata, handles) % hObject handle to EditSaveSemiannualamplitude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditSaveAnnualamplitude_Callback(hObject, eventdata, handles) % hObject handle to EditSaveAnnualamplitude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditSaveAnnualamplitude as text % str2double(get(hObject,'String')) returns contents of EditSaveAnnualamplitude as a double % --- Executes during object creation, after setting all properties. function EditSaveAnnualamplitude_CreateFcn(hObject, eventdata, handles) % hObject handle to EditSaveAnnualamplitude (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in PushbuttonOpenGrid. function PushbuttonOpenGrid_Callback(hObject, eventdata, handles) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.mat','Matlab-files (*.mat)'}, ... 'Pick grid file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') load(strcat(InputPathname,InputFilename)); if exist('grid_data_grace','var')% there is 'cs_grace' variable in SH mat files handles.grid_data=grid_data_grace; elseif exist('grid_data','var') % no 'cs' variable in SH mat files handles.grid_data=grid_data; else warndlg('There is no ''grid_data'' or ''grid_data_grace'' variable in .mat file!','Warning'); return; end if exist('time','var') handles.time=time; elseif exist('time_grace','var') handles.time=time_grace; else warndlg('There is no ''time'' or ''time_grace'' variable in .mat file!','Warning'); return; end if exist('str_year','var') handles.str_year=str_year; end if exist('str_month','var') handles.str_month=str_month; end end guidata(hObject,handles); set(handles.EditOpenGrid,'String',strcat(InputPathname,InputFilename)); end function EditOpenGrid_Callback(hObject, eventdata, handles) % hObject handle to EditOpenGrid (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditOpenGrid as text % str2double(get(hObject,'String')) returns contents of EditOpenGrid as a double % --- Executes during object creation, after setting all properties. function EditOpenGrid_CreateFcn(hObject, eventdata, handles) % hObject handle to EditOpenGrid (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Save Annual amplitude --- function PushbuttonSaveAnnualamplitude_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,filterindex] = uiputfile('annual_amplitude.mat','Save annual amplitude file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') set(handles.EditSaveAnnualamplitude,'String',strcat(InputPathname,InputFilename)); end end % --- Save Annual phase --- function PushbuttonSaveAnnualphase_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,filterindex] = uiputfile('annual_phase.mat','Save annual phase file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') set(handles.EditSaveAnnualphase,'String',strcat(InputPathname,InputFilename)); end end % --- Save Semiannual amplitude --- function PushbuttonSaveSemiannualamplitude_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,filterindex] = uiputfile('semiannual_amplitude.mat','Save semi-annual amplitude file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') set(handles.EditSaveSemiannualamplitude,'String',strcat(InputPathname,InputFilename)); end end % --- Save Semiannual phase --- function PushbuttonSaveSemiannualphase_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,filterindex] = uiputfile('semiannual_phase.mat','Save semi-annual phase file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') set(handles.EditSaveSemiannualphase,'String',strcat(InputPathname,InputFilename)); end end % --- Save Trend --- function PushbuttonSaveTrend_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,filterindex] = uiputfile('trend.mat','Save trend file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') set(handles.EditSaveTrend,'String',strcat(InputPathname,InputFilename)); end end % --- Executes on button press in PushbuttonCalculate. function PushbuttonCalculate_Callback(hObject, eventdata, handles) hh=msgbox('Spatial Harmonic Analysis is in processing.'); pause(0.3); close(hh); [ Amplitude1, Amplitude1_std, Phase1,Phase1_std, Amplitude2,... Amplitude2_std, Phase2, Phase2_std, Trend, Trend_std,... ~, ~, ~] = gmt_harmonic(handles.time,[],handles.grid_data); if ~isempty(get(handles.EditSaveAnnualamplitude,'string')) annual_amplitude=Amplitude1; save(get(handles.EditSaveAnnualamplitude,'string'),'annual_amplitude'); end if ~isempty(get(handles.EditSaveAnnualphase,'string')) annual_phase=Phase1; save(get(handles.EditSaveAnnualphase,'string'),'annual_phase'); end if ~isempty(get(handles.EditSaveSemiannualamplitude,'string')) semiannual_amplitude=Amplitude2; save(get(handles.EditSaveSemiannualamplitude,'string'),'semiannual_amplitude'); end if ~isempty(get(handles.EditSaveSemiannualphase,'string')) semiannual_phase=Phase2; save(get(handles.EditSaveSemiannualphase,'string'),'semiannual_phase'); end if ~isempty(get(handles.EditSaveTrend,'string')) trend=Trend; save(get(handles.EditSaveTrend,'string'),'trend'); end hh=msgbox('Spatial harmonic analysis is done.'); pause(1); close(hh);
github
fengweiigg/GRACE_Matlab_Toolbox-master
GRACE_Matlab_Toolbox_SHGrid.m
.m
GRACE_Matlab_Toolbox-master/GRACE_Matlab_Toolbox_SHGrid.m
10,513
utf_8
034ca5e2ececb7735df50033a84e4717
function varargout = GRACE_Matlab_Toolbox_SHGrid(varargin) % GRACE_MATLAB_TOOLBOX_SHGRID MATLAB code for GRACE_Matlab_Toolbox_SHGrid.fig % GRACE_MATLAB_TOOLBOX_SHGRID, by itself, creates a new GRACE_MATLAB_TOOLBOX_SHGRID or raises the existing % singleton*. % % H = GRACE_MATLAB_TOOLBOX_SHGRID returns the handle to a new GRACE_MATLAB_TOOLBOX_SHGRID or the handle to % the existing singleton*. % % GRACE_MATLAB_TOOLBOX_SHGRID('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GRACE_MATLAB_TOOLBOX_SHGRID.M with the given input arguments. % % GRACE_MATLAB_TOOLBOX_SHGRID('Property','Value',...) creates a new GRACE_MATLAB_TOOLBOX_SHGRID or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GRACE_Matlab_Toolbox_SHGrid_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GRACE_Matlab_Toolbox_SHGrid_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GRACE_Matlab_Toolbox_SHGrid % Last Modified by GUIDE v2.5 24-Mar-2015 16:22:39 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GRACE_Matlab_Toolbox_SHGrid_OpeningFcn, ... 'gui_OutputFcn', @GRACE_Matlab_Toolbox_SHGrid_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT end % --- Executes just before GRACE_Matlab_Toolbox_SHGrid is made visible. function GRACE_Matlab_Toolbox_SHGrid_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GRACE_Matlab_Toolbox_SHGrid (see VARARGIN) % Choose default command line output for GRACE_Matlab_Toolbox_SHGrid handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GRACE_Matlab_Toolbox_SHGrid wait for user response (see UIRESUME) % uiwait(handles.figure1); end % --- Outputs from this function are returned to the command line. function varargout = GRACE_Matlab_Toolbox_SHGrid_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; end % --- Open SH coefficients file --- function PushbuttonOpenSH_Callback(hObject, eventdata, handles) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.mat','Matlab-files (*.mat)'; ... '*.gfc','ICGEM-files (*.gfc)'}, ... 'Pick SH coefficients file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.gfc') || strcmp(FILE_TYPE,'.GFC') [cs,~]=gmt_readgfc(strcat(InputPathname,InputFilename)); elseif strcmp(FILE_TYPE,'.mat') load(strcat(InputPathname,InputFilename)); if exist('cs_grace','var')% there is 'cs_grace' variable in SH mat files handles.cs=cs_grace; elseif exist('cs','var') handles.cs=cs; else warndlg('There is no SH coefficients variable ''cs'' or ''cs_grace'' in .mat file!','Warning'); end if exist('time','var') handles.time=time; end if exist('time_grace','var') handles.time=time_grace; end if exist('str_year','var') handles.str_year=str_year; end if exist('str_month','var') handles.str_month=str_month; end else warndlg('Input file format is wrong!','Warning'); end guidata(hObject,handles); set(handles.EditOpenSH,'String',strcat(InputPathname,InputFilename)); end end % --- Save Grid file --- function PushbuttonSaveGrid_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,FilterIndex] = uiputfile('grid_data.mat','Save grid file'); if get(handles.Radiobutton1Degree,'value') type=1; else type=0.25; end if FilterIndex==1 && isfield(handles,'cs')% create output file if there's input file set(handles.EditSaveGrid,'string',strcat(InputPathname,InputFilename)); hh=msgbox('Sphercial Harmonic Synthesis is in processing.'); pause(0.3); close(hh); grid_data=gmt_cs2grid(handles.cs,0,type); save(strcat(InputPathname, InputFilename),'grid_data'); % add other variables if they are in input SH file *.mat if isfield(handles,'str_year') % whether str_year exists in handles str_year= handles.str_year; save(strcat(InputPathname, InputFilename),'-append','str_year'); end if isfield(handles,'str_month') str_month= handles.str_month; save(strcat(InputPathname, InputFilename),'-append','str_month'); end if isfield(handles,'time') time= handles.time; save(strcat(InputPathname, InputFilename),'-append','time'); end hh=msgbox('Spherical Harmonic Synthesis is done.'); pause(0.5); close(hh); end end % --- Open Grid file --- function PushbuttonOpenGrid_Callback(hObject, eventdata, handles) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.mat','Matlab-files (*.mat)'}, ... 'Pick grid file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') load(strcat(InputPathname,InputFilename)); if exist('grid_data_grace','var')% there is 'cs_grace' variable in SH mat files handles.grid_data=grid_data_grace; elseif exist('grid_data','var') % no 'cs' variable in SH mat files handles.grid_data=grid_data; else warndlg('There is no ''grid_data'' or ''grid_data_grace'' variable in .mat file!','Warning'); end if exist('time','var') handles.time=time; end if exist('time_grace','var') handles.time=time_grace; end if exist('str_year','var') handles.str_year=str_year; end if exist('str_month','var') handles.str_month=str_month; end end guidata(hObject,handles); set(handles.EditOpenGrid,'String',strcat(InputPathname,InputFilename)); end end % --- Save SH coefficents file --- function PushbuttonSaveSH_Callback(hObject, eventdata, handles) degree_max=str2double(get(handles.EditMaxDegree,'string')); if isnan(degree_max) || degree_max~=fix(degree_max) % not integer warndlg('Input maximum degree is wrong!','Warning'); return; end [InputFilename,InputPathname,FilterIndex] = uiputfile('cs.mat','Save SH coefficients file'); if FilterIndex==1 && isfield(handles,'grid_data') % create output file set(handles.EditSaveSH,'string',strcat(InputPathname,InputFilename)); hh=msgbox('Spherical Harmonic Analysis is in processing.'); pause(0.3); close(hh); cs=gmt_grid2cs(handles.grid_data,degree_max); save(strcat(InputPathname, InputFilename),'cs'); % add other variables if they are in input SH file *.mat if isfield(handles,'str_year') % whether str_year exists in handles str_year= handles.str_year; save(strcat(InputPathname, InputFilename),'-append','str_year'); end if isfield(handles,'str_month') str_month= handles.str_month; save(strcat(InputPathname, InputFilename),'-append','str_month'); end if isfield(handles,'time') time= handles.time; save(strcat(InputPathname, InputFilename),'-append','time'); end hh=msgbox('Spherical Harmonic Analysis is done.'); pause(0.5); close(hh); end end function Radiobutton1Degree_Callback(hObject, eventdata, handles) set(handles.Radiobutton1Degree,'value',1); set(handles.Radiobutton025Degree,'value',0); end function Radiobutton025Degree_Callback(hObject, eventdata, handles) set(handles.Radiobutton1Degree,'value',0); set(handles.Radiobutton025Degree,'value',1); end function EditOpenSH_Callback(hObject, eventdata, handles) end function EditOpenSH_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end end function EditSaveGrid_Callback(hObject, eventdata, handles) end function EditSaveGrid_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end end function EditOpenGrid_Callback(hObject, eventdata, handles) end function EditOpenGrid_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end end function EditSaveSH_Callback(hObject, eventdata, handles) end function EditSaveSH_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end end function EditMaxDegree_Callback(hObject, eventdata, handles) end function EditMaxDegree_CreateFcn(hObject, eventdata, handles) % hObject handle to EditMaxDegree (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end end
github
fengweiigg/GRACE_Matlab_Toolbox-master
GRACE_Matlab_Toolbox_LeakageReductionSpatial.m
.m
GRACE_Matlab_Toolbox-master/GRACE_Matlab_Toolbox_LeakageReductionSpatial.m
12,935
utf_8
1347aa0cb7a59cc3b4ee3bce77b0377e
function varargout = GRACE_Matlab_Toolbox_LeakageReductionSpatial(varargin) % GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL MATLAB code for GRACE_Matlab_Toolbox_LeakageReductionSpatial.fig % GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL, by itself, creates a new GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL or raises the existing % singleton*. % % H = GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL returns the handle to a new GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL or the handle to % the existing singleton*. % % GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL.M with the given input arguments. % % GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL('Property','Value',...) creates a new GRACE_MATLAB_TOOLBOX_LEAKAGEREDUCTIONSPATIAL or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GRACE_Matlab_Toolbox_LeakageReductionSpatial_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GRACE_Matlab_Toolbox_LeakageReductionSpatial_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GRACE_Matlab_Toolbox_LeakageReductionSpatial % Last Modified by GUIDE v2.5 05-Sep-2015 17:37:21 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GRACE_Matlab_Toolbox_LeakageReductionSpatial_OpeningFcn, ... 'gui_OutputFcn', @GRACE_Matlab_Toolbox_LeakageReductionSpatial_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before GRACE_Matlab_Toolbox_LeakageReductionSpatial is made visible. function GRACE_Matlab_Toolbox_LeakageReductionSpatial_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GRACE_Matlab_Toolbox_LeakageReductionSpatial (see VARARGIN) % Choose default command line output for GRACE_Matlab_Toolbox_LeakageReductionSpatial handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GRACE_Matlab_Toolbox_LeakageReductionSpatial wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = GRACE_Matlab_Toolbox_LeakageReductionSpatial_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function EditOpenSH_Callback(hObject, eventdata, handles) % hObject handle to EditOpenSH (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditOpenSH as text % str2double(get(hObject,'String')) returns contents of EditOpenSH as a double % --- Executes during object creation, after setting all properties. function EditOpenSH_CreateFcn(hObject, eventdata, handles) % hObject handle to EditOpenSH (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in PushbuttonOpenSH. function PushbuttonOpenSH_Callback(hObject, eventdata, handles) % hObject handle to PushbuttonOpenSH (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.mat','Matlab-files (*.mat)'; ... '*.gfc','ICGEM-files (*.gfc)'}, ... 'Pick SH coefficients file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.gfc') || strcmp(FILE_TYPE,'.GFC') [cs,~]=gmt_readgfc(strcat(InputPathname,InputFilename)); elseif strcmp(FILE_TYPE,'.mat') load(strcat(InputPathname,InputFilename)); if exist('cs_grace','var')% there is 'cs_grace' variable in SH mat files handles.cs=cs_grace; elseif exist('cs','var') handles.cs=cs; else warndlg('There is no SH coefficients variable ''cs'' or ''cs_grace'' in .mat file!','Warning'); end if exist('time','var') handles.time=time; end if exist('time_grace','var') handles.time=time_grace; end if exist('str_year','var') handles.str_year=str_year; end if exist('str_month','var') handles.str_month=str_month; end else warndlg('Input file format is wrong!','Warning'); end guidata(hObject,handles); set(handles.EditOpenSH,'String',strcat(InputPathname,InputFilename)); end function EditSaveSH_Callback(hObject, eventdata, handles) % hObject handle to EditSaveSH (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditSaveSH as text % str2double(get(hObject,'String')) returns contents of EditSaveSH as a double % --- Executes during object creation, after setting all properties. function EditSaveSH_CreateFcn(hObject, eventdata, handles) % hObject handle to EditSaveSH (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in PushbuttonSaveSH. function PushbuttonSaveSH_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,FilterIndex] = uiputfile('cs_leakage_removed.mat','Save SH coefficients file'); if FilterIndex==1 && isfield(handles,'cs') % create output file set(handles.EditSaveSH,'string',strcat(InputPathname,InputFilename)); hh=msgbox('Leakage reduction in spatial domain is in processing.'); pause(0.3); close(hh); % Processing leakage reduction % cs=gmt_grid2cs(handles.grid_data,degree_max); % Get leakage reduction method if get(handles.RadiobuttonOceanLeakageReduction,'value') type='ocean'; else type='land'; end % Get the destriping method option if get(handles.RadiobuttonNonedestriping,'value') option_destriping='NONE'; elseif get(handles.RadiobuttonSwenson,'value') option_destriping='SWENSON'; elseif get(handles.RadiobuttonChambers2007,'value') option_destriping='CHAMBERS2007'; elseif get(handles.RadiobuttonChambers2012,'value') option_destriping='CHAMBERS2012'; elseif get(handles.RadiobuttonChenP3M6,'value') option_destriping='CHENP3M6'; elseif get(handles.RadiobuttonChenP4M6,'value') option_destriping='CHENP4M6'; elseif get(handles.RadiobuttonDuan,'value') option_destriping='DUAN'; end radius_filter=str2double(get(handles.EditFilterRadius,'String')); cs=gmt_cs2leakagefreecs(handles.cs,type,option_destriping,radius_filter); save(strcat(InputPathname, InputFilename),'cs'); % add other variables if they are in input SH file *.mat if isfield(handles,'str_year') % whether str_year exists in handles str_year= handles.str_year; save(strcat(InputPathname, InputFilename),'-append','str_year'); end if isfield(handles,'str_month') str_month= handles.str_month; save(strcat(InputPathname, InputFilename),'-append','str_month'); end if isfield(handles,'time') time= handles.time; save(strcat(InputPathname, InputFilename),'-append','time'); end hh=msgbox('Leakage reduction in spatial domain is done.'); pause(0.5); close(hh); end % --- Executes on button press in RadiobuttonOceanLeakageReduction. function RadiobuttonOceanLeakageReduction_Callback(hObject, eventdata, handles) set(handles.RadiobuttonOceanLeakageReduction,'value',1); set(handles.RadiobuttonLandLeakageReduction,'value',0); % --- Executes on button press in RadiobuttonLandLeakageReduction. function RadiobuttonLandLeakageReduction_Callback(hObject, eventdata, handles) set(handles.RadiobuttonOceanLeakageReduction,'value',0); set(handles.RadiobuttonLandLeakageReduction,'value',1); % Specify the Destriping method function RadiobuttonNonedestriping_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',1); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonSwenson_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',1); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonChambers2007_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',1); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonChambers2012_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',1); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonChenP3M6_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',1); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonChenP4M6_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',1); set(handles.RadiobuttonDuan,'value',0); function RadiobuttonDuan_Callback(hObject, eventdata, handles) set(handles.RadiobuttonNonedestriping,'value',0); set(handles.RadiobuttonSwenson,'value',0); set(handles.RadiobuttonChambers2007,'value',0); set(handles.RadiobuttonChambers2012,'value',0); set(handles.RadiobuttonChenP3M6,'value',0); set(handles.RadiobuttonChenP4M6,'value',0); set(handles.RadiobuttonDuan,'value',1); function EditFilterRadius_Callback(hObject, eventdata, handles) guidata(hObject, handles); function EditFilterRadius_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
github
fengweiigg/GRACE_Matlab_Toolbox-master
GRACE_Matlab_Toolbox_Grid2Series.m
.m
GRACE_Matlab_Toolbox-master/GRACE_Matlab_Toolbox_Grid2Series.m
10,462
utf_8
2af44185348673e29b28f1c5effed356
function varargout = GRACE_Matlab_Toolbox_Grid2Series(varargin) % GRACE_MATLAB_TOOLBOX_GRID2SERIES MATLAB code for GRACE_Matlab_Toolbox_Grid2Series.fig % GRACE_MATLAB_TOOLBOX_GRID2SERIES, by itself, creates a new GRACE_MATLAB_TOOLBOX_GRID2SERIES or raises the existing % singleton*. % % H = GRACE_MATLAB_TOOLBOX_GRID2SERIES returns the handle to a new GRACE_MATLAB_TOOLBOX_GRID2SERIES or the handle to % the existing singleton*. % % GRACE_MATLAB_TOOLBOX_GRID2SERIES('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GRACE_MATLAB_TOOLBOX_GRID2SERIES.M with the given input arguments. % % GRACE_MATLAB_TOOLBOX_GRID2SERIES('Property','Value',...) creates a new GRACE_MATLAB_TOOLBOX_GRID2SERIES or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GRACE_Matlab_Toolbox_Grid2Series_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GRACE_Matlab_Toolbox_Grid2Series_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GRACE_Matlab_Toolbox_Grid2Series % Last Modified by GUIDE v2.5 24-Mar-2015 18:05:04 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GRACE_Matlab_Toolbox_Grid2Series_OpeningFcn, ... 'gui_OutputFcn', @GRACE_Matlab_Toolbox_Grid2Series_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before GRACE_Matlab_Toolbox_Grid2Series is made visible. function GRACE_Matlab_Toolbox_Grid2Series_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GRACE_Matlab_Toolbox_Grid2Series (see VARARGIN) % Choose default command line output for GRACE_Matlab_Toolbox_Grid2Series handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GRACE_Matlab_Toolbox_Grid2Series wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = GRACE_Matlab_Toolbox_Grid2Series_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function EditInputGrid_Callback(hObject, eventdata, handles) % hObject handle to EditInputGrid (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of EditInputGrid as text % str2double(get(hObject,'String')) returns contents of EditInputGrid as a double % --- Executes during object creation, after setting all properties. function EditInputGrid_CreateFcn(hObject, eventdata, handles) % hObject handle to EditInputGrid (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Open Grid file --- function PushbuttonInputGrid_Callback(hObject, eventdata, handles) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.mat','Matlab-files (*.mat)'}, ... 'Pick grid file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') load(strcat(InputPathname,InputFilename)); if exist('grid_data_grace','var')% there is 'cs_grace' variable in SH mat files handles.grid_data=grid_data_grace; elseif exist('grid_data','var') % no 'cs' variable in SH mat files handles.grid_data=grid_data; else warndlg('There is no ''grid_data'' or ''grid_data_grace'' variable in .mat file!','Warning'); end if exist('time','var') handles.time=time; end if exist('time_grace','var') handles.time=time_grace; end if exist('str_year','var') handles.str_year=str_year; end if exist('str_month','var') handles.str_month=str_month; end end guidata(hObject,handles); set(handles.EditInputGrid,'String',strcat(InputPathname,InputFilename)); end % --- Open boundary file --- function PushbuttonBoundaryFile_Callback(hObject, eventdata, handles) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.bln','Boundary-files (*.bln)'}, ... 'Pick boundary file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.bln') handles.boundaryfile=strcat(InputPathname,InputFilename); end guidata(hObject,handles); set(handles.EditBoundaryFile,'String',strcat(InputPathname,InputFilename)); end % --- Open mask file --- function PushbuttonMaskFile_Callback(hObject, eventdata, handles) [InputFilename, InputPathname, filterindex] = uigetfile( ... {'*.*','All files (*.*)'}, ... 'Pick mask file'); if filterindex==1 % file selected % [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); % if strcmp(FILE_TYPE,'.bln') handles.boundaryfile=strcat(InputPathname,InputFilename); % end guidata(hObject,handles); set(handles.EditMaskFile,'String',strcat(InputPathname,InputFilename)); end function RadiobuttonBoundaryfile_Callback(hObject, eventdata, handles) set(handles.RadiobuttonBoundaryfile,'value',1); set(handles.RadiobuttonMaskfile,'value',0); function RadiobuttonMaskfile_Callback(hObject, eventdata, handles) set(handles.RadiobuttonBoundaryfile,'value',0); set(handles.RadiobuttonMaskfile,'value',1); function EditBoundaryFile_Callback(hObject, eventdata, handles) function EditBoundaryFile_CreateFcn(hObject, eventdata, handles) % hObject handle to EditBoundaryFile (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function EditMaskFile_Callback(hObject, eventdata, handles) function EditMaskFile_CreateFcn(hObject, eventdata, handles) % hObject handle to EditMaskFile (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Save series file --- function PushbuttonOutputSeries_Callback(hObject, eventdata, handles) [InputFilename,InputPathname,filterindex] = uiputfile('time_series.mat','Save time series file'); if filterindex==1 % file selected [~,~,FILE_TYPE]=fileparts(strcat(InputPathname,InputFilename)); if strcmp(FILE_TYPE,'.mat') set(handles.EditOutputSeries,'String',strcat(InputPathname,InputFilename)); hh=msgbox('Grid2Series is in processing.'); pause(0.3); close(hh); % end if get(handles.RadiobuttonBoundaryfile,'value') time_series=gmt_grid2series(handles.grid_data,handles.boundaryfile,'line'); elseif get(handles.RadiobuttonMaskfile,'value') time_series=gmt_grid2series(handles.grid_data,handles.maskfile,'mask'); end save(strcat(InputPathname, InputFilename),'time_series'); % add other variables if they are in input SH file *.mat if isfield(handles,'str_year') % whether str_year exists in handles str_year= handles.str_year; save(strcat(InputPathname, InputFilename),'-append','str_year'); end if isfield(handles,'str_month') str_month= handles.str_month; save(strcat(InputPathname, InputFilename),'-append','str_month'); end if isfield(handles,'time') time= handles.time; save(strcat(InputPathname, InputFilename),'-append','time'); end hh=msgbox('Grid2Series is done.'); pause(0.5); close(hh); end end function EditOutputSeries_Callback(hObject, eventdata, handles) function EditOutputSeries_CreateFcn(hObject, eventdata, handles) % hObject handle to EditOutputSeries (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in PushbuttonOutputSeries. % hObject handle to PushbuttonOutputSeries (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
github
fengweiigg/GRACE_Matlab_Toolbox-master
gmt_destriping_ddk.m
.m
GRACE_Matlab_Toolbox-master/GRACE_functions/gmt_destriping_ddk.m
3,472
utf_8
631d74e74801849ae929bbec74c6b556
function dataDDK=gmt_destriping_ddk(number,data) % DDK filtering % % INPUT: % number the type of DDK filter % data spherical harmonic coefficients before filtering % % OUTPUT: % grid_filter equi-angular grid N*2N, N=180 or 720 % % DDK1d11: filtered with inverse signal degree power law 1e11*deg^4 (DDK5) weakest smoothing % DDK5d11: filtered with inverse signal degree power law 5e11*deg^4 (DDK4) | % DDK1d12: filtered with inverse signal degree power law 1e12*deg^4 (DDK3) | % DDK1d13: filtered with inverse signal degree power law 1e13*deg^4 (DDK2) | % DDK1d14: filtered with inverse signal degree power law 1e14*deg^4 (DDK1) strongest smoothing % FENG Wei 18/10/2016 % % State Key Laboratory of Geodesy and Earth's Dynamics % Institute of Geodesy and Geophysics, Chinese Academy of Sciences % [email protected] % This function is created based on the code from Roelof Rietbroek. % Copyright Roelof Rietbroek 2016 % This software is licensed under the MIT license see https://github.com/strawpants/GRACE-filter/blob/master/LICENSE % URL: https://github.com/strawpants/GRACE-filter switch number case 1 %strongest DDK1 file='Wbd_2-120.a_1d14p_4'; case 2 % DDK2 file='Wbd_2-120.a_1d13p_4'; case 3 % DDK3 file='Wbd_2-120.a_1d12p_4'; case 4 % DDK4 file='Wbd_2-120.a_5d11p_4'; case 5 % DDK5 file='Wbd_2-120.a_1d11p_4'; case 6 file='Wbd_2-120.a_5d10p_4'; case 7 file='Wbd_2-120.a_1d10p_4'; case 8 file='Wbd_2-120.a_5d9p_4'; end % rep=pwd; % cd('C:\_PROGZ\GRACE\DDK\filtercoef\') dat=read_BIN([file]); % cd(rep) % Block interpretation % size ith block clear sz nend nstart sz(1)=dat.blockind(1); nstart(1)=1; nend(1)=1+sz(1)^2-1; for ij=2:dat.nblocks sz(ij)=dat.blockind(ij)-dat.blockind(ij-1); nstart(ij)=1+sum(sz(1:ij-1).^2); nend(ij)=nstart(ij)+sz(ij).^2-1; end % GRACE dataset nmax=size(data.C,1)-1; ntime=size(data.C,3); % Initialization dataDDK=data; % CAS de l'ordre 0 ordre=0; % block d'ordre 0, degree 2-> 120 ij=ordre+1; block=reshape(dat.pack1(nstart(ij):nend(ij)),sz(ij),sz(ij)); % on garde degree 2-> nmax block=block(1:nmax-1,1:nmax-1); % GRACE ordre 0 degree 2->nmax for klm=1:ntime coef=squeeze(data.C(3:end,ordre+1,klm)); %coefF=block*coef; % remplacement dataDDK.C(3:end,ij,klm)=block*coef; end ordre=1; while ordre<nmax+1 % block d'ordre ordre, degree 2-> 120 ij=2*(ordre); blockC=reshape(dat.pack1(nstart(ij):nend(ij)),sz(ij),sz(ij)); blockS=reshape(dat.pack1(nstart(ij+1):nend(ij+1)),sz(ij+1),sz(ij+1)); % on garde degree 2-> nmax fin=min(nmax-1,nmax-ordre+1); blockC=blockC(1:fin,1:fin); blockS=blockS(1:fin,1:fin); % GRACE ordre ordre degree 2->nmax deb=max(3,ordre+1); for klm=1:ntime coefC=squeeze(data.C(deb:end,ordre+1,klm)); coefS=squeeze(data.S(deb:end,ordre+1,klm)); % coefCF=blockC*coefC; % coefSF=blockS*coefS; % remplacement dataDDK.C(deb:end,ordre+1,klm)=blockC*coefC; dataDDK.S(deb:end,ordre+1,klm)=blockS*coefS; end % increment ordre=ordre+1; end % imagesc(log10(abs(data.C(:,:,1)))) % set(gca,'Clim',[-12 0]) % colorbar % figure(2) % imagesc(log10(abs(dataDDK.C(:,:,1)))) % set(gca,'Clim',[-12 0]) % colorbar
github
fengweiigg/GRACE_Matlab_Toolbox-master
xyz2plm.m
.m
GRACE_Matlab_Toolbox-master/GRACE_functions/simons/xyz2plm.m
9,366
utf_8
04d6208d0c886556d07c21d6c75a52f5
function [lmcosi,dw]=xyz2plm(fthph,L,method,lat,lon,cnd) % [lmcosi,dw]=XYZ2PLM(fthph,L,method,lat,lon,cnd) % % Forward real spherical harmonic transform in the 4pi normalized basis. % % Converts a spatially gridded field into spherical harmonics. % For complete and regular spatial samplings [0 360 -90 90]. % If regularly spaced and complete, do not specify lat,lon. % If not regularly spaced, fthph, lat and lon are column vectors. % % INPUT: % % fthph Real-valued function whose transform we seek: % [1] MxN matrix of values corresponding to a regular grid % defined by lat,lon as described below, OR % [2] an MNx1 vector of values corrsponding to a set of % latitude and longitude values given by lat,lon as below % L Maximum degree of the expansion (Nyquist checked) % method 'im' By inversion (fast, accurate, preferred), % uses FFT on equally spaced longitudes, ok to % specify latitudes only as long as nat>=(L+1), % note: works with the orthogonality of the % cosine/sine of the longitude instead of with % the orthogonality of the Legendre polynomials. % 'gl' By Gauss-Legendre integration (fast, inaccurate) % note: resampling to GL integration points, % uses FFT on equally spaced longitudes % 'simpson' By Simpson integation (fast, inaccurate), % note: requires equidistant latitude spacing, % uses FFT on equally spaced longitudes % 'irr' By inversion (irregular samplings) % 'fib' By Riemann sum on a Fibonacci grid (not done yet) % lat Latitude range for the grid or set of function values: % [1] if unspecified, we assume [90 -90] and a regular grid % [2] 1x2 vector [maximumlatitude minimumlatitude] in degrees % [3] an MNx1 vector of values with the explicit latitudes % lon Longitude range for the grid or set of function values: % [1] if unspecified, we assume [0 360] and a regular grid % [2] 1x2 vector [maximumlatitude minimumlatitude] in degrees % [3] an MNx1 vector of values with the explicit longitudes % cnd Eigenvalue tolerance in the irregular case % % OUTPUT: % % lmcosi Matrix listing l,m,cosine and sine coefficients % dw Eigenvalue spectrum in the irregular case % % Note that the MEAN of the input data deviates from C(1), as sampled % fields lose the orthogonality. The inversion approaches should recover % the exact value of C(1), the true mean of the data, not the sample % mean. % % lmcosi=xyz2plm(ones(randi(100),randi(100))); lmcosi(1,3) is close to one % % See also PLM2XYZ, PLM2SPEC, PLOTPLM, etc. % % Last modified by fjsimons-at-alum.mit.edu, 09/04/2014 t0=clock; defval('method','im') defval('lon',[]) defval('lat',[]) defval('dw',[]) defval('cnd',[]) as=0; % If no grid is specified, assumes equal spacing and complete grid if isempty(lat) & isempty(lon) % Test if data is 2D, and periodic over longitude fthph=reduntest(fthph); polestest(fthph) % Make a complete grid nlon=size(fthph,2); nlat=size(fthph,1); % Nyquist wavelength Lnyq=min([ceil((nlon-1)/2) nlat-1]); % Colatitude and its increment theta=linspace(0,pi,nlat); as=1; % Equally spaced % Calculate latitude/longitude sampling interval; no wrap-around left dtheta=pi/(nlat-1); dphi=2*pi/nlon; switch method % Even without lat/lon can still choose the full inversion method % without Fourier transformation case 'irr' [LON,LAT]=meshgrid(linspace(0,2*pi*(1-1/nlon),nlon),... linspace(pi/2,-pi/2,nlat)); lat=LAT(:); lon=LON(:); fthph=fthph(:); theta=pi/2-lat; clear LON LAT end elseif isempty(lon) % If only latitudes are specified; make equal spacing longitude grid % Latitudes can be unequally spaced for 'im', 'irr' and 'gl'. fthph=reduntest(fthph); theta=(90-lat)*pi/180; dtheta=(lat(1)-lat(2))*pi/180; nlat=length(lat); nlon=size(fthph,2); dphi=2*pi/nlon; Lnyq=min([ceil((nlon-1)/2) ceil(pi/dtheta)]); else % Irregularly sampled data fthph=fthph(:); theta=(90-lat)*pi/180; lat=lat(:)*pi/180; lon=lon(:)*pi/180; nlon=length(lon); nlat=length(lat); % Nyquist wavelength adi=[abs(diff(sort(lon))) ; abs(diff(sort(lat)))]; Lnyq=ceil(pi/min(adi(~~adi))); method='irr'; end % Decide on the Nyquist frequency defval('L',Lnyq); % Never use Libbrecht algorithm... found out it wasn't that good defval('libb',0) %disp(sprintf('Lnyq= %i ; expansion out to degree L= %i',Lnyq,L)) if L>Lnyq | nlat<(L+1) warning('XYZ2PLM: Function undersampled. Aliasing will occur.') end % Make cosine and sine matrices [m,l,mz]=addmon(L); lmcosi=[l m zeros(length(l),2)]; % Define evaluation points switch method case 'gl' % Highest degree of integrand will always be 2*L [w,x]=gausslegendrecof(2*L,[],[-1 1]); % Function interpolated at Gauss-Legendre latitudes; 2D no help fthph=interp1(theta,fthph,acos(x),'spline'); case {'irr','simpson','im'} % Where else to evaluate the Legendre polynomials x=cos(theta); otherwise error('Specify valid method') end fnpl=sprintf('%s/LSSM-%i-%i.mat',... fullfile(getenv('IFILES'),'LEGENDRE'),L,length(x)); if exist(fnpl,'file')==2 & as==1 load(fnpl) else % Evaluate Legendre polynomials at selected points Plm=repmat(NaN,length(x),addmup(L)); if L>200 h=waitbar(0,'Evaluating all Legendre polynomials'); end in1=0; in2=1; for l=0:L if libb==0 Plm(:,in1+1:in2)=(legendre(l,x(:)','sch')*sqrt(2*l+1))'; else Plm(:,in1+1:in2)=(libbrecht(l,x(:)','sch')*sqrt(2*l+1))'; end in1=in2; in2=in1+l+2; if L>200 waitbar((l+1)/(L+1),h) end end if L>200 delete(h) end if as==1 % save(fnpl,'Plm')% Plm is not saved anymore! % Feng Wei modified end end switch method case {'irr'} Plm=[Plm.*cos(lon(:)*m(:)') Plm.*sin(lon(:)*m(:)')]; % Add these into the sensitivity matrix [C,merr,mcov,chi2,L2err,rnk,dw]=datafit(Plm,fthph,[],[],cnd); lmcosi(:,3)=C(1:end/2); lmcosi(:,4)=C(end/2+1:end); case {'im','gl','simpson'} % Perhaps demean the data for Fourier transform defval('dem',0) if dem meanm=mean(fthph,2); fthph=fthph-repmat(meanm,1,nlon); end % Calculate integration over phi by the fast Fourier % transform. Integration of real input field with respect to the second % dimension of r, at wavenumber m, thus at constant latitude. You get % as many wavenumbers m as there are longitudes; only use to L. With % Matlab's FFT, need to multiply by sampling interval. gfft=dphi*fft(fthph,nlon,2); if dem % Add the azimuthal mean back in there gfft(:,1)=2*pi*meanm; end % Note these things are only half unique - the maximum m is nlon/2 % But no Nyquist theory exists for the Legendre transform... a=real(gfft); b=-imag(gfft); in1=0; in2=1; otherwise error('Specify valid method') end switch method case 'im' % Loop over the orders. This speeds it up versus 'irr' for ord=0:L a(:,1)=a(:,1)/2; b(:,1)=b(:,1)/2; Pm=Plm(:,mz(ord+1:end)+ord)*pi; [lmcosi(mz(ord+1:end)+ord,3)]=datafit(Pm,a(:,ord+1),[],[],cnd); [lmcosi(mz(ord+1:end)+ord,4)]=datafit(Pm,b(:,ord+1),[],[],cnd); end case 'simpson' % Loop over the degrees. Could go up to l=nlon if you want for l=0:L, % Integrate over theta using Simpson's rule clm=simpson(theta,... repmat(sin(theta(:)),1,l+1).*a(:,1:l+1).*Plm(:,in1+1:in2)); slm=simpson(theta,... repmat(sin(theta(:)),1,l+1).*b(:,1:l+1).*Plm(:,in1+1: ... in2)); in1=in2; in2=in1+l+2; % And stick it in a matrix [l m Ccos Csin] lmcosi(addmup(l-1)+1:addmup(l),3)=clm(:)/4/pi; lmcosi(addmup(l-1)+1:addmup(l),4)=slm(:)/4/pi; end case 'gl' % Loop over the degrees. Could go up to l=nlon if you want for l=0:L, % Integrate over theta using Gauss-Legendre integration clm=sum(a(:,1:l+1).*(diag(w)*Plm(:,in1+1:in2))); slm=sum(b(:,1:l+1).*(diag(w)*Plm(:,in1+1:in2))); in1=in2; in2=in1+l+2; % And stick it in a matrix [l m Ccos Csin] lmcosi(addmup(l-1)+1:addmup(l),3)=clm(:)/4/pi; lmcosi(addmup(l-1)+1:addmup(l),4)=slm(:)/4/pi; end rnk=[]; end % Get rid of machine precision error lmcosi(abs(lmcosi(:,3))<eps,3)=0; lmcosi(abs(lmcosi(:,4))<eps,4)=0; %disp(sprintf('XYZ2PLM (Analysis) took %8.4f s',etime(clock,t0))) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function grd=reduntest(grd) % Tests if last longitude repeats last (0,360) % and removes last data column if sum(abs(grd(:,1)-grd(:,end))) >= size(grd,2)*eps*10 % disp(sprintf('Data violate wrap-around by %8.4e',... % sum(abs(grd(:,1)-grd(:,end))))) %comment out, Feng Wei modified end grd=grd(:,1:end-1); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function polestest(grd) % Tests if poles (-90,90) are identical over longitudes var1=var(grd(1,:)); var2=var(grd(end,:)); if var1>eps*10 | var2>eps*10 % disp(sprintf('Poles violated by %8.4e and %8.4e',var1,var2)) %comment out, Feng Wei modified end
github
fengweiigg/GRACE_Matlab_Toolbox-master
testddk.m
.m
GRACE_Matlab_Toolbox-master/GRACE_functions/ddk_filtercoef/testddk.m
2,100
utf_8
b83bf6d30660ea515968e1e59b24a607
function nouv=ddk(number,data); % ddk filtering switch number case 1 %strongest file='Wbd_2-120.a_1d14p_4'; case 2 file='Wbd_2-120.a_1d13p_4'; case 3 file='Wbd_2-120.a_1d12p_4'; case 4 file='Wbd_2-120.a_5d11p_4'; case 5 file='Wbd_2-120.a_1d11p_4'; end dat=read_BIN(file); % Block interpretation % size ith block clear sz nend nstart sz(1)=dat.blockind(1); nstart(1)=1; nend(1)=1+sz(1)^2-1; for ij=2:dat.nblocks sz(ij)=dat.blockind(ij)-dat.blockind(ij-1); nstart(ij)=1+sum(sz(1:ij-1).^2); nend(ij)=nstart(ij)+sz(ij).^2-1; end % GRACE dataset nmax=size(data.C,1)-1; ntime=size(data.C,3); % Initialization dataDDK=data; % CAS de l'ordre 0 ordre=0; % block d'ordre 0, degree 2-> 120 ij=ordre+1; block=reshape(dat.pack1(nstart(ij):nend(ij)),sz(ij),sz(ij)); % on garde degree 2-> nmax block=block(1:nmax-1,1:nmax-1); % GRACE ordre 0 degree 2->nmax for klm=1:ntime coef=squeeze(data.C(3:end,ordre+1,klm)); coefF=block*coef; % remplacement dataDDK.C(3:end,ij,klm)=coefF; end ordre=1; while ordre<nmax+1 % block d'ordre ordre, degree 2-> 120 ij=2*(ordre); blockC=reshape(dat.pack1(nstart(ij):nend(ij)),sz(ij),sz(ij)); blockS=reshape(dat.pack1(nstart(ij+1):nend(ij+1)),sz(ij+1),sz(ij+1)); % on garde degree 2-> nmax fin=min(nmax-1,nmax-ordre+1); blockC=blockC(1:fin,1:fin); blockS=blockS(1:fin,1:fin); % GRACE ordre ordre degree 2->nmax deb=max(3,ordre+1); for klm=1:ntime coefC=squeeze(data.C(deb:end,ordre+1,klm)); coefS=squeeze(data.S(deb:end,ordre+1,klm)); coefCF=blockC*coefC; coefSF=blockS*coefS; % remplacement dataDDK.C(deb:end,ordre+1,klm)=coefCF; dataDDK.S(deb:end,ordre+1,klm)=coefSF; end % increment ordre=ordre+1; end % imagesc(log10(abs(data.C(:,:,1)))) % set(gca,'Clim',[-12 0]) % colorbar % figure(2) % imagesc(log10(abs(dataDDK.C(:,:,1)))) % set(gca,'Clim',[-12 0]) % colorbar
github
fengweiigg/GRACE_Matlab_Toolbox-master
read_BIN.m
.m
GRACE_Matlab_Toolbox-master/GRACE_functions/ddk_filtercoef/read_BIN.m
4,694
utf_8
099496edd812b75154803c4cb6023ab2
%function which reads in a binary file containing symmetric/full or block %diagonal matrices and associated vectors and parameters %Roelof Rietbroek, 7-1-2008 %updated: 29-07-2008 % %usage: dat=read_BIN(file) %returns a structure array 'dat' with the file content % the matrix remains in packed form (dat.pack1 field) %or: dat=read_BIN(file,'F') % also expands the matrix to its full form (dat.mat1 field) % Warning: this option may cause excessive RAM memory use with large matrices %function now also works with Octave function dat=read_BIN(file,varargin) unpack=false; for i=1:size(varargin,2) switch varargin{i} case {'F'} unpack=true; % unpack matrix in full size end end %open file for read acces in little endian format [fid,message]=fopen(file,'r','ieee-le'); %check for errors if (fid == -1) message dat=[]; return; end %read BINARY version and type from file dat.version(1,1:8)=fread(fid,8,'uint8=>char')'; dat.type(1,1:8)=fread(fid,8,'uint8=>char')'; dat.descr(1,1:80)=fread(fid,80,'uint8=>char')'; %read indices %integers:inint,indbls,inval1,inval2,ipval1,ipval2 metaint=fread(fid,6,'integer*4'); %put index data in structure array n_ints=metaint(1); n_dbls=metaint(2); dat.nval1=metaint(3); dat.nval2=metaint(4); dat.pval1=metaint(5); dat.pval2=metaint(6); %Type dependent index data switch dat.type case {'BDSYMV0_','BDFULLV0'} %read additional nblocks parameter dat.nblocks=fread(fid,1,'integer*4'); end %get meta data %integers if(n_ints > 0) list=fread(fid,n_ints*24,'uint8=>char'); dat.ints_d=reshape(list,24,n_ints)'; dat.ints=fread(fid,n_ints,'integer*4'); end %doubles if(n_dbls > 0) list=fread(fid,n_dbls*24,'uint8=>char'); dat.dbls_d=reshape(list,24,n_dbls)'; dat.dbls=fread(fid,n_dbls,'real*8'); end %side description meta data list=fread(fid,dat.nval1*24,'uint8=>char'); %reshape characters and put in dat struct array dat.side1_d=reshape(list,24,dat.nval1)'; %type specific meta data switch dat.type case {'BDSYMV0_','BDFULLV0'} %read additional nblocks parameter dat.blockind=fread(fid,dat.nblocks,'integer*4'); end %data (type dependent) switch dat.type case 'SYMV0___' dat.pack1=fread(fid,dat.pval1,'real*8'); if( unpack) row=[1:dat.nval1]; col=row; %the array ind is upper triangular ind=triu(row'*ones(1,dat.nval1)) +triu(ones(dat.nval1,1)*(col.*(col-1))/2); %copy data from packed vector to full array dat.mat1=dat.pack1(ind+ind'-diag(diag(ind))); clear ind dat=rmfield(dat,'pack1'); end case 'SYMV1___' dat.vec1=fread(fid,dat.nval1,'real*8'); dat.pack1=fread(fid,dat.pval1,'real*8'); if( unpack) row=[1:dat.nval1]; col=row; %the array ind is upper triangular ind=triu(row'*ones(1,dat.nval1)) +triu(ones(dat.nval1,1)*(col.*(col-1))/2); %copy data from packed vector to full array dat.mat1=dat.pack1(ind+ind'-diag(diag(ind))); clear ind dat=rmfield(dat,'pack1'); end case 'SYMV2___' dat.vec1=fread(fid,dat.nval1,'real*8'); dat.vec2=fread(fid,dat.nval1,'real*8'); dat.pack1=fread(fid,dat.pval1,'real*8'); if(unpack) row=[1:dat.nval1]; col=row; %the array ind is upper triangular ind=triu(row'*ones(1,dat.nval1)) +triu(ones(dat.nval1,1)*(col.*(col-1))/2); %copy data from packed vector to full array dat.mat1=dat.pack1(ind+ind'-diag(diag(ind))); clear ind dat=rmfield(dat,'pack1'); end case 'BDSYMV0_' dat.pack1=fread(fid,dat.pval1,'real*8'); if(unpack) dat.mat1=[]; skip=0; skipentries=0; for i=1:dat.nblocks sz=dat.blockind(i)-skip; row=[1:sz]; col=row; ind=triu(row'*ones(1,sz)) +triu(ones(sz,1)*(col.*(col-1))/2); ind=triu(ind+skipentries) skip=dat.blockind(i); dat.mat1=blkdiag(dat.mat1,dat.pack1(ind+ind'-diag(diag(ind)))); skipentries=skipentries+(sz*(sz+1))/2; end clear ind dat=rmfield(dat,'pack1'); end case 'BDFULLV0' dat.pack1=fread(fid,dat.pval1,'real*8'); if(unpack) dat.mat1=[]; skip=0; skipentries=0; for i=1:dat.nblocks sz=dat.blockind(i)-skip; dat.mat1=blkdiag(dat.mat1,reshape(dat.pack1(skipentries+1:skipentries+sz^2),sz,sz)); %reset indices skip=dat.blockind(i); skipentries=skipentries+sz^2; end dat=rmfield(dat,'pack1'); end case 'FULLSQV0' dat.pack1=fread(fid,dat.pval1^2,'real*8'); if(unpack) dat.mat1=reshape(dat.pack1,dat.nval1,dat.nval1); dat=rmfield(dat,'pack1'); end end fclose(fid);
github
zhimingluo/MovingObjectSegmentation-master
training.m
.m
MovingObjectSegmentation-master/SBMI/Cascade/training.m
3,369
utf_8
13d359faf4fd100e37021dd78cacb7d2
function training(video) previousMethod = 'MSCNN'; % BasicCNN or MSCNN opts.expDir = [previousMethod 'net/', video]; opts.train.batchSize = 5 ; opts.train.numEpochs = 20; opts.train.continue = true ; opts.train.useGpu = true ; opts.train.learningRate = 1e-3; opts.train.expDir = opts.expDir; % -------------------------------------------------------------------- % Prepare data % -------------------------------------------------------------------- imgDir = ['../SBMIDataset/' video '/input']; labelDir = ['../SBMIDataset/' video '/groundtruth']; grayDir = ['../' previousMethod '/result/', video]; imdb = getImdb_new(video, imgDir, labelDir, grayDir); imdb.half_size = 15; %%%%%%Yi%%%%%% redefined the net load('net'); net.layers{1} = struct('type', 'conv', ... 'filters', 0.01 * randn(7, 7, 4, 32, 'single'), ... 'biases', zeros(1, 32, 'single'), ... 'stride', 1, ... 'pad', 0) ; net.layers{end-1} = struct('type', 'conv', ... 'filters', 0.1*randn(1,1,64,1, 'single'), ... 'biases', zeros(1, 1, 'single'), ... 'stride', 1, ... 'pad', 0) ; net.layers{end} = struct('type', 'sigmoidcrossentropyloss'); load('meanPixel.mat'); imdb.meanPixel = meanPixel; [net,info] = cnn_train_adagrad(net, imdb, @getBatch,... opts.train, 'errorType', 'euclideanloss', ... 'conserveMemory', true); end function [im, labels, mask] = getBatch(imdb, batch) half_size = imdb.half_size; meanPixel = imdb.meanPixel; meanPixel(:,:,4) =0; for ii = 1 : numel(batch) imagename = imdb.images.name{batch(ii)}; im_ii = single(imread(imagename)); labelname = imdb.images.labels{batch(ii)}; roi = imread(labelname); labels_ii = zeros(size(roi, 1), size(roi, 2)); labels_ii( roi == 50 ) = 0.25; %shade labels_ii( roi == 170 ) = 0.75; %object boundary labels_ii( roi == 255 ) = 1; %foreground % resize the image to half size if size(im_ii, 1) > 400 || size(im_ii, 2) >400 im_ii = imresize(im_ii, 0.5, 'nearest'); labels_ii = imresize(labels_ii, 0.5, 'nearest'); end grayname =imdb.images.gray_name{batch(ii)}; im_ii(:,:,4) = single(imread(grayname)); im_large = padarray(im_ii, [half_size, half_size], 'symmetric'); im_ii = bsxfun(@minus, im_large, meanPixel); im(:, :, :, ii) = im_ii; labels(:, :, 1, ii) = labels_ii; labels(:, :, 2, ii) = double(imdb.mask); end end function imdb = getImdb_new(video, imgDir, labelDir, grayDir) files = [dir([imgDir '/*.jpg']); dir([imgDir '/*.png'])]; label_files = dir([labelDir '/*.png']); gray_files = dir([grayDir '/*.png']); names = {}; labels = {}; gray_names = {}; load(['../split/' video '.mat']); for ii = 1:numel(train_index) k = train_index(ii); names{end+1} = [imgDir '/' files(k).name]; labels{end+1} = [labelDir '/' label_files(k).name]; gray_names{end+1} = [grayDir '/' gray_files(k).name]; end im = imread(labels{1}); mask = ones(size(im,1),size(im,2)); if size(mask,1) > 400 || size(mask,2) >400 mask = imresize(mask, 0.5, 'nearest'); end imdb.mask = single(mask); imdb.images.set = ones(1,numel(names)); imdb.images.name = names ; imdb.images.gray_name = gray_names; imdb.images.labels = labels; end
github
zhimingluo/MovingObjectSegmentation-master
cnn_train_adagrad.m
.m
MovingObjectSegmentation-master/SBMI/Cascade/cnn_train_adagrad.m
11,673
utf_8
313227873e4c91a0c6db387ba794ec99
function [net, info] = cnn_train_adagrad(net, imdb, getBatch, varargin) % CNN_TRAIN Demonstrates training a CNN % CNN_TRAIN() is an example learner implementing stochastic gradient % descent with momentum to train a CNN for image classification. % It can be used with different datasets by providing a suitable % getBatch function. opts.train = [] ; opts.val = [] ; opts.numEpochs = 300 ; opts.batchSize = 256 ; opts.useGpu = false ; opts.learningRate = 0.001 ; opts.continue = false ; opts.expDir = fullfile('data','exp') ; opts.conserveMemory = false ; opts.sync = true ; opts.prefetch = false ; opts.weightDecay = 0.0005 ; opts.errorType = 'multiclass' ; opts.plotDiagnostics = false ; opts.delta = 1e-8; opts.display = 1; opts.snapshot = 1; opts.test_interval = 1; opts = vl_argparse(opts, varargin) ; if ~exist(opts.expDir, 'dir'), mkdir(opts.expDir); end if isempty(opts.train), opts.train = find(imdb.images.set==1); end if isempty(opts.val), opts.val = find(imdb.images.set==2); end if isnan(opts.train), opts.train = []; end % ------------------------------------------------------------------------- % Network initialization % ------------------------------------------------------------------------- for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = zeros(size(net.layers{i}.filters), ... class(net.layers{i}.filters)) ; net.layers{i}.biasesMomentum = zeros(size(net.layers{i}.biases), ... class(net.layers{i}.biases)) ; %#ok<*ZEROLIKE> if ~isfield(net.layers{i}, 'filtersLearningRate') net.layers{i}.filtersLearningRate = 1 ; end if ~isfield(net.layers{i}, 'biasesLearningRate') net.layers{i}.biasesLearningRate = 1 ; end if ~isfield(net.layers{i}, 'filtersWeightDecay') net.layers{i}.filtersWeightDecay = 1 ; end if ~isfield(net.layers{i}, 'biasesWeightDecay') net.layers{i}.biasesWeightDecay = 1 ; end end if opts.useGpu net = vl_simplenn_move(net, 'gpu') ; for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = gpuArray(net.layers{i}.filtersMomentum) ; net.layers{i}.biasesMomentum = gpuArray(net.layers{i}.biasesMomentum) ; end end G_f = cell(numel(net.layers), 1); G_b = cell(numel(net.layers), 1); for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end G_f{l} = zeros(size(net.layers{l}.filters), 'single'); G_b{l} = zeros(size(net.layers{l}.biases), 'single'); end % ------------------------------------------------------------------------- % Train and validate % ------------------------------------------------------------------------- rng(0) ; if opts.useGpu one = gpuArray(single(1)) ; else one = single(1) ; end info.train.objective = [] ; info.train.error = [] ; info.train.topFiveError = [] ; info.train.speed = [] ; info.val.objective = [] ; info.val.error = [] ; info.val.topFiveError = [] ; info.val.speed = [] ; lr = opts.learningRate ; res = [] ; for epoch=1:opts.numEpochs % fast-forward to where we stopped modelPath = @(ep) fullfile(opts.expDir, sprintf('net-epoch-%d.mat', ep)); modelFigPath = fullfile(opts.expDir, 'net-train.pdf') ; if opts.continue if exist(modelPath(epoch),'file') if epoch == opts.numEpochs load(modelPath(epoch), 'net', 'info') ; end continue ; end if epoch > 1 fprintf('resuming by loading epoch %d\n', epoch-1) ; load(modelPath(epoch-1), 'net', 'info') ; end end train = opts.train(randperm(numel(opts.train))) ; val = opts.val ; info.train.objective(end+1) = 0 ; info.train.error(end+1) = 0 ; info.train.topFiveError(end+1) = 0 ; info.train.speed(end+1) = 0 ; info.val.objective(end+1) = 0 ; info.val.error(end+1) = 0 ; info.val.topFiveError(end+1) = 0 ; info.val.speed(end+1) = 0 ; for t=1:opts.batchSize:numel(train) % get next image batch and labels batch = train(t:min(t+opts.batchSize-1, numel(train))) ; batch_time = tic ; fprintf('training: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(train)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = train(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(train))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end % backprop net.layers{end}.class = labels ; res = vl_simplenn(net, im, one, res, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % gradient step for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end g_f = (net.layers{l}.filtersLearningRate) * ... (opts.weightDecay * net.layers{l}.filtersWeightDecay) * net.layers{l}.filters + ... (net.layers{l}.filtersLearningRate) / numel(batch) * res(l).dzdw{1}; g_b = (net.layers{l}.biasesLearningRate) * ... (opts.weightDecay * net.layers{l}.biasesWeightDecay) * net.layers{l}.biases + ... (net.layers{l}.biasesLearningRate) / numel(batch) * res(l).dzdw{2}; G_f{l} = G_f{l} + g_f .^ 2; G_b{l} = G_b{l} + g_b .^ 2; net.layers{l}.filters = net.layers{l}.filters - lr ./ (opts.delta + sqrt(G_f{l})) .* g_f; net.layers{l}.biases = net.layers{l}.biases - lr ./ (opts.delta + sqrt(G_b{l})) .* g_b; end % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.train = updateError(opts, info.train, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.train.error(end)/n*100, info.train.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.train.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.train.error(end) / n); fprintf('\n') ; end % debug info if opts.plotDiagnostics figure(2) ; vl_simplenn_diagnose(net,res) ; drawnow ; end end % next batch % evaluation on validation set if epoch == 1 || rem(epoch, opts.test_interval) == 0 || epoch == opts.numEpochs for t=1:opts.batchSize:numel(val) batch_time = tic ; batch = val(t:min(t+opts.batchSize-1, numel(val))) ; fprintf('validation: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(val)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = val(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(val))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end net.layers{end}.class = labels ; res = vl_simplenn(net, im, [], res, ... 'disableDropout', true, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.val = updateError(opts, info.val, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.val.error(end)/n*100, info.val.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.val.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.val.error(end) / n); fprintf('\n') ; end end end % save info.train.objective(end) = info.train.objective(end) / numel(train) ; info.train.error(end) = info.train.error(end) / numel(train) ; info.train.topFiveError(end) = info.train.topFiveError(end) / numel(train) ; info.train.speed(end) = numel(train) / info.train.speed(end) ; info.val.objective(end) = info.val.objective(end) / numel(val) ; info.val.error(end) = info.val.error(end) / numel(val) ; info.val.topFiveError(end) = info.val.topFiveError(end) / numel(val) ; info.val.speed(end) = numel(val) / info.val.speed(end) ; if epoch == 1 || rem(epoch, opts.snapshot) == 0 || epoch == opts.numEpochs save(modelPath(epoch), 'net', 'info') ; end if epoch == 1 || rem(epoch, opts.display) == 0 || epoch == opts.numEpochs figure(1) ; clf ; subplot(1,2,1) ; semilogy(1:epoch, info.train.objective, 'k') ; hold on ; semilogy([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.objective([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; xlabel('training epoch') ; ylabel('energy') ; grid on ; h=legend('train', 'val') ; set(h,'color','none'); title('objective') ; subplot(1,2,2) ; switch opts.errorType case 'multiclass' plot(1:epoch, info.train.error, 'k') ; hold on ; plot(1:epoch, info.train.topFiveError, 'k--') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.topFiveError([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b--') ; h=legend('train','train-5','val','val-5') ; case 'binary' plot(1:epoch, info.train.error, 'k') ; hold on ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h=legend('train','val') ; case 'euclideanloss' plot(1 : epoch, info.train.error, 'k'); hold on; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h = legend('train', 'val') ; end grid on ; xlabel('training epoch') ; ylabel('error') ; set(h,'color','none') ; title('error') ; drawnow ; print(1, modelFigPath, '-dpdf') ; end end % ------------------------------------------------------------------------- function info = updateError(opts, info, net, res, speed) % ------------------------------------------------------------------------- predictions = gather(res(end-1).x) ; sz = size(predictions) ; n = prod(sz(1:2)) ; labels = net.layers{end}.class ; info.objective(end) = info.objective(end) + sum(double(gather(res(end).x))) ; info.speed(end) = info.speed(end) + speed ; switch opts.errorType case 'multiclass' [~,predictions] = sort(predictions, 3, 'descend') ; error = ~bsxfun(@eq, predictions, reshape(labels, 1, 1, 1, [])) ; info.error(end) = info.error(end) +.... sum(sum(sum(error(:,:,1,:))))/n ; info.topFiveError(end) = info.topFiveError(end) + ... sum(sum(sum(min(error(:,:,1:5,:),[],3))))/n ; case 'binary' error = bsxfun(@times, predictions, labels) < 0 ; info.error(end) = info.error(end) + sum(error(:))/n ; case 'euclideanloss' error = euclideanloss(sigmoid(predictions), labels); info.error(end) = info.error(end) + error; end
github
zhimingluo/MovingObjectSegmentation-master
cnn_train_adagrad_ms.m
.m
MovingObjectSegmentation-master/SBMI/MSCNN/cnn_train_adagrad_ms.m
13,645
utf_8
f04bf6fcc2468adcfb032edb55192a75
function [net, info] = cnn_train_adagrad_ms(net, imdb, getBatch, varargin) % CNN_TRAIN Demonstrates training a CNN % CNN_TRAIN() is an example learner implementing stochastic gradient % descent with momentum to train a CNN for image classification. % It can be used with different datasets by providing a suitable % getBatch function. opts.train = [] ; opts.val = [] ; opts.numEpochs = 300 ; opts.batchSize = 256 ; opts.useGpu = false ; opts.learningRate = 0.001 ; opts.continue = false ; opts.expDir = fullfile('data','exp') ; opts.conserveMemory = false ; opts.sync = true ; opts.prefetch = false ; opts.weightDecay = 0.0005 ; opts.errorType = 'multiclass' ; opts.plotDiagnostics = false ; opts.delta = 1e-8; opts.display = 1; opts.snapshot = 1; opts.test_interval = 1; opts = vl_argparse(opts, varargin) ; if ~exist(opts.expDir, 'dir'), mkdir(opts.expDir); end if isempty(opts.train), opts.train = find(imdb.images.set==1); end if isempty(opts.val), opts.val = find(imdb.images.set==2); end if isnan(opts.train), opts.train = []; end % ------------------------------------------------------------------------- % Network initialization % ------------------------------------------------------------------------- for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = zeros(size(net.layers{i}.filters), ... class(net.layers{i}.filters)) ; net.layers{i}.biasesMomentum = zeros(size(net.layers{i}.biases), ... class(net.layers{i}.biases)) ; %#ok<*ZEROLIKE> if ~isfield(net.layers{i}, 'filtersLearningRate') net.layers{i}.filtersLearningRate = 1 ; end if ~isfield(net.layers{i}, 'biasesLearningRate') net.layers{i}.biasesLearningRate = 1 ; end if ~isfield(net.layers{i}, 'filtersWeightDecay') net.layers{i}.filtersWeightDecay = 1 ; end if ~isfield(net.layers{i}, 'biasesWeightDecay') net.layers{i}.biasesWeightDecay = 1 ; end end if opts.useGpu net = vl_simplenn_move(net, 'gpu') ; for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = gpuArray(net.layers{i}.filtersMomentum) ; net.layers{i}.biasesMomentum = gpuArray(net.layers{i}.biasesMomentum) ; end end G_f = cell(numel(net.layers), 1); G_b = cell(numel(net.layers), 1); for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end G_f{l} = zeros(size(net.layers{l}.filters), 'single'); G_b{l} = zeros(size(net.layers{l}.biases), 'single'); end % ------------------------------------------------------------------------- % Train and validate % ------------------------------------------------------------------------- rng(0) ; if opts.useGpu one = gpuArray(single(1)) ; else one = single(1) ; end info.train.objective = [] ; info.train.error = [] ; info.train.topFiveError = [] ; info.train.speed = [] ; info.val.objective = [] ; info.val.error = [] ; info.val.topFiveError = [] ; info.val.speed = [] ; lr = opts.learningRate ; res = [] ; for epoch=1:opts.numEpochs % fast-forward to where we stopped modelPath = @(ep) fullfile(opts.expDir, sprintf('net-epoch-%d.mat', ep)); modelFigPath = fullfile(opts.expDir, 'net-train.pdf') ; if opts.continue if exist(modelPath(epoch),'file') if epoch == opts.numEpochs load(modelPath(epoch), 'net', 'info') ; end continue ; end if epoch > 1 fprintf('resuming by loading epoch %d\n', epoch-1) ; load(modelPath(epoch-1), 'net', 'info') ; end end train = opts.train(randperm(numel(opts.train))) ; val = opts.val ; info.train.objective(end+1) = 0 ; info.train.error(end+1) = 0 ; info.train.topFiveError(end+1) = 0 ; info.train.speed(end+1) = 0 ; info.val.objective(end+1) = 0 ; info.val.error(end+1) = 0 ; info.val.topFiveError(end+1) = 0 ; info.val.speed(end+1) = 0 ; for t=1:opts.batchSize:numel(train) % get next image batch and labels batch = train(t:min(t+opts.batchSize-1, numel(train))) ; batch_time = tic ; fprintf('training: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(train)/opts.batchSize)) ; [im_ori, labels_ori] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = train(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(train))) ; getBatch(imdb, nextBatch) ; end for ss = 1 : numel(imdb.scales) [im, labels] = rescale_im(im_ori, labels_ori, imdb.scales(ss),... imdb.mask, imdb.half_size, imdb.meanPixel); if opts.useGpu im = gpuArray(im) ; end % backprop net.layers{end}.class = labels ; res = vl_simplenn(net, im, one, res, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % gradient step for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end g_f = (net.layers{l}.filtersLearningRate) * ... (opts.weightDecay * net.layers{l}.filtersWeightDecay) * net.layers{l}.filters + ... (net.layers{l}.filtersLearningRate) / numel(batch) * res(l).dzdw{1}; g_b = (net.layers{l}.biasesLearningRate) * ... (opts.weightDecay * net.layers{l}.biasesWeightDecay) * net.layers{l}.biases + ... (net.layers{l}.biasesLearningRate) / numel(batch) * res(l).dzdw{2}; G_f{l} = G_f{l} + g_f .^ 2; G_b{l} = G_b{l} + g_b .^ 2; net.layers{l}.filters = net.layers{l}.filters - lr ./ (opts.delta + sqrt(G_f{l})) .* g_f; net.layers{l}.biases = net.layers{l}.biases - lr ./ (opts.delta + sqrt(G_b{l})) .* g_b; end end % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.train = updateError(opts, info.train, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.train.error(end)/n*100, info.train.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.train.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.train.error(end) / n); fprintf('\n') ; end % debug info if opts.plotDiagnostics figure(2) ; vl_simplenn_diagnose(net,res) ; drawnow ; end end % next batch % evaluation on validation set if epoch == 1 || rem(epoch, opts.test_interval) == 0 || epoch == opts.numEpochs for t=1:opts.batchSize:numel(val) batch_time = tic ; batch = val(t:min(t+opts.batchSize-1, numel(val))) ; fprintf('validation: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(val)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = val(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(val))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end net.layers{end}.class = labels ; res = vl_simplenn(net, im, [], res, ... 'disableDropout', true, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.val = updateError(opts, info.val, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.val.error(end)/n*100, info.val.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.val.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.val.error(end) / n); fprintf('\n') ; end end end % save info.train.objective(end) = info.train.objective(end) / numel(train) ; info.train.error(end) = info.train.error(end) / numel(train) ; info.train.topFiveError(end) = info.train.topFiveError(end) / numel(train) ; info.train.speed(end) = numel(train) / info.train.speed(end) ; info.val.objective(end) = info.val.objective(end) / numel(val) ; info.val.error(end) = info.val.error(end) / numel(val) ; info.val.topFiveError(end) = info.val.topFiveError(end) / numel(val) ; info.val.speed(end) = numel(val) / info.val.speed(end) ; if epoch == 1 || rem(epoch, opts.snapshot) == 0 || epoch == opts.numEpochs save(modelPath(epoch), 'net', 'info') ; end if epoch == 1 || rem(epoch, opts.display) == 0 || epoch == opts.numEpochs figure(1) ; clf ; subplot(1,2,1) ; semilogy(1:epoch, info.train.objective, 'k') ; hold on ; semilogy([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.objective([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; xlabel('training epoch') ; ylabel('energy') ; grid on ; h=legend('train', 'val') ; set(h,'color','none'); title('objective') ; subplot(1,2,2) ; switch opts.errorType case 'multiclass' plot(1:epoch, info.train.error, 'k') ; hold on ; plot(1:epoch, info.train.topFiveError, 'k--') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.topFiveError([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b--') ; h=legend('train','train-5','val','val-5') ; case 'binary' plot(1:epoch, info.train.error, 'k') ; hold on ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h=legend('train','val') ; case 'euclideanloss' plot(1 : epoch, info.train.error, 'k'); hold on; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h = legend('train', 'val') ; end grid on ; xlabel('training epoch') ; ylabel('error') ; set(h,'color','none') ; title('error') ; drawnow ; print(1, modelFigPath, '-dpdf') ; end end end % ------------------------------------------------------------------------- function info = updateError(opts, info, net, res, speed) % ------------------------------------------------------------------------- predictions = gather(res(end-1).x) ; sz = size(predictions) ; n = prod(sz(1:2)) ; labels = net.layers{end}.class ; info.objective(end) = info.objective(end) + sum(double(gather(res(end).x))) ; info.speed(end) = info.speed(end) + speed ; switch opts.errorType case 'multiclass' [~,predictions] = sort(predictions, 3, 'descend') ; error = ~bsxfun(@eq, predictions, reshape(labels, 1, 1, 1, [])) ; info.error(end) = info.error(end) +.... sum(sum(sum(error(:,:,1,:))))/n ; info.topFiveError(end) = info.topFiveError(end) + ... sum(sum(sum(min(error(:,:,1:5,:),[],3))))/n ; case 'binary' labels = labels(:,:,1,:); [~,predictions] = sort(predictions, 3, 'descend') ; predictions = predictions(:,:,1,:); error = ~bsxfun(@eq, predictions, labels) ; info.error(end) = info.error(end) + sum(error(:))/n ; case 'euclideanloss' error = euclideanloss(sigmoid(predictions), labels); info.error(end) = info.error(end) + error; end end function [im, labels] = rescale_im(im_ori, label_ori, scale, mask, half_size, meanPixel) mask = imresize(mask, scale, 'nearest'); for i = 1:size(im_ori,4) im_ii = imresize(im_ori(:,:,:,i), scale, 'nearest'); im_large = padarray(im_ii, [half_size, half_size], 'symmetric'); im_ii = bsxfun(@minus, im_large, meanPixel); label_ii = imresize(label_ori(:,:,:,i), scale, 'nearest'); im(:, :, :, i) = im_ii; labels(:, :, 1, i) = label_ii; labels(:, :, 2, i) = double(mask); end end
github
zhimingluo/MovingObjectSegmentation-master
regular_training_ms.m
.m
MovingObjectSegmentation-master/SBMI/MSCNN/regular_training_ms.m
2,734
utf_8
ac270ae6d004596e4f3555eef3262c42
function regular_training_ms(video) opts.dataDir = 'net/traffic_Simple' ; opts.expDir = ['net/' video] ; opts.train.batchSize = 5 ; opts.train.numEpochs = 20; opts.train.continue = false ; opts.train.useGpu = true ; opts.train.learningRate = 1e-3; opts.train.expDir = opts.expDir ; scales = [1, 0.75, 0.5]; %opts = vl_argparse(opts, varargin) ; % -------------------------------------------------------------------- % Prepare data % -------------------------------------------------------------------- imgDir = ['../SBMIDataset/' video '/input']; labelDir = ['../SBMIDataset/' video '/groundtruth']; imdb = getImdb(video,imgDir,labelDir); imdb.half_size = 15; %%%%%%Yi%%%%%% redefined the net load('net'); net.layers{end-1} = struct('type', 'conv', ... 'filters', 0.1*randn(1,1,64,1, 'single'), ... 'biases', zeros(1, 1, 'single'), ... 'stride', 1, ... 'pad', 0) ; net.layers{end} = struct('type', 'sigmoidcrossentropyloss'); load('meanPixel.mat'); imdb.meanPixel = meanPixel; imdb.scales = scales; [net,info] = cnn_train_adagrad_ms(net, imdb, @getBatch,... opts.train,'errorType','euclideanloss',... 'conserveMemory', true); end function [im, labels] = getBatch(imdb, batch) % -------------------------------------------------------------------- half_size = imdb.half_size; meanPixel = imdb.meanPixel; for ii = 1:numel(batch) imagename = imdb.images.name{batch(ii)}; im_ii = single(imread(imagename)); labelname = imdb.images.labels{batch(ii)}; roi = imread(labelname); labels_ii = zeros(size(roi, 1), size(roi, 2)); labels_ii( roi == 50 ) = 0.25; %shade labels_ii( roi == 170 ) = 0.75; %object boundary labels_ii( roi == 255 ) = 1; %foreground % resize the image to half size if size(im_ii,1) > 400 || size(im_ii,2) >400 im_ii = imresize(im_ii, 0.5, 'nearest'); labels_ii = imresize(labels_ii, 0.5, 'nearest'); end im(:,:,:,ii) = im_ii; labels(:,:,1,ii) = labels_ii; end end function imdb = getImdb(video, imgDir, labelDir) files = [dir([imgDir '/*.png']); dir([imgDir '/*.jpg'])]; label_files = dir([labelDir '/*.png']); names = {};labels = {}; load(['../split/' video '.mat']); for ii = 1:numel(train_index) names{end+1} = [imgDir '/' files(train_index(ii)).name]; labels{end+1} = [labelDir '/' label_files(train_index(ii)).name]; end im = imread(labels{1}); mask = ones(size(im,1),size(im,2)); if size(mask,1) > 400 || size(mask,2) >400 mask = imresize(mask, 0.5, 'nearest'); end imdb.mask = single(mask); imdb.images.set = ones(1,numel(names)); imdb.images.name = names ; imdb.images.labels = labels; end
github
zhimingluo/MovingObjectSegmentation-master
regular_training.m
.m
MovingObjectSegmentation-master/SBMI/BasicCNN/regular_training.m
2,730
utf_8
a9196ae9e46f45d17b86ba05cff18112
function regular_training(video) opts.expDir = ['net/' video] ; opts.train.batchSize = 5 ; opts.train.numEpochs = 20; opts.train.continue = false ; opts.train.useGpu = true ; opts.train.learningRate = 1e-3; opts.train.expDir = opts.expDir ; %opts = vl_argparse(opts, varargin) ; % -------------------------------------------------------------------- % Prepare data % -------------------------------------------------------------------- imgDir = ['../SBMIDataset/' video '/input']; labelDir = ['../SBMIDataset/' video '/groundtruth']; imdb = getImdb(video,imgDir,labelDir); imdb.half_size = 15; %%%%%%Yi%%%%%% redefined the net load('net'); net.layers{end-1} = struct('type', 'conv', ... 'filters', 0.1*randn(1,1,64,1, 'single'), ... 'biases', zeros(1, 1, 'single'), ... 'stride', 1, ... 'pad', 0) ; net.layers{end} = struct('type', 'sigmoidcrossentropyloss'); %load(['../meanPixel/', category, '_', video, '_meanPixel']); load('meanPixel.mat'); imdb.meanPixel = meanPixel; [net,info] = cnn_train_adagrad(net, imdb, @getBatch,... opts.train,'errorType','euclideanloss',... 'conserveMemory', true); end function [im, labels] = getBatch(imdb, batch) % -------------------------------------------------------------------- half_size = imdb.half_size; meanPixel = imdb.meanPixel; for ii = 1:numel(batch) imagename = imdb.images.name{batch(ii)}; im_ii = single(imread(imagename)); labelname = imdb.images.labels{batch(ii)}; roi = imread(labelname); labels_ii = zeros(size(roi,1),size(roi,2)); labels_ii( roi == 50 ) = 0.25; %shade labels_ii( roi == 170 ) = 0.75; %object boundary labels_ii( roi == 255 ) = 1; %foreground % resize the image to half size if size(im_ii,1) > 400 || size(im_ii,2) >400 im_ii = imresize(im_ii, 0.5, 'nearest'); labels_ii = imresize(labels_ii, 0.5, 'nearest'); end im_large = padarray(im_ii,[half_size,half_size],'symmetric'); im_ii = bsxfun(@minus, im_large, meanPixel); im(:,:,:,ii) = im_ii; labels(:,:,1,ii) = labels_ii; labels(:,:,2,ii) = double(ones(size(labels_ii,1),size(labels_ii,2))); end end function imdb = getImdb(video, imgDir, labelDir) files = [dir([imgDir '/*.png']); dir([imgDir '/*.jpg'])]; label_files = dir([labelDir '/*.png']); names = {};labels = {}; load(['../split/' video '.mat']); for ii = 1:numel(train_index) names{end+1} = [imgDir '/' files(train_index(ii)).name]; labels{end+1} = [labelDir '/' label_files(train_index(ii)).name]; end imdb.images.set = ones(1,numel(names)); imdb.images.name = names ; imdb.images.labels = labels; end
github
zhimingluo/MovingObjectSegmentation-master
cnn_train_adagrad.m
.m
MovingObjectSegmentation-master/SBMI/BasicCNN/cnn_train_adagrad.m
11,359
utf_8
b97433eec24865c7f9bc705af9dcbb58
function [net, info] = cnn_train_adagrad(net, imdb, getBatch, varargin) % CNN_TRAIN Demonstrates training a CNN % CNN_TRAIN() is an example learner implementing stochastic gradient % descent with momentum to train a CNN for image classification. % It can be used with different datasets by providing a suitable % getBatch function. opts.train = [] ; opts.val = [] ; opts.numEpochs = 300 ; opts.batchSize = 256 ; opts.useGpu = false ; opts.learningRate = 0.001 ; opts.continue = false ; opts.expDir = fullfile('data','exp') ; opts.conserveMemory = false ; opts.sync = true ; opts.prefetch = false ; opts.weightDecay = 0.0005 ; opts.errorType = 'multiclass' ; opts.plotDiagnostics = false ; opts.delta = 1e-8; opts.display = 1; opts.snapshot = 1; opts.test_interval = 1; opts = vl_argparse(opts, varargin) ; if ~exist(opts.expDir, 'dir'), mkdir(opts.expDir) ; end if isempty(opts.train), opts.train = find(imdb.images.set==1) ; end if isempty(opts.val), opts.val = find(imdb.images.set==2) ; end if isnan(opts.train), opts.train = [] ; end % ------------------------------------------------------------------------- % Network initialization % ------------------------------------------------------------------------- for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = zeros(size(net.layers{i}.filters), ... class(net.layers{i}.filters)) ; net.layers{i}.biasesMomentum = zeros(size(net.layers{i}.biases), ... class(net.layers{i}.biases)) ; %#ok<*ZEROLIKE> if ~isfield(net.layers{i}, 'filtersLearningRate') net.layers{i}.filtersLearningRate = 1 ; end if ~isfield(net.layers{i}, 'biasesLearningRate') net.layers{i}.biasesLearningRate = 1 ; end if ~isfield(net.layers{i}, 'filtersWeightDecay') net.layers{i}.filtersWeightDecay = 1 ; end if ~isfield(net.layers{i}, 'biasesWeightDecay') net.layers{i}.biasesWeightDecay = 1 ; end end if opts.useGpu net = vl_simplenn_move(net, 'gpu') ; for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = gpuArray(net.layers{i}.filtersMomentum) ; net.layers{i}.biasesMomentum = gpuArray(net.layers{i}.biasesMomentum) ; end end G_f = cell(numel(net.layers), 1); G_b = cell(numel(net.layers), 1); for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end G_f{l} = zeros(size(net.layers{l}.filters), 'single'); G_b{l} = zeros(size(net.layers{l}.biases), 'single'); end % ------------------------------------------------------------------------- % Train and validate % ------------------------------------------------------------------------- rng(0) ; if opts.useGpu one = gpuArray(single(1)) ; else one = single(1) ; end info.train.objective = [] ; info.train.error = [] ; info.train.topFiveError = [] ; info.train.speed = [] ; info.val.objective = [] ; info.val.error = [] ; info.val.topFiveError = [] ; info.val.speed = [] ; lr = opts.learningRate ; res = [] ; for epoch=1:opts.numEpochs % fast-forward to where we stopped modelPath = @(ep) fullfile(opts.expDir, sprintf('net-epoch-%d.mat', ep)); modelFigPath = fullfile(opts.expDir, 'net-train.pdf') ; if opts.continue if exist(modelPath(epoch),'file') if epoch == opts.numEpochs load(modelPath(epoch), 'net', 'info') ; end continue ; end if epoch > 1 fprintf('resuming by loading epoch %d\n', epoch-1) ; load(modelPath(epoch-1), 'net', 'info') ; end end train = opts.train(randperm(numel(opts.train))) ; val = opts.val ; info.train.objective(end+1) = 0 ; info.train.error(end+1) = 0 ; info.train.topFiveError(end+1) = 0 ; info.train.speed(end+1) = 0 ; info.val.objective(end+1) = 0 ; info.val.error(end+1) = 0 ; info.val.topFiveError(end+1) = 0 ; info.val.speed(end+1) = 0 ; for t=1:opts.batchSize:numel(train) % get next image batch and labels batch = train(t:min(t+opts.batchSize-1, numel(train))) ; batch_time = tic ; fprintf('training: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(train)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = train(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(train))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end % backprop net.layers{end}.class = labels ; res = vl_simplenn(net, im, one, res, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % gradient step for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end g_f = (net.layers{l}.filtersLearningRate) * ... (opts.weightDecay * net.layers{l}.filtersWeightDecay) * net.layers{l}.filters + ... (net.layers{l}.filtersLearningRate) / numel(batch) * res(l).dzdw{1}; g_b = (net.layers{l}.biasesLearningRate) * ... (opts.weightDecay * net.layers{l}.biasesWeightDecay) * net.layers{l}.biases + ... (net.layers{l}.biasesLearningRate) / numel(batch) * res(l).dzdw{2}; G_f{l} = G_f{l} + g_f .^ 2; G_b{l} = G_b{l} + g_b .^ 2; net.layers{l}.filters = net.layers{l}.filters - lr ./ (opts.delta + sqrt(G_f{l})) .* g_f; net.layers{l}.biases = net.layers{l}.biases - lr ./ (opts.delta + sqrt(G_b{l})) .* g_b; end % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.train = updateError(opts, info.train, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.train.error(end)/n*100, info.train.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.train.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.train.error(end) / n); fprintf('\n') ; end % debug info if opts.plotDiagnostics figure(2) ; vl_simplenn_diagnose(net,res) ; drawnow ; end end % next batch % evaluation on validation set if epoch == 1 || rem(epoch, opts.test_interval) == 0 || epoch == opts.numEpochs for t=1:opts.batchSize:numel(val) batch_time = tic ; batch = val(t:min(t+opts.batchSize-1, numel(val))) ; fprintf('validation: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(val)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = val(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(val))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end net.layers{end}.class = labels ; res = vl_simplenn(net, im, [], res, ... 'disableDropout', true, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.val = updateError(opts, info.val, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.val.error(end)/n*100, info.val.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.val.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.val.error(end) / n); fprintf('\n') ; end end end % save info.train.objective(end) = info.train.objective(end) / numel(train) ; info.train.error(end) = info.train.error(end) / numel(train) ; info.train.topFiveError(end) = info.train.topFiveError(end) / numel(train) ; info.train.speed(end) = numel(train) / info.train.speed(end) ; info.val.objective(end) = info.val.objective(end) / numel(val) ; info.val.error(end) = info.val.error(end) / numel(val) ; info.val.topFiveError(end) = info.val.topFiveError(end) / numel(val) ; info.val.speed(end) = numel(val) / info.val.speed(end) ; if epoch == 1 || rem(epoch, opts.snapshot) == 0 || epoch == opts.numEpochs save(modelPath(epoch), 'net', 'info') ; end if epoch == 1 || rem(epoch, opts.display) == 0 || epoch == opts.numEpochs figure(1) ; clf ; subplot(1,2,1) ; semilogy(1:epoch, info.train.objective, 'k') ; hold on ; semilogy([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.objective([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; xlabel('training epoch') ; ylabel('energy') ; grid on ; h=legend('train', 'val') ; set(h,'color','none'); title('objective') ; subplot(1,2,2) ; switch opts.errorType case 'multiclass' plot(1:epoch, info.train.error, 'k') ; hold on ; plot(1:epoch, info.train.topFiveError, 'k--') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.topFiveError([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b--') ; h=legend('train','train-5','val','val-5') ; case 'binary' plot(1:epoch, info.train.error, 'k') ; hold on ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h=legend('train','val') ; case 'euclideanloss' plot(1 : epoch, info.train.error, 'k'); hold on; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h = legend('train', 'val') ; end grid on ; xlabel('training epoch') ; ylabel('error') ; set(h,'color','none') ; title('error') ; drawnow ; print(1, modelFigPath, '-dpdf') ; end end % ------------------------------------------------------------------------- function info = updateError(opts, info, net, res, speed) % ------------------------------------------------------------------------- predictions = gather(res(end-1).x) ; sz = size(predictions) ; n = prod(sz(1:2)) ; labels = net.layers{end}.class ; info.objective(end) = info.objective(end) + sum(double(gather(res(end).x))) ; info.speed(end) = info.speed(end) + speed ; switch opts.errorType case 'multiclass' [~,predictions] = sort(predictions, 3, 'descend') ; error = ~bsxfun(@eq, predictions, reshape(labels, 1, 1, 1, [])) ; info.error(end) = info.error(end) +.... sum(sum(sum(error(:,:,1,:))))/n ; info.topFiveError(end) = info.topFiveError(end) + ... sum(sum(sum(min(error(:,:,1:5,:),[],3))))/n ; case 'binary' error = bsxfun(@times, predictions, labels) < 0 ; info.error(end) = info.error(end) + sum(error(:))/n ; case 'euclideanloss' error = euclideanloss(sigmoid(predictions), labels); info.error(end) = info.error(end) + error; end
github
zhimingluo/MovingObjectSegmentation-master
training.m
.m
MovingObjectSegmentation-master/CDNet/Cascade/training.m
3,369
utf_8
55bd6c6fc17bd619f84337f5ab575009
function training(video, method, frames) opts.expDir = ['net/' method '/' num2str(frames) '/' video]; opts.train.batchSize = 5 ; opts.train.numEpochs = 20; opts.train.continue = true ; opts.train.useGpu = true ; opts.train.learningRate = 1e-3; opts.train.expDir = opts.expDir; % -------------------------------------------------------------------- % Prepare data % -------------------------------------------------------------------- imgDir = ['../' video '/input']; labelDir = ['../' video '/GT']; grayDir = fullfile('../result/', method, '/', num2str(num_frames), video); imdb = getImdb_new(imgDir, labelDir, grayDir); mask = imread(['../' video '/ROI.bmp']); mask = mask(:, :, 1); A = max(max(mask)); mask(mask == A) = 1; if size(mask, 1) > 400 || size(mask,2) > 400 mask = imresize(mask, 0.5, 'nearest'); end imdb.mask = single(double(mask)); imdb.half_size = 15; %%%%%%Yi%%%%%% redefined the net load('net'); net.layers{1} = struct('type', 'conv', ... 'filters', 0.01 * randn(7, 7, 4, 32, 'single'), ... 'biases', zeros(1, 32, 'single'), ... 'stride', 1, ... 'pad', 0) ; net.layers{end-1} = struct('type', 'conv', ... 'filters', 0.1*randn(1,1,64,1, 'single'), ... 'biases', zeros(1, 1, 'single'), ... 'stride', 1, ... 'pad', 0) ; net.layers{end} = struct('type', 'sigmoidcrossentropyloss'); load('meanPixel.mat'); imdb.meanPixel = meanPixel; [net,info] = cnn_train_adagrad(net, imdb, @getBatch,... opts.train, 'errorType', 'euclideanloss', ... 'conserveMemory', true); end function [im, labels, mask] = getBatch(imdb, batch) half_size = imdb.half_size; meanPixel = imdb.meanPixel; meanPixel(:,:,4) =0; for ii = 1 : numel(batch) imagename = imdb.images.name{batch(ii)}; im_ii = single(imread(imagename)); labelname = imdb.images.labels{batch(ii)}; roi = imread(labelname); labels_ii = zeros(size(roi, 1), size(roi, 2)); labels_ii( roi == 50 ) = 0.25; %shade labels_ii( roi == 170 ) = 0.75; %object boundary labels_ii( roi == 255 ) = 1; %foreground % resize the image to half size if size(im_ii, 1) > 400 || size(im_ii, 2) >400 im_ii = imresize(im_ii, 0.5, 'nearest'); labels_ii = imresize(labels_ii, 0.5, 'nearest'); end grayname =imdb.images.gray_name{batch(ii)}; im_ii(:,:,4) = single(imread(grayname)); im_large = padarray(im_ii, [half_size, half_size], 'symmetric'); im_ii = bsxfun(@minus, im_large, meanPixel); im(:, :, :, ii) = im_ii; labels(:, :, 1, ii) = labels_ii; labels(:, :, 2, ii) = double(imdb.mask); end end function imdb = getImdb_new(imgDir, labelDir, grayDir) files = dir([imgDir '/*.jpg']); label_files = dir([labelDir '/*.png']); names = {}; labels = {}; gray_names = {}; for ii = 1:numel(files) names{end+1} = [imgDir '/' files(ii).name]; labels{end+1} = [labelDir '/' label_files(ii).name]; %prob_name = strrep(label_files(ii).name, 'gt', 'in'); prob_name = strrep(label_files(ii).name, 'gt', 'in'); gray_names{end+1} = [grayDir '/' prob_name]; end imdb.images.set = ones(1,numel(names)); imdb.images.name = names ; imdb.images.gray_name = gray_names; imdb.images.labels = labels; end
github
zhimingluo/MovingObjectSegmentation-master
cnn_train_adagrad.m
.m
MovingObjectSegmentation-master/CDNet/Cascade/cnn_train_adagrad.m
11,673
utf_8
313227873e4c91a0c6db387ba794ec99
function [net, info] = cnn_train_adagrad(net, imdb, getBatch, varargin) % CNN_TRAIN Demonstrates training a CNN % CNN_TRAIN() is an example learner implementing stochastic gradient % descent with momentum to train a CNN for image classification. % It can be used with different datasets by providing a suitable % getBatch function. opts.train = [] ; opts.val = [] ; opts.numEpochs = 300 ; opts.batchSize = 256 ; opts.useGpu = false ; opts.learningRate = 0.001 ; opts.continue = false ; opts.expDir = fullfile('data','exp') ; opts.conserveMemory = false ; opts.sync = true ; opts.prefetch = false ; opts.weightDecay = 0.0005 ; opts.errorType = 'multiclass' ; opts.plotDiagnostics = false ; opts.delta = 1e-8; opts.display = 1; opts.snapshot = 1; opts.test_interval = 1; opts = vl_argparse(opts, varargin) ; if ~exist(opts.expDir, 'dir'), mkdir(opts.expDir); end if isempty(opts.train), opts.train = find(imdb.images.set==1); end if isempty(opts.val), opts.val = find(imdb.images.set==2); end if isnan(opts.train), opts.train = []; end % ------------------------------------------------------------------------- % Network initialization % ------------------------------------------------------------------------- for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = zeros(size(net.layers{i}.filters), ... class(net.layers{i}.filters)) ; net.layers{i}.biasesMomentum = zeros(size(net.layers{i}.biases), ... class(net.layers{i}.biases)) ; %#ok<*ZEROLIKE> if ~isfield(net.layers{i}, 'filtersLearningRate') net.layers{i}.filtersLearningRate = 1 ; end if ~isfield(net.layers{i}, 'biasesLearningRate') net.layers{i}.biasesLearningRate = 1 ; end if ~isfield(net.layers{i}, 'filtersWeightDecay') net.layers{i}.filtersWeightDecay = 1 ; end if ~isfield(net.layers{i}, 'biasesWeightDecay') net.layers{i}.biasesWeightDecay = 1 ; end end if opts.useGpu net = vl_simplenn_move(net, 'gpu') ; for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = gpuArray(net.layers{i}.filtersMomentum) ; net.layers{i}.biasesMomentum = gpuArray(net.layers{i}.biasesMomentum) ; end end G_f = cell(numel(net.layers), 1); G_b = cell(numel(net.layers), 1); for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end G_f{l} = zeros(size(net.layers{l}.filters), 'single'); G_b{l} = zeros(size(net.layers{l}.biases), 'single'); end % ------------------------------------------------------------------------- % Train and validate % ------------------------------------------------------------------------- rng(0) ; if opts.useGpu one = gpuArray(single(1)) ; else one = single(1) ; end info.train.objective = [] ; info.train.error = [] ; info.train.topFiveError = [] ; info.train.speed = [] ; info.val.objective = [] ; info.val.error = [] ; info.val.topFiveError = [] ; info.val.speed = [] ; lr = opts.learningRate ; res = [] ; for epoch=1:opts.numEpochs % fast-forward to where we stopped modelPath = @(ep) fullfile(opts.expDir, sprintf('net-epoch-%d.mat', ep)); modelFigPath = fullfile(opts.expDir, 'net-train.pdf') ; if opts.continue if exist(modelPath(epoch),'file') if epoch == opts.numEpochs load(modelPath(epoch), 'net', 'info') ; end continue ; end if epoch > 1 fprintf('resuming by loading epoch %d\n', epoch-1) ; load(modelPath(epoch-1), 'net', 'info') ; end end train = opts.train(randperm(numel(opts.train))) ; val = opts.val ; info.train.objective(end+1) = 0 ; info.train.error(end+1) = 0 ; info.train.topFiveError(end+1) = 0 ; info.train.speed(end+1) = 0 ; info.val.objective(end+1) = 0 ; info.val.error(end+1) = 0 ; info.val.topFiveError(end+1) = 0 ; info.val.speed(end+1) = 0 ; for t=1:opts.batchSize:numel(train) % get next image batch and labels batch = train(t:min(t+opts.batchSize-1, numel(train))) ; batch_time = tic ; fprintf('training: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(train)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = train(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(train))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end % backprop net.layers{end}.class = labels ; res = vl_simplenn(net, im, one, res, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % gradient step for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end g_f = (net.layers{l}.filtersLearningRate) * ... (opts.weightDecay * net.layers{l}.filtersWeightDecay) * net.layers{l}.filters + ... (net.layers{l}.filtersLearningRate) / numel(batch) * res(l).dzdw{1}; g_b = (net.layers{l}.biasesLearningRate) * ... (opts.weightDecay * net.layers{l}.biasesWeightDecay) * net.layers{l}.biases + ... (net.layers{l}.biasesLearningRate) / numel(batch) * res(l).dzdw{2}; G_f{l} = G_f{l} + g_f .^ 2; G_b{l} = G_b{l} + g_b .^ 2; net.layers{l}.filters = net.layers{l}.filters - lr ./ (opts.delta + sqrt(G_f{l})) .* g_f; net.layers{l}.biases = net.layers{l}.biases - lr ./ (opts.delta + sqrt(G_b{l})) .* g_b; end % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.train = updateError(opts, info.train, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.train.error(end)/n*100, info.train.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.train.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.train.error(end) / n); fprintf('\n') ; end % debug info if opts.plotDiagnostics figure(2) ; vl_simplenn_diagnose(net,res) ; drawnow ; end end % next batch % evaluation on validation set if epoch == 1 || rem(epoch, opts.test_interval) == 0 || epoch == opts.numEpochs for t=1:opts.batchSize:numel(val) batch_time = tic ; batch = val(t:min(t+opts.batchSize-1, numel(val))) ; fprintf('validation: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(val)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = val(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(val))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end net.layers{end}.class = labels ; res = vl_simplenn(net, im, [], res, ... 'disableDropout', true, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.val = updateError(opts, info.val, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.val.error(end)/n*100, info.val.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.val.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.val.error(end) / n); fprintf('\n') ; end end end % save info.train.objective(end) = info.train.objective(end) / numel(train) ; info.train.error(end) = info.train.error(end) / numel(train) ; info.train.topFiveError(end) = info.train.topFiveError(end) / numel(train) ; info.train.speed(end) = numel(train) / info.train.speed(end) ; info.val.objective(end) = info.val.objective(end) / numel(val) ; info.val.error(end) = info.val.error(end) / numel(val) ; info.val.topFiveError(end) = info.val.topFiveError(end) / numel(val) ; info.val.speed(end) = numel(val) / info.val.speed(end) ; if epoch == 1 || rem(epoch, opts.snapshot) == 0 || epoch == opts.numEpochs save(modelPath(epoch), 'net', 'info') ; end if epoch == 1 || rem(epoch, opts.display) == 0 || epoch == opts.numEpochs figure(1) ; clf ; subplot(1,2,1) ; semilogy(1:epoch, info.train.objective, 'k') ; hold on ; semilogy([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.objective([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; xlabel('training epoch') ; ylabel('energy') ; grid on ; h=legend('train', 'val') ; set(h,'color','none'); title('objective') ; subplot(1,2,2) ; switch opts.errorType case 'multiclass' plot(1:epoch, info.train.error, 'k') ; hold on ; plot(1:epoch, info.train.topFiveError, 'k--') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.topFiveError([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b--') ; h=legend('train','train-5','val','val-5') ; case 'binary' plot(1:epoch, info.train.error, 'k') ; hold on ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h=legend('train','val') ; case 'euclideanloss' plot(1 : epoch, info.train.error, 'k'); hold on; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h = legend('train', 'val') ; end grid on ; xlabel('training epoch') ; ylabel('error') ; set(h,'color','none') ; title('error') ; drawnow ; print(1, modelFigPath, '-dpdf') ; end end % ------------------------------------------------------------------------- function info = updateError(opts, info, net, res, speed) % ------------------------------------------------------------------------- predictions = gather(res(end-1).x) ; sz = size(predictions) ; n = prod(sz(1:2)) ; labels = net.layers{end}.class ; info.objective(end) = info.objective(end) + sum(double(gather(res(end).x))) ; info.speed(end) = info.speed(end) + speed ; switch opts.errorType case 'multiclass' [~,predictions] = sort(predictions, 3, 'descend') ; error = ~bsxfun(@eq, predictions, reshape(labels, 1, 1, 1, [])) ; info.error(end) = info.error(end) +.... sum(sum(sum(error(:,:,1,:))))/n ; info.topFiveError(end) = info.topFiveError(end) + ... sum(sum(sum(min(error(:,:,1:5,:),[],3))))/n ; case 'binary' error = bsxfun(@times, predictions, labels) < 0 ; info.error(end) = info.error(end) + sum(error(:))/n ; case 'euclideanloss' error = euclideanloss(sigmoid(predictions), labels); info.error(end) = info.error(end) + error; end
github
zhimingluo/MovingObjectSegmentation-master
ms_regular_training.m
.m
MovingObjectSegmentation-master/CDNet/MSCNN/ms_regular_training.m
2,806
utf_8
84fba4417e546a61491110751487c70a
function ms_regular_training(video, method, frames) opts.expDir = ['net/' method '/' num2str(frames) '/' video] ; opts.train.batchSize = 5 ; opts.train.numEpochs = 20; opts.train.continue = false ; opts.train.useGpu = true ; opts.train.learningRate = 1e-3; opts.train.expDir = opts.expDir ; scales = [1, 0.75, 0.5]; %opts = vl_argparse(opts, varargin) ; % -------------------------------------------------------------------- % Prepare data % -------------------------------------------------------------------- imgDir = ['../CDNetDataset/' method '/' num2str(frames) 'frames/' video '/input']; labelDir = ['../CDNetDataset/' method '/' num2str(frames) 'frames/' video '/GT']; imdb = getImdb(imgDir,labelDir); mask = imread(['../CDNetDataset/' method '/' num2str(frames) 'frames/' video '/ROI.bmp']); mask = mask(:,:,1); A = max(max(mask)); mask(mask == A) = 1; if size(mask,1) > 400 || size(mask,2) >400 mask = imresize(mask, 0.5, 'nearest'); end imdb.mask = single(double(mask)); imdb.half_size = 15; %%%%%%Yi%%%%%% redefined the net load('net'); net.layers{end-1} = struct('type', 'conv', ... 'filters', 0.1*randn(1,1,64,1, 'single'), ... 'biases', zeros(1, 1, 'single'), ... 'stride', 1, ... 'pad', 0) ; net.layers{end} = struct('type', 'sigmoidcrossentropyloss'); load('meanPixel.mat'); imdb.meanPixel = meanPixel; imdb.scales = scales; [net,info] = cnn_train_adagrad_ms(net, imdb, @getBatch,... opts.train,'errorType','euclideanloss',... 'conserveMemory', true); end function [im, labels] = getBatch(imdb, batch) % -------------------------------------------------------------------- half_size = imdb.half_size; meanPixel = imdb.meanPixel; for ii = 1:numel(batch) imagename = imdb.images.name{batch(ii)}; im_ii = single(imread(imagename)); labelname = imdb.images.labels{batch(ii)}; roi = imread(labelname); labels_ii = zeros(size(roi, 1), size(roi, 2)); labels_ii( roi == 50 ) = 0.25; %shade labels_ii( roi == 170 ) = 0.75; %object boundary labels_ii( roi == 255 ) = 1; %foreground % resize the image to half size if size(im_ii,1) > 400 || size(im_ii,2) >400 im_ii = imresize(im_ii, 0.5, 'nearest'); labels_ii = imresize(labels_ii, 0.5, 'nearest'); end im(:,:,:,ii) = im_ii; labels(:,:,1,ii) = labels_ii; end end function imdb = getImdb(imgDir, labelDir) files = dir([imgDir '/*.jpg']); label_files = dir([labelDir '/*.png']); names = {};labels = {}; for ii = 1:numel(files) names{end+1} = [imgDir '/' files(ii).name]; labels{end+1} = [labelDir '/' label_files(ii).name]; end imdb.images.set = ones(1,numel(names)); imdb.images.name = names ; imdb.images.labels = labels; end
github
zhimingluo/MovingObjectSegmentation-master
cnn_train_adagrad_ms.m
.m
MovingObjectSegmentation-master/CDNet/MSCNN/cnn_train_adagrad_ms.m
13,645
utf_8
f04bf6fcc2468adcfb032edb55192a75
function [net, info] = cnn_train_adagrad_ms(net, imdb, getBatch, varargin) % CNN_TRAIN Demonstrates training a CNN % CNN_TRAIN() is an example learner implementing stochastic gradient % descent with momentum to train a CNN for image classification. % It can be used with different datasets by providing a suitable % getBatch function. opts.train = [] ; opts.val = [] ; opts.numEpochs = 300 ; opts.batchSize = 256 ; opts.useGpu = false ; opts.learningRate = 0.001 ; opts.continue = false ; opts.expDir = fullfile('data','exp') ; opts.conserveMemory = false ; opts.sync = true ; opts.prefetch = false ; opts.weightDecay = 0.0005 ; opts.errorType = 'multiclass' ; opts.plotDiagnostics = false ; opts.delta = 1e-8; opts.display = 1; opts.snapshot = 1; opts.test_interval = 1; opts = vl_argparse(opts, varargin) ; if ~exist(opts.expDir, 'dir'), mkdir(opts.expDir); end if isempty(opts.train), opts.train = find(imdb.images.set==1); end if isempty(opts.val), opts.val = find(imdb.images.set==2); end if isnan(opts.train), opts.train = []; end % ------------------------------------------------------------------------- % Network initialization % ------------------------------------------------------------------------- for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = zeros(size(net.layers{i}.filters), ... class(net.layers{i}.filters)) ; net.layers{i}.biasesMomentum = zeros(size(net.layers{i}.biases), ... class(net.layers{i}.biases)) ; %#ok<*ZEROLIKE> if ~isfield(net.layers{i}, 'filtersLearningRate') net.layers{i}.filtersLearningRate = 1 ; end if ~isfield(net.layers{i}, 'biasesLearningRate') net.layers{i}.biasesLearningRate = 1 ; end if ~isfield(net.layers{i}, 'filtersWeightDecay') net.layers{i}.filtersWeightDecay = 1 ; end if ~isfield(net.layers{i}, 'biasesWeightDecay') net.layers{i}.biasesWeightDecay = 1 ; end end if opts.useGpu net = vl_simplenn_move(net, 'gpu') ; for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = gpuArray(net.layers{i}.filtersMomentum) ; net.layers{i}.biasesMomentum = gpuArray(net.layers{i}.biasesMomentum) ; end end G_f = cell(numel(net.layers), 1); G_b = cell(numel(net.layers), 1); for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end G_f{l} = zeros(size(net.layers{l}.filters), 'single'); G_b{l} = zeros(size(net.layers{l}.biases), 'single'); end % ------------------------------------------------------------------------- % Train and validate % ------------------------------------------------------------------------- rng(0) ; if opts.useGpu one = gpuArray(single(1)) ; else one = single(1) ; end info.train.objective = [] ; info.train.error = [] ; info.train.topFiveError = [] ; info.train.speed = [] ; info.val.objective = [] ; info.val.error = [] ; info.val.topFiveError = [] ; info.val.speed = [] ; lr = opts.learningRate ; res = [] ; for epoch=1:opts.numEpochs % fast-forward to where we stopped modelPath = @(ep) fullfile(opts.expDir, sprintf('net-epoch-%d.mat', ep)); modelFigPath = fullfile(opts.expDir, 'net-train.pdf') ; if opts.continue if exist(modelPath(epoch),'file') if epoch == opts.numEpochs load(modelPath(epoch), 'net', 'info') ; end continue ; end if epoch > 1 fprintf('resuming by loading epoch %d\n', epoch-1) ; load(modelPath(epoch-1), 'net', 'info') ; end end train = opts.train(randperm(numel(opts.train))) ; val = opts.val ; info.train.objective(end+1) = 0 ; info.train.error(end+1) = 0 ; info.train.topFiveError(end+1) = 0 ; info.train.speed(end+1) = 0 ; info.val.objective(end+1) = 0 ; info.val.error(end+1) = 0 ; info.val.topFiveError(end+1) = 0 ; info.val.speed(end+1) = 0 ; for t=1:opts.batchSize:numel(train) % get next image batch and labels batch = train(t:min(t+opts.batchSize-1, numel(train))) ; batch_time = tic ; fprintf('training: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(train)/opts.batchSize)) ; [im_ori, labels_ori] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = train(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(train))) ; getBatch(imdb, nextBatch) ; end for ss = 1 : numel(imdb.scales) [im, labels] = rescale_im(im_ori, labels_ori, imdb.scales(ss),... imdb.mask, imdb.half_size, imdb.meanPixel); if opts.useGpu im = gpuArray(im) ; end % backprop net.layers{end}.class = labels ; res = vl_simplenn(net, im, one, res, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % gradient step for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end g_f = (net.layers{l}.filtersLearningRate) * ... (opts.weightDecay * net.layers{l}.filtersWeightDecay) * net.layers{l}.filters + ... (net.layers{l}.filtersLearningRate) / numel(batch) * res(l).dzdw{1}; g_b = (net.layers{l}.biasesLearningRate) * ... (opts.weightDecay * net.layers{l}.biasesWeightDecay) * net.layers{l}.biases + ... (net.layers{l}.biasesLearningRate) / numel(batch) * res(l).dzdw{2}; G_f{l} = G_f{l} + g_f .^ 2; G_b{l} = G_b{l} + g_b .^ 2; net.layers{l}.filters = net.layers{l}.filters - lr ./ (opts.delta + sqrt(G_f{l})) .* g_f; net.layers{l}.biases = net.layers{l}.biases - lr ./ (opts.delta + sqrt(G_b{l})) .* g_b; end end % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.train = updateError(opts, info.train, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.train.error(end)/n*100, info.train.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.train.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.train.error(end) / n); fprintf('\n') ; end % debug info if opts.plotDiagnostics figure(2) ; vl_simplenn_diagnose(net,res) ; drawnow ; end end % next batch % evaluation on validation set if epoch == 1 || rem(epoch, opts.test_interval) == 0 || epoch == opts.numEpochs for t=1:opts.batchSize:numel(val) batch_time = tic ; batch = val(t:min(t+opts.batchSize-1, numel(val))) ; fprintf('validation: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(val)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = val(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(val))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end net.layers{end}.class = labels ; res = vl_simplenn(net, im, [], res, ... 'disableDropout', true, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.val = updateError(opts, info.val, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.val.error(end)/n*100, info.val.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.val.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.val.error(end) / n); fprintf('\n') ; end end end % save info.train.objective(end) = info.train.objective(end) / numel(train) ; info.train.error(end) = info.train.error(end) / numel(train) ; info.train.topFiveError(end) = info.train.topFiveError(end) / numel(train) ; info.train.speed(end) = numel(train) / info.train.speed(end) ; info.val.objective(end) = info.val.objective(end) / numel(val) ; info.val.error(end) = info.val.error(end) / numel(val) ; info.val.topFiveError(end) = info.val.topFiveError(end) / numel(val) ; info.val.speed(end) = numel(val) / info.val.speed(end) ; if epoch == 1 || rem(epoch, opts.snapshot) == 0 || epoch == opts.numEpochs save(modelPath(epoch), 'net', 'info') ; end if epoch == 1 || rem(epoch, opts.display) == 0 || epoch == opts.numEpochs figure(1) ; clf ; subplot(1,2,1) ; semilogy(1:epoch, info.train.objective, 'k') ; hold on ; semilogy([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.objective([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; xlabel('training epoch') ; ylabel('energy') ; grid on ; h=legend('train', 'val') ; set(h,'color','none'); title('objective') ; subplot(1,2,2) ; switch opts.errorType case 'multiclass' plot(1:epoch, info.train.error, 'k') ; hold on ; plot(1:epoch, info.train.topFiveError, 'k--') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.topFiveError([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b--') ; h=legend('train','train-5','val','val-5') ; case 'binary' plot(1:epoch, info.train.error, 'k') ; hold on ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h=legend('train','val') ; case 'euclideanloss' plot(1 : epoch, info.train.error, 'k'); hold on; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h = legend('train', 'val') ; end grid on ; xlabel('training epoch') ; ylabel('error') ; set(h,'color','none') ; title('error') ; drawnow ; print(1, modelFigPath, '-dpdf') ; end end end % ------------------------------------------------------------------------- function info = updateError(opts, info, net, res, speed) % ------------------------------------------------------------------------- predictions = gather(res(end-1).x) ; sz = size(predictions) ; n = prod(sz(1:2)) ; labels = net.layers{end}.class ; info.objective(end) = info.objective(end) + sum(double(gather(res(end).x))) ; info.speed(end) = info.speed(end) + speed ; switch opts.errorType case 'multiclass' [~,predictions] = sort(predictions, 3, 'descend') ; error = ~bsxfun(@eq, predictions, reshape(labels, 1, 1, 1, [])) ; info.error(end) = info.error(end) +.... sum(sum(sum(error(:,:,1,:))))/n ; info.topFiveError(end) = info.topFiveError(end) + ... sum(sum(sum(min(error(:,:,1:5,:),[],3))))/n ; case 'binary' labels = labels(:,:,1,:); [~,predictions] = sort(predictions, 3, 'descend') ; predictions = predictions(:,:,1,:); error = ~bsxfun(@eq, predictions, labels) ; info.error(end) = info.error(end) + sum(error(:))/n ; case 'euclideanloss' error = euclideanloss(sigmoid(predictions), labels); info.error(end) = info.error(end) + error; end end function [im, labels] = rescale_im(im_ori, label_ori, scale, mask, half_size, meanPixel) mask = imresize(mask, scale, 'nearest'); for i = 1:size(im_ori,4) im_ii = imresize(im_ori(:,:,:,i), scale, 'nearest'); im_large = padarray(im_ii, [half_size, half_size], 'symmetric'); im_ii = bsxfun(@minus, im_large, meanPixel); label_ii = imresize(label_ori(:,:,:,i), scale, 'nearest'); im(:, :, :, i) = im_ii; labels(:, :, 1, i) = label_ii; labels(:, :, 2, i) = double(mask); end end
github
zhimingluo/MovingObjectSegmentation-master
regular_training.m
.m
MovingObjectSegmentation-master/CDNet/BasicCNN/regular_training.m
2,883
utf_8
1cd69f4eb86fc4053c598bf51bbc5147
function regular_training(video, method, frames) opts.expDir = ['net/' method '/' num2str(frames) '/' video] ; opts.train.batchSize = 5 ; opts.train.numEpochs = 20; opts.train.continue = false ; opts.train.useGpu = true ; opts.train.learningRate = 1e-3; opts.train.expDir = opts.expDir ; % -------------------------------------------------------------------- % Prepare data % -------------------------------------------------------------------- imgDir = ['../CDNetDataset/' method '/' num2str(frames) 'frames/' video '/input']; labelDir = ['../CDNetDataset/' method '/' num2str(frames) 'frames/' video '/GT']; imdb = getImdb(imgDir,labelDir); mask = imread(['../CDNetDataset/' method '/' num2str(frames) 'frames/' video '/ROI.bmp']); mask = mask(:,:,1); A = max(max(mask)); mask(mask == A) = 1; if size(mask,1) > 400 || size(mask,2) >400 mask = imresize(mask, 0.5, 'nearest'); end imdb.mask = single(double(mask)); imdb.half_size = 15; %%%%%%Yi%%%%%% redefined the net load('net'); net.layers{end-1} = struct('type', 'conv', ... 'filters', 0.1*randn(1,1,64,1, 'single'), ... 'biases', zeros(1, 1, 'single'), ... 'stride', 1, ... 'pad', 0) ; net.layers{end} = struct('type', 'sigmoidcrossentropyloss'); load('meanPixel.mat'); imdb.meanPixel = meanPixel; [net,info] = cnn_train_adagrad(net, imdb, @getBatch,... opts.train,'errorType','euclideanloss',... 'conserveMemory', true); end function [im, labels] = getBatch(imdb, batch) % -------------------------------------------------------------------- half_size = imdb.half_size; meanPixel = imdb.meanPixel; for ii = 1:numel(batch) imagename = imdb.images.name{batch(ii)}; im_ii = single(imread(imagename)); labelname = imdb.images.labels{batch(ii)}; roi = imread(labelname); labels_ii = zeros(size(roi,1),size(roi,2)); labels_ii( roi == 50 ) = 0.25; %shade labels_ii( roi == 170 ) = 0.75; %object boundary labels_ii( roi == 255 ) = 1; %foreground % resize the image to half size if size(im_ii,1) > 400 || size(im_ii,2) >400 im_ii = imresize(im_ii, 0.5, 'nearest'); labels_ii = imresize(labels_ii, 0.5, 'nearest'); end im_large = padarray(im_ii,[half_size,half_size],'symmetric'); im_ii = bsxfun(@minus, im_large, meanPixel); im(:,:,:,ii) = im_ii; labels(:,:,1,ii) = labels_ii; labels(:,:,2,ii) = double(imdb.mask); end end function imdb = getImdb(imgDir, labelDir) files = dir([imgDir '/*.jpg']); label_files = dir([labelDir '/*.png']); names = {};labels = {}; for ii = 1:numel(files) names{end+1} = [imgDir '/' files(ii).name]; labels{end+1} = [labelDir '/' label_files(ii).name]; end imdb.images.set = ones(1,numel(names)); imdb.images.name = names ; imdb.images.labels = labels; end
github
zhimingluo/MovingObjectSegmentation-master
cnn_train_adagrad.m
.m
MovingObjectSegmentation-master/CDNet/BasicCNN/cnn_train_adagrad.m
11,359
utf_8
b97433eec24865c7f9bc705af9dcbb58
function [net, info] = cnn_train_adagrad(net, imdb, getBatch, varargin) % CNN_TRAIN Demonstrates training a CNN % CNN_TRAIN() is an example learner implementing stochastic gradient % descent with momentum to train a CNN for image classification. % It can be used with different datasets by providing a suitable % getBatch function. opts.train = [] ; opts.val = [] ; opts.numEpochs = 300 ; opts.batchSize = 256 ; opts.useGpu = false ; opts.learningRate = 0.001 ; opts.continue = false ; opts.expDir = fullfile('data','exp') ; opts.conserveMemory = false ; opts.sync = true ; opts.prefetch = false ; opts.weightDecay = 0.0005 ; opts.errorType = 'multiclass' ; opts.plotDiagnostics = false ; opts.delta = 1e-8; opts.display = 1; opts.snapshot = 1; opts.test_interval = 1; opts = vl_argparse(opts, varargin) ; if ~exist(opts.expDir, 'dir'), mkdir(opts.expDir) ; end if isempty(opts.train), opts.train = find(imdb.images.set==1) ; end if isempty(opts.val), opts.val = find(imdb.images.set==2) ; end if isnan(opts.train), opts.train = [] ; end % ------------------------------------------------------------------------- % Network initialization % ------------------------------------------------------------------------- for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = zeros(size(net.layers{i}.filters), ... class(net.layers{i}.filters)) ; net.layers{i}.biasesMomentum = zeros(size(net.layers{i}.biases), ... class(net.layers{i}.biases)) ; %#ok<*ZEROLIKE> if ~isfield(net.layers{i}, 'filtersLearningRate') net.layers{i}.filtersLearningRate = 1 ; end if ~isfield(net.layers{i}, 'biasesLearningRate') net.layers{i}.biasesLearningRate = 1 ; end if ~isfield(net.layers{i}, 'filtersWeightDecay') net.layers{i}.filtersWeightDecay = 1 ; end if ~isfield(net.layers{i}, 'biasesWeightDecay') net.layers{i}.biasesWeightDecay = 1 ; end end if opts.useGpu net = vl_simplenn_move(net, 'gpu') ; for i=1:numel(net.layers) if ~strcmp(net.layers{i}.type,'conv'), continue; end net.layers{i}.filtersMomentum = gpuArray(net.layers{i}.filtersMomentum) ; net.layers{i}.biasesMomentum = gpuArray(net.layers{i}.biasesMomentum) ; end end G_f = cell(numel(net.layers), 1); G_b = cell(numel(net.layers), 1); for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end G_f{l} = zeros(size(net.layers{l}.filters), 'single'); G_b{l} = zeros(size(net.layers{l}.biases), 'single'); end % ------------------------------------------------------------------------- % Train and validate % ------------------------------------------------------------------------- rng(0) ; if opts.useGpu one = gpuArray(single(1)) ; else one = single(1) ; end info.train.objective = [] ; info.train.error = [] ; info.train.topFiveError = [] ; info.train.speed = [] ; info.val.objective = [] ; info.val.error = [] ; info.val.topFiveError = [] ; info.val.speed = [] ; lr = opts.learningRate ; res = [] ; for epoch=1:opts.numEpochs % fast-forward to where we stopped modelPath = @(ep) fullfile(opts.expDir, sprintf('net-epoch-%d.mat', ep)); modelFigPath = fullfile(opts.expDir, 'net-train.pdf') ; if opts.continue if exist(modelPath(epoch),'file') if epoch == opts.numEpochs load(modelPath(epoch), 'net', 'info') ; end continue ; end if epoch > 1 fprintf('resuming by loading epoch %d\n', epoch-1) ; load(modelPath(epoch-1), 'net', 'info') ; end end train = opts.train(randperm(numel(opts.train))) ; val = opts.val ; info.train.objective(end+1) = 0 ; info.train.error(end+1) = 0 ; info.train.topFiveError(end+1) = 0 ; info.train.speed(end+1) = 0 ; info.val.objective(end+1) = 0 ; info.val.error(end+1) = 0 ; info.val.topFiveError(end+1) = 0 ; info.val.speed(end+1) = 0 ; for t=1:opts.batchSize:numel(train) % get next image batch and labels batch = train(t:min(t+opts.batchSize-1, numel(train))) ; batch_time = tic ; fprintf('training: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(train)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = train(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(train))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end % backprop net.layers{end}.class = labels ; res = vl_simplenn(net, im, one, res, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % gradient step for l=1:numel(net.layers) if ~strcmp(net.layers{l}.type, 'conv'), continue ; end g_f = (net.layers{l}.filtersLearningRate) * ... (opts.weightDecay * net.layers{l}.filtersWeightDecay) * net.layers{l}.filters + ... (net.layers{l}.filtersLearningRate) / numel(batch) * res(l).dzdw{1}; g_b = (net.layers{l}.biasesLearningRate) * ... (opts.weightDecay * net.layers{l}.biasesWeightDecay) * net.layers{l}.biases + ... (net.layers{l}.biasesLearningRate) / numel(batch) * res(l).dzdw{2}; G_f{l} = G_f{l} + g_f .^ 2; G_b{l} = G_b{l} + g_b .^ 2; net.layers{l}.filters = net.layers{l}.filters - lr ./ (opts.delta + sqrt(G_f{l})) .* g_f; net.layers{l}.biases = net.layers{l}.biases - lr ./ (opts.delta + sqrt(G_b{l})) .* g_b; end % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.train = updateError(opts, info.train, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.train.error(end)/n*100, info.train.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.train.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.train.error(end) / n); fprintf('\n') ; end % debug info if opts.plotDiagnostics figure(2) ; vl_simplenn_diagnose(net,res) ; drawnow ; end end % next batch % evaluation on validation set if epoch == 1 || rem(epoch, opts.test_interval) == 0 || epoch == opts.numEpochs for t=1:opts.batchSize:numel(val) batch_time = tic ; batch = val(t:min(t+opts.batchSize-1, numel(val))) ; fprintf('validation: epoch %02d: processing batch %3d of %3d ...', epoch, ... fix(t/opts.batchSize)+1, ceil(numel(val)/opts.batchSize)) ; [im, labels] = getBatch(imdb, batch) ; if opts.prefetch nextBatch = val(t+opts.batchSize:min(t+2*opts.batchSize-1, numel(val))) ; getBatch(imdb, nextBatch) ; end if opts.useGpu im = gpuArray(im) ; end net.layers{end}.class = labels ; res = vl_simplenn(net, im, [], res, ... 'disableDropout', true, ... 'conserveMemory', opts.conserveMemory, ... 'sync', opts.sync) ; % print information batch_time = toc(batch_time) ; speed = numel(batch)/batch_time ; info.val = updateError(opts, info.val, net, res, batch_time) ; fprintf(' %.2f s (%.1f images/s)', batch_time, speed) ; n = t + numel(batch) - 1 ; switch opts.errorType case 'multiclass' fprintf(' err %.1f err5 %.1f', ... info.val.error(end)/n*100, info.val.topFiveError(end)/n*100) ; fprintf('\n') ; case 'binary' fprintf(' err %.1f', ... info.val.error(end)/n*100) ; fprintf('\n') ; case 'euclideanloss' fprintf(' err %.1f', info.val.error(end) / n); fprintf('\n') ; end end end % save info.train.objective(end) = info.train.objective(end) / numel(train) ; info.train.error(end) = info.train.error(end) / numel(train) ; info.train.topFiveError(end) = info.train.topFiveError(end) / numel(train) ; info.train.speed(end) = numel(train) / info.train.speed(end) ; info.val.objective(end) = info.val.objective(end) / numel(val) ; info.val.error(end) = info.val.error(end) / numel(val) ; info.val.topFiveError(end) = info.val.topFiveError(end) / numel(val) ; info.val.speed(end) = numel(val) / info.val.speed(end) ; if epoch == 1 || rem(epoch, opts.snapshot) == 0 || epoch == opts.numEpochs save(modelPath(epoch), 'net', 'info') ; end if epoch == 1 || rem(epoch, opts.display) == 0 || epoch == opts.numEpochs figure(1) ; clf ; subplot(1,2,1) ; semilogy(1:epoch, info.train.objective, 'k') ; hold on ; semilogy([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.objective([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; xlabel('training epoch') ; ylabel('energy') ; grid on ; h=legend('train', 'val') ; set(h,'color','none'); title('objective') ; subplot(1,2,2) ; switch opts.errorType case 'multiclass' plot(1:epoch, info.train.error, 'k') ; hold on ; plot(1:epoch, info.train.topFiveError, 'k--') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.topFiveError([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b--') ; h=legend('train','train-5','val','val-5') ; case 'binary' plot(1:epoch, info.train.error, 'k') ; hold on ; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h=legend('train','val') ; case 'euclideanloss' plot(1 : epoch, info.train.error, 'k'); hold on; plot([1 opts.test_interval : opts.test_interval : epoch epoch], info.val.error([1 opts.test_interval : opts.test_interval : epoch epoch]), 'b') ; h = legend('train', 'val') ; end grid on ; xlabel('training epoch') ; ylabel('error') ; set(h,'color','none') ; title('error') ; drawnow ; print(1, modelFigPath, '-dpdf') ; end end % ------------------------------------------------------------------------- function info = updateError(opts, info, net, res, speed) % ------------------------------------------------------------------------- predictions = gather(res(end-1).x) ; sz = size(predictions) ; n = prod(sz(1:2)) ; labels = net.layers{end}.class ; info.objective(end) = info.objective(end) + sum(double(gather(res(end).x))) ; info.speed(end) = info.speed(end) + speed ; switch opts.errorType case 'multiclass' [~,predictions] = sort(predictions, 3, 'descend') ; error = ~bsxfun(@eq, predictions, reshape(labels, 1, 1, 1, [])) ; info.error(end) = info.error(end) +.... sum(sum(sum(error(:,:,1,:))))/n ; info.topFiveError(end) = info.topFiveError(end) + ... sum(sum(sum(min(error(:,:,1:5,:),[],3))))/n ; case 'binary' error = bsxfun(@times, predictions, labels) < 0 ; info.error(end) = info.error(end) + sum(error(:))/n ; case 'euclideanloss' error = euclideanloss(sigmoid(predictions), labels); info.error(end) = info.error(end) + error; end
github
gramuah/pose-errors-master
writeNumObjClass.m
.m
pose-errors-master/src/writeNumObjClass.m
303
utf_8
a8dcea39cdb9809fe77f44ecbf61b417
function writeNumObjClass(outdir, objects) if ~exist(outdir, 'file'), mkdir(outdir); end; global fid fid = fopen(fullfile(outdir, ['classes.tex']), 'w'); for obj=1:length(objects) pr('\\input{%s}\n', objects{obj}); end fclose(fid); function pr(varargin) global fid; fprintf(fid, varargin{:});
github
gramuah/pose-errors-master
writeTexObject.m
.m
pose-errors-master/src/writeTexObject.m
17,543
utf_8
03d088c85af1a2b7ee209ac56eaf02e6
function writeTexObject(name, outdir, gt, metric_type, dataset, detector) % writeTexObject(name, outdir, gt) % % Adds latex code to an existing file for one object: switch metric_type case 1 metric = 'AOS'; case 2 metric = 'AVP'; case 3 metric = 'PEAP'; case 4 metric = 'MAE'; case 5 metric = 'MedError'; end if ~exist(outdir, 'file'), mkdir(outdir); end; global fid fid = fopen(fullfile(outdir, [name '.tex']), 'w'); pr('\\subsection{%s}\n\n', name); % create table if ~isempty(gt) pr('\\textbf{Statistics for %s class:}\n', name); pr('\n\n') pr('Number of objects = %d, No difficult objects = %d\n', length(gt.isdiff), sum(~gt.isdiff)); pr('\n\n') pr('Truncated: None = %d, Truncated = %d\n', sum(~gt.isdiff)-sum(gt.istrunc), sum(gt.istrunc)); pr('\n\n') if ~isempty(gt.details{1}) details = cat(1, gt.details{:}); pr('Occluded: None = %d, Occluded = %d\n', hist([details.occ_level], 1:2)); pr('\n\n') a = find(gt.istrunc == 1); b = find(gt.isocc == 1); [c1,ia1] = setdiff(a,b); occtrunc = max(length(a), length(b)) - length(ia1); pr('Occluded and Truncated: %d\n', occtrunc); sv = [details.side_visible]; names = fieldnames(details(1).side_visible); pr('\n\n') pr('side visible: \n'); pr('\\begin{verbatim}\n'); for k = 1:numel(names) pr(' %s: Yes = %d No = %d \n', names{k}, sum([sv.(names{k})]==1), sum([sv.(names{k})]==0)); end pr('\\end{verbatim}\n'); pr('\n\n') pr('part visible: \n'); pr('\\begin{verbatim}\n'); sv = [details.part_visible]; names = fieldnames(details(1).part_visible); for k = 1:numel(names) pr(' part %d = %s: Yes = %d No = %d \n', k, names{k}, sum([sv.(names{k})]==1), sum([sv.(names{k})]==0)); end pr('\\end{verbatim}\n'); end pr('\n\n'); end pr('\\clearpage') pr('\n\n'); pr('Figure \\ref{fig1%s} summarizes the viewpoint distribution on the test set for %s class considering the 8 views described in Section \\ref{info}. Figure \\ref{fig2%s} shows the analysis and the impact on the pose performance of each type of pose error. We also report in Figure \\ref{fig3%s} the success rate for %s class considering each of the 8 viewpoints described in Section \\ref{info}. ', name, name, name, name, name); if exist(fullfile(outdir(1:end-4), name, 'analysisI/plot_2.pdf'), 'file') pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\includegraphics[width=0.65\\textwidth,trim = 20mm 65mm 25mm 60mm, clip]{../%s/analysisI/plot_3.pdf}\n', name); pr('\\caption{\\textbf{Analysis of Pose Distribution.} Histogram represents viewpoint distribution on test set for %s class from %s dataset.}\n', name, dataset); pr('\\label{fig1%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end if exist(fullfile(outdir(1:end-4), name, 'analysisI/plot_2.pdf'), 'file') pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig2%sa}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 20mm 65mm 25mm 60mm, clip]{../%s/analysisI/plot_2.pdf}\n', name); pr('}\n'); pr('\\subfloat[]{\n'); pr('\\label{fig2%sb}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 25mm 60mm, clip]{../%s/analysisI/plot_1.pdf}\n', name); pr('}\n'); pr('\\caption{\\textbf{Analysis of the Main Pose Estimation Errors.} (a) Given the correct detections, pie chart shows the fraction of pose error that are due to Opposite viewpoints (Opposite), confusion with Nearby viewpoints (Nearby), confusion with Other rotations (Other), and correct pose estimations (Correct) for %s class. (b) Impact of pose errors in terms of %s. \\textcolor{blue}{Blue Bars} show the %s performance obtained when all estimations are considered. \\textcolor{green}{Green Bars} display the %s improvement by removing all estimations of one type: \\textbf{OTH} removes confusion with other rotation viewpoints; \\textbf{NEAR} removes confusion with nearby viewpoints; \\textbf{OPP} removes confusion with opposite viewpoints. \\textcolor{BrickRed}{Brick Red Bars} display the %s improvement by correcting all estimations of one type: \\textbf{OTH} corrects confusion with other rotation viewpoints; \\textbf{NEAR} corrects confusion with nearby viewpoints; \\textbf{OPP} corrects confusion with opposite viewpoints.}\n', name, metric, metric, metric, metric); pr('\\label{fig2%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end if exist(fullfile(outdir(1:end-4), name, 'analysisI/plot_4.pdf'), 'file') pr('\\begin{figure}[h]\n') pr('\\centering\n'); pr('\\includegraphics[width=0.85\\textwidth,trim = 20mm 65mm 25mm 65mm, clip]{../%s/analysisI/plot_4.pdf} \n', name); pr('\\caption{\\textbf{Success rate for %s class considering 8 views.} For each of the 8 viewpoints, we report: In \\textcolor{blue}{Blue}, the percentage of the correct pose estimations. In \\textcolor{cyan}{Cyan}, the percentage of confusion with the opposite viewpoints. In \\textcolor{yellow}{Yellow}, the percentage of confusion with nearby viewpoints. In \\textcolor{BrickRed}{Brick Red}, the percentage of the confusions with other rotations.}\n', name); pr('\\label{fig3%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end pr('\\clearpage') pr('\n\n'); pr('Figure \\ref{fig4%s} summarizes the detection and pose estimation performances for %s class. Figure \\ref{fig4%sa} shows the model performance working on continuous pose estimation. For AVP and PEAP the results are obtained considering a threshold equal to $\\frac{\\pi}{12}$. Figures \\ref{fig4%sb} and \\ref{fig4%sc} report the AVP and PEAP performances achieve working on discrete pose estimation. The AVP and PEAP metrics are obtained considering different number of the views: 4, 8, 16 and 24.\n', name, name, name, name, name); if exist(fullfile(outdir(1:end-4), name, 'analysisIII/curves/plot_1.pdf'), 'file') pr('\\begin{figure}[h]\n') pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig4%sa}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 20mm 65mm 25mm 65mm, clip]{../%s/analysisIII/curves/plot_1.pdf} \n', name); pr('}\\\\ \n'); pr('\\subfloat[]{\n'); pr('\\label{fig4%sb}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 20mm 65mm 25mm 65mm, clip]{../%s/analysisIII/curves/plot_2.pdf} \n', name); pr('}\n'); pr('\\subfloat[]{\n'); pr('\\label{fig4%sc}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 20mm 65mm 25mm 65mm, clip]{../%s/analysisIII/curves/plot_3.pdf} \n', name); pr('}\n'); pr('\\caption{\\textbf{Precision/Recall Curves.} (a) Performance working on continuous pose estimation. For AVP and PEAP the results are obtained considering a threshold equal to $\\frac{\\pi}{12}$. (b) AVP and (c) PEAP performances working on discrete pose estimation. Results obtained by considering 4, 8, 16, and 24 views.}\n'); pr('\\label{fig4%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end pr('\\clearpage') pr('\n\n'); pr('Figures \\ref{fig5%s}, \\ref{fig6%s}, \\ref{fig7%s}, \\ref{fig8%s} and \\ref{fig9%s} summarize the main object characteristic influences on detection and pose estimation performances for %s class. Figure \\ref{fig5%s} reports the effect of object size characteristic on object detection and pose estimation performances. Figure \\ref{fig6%s} shows the influence of aspect ratio characteristic on object detection and pose estimation performances. Figure \\ref{fig7%s} represents the influence of occluded and truncated objects on detection and pose estimation performances. Figure \\ref{fig8%s} shows the visible side influence. Figure \\ref{fig9%s} reports the part visibily effect. \n', name, name, name ,name, name, name, name, name, name, name, name); if exist(fullfile(outdir(1:end-4), name, 'analysisII/obj_charact_detection/plot_2.pdf'), 'file') pr('\\begin{figure}[h]\n') pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig5%sa}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_detection/plot_2.pdf} \n', name); pr('}\n') pr('\\subfloat[]{\n'); pr('\\label{fig5%sb}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 20mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_pose/plot_5.pdf} \n', name); pr('}\n') pr('\\caption{\\textbf{Effect of Object Size Characteristic on Object Detection and Pose Estimation Performances.} (a) Detection analysis: AP variance. XS and S are considered EXTRA SMALL and SMALL objects, M are MEDIUM objects, L and XL are LARGE and EXTRA LARGE objects. (b) Pose Estimation Results in terms of %s. \\textcolor{blue}{Blue Bars} show the results when all pose estimations are considered, \\textcolor{green}{Green Bars} show the results when only the pose estimations corresponding this object size are considered and \\textcolor{BrickRed}{Brick Red Bars} display the results when the pose estimations corresponding this object size are removed.}\n', metric); pr('\\label{fig5%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end if exist(fullfile(outdir(1:end-4), name, 'analysisII/obj_charact_detection/plot_3.pdf'), 'file') pr('\\begin{figure}[h]\n') pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig6%sa}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_detection/plot_3.pdf} \n', name); pr('}\n') pr('\\subfloat[]{\n'); pr('\\label{fig6%sb}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 20mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_pose/plot_6.pdf} \n', name); pr('}\n') pr('\\caption{\\textbf{Effect of Object Size Characteristic on Object Detection and Pose Estimation.} (a) Detection analysis: AP variance. XS and S are considered EXTRA SMALL and SMALL objects, M are MEDIUM objects, L and XL are LARGE and EXTRA LARGE objects. (b) Pose Estimation Results in terms of %s. \\textcolor{blue}{Blue Bars} show the results when all pose estimations are considered, \\textcolor{green}{Green Bars} show the results when only the pose estimations corresponding this object size are considered and \\textcolor{BrickRed}{Brick Red Bars} display the results when the pose estimations corresponding this object size are removed.}\n', metric); pr('\\label{fig6%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end if exist(fullfile(outdir(1:end-4), name, 'analysisII/obj_charact_detection/plot_5.pdf'), 'file') pr('\\begin{figure}[h]\n') pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig7%sa}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_detection/plot_5.pdf} \n', name); pr('}\n') pr('\\subfloat[]{\n'); pr('\\label{fig7%sb}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_pose/plot_3.pdf} \n', name); pr('}\n') pr('\\caption{\\textbf{Effect of Occluded and Truncated Objects on Detection and Pose Estimation Performances.} (a) Detection analysis: AP variance. N non occluded or truncated object, T/O truncated or occluded object. Results on Pose Estimation in terms of the %s metric. \\textcolor{blue}{Blue Bars} show the results when all pose estimations are considered. \\textcolor{green}{Green Bars} display the results when the occluded and truncated objects are removed. \\textcolor{BrickRed}{Brick Red Bars} show the performance when we are only considered the occluded and truncated objects.}\n', metric); pr('\\label{fig7%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end if exist(fullfile(outdir(1:end-4), name, 'analysisII/obj_charact_detection/plot_8.pdf'), 'file') pr('\\begin{figure}[h]\n') pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig8%sa}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_detection/plot_8.pdf} \n', name); pr('}\n'); pr('\\subfloat[]{\n'); pr('\\label{fig8%sb}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 10mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_pose/plot_2.pdf} \n', name); pr('}\n'); pr('\\caption{\\textbf{Effect of Visible Sides on Object Detection and Pose Estimation Performances.} (a) Detection analysis: AP performance. Pose Estimation analysis: (b) Pose Estimation analysis: %s performance. Black dashed lines indicate overall. Visible side: \\textbf{1} = performance when the side is visible; \\textbf{0} = performance when the side is not visible.}\n', metric); pr('\\label{fig8%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end if exist(fullfile(outdir(1:end-4), name, 'analysisII/obj_charact_detection/plot_7.pdf'), 'file') pr('\\begin{figure}[h]\n') pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig9%sa}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_detection/plot_7.pdf} \n', name); pr('}\n') pr('\\subfloat[]{\n'); pr('\\label{fig9%sb}\n', name); pr('\\includegraphics[width=0.45\\textwidth,trim = 10mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_pose/plot_1.pdf} \n', name); pr('}\n') pr('\\caption{\\textbf{Part Visibility Influence on Object Detection and Pose Estimation Performances.} (a) Detection analysis: AP performance. Pose Estimation analysis: (b) Pose Estimation analysis: %s performance. Black dashed lines indicate overall performance. Visible part: \\textbf{1} = performance when the part is visible; \\textbf{0} = performance when the part is not visible. The correspondence between the part number and the part name is indicated at the beginning of this Section (see Statistics for %s class).}\n', metric, name); pr('\\label{fig9%s}\n', name); pr('\\end{figure}\n'); pr('\n\n'); end pr('\\clearpage') pr('\n\n'); pr('Figure \\ref{fig10%s} provides a summary of the sensitivity to each characteristic and the potential impact on improving pose estimation robustness. The worst-performing and best-performing combinations for each object characteristic are averaged over the selected object categories. The difference between the best and the worst performance indicates sensitivity; the difference between the best and the overall indicates the potential impact.\n', name); if strcmp(detector(length(detector)-1:length(detector)), 'gt') pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\includegraphics[width=0.65\\textwidth,trim = 10mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_pose/plot_7.pdf} \n', name); pr('\\caption{\\textbf{Summary of Sensitivity and Impact of Object Characteristics.} We show the performance of the highest performing and lowest performing subsets within each characteristic (occlusion/truncation (occ-trn), bounding box area or object size (size), aspect ratio (asp), visible sides (side) and part visibility (part)). Overall accuracy is indicated by the black dashed line. The difference between max and min indicates sensitivity; the difference between max and overall indicates the impact.\n'); pr('}\n'); pr('\\label{fig10%s}\n', name); pr('\\end{figure}\n'); else pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\includegraphics[width=0.85\\textwidth,trim = 10mm 65mm 25mm 65mm, clip]{../%s/analysisII/obj_charact_pose/plot_7.pdf} \n', name); pr('\\caption{\\textbf{Summary of Sensitivity and Impact of Object Characteristics.} We show the %s performance of the highest performing and lowest performing subsets within each characteristic (occlusion/truncation (occ-trn), difficult objects (diff), bounding box area or object size (size), aspect ratio (asp), visible sides (side) and part visibility (part)). Overall accuracy is indicated by the black dashed line. The difference between max and min indicates sensitivity; the difference between max and overall indicates the impact.\n', metric); pr('}\n'); pr('\\label{fig10%s}\n', name); pr('\\end{figure}\n'); end pr('\\clearpage\n'); if exist(fullfile(outdir(1:end-4), name, 'analysisIII/ov_analysis/plot_1.pdf'), 'file') pr('Figure \\ref{fig11%s} shows an analysis of the influence of the overlap criterion considering the %s metric. For this overlap criterion analysis we follow the PASCAL VOC formulation: to be considered a true positive, the area of overlap between the predicted BB and GT BB must exceed a threshold.\n', name, metric); pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\includegraphics[width=0.85\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../%s/analysisIII/ov_analysis/plot_1.pdf} \n', name); pr('\\caption{\\textbf{Simultaneous Object Detection and Pose Estimation.} The detection performance (AP) is represented in red and the pose estimation performance (%s) in blue.\n', metric); pr('}\n'); pr('\\label{fig11%s}\n', name); pr('\\end{figure}\n'); end pr('\\clearpage\n'); fclose(fid); function pr(varargin) global fid; fprintf(fid, varargin{:});
github
gramuah/pose-errors-master
matchDetectionsWithGroundTruth.m
.m
pose-errors-master/src/matchDetectionsWithGroundTruth.m
5,491
utf_8
cd0e182e842c1e3357082c6701324245
function [det, gt] = matchDetectionsWithGroundTruth(dataset, dataset_params, objname, ann, det, localization) % [det, gt] = matchDetectionsWithGroundTruth(dataset, dataset_params, objname, ann, det, localization) % % Determines which detections are correct based on dataset and localization % criteria. See matchDetectionsWithGroundTruth_VOC documentation (below) for % details. % switch dataset case {'PASCAL3D+'} o = strcmp(dataset_params.objnames_all, objname); gt = ann.gt(o); [det, gt] = matchDetectionsWithGroundTruth_PASCAL3D(dataset_params, gt, det, localization); otherwise error('unknown dataset: %s', dataset); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [det, gt] = matchDetectionsWithGroundTruth_PASCAL3D(dataset_params, gt, det, localization) % [det, gt] = matchDetectionsWithGroundTruth_PASCAL3D(dataset_params, det, gt, localization) % % Returns the intersection over union, intersection/object, and % intersection/gt areas and index of closest ground truth for each % detection % % Input: % Dataset parameters: % dataset_params.(iuthresh_weak, idthresh_weak, iuthresh_strong, idthresh_strong) % Ground truth anntoations: % gt.(bbox, rnum, isdiff) % Object detection results: % det.(bbox, conf, rnum) % Localization criteria: 'weak' or 'strong' % % Output % Adds to the input det struct: % the index of best-matching ground truth (gtnum), the corresponding % overlap measures, the label (1=true, 0=difficult, -1=false), and whether % the detection is a duplicate (label=-1 in this case) % det.(bbox, conf, rnum, gtnum, isdiff, ov, ov_obj, ov_gt, label, isduplicate) % Adds to the input gt struct: % (1) index (detnum) of highest scoring detection with ov>ovthresh; % (2) index (detnum_ov) of maximum overlap detection % (3) the overlaps with the detection of maximum overlap (ov, ov_obj, % ov_gt), which may not be the same detection % gt.(bbox, rnum, isdiff, detnum): switch localization case 'weak' % also duplicate detections are ignored, per last line iuthresh = dataset_params.iuthresh_weak; % intersection/union threshold idthresh = dataset_params.idthresh_weak; % intersection/det_area threshold case 'strong' iuthresh = dataset_params.iuthresh_strong; idthresh = dataset_params.idthresh_strong; case 'weak_1' iuthresh = 0.2; idthresh = 0; case 'weak_2' iuthresh = 0.3; idthresh = 0; case 'weak_3' iuthresh = 0.4; idthresh = 0; case 'strong_1' iuthresh = 0.6; idthresh = 0; case 'strong_2' iuthresh = 0.7; idthresh = 0; case 'strong_3' iuthresh = 0.8; idthresh = 0; case 'strong_4' iuthresh = 0.9; idthresh = 0; otherwise error('invalid localization criterion: %s', localization) end Ngt = size(gt.bbox, 1); gt.detnum = zeros(Ngt, 1); gt.detnum_ov = zeros(Ngt, 1); gt.ov = zeros(Ngt, 1); gt.ov_obj = zeros(Ngt, 1); gt.ov_gt = zeros(Ngt, 1); Nd = size(det.bbox, 1); det.gtnum = zeros(Nd, 1); det.ov = zeros(Nd, 1); det.ov_obj = zeros(Nd, 1); det.ov_gt = zeros(Nd, 1); det.isdiff = zeros(Nd, 1); det.label = -ones(Nd, 1); det.label_occ = zeros(Nd, 1); det.label_trunc = zeros(Nd, 1); det.isduplicate = false(Nd, 1); isdetected = zeros(Ngt, 1); [sv, si] = sort(det.conf, 'descend'); for dtmp = 1:Nd d = si(dtmp); indgt = find(gt.rnum == det.rnum(d)); if isempty(indgt), continue; end bbgt = gt.bbox(indgt, [1 3 2 4]); % ground truth in same image box = det.bbox(d, [1 3 2 4]); % detection window bi=[max(box(1),bbgt(:, 1)) max(box(3),bbgt(:, 3)) ... min(box(2),bbgt(:, 2)) min(box(4),bbgt(:, 4))]; iw=bi(:, 3)-bi(:, 1)+1; ih=bi(:, 4)-bi(:, 2)+1; ind = find(iw >0 & ih > 0); % others have no intersection if ~isempty(ind) gtarea = (bbgt(ind, 2)-bbgt(ind, 1)+1).*(bbgt(ind, 4)-bbgt(ind, 3)+1); detarea = (box(2)-box(1)+1)*(box(4)-box(3)+1); intersectArea = iw(ind).*ih(ind); unionArea =gtarea + detarea - intersectArea; i = find(((intersectArea ./ unionArea) >= iuthresh) & ... ((intersectArea ./ detarea) >= idthresh)... & (~isdetected(indgt(ind)))); if ~isempty(i) % correct detection [det.ov(d), i] = max((intersectArea ./ unionArea) .* (~isdetected(indgt(ind)))); gti = indgt(ind(i)); if gt.isdiff(gti) det.label(d) = 0; det.isdiff(d) = 1; else det.label(d) = 1; end if gt.istrunc(gti) det.label_trunc(d) = 1; end if gt.isocc(gti) det.label_occ(d) = 1; end gt.detnum(gti) = d; isdetected(gti) = 1; else % no correct detection, or extra detection [det.ov(d), i] = max(intersectArea ./ unionArea); gti = indgt(ind(i)); if gt.isdiff(gti) det.label(d) = 0; det.isdiff(d) = 1; else if det.ov(d)>=iuthresh && ((intersectArea(i) ./ detarea) >= idthresh) det.isduplicate(d) = true; end end end det.ov_obj(d) = intersectArea(i) ./ detarea; det.ov_gt(d) = intersectArea(i) ./ gtarea(i); det.gtnum(d) = gti; if det.ov(d) > gt.ov(gti) gt.ov(gti) = det.ov(d); gt.ov_obj(gti) = intersectArea(i) ./ detarea; gt.ov_gt(gti) = intersectArea(i) ./ gtarea(i); gt.detnum_ov(gti) = d; end end end
github
gramuah/pose-errors-master
analyzeDetections.m
.m
pose-errors-master/src/analyzeDetections.m
19,712
utf_8
659b017995dcdb25acaf67df4197f3aa
function result = analyzeDetections(dataset, dataset_params, objname, det, ann, localization) % result = analyzeDetections(dataset, dataset_params, objname, det, ann, localization) % % Input: % dataset: name of the dataset (e.g., PASCAL3D+) % dataset_params: parameters of the dataset % objname: name of the object class % det.(bbox, conf, rnum): object detection results % ann: dataset annotations % localization: 'weak' or 'strong' to specify localization criteria % % Output: % result: set of precision-recall and aos/avp/peap/errors statistics switch dataset case {'PASCAL3D+'} result = analyzeDetections_PASCAL3D(dataset, dataset_params, objname, ... ann, det, localization); otherwise error('dataset %s is unknown\n', dataset); end result.name = objname; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function result = analyzeDetections_PASCAL3D(dataset, dataset_params, objname, ... ann, det, localization) rec = ann.rec; [det.conf, si] = sort(det.conf, 'descend'); det.bbox = det.bbox(si, :); det.rnum = det.rnum(si); det.view = det.view(si, :); [det, gt] = matchDetectionsWithGroundTruth(dataset, dataset_params, objname, ann, det, localization); result.localization = localization; result.gt = gt; result.gt.bbox_conf = zeros(gt.N, 4); result.gt.bbox_conf(gt.detnum>0, 1:4) = det.bbox(gt.detnum(gt.detnum>0), :); result.gt.bbox_ov = zeros(gt.N, 4); result.gt.bbox_ov(gt.detnum_ov>0, 1:4) = det.bbox(gt.detnum_ov(gt.detnum_ov>0), :); result.det.bbox = det.bbox; result.det.view = det.view; result.det.conf = det.conf; result.det.gtnum = det.gtnum; result.det.rnum = det.rnum; result.det.isduplicate = det.isduplicate; %% Obtaining Precision-recall curves % Overall npos = sum(~[gt.isdiff]); dummy = []; [result.pose, dummy] = averagePoseDetectionPrecision(det, gt, npos); % Detection and pose estimation considering the difficult objects as well npos = length(gt.bbox);% result.pose.diff = averagePoseDetectionPrecision(det, gt, npos, 1); result.diff_nondiff(1) = result.pose.diff; result.gt.diffnondiff = zeros(gt.N, 1); deto = det; npos = 0; rec = ann.rec; for k = 1:gt.N r = gt.rnum(k); o = gt.onum(k); if rec(r).objects(o).difficult == 1 result.gt.trunc_occ(k) = 1; i = (det.label==0 & det.gtnum==k); deto.label(i) = 1; npos = npos+1; else i = (det.label==1 & det.gtnum==k); deto.label(i) = 0; end end dummy = []; [result.diff_nondiff(2), dummy] = averagePoseDetectionPrecision(deto, gt, npos); %% Object Characteristic Analysis % (occ/trunc. objects, object size, aspect ratio, part visibility, visible side) % Occlusion result.gt.occ_level = zeros(gt.N, 1); for level = 1:2 deto = det; npos = 0; for k = 1:gt.N if gt.isdiff(k), continue; end; r = gt.rnum(k); o = gt.onum(k); if rec(r).objects(o).detailedannotation result.gt.occ_level(k) = rec(r).objects(o).details.occ_level; if rec(r).objects(o).details.occ_level~=level; i = (det.label==1 & det.gtnum==k); deto.label(i) = 0; else npos = npos+1; end end end dummy = []; [result.occ(level), dummy] = averagePoseDetectionPrecision(deto, gt, npos); end % Truncation result.gt.truncated = zeros(gt.N, 1); for val = 0:1 deto = det; npos = 0; for k = 1:gt.N if gt.isdiff(k), continue; end; r = gt.rnum(k); o = gt.onum(k); if rec(r).objects(o).truncated~=val result.gt.truncated(k) = rec(r).objects(o).truncated; i = (det.label==1 & det.gtnum==k); deto.label(i) = 0; else npos = npos+1; end end dummy = []; [result.truncated(val+1), dummy] = averagePoseDetectionPrecision(deto, gt, npos); end % Truncation and Occlusion result.gt.trunc_occ = zeros(gt.N, 1); for val = 1:2 deto = det; npos = 0; for k = 1:gt.N if gt.isdiff(k), continue; end; r = gt.rnum(k); o = gt.onum(k); if val == 2 if rec(r).objects(o).truncated == 1 || rec(r).objects(o).occluded == 1 result.gt.trunc_occ(k) = 1; npos = npos+1; else i = (det.label==1 & det.gtnum==k); deto.label(i) = 0; end else if rec(r).objects(o).truncated == 0 && rec(r).objects(o).occluded == 0 result.gt.trunc_occ(k) = 0; npos = npos+1; else i = (det.label==1 & det.gtnum==k); deto.label(i) = 0; end end end dummy = []; [result.trunc_occ(val), dummy] = averagePoseDetectionPrecision(deto, gt, npos); end % Ignore truncated and occluded objects: remove objects with labels: isocc == 1 and % istrunc == 1 ob_gtindex = []; ob_gtindex= unique(find((gt.istrunc == 0) & (gt.isocc==0))); hh=1; for jj= 1:length(ob_gtindex) if gt.detnum(ob_gtindex(jj)) ~= 0 result.pose.isocc(hh) = gt.detnum(ob_gtindex(jj)); hh= hh+1; end end det2=[]; if hh > 1 det2.bbox = det.bbox(result.pose.isocc,:); det2.conf = det.conf(result.pose.isocc,:); det2.rnum = det.rnum(result.pose.isocc,:); det2.view = det.view(result.pose.isocc,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(result.pose.isocc,:); det2.ov = det.ov(result.pose.isocc,:); det2.ov_obj = det.ov_obj(result.pose.isocc,:); det2.ov_gt = det.ov_gt(result.pose.isocc,:); det2.isdiff = det.isdiff(result.pose.isocc,:); det2.label = det.label(result.pose.isocc,:); det2.label_occ = det.label_occ(result.pose.isocc,:); det2.label_trunc = det.label_trunc(result.pose.isocc,:); det2.isduplicate = det.isduplicate(result.pose.isocc,:); gt2=[]; for j=1:length(result.pose.isocc) gt2.isdiff(j) = gt.isdiff(det.gtnum(result.pose.isocc(j)), :); end if ~isempty(gt2) ah=0; ai=unique(find((gt.istrunc == 1) | (gt.isocc==1))); for j = 1: length(ai); if gt.isdiff(ai(j)) == 0 ah = ah+1; end end npos = sum(~[gt.isdiff])-ah; else npos = 0; end dummy = []; [result.pose.ignoreocc, dummy] = averagePoseDetectionPrecision(det2, gt, npos); else result.pose.ignoreocc = []; end % Considering only truncated and occluded objects: remove objects with labels: isocc == 0 and % istrunc == 0 ob_gtindex = []; ob_gtindex= unique(find((gt.istrunc == 1) & (gt.isocc==1))); hh=1; for jj= 1:length(ob_gtindex) if gt.detnum(ob_gtindex(jj)) ~= 0 result.pose.occind(hh) = gt.detnum(ob_gtindex(jj)); hh= hh+1; end end det2=[]; if hh > 1 det2.bbox = det.bbox(result.pose.occind,:); det2.conf = det.conf(result.pose.occind,:); det2.rnum = det.rnum(result.pose.occind,:); det2.view = det.view(result.pose.occind,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(result.pose.occind,:); det2.ov = det.ov(result.pose.occind,:); det2.ov_obj = det.ov_obj(result.pose.occind,:); det2.ov_gt = det.ov_gt(result.pose.occind,:); det2.isdiff = det.isdiff(result.pose.occind,:); det2.label = det.label(result.pose.occind,:); det2.label_occ = det.label_occ(result.pose.occind,:); det2.label_trunc = det.label_trunc(result.pose.occind,:); det2.isduplicate = det.isduplicate(result.pose.occind,:); gt2=[]; for j=1:length(result.pose.occind) gt2.isdiff(j) = gt.isdiff(det.gtnum(result.pose.occind(j)), :); end if ~isempty(gt2) ah=0; ai=unique(find((gt.istrunc == 0) | (gt.isocc==0))); for j = 1: length(ai); if gt.isdiff(ai(j)) == 0 ah = ah+1; end end npos = sum(~[gt.isdiff])-ah; else npos = 0; end dummy = []; [result.pose.onlyocc, dummy] = averagePoseDetectionPrecision(det2, gt, npos); else result.pose.onlyocc = []; end % BBox Area bb = gt.bbox(~[gt.isdiff], :); gtarea = (bb(:, 3)-bb(:, 1)+1).*(bb(:, 4)-bb(:, 2)+1); [sa, si] = sort(gtarea, 'ascend'); athresh = [0 sa(round([1/10 3/10 7/10 9/10]*size(bb,1)))']; alabel(~[gt.isdiff]) = sum(repmat(gtarea, [1 5])>repmat(athresh, [size(bb, 1) 1]), 2); alabel(logical([gt.isdiff])) = 0; result.gt.area = alabel; for a = 1:5 deto = det; npos = sum(alabel==a &~ [gt.isdiff]'); ind = find(deto.label==1); gti = deto.gtnum(ind); ind = ind(alabel(gti)~=a); deto.label(ind) = 0; dummy = []; [result.area(a), dummy] = averagePoseDetectionPrecision(deto, gt, npos); end areathresh = athresh; % BBox Height alabel = []; bb = gt.bbox(~[gt.isdiff], :); gtheight = (bb(:, 4)-bb(:, 2)+1); [sa, si] = sort(gtheight, 'ascend'); athresh = [0 sa(round([1/10 3/10 7/10 9/10]*size(bb,1)))']; alabel(~[gt.isdiff]) = sum(repmat(gtheight, [1 5])>repmat(athresh, [size(bb, 1) 1]), 2); alabel(logical([gt.isdiff])) = 0; for a = 1:5 deto = det; npos = sum(alabel==a &~ [gt.isdiff]'); ind = find(deto.label==1); gti = deto.gtnum(ind); ind = ind(alabel(gti)~=a); deto.label(ind) = 0; dummy = []; [result.height(a), dummy] = averagePoseDetectionPrecision(deto, gt, npos); end result.gt.height = alabel; heightthresh = athresh; % Aspect Ratio bb = gt.bbox(~[gt.isdiff], :); gtaspect = (bb(:, 3)-bb(:, 1)+1)./(bb(:, 4)-bb(:, 2)+1); [sa, si] = sort(gtaspect, 'ascend'); athresh = [0 sa(round([1/10 3/10 7/10 9/10]*size(bb,1)))']; alabel(~[gt.isdiff]) = sum(repmat(gtaspect, [1 5])>repmat(athresh, [size(bb, 1) 1]), 2); alabel(logical([gt.isdiff])) = 0; for a = 1:5 deto = det; npos = sum(alabel==a &~ [gt.isdiff]'); ind = find(deto.label==1); gti = deto.gtnum(ind); ind = ind(alabel(gti)~=a); deto.label(ind) = 0; dummy = []; [result.aspect(a), dummy] = averagePoseDetectionPrecision(deto, gt, npos); end result.gt.aspect = alabel; aspectthresh = athresh; % Pose estimation vs BBox Area bb = gt.bbox; gtarea = (bb(:, 3)-bb(:, 1)+1).*(bb(:, 4)-bb(:, 2)+1); [sa, si] = sort(gtarea, 'ascend'); athresh = [0 sa(round([1/10 3/10 7/10 9/10]*size(bb,1)))']; alabel = sum(repmat(gtarea, [1 5])>repmat(athresh, [size(bb, 1) 1]), 2); result.gt.area = alabel; for a = 1:5 det2=[]; ind=[]; dummy = []; [ii dummy] = find(alabel==a); npos_aux=length(find(gt.isdiff(ii)==0)); hh=1; for jj= 1:length(ii) if gt.detnum(ii(jj)) ~= 0 && gt.isdiff(ii(jj)) == 0 ind(hh) = gt.detnum(ii(jj)); hh= hh+1; end end det2.bbox = det.bbox(ind,:); det2.conf = det.conf(ind,:); det2.rnum = det.rnum(ind,:); det2.view = det.view(ind,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(ind,:); det2.ov = det.ov(ind,:); det2.ov_obj = det.ov_obj(ind,:); det2.ov_gt = det.ov_gt(ind,:); det2.isdiff = det.isdiff(ind,:); det2.label = det.label(ind,:); det2.label_occ = det.label_occ(ind,:); det2.label_trunc = det.label_trunc(ind,:); det2.isduplicate = det.isduplicate(ind,:); gt2 = []; for j=1:length(det2.gtnum) if det2.gtnum(j) ~= 0 gt2.isdiff(j) = gt.isdiff(det2.gtnum(j), :); end end if ~isempty(gt2) npos = npos_aux;%sum(~[gt2.isdiff]); else npos = 0; end dummy = []; [result.pose.onlythissize(a), dummy] = averagePoseDetectionPrecision(det2, gt, npos); det2=[]; ind=[]; ii=[]; val=[]; dummy = []; [ii dummy] = find(alabel~=a); npos_aux=length(find(gt.isdiff(ii)==0)); hh=1; for jj= 1:length(ii) if gt.detnum(ii(jj)) ~= 0 && gt.isdiff(ii(jj)) == 0 ind(hh) = gt.detnum(ii(jj)); hh= hh+1; end end det2.bbox = det.bbox(ind,:); det2.conf = det.conf(ind,:); det2.rnum = det.rnum(ind,:); det2.view = det.view(ind,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(ind,:); det2.ov = det.ov(ind,:); det2.ov_obj = det.ov_obj(ind,:); det2.ov_gt = det.ov_gt(ind,:); det2.isdiff = det.isdiff(ind,:); det2.label = det.label(ind,:); det2.label_occ = det.label_occ(ind,:); det2.label_trunc = det.label_trunc(ind,:); det2.isduplicate = det.isduplicate(ind,:); gt2 = []; for j=1:length(det2.gtnum) if det2.gtnum(j) ~= 0 gt2.isdiff(j) = gt.isdiff(det2.gtnum(j), :); end end if ~isempty(gt2) npos = npos_aux;%sum(~[gt2.isdiff]); else npos = 0; end dummy = []; [result.pose.ignorethissize(a), dummy] = averagePoseDetectionPrecision(det2, gt, npos); end % Pose estimation vs Aspect Ratio alabel = []; bb = gt.bbox; gtaspect = (bb(:, 3)-bb(:, 1)+1)./(bb(:, 4)-bb(:, 2)+1); [sa, si] = sort(gtaspect, 'ascend'); athresh = [0 sa(round([1/10 3/10 7/10 9/10]*size(bb,1)))']; alabel = sum(repmat(gtaspect, [1 5])>repmat(athresh, [size(bb, 1) 1]), 2); for a = 1:5 det2=[]; ii=[]; ind=[]; [ii dummy] = find(alabel==a); npos_aux=length(find(gt.isdiff(ii)==0)); hh=1; for jj= 1:length(ii) if gt.detnum(ii(jj)) ~= 0 && gt.isdiff(ii(jj)) == 0 ind(hh) = gt.detnum(ii(jj)); hh= hh+1; end end det2.bbox = det.bbox(ind,:); det2.conf = det.conf(ind,:); det2.rnum = det.rnum(ind,:); det2.view = det.view(ind,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(ind,:); det2.ov = det.ov(ind,:); det2.ov_obj = det.ov_obj(ind,:); det2.ov_gt = det.ov_gt(ind,:); det2.isdiff = det.isdiff(ind,:); det2.label = det.label(ind,:); det2.label_occ = det.label_occ(ind,:); det2.label_trunc = det.label_trunc(ind,:); det2.isduplicate = det.isduplicate(ind,:); gt2 = []; for j=1:length(det2.gtnum) if det2.gtnum(j) ~= 0 gt2.isdiff(j) = gt.isdiff(det2.gtnum(j), :); end end if ~isempty(gt2) npos = npos_aux;%sum(~[gt2.isdiff]); else npos = 0; end dummy = []; [result.pose.onlythisaspect(a), dummy] = averagePoseDetectionPrecision(det2, gt, npos); det2=[]; ind=[]; ii=[]; val=[]; [ii dummy] =find(alabel~=a); npos_aux=length(find(gt.isdiff(ii)==0)); hh=1; for jj= 1:length(ii) if gt.detnum(ii(jj)) ~= 0 && gt.isdiff(ii(jj)) == 0 ind(hh) = gt.detnum(ii(jj)); hh= hh+1; end end det2.bbox = det.bbox(ind,:); det2.conf = det.conf(ind,:); det2.rnum = det.rnum(ind,:); det2.view = det.view(ind,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(ind,:); det2.ov = det.ov(ind,:); det2.ov_obj = det.ov_obj(ind,:); det2.ov_gt = det.ov_gt(ind,:); det2.isdiff = det.isdiff(ind,:); det2.label = det.label(ind,:); det2.label_occ = det.label_occ(ind,:); det2.label_trunc = det.label_trunc(ind,:); det2.isduplicate = det.isduplicate(ind,:); gt2 = []; for j=1:length(det2.gtnum) if det2.gtnum(j) ~= 0 gt2.isdiff(j) = gt.isdiff(det2.gtnum(j), :); end end if ~isempty(gt2) npos = npos_aux;%sum(~[gt2.isdiff]); else npos = 0; end dummy = []; [result.pose.ignorethisaspect(a), dummy] = averagePoseDetectionPrecision(det2, gt, npos); end % Parts i = find(~[gt.isdiff], 1, 'first'); if rec(gt.rnum(i)).objects(gt.onum(i)).detailedannotation pnames = fieldnames(rec(gt.rnum(i)).objects(gt.onum(i)).details.part_visible); for p = 1:numel(pnames) name = pnames{p}; for val = 0:1 deto = det; npos = 0; for k = 1:gt.N r = gt.rnum(k); o = gt.onum(k); if rec(r).objects(o).detailedannotation result.gt.part.(name)(k) = rec(r).objects(o).details.part_visible.(name); if rec(r).objects(o).details.part_visible.(name)~=val deto.label(det.label==1 & det.gtnum==k) = 0; else if gt.isdiff(k) == 0 npos = npos+1; end end end end dummy = []; [result.pose.part.(name)(val+1), dummy] = averagePoseDetectionPrecision(deto, gt, npos); end end end % Side i = find(~[gt.isdiff], 1, 'first'); if rec(gt.rnum(i)).objects(gt.onum(i)).detailedannotation pnames = fieldnames(rec(gt.rnum(i)).objects(gt.onum(i)).details.side_visible); for p = 1:numel(pnames) name = pnames{p}; for val = 0:1 %0 = non-visible 1 = visible deto = det; npos = 0; for k = 1:gt.N r = gt.rnum(k); o = gt.onum(k); if rec(r).objects(o).detailedannotation result.gt.side.(name)(k) = rec(r).objects(o).details.side_visible.(name); if rec(r).objects(o).details.side_visible.(name)~=val deto.label(det.label==1 & det.gtnum==k) = 0; else if gt.isdiff(k) == 0 npos = npos+1; end end end end dummy = []; [result.pose.side.(name)(val+1), dummy] =averagePoseDetectionPrecision(deto, gt, npos); end end end %% Statistics of missed vs. detected % result.counts stores counts of properties of all and missed objects % result.overlap stores maximum overlap of different kinds of objects missedthresh = 0.05; missed = true(gt.N, 1); missed(det.gtnum(result.pose.p>=missedthresh & det.label==1)) = false; missed(gt.isdiff) = false; found = ~missed; found(gt.isdiff) = false; % occlusion/truncation gtoccludedL = result.gt.occ_level(:)>=2 | result.gt.truncated(:); gtoccludedM = result.gt.occ_level(:)>=3 | result.gt.truncated(:); result.counts.missed.total = sum(missed); result.counts.missed.occludedL = sum(missed.*gtoccludedL(:)); result.counts.missed.occludedM = sum(missed.*gtoccludedM(:)); result.counts.all.total = sum(missed)+sum(found); result.counts.all.occludedL = sum(gtoccludedL); result.counts.all.occludedM = sum(gtoccludedM); result.overlap.all.all = mean(gt.ov); gtnum = det.gtnum(det.gtnum==1); result.overlap.detected.all = mean(gt.ov(gtnum)); ind = gtoccludedL(gtnum); result.overlap.detected.occludedL = mean(gt.ov(gtnum(ind))); result.overlap.all.occludedL = mean(gt.ov(gtoccludedL)); ind = gtoccludedM(gtnum); result.overlap.detected.occludedM = mean(gt.ov(gtnum(ind))); result.overlap.all.occludedM = mean(gt.ov(gtoccludedM)); % area alabel = result.gt.area(:); alabel(logical([gt.isdiff])) = 0; result.counts.missed.area = hist(alabel(missed & alabel>0), 1:5); result.counts.all.area = hist(alabel(alabel>0), 1:5); for k = 1:5 ind = det.gtnum>0; ind(ind) = alabel(det.gtnum(ind))==k; result.overlap.detected.area(k) = mean(gt.ov(det.gtnum(ind))); result.overlap.all.area(k) = mean(gt.ov(alabel==k)); end % aspect alabel = result.gt.aspect(:); alabel(logical([gt.isdiff])) = 0; result.counts.all.aspectratio = hist(alabel(alabel>0), 1:5); result.counts.missed.aspectratio = hist(alabel(missed & alabel>0), 1:5); for k = 1:5 ind = det.gtnum>0; ind(ind) = alabel(det.gtnum(ind))==k; result.overlap.detected.aspectratio(k) = mean(gt.ov(det.gtnum(ind))); result.overlap.all.aspectratio(k) = mean(gt.ov(alabel==k)); end
github
gramuah/pose-errors-master
analyzePoseError.m
.m
pose-errors-master/src/analyzePoseError.m
7,939
utf_8
ff08935c01bb85fd65958948f3efd616
function [result, resulclass] = analyzePoseError(dataset, dataset_params, ann, objind, det, localization) % result = analyzePoseError(dataset, dataset_params, ann, objind, similar_ind, det) % Pose Error Analysis. switch dataset case {'PASCAL3D+'} [result, resulclass] = analyzePoseError_PASCAL3D(dataset, ... dataset_params, ann, objind, det, localization); otherwise error('dataset %s is unknown\n', dataset); end function [result, resulclass] = analyzePoseError_PASCAL3D(dataset, dataset_params, ann, objind, det, localization) [sv, si] = sort(det.conf, 'descend'); det.bbox = det.bbox(si, :); det.conf = det.conf(si); det.rnum = det.rnum(si); det.view = det.view(si, :); objname = dataset_params.objnames_all{objind}; % Regular [det, gt] = matchDetectionsWithGroundTruth(dataset, dataset_params, objname, ann, det, localization); npos = sum(~[gt.isdiff]); result.iscorrect = (det.label>=0); [result.pose, resulclass] = averagePoseDetectionPrecision(det, gt, npos); %% Pose Error Analysis % Ignore opposite error: remove estimations that have label 2 det2 = []; ii = []; ii = find(result.pose.labels_pose == 1 | result.pose.labels_pose == 3 | ... result.pose.labels_pose == 4 | result.pose.labels_pose == 0); hh=1; result.pose.isopp = []; for jj = 1: length(ii) result.pose.isopp(hh) = ii(jj); hh = hh+1; end if ~isempty(result.pose.isopp) det2.bbox = det.bbox(result.pose.isopp,:); det2.conf = det.conf(result.pose.isopp,:); det2.rnum = det.rnum(result.pose.isopp,:); det2.view = det.view(result.pose.isopp,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(result.pose.isopp,:); det2.ov = det.ov(result.pose.isopp,:); det2.ov_obj = det.ov_obj(result.pose.isopp,:); det2.ov_gt = det.ov_gt(result.pose.isopp,:); det2.isdiff = det.isdiff(result.pose.isopp,:); det2.label = det.label(result.pose.isopp,:); det2.label_occ = det.label_occ(result.pose.isopp,:); det2.label_trunc = det.label_trunc(result.pose.isopp,:); det2.isduplicate = det.isduplicate(result.pose.isopp,:); ah=0; ai=find(result.pose.labels_pose == 2); for j = 1: length(ai); if det.isdiff(ai(j)) == 0 ah = ah+1; end end npos = sum(~[gt.isdiff])-ah; dummy = []; [result.pose.ignoreopp, dummy] = averagePoseDetectionPrecision(det2, gt, npos); else result.pose.ignoreopp = result.pose; end % reassigns opposite error to correct estimations ii = []; ii = find(result.pose.labels_pose == 2); hh=1; for jj = 1: length(ii) result.pose.isopp2(hh) = ii(jj); hh = hh +1; end det3 = det; if hh > 1 for j=1:length(result.pose.isopp2) det3.view(result.pose.isopp2(j),1) = gt.viewpoint(det3.gtnum(result.pose.isopp2(j)), :).azimuth; end end npos = sum(~[gt.isdiff]); dummy = []; [result.pose.correctopp, dummy] = averagePoseDetectionPrecision(det3, gt, npos); % Ignore nearby error: remove estimations that have label 3 ii = []; ii = find(result.pose.labels_pose == 1 | result.pose.labels_pose == 2 | ... result.pose.labels_pose == 4 | result.pose.labels_pose == 0); hh=1; for jj= 1:length(ii) result.pose.isnearby(hh) = ii(jj); hh= hh+1; end det2 = []; if hh > 1 det2.bbox = det.bbox(result.pose.isnearby,:); det2.conf = det.conf(result.pose.isnearby,:); det2.rnum = det.rnum(result.pose.isnearby,:); det2.view = det.view(result.pose.isnearby,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(result.pose.isnearby,:); det2.ov = det.ov(result.pose.isnearby,:); det2.ov_obj = det.ov_obj(result.pose.isnearby,:); det2.ov_gt = det.ov_gt(result.pose.isnearby,:); det2.isdiff = det.isdiff(result.pose.isnearby,:); det2.label = det.label(result.pose.isnearby,:); det2.label_occ = det.label_occ(result.pose.isnearby,:); det2.label_trunc = det.label_trunc(result.pose.isnearby,:); det2.isduplicate = det.isduplicate(result.pose.isnearby,:); ah=0; ai=find(result.pose.labels_pose == 3); for j = 1: length(ai); if det.isdiff(ai(j)) == 0 ah = ah+1; end end npos = sum(~[gt.isdiff])-ah; dummy = []; [result.pose.ignorenearby, dummy] = averagePoseDetectionPrecision(det2, gt, npos); else NAMES = fieldnames(det); for na=1:length(NAMES) det2= setfield(det2,NAMES{na},[]); end npos = 0; result.pose.ignorenearby = []; end % reassigns nearby error to correct estimations ii = []; ii = find(result.pose.labels_pose == 3); hh=1; for jj= 1:length(ii) result.pose.isnearby2(hh) = ii(jj); hh= hh+1; end det3 = det; if hh > 1 for j=1:length(result.pose.isnearby2) det3.view(result.pose.isnearby2(j),1) = ... gt.viewpoint(det3.gtnum(result.pose.isnearby2(j)), :).azimuth; end end npos = sum(~[gt.isdiff]); dummy =[]; [result.pose.correctnearby, dummy] = averagePoseDetectionPrecision(det3, gt, npos); % Ignore other error: remove estimations that have label 4 ii = []; ii = find(result.pose.labels_pose == 1 | result.pose.labels_pose == 2 | ... result.pose.labels_pose == 3 | result.pose.labels_pose == 0); hh=1; for jj= 1:length(ii) result.pose.isother(hh) = ii(jj); hh= hh+1; end det2 = []; if hh > 1 det2.bbox = det.bbox(result.pose.isother,:); det2.conf = det.conf(result.pose.isother,:); det2.rnum = det.rnum(result.pose.isother,:); det2.view = det.view(result.pose.isother,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(result.pose.isother,:); det2.ov = det.ov(result.pose.isother,:); det2.ov_obj = det.ov_obj(result.pose.isother,:); det2.ov_gt = det.ov_gt(result.pose.isother,:); det2.isdiff = det.isdiff(result.pose.isother,:); det2.label = det.label(result.pose.isother,:); det2.label_occ = det.label_occ(result.pose.isother,:); det2.label_trunc = det.label_trunc(result.pose.isother,:); det2.isduplicate = det.isduplicate(result.pose.isother,:); ah=0; ai=find(result.pose.labels_pose == 4); for j = 1: length(ai); if det.isdiff(ai(j)) == 0 ah = ah+1; end end npos = sum(~[gt.isdiff])-ah; dummy=[]; [result.pose.ignoreother, dummy] = averagePoseDetectionPrecision(det2, gt, npos); else result.pose.ignoreother = []; end % reassigns other error to correct estimations ii = []; ii = find(result.pose.labels_pose == 4); hh=1; for jj= 1:length(ii) result.pose.isother2(hh) = ii(jj); hh= hh+1; end det3 = det; if hh > 1 for j=1:length(result.pose.isother2) det3.view(result.pose.isother2(j),1) = ... gt.viewpoint(det3.gtnum(result.pose.isother2(j)), :).azimuth; end end npos = sum(~[gt.isdiff]); dummy = []; [result.pose.correctother, dummy] = averagePoseDetectionPrecision(det3, gt, npos); % Only correct estimation: remove estimations that have label 2,3 and 4 ii = []; det2 = []; ii = find(result.pose.labels_pose == 1); hh=1; for jj= 1:length(ii) if det.isdiff(ii(jj)) == 0 result.pose.ignall(hh) = ii(jj); hh= hh+1; end end det2.bbox = det.bbox(result.pose.ignall,:); det2.conf = det.conf(result.pose.ignall,:); det2.rnum = det.rnum(result.pose.ignall,:); det2.view = det.view(result.pose.ignall,:); det2.nimages = det.nimages; det2.N = det.N; det2.gtnum = det.gtnum(result.pose.ignall,:); det2.ov = det.ov(result.pose.ignall,:); det2.ov_obj = det.ov_obj(result.pose.ignall,:); det2.ov_gt = det.ov_gt(result.pose.ignall,:); det2.isdiff = det.isdiff(result.pose.ignall,:); det2.label = det.label(result.pose.ignall,:); det2.label_occ = det.label_occ(result.pose.ignall,:); det2.label_trunc = det.label_trunc(result.pose.ignall,:); det2.isduplicate = det.isduplicate(result.pose.ignall,:); npos = length(result.pose.ignall); dummy = []; [result.pose.ignoreall, dummy] = averagePoseDetectionPrecision(det2, gt, npos);
github
gramuah/pose-errors-master
writeTexHeader.m
.m
pose-errors-master/src/writeTexHeader.m
2,580
utf_8
dcb5ce28f51374b9f67f7518477d7740
function writeTexHeader(outdir, detname) ch = sprintf('%c', '%'); if ~exist(outdir, 'file'), mkdir(outdir); end; global fid fid = fopen(fullfile(outdir, ['header.tex']), 'w'); pr('\\section{Information}\n'); pr('\\label{info}') pr('The \\textbf{%s} detector is analyzed. This is an automatically generated report.\n\n', detname); pr('Our diagnostic tool analyzes the frequency and impact of different types of false positives, and the infuence on the performance of the main object characteristics. Analyzing the different types of false pose estimations of the methods, we can gather very interesting information to improve them. Since it is difficult to characterize the error modes for generic rotations, we restrict our analysis to only the predicted azimuth. We discretize the azimuth angle into $K$ bins, such that the bin centers have an equidistant spacing of $\\frac{2\\pi}{K}$. For our evaluations we set $K=24$. Thus, we define the following types of error modes. \\textit{Opposite viewpoint error}, which measures the efect of flipped estimates (\\textit{e.g}. confusion between frontal and rear views of a car). \\textit{Nearby viewpoint errors}. Nearby pose bins are confused due to they are very correlated in terms of appearance. Finally, the \\textit{Other rotation errors}, which include the rest of false positives. \n\n We also provide the success rate for each pose estimator considering 8 viewpoints: F: frontal. F-L: frontal-left. L: Left. L-RE: left-rear. RE: rear. RE-R: rear-right. R: right. R-F: right-frontal.\n\n'); pr('With respect to the impact of the main object characteristic, the following characteristic are considered in our study: occlusion/truncation, which indicates whether the object is occluded/truncated or not; object size and aspect ratio, which organizes the objects in different sets, depending on their size or aspect ratio; visible sides, which indicates if the object is in frontal, rear or side view position; and part visibility, which marks whether a 3D part is visible or not. For the object size, we measure the pixel area of the bounding box. We assign each object to a size category, depending on the object percentile size within its object category: extra-small (XS: bottom 10$\\%c$); small (S: next 20$\\%c$); large (L: next 80$\\%c$); extra-large (XL: next 100$\\%c$). Likewise, for the aspect ratio, objects are categorized into extra-tall (XT), tall (T), wide (W), and extra-wide (XW), using the same percentiles.\n', ch, ch, ch, ch); fclose(fid); function pr(varargin) global fid; fprintf(fid, varargin{:});
github
gramuah/pose-errors-master
writeTableResults.m
.m
pose-errors-master/src/writeTableResults.m
15,577
utf_8
0e5f03d0af7f21ac22d7f5a429be3e10
function writeTableResults(outdir, detector, res, avp_matrix, peap_matrix, dataset, objects, metric_type) switch metric_type case 1 metric = 'AOS'; case 2 metric = 'AVP'; case 3 metric = 'PEAP'; case 4 metric = 'MAE'; case 5 metric = 'MedError'; end if ~exist(outdir, 'file'), mkdir(outdir); end; global fid fid = fopen(fullfile(outdir, ['results.tex']), 'w'); pr('Note that the results shown in this section are obtained by computing the average over \\textbf{the selected object classes} (\\textit{i.e}:'); for obj=1:length(objects) if obj == length(objects) pr(' %s) included in the %s dataset.\n', objects{obj}, dataset) else pr(' %s, ', objects{obj}) end end pr('\n\n') pr('Tables \\ref{cont_pose} and \\ref{disc_pose} summarize the detection and pose estimation results. Table \\ref{cont_pose} shows the model performance working on continuous pose estimation. For AVP and PEAP the results are obtained considering a threshold equal to $\\frac{\\pi}{12}$.\n Table \\ref{disc_pose} summarizes the results achieved working on discrete pose estimation. The AVP and PEAP metrics are obtained considering different viewpoint discretizations: 4, 8, 16 and 24 views.', length(objects), dataset) pr('\n\n'); pr('\\begin{table}[h]\n') pr('\\caption{\\textbf{%s: Detection and Continuous Pose Estimation Results on %s dataset. For AVP and PEAP the results are obtained considering a threshold equal to $\\frac{\\pi}{12}$.}}\n', detector, dataset); pr('\\label{cont_pose}\n') pr('\\begin{center}\n'); pr('\\resizebox{\\textwidth}{!}{\n') pr('\\begin{tabular}{|c||') for obj=1:length(objects)+1 if obj == length(objects)+1 pr('c|}\n'); else pr('c|'); end end pr('\\hline\n') pr('Metric & ') for obj=1:length(objects) pr('%s & ', objects{obj}); end pr('AVG \\\\ \n'); pr('\\hline\n') pr('AP & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean([res.ap])*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).ap*100; pr('%.1f & ', cad); end end pr('AOS & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean([res.aos])*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).aos*100; pr('%.1f & ', cad); end end pr('AVP ($\\frac{\\pi}{12}$) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean([res.avp])*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).avp*100; pr('%.1f & ', cad); end end pr('PEAP ($\\frac{\\pi}{12}$) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean([res.peap])*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).peap*100; pr('%.1f & ', cad); end end pr('\\hline\n'); pr('\\end{tabular}\n'); pr('}'); pr('\\end{center}\n'); pr('\\end{table}\n'); pr('\\begin{table}[h]\n') pr('\\vspace{-0.4cm}') pr('\\caption{\\textbf{%s: Detection and Discrete Pose Estimation Results on %s dataset. Results obtained considering: 4, 8, 16 and 24 Views.}}\n', detector, dataset); pr('\\label{disc_pose}\n') pr('\\begin{center}\n'); pr('\\resizebox{\\textwidth}{!}{\n') pr('\\begin{tabular}{|c||') for obj=1:length(objects)+1 if obj == length(objects)+1 pr('c|}\n'); else pr('c|'); end end pr('\\hline\n') pr('Metric & ') for obj=1:length(objects) pr('%s & ', objects{obj}); end pr('AVG \\\\ \n'); pr('\\hline\n') pr('AP & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean([res.ap])*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).ap*100; pr('%.1f & ', cad); end end pr('\\hline'); pr('\\hline\n'); pr('AVP (4 views) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean(avp_matrix(1,:))*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).avp_views(1)*100; pr('%.1f & ', cad); end end pr('PEAP (4 views) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean(peap_matrix(1,:))*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).peap_views(1)*100; pr('%.1f & ', cad); end end pr('\\hline'); pr('\\hline\n'); pr('AVP (8 views) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean(avp_matrix(2,:))*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).avp_views(2)*100; pr('%.1f & ', cad); end end pr('PEAP (8 views) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean(peap_matrix(2,:))*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).peap_views(2)*100; pr('%.1f & ', cad); end end pr('\\hline'); pr('\\hline\n'); pr('AVP (16 views) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean(avp_matrix(3,:))*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).avp_views(3)*100; pr('%.1f & ', cad); end end pr('PEAP (16 views) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean(peap_matrix(3,:))*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).peap_views(3)*100; pr('%.1f & ', cad); end end pr('\\hline'); pr('\\hline\n'); pr('AVP (24 views) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean(avp_matrix(4,:))*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).avp_views(4)*100; pr('%.1f & ', cad); end end pr('PEAP (24 views) & '); for obj=1:length(objects)+1 if obj == length(objects) + 1 cad = mean(peap_matrix(4,:))*100; pr('%.1f \\\\ \n', cad ); else cad = res(obj).peap_views(4)*100; pr('%.1f & ', cad); end end pr('\\hline\n'); pr('\\end{tabular}\n'); pr('}'); pr('\\end{center}\n'); pr('\\end{table}\n'); pr('Figure \\ref{fig1} summarizes the impact on the pose performance of each type of error. Figure \\ref{fig1a} reports, for the correct detections obtained by the %s model, the frequency and impact on the pose performance of each type of false positive. For this figure a pose estimation is considered as: a) correct if its error is $< 15^\\circ$; b) opposite if its pose error is $> 165^\\circ$; c) nearby if its pose error is $\\in [15^\\circ; 30^\\circ]$; d) other for the rest of situations. Figure \\ref{fig1b} shows the impact of different type of pose errors.\n', detector); pr('Figure \\ref{fig2} shows the success rate considering the 8 viewpoints described in Section \\ref{info}. Hence, considering only the correct detections, Figure \\ref{fig1b} also summarizes the percentage of success and error on pose estimation. \n'); pr('\n'); pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig1a}\n'); pr('\\includegraphics[width=0.45\\textwidth,trim = 25mm 65mm 20mm 65mm, clip]{../plot_3.pdf} \n'); pr('}\n'); pr('\\subfloat[]{\n'); pr('\\label{fig1b}\n'); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../plot_6.pdf}\n'); pr('}\n'); pr('\\caption{\\textbf{Analysis and Impact of Pose Estimation Errors.} (a) Pie chart shows the fraction of pose errors that are due to Opposite viewpoints (Opposite), confusion with Nearby viewpoints (Nearby), confusion with Other rotations (Other). It also reports the percentage of correct pose estimations (Correct). (b) Impact of Pose Errors. \\textcolor{blue}{Blue Bars} display the %s performance obtained when all estimations are considered. \\textcolor{green}{Green Bars} display the %s improvement by \\textbf{removing} all estimations of one type: \\textbf{OTH} removes confusion with other rotation viewpoints; \\textbf{NEAR} removes confusion with nearby viewpoints; \\textbf{OPP} removes confusion with opposite viewpoints. \\textcolor{BrickRed}{Brick Red Bars} show the %s improvement by \\textbf{correcting} all estimations of one type: \\textbf{OTH}, \\textbf{NEAR} and \\textbf{OPP}.} \n', metric, metric, metric); pr('\\label{fig1}\n'); pr('\\end{figure}\n'); pr('\n'); pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\includegraphics[width=0.85\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../plot_7.pdf} \n'); pr('\\caption{\\textbf{Success Rate considering 8 viewpoints.} For each of the 8 viewpoints, we report: In \\textcolor{blue}{Blue}, the percentage of the correct pose estimations. In \\textcolor{cyan}{Cyan}, the percentage of confusion with the opposite viewpoints. In \\textcolor{yellow}{Yellow}, the percentage of confusion with nearby viewpoints. In \\textcolor{BrickRed}{Brick Red}, the percentage of the confusions with other rotations.}\n'); pr('\\label{fig2}\n'); pr('\\end{figure}\n'); pr('\n'); pr('\\clearpage\n'); pr('Figure \\ref{fig3} summarizes the main object characteristic influences. Figure \\ref{fig3a} shows the influence of the side visibility. Figures \\ref{fig3b} and \\ref{fig3c} report the aspect ratio and object size effects, respectively.\n'); pr('Figure \\ref{fig4} provides a summary of the sensitivity to each characteristic and the potential impact on improving pose estimation robustness. The worst-performing and best-performing combinations for each object characteristic are averaged over the selected object categories. The difference between the best and the worst performance indicates sensitivity; the difference between the best and the overall indicates the potential impact.\n'); pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig3a}\n'); pr('\\includegraphics[width=0.3\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../plot_2.pdf}\n'); pr('}\n'); pr('\\subfloat[]{\n'); pr('\\label{fig3b}\n'); pr('\\includegraphics[width=0.3\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../plot_8.pdf}\n'); pr('}\n'); pr('\\subfloat[]{\n'); pr('\\label{fig3c}\n'); pr('\\includegraphics[width=0.3\\textwidth,trim = 15mm 65mm 25mm 65mm, clip]{../plot_9.pdf}\n'); pr('}\n'); pr('\\caption{\\textbf{Object Characteristic Influences in terms of %s}. (a) Side Visibility Influence. Visible side: \\textbf{1} = performance obtained when the corresponding side is visible; \\textbf{0} = accuracy achieved when the side is not visible. (b) Aspect Ratio Effect. We show the overall accuracy by the black dashed line, and the performance achieved when we only consider: XT , T, W and XW objects. (c) Object Size Effect. We show the overall accuracy by the black dashed line, and the performance achieved when we only consider: XS, S, L and XL objects.}\n', metric); pr('\\label{fig3}\n'); pr('\\end{figure}\n'); if strcmp(detector(length(detector)-1:length(detector)), 'gt') pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\includegraphics[width=0.85\\textwidth,trim = 10mm 65mm 25mm 65mm, clip]{../plot_1.pdf}\n'); pr('\\caption{\\textbf{Summary of Sensitivity and Impact of Object Characteristics.} We show the %s performance of the highest performing and lowest performing subsets within each characteristic (occlusion/truncation (occ-trn), bounding box area or object size (size), aspect ratio (asp), visible sides (side) and part visibility (part)). Overall accuracy is indicated by the black dashed line. The difference between max and min indicates sensitivity; the difference between max and overall indicates the impact.\n', metric); pr('}\n'); pr('\\label{fig4}\n'); pr('\\end{figure}\n'); else pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\includegraphics[width=0.85\\textwidth,trim = 10mm 65mm 25mm 65mm, clip]{../plot_1.pdf}\n'); pr('\\caption{\\textbf{Summary of Sensitivity and Impact of Object Characteristics.} We show the %s performance of the highest performing and lowest performing subsets within each characteristic (occlusion/truncation (occ-trn), difficult objects (diff), bounding box area or object size (size), aspect ratio (asp), visible sides (side) and part visibility (part)). Overall accuracy is indicated by the black dashed line. The difference between max and min indicates sensitivity; the difference between max and overall indicates the impact.\n', metric); pr('}\n'); pr('\\label{fig4}\n'); pr('\\end{figure}\n'); end pr('\\clearpage\n'); pr('Figure \\ref{fig5} shows an analysis of the influence of the overlap criterion considering all the metrics. Figure \\ref{fig5a} shows AOS, AVP and PEAP, and Figure \\ref{fig5b} reports MAE and MedError. For this overlap criterion analysis we follow the PASCAL VOC formulation: to be considered a true positive, the area of overlap between the predicted BB and GT BB must exceed a threshold.\n'); pr('\\begin{figure}[h]\n'); pr('\\centering\n'); pr('\\subfloat[]{\n'); pr('\\label{fig5a}\n'); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 20mm 65mm, clip]{../plot_4.pdf}\n'); pr('}\n'); pr('\\subfloat[]{\n'); pr('\\label{fig5b}\n'); pr('\\includegraphics[width=0.45\\textwidth,trim = 15mm 65mm 20mm 65mm, clip]{../plot_5.pdf}\n'); pr('}\n'); pr('\\caption{\\textbf{Simultaneous Object Detection and Pose Estimation.} Analysis of pose estimation performance considering different metrics and different overlap criteria. (a) AP, AOS, AVP and PEAP. (b) MAE and MedError.}\n'); pr('\\label{fig5}\n'); pr('\\end{figure}\n'); pr('\n\n') pr('Finally, we summarize the main pose estimation errors (Figure \\ref{fig6}) and the success rate considering 8 viewpoints (Figure \\ref{fig7}) for each of the selected object classes: ') for obj=1:length(objects) if obj == length(objects) pr(' %s from %s dataset.\n', objects{obj}, dataset) else pr(' %s, ', objects{obj}) end end pr('\n\n') pr('\\begin{figure}[h]\n') pr('\\centering\n'); for obj=1:length(objects) name = objects{obj}; if exist(fullfile(outdir(1:end-4), name, 'analysisI/plot_2.pdf'), 'file') pr('\\subfloat[%s]{\n', name); pr('\\label{fig6%c}\n', char(96 + obj)); if mod(obj,3) ~= 0 pr('\\includegraphics[width=0.3\\textwidth,trim = 25mm 65mm 20mm 65mm, clip]{../%s/analysisI/plot_2.pdf} \n', name); pr('}\n'); else pr('\\includegraphics[width=0.3\\textwidth,trim = 25mm 65mm 20mm 65mm, clip]{../%s/analysisI/plot_2.pdf} \n', name); pr('}\\\\n'); end end end pr('\\caption{\\textbf{Main Pose Estimation Errors for all selected Object Classes from %s dataset.}}\n', dataset); pr('\\label{fig6}\n'); pr('\\end{figure}\n'); pr('\\begin{figure}[h]\n') pr('\\centering\n'); for obj=1:length(objects) name = objects{obj}; if exist(fullfile(outdir(1:end-4), name, 'analysisI/plot_4.pdf'), 'file') pr('\\subfloat[%s]{\n', name); pr('\\label{fig7%c}\n', char(96 + obj)); if mod(obj,3) ~= 0 pr('\\includegraphics[width=0.3\\textwidth,trim = 20mm 65mm 25mm 65mm, clip]{../%s/analysisI/plot_4.pdf} \n', name); pr('}\n'); else pr('\\includegraphics[width=0.3\\textwidth,trim = 20mm 65mm 25mm 65mm, clip]{../%s/analysisI/plot_4.pdf} \n', name); pr('}\\\\n'); end end end pr('\\caption{\\textbf{Success Rate considering 8 viewpoints for all selected Object Classes from %s dataset.}}\n', dataset); pr('\\label{fig7}\n'); pr('\\end{figure}\n'); fclose(fid); function pr(varargin) global fid; fprintf(fid, varargin{:});
github
gramuah/pose-errors-master
displayPerCharacteristicPosePlots.m
.m
pose-errors-master/src/displayPerCharacteristicPosePlots.m
35,305
utf_8
6f6e849114b00ea0f0b75027b316bc43
function [resultclass, f] = displayPerCharacteristicPosePlots(resultfp, result, detector, error_type) %function [resutclass,f] = displayPerCharacteristicDetPlots(results_all, error_type) % % Object characteristic effect on pose estimation: save and display plots % % Inputs: % result: detection results % resultfp: pose error results (false positives) % error_type: metric to analysis close all switch error_type case 1 metric = 'AOS'; case 2 metric = 'AVP'; case 3 metric = 'PEAP'; case 4 metric = 'MAE'; case 5 metric = 'MedError'; end %% Impact Bar Chart % Obtained pose results: tmp = [resultfp.pose]; AP = mean([tmp.ap]); AOS = mean([tmp.aos]); AVP = mean([tmp.avp15]); PEAP = mean([tmp.peap15]); MAE = mean([tmp.mean_error]); MedErr = mean([tmp.median_error]); resultclass.MAE = MAE; resultclass.MedError = MedErr; fs = 18; f = 1; %% occ vs non-occluded tmp = [result.pose.ignoreocc]; occ_flag = 0; if ~isempty(tmp) occ_flag = 1; ignore_OCC_aos = mean([tmp.aos]); ignore_OCC_avp = mean([tmp.avp15]); ignore_OCC_peap = mean([tmp.peap15]); ignore_OCC_mae = mean([tmp.mean_error]); ignore_OCC_mederr = mean([tmp.median_error]); else occ_flag = 0; ignore_OCC_aos = 0; ignore_OCC_avp = 0; ignore_OCC_peap = 0; ignore_OCC_mae = 0; ignore_OCC_mederr = 0; end tmp = [result.pose.onlyocc]; occ_flag = 0; if ~isempty(tmp) occ_flag = 1; only_OCC_aos = mean([tmp.aos]); only_OCC_avp = mean([tmp.avp15]); only_OCC_peap = mean([tmp.peap15]); only_OCC_mae = mean([tmp.mean_error]); only_OCC_mederr = mean([tmp.median_error]); else occ_flag = 0; only_OCC_aos = 0; only_OCC_avp = 0; only_OCC_peap = 0; only_OCC_mae = 0; only_OCC_mederr = 0; end switch error_type case 1 y = [0, 0, 0; ... AOS, ignore_OCC_aos, only_OCC_aos]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 1 0 4]); xlim = [0 1]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('AOS','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Trunc/Occ. Objects']) case 2 y = [0, 0, 0; AVP, ignore_OCC_avp, only_OCC_avp]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 1 0 4]); xlim = [0 1]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('AVP','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Trunc/Occ. Objects']) case 3 y = [0, 0, 0; PEAP, ignore_OCC_peap, only_OCC_peap]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 1 0 4]); xlim = [0 1]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('PEAP','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Trunc/Occ. Objects']) case 4 y = [0, 0, 0; ... MAE, ignore_OCC_mae, only_OCC_mae]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 ceil(max([MAE ignore_OCC_mae only_OCC_mae])+10) 0 4]); xlim = [0 ceil((max([MAE ignore_OCC_mae only_OCC_mae])+10))]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('MAE','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Trunc/Occ. Objects']) case 5 y = [0, 0, 0; ... MedErr, ignore_OCC_mederr, only_OCC_mederr]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 ceil(max([MedErr ignore_OCC_mederr only_OCC_mederr])+10) 0 4]); xlim = [0 ceil((max([MedErr ignore_OCC_mederr only_OCC_mederr])+10))]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('MedError','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Trunc/Occ. Objects']) end %% diff vs non-diff %%%% f = f + 1; tmp = [result.pose.diff]; diff_aos = mean([tmp.aos]); diff_avp = mean([tmp.avp15]); diff_peap = mean([tmp.peap15]); diff_mae = mean([tmp.mean_error]); diff_mederr = mean([tmp.median_error]); tmp = [result.diff_nondiff(2)]; only_diff_aos = mean([tmp.aos]); only_diff_avp = mean([tmp.avp15]); only_diff_peap = mean([tmp.peap15]); only_diff_mae = mean([tmp.mean_error]); only_diff_mederr = mean([tmp.median_error]); switch error_type case 1 y = [0, 0, 0; ... AOS, diff_aos, only_diff_aos]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 1 0 4]); xlim = [0 1]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('AOS','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Difficult Objects']) case 2 y = [0, 0, 0; AVP, diff_avp, only_diff_avp]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 1 0 4]); xlim = [0 1]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('AVP','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Difficult Objects']) case 3 y = [0, 0, 0; PEAP, diff_peap, only_diff_peap]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 1 0 4]); xlim = [0 1]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('PEAP','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Difficult Objects']) case 4 y = [0, 0, 0; ... MAE, diff_mae, only_diff_mae]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 ceil(max([MAE ignore_OCC_mae only_OCC_mae])+10) 0 4]); xlim = [0 ceil((max([MAE ignore_OCC_mae only_OCC_mae])+10))]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('MAE','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Difficult Objects']) case 5 y = [0, 0, 0; ... MedErr, diff_mederr, only_diff_mederr]; x = [-2 2]; figure(f), hold off; barh(x, y); axis([0 ceil(max([MedErr ignore_OCC_mederr only_OCC_mederr])+10) 0 4]); xlim = [0 ceil((max([MedErr ignore_OCC_mederr only_OCC_mederr])+10))]; set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); set(gca, 'ytick', 2) set(gca, 'yticklabel', {' '}); ylabel('MedError','fontsize', fs,'Rotation',90); set(gca, 'fontsize', fs); title([resultfp.name ': Difficult Objects']) end %% object size analysis %%%% f = f + 1; onlythissize_aos = zeros(1, length(result.pose.onlythissize)); onlythissize_avp = zeros(1, length(result.pose.onlythissize)); onlythissize_peap = zeros(1, length(result.pose.onlythissize)); onlythissize_mae = zeros(1, length(result.pose.onlythissize)); onlythissize_mederr = zeros(1, length(result.pose.onlythissize)); ignorethissize_aos = zeros(1, length(result.pose.onlythissize)); ignorethissize_avp = zeros(1, length(result.pose.onlythissize)); ignorethissize_peap = zeros(1, length(result.pose.onlythissize)); ignorethissize_mae = zeros(1, length(result.pose.onlythissize)); ignorethissize_mederr = zeros(1, length(result.pose.onlythissize)); for i=1:length(result.pose.onlythissize) tmp = [result.pose.onlythissize(i)]; onlythissize_aos(i) = mean([tmp.aos]); onlythissize_avp(i) = mean([tmp.avp15]); onlythissize_peap(i) = mean([tmp.peap15]); onlythissize_mae(i) = mean([tmp.mean_error]); onlythissize_mederr(i) = mean([tmp.median_error]); tmp = [result.pose.ignorethissize(i)]; ignorethissize_aos(i) = mean([tmp.aos]); ignorethissize_avp(i) = mean([tmp.avp15]); ignorethissize_peap(i) = mean([tmp.peap15]); ignorethissize_mae(i) = mean([tmp.mean_error]); ignorethissize_mederr(i) = mean([tmp.median_error]); end switch error_type case 1 resultclass.extrasmall = onlythissize_aos(1); resultclass.small = onlythissize_aos(2); resultclass.large = onlythissize_aos(4); resultclass.extralarge = onlythissize_aos(5); y1 = [AOS, onlythissize_aos(1), ignorethissize_aos(1); AOS, onlythissize_aos(2), ignorethissize_aos(2); AOS, onlythissize_aos(3), ignorethissize_aos(3); AOS, onlythissize_aos(4), ignorethissize_aos(4); AOS, onlythissize_aos(5), ignorethissize_aos(5)]; case 2 resultclass.extrasmall = onlythissize_avp(1); resultclass.small = onlythissize_avp(2); resultclass.large = onlythissize_avp(4); resultclass.extralarge = onlythissize_avp(5); y1 = [AVP, onlythissize_avp(1), ignorethissize_avp(1); AVP, onlythissize_avp(2), ignorethissize_avp(2); AVP, onlythissize_avp(3), ignorethissize_avp(3); AVP, onlythissize_avp(4), ignorethissize_avp(4); AVP, onlythissize_avp(5), ignorethissize_avp(5)]; case 3 resultclass.extrasmall = onlythissize_peap(1); resultclass.small = onlythissize_peap(2); resultclass.large = onlythissize_peap(4); resultclass.extralarge = onlythissize_peap(5); y1 = [PEAP, onlythissize_peap(1), ignorethissize_peap(1); AVP, onlythissize_peap(2), ignorethissize_peap(2); AVP, onlythissize_peap(3), ignorethissize_peap(3); AVP, onlythissize_peap(4), ignorethissize_peap(4); AVP, onlythissize_peap(5), ignorethissize_peap(5)]; case 4 resultclass.extrasmall = onlythissize_mae(1); resultclass.small = onlythissize_mae(2); resultclass.large = onlythissize_mae(4); resultclass.extralarge = onlythissize_mae(5); y1 = [MAE, onlythissize_mae(1), ignorethissize_mae(1); MAE, onlythissize_mae(2), ignorethissize_mae(2); MAE, onlythissize_mae(3), ignorethissize_mae(3); MAE, onlythissize_mae(4), ignorethissize_mae(4); MAE, onlythissize_mae(5), ignorethissize_mae(5)]; case 5 resultclass.extrasmall = onlythissize_mederr(1); resultclass.small = onlythissize_mederr(2); resultclass.large = onlythissize_mederr(4); resultclass.extralarge = onlythissize_mederr(5); y1 = [MedErr, onlythissize_mederr(1), ignorethissize_mederr(1); MedErr, onlythissize_mederr(2), ignorethissize_mederr(2); MedErr, onlythissize_mederr(3), ignorethissize_mederr(3); MedErr, onlythissize_mederr(4), ignorethissize_mederr(4); MedErr, onlythissize_mederr(5), ignorethissize_mederr(5)]; end x = [1 2 3 4 5]; figure(f), hold off; barh(x, y1); if (error_type == 1) || (error_type == 2) || (error_type == 3) xlim = [0 1]; else xlim = [0 ceil(max(max(y1))+10)]; end set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); xlabel(metric, 'fontsize', fs); set(gca, 'ytick', 1:5) set(gca, 'yticklabel', {'XS', 'S', 'M', 'L', 'XL'}); set(gca, 'fontsize', fs); title([resultfp.name ': Object Size Influence'], 'fontsize', fs, 'fontweight', 'bold') %% aspect ratio analysis %%%% f = f + 1; onlythisaspect_aos = zeros(1, length(result.pose.onlythisaspect)); onlythisaspect_avp = zeros(1, length(result.pose.onlythisaspect)); onlythisaspect_peap = zeros(1, length(result.pose.onlythisaspect)); onlythisaspect_mae = zeros(1, length(result.pose.onlythisaspect)); onlythisaspect_mederr = zeros(1, length(result.pose.onlythisaspect)); ignorethisaspect_aos = zeros(1, length(result.pose.onlythisaspect)); ignorethisaspect_avp = zeros(1, length(result.pose.onlythisaspect)); ignorethisaspect_peap = zeros(1, length(result.pose.onlythisaspect)); ignorethisaspect_mae = zeros(1, length(result.pose.onlythisaspect)); ignorethisaspect_mederr = zeros(1, length(result.pose.onlythisaspect)); for i = 1:length(result.pose.onlythisaspect) tmp = [result.pose.onlythisaspect(i)]; onlythisaspect_aos(i) = mean([tmp.aos]); onlythisaspect_avp(i) = mean([tmp.avp15]); onlythisaspect_peap(i) = mean([tmp.peap15]); onlythisaspect_mae(i) = mean([tmp.mean_error]); onlythisaspect_mederr(i) = mean([tmp.median_error]); tmp = [result.pose.ignorethisaspect(i)]; ignorethisaspect_aos(i) = mean([tmp.aos]); ignorethisaspect_avp(i) = mean([tmp.avp15]); ignorethisaspect_peap(i) = mean([tmp.peap15]); ignorethisaspect_mae(i) = mean([tmp.mean_error]); ignorethisaspect_mederr(i) = mean([tmp.median_error]); end switch error_type case 1 resultclass.extratall = onlythisaspect_aos(1); resultclass.tall = onlythisaspect_aos(2); resultclass.wide = onlythisaspect_aos(4); resultclass.extrawide = onlythisaspect_aos(5); y1 = [AOS, onlythisaspect_aos(1), ignorethisaspect_aos(1); AOS, onlythisaspect_aos(2), ignorethisaspect_aos(2); AOS, onlythisaspect_aos(3), ignorethisaspect_aos(3); AOS, onlythisaspect_aos(4), ignorethisaspect_aos(4); AOS, onlythisaspect_aos(5), ignorethisaspect_aos(5)]; case 2 resultclass.extratall = onlythisaspect_avp(1); resultclass.tall = onlythisaspect_avp(2); resultclass.wide = onlythisaspect_avp(4); resultclass.extrawide = onlythisaspect_avp(5); y1 = [AVP, onlythisaspect_avp(1), ignorethisaspect_avp(1); AVP, onlythisaspect_avp(2), ignorethisaspect_avp(2); AVP, onlythisaspect_avp(3), ignorethisaspect_avp(3); AVP, onlythisaspect_avp(4), ignorethisaspect_avp(4); AVP, onlythisaspect_avp(5), ignorethisaspect_avp(5)]; case 3 resultclass.extratall = onlythisaspect_peap(1); resultclass.tall = onlythisaspect_peap(2); resultclass.wide = onlythisaspect_peap(4); resultclass.extrawide = onlythisaspect_peap(5); y1 = [PEAP, onlythisaspect_peap(1), ignorethisaspect_peap(1); PEAP, onlythisaspect_peap(2), ignorethisaspect_peap(2); PEAP, onlythisaspect_peap(3), ignorethisaspect_peap(3); PEAP, onlythisaspect_peap(4), ignorethisaspect_peap(4); PEAP, onlythisaspect_peap(5), ignorethisaspect_peap(5)]; case 4 resultclass.extratall = onlythisaspect_mae(1); resultclass.tall = onlythisaspect_mae(2); resultclass.wide = onlythisaspect_mae(4); resultclass.extrawide = onlythisaspect_mae(5); y1 = [MAE, onlythisaspect_mae(1), ignorethisaspect_mae(1); MAE, onlythisaspect_mae(2), ignorethisaspect_mae(2); MAE, onlythisaspect_mae(3), ignorethisaspect_mae(3); MAE, onlythisaspect_mae(4), ignorethisaspect_mae(4); MAE, onlythisaspect_mae(5), ignorethisaspect_mae(5)]; case 5 resultclass.extratall = onlythisaspect_mederr(1); resultclass.tall = onlythisaspect_mederr(2); resultclass.wide = onlythisaspect_mederr(4); resultclass.extrawide = onlythisaspect_mederr(5); y1 = [MedErr, onlythisaspect_mederr(1), ignorethisaspect_mederr(1); MedErr, onlythisaspect_mederr(2), ignorethisaspect_mederr(2); MedErr, onlythisaspect_mederr(3), ignorethisaspect_mederr(3); MedErr, onlythisaspect_mederr(4), ignorethisaspect_mederr(4); MedErr, onlythisaspect_mederr(5), ignorethisaspect_mederr(5)]; end x = [1 2 3 4 5]; figure(f), hold off; barh(x, y1); if (error_type == 1) || (error_type == 2) || (error_type == 3) xlim = [0 1]; else xlim = [0 round(max(max(y1))+10)]; end set(gca, 'xlim', xlim); set(gca, 'xminortick', 'on'); set(gca, 'ticklength', get(gca, 'ticklength')); xlabel(metric, 'fontsize', fs); set(gca, 'ytick', 1:5) set(gca, 'yticklabel', {'XT', 'T', 'M', 'W', 'XW'}); set(gca, 'fontsize', fs); title([resultfp.name ': Aspect Ratio Influence'], 'fontsize', fs, 'fontweight', 'bold') %%%% fs = 18; f = f + 1; if strcmp(detector(length(detector)-1:length(detector)), 'gt') fnames = {'side', 'part'}; xticklab = {'occ-trn', 'size', 'asp', 'side', 'part'}; valid = true(size(xticklab)); for af = 1:numel(fnames) if ~isfield(result(1).pose, fnames{af}) valid(f) = false; continue; end if af == 1 if occ_flag switch error_type case 1 maxval(1)= max([AOS, ignore_OCC_aos, only_OCC_aos]); minval(1)= min([AOS, ignore_OCC_aos, only_OCC_aos]); case 2 maxval(1)= max([AVP, ignore_OCC_avp, only_OCC_avp]); minval(1)= min([AVP, ignore_OCC_avp, only_OCC_avp]); case 3 maxval(1)= max([PEAP, ignore_OCC_peap, only_OCC_peap]); minval(1)= min([PEAP, ignore_OCC_peap, only_OCC_peap]); case 4 maxval(1)= max([MAE, ignore_OCC_mae, only_OCC_mae]); minval(1)= min([MAE, ignore_OCC_mae, only_OCC_mae]); case 5 maxval(1)= max([MedErr, ignore_OCC_mederr, only_OCC_mederr]); minval(1)= min([MedErr, ignore_OCC_mederr, only_OCC_mederr]); end else switch error_type case 1 maxval(1) = AOS; minval(1) = 0; case 2 maxval(1) = AVP; minval(1) = 0; case 3 maxval(1) = PEAP; minval(1) = 0; case 4 maxval(1) = MAE; minval(1) = 0; case 5 maxval(1) = MedErr; minval(1) = 0; end end resultclass.ap = AP; resultclass.aos = AOS; resultclass.avp = AVP; resultclass.peap = PEAP; resultclass.mae = MAE; resultclass.mederr = MedErr; switch error_type case 1 tmp = [resultfp.pose]; avgval = mean([tmp.aos]); maxval(2)= max([AOS, onlythissize_aos, ignorethissize_aos]); minval(2)= min([AOS, onlythissize_aos, ignorethissize_aos]); maxval(3)= max([AOS, onlythisaspect_aos, ignorethisaspect_aos]); minval(3)= min([AOS, onlythisaspect_aos, ignorethisaspect_aos]); case 2 tmp = [resultfp.pose]; avgval = mean([tmp.avp15]); maxval(2)= max([AVP, onlythissize_avp, ignorethissize_avp]); minval(2)= min([AVP, onlythissize_avp, ignorethissize_avp]); maxval(3)= max([AVP, onlythisaspect_avp, ignorethisaspect_avp]); minval(3)= min([AVP, onlythisaspect_avp, ignorethisaspect_avp]); case 3 tmp = [resultfp.pose]; avgval = mean([tmp.peap15]); maxval(2)= max([PEAP, onlythissize_peap, ignorethissize_peap]); minval(2)= min([PEAP, onlythissize_peap, ignorethissize_peap]); maxval(3)= max([PEAP, onlythisaspect_peap, ignorethisaspect_peap]); minval(3)= min([PEAP, onlythisaspect_peap, ignorethisaspect_peap]); case 4 tmp = [resultfp.pose]; avgval = mean([tmp.mean_error]); maxval(2)= max([MAE, onlythissize_mae, ignorethissize_mae]); minval(2)= min([MAE, onlythissize_mae, ignorethissize_mae]); maxval(3)= max([MAE, onlythisaspect_mae, ignorethisaspect_mae]); minval(3)= min([MAE, onlythisaspect_mae, ignorethisaspect_mae]); case 5 tmp = [resultfp.pose]; avgval = mean([tmp.median_error]); maxval(2)= max([MedErr, onlythissize_mederr, ignorethissize_mederr]); minval(2)= min([MedErr, onlythissize_mederr, ignorethissize_mederr]); maxval(3)= max([MedErr, onlythisaspect_mederr, ignorethisaspect_mederr]); minval(3)= min([MedErr, onlythisaspect_mederr, ignorethisaspect_mederr]); end resultclass.maxval(1) = maxval(1); resultclass.minval(1) = minval(1); resultclass.maxval(2) = maxval(2); resultclass.minval(2) = minval(2); resultclass.maxval(3) = maxval(3); resultclass.minval(3) = minval(3); end switch error_type case 1 maxval(af+3) = getMaxVal([result.pose.(fnames{af})], 'aos'); minval(af+3) = getMinVal([result.pose.(fnames{af})], 'aos'); case 2 maxval(af+3) = getMaxVal([result.pose.(fnames{af})], 'avp15'); minval(af+3) = getMinVal([result.pose.(fnames{af})], 'avp15'); case 3 maxval(af+3) = getMaxVal([result.pose.(fnames{af})], 'peap15'); minval(af+3) = getMinVal([result.pose.(fnames{af})], 'peap15'); case 4 maxval(af+3) = getMaxVal([result.pose.(fnames{af})], 'mean_error'); minval(af+3) = getMinVal([result.pose.(fnames{af})], 'mean_error'); case 5 maxval(af+3) = getMaxVal([result.pose.(fnames{af})], 'median_error'); minval(af+3) = getMinVal([result.pose.(fnames{af})], 'median_error'); end resultclass.maxval(af+3) = maxval(af+3); resultclass.minval(af+3) = minval(af+3); end maxval = maxval(:, valid); minval = minval(:, valid); fnames = xticklab(valid); xticklab = xticklab(valid); maxval = mean(maxval, 1); minval = mean(minval, 1); figure(f), hold off; plot([1 numel(fnames)], [avgval avgval], 'k--', 'linewidth', 2); hold on; errorbar(1:numel(fnames), avgval*ones(1, numel(fnames)), avgval-minval, ... maxval-avgval, 'r+', 'linewidth', 2); for x = 1:numel(fnames) if (error_type == 1) || (error_type == 2) || (error_type == 3) text(x+0.12, minval(x)+0.01, sprintf('%0.3f', minval(x)), ... 'fontsize', fs, 'fontweight', 'bold'); text(x+0.12, maxval(x)-0.02, sprintf('%0.3f', maxval(x)), ... 'fontsize', fs, 'fontweight', 'bold'); else text(x+0.12, minval(x), sprintf('%0.1f', minval(x)), 'fontsize', fs, 'fontweight', 'bold'); text(x+0.12, maxval(x), sprintf('%0.1f', maxval(x)), 'fontsize', fs, 'fontweight', 'bold'); end end text(0.1, avgval, sprintf('%0.3f', avgval), 'fontsize', fs, 'fontweight', 'bold'); if (error_type == 1) || (error_type == 2) || (error_type == 3) ymax = min(round((max(maxval)+0.15)*10)/10,1); else ymax = max(maxval) + 5; end axis([0 numel(fnames)+1 0 ymax]); ylabel(metric, 'fontsize', fs, 'fontweight', 'bold'); set(gca, 'xtick', 1:numel(fnames)); set(gca, 'xticklabel', xticklab); set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs, 'fontweight', 'bold'); set(gca, 'ticklength', [0.001 0.001]); title([resultfp.name ': Sensitivity and Impact']) else fnames = {'side', 'part'}; xticklab = {'occ-trn', 'diff', 'size', 'asp', 'side', 'part'}; af=1; valid = true(size(xticklab)); for af = 1:numel(fnames) if ~isfield(result(1).pose, fnames{af}) valid(f) = false; continue; end if af == 1 if occ_flag switch error_type case 1 maxval(1)= max([AOS, ignore_OCC_aos, only_OCC_aos]); minval(1)= min([AOS, ignore_OCC_aos, only_OCC_aos]); case 2 maxval(1)= max([AVP, ignore_OCC_avp, only_OCC_avp]); minval(1)= min([AVP, ignore_OCC_avp, only_OCC_avp]); case 3 maxval(1)= max([PEAP, ignore_OCC_peap, only_OCC_peap]); minval(1)= min([PEAP, ignore_OCC_peap, only_OCC_peap]); case 4 maxval(1)= max([MAE, ignore_OCC_mae, only_OCC_mae]); minval(1)= min([MAE, ignore_OCC_mae, only_OCC_mae]); case 5 maxval(1)= max([MedErr, ignore_OCC_mederr, only_OCC_mederr]); minval(1)= min([MedErr, ignore_OCC_mederr, only_OCC_mederr]); end else switch error_type case 1 maxval(1) = AOS; minval(1) = 0; case 2 maxval(1) = AVP; minval(1) = 0; case 3 maxval(1) = PEAP; minval(1) = 0; case 4 maxval(1) = MAE; minval(1) = 0; case 5 maxval(1) = MedErr; minval(1) = 0; end end resultclass.ap = AP; resultclass.aos = AOS; resultclass.avp = AVP; resultclass.peap = PEAP; resultclass.mae = MAE; resultclass.mederr = MedErr; switch error_type case 1 tmp = [resultfp.pose]; avgval = mean([tmp.aos]); maxval(2)= max(AOS, diff_aos); minval(2)= min(AOS, diff_aos); maxval(3)= max([AOS, onlythissize_aos, ignorethissize_aos]); minval(3)= min([AOS, onlythissize_aos, ignorethissize_aos]); maxval(4)= max([AOS, onlythisaspect_aos, ignorethisaspect_aos]); minval(4)= min([AOS, onlythisaspect_aos, ignorethisaspect_aos]); case 2 tmp = [resultfp.pose]; avgval = mean([tmp.avp15]); maxval(2)= max(AVP, diff_avp); minval(2)= min(AVP, diff_avp); maxval(3)= max([AVP, onlythissize_avp, ignorethissize_avp]); minval(3)= min([AVP, onlythissize_avp, ignorethissize_avp]); maxval(4)= max([AVP, onlythisaspect_avp, ignorethisaspect_avp]); minval(4)= min([AVP, onlythisaspect_avp, ignorethisaspect_avp]); case 3 tmp = [resultfp.pose]; avgval = mean([tmp.peap15]); maxval(2)= max(PEAP, diff_peap); minval(2)= min(PEAP, diff_peap); maxval(3)= max([PEAP, onlythissize_peap, ignorethissize_peap]); minval(3)= min([PEAP, onlythissize_peap, ignorethissize_peap]); maxval(4)= max([PEAP, onlythisaspect_peap, ignorethisaspect_peap]); minval(4)= min([PEAP, onlythisaspect_peap, ignorethisaspect_peap]); case 4 tmp = [resultfp.pose]; avgval = mean([tmp.mean_error]); maxval(2)= max(MAE, diff_mae); minval(2)= min(MAE, diff_mae); maxval(3)= max([MAE, onlythissize_mae, ignorethissize_mae]); minval(3)= min([MAE, onlythissize_mae, ignorethissize_mae]); maxval(4)= max([MAE, onlythisaspect_mae, ignorethisaspect_mae]); minval(4)= min([MAE, onlythisaspect_mae, ignorethisaspect_mae]); case 5 tmp = [resultfp.pose]; avgval = mean([tmp.median_error]); maxval(2)= max(MedErr, diff_mederr); minval(2)= min(MedErr, diff_mederr); maxval(3)= max([MedErr, onlythissize_mederr, ignorethissize_mederr]); minval(3)= min([MedErr, onlythissize_mederr, ignorethissize_mederr]); maxval(4)= max([MedErr, onlythisaspect_mederr, ignorethisaspect_mederr]); minval(4)= min([MedErr, onlythisaspect_mederr, ignorethisaspect_mederr]); end resultclass.maxval(1) = maxval(1); resultclass.minval(1) = minval(1); resultclass.maxval(2) = maxval(2); resultclass.minval(2) = minval(2); resultclass.maxval(3) = maxval(3); resultclass.minval(3) = minval(3); resultclass.maxval(4) = maxval(4); resultclass.minval(4) = minval(4); end switch error_type case 1 maxval(af+4) = getMaxVal([result.pose.(fnames{af})], 'aos'); minval(af+4) = getMinVal([result.pose.(fnames{af})], 'aos'); case 2 maxval(af+4) = getMaxVal([result.pose.(fnames{af})], 'avp15'); minval(af+4) = getMinVal([result.pose.(fnames{af})], 'avp15'); case 3 maxval(af+4) = getMaxVal([result.pose.(fnames{af})], 'peap15'); minval(af+4) = getMinVal([result.pose.(fnames{af})], 'peap15'); case 4 maxval(af+4) = getMaxVal([result.pose.(fnames{af})], 'mean_error'); minval(af+4) = getMinVal([result.pose.(fnames{af})], 'mean_error'); case 5 maxval(af+4) = getMaxVal([result.pose.(fnames{af})], 'median_error'); minval(af+4) = getMinVal([result.pose.(fnames{af})], 'median_error'); end resultclass.maxval(af+4) = maxval(af+4); resultclass.minval(af+4) = minval(af+4); end maxval = maxval(:, valid); minval = minval(:, valid); fnames = xticklab(valid); xticklab = xticklab(valid); maxval = mean(maxval, 1); minval = mean(minval, 1); figure(f), hold off; plot([1 numel(fnames)], [avgval avgval], 'k--', 'linewidth', 2); hold on; errorbar(1:numel(fnames), avgval*ones(1, numel(fnames)), avgval-minval, ... maxval-avgval, 'r+', 'linewidth', 2); for x = 1:numel(fnames) if (error_type == 1) || (error_type == 2) || (error_type == 3) text(x+0.12, minval(x)+0.01, sprintf('%0.3f', minval(x)), ... 'fontsize', fs, 'fontweight', 'bold'); text(x+0.12, maxval(x)-0.02, sprintf('%0.3f', maxval(x)), ... 'fontsize', fs, 'fontweight', 'bold'); else text(x+0.12, minval(x), sprintf('%0.1f', minval(x)), 'fontsize', fs, 'fontweight', 'bold'); text(x+0.12, maxval(x), sprintf('%0.1f', maxval(x)), 'fontsize', fs, 'fontweight', 'bold'); end end text(0.1, avgval, sprintf('%0.3f', avgval), 'fontsize', fs, 'fontweight', 'bold'); if (error_type == 1) || (error_type == 2) || (error_type == 3) ymax = min(round((max(maxval)+0.15)*10)/10,1); else ymax = max(maxval) + 5; end axis([0 numel(fnames)+1 0 ymax]); ylabel(metric, 'fontsize', fs, 'fontweight', 'bold'); set(gca, 'xtick', 1:numel(fnames)); set(gca, 'xticklabel', xticklab); set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs, 'fontweight', 'bold'); set(gca, 'ticklength', [0.001 0.001]); title([resultfp.name ': Sensitivity and Impact']) end %% Gets the maximum value of a particular variable name for any field in the structure function maxy = getMaxVal(s, fname, maxy) if ~exist('maxy', 'var') || isempty(maxy) maxy = -Inf; end if numel(s)>1 for k = 1:numel(s) maxy = max(maxy, getMaxVal(s(k), fname, maxy)); end return; end names = fieldnames(s); for k = 1:numel(names) if ~isstruct(s.(names{k})) && ~strcmp(names{k}, fname) continue; end for j = 1:numel(s.(names{k})) if strcmp(names{k}, fname) maxy = max(maxy, s.(fname)(j)); else maxy = max(maxy, getMaxVal(s.(names{k})(j), fname, maxy)); end end end function miny = getMinVal(s, fname, miny) if ~exist('miny', 'var') || isempty(miny) miny = Inf; end if numel(s)>1 for k = 1:numel(s) miny = min(miny, getMinVal(s(k), fname, miny)); end return; end names = fieldnames(s); for k = 1:numel(names) if ~isstruct(s.(names{k})) && ~strcmp(names{k}, fname) continue; end for j = 1:numel(s.(names{k})) if strcmp(names{k}, fname) %if s.npos>=5 % special case miny = min(miny, s.(fname)(j)); %end else miny = min(miny, getMinVal(s.(names{k})(j), fname, miny)); end end end %% Removes vowels from a string function str = removeVowels(str) for v = 'aeiou' str(str==v) = []; end
github
gramuah/pose-errors-master
averagePoseDetectionPrecision.m
.m
pose-errors-master/src/averagePoseDetectionPrecision.m
11,758
utf_8
c860088de2a9ab843d34b5c7d4ea649d
function [result, resultclass] = averagePoseDetectionPrecision(det, gt, npos, diff_flag) % result = averagePoseDetectionPrecision(det, gt, npos, diff_flag) % % Computes full interpolated average precision % Normally, p = tp ./ (fp + tp) % % Input: % det(ndet, 1): detections % gt: ground truth annotations % npos: the number of ground truth positive examples % diff_flag: set true to consider the difficult objects (by default 0) % % Output: % result.(labels, conf, npos, r, p, ap, ap_std, MAE, MedErr, std_err, ... % aos, avp): % the precision-recall and aos, avp and peap precision-recall curves. % Pose estimation analysis: aos, avp, peap, MAE and MedErr % if nargin < 4 diff_flag = 0; end [sv, si] = sort(det.conf, 'descend'); label = det.label(si); label_pose = zeros(length(det.label),1); % label (-1, 1; 0=don't care) if diff_flag ind_tp=find(label==1 | label==0); else ind_tp=find(label==1); end % compute average precision in pose estimation tmp=zeros(1,length(label)); tmp_v=zeros(1,length(label)); tmp_v15=zeros(1,length(label)); tp_peap_15=zeros(1,length(label)); fp_peap_15=ones(1,length(label)); tp_peap_30=zeros(1,length(label)); fp_peap_30=ones(1,length(label)); viewcountvector = zeros(1,8); viewcountvector_opp = zeros(1,8); viewcountvector_near = zeros(1,8); viewcountvector_oth = zeros(1,8); gtviewcountvector = gt.gtviewvector; error_azimuth = zeros(1, length(ind_tp)); vnum_test = [4 8 16 24]; tmp_bins=zeros(length(label), size(vnum_test,2)); tp_peap_bins=zeros(length(label), size(vnum_test,2)); fp_peap_bins=ones(length(label), size(vnum_test,2)); resultclass.obj = zeros(1,length(label)); resultclass.err = zeros(1,length(label)); for h=1:length(ind_tp) if gt.viewpoint(det.gtnum(ind_tp(h))).azimuth ~= 0 gtview = gt.viewpoint(det.gtnum(ind_tp(h))).azimuth; else gtview = gt.viewpoint(det.gtnum(ind_tp(h))).azimuth_coarse; end error_azimuth(h) = min(mod(det.view(ind_tp(h),1)-gtview,360), ... mod(gtview-det.view(ind_tp(h),1),360)); resultclass.obj(h) = det.gtnum(ind_tp(h)); resultclass.err(h) = error_azimuth(h); tmp(ind_tp(h))=(1 + cos((error_azimuth(h)*pi)/180))/2; % AOS if error_azimuth(h) < 15 % pi/12 --> AVP_15 tmp_v15(ind_tp(h))=1; tp_peap_15(ind_tp(h))=1; fp_peap_15(ind_tp(h))=0; else tmp_v15(ind_tp(h))=0; fp_peap_15(ind_tp(h))=1; end if error_azimuth(h) < 30 % pi/6 --> AVP_30 tmp_v(ind_tp(h))=1; tp_peap_30(ind_tp(h))=1; fp_peap_30(ind_tp(h))=0; else tmp_v(ind_tp(h))=0; fp_peap_30(ind_tp(h))=1; end for av = 1:size(vnum_test,2) azimuth_interval = [0 (360/(vnum_test(av)*2)):(360/vnum_test(av)):360-(360/(vnum_test(av)*2))]; view_gt = find_interval(gtview, azimuth_interval); view_pr = find_interval(det.view(ind_tp(h),1), azimuth_interval); if view_pr == view_gt tmp_bins(ind_tp(h),av)=1; tp_peap_bins(ind_tp(h),av)=1; fp_peap_bins(ind_tp(h),av)=0; else tmp_bins(ind_tp(h),av)=0; fp_peap_bins(ind_tp(h),av)=1; end end %% error classification: % label 1 --> error < 15 (correct); % label 2 --> error > 165 (opposite); % label 3 --> 15 < error < 30 (nearby); % label 4 --> others flag = 0; if error_azimuth(h) <= 15 label_pose(ind_tp(h)) = 1; flag = 1; if gtview <= 25 || gtview > 340 viewcountvector(1) = viewcountvector(1) + 1; end if gtview <= 70 && gtview > 25 viewcountvector(2) = viewcountvector(2) + 1; end if gtview <= 115 && gtview > 70 viewcountvector(3) = viewcountvector(3) + 1; end if gtview <= 160 && gtview > 115 viewcountvector(4) = viewcountvector(4) + 1; end if gtview <= 205 && gtview > 160 viewcountvector(5) = viewcountvector(5) + 1; end if gtview <= 250 && gtview > 205 viewcountvector(6) = viewcountvector(6) + 1; end if gtview <= 295 && gtview > 250 viewcountvector(7) = viewcountvector(7) + 1; end if gtview <= 340 && gtview > 295 viewcountvector(8) = viewcountvector(8) + 1; end end if error_azimuth(h) > 165 label_pose(ind_tp(h)) = 2; flag = 1; if gtview <= 25 || gtview > 340 viewcountvector_opp(1) = viewcountvector_opp(1) + 1; end if gtview <= 70 && gtview > 25 viewcountvector_opp(2) = viewcountvector_opp(2) + 1; end if gtview <= 115 && gtview > 70 viewcountvector_opp(3) = viewcountvector_opp(3) + 1; end if gtview <= 160 && gtview > 115 viewcountvector_opp(4) = viewcountvector_opp(4) + 1; end if gtview <= 205 && gtview > 160 viewcountvector_opp(5) = viewcountvector_opp(5) + 1; end if gtview <= 250 && gtview > 205 viewcountvector_opp(6) = viewcountvector_opp(6) + 1; end if gtview <= 295 && gtview > 250 viewcountvector_opp(7) = viewcountvector_opp(7) + 1; end if gtview <= 340 && gtview > 295 viewcountvector_opp(8) = viewcountvector_opp(8) + 1; end end if error_azimuth(h) > 15 && error_azimuth(h) <= 30 label_pose(ind_tp(h)) = 3; flag = 1; if gtview <= 25 || gtview > 340 viewcountvector_near(1) = viewcountvector_near(1) + 1; end if gtview <= 70 && gtview > 25 viewcountvector_near(2) = viewcountvector_near(2) + 1; end if gtview <= 115 && gtview > 70 viewcountvector_near(3) = viewcountvector_near(3) + 1; end if gtview <= 160 && gtview > 115 viewcountvector_near(4) = viewcountvector_near(4) + 1; end if gtview <= 205 && gtview > 160 viewcountvector_near(5) = viewcountvector_near(5) + 1; end if gtview <= 250 && gtview > 205 viewcountvector_near(6) = viewcountvector_near(6) + 1; end if gtview <= 295 && gtview > 250 viewcountvector_near(7) = viewcountvector_near(7) + 1; end if gtview <= 340 && gtview > 295 viewcountvector_near(8) = viewcountvector_near(8) + 1; end end if flag == 0 label_pose(ind_tp(h)) = 4; if gtview <= 25 || gtview > 340 viewcountvector_oth(1) = viewcountvector_oth(1) + 1; end if gtview <= 70 && gtview > 25 viewcountvector_oth(2) = viewcountvector_oth(2) + 1; end if gtview <= 115 && gtview > 70 viewcountvector_oth(3) = viewcountvector_oth(3) + 1; end if gtview <= 160 && gtview > 115 viewcountvector_oth(4) = viewcountvector_oth(4) + 1; end if gtview <= 205 && gtview > 160 viewcountvector_oth(5) = viewcountvector_oth(5) + 1; end if gtview <= 250 && gtview > 205 viewcountvector_oth(6) = viewcountvector_oth(6) + 1; end if gtview <= 295 && gtview > 250 viewcountvector_oth(7) = viewcountvector_oth(7) + 1; end if gtview <= 340 && gtview > 295 viewcountvector_oth(8) = viewcountvector_oth(8) + 1; end end end if ~isempty(error_azimuth) mean_error = mean(error_azimuth); median_error = median(error_azimuth); std_error = std(error_azimuth); else mean_error = 0; median_error = 0; std_error = 0; end tp = cumsum(label==1); fp = cumsum(label==-1); conf = sv; acc=cumsum(tmp); accV=cumsum(tmp_v); accV_15 = cumsum(tmp_v15); tp_peap_15 = cumsum(tp_peap_15); fp_peap_15 = cumsum(fp_peap_15); tp_peap_30 = cumsum(tp_peap_30); fp_peap_30 = cumsum(fp_peap_30); for av=1:size(vnum_test,2) accV_bins = cumsum(tmp_bins(:,av)); tp_peap = cumsum(tp_peap_bins(:,av)); fp_peap = cumsum(fp_peap_bins(:,av)); r_peap(:,av) = tp_peap / npos; p_peap(:,av) = tp_peap./(fp_peap+tp_peap); p_avp_bins(:,av) = accV_bins ./(fp+tp); end r = tp / npos; p = tp ./ (tp + fp); r_peap15 = tp_peap_15 / npos; p_peap15 = tp_peap_15 ./ (tp_peap_15 + fp_peap_15); r_peap30 = tp_peap_30 / npos; p_peap30 = tp_peap_30 ./ (tp_peap_30 + fp_peap_30); p_aos = acc./(fp+tp)'; p_avp30=accV./(fp+tp)'; p_avp15=accV_15 ./(fp+tp)'; result = struct('labels', label, 'labels_pose', label_pose, 'hist_views', ... viewcountvector, 'hist_gt_views', gtviewcountvector, ... 'hist_opp_views', viewcountvector_opp, 'hist_near_views', viewcountvector_near, ... 'hist_oth_views', viewcountvector_oth,'conf', conf, 'r', r, 'p', p, ... 'p_aos', p_aos, 'p_avp30', p_avp30, ... 'p_avp15', p_avp15, 'p_peap15', p_peap15, 'r_peap15', r_peap15, ... 'p_peap30', p_peap30, 'r_peap30', r_peap30); result.npos = npos; result.mean_error = mean_error; result.median_error = median_error; result.std_error = std_error; for av=1:size(vnum_test,2) result.p_avp_bins(:,av) = p_avp_bins(:,av); result.p_peap_bins(:,av) = p_peap(:,av); result.r_peap_bins(:,av) = r_peap(:,av); end %% Error types result.opp_error= (length(find(error_azimuth>165))/length(error_azimuth))*100; result.nearby_error= (length(find(error_azimuth>15 & error_azimuth<30))/length(error_azimuth))*100; result.no_error= (length(find(error_azimuth<=15))/length(error_azimuth))*100; result.other_error= 100 - (result.opp_error+result.nearby_error+result.no_error); result.opp_error_count= length(find(error_azimuth>165)); result.nearby_error_count= length(find(error_azimuth>15 & error_azimuth<30)); result.no_error_count= length(find(error_azimuth<=15)); result.other_error_count= length(error_azimuth) - (result.opp_error_count+result.nearby_error_count+result.no_error_count); % compute interpolated precision and precision (AP) istp = (label==1); [result.ap, result.pi] = calcule_ap(r, p); missed = zeros(npos-sum(label==1),1); result.ap_stderr = std([p(istp(:)) ; missed])/sqrt(npos); %% compute interpolated precision and normalized precision for pose (AOS, AVP and PEAP) % AOS [result.aos, result.aos_pi] = calcule_ap(r, p_aos); result.aos_stderr = std([p_aos(istp(:))' ; missed])/sqrt(npos); % AVP [result.avp30, result.avp_pi30] = calcule_ap(r, p_avp30); result.avp_stderr30 = std([p_avp30(istp(:))' ; missed])/sqrt(npos); [result.avp15, result.avp_pi15] = calcule_ap(r, p_avp15); result.avp_stderr15 = std([p_avp15(istp(:))' ; missed])/sqrt(npos); % PEAP [result.peap30, result.peap_pi30] = calcule_ap(r_peap30', p_peap30); result.peap_stderr30 = std([p_peap30(istp(:))' ; missed])/sqrt(npos); [result.peap15, result.peap_pi15] = calcule_ap(r_peap15', p_peap15); result.peap_stderr15 = std([p_peap15(istp(:))' ; missed])/sqrt(npos); for av=1:size(vnum_test,2) [result.avp_bin(av), result.avp_pi_bin(:,av)] = calcule_ap(r, p_avp_bins(:,av)); [result.peap_bin(av), result.peap_pi_bin(:,av)] = calcule_ap(r_peap(:,av), p_peap(:,av)); result.avp_stderr_bin(av) = std([p_avp_bins(istp(:), av) ; missed])/sqrt(npos); end function ind = find_interval(azimuth, a) for i = 1:numel(a) if azimuth < a(i) break; end end ind = i - 1; if azimuth > a(end) ind = 1; end function [ap, mpre] = calcule_ap(rec, prec) mrec = [0; rec; 1]; if size(prec,1) >= size(prec,2) mpre = [0; prec; 0]; else mpre = [0; prec'; 0]; end for i = numel(mpre)-1:-1:1 mpre(i) = max(mpre(i), mpre(i+1)); end i = find(mrec(2:end) ~= mrec(1:end-1)) + 1; ap = sum((mrec(i) - mrec(i-1)) .* mpre(i));
github
gramuah/pose-errors-master
displayPerCharacteristicDetPlots.m
.m
pose-errors-master/src/displayPerCharacteristicDetPlots.m
15,123
utf_8
8b2b7edcad03a9fefdfea69282b0546b
function [resutclass,f] = displayPerCharacteristicDetPlots(results_all, error_type) %function [resutclass,f] = displayPerCharacteristicDetPlots(results_all, error_type) % % Object characteristic effect on detection: save and display plots % % Inputs: % results_all: detection results % error_type: metric to analysis close all drawline = true; makeMultiCategoryPlot(1, results_all, 'occ', ... [results_all(1).name ': Occluded Objects'], 1, {'N', 'O'}, drawline); makeMultiCategoryPlot(2, results_all, 'area', ... [results_all(1).name ': Object Size Influence'], 1, {'XS', 'S', 'M', 'L', 'XL'}, drawline); makeMultiCategoryPlot(3, results_all, 'aspect', ... [results_all(1).name ': Aspect Ratio Influence'], 1, {'XT', 'T', 'M', 'W', 'XW'}, drawline); makeMultiCategoryPlot(4, results_all, 'truncated', ... [results_all(1).name ': Truncated Objects'], 1, {'N', 'T'}, drawline); makeMultiCategoryPlot(5, results_all, 'trunc_occ', ... [results_all(1).name ': Trunc/Occ. Objects'], 1, {'N', 'T/O'}, drawline); makeMultiCategoryPlot(6, results_all, 'diff_nondiff', ... [results_all(1).name ': Difficult Objects'], 1, {'All', 'Only Diff'}, drawline); f=6; fs = 18; %% Visible parts f=f+1; tickstr = {}; np=0; for o = 1:numel(results_all) if isfield(results_all(o).pose, 'part') pnames = fieldnames(results_all(o).pose.part); for p = 1:numel(pnames) np=np+1; results_all(o).tmp((p-1)*2+(1:2)) = results_all(o).pose.part.(pnames{p}); end end end drawline = false; makeMultiCategoryPlot(f, results_all, 'tmp', ... [results_all(o).name ': Part Visibility Effect'], 1, tickstr, drawline); axisval = axis; n=0; for o = 1:numel(results_all) if isfield(results_all(o).pose, 'part') pnames = fieldnames(results_all(o).pose.part); n=n+1; for p = 1:numel(pnames) text(n+1, -0.071*axisval(4), sprintf('%d\n0/1', p), 'fontsize', fs); n = n+2; end end end if isfield(results_all, 'tmp') results_all = rmfield(results_all, 'tmp'); end %% Visible sides f=f+1; tickstr = {}; np=0; for o = 1:numel(results_all) if isfield(results_all(o).pose, 'side') pnames = fieldnames(results_all(o).pose.side); pnames = pnames(2:4); for p = 1:numel(pnames) np=np+1; results_all(o).tmp((p-1)*2+(1:2)) = results_all(o).pose.side.(pnames{p}); end end end drawline = false; makeMultiCategoryPlot(f, results_all, 'tmp', ... [results_all(o).name ': Visible Side Influence'], 1, tickstr, drawline); axisval = axis; n=0; for o = 1:numel(results_all) if isfield(results_all(o).pose, 'side') pnames = fieldnames(results_all(o).pose.side); pnames = pnames(2:4); n=n+1; for p = 1:numel(pnames) name = pnames{p}; if numel(name)>5, name = removeVowels(name); end; text(n+1, -0.071*axisval(4), sprintf('%s\n0/1', name), 'fontsize', fs); n = n+2; end end end if isfield(results_all, 'tmp') results_all = rmfield(results_all, 'tmp'); end %% Visible parts vs pose estimation f=f+1; tickstr = {}; np=0; for o = 1:numel(results_all) if isfield(results_all(o).pose, 'part') pnames = fieldnames(results_all(o).pose.part); for p = 1:numel(pnames) np=np+1; results_all(o).pose.tmp((p-1)*2+(1:2)) = results_all(o).pose.part.(pnames{p}); end end end drawline = false; makeMultiCategoryPlotPose(f, results_all.pose, 'tmp', ... [results_all(o).name ': Part Visibility Effect'], 1, tickstr, drawline, error_type); axisval = axis; n=0; for o = 1:numel(results_all) if isfield(results_all(o).pose, 'part') pnames = fieldnames(results_all(o).pose.part); n=n+1; for p = 1:numel(pnames) text(n+1, -0.071*axisval(4), sprintf('%d\n0/1', p), 'fontsize', fs); n = n+2; end end end if isfield(results_all, 'tmp') results_all = rmfield(results_all, 'tmp'); end %% Visible sides vs pose estimation f=f+1; tickstr = {}; np=0; for o = 1:numel(results_all) if isfield(results_all(o).pose, 'side') pnames = fieldnames(results_all(o).pose.side); pnames = pnames(2:4); for p = 1:numel(pnames) switch error_type case 1 resutclass.side_1(p) = results_all(o).pose.side.(pnames{p})(1).aos; if isnan(resutclass.side_1(p)) resutclass.side_1(p) = results_all(o).pose.aos; end resutclass.side_2(p) = results_all(o).pose.side.(pnames{p})(2).aos; if isnan(resutclass.side_2(p)) resutclass.side_2(p) = results_all(o).pose.aos; end case 2 resutclass.side_1(p) = results_all(o).pose.side.(pnames{p})(1).avp15; if isnan(resutclass.side_1(p)) resutclass.side_1(p) = results_all(o).pose.avp15; end resutclass.side_2(p) = results_all(o).pose.side.(pnames{p})(2).avp15; if isnan(resutclass.side_2(p)) resutclass.side_2(p) = results_all(o).pose.avp15; end case 3 resutclass.side_1(p) = results_all(o).pose.side.(pnames{p})(1).peap15; if isnan(resutclass.side_1(p)) resutclass.side_1(p) = results_all(o).pose.peap15; end resutclass.side_2(p) = results_all(o).pose.side.(pnames{p})(2).peap15; if isnan(resutclass.side_2(p)) resutclass.side_2(p) = results_all(o).pose.avp15; end case 4 resutclass.side_1(p) = results_all(o).pose.side.(pnames{p})(1).mean_error; if isnan(resutclass.side_1(p)) resutclass.side_1(p) = results_all(o).pose.mean_error; end resutclass.side_2(p) = results_all(o).pose.side.(pnames{p})(2).mean_error; if isnan(resutclass.side_2(p)) resutclass.side_2(p) = results_all(o).pose.mean_error; end case 5 resutclass.side_1(p) = results_all(o).pose.side.(pnames{p})(1).median_error; if isnan(resutclass.side_1(p)) resutclass.side_1(p) = results_all(o).pose.median_error; end resutclass.side_2(p) = results_all(o).pose.side.(pnames{p})(2).median_error; if isnan(resutclass.side_2(p)) resutclass.side_2(p) = results_all(o).pose.median_error; end end np=np+1; results_all(o).pose.tmp2((p-1)*2+(1:2)) = results_all(o).pose.side.(pnames{p}); end end end drawline = false; makeMultiCategoryPlotPose(f, results_all.pose, 'tmp2', ... [results_all(o).name ': Visible Side Influence'], 1, tickstr, drawline, error_type); axisval = axis; n=0; for o = 1:numel(results_all) if isfield(results_all(o).pose, 'side') pnames = fieldnames(results_all(o).pose.side); pnames = pnames(2:4); n=n+1; for p = 1:numel(pnames) name = pnames{p}; if numel(name)>5, name = removeVowels(name); end; text(n+1, -0.071*axisval(4), sprintf('%s\n0/1', name), 'fontsize', fs); n = n+2; end end end if isfield(results_all, 'tmp2') results_all = rmfield(results_all, 'tmp2'); end if isfield(results_all, 'tmp2') results_all = rmfield(results_all, 'tmp2'); end function makeMultiCategoryPlot(f, results, rname, title_str, xtickstep, xticklab, drawline) fs = 18; setupplot(f); if ~isfield(results(1), rname) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); plotapnbars(result.(rname), rangex, drawline); maxy = max(maxy, round(max(([result.(rname).ap]+0.15))*10)/10); h=plot(rangex([1 end]), [1 1]*result.pose.ap, 'k--', 'linewidth', 2); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end maxy = min(maxy, 1); if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 maxy]); for o = 1:numel(results) if strcmp(results(o).name, 'diningtable') results(o).name = 'diningtable'; elseif strcmp(results(o).name, 'aeroplane') results(o).name = 'aeroplane'; end end title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); ylabel('AP', 'fontsize', fs); set(gca, 'xticklabel', xticklab); set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type) fs = 18; setupplot(f); if ~isfield(results(1), rname) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); plotapnbarspose(result.(rname), rangex, drawline, error_type); switch error_type case 1 maxy = max(maxy, round(max(([result.(rname).aos]+0.15))*10)/10); h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); ylabel('AOS', 'fontsize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); case 2 maxy = max(maxy, round(max(([result.(rname).avp15]+0.15))*10)/10); h=plot(rangex([1 end]), [1 1]*result.avp15, 'k--', 'linewidth', 2); ylabel('AVP', 'fontsize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); case 3 maxy = max(maxy, round(max(([result.(rname).peap15]+0.15))*10)/10); h=plot(rangex([1 end]), [1 1]*result.peap15, 'k--', 'linewidth', 2); ylabel('PEAP', 'fontsize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); case 4 maxy = max(maxy, round(max(([result.(rname).mean_error]))) + 80); h=plot(rangex([1 end]), [1 1]*result.mean_error, 'k--', 'linewidth', 2); ylabel('MAE', 'fontsize', fs, 'FontWeight', 'bold'); case 5 maxy = max(maxy, round(max(([result.(rname).median_error]))) + 80); h=plot(rangex([1 end]), [1 1]*result.median_error, 'k--', 'linewidth', 2); ylabel('MedError', 'fontsize', fs, 'FontWeight', 'bold'); end firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 maxy]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbars(resall, x, drawline) fs = 18; for k = 1:numel(resall) res =resall(k); if isnan(res.ap), res.ap = 0; end if ~isnan(res.ap_stderr) errorbar(x(k), res.ap, res.ap_stderr, 'r', 'linewidth', 1); end hold on; plot(x(k), res.ap, '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); text(x(k)+0.12, res.ap, sprintf('%0.2f', res.ap), 'fontsize', fs, 'FontWeight', 'bold'); end if drawline plot(x, [resall.ap], 'b-', 'linewidth', 4); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).ap], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end function plotapnbarspose(resall, x, drawline, error_type) fs = 18; for k = 1:numel(resall) res =resall(k); switch error_type case 1 err_name = res.aos; err_name_std = res.aos_stderr; case 2 err_name = res.avp15; err_name_std = res.avp_stderr15; case 3 err_name = res.peap15; err_name_std = res.peap_stderr15; case 4 err_name = res.mean_error; err_name_std = res.std_error; case 5 err_name = res.median_error; err_name_std = res.std_error; end if isnan(err_name), err_name = 0; end if ~isnan(res.ap_stderr) errorbar(x(k), err_name, err_name_std, 'r', 'linewidth', 1); end hold on; plot(x(k), err_name, '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); if (error_type == 1) || (error_type == 2) || (error_type == 3) text(x(k)+0.12, err_name, sprintf('%0.2f', err_name), 'FontSize', fs, 'FontWeight', 'bold'); else text(x(k)+0.12, err_name, sprintf('%0.1f', err_name), 'FontSize', fs, 'FontWeight', 'bold'); end end switch error_type case 1 if drawline plot(x, [resall.aos], 'b-', 'linewidth', 4); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).aos], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 2 if drawline plot(x, [resall.avp15], 'b-', 'linewidth', 4); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).avp15], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 3 if drawline plot(x, [resall.peap15], 'b-', 'linewidth', 4); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).peap15], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 4 if drawline plot(x, [resall.mean_error], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).mean_error], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 5 if drawline plot(x, [resall.median_error], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).median_error], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end end function str = removeVowels(str) for v = 'aeiou' str(str==v) = []; end function setupplot(f) figure(f), hold off
github
gramuah/pose-errors-master
VOCevalseg.m
.m
pose-errors-master/src/VOCcode/VOCevalseg.m
3,330
utf_8
df4ea45a026fbf0caff5d9fb135af1a2
%VOCEVALSEG Evaluates a set of segmentation results. % VOCEVALSEG(VOCopts,ID); prints out the per class and overall % segmentation accuracies. Accuracies are given using the intersection/union % metric: % true positives / (true positives + false positives + false negatives) % % [ACCURACIES,AVACC,CONF] = VOCEVALSEG(VOCopts,ID) returns the per class % percentage ACCURACIES, the average accuracy AVACC and the confusion % matrix CONF. % % [ACCURACIES,AVACC,CONF,RAWCOUNTS] = VOCEVALSEG(VOCopts,ID) also returns % the unnormalised confusion matrix, which contains raw pixel counts. function [accuracies,avacc,conf,rawcounts] = VOCevalseg(VOCopts,id) % image test set [gtids,t]=textread(sprintf(VOCopts.seg.imgsetpath,VOCopts.testset),'%s %d'); % number of labels = number of classes plus one for the background num = VOCopts.nclasses+1; confcounts = zeros(num); count=0; tic; for i=1:length(gtids) % display progress if toc>1 fprintf('test confusion: %d/%d\n',i,length(gtids)); drawnow; tic; end imname = gtids{i}; % ground truth label file gtfile = sprintf(VOCopts.seg.clsimgpath,imname); [gtim,map] = imread(gtfile); gtim = double(gtim); % results file resfile = sprintf(VOCopts.seg.clsrespath,id,VOCopts.testset,imname); [resim,map] = imread(resfile); resim = double(resim); % Check validity of results image maxlabel = max(resim(:)); if (maxlabel>VOCopts.nclasses), error('Results image ''%s'' has out of range value %d (the value should be <= %d)',imname,maxlabel,VOCopts.nclasses); end szgtim = size(gtim); szresim = size(resim); if any(szgtim~=szresim) error('Results image ''%s'' is the wrong size, was %d x %d, should be %d x %d.',imname,szresim(1),szresim(2),szgtim(1),szgtim(2)); end %pixel locations to include in computation locs = gtim<255; % joint histogram sumim = 1+gtim+resim*num; hs = histc(sumim(locs),1:num*num); count = count + numel(find(locs)); confcounts(:) = confcounts(:) + hs(:); end % confusion matrix - first index is true label, second is inferred label %conf = zeros(num); conf = 100*confcounts./repmat(1E-20+sum(confcounts,2),[1 size(confcounts,2)]); rawcounts = confcounts; % Percentage correct labels measure is no longer being used. Uncomment if % you wish to see it anyway %overall_acc = 100*sum(diag(confcounts)) / sum(confcounts(:)); %fprintf('Percentage of pixels correctly labelled overall: %6.3f%%\n',overall_acc); accuracies = zeros(VOCopts.nclasses,1); fprintf('Accuracy for each class (intersection/union measure)\n'); for j=1:num gtj=sum(confcounts(j,:)); resj=sum(confcounts(:,j)); gtjresj=confcounts(j,j); % The accuracy is: true positive / (true positive + false positive + false negative) % which is equivalent to the following percentage: accuracies(j)=100*gtjresj/(gtj+resj-gtjresj); clname = 'background'; if (j>1), clname = VOCopts.classes{j-1};end; fprintf(' %14s: %6.3f%%\n',clname,accuracies(j)); end accuracies = accuracies(1:end); avacc = mean(accuracies); fprintf('-------------------------\n'); fprintf('Average accuracy: %6.3f%%\n',avacc);
github
gramuah/pose-errors-master
VOClabelcolormap.m
.m
pose-errors-master/src/VOCcode/VOClabelcolormap.m
691
utf_8
0bfcd3122e62038f83e2d64f456d556b
% VOCLABELCOLORMAP Creates a label color map such that adjacent indices have different % colors. Useful for reading and writing index images which contain large indices, % by encoding them as RGB images. % % CMAP = VOCLABELCOLORMAP(N) creates a label color map with N entries. function cmap = labelcolormap(N) if nargin==0 N=256 end cmap = zeros(N,3); for i=1:N id = i-1; r=0;g=0;b=0; for j=0:7 r = bitor(r, bitshift(bitget(id,1),7 - j)); g = bitor(g, bitshift(bitget(id,2),7 - j)); b = bitor(b, bitshift(bitget(id,3),7 - j)); id = bitshift(id,-3); end cmap(i,1)=r; cmap(i,2)=g; cmap(i,3)=b; end cmap = cmap / 255;
github
gramuah/pose-errors-master
VOCwritexml.m
.m
pose-errors-master/src/VOCcode/VOCwritexml.m
1,166
utf_8
5eee01a8259554f83bf00cf9cf2992a2
function VOCwritexml(rec, path) fid=fopen(path,'w'); writexml(fid,rec,0); fclose(fid); function xml = writexml(fid,rec,depth) fn=fieldnames(rec); for i=1:length(fn) f=rec.(fn{i}); if ~isempty(f) if isstruct(f) for j=1:length(f) fprintf(fid,'%s',repmat(char(9),1,depth)); fprintf(fid,'<%s>\n',fn{i}); writexml(fid,rec.(fn{i})(j),depth+1); fprintf(fid,'%s',repmat(char(9),1,depth)); fprintf(fid,'</%s>\n',fn{i}); end else if ~iscell(f) f={f}; end for j=1:length(f) fprintf(fid,'%s',repmat(char(9),1,depth)); fprintf(fid,'<%s>',fn{i}); if ischar(f{j}) fprintf(fid,'%s',f{j}); elseif isnumeric(f{j})&&numel(f{j})==1 fprintf(fid,'%s',num2str(f{j})); else error('unsupported type'); end fprintf(fid,'</%s>\n',fn{i}); end end end end
github
gramuah/pose-errors-master
VOCreadrecxml.m
.m
pose-errors-master/src/VOCcode/VOCreadrecxml.m
1,914
utf_8
174191a85122cb6b823846389450728e
function rec = VOCreadrecxml(path) x=VOCreadxml(path); x=x.annotation; rec=rmfield(x,'object'); rec.size.width=str2double(rec.size.width); rec.size.height=str2double(rec.size.height); rec.size.depth=str2double(rec.size.depth); rec.segmented=strcmp(rec.segmented,'1'); rec.imgname=[x.folder '/JPEGImages/' x.filename]; rec.imgsize=str2double({x.size.width x.size.height x.size.depth}); rec.database=rec.source.database; for i=1:length(x.object) rec.objects(i)=xmlobjtopas(x.object(i)); end function p = xmlobjtopas(o) p.class=o.name; if isfield(o,'pose') if strcmp(o.pose,'Unspecified') p.view=''; else p.view=o.pose; end else p.view=''; end if isfield(o,'truncated') p.truncated=strcmp(o.truncated,'1'); else p.truncated=false; end if isfield(o,'occluded') p.occluded=strcmp(o.occluded,'1'); else p.occluded=false; end if isfield(o,'difficult') p.difficult=strcmp(o.difficult,'1'); else p.difficult=false; end p.label=['PAS' p.class p.view]; if p.truncated p.label=[p.label 'Trunc']; end if p.occluded p.label=[p.label 'Occ']; end if p.difficult p.label=[p.label 'Diff']; end p.orglabel=p.label; p.bbox=str2double({o.bndbox.xmin o.bndbox.ymin o.bndbox.xmax o.bndbox.ymax}); p.bndbox.xmin=str2double(o.bndbox.xmin); p.bndbox.ymin=str2double(o.bndbox.ymin); p.bndbox.xmax=str2double(o.bndbox.xmax); p.bndbox.ymax=str2double(o.bndbox.ymax); if isfield(o,'polygon') warning('polygon unimplemented'); p.polygon=[]; else p.polygon=[]; end if isfield(o,'mask') warning('mask unimplemented'); p.mask=[]; else p.mask=[]; end if isfield(o,'part')&&~isempty(o.part) p.hasparts=true; for i=1:length(o.part) p.part(i)=xmlobjtopas(o.part(i)); end else p.hasparts=false; p.part=[]; end
github
gramuah/pose-errors-master
VOCxml2struct.m
.m
pose-errors-master/src/VOCcode/VOCxml2struct.m
1,920
utf_8
6a873dba4b24c57e9f86a15ee12ea366
function res = VOCxml2struct(xml) xml(xml==9|xml==10|xml==13)=[]; [res,xml]=parse(xml,1,[]); function [res,ind]=parse(xml,ind,parent) res=[]; if ~isempty(parent)&&xml(ind)~='<' i=findchar(xml,ind,'<'); res=trim(xml(ind:i-1)); ind=i; [tag,ind]=gettag(xml,i); if ~strcmp(tag,['/' parent]) error('<%s> closed with <%s>',parent,tag); end else while ind<=length(xml) [tag,ind]=gettag(xml,ind); if strcmp(tag,['/' parent]) return else [sub,ind]=parse(xml,ind,tag); if isstruct(sub) if isfield(res,tag) n=length(res.(tag)); fn=fieldnames(sub); for f=1:length(fn) res.(tag)(n+1).(fn{f})=sub.(fn{f}); end else res.(tag)=sub; end else if isfield(res,tag) if ~iscell(res.(tag)) res.(tag)={res.(tag)}; end res.(tag){end+1}=sub; else res.(tag)=sub; end end end end end function i = findchar(str,ind,chr) i=[]; while ind<=length(str) if str(ind)==chr i=ind; break else ind=ind+1; end end function [tag,ind]=gettag(xml,ind) if ind>length(xml) tag=[]; elseif xml(ind)=='<' i=findchar(xml,ind,'>'); if isempty(i) error('incomplete tag'); end tag=xml(ind+1:i-1); ind=i+1; else error('expected tag'); end function s = trim(s) for i=1:numel(s) if ~isspace(s(i)) s=s(i:end); break end end for i=numel(s):-1:1 if ~isspace(s(i)) s=s(1:i); break end end
github
gramuah/pose-errors-master
PASreadrectxt.m
.m
pose-errors-master/src/VOCcode/PASreadrectxt.m
3,179
utf_8
3b0bdbeb488c8292a1744dace066bb73
function record=PASreadrectxt(filename) [fd,syserrmsg]=fopen(filename,'rt'); if (fd==-1), PASmsg=sprintf('Could not open %s for reading',filename); PASerrmsg(PASmsg,syserrmsg); end; matchstrs=initstrings; record=PASemptyrecord; notEOF=1; while (notEOF), line=fgetl(fd); notEOF=ischar(line); if (notEOF), matchnum=match(line,matchstrs); switch matchnum, case 1, [imgname]=strread(line,matchstrs(matchnum).str); record.imgname=char(imgname); case 2, [x,y,c]=strread(line,matchstrs(matchnum).str); record.imgsize=[x y c]; case 3, [database]=strread(line,matchstrs(matchnum).str); record.database=char(database); case 4, [obj,lbl,xmin,ymin,xmax,ymax]=strread(line,matchstrs(matchnum).str); record.objects(obj).label=char(lbl); record.objects(obj).bbox=[min(xmin,xmax),min(ymin,ymax),max(xmin,xmax),max(ymin,ymax)]; case 5, tmp=findstr(line,' : '); [obj,lbl]=strread(line(1:tmp),matchstrs(matchnum).str); record.objects(obj).label=char(lbl); record.objects(obj).polygon=sscanf(line(tmp+3:end),'(%d, %d) ')'; case 6, [obj,lbl,mask]=strread(line,matchstrs(matchnum).str); record.objects(obj).label=char(lbl); record.objects(obj).mask=char(mask); case 7, [obj,lbl,orglbl]=strread(line,matchstrs(matchnum).str); lbl=char(lbl); record.objects(obj).label=lbl; record.objects(obj).orglabel=char(orglbl); if strcmp(lbl(max(end-8,1):end),'Difficult') record.objects(obj).difficult=true; lbl(end-8:end)=[]; else record.objects(obj).difficult=false; end if strcmp(lbl(max(end-4,1):end),'Trunc') record.objects(obj).truncated=true; lbl(end-4:end)=[]; else record.objects(obj).truncated=false; end t=find(lbl>='A'&lbl<='Z'); t=t(t>=4); if ~isempty(t) record.objects(obj).view=lbl(t(1):end); lbl(t(1):end)=[]; else record.objects(obj).view=''; end record.objects(obj).class=lbl(4:end); otherwise, %fprintf('Skipping: %s\n',line); end; end; end; fclose(fd); return function matchnum=match(line,matchstrs) for i=1:length(matchstrs), matched(i)=strncmp(line,matchstrs(i).str,matchstrs(i).matchlen); end; matchnum=find(matched); if isempty(matchnum), matchnum=0; end; if (length(matchnum)~=1), PASerrmsg('Multiple matches while parsing',''); end; return function s=initstrings s(1).matchlen=14; s(1).str='Image filename : %q'; s(2).matchlen=10; s(2).str='Image size (X x Y x C) : %d x %d x %d'; s(3).matchlen=8; s(3).str='Database : %q'; s(4).matchlen=8; s(4).str='Bounding box for object %d %q (Xmin, Ymin) - (Xmax, Ymax) : (%d, %d) - (%d, %d)'; s(5).matchlen=7; s(5).str='Polygon for object %d %q (X, Y)'; s(6).matchlen=5; s(6).str='Pixel mask for object %d %q : %q'; s(7).matchlen=8; s(7).str='Original label for object %d %q : %q'; return
github
gramuah/pose-errors-master
plotFigure10.m
.m
pose-errors-master/src/utils/plot_figures/plotFigure10.m
6,834
utf_8
029d97648c31c4be2ed6446dc55aebdc
function plotFigure10() %% plot Figure 10 from paper f=0; fs = 18; resultDir = '/home/carolina/projects/pose-estimation/eccv2016/eval_code/results'; detectors = { 'vdpm','vpskps', '3ddpm','bhf'}; objnames = {'aeroplane', 'bicycle', 'boat', 'bus', 'car', ... 'chair', 'diningtable', 'motorbike', 'sofa', 'train', 'tvmonitor'}; % Visible parts vs pose estimation for obj = 1: length(objnames) for d = 1:length(detectors) tmp(d) = load ([resultDir, '/', detectors{d}, '/', objnames{obj}, ... '/results_I_', objnames{obj} '_strong.mat']); end f=f+1; tickstr = {}; np=0; clear results_all; for o = 1:numel(tmp) if isfield(tmp(o).result.pose, 'part') pnames = fieldnames(tmp(o).result.pose.part); results_all(o).aos = tmp(o).result.pose.aos; results_all(o).avp = tmp(o).result.pose.avp15; results_all(o).mean = tmp(o).result.pose.mean_error; results_all(o).medError = tmp(o).result.pose.median_error; for p = 1:numel(pnames) np=np+1; results_all(o).tmp((p-1)*2+(1:2)) = tmp(o).result.pose.part.(pnames{p}); end end end N = length(detectors); drawline = false; xticks = makeMultiCategoryPlotPose(f, results_all, 'tmp', ... [objnames{obj} ': Visible Parts'], 1, tickstr, drawline, 1, N); axisval = axis; n=0; for o = 1:numel(results_all) if isfield(tmp(o).result.pose, 'part') pnames = fieldnames(tmp(o).result.pose.part); n=n+1; for p = 1:numel(pnames) name = pnames{p}; hold on; text(n+1, -0.051*axisval(4), sprintf('%d', p), 'fontsize', fs-2); n = n+2; end end end au = '0/1'; text(xticks(round(numel(pnames) / 2)+2), -0.12*axisval(4), sprintf('%s', au), 'fontsize', fs); text(xticks(round(numel(pnames) / 2) + 2 + (2*numel(pnames))), -0.12*axisval(4), sprintf('%s', au), 'fontsize', fs); text(xticks(round(numel(pnames) / 2) + 2 + (4*numel(pnames))), -0.12*axisval(4), sprintf('%s', au), 'fontsize', fs); text(xticks(round(numel(pnames) / 2) + 2 + (6*numel(pnames))), -0.12*axisval(4), sprintf('%s', au), 'fontsize', fs); text(xticks(round(numel(pnames) / 2)), 0.3, sprintf('%s', 'VDPM'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (2*numel(pnames))), 0.3, sprintf('%s', 'V&K'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (4*numel(pnames)))-1, 0.3, sprintf('%s', 'DPM+VOC-VP'), 'fontsize', fs, 'FontWeight', 'bold'); text(xticks(round(numel(pnames) / 2) + (6*numel(pnames))), 0.3, sprintf('%s', 'BHF'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); hold off; end Nfig = f; for f = 1:Nfig print('-dpdf', ['-f' num2str(f)], ... fullfile(resultDir, sprintf('plot_%d.pdf', f))); end close all; function xticks = makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type, N) fs = 18; setupplot(f); if ~isfield(results(1), rname)% || any(isnan([results(1).(rname).apn])) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; yticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); shift_y(o) = result.aos; plotapnbarspose(result.(rname), rangex, drawline, error_type, shift_y(o)); maxy = max(maxy, round(max(([result.aos]+0.15))*10)/10); my(o) = max(maxy, round(max(([result.aos]+0.15))*10)/10); h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); hold on; text(rangex(1)-6, result.aos, sprintf('%0.2f', result.aos), ... 'FontSize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 max(my) + 0.05]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); set(gca, 'ytick', 0:10); ylabel('AOS'); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'yticklabel', [], 'fontsize', fs) set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbarspose(resall, x, drawline, error_type, shift_y) fs = 18; for k = 1:numel(resall) res =resall(k); switch error_type case 1 err_name = res.aos; err_name_std = res.aos_stderr; case 2 err_name = res.avp; err_name_std = res.avp_stderr; case 3 err_name = res.mean_error; err_name_std = res.std_error; case 4 err_name = res.median_error; err_name_std = res.std_error; end if isnan(err_name), err_name = 0; end if ~isnan(res.apn_stderr) errorbar(x(k), err_name , err_name_std, 'r', 'linewidth', 1); end hold on; plot(x(k), err_name, '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end switch error_type case 1 if drawline plot(x, [resall.aos], 'b-', 'linewidth', 4); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).aos], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 2 if drawline plot(x, [resall.avp], 'b-', 'linewidth', 4); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).avp] + shift_y, 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 3 if drawline plot(x, [resall.mean_error], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).mean_error] + shift_y, 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 4 if drawline plot(x, [resall.median_error], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).median_error] + shift_y, 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end end function setupplot(f) figure(f), hold off
github
gramuah/pose-errors-master
plotFigure9c.m
.m
pose-errors-master/src/utils/plot_figures/plotFigure9c.m
4,647
utf_8
60ea095bf103f6922a56f6c8bb3956b2
function plotFigure9c() %% plot Figure 9(c) from paper f=0; fs = 18; resultDir = '/home/carolina/projects/pose-estimation/eccv2016/eval_code/results'; detectors = {'vdpm', 'vpskps','3ddpm', 'bhf'}; % Visible parts vs pose estimation for obj = 1: length(detectors) tmp(obj) = load ([resultDir, '/', detectors{obj}, '/results_total.mat']); end f=f+1; tickstr = {}; np=0; clear results_all; for o = 1:numel(tmp) pnames = {'ET', 'T', 'W', 'EW'}; results_all(o).aos = mean([tmp(o).resulttotal(:).aos]); results_all(o).avp = mean([tmp(o).resulttotal(:).avp]); maxval_a = zeros(1,length(tmp(o).resulttotal(1).extratall)); minval_a = zeros(1,length(tmp(o).resulttotal(1).tall)); maxval_a = zeros(1,length(tmp(o).resulttotal(1).wide)); minval_a = zeros(1,length(tmp(o).resulttotal(1).extrawide)); for mx = 1:length(tmp(o).resulttotal) maxval_a = maxval_a + tmp(o).resulttotal(mx).extratall; minval_a = minval_a + tmp(o).resulttotal(mx).tall; maxval_b = maxval_a + tmp(o).resulttotal(mx).wide; minval_b = minval_a + tmp(o).resulttotal(mx).extrawide; end maxval_a = maxval_a/length(tmp(o).resulttotal); minval_a = minval_a/length(tmp(o).resulttotal); maxval_b = maxval_b/length(tmp(o).resulttotal); minval_b = minval_b/length(tmp(o).resulttotal); maxval=[results_all(o).aos, results_all(o).aos, results_all(o).aos, results_all(o).aos]; minval=[maxval_a, minval_a,maxval_b, minval_b]; for p = 1:numel(pnames) results_all(o).tmp((p-1)*2+(1:2)) = [maxval(p), minval(p)]; end end N = length(detectors); drawline = false; xticks = makeMultiCategoryPlotPose(f, results_all, 'tmp', ... ['Aspect Ratio Influence'], 1, tickstr, drawline, 1, N); axisval = axis; n=0; for o = 1:numel(results_all) n=n+1; for p = 1:numel(pnames) name = pnames{p}; hold on; text(n+1, -0.071*axisval(4), sprintf('%s', name), 'fontsize', fs, 'fontweight', 'bold'); n = n+2; end end text(xticks(round(numel(pnames) / 2)) , 0.7, sprintf('%s', 'VDPM'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (2*numel(pnames))), 0.7, sprintf('%s', 'V&K'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (4*numel(pnames)))-2, 0.7, sprintf('%s', 'DPM+VOC-VP'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (6*numel(pnames)))+1.5, 0.7, sprintf('%s', 'BHF'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); hold off; Nfig = f; for f = 1:Nfig print('-dpdf', ['-f' num2str(f)], ... fullfile(resultDir, sprintf('plot_%d.pdf', f))); end hold off; close all; function xticks = makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type, N) fs = 18; setupplot(f); if ~isfield(results(1), rname) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; yticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); shift_y(o) = result.aos; plotapnbarspose(result.(rname), rangex, drawline, error_type, shift_y(o)); maxy = max(maxy, round(max(([result.aos]+0.15))*10)/10); my(o) = max(maxy, round(max(([result.aos]+0.15))*10)/10); hold on; h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); text(rangex(1)-2.5, result.aos, sprintf('%0.2f', result.aos), ... 'FontSize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 max(my) + 0.05]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); box on ylabel('AOS'); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'yticklabel', [], 'fontsize', fs) set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbarspose(resall, x) fs = 18; for k = 1:numel(resall) hold on; plot(x(k), resall(k), '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end for k = 2:2:numel(resall) text(x(k)-0.12, resall(k), sprintf('%0.2f', resall(k)), 'FontSize', fs, 'FontWeight', 'bold'); end for i=1:2:numel(x)-1 plot(x([i i+1]), [resall([i i+1])], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end function setupplot(f) figure(f), hold off
github
gramuah/pose-errors-master
plotFigure4a.m
.m
pose-errors-master/src/utils/plot_figures/plotFigure4a.m
4,099
utf_8
b50b1944f9dc8db0abb6e694983fce6f
function plotFigure4a() %% plot Figure 4(a) from paper f=0; fs = 18; resultDir = '/home/carolina/projects/pose-estimation/eccv2016/eval_code/results'; detectors = {'vdpm-gt','vpskps-gt', 'bhf-gt'}; % Visible parts vs pose estimation for obj = 1: length(detectors) tmp(obj) = load ([resultDir, '/', detectors{obj}, '/results_total.mat']); end f=f+1; tickstr = {}; np=0; clear results_all; for o = 1:numel(tmp) pnames = {'fr', 're', 'side'}; results_all(o).aos = mean([tmp(o).resulttotal(:).aos]); results_all(o).avp = mean([tmp(o).resulttotal(:).avp]); maxval_a = zeros(1,length(tmp(o).resulttotal(1).side_1)); minval_a = zeros(1,length(tmp(o).resulttotal(1).side_2)); for mx = 1:length(tmp(o).resulttotal) maxval_a = maxval_a + tmp(o).resulttotal(mx).side_1; minval_a = minval_a + tmp(o).resulttotal(mx).side_2; end maxval = maxval_a/length(tmp(o).resulttotal); minval = minval_a/length(tmp(o).resulttotal); for p = 1:numel(pnames) results_all(o).tmp((p-1)*2+(1:2)) = [maxval(p), minval(p)]; end end N = length(detectors); drawline = false; xticks = makeMultiCategoryPlotPose(f, results_all, 'tmp', ... ['Visible Side Characteristic Overview'], 1, tickstr, drawline, 1, N); axisval = axis; n=0; for o = 1:numel(results_all) n=n+1; for p = 1:numel(pnames) name = pnames{p}; hold on; text(n+0.5, -0.071*axisval(4), sprintf('%s\n 0/1', name), 'fontsize', fs, 'fontweight', 'bold'); n = n+2; end end text(xticks(round(numel(pnames) / 2)) , 0.2, sprintf('%s', 'VDPM'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (2*numel(pnames)))+1, 0.2, sprintf('%s', 'V&K'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (4*numel(pnames)))+1, 0.2, sprintf('%s', 'BHF'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); hold off; Nfig = f; for f = 1:Nfig print('-dpdf', ['-f' num2str(f)], ... fullfile(resultDir, sprintf('plot_%d.pdf', f))); end hold off; close all; function xticks = makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type, N) fs = 18; setupplot(f); if ~isfield(results(1), rname)% || any(isnan([results(1).(rname).apn])) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; yticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); shift_y(o) = result.aos; plotapnbarspose(result.(rname), rangex, drawline, error_type, shift_y(o)); maxy = max(maxy, round(max(([result.aos]+0.15))*10)/10); my(o) = max(maxy, round(max(([result.aos]+0.15))*10)/10); hold on; h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); text(rangex(1)-2.5, result.aos, sprintf('%0.2f', result.aos), ... 'FontSize', fs, 'FontWeight', 'bold'); %ylabel('AOS', 'fontsize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 max(my) + 0.05]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); %set(gca, 'ytick', 0:10); box on ylabel('AOS'); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'yticklabel', [], 'fontsize', fs) set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbarspose(resall, x) fs = 18; for k = 1:numel(resall) hold on; plot(x(k), resall(k), '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); text(x(k)+0.12, resall(k), sprintf('%0.2f', resall(k)), 'FontSize', fs, 'FontWeight', 'bold'); end for i=1:2:numel(x)-1 plot(x([i i+1]), [resall([i i+1])], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end function setupplot(f) figure(f), hold off
github
gramuah/pose-errors-master
plotFigure9b.m
.m
pose-errors-master/src/utils/plot_figures/plotFigure9b.m
4,716
utf_8
83ef7d0ecc26b31b2a73badb85ef0142
function plotFigure9b() %% plot Figure 9(b) from paper f=0; fs = 18; resultDir = '/home/carolina/projects/pose-estimation/eccv2016/eval_code/results'; detectors = {'vdpm','vpskps', '3ddpm', 'bhf'}; % Visible parts vs pose estimation for obj = 1: length(detectors) tmp(obj) = load ([resultDir, '/', detectors{obj}, '/results_total.mat']); end f=f+1; tickstr = {}; np=0; clear results_all; for o = 1:numel(tmp) pnames = {'ES', 'S', 'L', 'EL'}; results_all(o).aos = mean([tmp(o).resulttotal(:).aos]); results_all(o).avp = mean([tmp(o).resulttotal(:).avp]); maxval_a = zeros(1,length(tmp(o).resulttotal(1).extrasmall)); minval_a = zeros(1,length(tmp(o).resulttotal(1).small)); maxval_a = zeros(1,length(tmp(o).resulttotal(1).large)); minval_a = zeros(1,length(tmp(o).resulttotal(1).extralarge)); for mx = 1:length(tmp(o).resulttotal) maxval_a = maxval_a + tmp(o).resulttotal(mx).extrasmall; minval_a = minval_a + tmp(o).resulttotal(mx).small; maxval_b = maxval_a + tmp(o).resulttotal(mx).large; minval_b = minval_a + tmp(o).resulttotal(mx).extralarge; end maxval_a = maxval_a/length(tmp(o).resulttotal); minval_a = minval_a/length(tmp(o).resulttotal); maxval_b = maxval_b/length(tmp(o).resulttotal); minval_b = minval_b/length(tmp(o).resulttotal); maxval=[results_all(o).aos, results_all(o).aos, results_all(o).aos, results_all(o).aos]; minval=[maxval_a, minval_a,maxval_b, minval_b]; for p = 1:numel(pnames) results_all(o).tmp((p-1)*2+(1:2)) = [maxval(p), minval(p)]; end end N = length(detectors); drawline = false; xticks = makeMultiCategoryPlotPose(f, results_all, 'tmp', ... ['Object Size Influence'], 1, tickstr, drawline, 1, N); axisval = axis; n=0; for o = 1:numel(results_all) n=n+1; for p = 1:numel(pnames) name = pnames{p}; hold on; text(n+1, -0.071*axisval(4), sprintf('%s', name), 'fontsize', fs, 'fontweight', 'bold'); n = n+2; end end text(xticks(round(numel(pnames) / 2)) , 0.7, sprintf('%s', 'VDPM'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (2*numel(pnames))), 0.7, sprintf('%s', 'V&K'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (4*numel(pnames)))-2, 0.7, sprintf('%s', 'DPM+VOC-VP'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (6*numel(pnames)))+1.5, 0.7, sprintf('%s', 'BHF'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); hold off; Nfig = f; for f = 1:Nfig print('-dpdf', ['-f' num2str(f)], ... fullfile(resultDir, sprintf('plot_%d.pdf', f))); end hold off; close all; function xticks = makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type, N) fs = 18; setupplot(f); if ~isfield(results(1), rname) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; yticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); shift_y(o) = result.aos; plotapnbarspose(result.(rname), rangex, drawline, error_type, shift_y(o)); maxy = max(maxy, round(max(([result.aos]+0.15))*10)/10); my(o) = max(maxy, round(max(([result.aos]+0.15))*10)/10); hold on; h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); text(rangex(1)-2.5, result.aos, sprintf('%0.2f', result.aos), ... 'FontSize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 max(my) + 0.05]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); %set(gca, 'ytick', 0:10); box on ylabel('AOS'); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'yticklabel', [], 'fontsize', fs) set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbarspose(resall, x, drawline, error_type, shift_y) fs = 18; for k = 1:numel(resall) hold on; plot(x(k), resall(k), '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end for k = 2:2:numel(resall) text(x(k)-0.12, resall(k), sprintf('%0.2f', resall(k)), 'FontSize', fs, 'FontWeight', 'bold'); end for i=1:2:numel(x)-1 plot(x([i i+1]), [resall([i i+1])], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end function setupplot(f) figure(f), hold off
github
gramuah/pose-errors-master
plotFigure5.m
.m
pose-errors-master/src/utils/plot_figures/plotFigure5.m
6,499
utf_8
ed30bc380ffcbf3d1de53920c67a86f5
function plotFigure5() %% plot Figure 5 from paper f=0; fs = 18; resultDir = '/home/carolina/projects/pose-estimation/eccv2016/eval_code/results'; detectors = { 'vdpm-gt','vpskps-gt','bhf-gt'}; objnames = {'aeroplane', 'bicycle', 'boat', 'bus', 'car', ... 'chair', 'diningtable', 'motorbike', 'sofa', 'train', 'tvmonitor'}; % Visible parts vs pose estimation for obj = 1: length(objnames) for d = 1:length(detectors) tmp(d) = load ([resultDir, '/', detectors{d}, '/', objnames{obj}, ... '/results_I_', objnames{obj} '_strong.mat']); end f=f+1; tickstr = {}; np=0; clear results_all; for o = 1:numel(tmp) if isfield(tmp(o).result.pose, 'part') pnames = fieldnames(tmp(o).result.pose.part); results_all(o).aos = tmp(o).result.pose.aos; results_all(o).avp = tmp(o).result.pose.avp15; results_all(o).mean = tmp(o).result.pose.mean_error; results_all(o).medError = tmp(o).result.pose.median_error; for p = 1:numel(pnames) np=np+1; results_all(o).tmp((p-1)*2+(1:2)) = tmp(o).result.pose.part.(pnames{p}); end end end N = length(detectors); drawline = false; xticks = makeMultiCategoryPlotPose(f, results_all, 'tmp', ... [objnames{obj} ': Visible Parts'], 1, tickstr, drawline, 1, N); axisval = axis; n=0; for o = 1:numel(results_all) if isfield(tmp(o).result.pose, 'part') pnames = fieldnames(tmp(o).result.pose.part); n=n+1; for p = 1:numel(pnames) name = pnames{p}; hold on; text(n+1, -0.051*axisval(4), sprintf('%d', p), 'fontsize', fs-2); n = n+2; end end end au = '0/1'; text(xticks(round(numel(pnames) / 2)+2), -0.12*axisval(4), sprintf('%s', au), 'fontsize', fs); text(xticks(round(numel(pnames) / 2) + 2 + (2*numel(pnames))), -0.12*axisval(4), sprintf('%s', au), 'fontsize', fs); text(xticks(round(numel(pnames) / 2) + 2 + (4*numel(pnames))), -0.12*axisval(4), sprintf('%s', au), 'fontsize', fs); text(xticks(round(numel(pnames) / 2)), 0.3, sprintf('%s', 'VDPM'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (2*numel(pnames))), 0.3, sprintf('%s', 'V&K'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (4*numel(pnames))), 0.3, sprintf('%s', 'BHF'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); hold off; end Nfig = f; for f = 1:Nfig print('-dpdf', ['-f' num2str(f)], ... fullfile(resultDir, sprintf('plot_%d.pdf', f))); end close all; function xticks = makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type, N) fs = 18; setupplot(f); if ~isfield(results(1), rname)% || any(isnan([results(1).(rname).apn])) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; yticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); shift_y(o) = result.aos; plotapnbarspose(result.(rname), rangex, drawline, error_type, shift_y(o)); maxy = max(maxy, round(max(([result.aos]+0.15))*10)/10); my(o) = max(maxy, round(max(([result.aos]+0.15))*10)/10); h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); hold on; text(rangex(1)-6, result.aos, sprintf('%0.2f', result.aos), ... 'FontSize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 max(my) + 0.05]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); set(gca, 'ytick', 0:10); ylabel('AOS'); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'yticklabel', [], 'fontsize', fs) set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbarspose(resall, x, drawline, error_type, shift_y) fs = 18; for k = 1:numel(resall) res =resall(k); switch error_type case 1 err_name = res.aos; err_name_std = res.aos_stderr; case 2 err_name = res.avp; err_name_std = res.avp_stderr; case 3 err_name = res.mean_error; err_name_std = res.std_error; case 4 err_name = res.median_error; err_name_std = res.std_error; end if isnan(err_name), err_name = 0; end if ~isnan(res.apn_stderr) errorbar(x(k), err_name , err_name_std, 'r', 'linewidth', 1); end hold on; plot(x(k), err_name, '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end switch error_type case 1 if drawline plot(x, [resall.aos], 'b-', 'linewidth', 4); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).aos], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 2 if drawline plot(x, [resall.avp], 'b-', 'linewidth', 4); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).avp] + shift_y, 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 3 if drawline plot(x, [resall.mean_error], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).mean_error] + shift_y, 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end case 4 if drawline plot(x, [resall.median_error], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); else % draw every other for i=1:2:numel(x) plot(x([i i+1]), [resall([i i+1]).median_error] + shift_y, 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end end end function setupplot(f) figure(f), hold off
github
gramuah/pose-errors-master
plotFigure4c.m
.m
pose-errors-master/src/utils/plot_figures/plotFigure4c.m
4,593
utf_8
078fde124eb8a63a7dcbe0a1577947bf
function plotFigure4c() %% plot Figure 4(c) from paper f=0; fs = 18; resultDir = '/home/carolina/projects/pose-estimation/eccv2016/eval_code/results'; detectors = {'vdpm-gt', 'vpskps-gt', 'bhf-gt'}; % Visible parts vs pose estimation for obj = 1: length(detectors) tmp(obj) = load ([resultDir, '/', detectors{obj}, '/results_total.mat']); end f=f+1; tickstr = {}; np=0; clear results_all; for o = 1:numel(tmp) pnames = {'ET', 'T', 'W', 'EW'}; results_all(o).aos = mean([tmp(o).resulttotal(:).aos]); results_all(o).avp = mean([tmp(o).resulttotal(:).avp]); maxval_a = zeros(1,length(tmp(o).resulttotal(1).extratall)); minval_a = zeros(1,length(tmp(o).resulttotal(1).tall)); maxval_a = zeros(1,length(tmp(o).resulttotal(1).wide)); minval_a = zeros(1,length(tmp(o).resulttotal(1).extrawide)); for mx = 1:length(tmp(o).resulttotal) maxval_a = maxval_a + tmp(o).resulttotal(mx).extratall; minval_a = minval_a + tmp(o).resulttotal(mx).tall; maxval_b = maxval_a + tmp(o).resulttotal(mx).wide; minval_b = minval_a + tmp(o).resulttotal(mx).extrawide; end maxval_a = maxval_a/length(tmp(o).resulttotal); minval_a = minval_a/length(tmp(o).resulttotal); maxval_b = maxval_b/length(tmp(o).resulttotal); minval_b = minval_b/length(tmp(o).resulttotal); maxval=[results_all(o).aos, results_all(o).aos, results_all(o).aos, results_all(o).aos]; minval=[maxval_a, minval_a,maxval_b, minval_b]; for p = 1:numel(pnames) results_all(o).tmp((p-1)*2+(1:2)) = [maxval(p), minval(p)]; end end N = length(detectors); drawline = false; xticks = makeMultiCategoryPlotPose(f, results_all, 'tmp', ... ['Aspect Ratio Influence'], 1, tickstr, drawline, 1, N); axisval = axis; n=0; for o = 1:numel(results_all) n=n+1; for p = 1:numel(pnames) name = pnames{p}; hold on; text(n+1, -0.071*axisval(4), sprintf('%s', name), 'fontsize', fs, 'fontweight', 'bold'); n = n+2; end end text(xticks(round(numel(pnames) / 2)) , 0.2, sprintf('%s', 'VDPM'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (2*numel(pnames)))+1, 0.2, sprintf('%s', 'V&K'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (4*numel(pnames)))+2, 0.2, sprintf('%s', 'BHF'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); hold off; Nfig = f; for f = 1:Nfig print('-dpdf', ['-f' num2str(f)], ... fullfile(resultDir, sprintf('plot_%d.pdf', f))); end hold off; close all; function xticks = makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type, N) fs = 18; setupplot(f); if ~isfield(results(1), rname)% || any(isnan([results(1).(rname).apn])) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; yticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); shift_y(o) = result.aos; plotapnbarspose(result.(rname), rangex, drawline, error_type, shift_y(o)); maxy = max(maxy, round(max(([result.aos]+0.15))*10)/10); my(o) = max(maxy, round(max(([result.aos]+0.15))*10)/10); hold on; h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); text(rangex(1)-2.5, result.aos, sprintf('%0.2f', result.aos), ... 'FontSize', fs, 'FontWeight', 'bold'); %ylabel('AOS', 'fontsize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 max(my) + 0.05]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); box on ylabel('AOS'); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'yticklabel', [], 'fontsize', fs) set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbarspose(resall, x) fs = 18; for k = 1:numel(resall) hold on; plot(x(k), resall(k), '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end for k = 2:2:numel(resall) text(x(k)-0.12, resall(k), sprintf('%0.2f', resall(k)), 'FontSize', fs, 'FontWeight', 'bold'); end for i=1:2:numel(x)-1 plot(x([i i+1]), [resall([i i+1])], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end function setupplot(f) figure(f), hold off
github
gramuah/pose-errors-master
plotFigure4b.m
.m
pose-errors-master/src/utils/plot_figures/plotFigure4b.m
4,566
utf_8
d189abcb9012e29ad8400c07fe4a1493
function plotFigure4b() %% plot Figure 4(b) from paper f=0; fs = 18; resultDir = '/home/carolina/projects/pose-estimation/eccv2016/eval_code/results'; detectors = {'vdpm-gt','vpskps-gt', 'bhf-gt'}; % Visible parts vs pose estimation for obj = 1: length(detectors) tmp(obj) = load ([resultDir, '/', detectors{obj}, '/results_total.mat']); end f=f+1; tickstr = {}; np=0; clear results_all; for o = 1:numel(tmp) pnames = {'ES', 'S', 'L', 'EL'}; results_all(o).aos = mean([tmp(o).resulttotal(:).aos]); results_all(o).avp = mean([tmp(o).resulttotal(:).avp]); maxval_a = zeros(1,length(tmp(o).resulttotal(1).extrasmall)); minval_a = zeros(1,length(tmp(o).resulttotal(1).small)); maxval_a = zeros(1,length(tmp(o).resulttotal(1).large)); minval_a = zeros(1,length(tmp(o).resulttotal(1).extralarge)); for mx = 1:length(tmp(o).resulttotal) maxval_a = maxval_a + tmp(o).resulttotal(mx).extrasmall; minval_a = minval_a + tmp(o).resulttotal(mx).small; maxval_b = maxval_a + tmp(o).resulttotal(mx).large; minval_b = minval_a + tmp(o).resulttotal(mx).extralarge; end maxval_a = maxval_a/length(tmp(o).resulttotal); minval_a = minval_a/length(tmp(o).resulttotal); maxval_b = maxval_b/length(tmp(o).resulttotal); minval_b = minval_b/length(tmp(o).resulttotal); maxval=[results_all(o).aos, results_all(o).aos, results_all(o).aos, results_all(o).aos]; minval=[maxval_a, minval_a,maxval_b, minval_b]; for p = 1:numel(pnames) results_all(o).tmp((p-1)*2+(1:2)) = [maxval(p), minval(p)]; end end N = length(detectors); drawline = false; xticks = makeMultiCategoryPlotPose(f, results_all, 'tmp', ... ['Object Size Influence'], 1, tickstr, drawline, 1, N); axisval = axis; n=0; for o = 1:numel(results_all) n=n+1; for p = 1:numel(pnames) name = pnames{p}; hold on; text(n+1, -0.071*axisval(4), sprintf('%s', name), 'fontsize', fs, 'fontweight', 'bold'); n = n+2; end end text(xticks(round(numel(pnames) / 2)) , 0.2, sprintf('%s', 'VDPM'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (2*numel(pnames)))+1, 0.2, sprintf('%s', 'V&K'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (4*numel(pnames)))+1, 0.2, sprintf('%s', 'BHF'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); hold off; Nfig = f; for f = 1:Nfig print('-dpdf', ['-f' num2str(f)], ... fullfile(resultDir, sprintf('plot_%d.pdf', f))); end hold off; close all; function xticks = makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type, N) fs = 18; setupplot(f); if ~isfield(results(1), rname) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; yticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); shift_y(o) = result.aos; plotapnbarspose(result.(rname), rangex, drawline, error_type, shift_y(o)); maxy = max(maxy, round(max(([result.aos]+0.15))*10)/10); my(o) = max(maxy, round(max(([result.aos]+0.15))*10)/10); hold on; h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); text(rangex(1)-2.5, result.aos, sprintf('%0.2f', result.aos), ... 'FontSize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 max(my) + 0.05]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); %set(gca, 'ytick', 0:10); box on ylabel('AOS'); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'yticklabel', [], 'fontsize', fs) set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbarspose(resall, x, drawline, error_type, shift_y) fs = 18; for k = 1:numel(resall) hold on; plot(x(k), resall(k), '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end for k = 2:2:numel(resall) text(x(k)-0.12, resall(k), sprintf('%0.2f', resall(k)), 'FontSize', fs, 'FontWeight', 'bold'); end for i=1:2:numel(x)-1 plot(x([i i+1]), [resall([i i+1])], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end function setupplot(f) figure(f), hold off
github
gramuah/pose-errors-master
plotFigure9a.m
.m
pose-errors-master/src/utils/plot_figures/plotFigure9a.m
4,149
utf_8
c29f1498294dfcc7870ca22632824264
function plotFigure9a() %% plot Figure 9(a) from paper f=0; fs = 18; resultDir = '/home/carolina/projects/pose-estimation/eccv2016/eval_code/results'; detectors = {'vdpm','vpskps','3ddpm', 'bhf'}; % Visible parts vs pose estimation for obj = 1: length(detectors) tmp(obj) = load ([resultDir, '/', detectors{obj}, '/results_total.mat']); end f=f+1; tickstr = {}; np=0; clear results_all; for o = 1:numel(tmp) pnames = {'fr', 're', 'side'}; results_all(o).aos = mean([tmp(o).resulttotal(:).aos]); results_all(o).avp = mean([tmp(o).resulttotal(:).avp]); maxval_a = zeros(1,length(tmp(o).resulttotal(1).side_1)); minval_a = zeros(1,length(tmp(o).resulttotal(1).side_2)); for mx = 1:length(tmp(o).resulttotal) maxval_a = maxval_a + tmp(o).resulttotal(mx).side_1; minval_a = minval_a + tmp(o).resulttotal(mx).side_2; end maxval = maxval_a/length(tmp(o).resulttotal); minval = minval_a/length(tmp(o).resulttotal); for p = 1:numel(pnames) results_all(o).tmp((p-1)*2+(1:2)) = [maxval(p), minval(p)]; end end N = length(detectors); drawline = false; xticks = makeMultiCategoryPlotPose(f, results_all, 'tmp', ... ['Visible Side Characteristic Overview'], 1, tickstr, drawline, 1, N); axisval = axis; n=0; for o = 1:numel(results_all) n=n+1; for p = 1:numel(pnames) name = pnames{p}; hold on; text(n+0.5, -0.071*axisval(4), sprintf('%s\n 0/1', name), 'fontsize', fs, 'fontweight', 'bold'); n = n+2; end end text(xticks(round(numel(pnames) / 2)) , 0.7, sprintf('%s', 'VDPM'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (2*numel(pnames))), 0.7, sprintf('%s', 'V&K'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (4*numel(pnames)))-2, 0.7, sprintf('%s', 'DPM+VOC-VP'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); text(xticks(round(numel(pnames) / 2) + (6*numel(pnames)))+1.5, 0.7, sprintf('%s', 'BHF'), 'fontsize', fs, 'FontWeight', 'bold', 'Color', 'red'); hold off; Nfig = f; for f = 1:Nfig print('-dpdf', ['-f' num2str(f)], ... fullfile(resultDir, sprintf('plot_%d.pdf', f))); end hold off; close all; function xticks = makeMultiCategoryPlotPose(f, results, ... rname, title_str, xtickstep, xticklab, drawline, error_type, N) fs = 18; setupplot(f); if ~isfield(results(1), rname) return; end nobj = numel(results); rangex = 0; maxy = 0; xticks = []; yticks = []; firsttick = zeros(nobj,1); for o = 1:nobj result = results(o); nres = numel(results(o).(rname)); rangex = rangex(end)+1+(1:nres); shift_y(o) = result.aos; plotapnbarspose(result.(rname), rangex, drawline, error_type, shift_y(o)); maxy = max(maxy, round(max(([result.aos]+0.15))*10)/10); my(o) = max(maxy, round(max(([result.aos]+0.15))*10)/10); hold on; h=plot(rangex([1 end]), [1 1]*result.aos, 'k--', 'linewidth', 2); text(rangex(1)-2.5, result.aos, sprintf('%0.2f', result.aos), ... 'FontSize', fs, 'FontWeight', 'bold'); maxy = min(maxy, 1); firsttick(o) = rangex(1); xticks = [xticks rangex(1:xtickstep:end)]; end if numel(xticklab)==nres xticklab = repmat(xticklab, [1 nobj]); end axis([0 rangex(end)+1 0 max(my) + 0.05]); title(title_str, 'fontsize', fs); set(gca, 'xtick', xticks); %set(gca, 'ytick', 0:10); box on ylabel('AOS'); set(gca, 'xticklabel', xticklab, 'fontsize', fs); set(gca, 'yticklabel', [], 'fontsize', fs) set(gca, 'ygrid', 'on') set(gca, 'xgrid', 'on') set(gca, 'fontsize', fs); set(gca, 'ticklength', [0.001 0.001]); function plotapnbarspose(resall, x) fs = 18; for k = 1:numel(resall) hold on; plot(x(k), resall(k), '+', 'linewidth', 4, 'markersize', 2); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); text(x(k)+0.12, resall(k), sprintf('%0.2f', resall(k)), 'FontSize', fs, 'FontWeight', 'bold'); end for i=1:2:numel(x)-1 plot(x([i i+1]), [resall([i i+1])], 'b-', 'linewidth', 4); set(gca, 'fontsize', fs, 'FontWeight', 'bold'); end function setupplot(f) figure(f), hold off
github
kstrotz/URToolbox-master
installURToolbox.m
.m
URToolbox-master/installURToolbox.m
10,069
utf_8
7fad6ecb89fa082153fe4d8db039c4b5
function installURToolbox(replaceExisting) % INSTALLURTOOLBOX installs UR Toolbox for MATLAB. % INSTALLURTOOLBOX installs UR Toolbox into the following % locations: % Source: Destination % URToolboxFunctions: matlabroot\toolbox\optitrack % URToolboxSupport: matlabroot\toolbox\optitrack\OptiTrackToolboxSupport % % INSTALLURTOOLBOX(true) installs UR Toolbox regardless of % whether a copy of the UR toolbox exists in the MATLAB root. % % INSTALLURTOOLBOX(false) installs UR Toolbox only if no copy % of the UR toolbox exists in the MATLAB root. % % M. Kutzer 17Feb2016, USNA % Updates % TODO - Allow users to create a local version if admin rights are not % possible. %% Install/Update required toolboxes ToolboxUpdate('Transformation'); ToolboxUpdate('Plotting'); %% Assign tool/toolbox specific parameters dirName = 'ur'; %% Check inputs if nargin == 0 replaceExisting = []; end %% Installation error solution(s) adminSolution = sprintf(... ['Possible solution:\n',... '\t(1) Close current instance of MATLAB\n',... '\t(2) Open a new instance of MATLAB "as administrator"\n',... '\t\t(a) Locate MATLAB shortcut\n',... '\t\t(b) Right click\n',... '\t\t(c) Select "Run as administrator"\n']); %% Check for toolbox directory toolboxRoot = fullfile(matlabroot,'toolbox',dirName); isToolbox = exist(toolboxRoot,'file'); if isToolbox == 7 % Apply replaceExisting argument if isempty(replaceExisting) choice = questdlg(sprintf(... ['MATLAB Root already contains the UR Toolbox.\n',... 'Would you like to replace the existing toolbox?']),... 'Yes','No'); elseif replaceExisting choice = 'Yes'; else choice = 'No'; end % Replace existing or cancel installation switch choice case 'Yes' % TODO - check if NatNet SDK components are running and close % them prior to removing directory rmpath(toolboxRoot); [isRemoved, msg, msgID] = rmdir(toolboxRoot,'s'); if isRemoved fprintf('Previous version of UR Toolbox removed successfully.\n'); else fprintf('Failed to remove old UR Toolbox folder:\n\t"%s"\n',toolboxRoot); fprintf(adminSolution); error(msgID,msg); end case 'No' fprintf('UR Toolbox currently exists, installation cancelled.\n'); return case 'Cancel' fprintf('Action cancelled.\n'); return otherwise error('Unexpected response.'); end end %% Create Scorbot Toolbox Path [isDir,msg,msgID] = mkdir(toolboxRoot); if isDir fprintf('UR toolbox folder created successfully:\n\t"%s"\n',toolboxRoot); else fprintf('Failed to create UR Toolbox folder:\n\t"%s"\n',toolboxRoot); fprintf(adminSolution); error(msgID,msg); end %% Migrate toolbox folder contents toolboxContent = 'URToolboxFunctions'; if ~isdir(toolboxContent) error(sprintf(... ['Change your working directory to the location of "installURToolbox.m".\n',... '\n',... 'If this problem persists:\n',... '\t(1) Unzip your original download of "URToolbox" into a new directory\n',... '\t(2) Open a new instance of MATLAB "as administrator"\n',... '\t\t(a) Locate MATLAB shortcut\n',... '\t\t(b) Right click\n',... '\t\t(c) Select "Run as administrator"\n',... '\t(3) Change your "working directory" to the location of "installURToolbox.m"\n',... '\t(4) Enter "installURToolbox" (without quotes) into the command window\n',... '\t(5) Press Enter.'])); end files = dir(toolboxContent); wb = waitbar(0,'Copying UR Toolbox toolbox contents...'); n = numel(files); fprintf('Copying UR Toolbox contents:\n'); for i = 1:n % source file location source = fullfile(toolboxContent,files(i).name); % destination location destination = toolboxRoot; if files(i).isdir switch files(i).name case '.' %Ignore case '..' %Ignore otherwise fprintf('\t%s...',files(i).name); nDestination = fullfile(destination,files(i).name); [isDir,msg,msgID] = mkdir(nDestination); if isDir [isCopy,msg,msgID] = copyfile(source,nDestination,'f'); if isCopy fprintf('[Complete]\n'); else bin = msg == char(10); msg(bin) = []; bin = msg == char(13); msg(bin) = []; fprintf('[Failed: "%s"]\n',msg); end else bin = msg == char(10); msg(bin) = []; bin = msg == char(13); msg(bin) = []; fprintf('[Failed: "%s"]\n',msg); end end else fprintf('\t%s...',files(i).name); [isCopy,msg,msgID] = copyfile(source,destination,'f'); if isCopy == 1 fprintf('[Complete]\n'); else bin = msg == char(10); msg(bin) = []; bin = msg == char(13); msg(bin) = []; fprintf('[Failed: "%s"]\n',msg); end end waitbar(i/n,wb); end set(wb,'Visible','off'); %% Migrate toolbox support folder pythonRoot = fullfile('C:\Python34\Lib'); toolboxContent = 'URToolboxSupport'; if ~isdir(toolboxContent) error(sprintf(... ['Change your working directory to the location of "installURToolbox.m".\n',... '\n',... 'If this problem persists:\n',... '\t(1) Unzip your original download of "URToolbox" into a new directory\n',... '\t(2) Open a new instance of MATLAB "as administrator"\n',... '\t\t(a) Locate MATLAB shortcut\n',... '\t\t(b) Right click\n',... '\t\t(c) Select "Run as administrator"\n',... '\t(3) Change your "working directory" to the location of "installURToolbox.m"\n',... '\t(4) Enter "installURToolbox" (without quotes) into the command window\n',... '\t(5) Press Enter.'])); end files = dir(toolboxContent); wb = waitbar(0,'Copying UR Toolbox toolbox contents...'); n = numel(files); fprintf('Copying UR Toolbox contents:\n'); for i = 1:n % source file location source = fullfile(toolboxContent,files(i).name); % destination location destination = pythonRoot; if files(i).isdir switch files(i).name case '.' %Ignore case '..' %Ignore otherwise fprintf('\t%s...',files(i).name); nDestination = fullfile(destination,files(i).name); [isDir,msg,msgID] = mkdir(nDestination); if isDir [isCopy,msg,msgID] = copyfile(source,nDestination,'f'); if isCopy fprintf('[Complete]\n'); else bin = msg == char(10); msg(bin) = []; bin = msg == char(13); msg(bin) = []; fprintf('[Failed: "%s"]\n',msg); end else bin = msg == char(10); msg(bin) = []; bin = msg == char(13); msg(bin) = []; fprintf('[Failed: "%s"]\n',msg); end end else fprintf('\t%s...',files(i).name); [isCopy,msg,msgID] = copyfile(source,destination,'f'); if isCopy == 1 fprintf('[Complete]\n'); else bin = msg == char(10); msg(bin) = []; bin = msg == char(13); msg(bin) = []; fprintf('[Failed: "%s"]\n',msg); end end waitbar(i/n,wb); end set(wb,'Visible','off'); %% Save toolbox path %addpath(genpath(toolboxRoot),'-end'); addpath(toolboxRoot,'-end'); savepath; %% Rehash toolbox cache fprintf('Rehashing Toolbox Cache...'); rehash TOOLBOXCACHE fprintf('[Complete]\n'); end function ToolboxUpdate(toolboxName) %% Setup functions ToolboxVer = str2func( sprintf('%sToolboxVer',toolboxName) ); installToolbox = str2func( sprintf('install%sToolbox',toolboxName) ); %% Check current version try A = ToolboxVer; catch ME A = []; fprintf('No previous version of %s detected.\n',toolboxName); end %% Setup temporary file directory fprintf('Downloading the %s Toolbox...',toolboxName); tmpFolder = sprintf('%sToolbox',toolboxName); pname = fullfile(tempdir,tmpFolder); %% Download and unzip toolbox (GitHub) if (strcmp(toolboxName,'Transformation')) || (strcmp(toolboxName,'Plotting')) url = sprintf('https://github.com/kutzer/%sToolbox/archive/master.zip',toolboxName); else url = sprintf('https://github.com/kstrotz/%sToolbox/archive/master.zip',toolboxName); end try fnames = unzip(url,pname); fprintf('SUCCESS\n'); confirm = true; catch confirm = false; end %% Check for successful download if ~confirm error('InstallToolbox:FailedDownload','Failed to download updated version of %s Toolbox.',toolboxName); end %% Find base directory install_pos = strfind(fnames, sprintf('install%sToolbox.m',toolboxName) ); sIdx = cell2mat( install_pos ); cIdx = ~cell2mat( cellfun(@isempty,install_pos,'UniformOutput',0) ); pname_star = fnames{cIdx}(1:sIdx-1); %% Get current directory and temporarily change path cpath = cd; cd(pname_star); %% Install ScorBot Toolbox installToolbox(true); %% Move back to current directory and remove temp file cd(cpath); [ok,msg] = rmdir(pname,'s'); if ~ok warning('Unable to remove temporary download folder. %s',msg); end %% Complete installation fprintf('Installation complete.\n'); end
github
kstrotz/URToolbox-master
URToolboxUpdate.m
.m
URToolbox-master/URToolboxFunctions/URToolboxUpdate.m
1,675
utf_8
f9676ebb610a475bb41b827d331033ad
function URToolboxUpdate % URTOOLBOXUPDATE download and update the UR Toolbox. % % M. Kutzer 27Feb2016, USNA % TODO - Find a location for "URToolbox Example SCRIPTS" % TODO - update function for general operation % Install UR Toolbox ToolboxUpdate('UR'); end function ToolboxUpdate(toolboxName) %% Setup functions ToolboxVer = str2func( sprintf('%sToolboxVer',toolboxName) ); installToolbox = str2func( sprintf('install%sToolbox',toolboxName) ); %% Check current version A = ToolboxVer; %% Setup temporary file directory fprintf('Downloading the %s Toolbox...',toolboxName); tmpFolder = sprintf('%sToolbox',toolboxName); pname = fullfile(tempdir,tmpFolder); %% Download and unzip toolbox (GitHub) url = sprintf('https://github.com/kstrotz/%sToolbox/archive/master.zip',toolboxName); try fnames = unzip(url,pname); fprintf('SUCCESS\n'); confirm = true; catch confirm = false; end %% Check for successful download if ~confirm error('InstallToolbox:FailedDownload','Failed to download updated version of %s Toolbox.',toolboxName); end %% Find base directory install_pos = strfind(fnames, sprintf('install%sToolbox.m',toolboxName) ); sIdx = cell2mat( install_pos ); cIdx = ~cell2mat( cellfun(@isempty,install_pos,'UniformOutput',0) ); pname_star = fnames{cIdx}(1:sIdx-1); %% Get current directory and temporarily change path cpath = cd; cd(pname_star); %% Install ScorBot Toolbox installToolbox(true); %% Move back to current directory and remove temp file cd(cpath); [ok,msg] = rmdir(pname,'s'); if ~ok warning('Unable to remove temporary download folder. %s',msg); end %% Complete installation fprintf('Installation complete.\n'); end
github
Mark-Kramer/Spike-Ripple-Detector-Method-master
spike_ripple_detector.m
.m
Spike-Ripple-Detector-Method-master/spike_ripple_detector.m
12,942
utf_8
8552c4cead1053e7c0b1f5b34f70d65e
% Spike-ripple detector. % Developed by Catherine Chu, Arthur Chan, and Mark Kramer. % % INPUTS: % data = the time series data, in this case EEG from one electrode. % time = the time axis for the data, in units of seconds. % ADVANCED INPUTS: % varargin = 'PercentileEnvelope', value % set 'value' between 0 and 1 to choose the % envelope threshold. If this parameter is not specified, the default % envelope threshold of 0.85 is used. % varargin = 'SharedMaxMin', [value1, value2] % where value1 = max_min_threshold % value2 = peak_threshold % % OUTPUT: % res = structure that holds each candidate spike-ripple event. % res.INPOS %Start time [s] % res.FIPOS %End time [s] % res.LEN %Duration [s] % res.freq %Frequency of ripple [Hz]. % res.zc %Zero-crossing of ripple [Hz] % res.fano %Fano factor of ripple. % res.Lhite %Difference between spike peak and start of interval. % res.Rhite %Difference between spike peak and end of interval. % res.Ctime %Time difference between start of ripple and start of spike. % res.Vpeak %Peak voltage of spike. % diagnostics = structure that holds method diagnostics (see code). % % DEPENDENCIES: % findseq.m developed by Oleg Komarov. function [res,diagnostics] = spike_ripple_detector(data,time, varargin) Fs = 1/(time(2)-time(1)); %Sampling frequency. res = {}; %Structure to store results. fprintf('Design the filter ... \n') fNQ = Fs/2; %Define Nyquist frequeuncy. d = fdesign.bandpass('Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2',... (60)/fNQ,... %Freq @ edge first stop band. (100)/fNQ,... %Freq @ edge of start of passband. (300)/fNQ,... %Freq @ edge of end of passband (350)/fNQ,... %Freq @ edge second stop band 80,... %Attenuation in the first stop band in decibels 0.1,... %Amount of ripple allowed in the pass band. 40); %Attenuation in the second stop band in decibels Hd = design(d,'equiripple'); %Design the filter [num, den] = tf(Hd); %Convert filter to numerator, denominator expression. order = length(num); %Get filter order. diagnostics.num = num; diagnostics.den = den; diagnostics.order = order; dfilt = filter(num, den, data); %Filter the data. dfilt = [dfilt(floor(order/2+1):end); zeros(floor(order/2),1)]; %Shift after filtering. if any(isnan(dfilt)) % If there's a nan in the data, nan_dfilt = find(isnan(dfilt)); % ... find nans, temp_for_hilbert = dfilt; % ... make dfilt for hilbert, temp_for_hilbert(nan_dfilt)=0; % ... and put 0s at nans amp = abs(hilbert(temp_for_hilbert)); %Compute amplitude envelope. else amp = abs(hilbert(dfilt)); %Compute amplitude envelope. end if any(strcmp(varargin, 'PercentileEnvelope')) %Choose envelope threshold (ADVANCED) i0 = 1+find(strcmp(varargin, 'PercentileEnvelope')); percentile_envelope = varargin{i0}; %... as input, else %... or, percentile_envelope = 0.85; %... as default envelope threshold. end threshold = quantile(amp, percentile_envelope); %Set amplitude threshold. fprintf(['Percentile envelope = ' num2str(percentile_envelope) ' ... \n']) diagnostics.threshold = threshold; %... save as diagnoistic to return. if any(strcmp(varargin, 'SharedMaxMin')) %Choose max&min threshold (ADVANCED) i0 = 1+find(strcmp(varargin, 'SharedMaxMin')); %... as input thresholds = varargin{i0}; max_min_threshold = thresholds(1); peak_threshold = thresholds(2); else % ... or get a sampling of max-start values. n_max_min = 10000; %For 10,000 resamples, N_time = length(data); win_max_min = round(0.050*Fs); %... and window interval of 50 ms, max_min_distribution = zeros(n_max_min,1); %... create a surrogate distribution, parfor n=1:n_max_min %... for each surrogate, istart=randi(N_time-win_max_min); %... choose a random time index. %... compute max value - value @ start of interval. max_min_distribution(n) = max(data(istart:istart+win_max_min-1))-data(istart); end percentile_max_and_peaks = 0.95; %Set max & peak threshold, %Get threshold for max-start values. max_min_threshold = quantile(max_min_distribution, percentile_max_and_peaks); %Get threshold for max voltage values. peak_threshold = quantile(data, percentile_max_and_peaks); end binary_above = amp > threshold; above = find(amp > threshold); %Find amp's above threshold. t_separation = 0.005; %Set small time seperation to 5 ms, %... and merge small separations. small_separation = find(diff(above) > 1 & diff(above) < round(t_separation*Fs)); for js=0:length(small_separation)-1 ileft = small_separation(end-js); iright = ileft+1; binary_above(above(ileft):above(iright))=1; end above=find(binary_above); [VALUES, INPOS, FIPOS, LEN] = findseq(diff(above)); i_values=find(VALUES==1); %Locate sequences of value=1. diagnostics.sequences_above = length(i_values); if ~isempty(i_values) %If we find sequences of 1's, INPOS = INPOS(i_values); %...save start index of each sequence, FIPOS = FIPOS(i_values); %...save end index of each sequence, LEN = LEN(i_values); %...and save length. INPOS = time(above(INPOS)); %Convert detections to TIME. FIPOS = time(above(FIPOS)); LEN = LEN/Fs; long_enough = find(LEN > 0.02); %Find intervals > 20 ms. diagnostics.number_long_enough = length(long_enough); if ~isempty(long_enough) %If we find intervals > 20 ms, fprintf(['Found sequences > 20 ms ... \n' ]) INPOS=INPOS(long_enough); %... get those intervals. FIPOS=FIPOS(long_enough); LEN =LEN(long_enough); %Find intervals away from first/last time index. away_from_edges = find(INPOS > 1 & FIPOS < time(end)-1); INPOS=INPOS(away_from_edges); FIPOS=FIPOS(away_from_edges); LEN =LEN(away_from_edges); % For each interval, compute zero-crossings, frequency, fano, left-right-max value, and time of max. zc = zeros(length(INPOS),1); freq = zeros(length(INPOS),1); fano = zeros(length(INPOS),1); Lhite = zeros(length(INPOS),1); Rhite = zeros(length(INPOS),1); Ctime = zeros(length(INPOS),1); Vpeak = zeros(length(INPOS),1); parfor k=1:length(INPOS) % Find candidate HFO interval. good = find(time >= INPOS(k) & time < FIPOS(k)); d0 = dfilt(good); % Get filtered data. d0 = d0 - mean(d0); % Subtract mean. d0((d0>0))=1; % Set values > 0 equal to 1. d0((d0<0))=0; % Set values < 0 equal to 0. zc0 = find(diff(d0)==1); % ZC when transition from 0 to 1. zc(k)=length(zc0); % Count ZC. ISI0 = diff(zc0); % Distance between ZC. freq(k)=mean(1/(mean(ISI0)/Fs)); % Approx freq. fano(k)=var(ISI0)/mean(ISI0); % Fano factor of of zero crossing times. center_time = mean(time(good)); % Center time of window. good = find(time >= center_time-0.05 & time < center_time+0.05); %+/- 50 ms around center. dorig = data(good); % Get unfiltered data. dorig = smooth(dorig,11); % Smooth it. [mx, imx] = max(dorig); % Find max. Lhite(k) = mx-dorig(1); % Difference between max & left (or start) of interval. Rhite(k) = mx-dorig(end); % Difference betweem max & right (or end) of interval. Ctime(k) = INPOS(k) - time(good(imx)); % Time from ripple start to max Vpeak(k) = mx; % Max values. end % Find intervals that pass tests. threshold_fano = 1; %Fix Fano threshold. %To classify as a spike-ripple detection, must have: good = find(zc >= 3 ... % At least 3 ZC. & fano < threshold_fano ... % Fano < 1. & Lhite > max_min_threshold ... % Max - start value > threshold. & Rhite > max_min_threshold ... % Max - end value > threshold. & Ctime < 0 ... % Ripple begin before peak. & Vpeak > peak_threshold); % Max > threshold. end % Save candidate spike-ripple events. INPOS=INPOS(good); FIPOS=FIPOS(good); LEN =LEN(good); zc = zc(good); freq = freq(good); fano = fano(good); Lhite = Lhite(good); Rhite = Rhite(good); Ctime = Ctime(good); Vpeak = Vpeak(good); diagnostics.number_detections = length(good); %Sort detections by starting time. [~, isort] = sort(INPOS, 'ascend'); INPOS = INPOS(isort); FIPOS = FIPOS(isort); LEN = LEN(isort); freq = freq(isort); zc = zc(isort); fano = fano(isort); Lhite = Lhite(isort); Rhite = Rhite(isort); Ctime = Ctime(isort); Vpeak = Vpeak(isort); fprintf(['Candidate spike-ripple events = ' num2str(length(good)) ' ... \n' ]) %Save the results for each candidate spike-ripple event. res.INPOS = INPOS; %Start time [s] res.FIPOS = FIPOS; %End time [s] res.LEN = LEN; %Duration [s] res.freq = freq; %Frequency of ripple [Hz]. res.zc = zc; %Zero-crossing of ripple [Hz] res.fano = fano; %Fano factor of ripple. res.Lhite = Lhite; %Difference between spike peak and start of interval. res.Rhite = Rhite; %Difference between spike peak and end of interval. res.Ctime = Ctime; %Time difference between start of ripple and start of spike. res.Vpeak = Vpeak; %Peak voltage of spike. end end
github
Mark-Kramer/Spike-Ripple-Detector-Method-master
spike_ripple_visualizer.m
.m
Spike-Ripple-Detector-Method-master/spike_ripple_visualizer.m
5,754
utf_8
9fddc4b8bfa03634727d213351a8345c
% Function to visualize and classify the candidate spike ripple events % detected in spike_ripple_detector.m % % This function produces a figure showing the (1) the original data, (2) % the filtered data, and (3) the spectrogram surrounding each candidate spike ripple % event. % % For each candidate spike ripple event, the user enters "y" for YES or "n" % for NO at the command line. The results of these classifications are then % returned in the output. % INPUTS. % data = the LFP data (same as for spike_ripple_detector.m) % time = the time axis (same as for spike_ripple_detector.m) % res0 = the 1st output of spike_ripple_detector.m % diagnostics = the 2nd output of spike_ripple_detector.m % OUTPUTS. % expert_classify = the classification of each candidate spike ripple % event as 'y' or 'n'. function [expert_classify] = spike_ripple_visualizer(data, time, res0, diagnostics) Fs = 1/(time(10)-time(9)); num = diagnostics.num; den = diagnostics.den; order = diagnostics.order; dfilt = filter(num, den, data); %Filter it. dfilt = [dfilt(floor(order/2)+1:end); zeros(floor(order/2),1)]; %Shift after filtering. n_detections = length(res0.INPOS); counter = 1; for k=1:n_detections INPOS = res0.INPOS(k); FIPOS = res0.FIPOS(k); LEN = res0.LEN(k); freq = res0.freq(k); zc = res0.zc(k); fano = res0.fano(k); Lhite = res0.Lhite(k); Rhite = res0.Rhite(k); Ctime = res0.Ctime(k); Vpeak = res0.Vpeak(k); igood = find(time > INPOS-0.5 & time < FIPOS+0.5); t = time(igood); dat = data(igood); datf = dfilt(igood); dspec = data(igood)-mean(data(igood)); params.Fs = Fs; % Sampling frequency [Hz] params.fpass = [30 250]; % Frequencies to visualize in spectra [Hz] movingwin = [0.200,0.005]; % Window size, Step size [s] params.tEDF = t; [S,S_times,S_freq] = hannspecgramc(dspec,movingwin,params); %Smooth the spectra. t_smooth = 11; dt_S = S_times(2)-S_times(1); myfilter = fspecial('gaussian',[1 t_smooth], 1); if k==1 fprintf(['Smooth spectra over +/- ' num2str((t_smooth-1)/2*(dt_S)*1000,3) ' ms \n']) end S_smooth = imfilter(S, myfilter, 'replicate'); % Smooth the spectrum. res{counter}.INPOS = INPOS; res{counter}.FIPOS = FIPOS; res{counter}.LEN = LEN; res{counter}.freq = freq; res{counter}.zc = zc; res{counter}.fano = fano; res{counter}.Lhite = Lhite; res{counter}.Rhite = Rhite; res{counter}.Ctime = Ctime; res{counter}.Vpeak = Vpeak; res{counter}.threshold = diagnostics.threshold; res{counter}.t = t; res{counter}.data = dat; res{counter}.dfilt = datf; res{counter}.S_smooth = S_smooth; res{counter}.S_times = S_times; res{counter}.S_freq = S_freq; res{counter}.k = k; counter = counter + 1; end %% Visualize expert_classify = cell(length(res),1); ek = 1; while ek <= length(res) INPOS = res{ek}.INPOS; FIPOS = res{ek}.FIPOS; LEN = res{ek}.LEN; freq = res{ek}.freq; zc = res{ek}.zc; fano = res{ek}.fano; Lhite = res{ek}.Lhite; Rhite = res{ek}.Rhite; Ctime = res{ek}.Ctime; Vpeak = res{ek}.Vpeak; data = res{ek}.data; dfilt = res{ek}.dfilt; amp = abs(hilbert(dfilt)); t = res{ek}.t; threshold = res{ek}.threshold; S_times = res{ek}.S_times; S_freq = res{ek}.S_freq; S_smooth = res{ek}.S_smooth; t0 = 0; t = t-t0; INPOS = INPOS - t0; FIPOS = FIPOS - t0; S_times = S_times - t0; subplot(3,1,1) plot(t, data) ax = axis; axis tight hold on plot([INPOS INPOS], [ax(3) ax(4)], 'k') plot([FIPOS FIPOS], [ax(3) ax(4)], 'k') hold off title(['# ' num2str(length(INPOS)) ', @ ' num2str(k) ... ' DUR ' num2str(LEN*1000,3) ', FQ ' num2str(freq,3) ... ', LHT ' num2str(Lhite,3) ', RHT ' num2str(Rhite,3) ', CT ' num2str(Ctime,3)... ', VPK ' num2str(Vpeak,3) ... ', ZC ' num2str(zc) ', FF ' num2str(fano,2)]) subplot(3,1,2) plot(t, dfilt) hold on plot(t, threshold*ones(size(t)), 'k') axis tight ax = axis; plot([INPOS INPOS], [ax(3) ax(4)], 'k') plot([FIPOS FIPOS], [ax(3) ax(4)], 'k') hold off %Compute the spectrogram. subplot(3,1,3) colormap(jet) imagesc(S_times,S_freq,log10(S_smooth)') %, [-3 -0.5]) axis xy ax = axis; hold on plot([INPOS INPOS], [ax(3) ax(4)], 'k') plot([FIPOS FIPOS], [ax(3) ax(4)], 'k') hold off xlim([INPOS-0.5, FIPOS+0.5]) input0 = input(['Event ' num2str(ek) ' of ' num2str(length(res)) ', Is there an HFO? y/[n]/b: '], 's'); switch input0 case 'b' ek = ek-1; fprintf(['going back one to ' num2str(ek) '\n']) case '' %If you enter nothing, expert_classify{ek,1} = 'n'; %... it's "no". ek = ek+1; otherwise expert_classify{ek,1} = input0; ek = ek+1; end end end
github
Mark-Kramer/Spike-Ripple-Detector-Method-master
findseq.m
.m
Spike-Ripple-Detector-Method-master/findseq.m
5,921
utf_8
21500cb2129c3e3e6c06539f219a9c9a
function varargout = findseq(A,dim) % FINDSEQ Find sequences of repeated (adjacent/consecutive) numeric values % % FINDSEQ(A) Find sequences of repeated numeric values in A along the % first non-singleton dimension. A should be numeric. % % FINDSEQ(...,DIM) Look for sequences along the dimension specified by the % positive integer scalar DIM. % % OUT = findseq(...) % OUT is a "m by 4" numeric matrix where m is the number of sequences found. % % Each sequence has 4 columns where: % - 1st col.: the value being repeated % - 2nd col.: the position of the first value of the sequence % - 3rd col.: the position of the last value of the sequence % - 4th col.: the length of the sequence % % [VALUES, INPOS, FIPOS, LEN] = findseq(...) % Get OUT as separate outputs. % % If no sequences are found no value is returned. % To convert positions into subs/coordinates use IND2SUB % % % Examples: % % % There are sequences of 20s, 1s and NaNs (column-wise) % A = [ 20, 19, 3, 2, NaN, NaN % 20, 23, 1, 1, 1, NaN % 20, 7, 7, NaN, 1, NaN] % % OUT = findseq(A) % OUT = % 20 1 3 3 % 1 14 15 2 % NaN 16 18 3 % % % 3D sequences: NaN, 6 and 0 % A = [ 1, 4 % NaN, 5 % 3, 6]; % A(:,:,2) = [ 0, 0 % NaN, 0 % 0, 6]; % A(:,:,3) = [ 1, 0 % 2, 5 % 3, 6]; % % OUT = findseq(A,3) % OUT = % 6 6 18 3 % 0 10 16 2 % NaN 2 8 2 % % Additional features: % - <a href="matlab: web('http://www.mathworks.com/matlabcentral/fileexchange/28113','-browser')">FEX findseq page</a> % - <a href="matlab: web('http://www.mathworks.com/matlabcentral/fileexchange/6436','-browser')">FEX rude by us page</a> % % See also: DIFF, FIND, SUB2IND, IND2SUB % Author: Oleg Komarov ([email protected]) % Tested on R14SP3 (7.1) and on R2012a. In-between compatibility is assumed. % 02 jul 2010 - Created % 05 jul 2010 - Reorganized code and fixed bug when concatenating results % 12 jul 2010 - Per Xiaohu's suggestion fixed bug in output dimensions when A is row vector % 26 aug 2010 - Cast double on logical instead of single % 28 aug 2010 - Per Zachary Danziger's suggestion reorganized check structure to avoid bug when concatenating results % 22 mar 2012 - Per Herbert Gsenger's suggestion fixed bug in matching initial and final positions; minor change to distribution of OUT if multiple outputs; added 3D example % 08 nov 2013 - Fixed major bug in the sorting of Final position that relied on regularity conditions not always verified % NINPUTS %error(narginchk(1,2,nargin)); % NOUTPUTS %error(nargoutchk(0,4,nargout)); % IN if ~isnumeric(A) error('findseq:fmtA', 'A should be numeric') elseif isempty(A) || isscalar(A) varargout{1} = []; return elseif islogical(A) A = double(A); end % DIM szA = size(A); if nargin == 1 || isempty(dim) % First non singleton dimension dim = find(szA ~= 1,1,'first'); elseif ~(isnumeric(dim) && dim > 0 && rem(dim,1) == 0) || dim > numel(szA) error('findseq:fmtDim', 'DIM should be a scalar positive integer <= ndims(A)'); end % Less than two elements along DIM if szA(dim) == 1 varargout{1} = []; return end % ISVECTOR if nnz(szA ~= 1) == 1 A = A(:); dim = 1; szA = size(A); end % Detect 0, NaN, Inf and -Inf OtherValues = cell(1,4); OtherValues{1} = A == 0; OtherValues{2} = isnan(A) ; OtherValues{3} = A == Inf; OtherValues{4} = A == -Inf; Values = [0,NaN, Inf,-Inf]; % Remove zeros A(OtherValues{1}) = NaN; % Make the bread bread = NaN([szA(1:dim-1),1,szA(dim+1:end)]); % [1] Get chunks of "normal" values Out = mainengine(A,bread,dim,szA); % [2] Get chunks of 0, NaN, Inf and -Inf for c = 1:4 if nnz(OtherValues{c}) > 1 % Logical to double and NaN padding OtherValues{c} = double(OtherValues{c}); OtherValues{c}(~OtherValues{c}) = NaN; % Call mainengine and concatenate results tmp = mainengine(OtherValues{c}, bread,dim,szA); if ~isempty(tmp) Out = [Out; [repmat(Values(c),size(tmp,1),1) tmp(:,2:end)]]; %#ok end end end % Distribute output if nargout < 2 varargout = {Out}; else varargout = num2cell(Out(:,1:nargout),1); end end % MAINENGINE This functions uses run length encoding and retrieve positions function Out = mainengine(meat,bread,dim,szMeat) % Make a sandwich sandwich = cat(dim, bread, meat, bread); % Find chunks (run length encoding engine) IDX = diff(diff(sandwich,[],dim) == 0,[],dim); % Initial and final row/col subscripts [rIn, cIn] = find(IDX == 1); [rFi, cFi] = find(IDX == -1); % Make sure row/col subs correspond (relevant if dim > 1) [In, idx] = sortrows([rIn, cIn],1); Fi = [rFi, cFi]; Fi = Fi(idx,:); % Calculate length of blocks if dim < 3 Le = Fi(:,dim) - In(:,dim) + 1; else md = prod(szMeat(2:dim-1)); Le = (Fi(:,2) - In(:,2))/md + 1; end % Convert to linear index InPos = sub2ind(szMeat,In(:,1),In(:,2)); FiPos = sub2ind(szMeat,Fi(:,1),Fi(:,2)); % Assign output Out = [meat(InPos),... % Values InPos ,... % Initial positions FiPos ,... % Final positions Le ]; % Length of the blocks end
github
dschick/udkm1DsimML-master
bool2str.m
.m
udkm1DsimML-master/helpers/functions/bool2str.m
185
utf_8
7a576a35879a9481b26e8782d0918d2b
%% bool2str % Returns the according string for a boolean input. function str = bool2str(bool) if bool str = 'true'; else str = 'false'; end%if end%function
github
dschick/udkm1DsimML-master
dataHash.m
.m
udkm1DsimML-master/helpers/functions/dataHash.m
15,297
utf_8
8592e240500ffb55915cf0df7bffbd33
function Hash = dataHash(Data, Opt) %% DATAHASH - Checksum for Matlab array of any type % This function creates a hash value for an input of any type. The type and % dimensions of the input are considered as default, such that UINT8([0,0]) and % UINT16(0) have different hash values. Nested STRUCTs and CELLs are parsed % recursively. % % Hash = DataHash(Data, Opt) % INPUT: % Data: Array of these built-in types: % (U)INT8/16/32/64, SINGLE, DOUBLE, (real or complex) % CHAR, LOGICAL, CELL (nested), STRUCT (scalar or array, nested), % function_handle. % Opt: Struct to specify the hashing algorithm and the output format. % Opt and all its fields are optional. % Opt.Method: String, known methods for Java 1.6 (Matlab 2009a): % 'SHA-1', 'SHA-256', 'SHA-384', 'SHA-512', 'MD2', 'MD5'. % Known methods for Java 1.3 (Matlab 6.5): % 'MD5', 'SHA-1'. % Default: 'MD5'. % Opt.Format: String specifying the output format: % 'hex', 'HEX': Lower/uppercase hexadecimal string. % 'double', 'uint8': Numerical vector. % 'base64': Base64 encoded string, only printable % ASCII characters, 33% shorter than 'hex'. % Default: 'hex'. % Opt.Input: Type of the input as string, not case-sensitive: % 'array': The contents, type and size of the input [Data] are % considered for the creation of the hash. Nested CELLs % and STRUCT arrays are parsed recursively. Empty arrays of % different type reply different hashs. % 'file': [Data] is treated as file name and the hash is calculated % for the files contents. % 'bin': [Data] is a numerical, LOGICAL or CHAR array. Only the % binary contents of the array is considered, such that % e.g. empty arrays of different type reply the same hash. % Default: 'array'. % % OUTPUT: % Hash: String, DOUBLE or UINT8 vector. The length depends on the hashing % method. % % EXAMPLES: % % Default: MD5, hex: % DataHash([]) % 7de5637fd217d0e44e0082f4d79b3e73 % % MD5, Base64: % Opt.Format = 'base64'; % Opt.Method = 'MD5'; % DataHash(int32(1:10), Opt) % bKdecqzUpOrL4oxzk+cfyg % % SHA-1, Base64: % S.a = uint8([]); % S.b = {{1:10}, struct('q', uint64(415))}; % Opt.Method = 'SHA-1'; % DataHash(S, Opt) % ZMe4eUAp0G9TDrvSW0/Qc0gQ9/A % % SHA-1 of binary values: % Opt.Method = 'SHA-1'; % Opt.Input = 'bin'; % DataHash(1:8, Opt) % 826cf9d3a5d74bbe415e97d4cecf03f445f69225 % % NOTE: % Function handles and user-defined objects cannot be converted uniquely: % - The subfunction ConvertFuncHandle uses the built-in function FUNCTIONS, % but the replied struct can depend on the Matlab version. % - It is tried to convert objects to UINT8 streams in the subfunction % ConvertObject. A conversion by STRUCT() might be more appropriate. % Adjust these subfunctions on demand. % % MATLAB CHARs have 16 bits! In consequence the string 'hello' is treated as % UINT16('hello') for the binary input method. % % DataHash uses James Tursa's smart and fast TYPECASTX, if it is installed: % http://www.mathworks.com/matlabcentral/fileexchange/17476 % As fallback the built-in TYPECAST is used automatically, but for large % inputs this can be more than 10 times slower. % For Matlab 6.5 installing typecastx is obligatory to run DataHash. % % Tested: Matlab 6.5, 7.7, 7.8, WinXP, Java: 1.3.1_01, 1.6.0_04. % Author: Jan Simon, Heidelberg, (C) 2011 matlab.THISYEAR(a)nMINUSsimon.de % % See also: TYPECAST, CAST. % FEX: % Michael Kleder, "Compute Hash", no structs and cells: % http://www.mathworks.com/matlabcentral/fileexchange/8944 % Tim, "Serialize/Deserialize", converts structs and cells to a byte stream: % http://www.mathworks.com/matlabcentral/fileexchange/29457 % Jan Simon, "CalcMD5", MD5 only, faster C-mex, no structs and cells: % http://www.mathworks.com/matlabcentral/fileexchange/25921 % $JRev: R-j V:010 Sum:q3tnsDSkI19o Date:09-Sep-2011 13:32:19 $ % $License: BSD (use/copy/change/redistribute on own risk, mention the author) $ % $File: Tools\GLFile\DataHash.m $ % History: % 001: 01-May-2011 21:52, First version. % 007: 10-Jun-2011 10:38, [Opt.Input], binary data, complex values considered. % Main function: =============================================================== % Java is needed: if ~usejava('jvm') error(['JSimon:', mfilename, ':NoJava'], ... '*** %s: Java is required.', mfilename); end % typecastx creates a shared data copy instead of the deep copy as Matlab's % TYPECAST - for a [1000x1000] DOUBLE array this is 100 times faster! persistent usetypecastx if isempty(usetypecastx) usetypecastx = ~isempty(which('typecastx')); % Run the slow WHICH once only end % Default options: ------------------------------------------------------------- Method = 'MD5'; OutFormat = 'hex'; isFile = false; isBin = false; % Check number and type of inputs: --------------------------------------------- nArg = nargin; if nArg == 2 if isa(Opt, 'struct') == 0 % Bad type of 2nd input: error(['JSimon:', mfilename, ':BadInput2'], ... '*** %s: 2nd input [Opt] must be a struct.', mfilename); end % Specify hash algorithm: if isfield(Opt, 'Method') Method = upper(Opt.Method); end % Specify output format: if isfield(Opt, 'Format') OutFormat = Opt.Format; end % Check if the Input type is specified - default: 'array': if isfield(Opt, 'Input') if strcmpi(Opt.Input, 'File') isFile = true; if ischar(Data) == 0 error(['JSimon:', mfilename, ':CannotOpen'], ... '*** %s: 1st input is not a file name', mfilename); end if exist(Data, 'file') ~= 2 error(['JSimon:', mfilename, ':FileNotFound'], ... '*** %s: File not found: %s.', mfilename, Data); end elseif strncmpi(Opt.Input, 'bin', 3) % Accept 'binary' isBin = true; if (isnumeric(Data) || ischar(Data) || islogical(Data)) == 0 error(['JSimon:', mfilename, ':BadDataType'], ... '*** %s: 1st input is not numeric, CHAR or LOGICAL.', mfilename); end end end elseif nArg ~= 1 % Bad number of arguments: error(['JSimon:', mfilename, ':BadNInput'], ... '*** %s: 1 or 2 inputs required.', mfilename); end % Create the engine: ----------------------------------------------------------- try Engine = java.security.MessageDigest.getInstance(Method); catch error(['JSimon:', mfilename, ':BadInput2'], ... '*** %s: Invalid algorithm: [%s].', mfilename, Method); end % Create the hash value: ------------------------------------------------------- if isFile % Read the file and calculate the hash: FID = fopen(Data, 'r'); if FID < 0 error(['JSimon:', mfilename, ':CannotOpen'], ... '*** %s: Cannot open file: %s.', mfilename, Data); end Data = fread(FID, Inf, '*uint8'); fclose(FID); Engine.update(Data); if usetypecastx Hash = typecastx(Engine.digest, 'uint8'); else Hash = typecast(Engine.digest, 'uint8'); end elseif isBin % Contents of an elementary array: if usetypecastx % Faster typecastx: if isreal(Data) Engine.update(typecastx(Data(:), 'uint8')); else Engine.update(typecastx(real(Data(:)), 'uint8')); Engine.update(typecastx(imag(Data(:)), 'uint8')); end Hash = typecastx(Engine.digest, 'uint8'); else % Matlab's TYPECAST is less elegant: if isnumeric(Data) if isreal(Data) Engine.update(typecast(Data(:), 'uint8')); else Engine.update(typecast(real(Data(:)), 'uint8')); Engine.update(typecast(imag(Data(:)), 'uint8')); end elseif islogical(Data) % TYPECAST cannot handle LOGICAL Engine.update(typecast(uint8(Data(:)), 'uint8')); elseif ischar(Data) % TYPECAST cannot handle CHAR Engine.update(typecast(uint16(Data(:)), 'uint8')); Engine.update(typecast(Data(:), 'uint8')); end Hash = typecast(Engine.digest, 'uint8'); end elseif usetypecastx % Faster typecastx: Engine = CoreHash_(Data, Engine); Hash = typecastx(Engine.digest, 'uint8'); else % Slower built-in TYPECAST: Engine = CoreHash(Data, Engine); Hash = typecast(Engine.digest, 'uint8'); end % Convert hash specific output format: ----------------------------------------- switch OutFormat case 'hex' Hash = sprintf('%.2x', double(Hash)); case 'HEX' Hash = sprintf('%.2X', double(Hash)); case 'double' Hash = double(reshape(Hash, 1, [])); case 'uint8' Hash = reshape(Hash, 1, []); case 'base64' Hash = fBase64_enc(double(Hash)); otherwise error(['JSimon:', mfilename, ':BadOutFormat'], ... '*** %s: [Opt.Format] must be: HEX, hex, uint8, double, base64.', ... mfilename); end % return; % ****************************************************************************** function Engine = CoreHash_(Data, Engine) % This mothod uses the faster typecastx version. % Consider the type and dimensions of the array to distinguish arrays with the % same data, but different shape: [0 x 0] and [0 x 1], [1,2] and [1;2], % DOUBLE(0) and SINGLE([0,0]): Engine.update([uint8(class(Data)), typecastx(size(Data), 'uint8')]); if isstruct(Data) % Hash for all array elements and fields: F = sort(fieldnames(Data)); % Ignore order of fields Engine = CoreHash_(F, Engine); % Catch the fieldnames for iS = 1:numel(Data) % Loop over elements of struct array for iField = 1:length(F) % Loop over fields Engine = CoreHash_(Data(iS).(F{iField}), Engine); end end elseif iscell(Data) % Get hash for all cell elements: for iS = 1:numel(Data) Engine = CoreHash_(Data{iS}, Engine); end elseif isnumeric(Data) || islogical(Data) || ischar(Data) if isempty(Data) == 0 if isreal(Data) % TRUE for LOGICAL and CHAR also: Engine.update(typecastx(Data(:), 'uint8')); else % typecastx accepts complex input: Engine.update(typecastx(real(Data(:)), 'uint8')); Engine.update(typecastx(imag(Data(:)), 'uint8')); end end elseif isa(Data, 'function_handle') Engine = CoreHash(ConvertFuncHandle(Data), Engine); else % Most likely this is a user-defined object: try Engine = CoreHash(ConvertObject(Data), Engine); catch warning(['JSimon:', mfilename, ':BadDataType'], ... ['Type of variable not considered: ', class(Data)]); end end % return; % ****************************************************************************** function Engine = CoreHash(Data, Engine) % This methods uses the slower TYPECAST of Matlab % See CoreHash_ for comments. Engine.update([uint8(class(Data)), typecast(size(Data), 'uint8')]); if isstruct(Data) % Hash for all array elements and fields: F = sort(fieldnames(Data)); % Ignore order of fields Engine = CoreHash(F, Engine); % Catch the fieldnames for iS = 1:numel(Data) % Loop over elements of struct array for iField = 1:length(F) % Loop over fields Engine = CoreHash(Data(iS).(F{iField}), Engine); end end elseif iscell(Data) % Get hash for all cell elements: for iS = 1:numel(Data) Engine = CoreHash(Data{iS}, Engine); end elseif isempty(Data) elseif isnumeric(Data) if isreal(Data) Engine.update(typecast(Data(:), 'uint8')); else Engine.update(typecast(real(Data(:)), 'uint8')); Engine.update(typecast(imag(Data(:)), 'uint8')); end elseif islogical(Data) % TYPECAST cannot handle LOGICAL Engine.update(typecast(uint8(Data(:)), 'uint8')); elseif ischar(Data) % TYPECAST cannot handle CHAR Engine.update(typecast(uint16(Data(:)), 'uint8')); elseif isa(Data, 'function_handle') Engine = CoreHash(ConvertFuncHandle(Data), Engine); else % Most likely a user-defined object: try Engine = CoreHash(ConvertObject(Data), Engine); catch warning(['JSimon:', mfilename, ':BadDataType'], ... ['Type of variable not considered: ', class(Data)]); end end % return; % ****************************************************************************** function FuncKey = ConvertFuncHandle(FuncH) % The subfunction ConvertFuncHandle converts function_handles to a struct % using the Matlab function FUNCTIONS. The output of this function changes % with the Matlab version, such that DataHash(@sin) replies different hashes % under Matlab 6.5 and 2009a. % An alternative is using the function name and name of the file for % function_handles, but this is not unique for nested or anonymous functions. % If the MATLABROOT is removed from the file's path, at least the hash of % Matlab's toolbox functions is (usually!) not influenced by the version. % Finally I'm in doubt if there is a unique method to hash function handles. % Please adjust the subfunction ConvertFuncHandles to your needs. % The Matlab version influences the conversion by FUNCTIONS: % 1. The format of the struct replied FUNCTIONS is not fixed, % 2. The full paths of toolbox function e.g. for @mean differ. FuncKey = functions(FuncH); % ALTERNATIVE: Use name and path. The <matlabroot> part of the toolbox functions % is replaced such that the hash for @mean does not depend on the Matlab % version. % Drawbacks: Anonymous functions, nested functions... % funcStruct = functions(FuncH); % funcfile = strrep(funcStruct.file, matlabroot, '<MATLAB>'); % FuncKey = uint8([funcStruct.function, ' ', funcfile]); % Finally I'm afraid there is no unique method to get a hash for a function % handle. Please adjust this conversion to your needs. % return; % ****************************************************************************** function DataBin = ConvertObject(DataObj) % Convert a user-defined object to a binary stream. There cannot be a unique % solution, so this part is left for the user... warning off DataBin = struct(DataObj); warning on % disp(DataBin); % Perhaps a direct conversion is implemented: % DataBin = uint8(DataObj); % Or perhaps this is better: % DataBin = struct(DataObj); % return; % ****************************************************************************** function Out = fBase64_enc(In) % Encode numeric vector of UINT8 values to base64 string. Pool = [65:90, 97:122, 48:57, 43, 47]; % [0:9, a:z, A:Z, +, /] v8 = [128; 64; 32; 16; 8; 4; 2; 1]; v6 = [32, 16, 8, 4, 2, 1]; In = reshape(In, 1, []); X = rem(floor(In(ones(8, 1), :) ./ v8(:, ones(length(In), 1))), 2); Y = reshape([X(:); zeros(6 - rem(numel(X), 6), 1)], 6, []); Out = char(Pool(1 + v6 * Y)); % return;
github
dschick/udkm1DsimML-master
mtimesx_test_ssspeed.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_ssspeed.m
415,311
utf_8
c663b5bc66edbfec752f88862a1805d1
% 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
github
dschick/udkm1DsimML-master
mtimesx_build.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_build.m
16,405
utf_8
838ce3d9c7bc33beb0d2f75546ead978
% 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
github
dschick/udkm1DsimML-master
mtimesx_test_nd.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_nd.m
14,364
utf_8
0d3b436cea001bccb9c6cccdaa21b34d
% 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
github
dschick/udkm1DsimML-master
mtimesx_test_sdequal.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_sdequal.m
350,821
utf_8
7e6a367b3ad6154ce1e4da70a91ba4cf
% 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
github
dschick/udkm1DsimML-master
mtimesx_test_ddequal.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_ddequal.m
94,229
utf_8
219fa3623cf14a54da7d267a29e61151
% 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
github
dschick/udkm1DsimML-master
mtimesx_test_dsequal.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_dsequal.m
350,693
utf_8
325490ae690791eb9f0e7d03408cc540
% 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
github
dschick/udkm1DsimML-master
mtimesx_test_sdspeed.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_sdspeed.m
388,309
utf_8
1ed55a613d5cbfe9a11579562f600c9a
% 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
github
dschick/udkm1DsimML-master
mtimesx_test_ddspeed.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_ddspeed.m
121,611
utf_8
32613fb321b2de56bd52cb4b4567187d
% 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
github
dschick/udkm1DsimML-master
mtimesx_sparse.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_sparse.m
3,015
utf_8
eeb3eb2df4d70c69695b45188807e91c
% 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
github
dschick/udkm1DsimML-master
mtimesx_test_dsspeed.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_dsspeed.m
388,140
utf_8
53e3e8d0e86784747c58c68664ae0d85
% 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
github
dschick/udkm1DsimML-master
mtimesx_test_ssequal.m
.m
udkm1DsimML-master/helpers/functions/mtimesx/mtimesx_test_ssequal.m
355,156
utf_8
4c01cb508f7cf6adb1b848f98ee9ca41
% 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
github
dschick/udkm1DsimML-master
xml_write.m
.m
udkm1DsimML-master/helpers/functions/xml_io_tools/xml_write.m
18,325
utf_8
24bd3dc683e5a0a0ad4080deaa6a93a5
function DOMnode = xml_write(filename, tree, RootName, Pref) %XML_WRITE Writes Matlab data structures to XML file % % DESCRIPTION % xml_write( filename, tree) Converts Matlab data structure 'tree' containing % cells, structs, numbers and strings to Document Object Model (DOM) node % tree, then saves it to XML file 'filename' using Matlab's xmlwrite % function. Optionally one can also use alternative version of xmlwrite % function which directly calls JAVA functions for XML writing without % MATLAB middleware. This function is provided as a patch to existing % bugs in xmlwrite (in R2006b). % % xml_write(filename, tree, RootName, Pref) allows you to specify % additional preferences about file format % % DOMnode = xml_write([], tree) same as above except that DOM node is % not saved to the file but returned. % % INPUT % filename file name % tree Matlab structure tree to store in xml file. % RootName String with XML tag name used for root (top level) node % Optionally it can be a string cell array storing: Name of % root node, document "Processing Instructions" data and % document "comment" string % Pref Other preferences: % Pref.ItemName - default 'item' - name of a special tag used to % itemize cell or struct arrays % Pref.XmlEngine - let you choose the XML engine. Currently default is % 'Xerces', which is using directly the apache xerces java file. % Other option is 'Matlab' which uses MATLAB's xmlwrite and its % XMLUtils java file. Both options create identical results except in % case of CDATA sections where xmlwrite fails. % Pref.CellItem - default 'true' - allow cell arrays to use 'item' % notation. See below. % Pref.RootOnly - default true - output variable 'tree' corresponds to % xml file root element, otherwise it correspond to the whole file. % Pref.StructItem - default 'true' - allow arrays of structs to use % 'item' notation. For example "Pref.StructItem = true" gives: % <a> % <b> % <item> ... <\item> % <item> ... <\item> % <\b> % <\a> % while "Pref.StructItem = false" gives: % <a> % <b> ... <\b> % <b> ... <\b> % <\a> % % % Several special xml node types can be created if special tags are used % for field names of 'tree' nodes: % - node.CONTENT - stores data section of the node if other fields % (usually ATTRIBUTE are present. Usually data section is stored % directly in 'node'. % - node.ATTRIBUTE.name - stores node's attribute called 'name'. % - node.COMMENT - create comment child node from the string. For global % comments see "RootName" input variable. % - node.PROCESSING_INSTRUCTIONS - create "processing instruction" child % node from the string. For global "processing instructions" see % "RootName" input variable. % - node.CDATA_SECTION - stores node's CDATA section (string). Only works % if Pref.XmlEngine='Xerces'. For more info, see comments of F_xmlwrite. % - other special node types like: document fragment nodes, document type % nodes, entity nodes and notation nodes are not being handled by % 'xml_write' at the moment. % % OUTPUT % DOMnode Document Object Model (DOM) node tree in the format % required as input to xmlwrite. (optional) % % EXAMPLES: % MyTree=[]; % MyTree.MyNumber = 13; % MyTree.MyString = 'Hello World'; % xml_write('test.xml', MyTree); % type('test.xml') % %See also xml_tutorial.m % % See also % xml_read, xmlread, xmlwrite % % Written by Jarek Tuszynski, SAIC, jaroslaw.w.tuszynski_at_saic.com %% Check Matlab Version v = ver('MATLAB'); v = str2double(regexp(v.Version, '\d.\d','match','once')); if (v<7) error('Your MATLAB version is too old. You need version 7.0 or newer.'); end %% default preferences DPref.TableName = {'tr','td'}; % name of a special tags used to itemize 2D cell arrays DPref.ItemName = 'item'; % name of a special tag used to itemize 1D cell arrays DPref.StructItem = true; % allow arrays of structs to use 'item' notation DPref.CellItem = true; % allow cell arrays to use 'item' notation DPref.StructTable= 'Html'; DPref.CellTable = 'Html'; DPref.XmlEngine = 'Matlab'; % use matlab provided XMLUtils %DPref.XmlEngine = 'Xerces'; % use Xerces xml generator directly DPref.PreserveSpace = false; % Preserve or delete spaces at the beggining and the end of stings? RootOnly = true; % Input is root node only GlobalProcInst = []; GlobalComment = []; GlobalDocType = []; %% read user preferences if (nargin>3) if (isfield(Pref, 'TableName' )), DPref.TableName = Pref.TableName; end if (isfield(Pref, 'ItemName' )), DPref.ItemName = Pref.ItemName; end if (isfield(Pref, 'StructItem')), DPref.StructItem = Pref.StructItem; end if (isfield(Pref, 'CellItem' )), DPref.CellItem = Pref.CellItem; end if (isfield(Pref, 'CellTable')), DPref.CellTable = Pref.CellTable; end if (isfield(Pref, 'StructTable')), DPref.StructTable= Pref.StructTable; end if (isfield(Pref, 'XmlEngine' )), DPref.XmlEngine = Pref.XmlEngine; end if (isfield(Pref, 'RootOnly' )), RootOnly = Pref.RootOnly; end if (isfield(Pref, 'PreserveSpace')), DPref.PreserveSpace = Pref.PreserveSpace; end end if (nargin<3 || isempty(RootName)), RootName=inputname(2); end if (isempty(RootName)), RootName='ROOT'; end if (iscell(RootName)) % RootName also stores global text node data rName = RootName; RootName = char(rName{1}); if (length(rName)>1), GlobalProcInst = char(rName{2}); end if (length(rName)>2), GlobalComment = char(rName{3}); end if (length(rName)>3), GlobalDocType = char(rName{4}); end end if(~RootOnly && isstruct(tree)) % if struct than deal with each field separatly fields = fieldnames(tree); for i=1:length(fields) field = fields{i}; x = tree(1).(field); if (strcmp(field, 'COMMENT')) GlobalComment = x; elseif (strcmp(field, 'PROCESSING_INSTRUCTION')) GlobalProcInst = x; elseif (strcmp(field, 'DOCUMENT_TYPE')) GlobalDocType = x; else RootName = field; t = x; end end tree = t; end %% Initialize jave object that will store xml data structure RootName = varName2str(RootName); if (~isempty(GlobalDocType)) % n = strfind(GlobalDocType, ' '); % if (~isempty(n)) % dtype = com.mathworks.xml.XMLUtils.createDocumentType(GlobalDocType); % end % DOMnode = com.mathworks.xml.XMLUtils.createDocument(RootName, dtype); warning('xml_io_tools:write:docType', ... 'DOCUMENT_TYPE node was encountered which is not supported yet. Ignoring.'); end DOMnode = com.mathworks.xml.XMLUtils.createDocument(RootName); %% Use recursive function to convert matlab data structure to XML root = DOMnode.getDocumentElement; struct2DOMnode(DOMnode, root, tree, DPref.ItemName, DPref); %% Remove the only child of the root node root = DOMnode.getDocumentElement; Child = root.getChildNodes; % create array of children nodes nChild = Child.getLength; % number of children if (nChild==1) node = root.removeChild(root.getFirstChild); while(node.hasChildNodes) root.appendChild(node.removeChild(node.getFirstChild)); end while(node.hasAttributes) % copy all attributes root.setAttributeNode(node.removeAttributeNode(node.getAttributes.item(0))); end end %% Save exotic Global nodes if (~isempty(GlobalComment)) DOMnode.insertBefore(DOMnode.createComment(GlobalComment), DOMnode.getFirstChild()); end if (~isempty(GlobalProcInst)) n = strfind(GlobalProcInst, ' '); if (~isempty(n)) proc = DOMnode.createProcessingInstruction(GlobalProcInst(1:(n(1)-1)),... GlobalProcInst((n(1)+1):end)); DOMnode.insertBefore(proc, DOMnode.getFirstChild()); end end % Not supported yet as the code below does not work % if (~isempty(GlobalDocType)) % n = strfind(GlobalDocType, ' '); % if (~isempty(n)) % dtype = DOMnode.createDocumentType(GlobalDocType); % DOMnode.insertBefore(dtype, DOMnode.getFirstChild()); % end % end %% save java DOM tree to XML file if (~isempty(filename)) if (strcmpi(DPref.XmlEngine, 'Xerces')) xmlwrite_xerces(filename, DOMnode); else xmlwrite(filename, DOMnode); end end %% ======================================================================= % === struct2DOMnode Function =========================================== % ======================================================================= function [] = struct2DOMnode(xml, parent, s, TagName, Pref) % struct2DOMnode is a recursive function that converts matlab's structs to % DOM nodes. % INPUTS: % xml - jave object that will store xml data structure % parent - parent DOM Element % s - Matlab data structure to save % TagName - name to be used in xml tags describing 's' % Pref - preferenced % OUTPUT: % parent - modified 'parent' % perform some conversions if (ischar(s) && min(size(s))>1) % if 2D array of characters s=cellstr(s); % than convert to cell array end % if (strcmp(TagName, 'CONTENT')) % while (iscell(s) && length(s)==1), s = s{1}; end % unwrap cell arrays of length 1 % end TagName = varName2str(TagName); %% == node is a 2D cell array == % convert to some other format prior to further processing nDim = nnz(size(s)>1); % is it a scalar, vector, 2D array, 3D cube, etc? if (iscell(s) && nDim==2 && strcmpi(Pref.CellTable, 'Matlab')) s = var2str(s, Pref.PreserveSpace); end if (nDim==2 && (iscell (s) && strcmpi(Pref.CellTable, 'Vector')) || ... (isstruct(s) && strcmpi(Pref.StructTable, 'Vector'))) s = s(:); end if (nDim>2), s = s(:); end % can not handle this case well nItem = numel(s); nDim = nnz(size(s)>1); % is it a scalar, vector, 2D array, 3D cube, etc? %% == node is a cell == if (iscell(s)) % if this is a cell or cell array if ((nDim==2 && strcmpi(Pref.CellTable,'Html')) || (nDim< 2 && Pref.CellItem)) % if 2D array of cells than can use HTML-like notation or if 1D array % than can use item notation if (strcmp(TagName, 'CONTENT')) % CONTENT nodes already have <TagName> ... </TagName> array2DOMnode(xml, parent, s, Pref.ItemName, Pref ); % recursive call else node = xml.createElement(TagName); % <TagName> ... </TagName> array2DOMnode(xml, node, s, Pref.ItemName, Pref ); % recursive call parent.appendChild(node); end else % use <TagName>...<\TagName> <TagName>...<\TagName> notation array2DOMnode(xml, parent, s, TagName, Pref ); % recursive call end %% == node is a struct == elseif (isstruct(s)) % if struct than deal with each field separatly if ((nDim==2 && strcmpi(Pref.StructTable,'Html')) || (nItem>1 && Pref.StructItem)) % if 2D array of structs than can use HTML-like notation or % if 1D array of structs than can use 'items' notation node = xml.createElement(TagName); array2DOMnode(xml, node, s, Pref.ItemName, Pref ); % recursive call parent.appendChild(node); elseif (nItem>1) % use <TagName>...<\TagName> <TagName>...<\TagName> notation array2DOMnode(xml, parent, s, TagName, Pref ); % recursive call else % otherwise save each struct separatelly fields = fieldnames(s); node = xml.createElement(TagName); for i=1:length(fields) % add field by field to the node field = fields{i}; x = s.(field); switch field case {'COMMENT', 'CDATA_SECTION', 'PROCESSING_INSTRUCTION'} if iscellstr(x) % cell array of strings -> add them one by one array2DOMnode(xml, node, x(:), field, Pref ); % recursive call will modify 'node' elseif ischar(x) % single string -> add it struct2DOMnode(xml, node, x, field, Pref ); % recursive call will modify 'node' else % not a string - Ignore warning('xml_io_tools:write:badSpecialNode', ... ['Struct field named ',field,' encountered which was not a string. Ignoring.']); end case 'ATTRIBUTE' % set attributes of the node if (isempty(x)), continue; end if (isstruct(x)) attName = fieldnames(x); % get names of all the attributes for k=1:length(attName) % attach them to the node att = xml.createAttribute(varName2str(attName(k))); att.setValue(var2str(x.(attName{k}),Pref.PreserveSpace)); node.setAttributeNode(att); end else warning('xml_io_tools:write:badAttribute', ... 'Struct field named ATTRIBUTE encountered which was not a struct. Ignoring.'); end otherwise % set children of the node struct2DOMnode(xml, node, x, field, Pref ); % recursive call will modify 'node' end end % end for i=1:nFields parent.appendChild(node); end %% == node is a leaf node == else % if not a struct and not a cell than it is a leaf node switch TagName % different processing depending on desired type of the node case 'COMMENT' % create comment node com = xml.createComment(s); parent.appendChild(com); case 'CDATA_SECTION' % create CDATA Section cdt = xml.createCDATASection(s); parent.appendChild(cdt); case 'PROCESSING_INSTRUCTION' % set attributes of the node OK = false; if (ischar(s)) n = strfind(s, ' '); if (~isempty(n)) proc = xml.createProcessingInstruction(s(1:(n(1)-1)),s((n(1)+1):end)); parent.insertBefore(proc, parent.getFirstChild()); OK = true; end end if (~OK) warning('xml_io_tools:write:badProcInst', ... ['Struct field named PROCESSING_INSTRUCTION need to be',... ' a string, for example: xml-stylesheet type="text/css" ', ... 'href="myStyleSheet.css". Ignoring.']); end case 'CONTENT' % this is text part of already existing node txt = xml.createTextNode(var2str(s, Pref.PreserveSpace)); % convert to text parent.appendChild(txt); otherwise % I guess it is a regular text leaf node txt = xml.createTextNode(var2str(s, Pref.PreserveSpace)); node = xml.createElement(TagName); node.appendChild(txt); parent.appendChild(node); end end % of struct2DOMnode function %% ======================================================================= % === array2DOMnode Function ============================================ % ======================================================================= function [] = array2DOMnode(xml, parent, s, TagName, Pref) % Deal with 1D and 2D arrays of cell or struct. Will modify 'parent'. nDim = nnz(size(s)>1); % is it a scalar, vector, 2D array, 3D cube, etc? switch nDim case 2 % 2D array for r=1:size(s,1) subnode = xml.createElement(Pref.TableName{1}); for c=1:size(s,2) v = s(r,c); if iscell(v), v = v{1}; end struct2DOMnode(xml, subnode, v, Pref.TableName{2}, Pref ); % recursive call end parent.appendChild(subnode); end case 1 %1D array for iItem=1:numel(s) v = s(iItem); if iscell(v), v = v{1}; end struct2DOMnode(xml, parent, v, TagName, Pref ); % recursive call end case 0 % scalar -> this case should never be called if ~isempty(s) if iscell(s), s = s{1}; end struct2DOMnode(xml, parent, s, TagName, Pref ); end end %% ======================================================================= % === var2str Function ================================================== % ======================================================================= function str = var2str(object, PreserveSpace) % convert matlab variables to a string switch (1) case isempty(object) str = ''; case (isnumeric(object) || islogical(object)) if ndims(object)>2, object=object(:); end % can't handle arrays with dimention > 2 str=mat2str(object); % convert matrix to a string % mark logical scalars with [] (logical arrays already have them) so the xml_read % recognizes them as MATLAB objects instead of strings. Same with sparse % matrices if ((islogical(object) && isscalar(object)) || issparse(object)), str = ['[' str ']']; end if (isinteger(object)), str = ['[', class(object), '(', str ')]']; end case iscell(object) if ndims(object)>2, object=object(:); end % can't handle cell arrays with dimention > 2 [nr nc] = size(object); obj2 = object; for i=1:length(object(:)) str = var2str(object{i}, PreserveSpace); if (ischar(object{i})), object{i} = ['''' object{i} '''']; else object{i}=str; end obj2{i} = [object{i} ',']; end for r = 1:nr, obj2{r,nc} = [object{r,nc} ';']; end obj2 = obj2.'; str = ['{' obj2{:} '}']; case isstruct(object) str=''; warning('xml_io_tools:write:var2str', ... 'Struct was encountered where string was expected. Ignoring.'); case isa(object, 'function_handle') str = ['[@' char(object) ']']; case ischar(object) str = object; otherwise str = char(object); end %% string clean-up str=str(:); str=str.'; % make sure this is a row vector of char's if (~isempty(str)) str(str<32|str==127)=' '; % convert no-printable characters to spaces if (~PreserveSpace) str = strtrim(str); % remove spaces from begining and the end str = regexprep(str,'\s+',' '); % remove multiple spaces end end %% ======================================================================= % === var2Namestr Function ============================================== % ======================================================================= function str = varName2str(str) % convert matlab variable names to a sting str = char(str); p = strfind(str,'0x'); if (~isempty(p)) for i=1:length(p) before = str( p(i)+(0:3) ); % string to replace after = char(hex2dec(before(3:4))); % string to replace with str = regexprep(str,before,after, 'once', 'ignorecase'); p=p-3; % since 4 characters were replaced with one - compensate end end str = regexprep(str,'_COLON_',':', 'once', 'ignorecase'); str = regexprep(str,'_DASH_' ,'-', 'once', 'ignorecase');
github
dschick/udkm1DsimML-master
xml_read.m
.m
udkm1DsimML-master/helpers/functions/xml_io_tools/xml_read.m
23,864
utf_8
5bba7e1f07a293d773aed5616ad3d5c9
function [tree, RootName, DOMnode] = xml_read(xmlfile, Pref) %XML_READ reads xml files and converts them into Matlab's struct tree. % % DESCRIPTION % tree = xml_read(xmlfile) reads 'xmlfile' into data structure 'tree' % % tree = xml_read(xmlfile, Pref) reads 'xmlfile' into data structure 'tree' % according to your preferences % % [tree, RootName, DOMnode] = xml_read(xmlfile) get additional information % about XML file % % INPUT: % xmlfile URL or filename of xml file to read % Pref Preferences: % Pref.ItemName - default 'item' - name of a special tag used to itemize % cell arrays % Pref.ReadAttr - default true - allow reading attributes % Pref.ReadSpec - default true - allow reading special nodes % Pref.Str2Num - default 'smart' - convert strings that look like numbers % to numbers. Options: "always", "never", and "smart" % Pref.KeepNS - default true - keep or strip namespace info % Pref.NoCells - default true - force output to have no cell arrays % Pref.Debug - default false - show mode specific error messages % Pref.NumLevels- default infinity - how many recursive levels are % allowed. Can be used to speed up the function by prunning the tree. % Pref.RootOnly - default true - output variable 'tree' corresponds to % xml file root element, otherwise it correspond to the whole file. % Pref.CellItem - default 'true' - leave 'item' nodes in cell notation. % OUTPUT: % tree tree of structs and/or cell arrays corresponding to xml file % RootName XML tag name used for root (top level) node. % Optionally it can be a string cell array storing: Name of % root node, document "Processing Instructions" data and % document "comment" string % DOMnode output of xmlread % % DETAILS: % Function xml_read first calls MATLAB's xmlread function and than % converts its output ('Document Object Model' tree of Java objects) % to tree of MATLAB struct's. The output is in format of nested structs % and cells. In the output data structure field names are based on % XML tags, except in cases when tags produce illegal variable names. % % Several special xml node types result in special tags for fields of % 'tree' nodes: % - node.CONTENT - stores data section of the node if other fields are % present. Usually data section is stored directly in 'node'. % - node.ATTRIBUTE.name - stores node's attribute called 'name'. % - node.COMMENT - stores node's comment section (string). For global % comments see "RootName" output variable. % - node.CDATA_SECTION - stores node's CDATA section (string). % - node.PROCESSING_INSTRUCTIONS - stores "processing instruction" child % node. For global "processing instructions" see "RootName" output variable. % - other special node types like: document fragment nodes, document type % nodes, entity nodes, notation nodes and processing instruction nodes % will be treated like regular nodes % % EXAMPLES: % MyTree=[]; % MyTree.MyNumber = 13; % MyTree.MyString = 'Hello World'; % xml_write('test.xml', MyTree); % [tree treeName] = xml_read ('test.xml'); % disp(treeName) % gen_object_display() % % See also xml_examples.m % % See also: % xml_write, xmlread, xmlwrite % % Written by Jarek Tuszynski, SAIC, jaroslaw.w.tuszynski_at_saic.com % References: % - Function inspired by Example 3 found in xmlread function. % - Output data structures inspired by xml_toolbox structures. %% default preferences DPref.TableName = {'tr','td'}; % name of a special tags used to itemize 2D cell arrays DPref.ItemName = 'item'; % name of a special tag used to itemize 1D cell arrays DPref.CellItem = false; % leave 'item' nodes in cell notation DPref.ReadAttr = true; % allow reading attributes DPref.ReadSpec = true; % allow reading special nodes: comments, CData, etc. DPref.KeepNS = true; % Keep or strip namespace info DPref.Str2Num = 'smart';% convert strings that look like numbers to numbers DPref.NoCells = true; % force output to have no cell arrays DPref.NumLevels = 1e10; % number of recurence levels DPref.PreserveSpace = false; % Preserve or delete spaces at the beggining and the end of stings? RootOnly = true; % return root node with no top level special nodes Debug = false; % show specific errors (true) or general (false)? tree = []; RootName = []; %% Check Matlab Version v = ver('MATLAB'); version = str2double(regexp(v.Version, '\d.\d','match','once')); if (version<7.1) error('Your MATLAB version is too old. You need version 7.1 or newer.'); end %% read user preferences if (nargin>1) if (isfield(Pref, 'TableName')), DPref.TableName = Pref.TableName; end if (isfield(Pref, 'ItemName' )), DPref.ItemName = Pref.ItemName; end if (isfield(Pref, 'CellItem' )), DPref.CellItem = Pref.CellItem; end if (isfield(Pref, 'Str2Num' )), DPref.Str2Num = Pref.Str2Num ; end if (isfield(Pref, 'NoCells' )), DPref.NoCells = Pref.NoCells ; end if (isfield(Pref, 'NumLevels')), DPref.NumLevels = Pref.NumLevels; end if (isfield(Pref, 'ReadAttr' )), DPref.ReadAttr = Pref.ReadAttr; end if (isfield(Pref, 'ReadSpec' )), DPref.ReadSpec = Pref.ReadSpec; end if (isfield(Pref, 'KeepNS' )), DPref.KeepNS = Pref.KeepNS; end if (isfield(Pref, 'RootOnly' )), RootOnly = Pref.RootOnly; end if (isfield(Pref, 'Debug' )), Debug = Pref.Debug ; end if (isfield(Pref, 'PreserveSpace')), DPref.PreserveSpace = Pref.PreserveSpace; end end if ischar(DPref.Str2Num), % convert from character description to numbers DPref.Str2Num = find(strcmpi(DPref.Str2Num, {'never', 'smart', 'always'}))-1; if isempty(DPref.Str2Num), DPref.Str2Num=1; end % 1-smart by default end %% read xml file using Matlab function if isa(xmlfile, 'org.apache.xerces.dom.DeferredDocumentImpl'); % if xmlfile is a DOMnode than skip the call to xmlread try try DOMnode = xmlfile; catch ME error('Invalid DOM node: \n%s.', getReport(ME)); end catch %#ok<CTCH> catch for mablab versions prior to 7.5 error('Invalid DOM node. \n'); end else % we assume xmlfile is a filename if (Debug) % in debuging mode crashes are allowed DOMnode = xmlread(xmlfile); else % in normal mode crashes are not allowed try try DOMnode = xmlread(xmlfile); catch ME error('Failed to read XML file %s: \n%s',xmlfile, getReport(ME)); end catch %#ok<CTCH> catch for mablab versions prior to 7.5 error('Failed to read XML file %s\n',xmlfile); end end end Node = DOMnode.getFirstChild; %% Find the Root node. Also store data from Global Comment and Processing % Instruction nodes, if any. GlobalTextNodes = cell(1,3); GlobalProcInst = []; GlobalComment = []; GlobalDocType = []; while (~isempty(Node)) if (Node.getNodeType==Node.ELEMENT_NODE) RootNode=Node; elseif (Node.getNodeType==Node.PROCESSING_INSTRUCTION_NODE) data = strtrim(char(Node.getData)); target = strtrim(char(Node.getTarget)); GlobalProcInst = [target, ' ', data]; GlobalTextNodes{2} = GlobalProcInst; elseif (Node.getNodeType==Node.COMMENT_NODE) GlobalComment = strtrim(char(Node.getData)); GlobalTextNodes{3} = GlobalComment; % elseif (Node.getNodeType==Node.DOCUMENT_TYPE_NODE) % GlobalTextNodes{4} = GlobalDocType; end Node = Node.getNextSibling; end %% parse xml file through calls to recursive DOMnode2struct function if (Debug) % in debuging mode crashes are allowed [tree RootName] = DOMnode2struct(RootNode, DPref, 1); else % in normal mode crashes are not allowed try try [tree RootName] = DOMnode2struct(RootNode, DPref, 1); catch ME error('Unable to parse XML file %s: \n %s.',xmlfile, getReport(ME)); end catch %#ok<CTCH> catch for mablab versions prior to 7.5 error('Unable to parse XML file %s.',xmlfile); end end %% If there were any Global Text nodes than return them if (~RootOnly) if (~isempty(GlobalProcInst) && DPref.ReadSpec) t.PROCESSING_INSTRUCTION = GlobalProcInst; end if (~isempty(GlobalComment) && DPref.ReadSpec) t.COMMENT = GlobalComment; end if (~isempty(GlobalDocType) && DPref.ReadSpec) t.DOCUMENT_TYPE = GlobalDocType; end t.(RootName) = tree; tree=t; end if (~isempty(GlobalTextNodes)) GlobalTextNodes{1} = RootName; RootName = GlobalTextNodes; end %% ======================================================================= % === DOMnode2struct Function =========================================== % ======================================================================= function [s TagName LeafNode] = DOMnode2struct(node, Pref, level) %% === Step 1: Get node name and check if it is a leaf node ============== [TagName LeafNode] = NodeName(node, Pref.KeepNS); s = []; % initialize output structure %% === Step 2: Process Leaf Nodes (nodes with no children) =============== if (LeafNode) if (LeafNode>1 && ~Pref.ReadSpec), LeafNode=-1; end % tags only so ignore special nodes if (LeafNode>0) % supported leaf node types try try % use try-catch: errors here are often due to VERY large fields (like images) that overflow java memory s = char(node.getData); if (isempty(s)), s = ' '; end % make it a string % for some reason current xmlread 'creates' a lot of empty text % fields with first chatacter=10 - those will be deleted. if (~Pref.PreserveSpace || s(1)==10) if (isspace(s(1)) || isspace(s(end))), s = strtrim(s); end % trim speces is any end if (LeafNode==1), s=str2var(s, Pref.Str2Num, 0); end % convert to number(s) if needed catch ME % catch for mablab versions 7.5 and higher warning('xml_io_tools:read:LeafRead', ... 'This leaf node could not be read and was ignored. '); getReport(ME) end catch %#ok<CTCH> catch for mablab versions prior to 7.5 warning('xml_io_tools:read:LeafRead', ... 'This leaf node could not be read and was ignored. '); end end if (LeafNode==3) % ProcessingInstructions need special treatment target = strtrim(char(node.getTarget)); s = [target, ' ', s]; end return % We are done the rest of the function deals with nodes with children end if (level>Pref.NumLevels+1), return; end % if Pref.NumLevels is reached than we are done %% === Step 3: Process nodes with children =============================== if (node.hasChildNodes) % children present Child = node.getChildNodes; % create array of children nodes nChild = Child.getLength; % number of children % --- pass 1: how many children with each name ----------------------- f = []; for iChild = 1:nChild % read in each child [cname cLeaf] = NodeName(Child.item(iChild-1), Pref.KeepNS); if (cLeaf<0), continue; end % unsupported leaf node types if (~isfield(f,cname)), f.(cname)=0; % initialize first time I see this name end f.(cname) = f.(cname)+1; % add to the counter end % end for iChild % text_nodes become CONTENT & for some reason current xmlread 'creates' a % lot of empty text fields so f.CONTENT value should not be trusted if (isfield(f,'CONTENT') && f.CONTENT>2), f.CONTENT=2; end % --- pass 2: store all the children as struct of cell arrays ---------- for iChild = 1:nChild % read in each child [c cname cLeaf] = DOMnode2struct(Child.item(iChild-1), Pref, level+1); if (cLeaf && isempty(c)) % if empty leaf node than skip continue; % usually empty text node or one of unhandled node types elseif (nChild==1 && cLeaf==1) s=c; % shortcut for a common case else % if normal node if (level>Pref.NumLevels), continue; end n = f.(cname); % how many of them in the array so far? if (~isfield(s,cname)) % encountered this name for the first time if (n==1) % if there will be only one of them ... s.(cname) = c; % than save it in format it came in else % if there will be many of them ... s.(cname) = cell(1,n); s.(cname){1} = c; % than save as cell array end f.(cname) = 1; % initialize the counter else % already have seen this name s.(cname){n+1} = c; % add to the array f.(cname) = n+1; % add to the array counter end end end % for iChild end % end if (node.hasChildNodes) %% === Step 4: Post-process struct's created for nodes with children ===== if (isstruct(s)) fields = fieldnames(s); nField = length(fields); % Detect structure that looks like Html table and store it in cell Matrix if (nField==1 && strcmpi(fields{1},Pref.TableName{1})) tr = s.(Pref.TableName{1}); fields2 = fieldnames(tr{1}); if (length(fields2)==1 && strcmpi(fields2{1},Pref.TableName{2})) % This seems to be a special structure such that for % Pref.TableName = {'tr','td'} 's' corresponds to % <tr> <td>M11</td> <td>M12</td> </tr> % <tr> <td>M12</td> <td>M22</td> </tr> % Recognize it as encoding for 2D struct nr = length(tr); for r = 1:nr row = tr{r}.(Pref.TableName{2}); Table(r,1:length(row)) = row; %#ok<AGROW> end s = Table; end end % --- Post-processing: convert 'struct of cell-arrays' to 'array of structs' % Example: let say s has 3 fields s.a, s.b & s.c and each field is an % cell-array with more than one cell-element and all 3 have the same length. % Then change it to array of structs, each with single cell. % This way element s.a{1} will be now accessed through s(1).a vec = zeros(size(fields)); for i=1:nField, vec(i) = f.(fields{i}); end if (numel(vec)>1 && vec(1)>1 && var(vec)==0) % convert from struct of s = cell2struct(struct2cell(s), fields, 1); % arrays to array of struct end % if anyone knows better way to do above conversion please let me know. end %% === Step 5: Process nodes with attributes ============================= if (node.hasAttributes && Pref.ReadAttr) if (~isstruct(s)), % make into struct if is not already ss.CONTENT=s; s=ss; end Attr = node.getAttributes; % list of all attributes for iAttr = 1:Attr.getLength % for each attribute name = char(Attr.item(iAttr-1).getName); % attribute name name = str2varName(name, Pref.KeepNS); % fix name if needed value = char(Attr.item(iAttr-1).getValue); % attribute value value = str2var(value, Pref.Str2Num, 1); % convert to number if possible s.ATTRIBUTE.(name) = value; % save again end % end iAttr loop end % done with attributes if (~isstruct(s)), return; end %The rest of the code deals with struct's %% === Post-processing: fields of "s" % convert 'cell-array of structs' to 'arrays of structs' fields = fieldnames(s); % get field names nField = length(fields); for iItem=1:length(s) % for each struct in the array - usually one for iField=1:length(fields) field = fields{iField}; % get field name % if this is an 'item' field and user want to leave those as cells % than skip this one if (strcmpi(field, Pref.ItemName) && Pref.CellItem), continue; end x = s(iItem).(field); if (iscell(x) && all(cellfun(@isstruct,x(:))) && numel(x)>1) % it's cell-array of structs % numel(x)>1 check is to keep 1 cell-arrays created when Pref.CellItem=1 try % this operation fails sometimes % example: change s(1).a{1}.b='jack'; s(1).a{2}.b='john'; to % more convinient s(1).a(1).b='jack'; s(1).a(2).b='john'; s(iItem).(field) = [x{:}]'; %#ok<AGROW> % converted to arrays of structs catch %#ok<CTCH> % above operation will fail if s(1).a{1} and s(1).a{2} have % different fields. If desired, function forceCell2Struct can force % them to the same field structure by adding empty fields. if (Pref.NoCells) s(iItem).(field) = forceCell2Struct(x); %#ok<AGROW> end end % end catch end end end %% === Step 4: Post-process struct's created for nodes with children ===== % --- Post-processing: remove special 'item' tags --------------------- % many xml writes (including xml_write) use a special keyword to mark % arrays of nodes (see xml_write for examples). The code below converts % s.item to s.CONTENT ItemContent = false; if (isfield(s,Pref.ItemName)) s.CONTENT = s.(Pref.ItemName); s = rmfield(s,Pref.ItemName); ItemContent = Pref.CellItem; % if CellItem than keep s.CONTENT as cells end % --- Post-processing: clean up CONTENT tags --------------------- % if s.CONTENT is a cell-array with empty elements at the end than trim % the length of this cell-array. Also if s.CONTENT is the only field than % remove .CONTENT part and store it as s. if (isfield(s,'CONTENT')) if (iscell(s.CONTENT) && isvector(s.CONTENT)) x = s.CONTENT; for i=numel(x):-1:1, if ~isempty(x{i}), break; end; end if (i==1 && ~ItemContent) s.CONTENT = x{1}; % delete cell structure else s.CONTENT = x(1:i); % delete empty cells end end if (nField==1) if (ItemContent) ss = s.CONTENT; % only child: remove a level but ensure output is a cell-array s=[]; s{1}=ss; else s = s.CONTENT; % only child: remove a level end end end %% ======================================================================= % === forceCell2Struct Function ========================================= % ======================================================================= function s = forceCell2Struct(x) % Convert cell-array of structs, where not all of structs have the same % fields, to a single array of structs %% Convert 1D cell array of structs to 2D cell array, where each row % represents item in original array and each column corresponds to a unique % field name. Array "AllFields" store fieldnames for each column AllFields = fieldnames(x{1}); % get field names of the first struct CellMat = cell(length(x), length(AllFields)); for iItem=1:length(x) fields = fieldnames(x{iItem}); % get field names of the next struct for iField=1:length(fields) % inspect all fieldnames and find those field = fields{iField}; % get field name col = find(strcmp(field,AllFields),1); if isempty(col) % no column for such fieldname yet AllFields = [AllFields; field]; %#ok<AGROW> col = length(AllFields); % create a new column for it end CellMat{iItem,col} = x{iItem}.(field); % store rearanged data end end %% Convert 2D cell array to array of structs s = cell2struct(CellMat, AllFields, 2); %% ======================================================================= % === str2var Function ================================================== % ======================================================================= function val=str2var(str, option, attribute) % Can this string 'str' be converted to a number? if so than do it. val = str; len = numel(str); if (len==0 || option==0), return; end % Str2Num="never" of empty string -> do not do enything if (len>10000 && option==1), return; end % Str2Num="smart" and string is very long -> probably base64 encoded binary digits = '(Inf)|(NaN)|(pi)|[\t\n\d\+\-\*\.ei EI\;\,]'; s = regexprep(str, digits, ''); % remove all the digits and other allowed characters if (~all(~isempty(s))) % if nothing left than this is probably a number if (~isempty(strfind(str, ' '))), option=2; end %if str has white-spaces assume by default that it is not a date string if (~isempty(strfind(str, '['))), option=2; end % same with brackets str(strfind(str, '\n')) = ';';% parse data tables into 2D arrays, if any if (option==1) % the 'smart' option try % try to convert to a date, like 2007-12-05 datenum(str); % if successful than leave it as string catch %#ok<CTCH> % if this is not a date than ... option=2; % ... try converting to a number end end if (option==2) if (attribute) num = str2double(str); % try converting to a single number using sscanf function if isnan(num), return; end % So, it wasn't really a number after all else num = str2num(str); %#ok<ST2NM> % try converting to a single number or array using eval function end if(isnumeric(num) && numel(num)>0), val=num; end % if convertion to a single was succesful than save end elseif ((str(1)=='[' && str(end)==']') || (str(1)=='{' && str(end)=='}')) % this looks like a (cell) array encoded as a string try val = eval(str); catch %#ok<CTCH> val = str; end elseif (~attribute) % see if it is a boolean array with no [] brackets str1 = lower(str); str1 = strrep(str1, 'false', '0'); str1 = strrep(str1, 'true' , '1'); s = regexprep(str1, '[01 \;\,]', ''); % remove all 0/1, spaces, commas and semicolons if (~all(~isempty(s))) % if nothing left than this is probably a boolean array num = str2num(str1); %#ok<ST2NM> if(isnumeric(num) && numel(num)>0), val = (num>0); end % if convertion was succesful than save as logical end end %% ======================================================================= % === str2varName Function ============================================== % ======================================================================= function str = str2varName(str, KeepNS) % convert a sting to a valid matlab variable name if(KeepNS) str = regexprep(str,':','_COLON_', 'once', 'ignorecase'); else k = strfind(str,':'); if (~isempty(k)) str = str(k+1:end); end end str = regexprep(str,'-','_DASH_' ,'once', 'ignorecase'); if (~isvarname(str)) && (~iskeyword(str)) str = genvarname(str); end %% ======================================================================= % === NodeName Function ================================================= % ======================================================================= function [Name LeafNode] = NodeName(node, KeepNS) % get node name and make sure it is a valid variable name in Matlab. % also get node type: % LeafNode=0 - normal element node, % LeafNode=1 - text node % LeafNode=2 - supported non-text leaf node, % LeafNode=3 - supported processing instructions leaf node, % LeafNode=-1 - unsupported non-text leaf node switch (node.getNodeType) case node.ELEMENT_NODE Name = char(node.getNodeName);% capture name of the node Name = str2varName(Name, KeepNS); % if Name is not a good variable name - fix it LeafNode = 0; case node.TEXT_NODE Name = 'CONTENT'; LeafNode = 1; case node.COMMENT_NODE Name = 'COMMENT'; LeafNode = 2; case node.CDATA_SECTION_NODE Name = 'CDATA_SECTION'; LeafNode = 2; case node.DOCUMENT_TYPE_NODE Name = 'DOCUMENT_TYPE'; LeafNode = 2; case node.PROCESSING_INSTRUCTION_NODE Name = 'PROCESSING_INSTRUCTION'; LeafNode = 3; otherwise NodeType = {'ELEMENT','ATTRIBUTE','TEXT','CDATA_SECTION', ... 'ENTITY_REFERENCE', 'ENTITY', 'PROCESSING_INSTRUCTION', 'COMMENT',... 'DOCUMENT', 'DOCUMENT_TYPE', 'DOCUMENT_FRAGMENT', 'NOTATION'}; Name = char(node.getNodeName);% capture name of the node warning('xml_io_tools:read:unkNode', ... 'Unknown node type encountered: %s_NODE (%s)', NodeType{node.getNodeType}, Name); LeafNode = -1; end
github
happynear/MTCNN_face_detection_alignment-master
test.m
.m
MTCNN_face_detection_alignment-master/code/codes/camera_demo/test.m
8,824
utf_8
484a3e8719f2102fd5aa6c841209b5ed
function varargout = test(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @test_OpeningFcn, ... 'gui_OutputFcn', @test_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end function test_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); function varargout = test_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; function pushbutton1_Callback(hObject, eventdata, handles) threshold=[0.6 0.7 str2num(get(findobj('tag','edit4'),'string'))] factor=0.709; minsize=str2num(get(findobj('tag','edit6'),'string')); stop=0.03; mypath=get(findobj('tag','edit1'),'string') addpath(mypath); caffe.reset_all(); caffe.set_mode_cpu(); mypath=get(findobj('tag','edit3'),'string') addpath(mypath); cameraid=get(findobj('tag','edit2'),'string') camera=imaqhwinfo; camera=camera.InstalledAdaptors{str2num(cameraid)} vid1= videoinput(camera,1,get(findobj('tag','edit5'),'string')); warning off all usbVidRes1=get(vid1,'videoResolution'); nBands1=get(vid1,'NumberOfBands'); hImage1=imshow(zeros(usbVidRes1(2),usbVidRes1(1),nBands1)); preview(vid1,hImage1); prototxt_dir = './model/det1.prototxt'; model_dir = './model/det1.caffemodel'; PNet=caffe.Net(prototxt_dir,model_dir,'test'); prototxt_dir = './model/det2.prototxt'; model_dir = './model/det2.caffemodel'; RNet=caffe.Net(prototxt_dir,model_dir,'test'); prototxt_dir = './model/det3.prototxt'; model_dir = './model/det3.caffemodel'; ONet=caffe.Net(prototxt_dir,model_dir,'test'); prototxt_dir = './model/det4.prototxt'; model_dir = './model/det4.caffemodel'; LNet=caffe.Net(prototxt_dir,model_dir,'test'); rec=rectangle('Position',[1 1 1 1],'Edgecolor','r'); while (1) img=getsnapshot(vid1); [total_boxes point]=detect_face(img,minsize,PNet,RNet,ONet,threshold,false,factor); try delete(rec); catch end numbox=size(total_boxes,1); for j=1:numbox; rec(j)=rectangle('Position',[total_boxes(j,1:2) total_boxes(j,3:4)-total_boxes(j,1:2)],'Edgecolor','g','LineWidth',3); rec(6*numbox+j)=rectangle('Position',[point(1,j),point(6,j),5,5],'Curvature',[1,1],'FaceColor','g','LineWidth',3); rec(12*numbox+j)=rectangle('Position',[point(2,j),point(7,j),5,5],'Curvature',[1,1],'FaceColor','g','LineWidth',3); rec(18*numbox+j)=rectangle('Position',[point(3,j),point(8,j),5,5],'Curvature',[1,1],'FaceColor','g','LineWidth',3); rec(24*numbox+j)=rectangle('Position',[point(4,j),point(9,j),5,5],'Curvature',[1,1],'FaceColor','g','LineWidth',3); rec(30*numbox+j)=rectangle('Position',[point(5,j),point(10,j),5,5],'Curvature',[1,1],'FaceColor','g','LineWidth',3); end pause(stop) end function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double % --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit6_Callback(hObject, eventdata, handles) % hObject handle to edit6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit6 as text % str2double(get(hObject,'String')) returns contents of edit6 as a double % --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
github
UCL-SML/pilco-matlab-master
print_pdf.m
.m
pilco-matlab-master/doc/plots/print_pdf.m
7,570
utf_8
97a41030f45e2c5d10cc569c07e12a19
%PRINT_PDF Prints cropped figures to pdf with fonts embedded % % Examples: % print_pdf filename % print_pdf(filename, fig_handle) % % This function saves a figure as a pdf nicely, without the need to specify % multiple options. It improves on MATLAB's print command (using default % options) in several ways: % - The figure borders are cropped % - Fonts are embedded (as subsets) % - Lossless compression is used on vector graphics % - High quality jpeg compression is used on bitmaps % - Dotted/dashed line dash lengths vary with line width (as on screen) % - Grid lines given their own dot style, instead of dashed % % This function requires that you have ghostscript installed on your system % and that the executable binary is on your system's path. Ghostscript can % be downloaded from: http://www.ghostscript.com % %IN: % filename - string containing the name (optionally including full or % relative path) of the file the figure is to be saved as. A % ".pdf" extension is added if not there already. If a path is % not specified, the figure is saved in the current directory. % fig_handle - The handle of the figure to be saved. Default: current % figure. % % Copyright (C) Oliver Woodford 2008 % This function is inspired by Peder Axensten's SAVEFIG (fex id: 10889) % which is itself inspired by EPS2PDF (fex id: 5782) % The idea of editing the EPS file to change line styles comes from Jiro % Doke's FIXPSLINESTYLE (fex id: 17928) % The idea of changing dash length with line width came from comments on % fex id: 5743, but the implementation is mine :) % $Id: print_pdf.m,v 1.25 2008/12/15 16:52:07 ojw Exp $ function print_pdf(name, fig) if nargin < 2 fig = gcf; end % Set paper size % set(fig, 'PaperPositionMode', 'auto'); % Print to eps file tmp_nam = [tempname '.eps']; print(fig, '-depsc2', '-painters', '-r864', tmp_nam); % Fix the line styles fix_lines(tmp_nam); % Construct the filename if numel(name) < 5 || ~strcmpi(name(end-3:end), '.pdf') name = [name '.pdf']; % Add the missing extension end % Construct the command string for ghostscript. This assumes that the % ghostscript binary is on your path - you can also give the complete path, % e.g. cmd = '"C:\Program Files\gs\gs8.63\bin\gswin32c.exe"'; cmd = 'gs'; if ispc cmd = [cmd 'win32c.exe']; end options = [' -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile="' name '" -f "' tmp_nam '"']; % Convert to pdf [status result] = system([cmd options]); % Check status if status % Something went wrong if isempty(strfind(result, 'not recognized')) fprintf('%s\n', result); else % Ghostscript isn't on the path - try to find it cmd = find_ghostscript; if isempty(cmd) fprintf('Ghostscript not found.\n'); else system([cmd options]); end end end % Delete the temporary file delete(tmp_nam); return function cmd = find_ghostscript % Find the full path to a ghostscript executable cmd = ''; if ispc % For Windows, look in the default location default_location = 'C:\Program Files\gs\'; executable = '\bin\gswin32c.exe'; else % This case isn't supported. Contact me if you have a fix. return end dir_list = dir(default_location); ver_num = 0; for a = 1:numel(dir_list) % If there are multiple versions, use the newest ver_num2 = sscanf(dir_list(a).name, 'gs%g'); if ~isempty(ver_num2) && ver_num2 > ver_num cmd2 = [default_location dir_list(a).name executable]; if exist(cmd2, 'file') == 2 cmd = ['"' cmd2 '"']; ver_num = ver_num2; end end end return function fix_lines(fname) % Improve the style of lines used and set grid lines to an entirely new % style using dots, not dashes % Read in the file fh = fopen(fname, 'rt'); fstrm = char(fread(fh, '*uint8')'); fclose(fh); % Make sure all line width commands come before the line style definitions, % so that dash lengths can be based on the correct widths % Find all line style sections ind = [regexp(fstrm, '[\n\r]SO[\n\r]'),... % This needs to be here even though it doesn't have dots/dashes! regexp(fstrm, '[\n\r]DO[\n\r]'),... regexp(fstrm, '[\n\r]DA[\n\r]'),... regexp(fstrm, '[\n\r]DD[\n\r]')]; ind = sort(ind); % Find line width commands [ind2 ind3] = regexp(fstrm, '[\n\r]\d* w[\n\r]', 'start', 'end'); % Go through each line style section and swap with any line width commands % near by b = 1; m = numel(ind); n = numel(ind2); for a = 1:m % Go forwards width commands until we pass the current line style while b <= n && ind2(b) < ind(a) b = b + 1; end if b > n % No more width commands break; end % Check we haven't gone past another line style (including SO!) if a < m && ind2(b) > ind(a+1) continue; end % Are the commands close enough to be confident we can swap them? if (ind2(b) - ind(a)) > 8 continue; end % Move the line style command below the line width command fstrm(ind(a)+1:ind3(b)) = [fstrm(ind(a)+4:ind3(b)) fstrm(ind(a)+1:ind(a)+3)]; b = b + 1; end % Find any grid line definitions and change to GR format % Find the DO sections again as they may have moved ind = int32(regexp(fstrm, '[\n\r]DO[\n\r]')); if ~isempty(ind) % Find all occurrences of what are believed to be axes and grid lines ind2 = int32(regexp(fstrm, '[\n\r] *\d* *\d* *mt *\d* *\d* *L[\n\r]')); if ~isempty(ind2) % Now see which DO sections come just before axes and grid lines ind2 = repmat(ind2', [1 numel(ind)]) - repmat(ind, [numel(ind2) 1]); ind2 = any(ind2 > 0 & ind2 < 12); % 12 chars seems about right ind = ind(ind2); % Change any regions we believe to be grid lines to GR fstrm(ind+1) = 'G'; fstrm(ind+2) = 'R'; end end % Isolate line style definition section first_sec = findstr(fstrm, '% line types:'); [second_sec remaining] = strtok(fstrm(first_sec+1:end), '/'); [dummy remaining] = strtok(remaining, '%'); % Define the new styles, including the new GR format % Dot and dash lengths have two parts: a constant amount plus a line width % variable amount. The constant amount comes after dpi2point, and the % variable amount comes after currentlinewidth. If you want to change % dot/dash lengths for a one particular line style only, edit the numbers % in the /DO (dotted lines), /DA (dashed lines), /DD (dot dash lines) and % /GR (grid lines) lines for the style you want to change. new_style = {'/dom { dpi2point 1 currentlinewidth 0.08 mul add mul mul } bdef',... % Dot length macro based on line width '/dam { dpi2point 2 currentlinewidth 0.04 mul add mul mul } bdef',... % Dash length macro based on line width '/SO { [] 0 setdash 0 setlinecap } bdef',... % Solid lines '/DO { [1 dom 1.2 dom] 0 setdash 0 setlinecap } bdef',... % Dotted lines '/DA { [4 dam 1.5 dam] 0 setdash 0 setlinecap } bdef',... % Dashed lines '/DD { [1 dom 1.2 dom 4 dam 1.2 dom] 0 setdash 0 setlinecap } bdef',... % Dot dash lines '/GR { [0 dpi2point mul 4 dpi2point mul] 0 setdash 1 setlinecap } bdef'}; % Grid lines - dot spacing remains constant new_style = sprintf('%s\r', new_style{:}); % Save the file with the section replaced fh = fopen(fname, 'wt'); fprintf(fh, '%s%s%s%s', fstrm(1:first_sec), second_sec, new_style, remaining); fclose(fh); fprintf('pdf successfully printed\n'); return
github
UCL-SML/pilco-matlab-master
draw_pendubot.m
.m
pilco-matlab-master/scenarios/pendubot/draw_pendubot.m
2,880
utf_8
d1b44901843520801be32a25b7efd3b2
%% draw_pendubot.m % *Summary:* Draw the Pendubot system with reward, applied torque, % and predictive uncertainty of the tips of the pendulums % % function draw_pendubot(theta1, theta2, force, cost, text1, text2, M, S) % % % *Input arguments:* % % theta1 angle of inner pendulum % theta2 angle of outer pendulum % f1 torque applied to inner pendulum % f2 torque applied to outer pendulum % cost cost structure % .fcn function handle (it is assumed to use saturating cost) % .<> other fields that are passed to cost % text1 (optional) text field 1 % text2 (optional) text field 2 % M (optional) mean of state % S (optional) covariance of state % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-08 function draw_pendubot(theta1, theta2, force, cost, text1, text2, M, S) %% Code l = 0.6; xmin = -2*l; xmax = 2*l; umax = 2; height = 0; % Draw double pendulum clf; hold on sth1 = sin(theta1); sth2 = sin(theta2); cth1 = cos(theta1); cth2 = cos(theta2); pendulum1 = [0, 0; -l*sth1, l*cth1]; pendulum2 = [-l*sth1, l*cth1; -l*(sth1-sth2), l*(cth1+cth2)]; plot(pendulum1(:,1), pendulum1(:,2),'r','linewidth',4) plot(pendulum2(:,1), pendulum2(:,2),'r','linewidth',4) % plot target location plot(0,2*l,'k+','MarkerSize',20); plot([xmin, xmax], [-height, -height],'k','linewidth',2) % plot inner joint plot(0,0,'k.','markersize',24) plot(0,0,'y.','markersize',14) % plot outer joint plot(-l*sth1, l*cth1,'k.','markersize',24) plot(-l*sth1, l*cth1,'y.','markersize',14) % plot tip of outer joint plot(-l*(sth1-sth2), l*(cth1+cth2),'k.','markersize',24) plot(-l*(sth1-sth2), l*(cth1+cth2),'y.','markersize',14) plot(0,-2*l,'.w','markersize',0.005) % % Draw sample positions of the joints % if nargin > 6 % samples = gaussian(M,S+1e-8*eye(4),1000); % t1 = samples(3,:); t2 = samples(4,:); % plot(-l*sin(t1),l*cos(t1),'b.','markersize',2) % plot(-l*(sin(t1)-sin(t2)),l*(cos(t1)+cos(t2)),'r.','markersize',2) % end % plot ellipses around tips of pendulums (if M, S exist) try if max(max(S))>0 [M1 S1 M2 S2] = getPlotDistr_pendubot(M, S, l, l); error_ellipse(S1, M1, 'style','b'); % inner pendulum error_ellipse(S2, M2, 'style','r'); % outer pendulum end catch end % Draw useful information % plot applied torque plot([0 force/umax*xmax],[-0.5, -0.5],'g','linewidth',10) % plot immediate reward reward = 1-cost.fcn(cost,[0, 0, theta1, theta2]',zeros(4)); plot([0 reward*xmax],[-0.7, -0.7],'y','linewidth',10) text(0,-0.5,'applied torque (inner joint)') text(0,-0.7,'immediate reward') if exist('text1','var') text(0,-0.9, text1) end if exist('text2','var') text(0,-1.1, text2) end set(gca,'DataAspectRatio',[1 1 1],'XLim',[xmin xmax],'YLim',[-2*l 2*l]); axis off drawnow;
github
UCL-SML/pilco-matlab-master
loss_pendubot.m
.m
pilco-matlab-master/scenarios/pendubot/loss_pendubot.m
4,307
utf_8
acf6555f4c0bb7d9c47e31649d69239e
%% loss_pendubot.m % *Summary:* Pendubot loss function; the loss is % $1-\exp(-0.5*d^2*a)$, where $a>0$ and $d^2$ is the squared difference % between the actual and desired position of the tip of the outer pendulum. % The mean and the variance of the loss are computed by averaging over the % Gaussian distribution of the state $p(x) = \mathcal N(m,s)$ with mean $m$ % and covariance matrix $s$. % Derivatives of these quantities are computed when desired. % % % function [L, dLdm, dLds, S2] = loss_pendubot(cost, m, s) % % % *Input arguments:* % % cost cost structure % .p lengths of the 2 pendulums [2 x 1 ] % .width array of widths of the cost (summed together) % .expl (optional) exploration parameter % .angle (optional) array of angle indices % .target target state [D x 1 ] % m mean of state distribution [D x 1 ] % s covariance matrix for the state distribution [D x D ] % % *Output arguments:* % % L expected cost [1 x 1 ] % dLdm derivative of expected cost wrt. state mean vector [1 x D ] % dLds derivative of expected cost wrt. state covariance matrix [1 x D^2] % S2 variance of cost [1 x 1 ] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-08 % %% High-Level Steps % # Precomputations % # Define static penalty as distance from target setpoint % # Trigonometric augmentation % # Calculate loss function [L, dLdm, dLds, S2] = loss_pendubot(cost, m, s) %% Code if isfield(cost,'width'); cw = cost.width; else cw = 1; end if ~isfield(cost,'expl') || isempty(cost.expl); b = 0; else b = cost.expl; end % 1. Some precomputations D0 = size(s,2); D = D0; % state dimension D1 = D0 + 2*length(cost.angle); % state dimension (with sin/cos) M = zeros(D1,1); M(1:D0) = m; S = zeros(D1); S(1:D0,1:D0) = s; Mdm = [eye(D0); zeros(D1-D0,D0)]; Sdm = zeros(D1*D1,D0); Mds = zeros(D1,D0*D0); Sds = kron(Mdm,Mdm); % 2. Define static penalty as distance from target setpoint ell1 = cost.p(1); ell2 = cost.p(2); C = [ell1 0 ell2 0; 0 ell1 0 ell2]; Q = zeros(D1); Q(D+1:D+4,D+1:D+4) = C'*C; % 3. Trigonometric augmentation if D1-D0 > 0 target = [cost.target(:); gTrig(cost.target(:), 0*s, cost.angle)]; i = 1:D0; k = D0+1:D1; [M(k) S(k,k) C mdm sdm Cdm mds sds Cds] = gTrig(M(i),S(i,i),cost.angle); [S Mdm Mds Sdm Sds] = ... fillIn(S,C,mdm,sdm,Cdm,mds,sds,Cds,Mdm,Sdm,Mds,Sds,i,k,D1); end % 4. Calculate loss L = 0; dLdm = zeros(1,D0); dLds = zeros(1,D0*D0); S2 = 0; for i = 1:length(cw) % scale mixture of immediate costs cost.z = target; cost.W = Q/cw(i)^2; [r rdM rdS s2 s2dM s2dS] = lossSat(cost, M, S); L = L + r; S2 = S2 + s2; dLdm = dLdm + rdM(:)'*Mdm + rdS(:)'*Sdm; dLds = dLds + rdM(:)'*Mds + rdS(:)'*Sds; if (b~=0 || ~isempty(b)) && abs(s2)>1e-12 L = L + b*sqrt(s2); dLdm = dLdm + b/sqrt(s2) * ( s2dM(:)'*Mdm + s2dS(:)'*Sdm )/2; dLds = dLds + b/sqrt(s2) * ( s2dM(:)'*Mds + s2dS(:)'*Sds )/2; end end % normalize n = length(cw); L = L/n; dLdm = dLdm/n; dLds = dLds/n; S2 = S2/n; % Fill in covariance matrix...and derivatives ---------------------------- function [S Mdm Mds Sdm Sds] = ... fillIn(S,C,mdm,sdm,Cdm,mds,sds,Cds,Mdm,Sdm,Mds,Sds,i,k,D) X = reshape(1:D*D,[D D]); XT = X'; % vectorized indices I=0*X; I(i,i)=1; ii=X(I==1)'; I=0*X; I(k,k)=1; kk=X(I==1)'; I=0*X; I(i,k)=1; ik=X(I==1)'; ki=XT(I==1)'; Mdm(k,:) = mdm*Mdm(i,:) + mds*Sdm(ii,:); % chainrule Mds(k,:) = mdm*Mds(i,:) + mds*Sds(ii,:); Sdm(kk,:) = sdm*Mdm(i,:) + sds*Sdm(ii,:); Sds(kk,:) = sdm*Mds(i,:) + sds*Sds(ii,:); dCdm = Cdm*Mdm(i,:) + Cds*Sdm(ii,:); dCds = Cdm*Mds(i,:) + Cds*Sds(ii,:); S(i,k) = S(i,i)*C; S(k,i) = S(i,k)'; % off-diagonal SS = kron(eye(length(k)),S(i,i)); CC = kron(C',eye(length(i))); Sdm(ik,:) = SS*dCdm + CC*Sdm(ii,:); Sdm(ki,:) = Sdm(ik,:); Sds(ik,:) = SS*dCds + CC*Sds(ii,:); Sds(ki,:) = Sds(ik,:);
github
UCL-SML/pilco-matlab-master
dynamics_pendubot.m
.m
pilco-matlab-master/scenarios/pendubot/dynamics_pendubot.m
2,465
utf_8
d04c0a8c0506c14bafcb992ee945135a
%% dynamics_pendubot.m % *Summary:* Implements ths ODE for simulating the Pendubot % dynamics, where an input torque f can be applied to the inner link % % function dz = dynamics_pendubot(t,z,f) % % % *Input arguments:* % % t current time step (called from ODE solver) % z state [4 x 1] % f (optional): torque f(t) applied to inner pendulum % % *Output arguments:* % % dz if 3 input arguments: state derivative wrt time % if only 2 input arguments: total mechanical energy % % Note: It is assumed that the state variables are of the following order: % dtheta1: [rad/s] angular velocity of inner pendulum % dtheta2: [rad/s] angular velocity of outer pendulum % theta1: [rad] angle of inner pendulum % theta2: [rad] angle of outer pendulum % % A detailed derivation of the dynamics can be found in: % % M.P. Deisenroth: % Efficient Reinforcement Learning Using Gaussian Processes, Appendix C, % KIT Scientific Publishing, 2010. % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-08 function dz = dynamics_pendubot(t,z,f) %% Code m1 = 0.5; % [kg] mass of 1st link m2 = 0.5; % [kg] mass of 2nd link b1 = 0.0; % [Ns/m] coefficient of friction (1st joint) b2 = 0.0; % [Ns/m] coefficient of friction (2nd joint) l1 = 0.5; % [m] length of 1st pendulum l2 = 0.5; % [m] length of 2nd pendulum g = 9.82; % [m/s^2] acceleration of gravity I1 = m1*l1^2/12; % moment of inertia around pendulum midpoint (inner link) I2 = m2*l2^2/12; % moment of inertia around pendulum midpoint (outer link) if nargin == 3 % compute time derivatives A = [l1^2*(0.25*m1+m2) + I1, 0.5*m2*l1*l2*cos(z(3)-z(4)); 0.5*m2*l1*l2*cos(z(3)-z(4)), l2^2*0.25*m2 + I2 ]; b = [g*l1*sin(z(3))*(0.5*m1+m2) - 0.5*m2*l1*l2*z(2)^2*sin(z(3)-z(4))... + f(t) - b1*z(1); 0.5*m2*l2*( l1*z(1)^2*sin(z(3)-z(4)) + g*sin(z(4)) ) - b2*z(2)]; x = A\b; dz = zeros(4,1); dz(1) = x(1); dz(2) = x(2); dz(3) = z(1); dz(4) = z(2); else % compute total mechanical energy dz = m1*l1^2*z(1)^2/8 + I1*z(1)^2/2 + m2/2*(l1^2*z(1)^2 ... + l2^2*z(2)^2/4 + l1*l2*z(1)*z(2)*cos(z(3)-z(4))) + I2*z(2)^2/2 ... + m1*g*l1*cos(z(3))/2 + m2*g*(l1*cos(z(3))+l2*cos(z(4))/2); end
github
UCL-SML/pilco-matlab-master
getPlotDistr_pendubot.m
.m
pilco-matlab-master/scenarios/pendubot/getPlotDistr_pendubot.m
2,792
utf_8
90cd4837258b5d69ecce949b34088e6f
%% getPlotDistr_pendubot.m % *Summary:* Compute means and covariances of the Cartesian coordinates of % the tips both the inner and outer pendulum assuming that the joint state % $x$ of the cart-double-pendulum system is Gaussian, i.e., $x\sim N(m, s)$ % % % function [M1, S1, M2, S2] = getPlotDistr_pendubot(m, s, ell1, ell2) % % % % *Input arguments:* % % m mean of full state [6 x 1] % s covariance of full state [6 x 6] % ell1 length of inner pendulum % ell2 length of outer pendulum % % Note: this code assumes that the following order of the state: % 1: pend1 angular velocity, % 2: pend2 angular velocity, % 3: pend1 angle, % 4: pend2 angle % % *Output arguments:* % % M1 mean of tip of inner pendulum [2 x 1] % S1 covariance of tip of inner pendulum [2 x 2] % M2 mean of tip of outer pendulum [2 x 1] % S2 covariance of tip of outer pendulum [2 x 2] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modification: 2013-03-27 % %% High-Level Steps % # Augment input distribution to complex angle representation % # Compute means of tips of pendulums (in Cartesian coordinates) % # Compute covariances of tips of pendulums (in Cartesian coordinates) function [M1, S1, M2, S2] = getPlotDistr_pendubot(m, s, ell1, ell2) %% Code % 1. Augment input distribution [m1 s1 c1] = gTrig(m, s, [3 4], [ell1, ell2]); % map input through sin/cos m1 = [m; m1]; % mean of joint c1 = s*c1; % cross-covariance between input and prediction s1 = [s c1; c1' s1]; % covariance of joint % 2. Compute means of tips of pendulums (in Cartesian coordinates) M1 = [-m1(5); m1(6)]; % [-l*sin(t1), l*cos(t1)] M2 = [-m1(5) + m1(7); m1(6) + m1(8)]; % [-l*(sin(t1)-sin(t2)),l*(cos(t1)+cos(t2))] % 2. Put covariance matrices together (Cart. coord.) % first set of coordinates (tip of 1st pendulum) s11 = s1(5,5); s12 = -s1(5,6); s22 = s1(6,6); S1 = [s11 s12; s12' s22]; % second set of coordinates (tip of 2nd pendulum) s11 = s1(5,5) + s1(7,7) - s1(5,7) - s1(7,5); % ell1*sin(t1) + ell2*sin(t2) s22 = s1(6,6) + s1(8,8) + s1(6,8) + s1(8,6); % ell1*cos(t1) + ell2*cos(t2) s12 = -(s1(5,6) + s1(5,8) + s1(7,6) + s1(7,8)); S2 = [s11 s12; s12' s22]; % make sure we have proper covariances (sometimes numerical problems occur) try chol(S1); catch warning('matrix S1 not pos.def. (getPlotDistr)'); S1 = S1 + (1e-6 - min(eig(S1)))*eye(2); end try chol(S2); catch warning('matrix S2 not pos.def. (getPlotDistr)'); S2 = S2 + (1e-6 - min(eig(S2)))*eye(2); end
github
UCL-SML/pilco-matlab-master
loss_dp.m
.m
pilco-matlab-master/scenarios/doublePendulum/loss_dp.m
4,296
utf_8
5aa6f225ab08ea5144106b58baf9624c
%% loss_dp.m % *Summary:* Double-Pendulum loss function; the loss is % $1-\exp(-0.5*d^2*a)$, where $a>0$ and $d^2$ is the squared difference % between the actual and desired position of the tip of the outer pendulum. % The mean and the variance of the loss are computed by averaging over the % Gaussian distribution of the state $p(x) = \mathcal N(m,s)$ with mean $m$ % and covariance matrix $s$. % Derivatives of these quantities are computed when desired. % % % function [L, dLdm, dLds, S2] = loss_dp(cost, m, s) % % % *Input arguments:* % % cost cost structure % .p lengths of the 2 pendulums [2 x 1 ] % .width array of widths of the cost (summed together) % .expl (optional) exploration parameter % .angle (optional) array of angle indices % .target target state [D x 1 ] % m mean of state distribution [D x 1 ] % s covariance matrix for the state distribution [D x D ] % % *Output arguments:* % % L expected cost [1 x 1 ] % dLdm derivative of expected cost wrt. state mean vector [1 x D ] % dLds derivative of expected cost wrt. state covariance matrix [1 x D^2] % S2 variance of cost [1 x 1 ] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-08 % %% High-Level Steps % # Precomputations % # Define static penalty as distance from target setpoint % # Trigonometric augmentation % # Calculate loss function [L, dLdm, dLds, S2] = loss_dp(cost, m, s) %% Code if isfield(cost,'width'); cw = cost.width; else cw = 1; end if ~isfield(cost,'expl') || isempty(cost.expl); b = 0; else b = cost.expl; end % 1. Some precomputations D0 = size(s,2); D = D0; % state dimension D1 = D0 + 2*length(cost.angle); % state dimension (with sin/cos) M = zeros(D1,1); M(1:D0) = m; S = zeros(D1); S(1:D0,1:D0) = s; Mdm = [eye(D0); zeros(D1-D0,D0)]; Sdm = zeros(D1*D1,D0); Mds = zeros(D1,D0*D0); Sds = kron(Mdm,Mdm); % 2. Define static penalty as distance from target setpoint ell1 = cost.p(1); ell2 = cost.p(2); C = [ell1 0 ell2 0; 0 ell1 0 ell2]; Q = zeros(D1); Q(D+1:D+4,D+1:D+4) = C'*C; % 3. Trigonometric augmentation if D1-D0 > 0 target = [cost.target(:); gTrig(cost.target(:), 0*s, cost.angle)]; i = 1:D0; k = D0+1:D1; [M(k) S(k,k) C mdm sdm Cdm mds sds Cds] = gTrig(M(i),S(i,i),cost.angle); [S Mdm Mds Sdm Sds] = ... fillIn(S,C,mdm,sdm,Cdm,mds,sds,Cds,Mdm,Sdm,Mds,Sds,i,k,D1); end % 4. Calculate loss L = 0; dLdm = zeros(1,D0); dLds = zeros(1,D0*D0); S2 = 0; for i = 1:length(cw) % scale mixture of immediate costs cost.z = target; cost.W = Q/cw(i)^2; [r rdM rdS s2 s2dM s2dS] = lossSat(cost, M, S); L = L + r; S2 = S2 + s2; dLdm = dLdm + rdM(:)'*Mdm + rdS(:)'*Sdm; dLds = dLds + rdM(:)'*Mds + rdS(:)'*Sds; if (b~=0 || ~isempty(b)) && abs(s2)>1e-12 L = L + b*sqrt(s2); dLdm = dLdm + b/sqrt(s2) * ( s2dM(:)'*Mdm + s2dS(:)'*Sdm )/2; dLds = dLds + b/sqrt(s2) * ( s2dM(:)'*Mds + s2dS(:)'*Sds )/2; end end % normalize n = length(cw); L = L/n; dLdm = dLdm/n; dLds = dLds/n; S2 = S2/n; % Fill in covariance matrix...and derivatives ---------------------------- function [S Mdm Mds Sdm Sds] = ... fillIn(S,C,mdm,sdm,Cdm,mds,sds,Cds,Mdm,Sdm,Mds,Sds,i,k,D) X = reshape(1:D*D,[D D]); XT = X'; % vectorized indices I=0*X; I(i,i)=1; ii=X(I==1)'; I=0*X; I(k,k)=1; kk=X(I==1)'; I=0*X; I(i,k)=1; ik=X(I==1)'; ki=XT(I==1)'; Mdm(k,:) = mdm*Mdm(i,:) + mds*Sdm(ii,:); % chainrule Mds(k,:) = mdm*Mds(i,:) + mds*Sds(ii,:); Sdm(kk,:) = sdm*Mdm(i,:) + sds*Sdm(ii,:); Sds(kk,:) = sdm*Mds(i,:) + sds*Sds(ii,:); dCdm = Cdm*Mdm(i,:) + Cds*Sdm(ii,:); dCds = Cdm*Mds(i,:) + Cds*Sds(ii,:); S(i,k) = S(i,i)*C; S(k,i) = S(i,k)'; % off-diagonal SS = kron(eye(length(k)),S(i,i)); CC = kron(C',eye(length(i))); Sdm(ik,:) = SS*dCdm + CC*Sdm(ii,:); Sdm(ki,:) = Sdm(ik,:); Sds(ik,:) = SS*dCds + CC*Sds(ii,:); Sds(ki,:) = Sds(ik,:);
github
UCL-SML/pilco-matlab-master
dynamics_dp.m
.m
pilco-matlab-master/scenarios/doublePendulum/dynamics_dp.m
2,575
utf_8
67e3af4bfc5975be48d8c58ec68c0c33
%% dynamics_dp.m % *Summary:* Implements ths ODE for simulating the double pendulum % dynamics, where an input torque can be applied to both links, % f1:torque at inner joint, f2:torque at outer joint % % function dz = dynamics_dp(t, z, f1, f2) % % % *Input arguments:* % % t current time step (called from ODE solver) % z state [4 x 1] % f1 (optional): torque f1(t) applied to inner pendulum % f2 (optional): torque f2(t) applied to outer pendulum % % *Output arguments:* % % dz if 4 input arguments: state derivative wrt time % if only 2 input arguments: total mechanical energy % % Note: It is assumed that the state variables are of the following order: % dtheta1: [rad/s] angular velocity of inner pendulum % dtheta2: [rad/s] angular velocity of outer pendulum % theta1: [rad] angle of inner pendulum % theta2: [rad] angle of outer pendulum % % A detailed derivation of the dynamics can be found in: % % M.P. Deisenroth: % Efficient Reinforcement Learning Using Gaussian Processes, Appendix C, % KIT Scientific Publishing, 2010. % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-08 function dz = dynamics_dp(t, z, f1, f2) %% Code m1 = 0.5; % [kg] mass of 1st link m2 = 0.5; % [kg] mass of 2nd link b1 = 0.0; % [Ns/m] coefficient of friction (1st joint) b2 = 0.0; % [Ns/m] coefficient of friction (2nd joint) l1 = 0.5; % [m] length of 1st pendulum l2 = 0.5; % [m] length of 2nd pendulum g = 9.82; % [m/s^2] acceleration of gravity I1 = m1*l1^2/12; % moment of inertia around pendulum midpoint (1st link) I2 = m2*l2^2/12; % moment of inertia around pendulum midpoint (2nd link) if nargin == 4 % compute time derivatives A = [l1^2*(0.25*m1+m2) + I1, 0.5*m2*l1*l2*cos(z(3)-z(4)); 0.5*m2*l1*l2*cos(z(3)-z(4)), l2^2*0.25*m2 + I2 ]; b = [g*l1*sin(z(3))*(0.5*m1+m2) - 0.5*m2*l1*l2*z(2)^2*sin(z(3)-z(4)) ... + f1(t)-b1*z(1); 0.5*m2*l2*(l1*z(1)^2*sin(z(3)-z(4))+g*sin(z(4))) + f2(t)-b2*z(2)]; x = A\b; dz = zeros(4,1); dz(1) = x(1); dz(2) = x(2); dz(3) = z(1); dz(4) = z(2); else % compute total mechanical energy dz = m1*l1^2*z(1)^2/8 + I1*z(1)^2/2 + m2/2*(l1^2*z(1)^2 ... + l2^2*z(2)^2/4 + l1*l2*z(1)*z(2)*cos(z(3)-z(4))) + I2*z(2)^2/2 ... + m1*g*l1*cos(z(3))/2 + m2*g*(l1*cos(z(3))+l2*cos(z(4))/2); end
github
UCL-SML/pilco-matlab-master
draw_dp.m
.m
pilco-matlab-master/scenarios/doublePendulum/draw_dp.m
2,955
utf_8
a367561c45b347a90f121a366b70c407
%% draw_dp.m % *Summary:* Draw the double-pendulum system with reward, applied torques, % and predictive uncertainty of the tips of the pendulums % % function draw_dp(theta1, theta2, f1, f2, cost, text1, text2, M, S) % % *Input arguments:* % % theta1 angle of inner pendulum % theta2 angle of outer pendulum % f1 torque applied to inner pendulum % f2 torque applied to outer pendulum % cost cost structure % .fcn function handle (it is assumed to use saturating cost) % .<> other fields that are passed to cost % text1 (optional) text field 1 % text2 (optional) text field 2 % M (optional) mean of state % S (optional) covariance of state % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-07 function draw_dp(theta1, theta2, f1, f2, cost, text1, text2, M, S) %% Code l = 0.6; xmin = -2*l; xmax = 2*l; umax = 2; height = 0; % Draw double pendulum clf; hold on sth1 = sin(theta1); sth2 = sin(theta2); cth1 = cos(theta1); cth2 = cos(theta2); pendulum1 = [0, 0; -l*sth1, l*cth1]; pendulum2 = [-l*sth1, l*cth1; -l*(sth1-sth2), l*(cth1+cth2)]; plot(pendulum1(:,1), pendulum1(:,2),'r','linewidth',4) plot(pendulum2(:,1), pendulum2(:,2),'r','linewidth',4) % plot target location plot(0,2*l,'k+','MarkerSize',20); plot([xmin, xmax], [-height, -height],'k','linewidth',2) % plot inner joint plot(0,0,'k.','markersize',24) plot(0,0,'y.','markersize',14) % plot outer joint plot(-l*sth1, l*cth1,'k.','markersize',24) plot(-l*sth1, l*cth1,'y.','markersize',14) % plot tip of outer joint plot(-l*(sth1-sth2), l*(cth1+cth2),'k.','markersize',24) plot(-l*(sth1-sth2), l*(cth1+cth2),'y.','markersize',14) plot(0,-2*l,'.w','markersize',0.005) % % Draw sample positions of the joints % if nargin > 7 % samples = gaussian(M,S+1e-8*eye(4),1000); % t1 = samples(3,:); t2 = samples(4,:); % plot(-l*sin(t1),l*cos(t1),'b.','markersize',2) % plot(-l*(sin(t1)-sin(t2)),l*(cos(t1)+cos(t2)),'r.','markersize',2) % end % plot ellipses around tips of pendulums (if M, S exist) try if max(max(S))>0 [M1 S1 M2 S2] = getPlotDistr_dp(M, S, l, l); error_ellipse(S1,M1,'style','b'); % inner pendulum error_ellipse(S2,M2,'style','r'); % outer pendulum end catch end % Show other useful information % plot applied torques plot([0 f1/umax*xmax],[-0.3, -0.3],'g','linewidth',10) plot([0 f2/umax*xmax],[-0.5, -0.5],'g','linewidth',10) % plot reward reward = 1-cost.fcn(cost,[0, 0, theta1, theta2]',zeros(4)); plot([0 reward*xmax],[-0.7, -0.7],'y','linewidth',10) text(0,-0.3,'applied torque (inner joint)') text(0,-0.5,'applied torque (outer joint)') text(0,-0.7,'immediate reward') if exist('text1','var') text(0,-0.9, text1) end if exist('text2','var') text(0,-1.1, text2) end set(gca,'DataAspectRatio',[1 1 1],'XLim',[xmin xmax],'YLim',[-2*l 2*l]); axis off drawnow;
github
UCL-SML/pilco-matlab-master
getPlotDistr_dp.m
.m
pilco-matlab-master/scenarios/doublePendulum/getPlotDistr_dp.m
2,772
utf_8
9be4d2bdc8b4beb731e6776c5dd791a1
%% getPlotDistr_dp.m % *Summary:* Compute means and covariances of the Cartesian coordinates of % the tips both the inner and outer pendulum assuming that the joint state % $x$ of the cart-double-pendulum system is Gaussian, i.e., $x\sim N(m, s)$ % % % function [M1, S1, M2, S2] = getPlotDistr_dp(m, s, ell1, ell2) % % % *Input arguments:* % % m mean of full state [6 x 1] % s covariance of full state [6 x 6] % ell1 length of inner pendulum % ell2 length of outer pendulum % % Note: this code assumes that the following order of the state: % 1: pend1 angular velocity, % 2: pend2 angular velocity, % 3: pend1 angle, % 4: pend2 angle % % *Output arguments:* % % M1 mean of tip of inner pendulum [2 x 1] % S1 covariance of tip of inner pendulum [2 x 2] % M2 mean of tip of outer pendulum [2 x 1] % S2 covariance of tip of outer pendulum [2 x 2] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modification: 2013-03-27 % %% High-Level Steps % # Augment input distribution to complex angle representation % # Compute means of tips of pendulums (in Cartesian coordinates) % # Compute covariances of tips of pendulums (in Cartesian coordinates) function [M1, S1, M2, S2] = getPlotDistr_dp(m, s, ell1, ell2) %% Code % 1. Augment input distribution [m1 s1 c1] = gTrig(m, s, [3 4], [ell1, ell2]); % map input through sin/cos m1 = [m; m1]; % mean of joint c1 = s*c1; % cross-covariance between input and prediction s1 = [s c1; c1' s1]; % covariance of joint % 2. Compute means of tips of pendulums (in Cartesian coordinates) M1 = [-m1(5); m1(6)]; % [-l*sin(t1), l*cos(t1)] M2 = [-m1(5) + m1(7); m1(6) + m1(8)]; % [-l*(sin(t1)-sin(t2)),l*(cos(t1)+cos(t2))] % 2. Put covariance matrices together (Cart. coord.) % first set of coordinates (tip of 1st pendulum) s11 = s1(5,5); s12 = -s1(5,6); s22 = s1(6,6); S1 = [s11 s12; s12' s22]; % second set of coordinates (tip of 2nd pendulum) s11 = s1(5,5) + s1(7,7) - s1(5,7) - s1(7,5); % ell1*sin(t1) + ell2*sin(t2) s22 = s1(6,6) + s1(8,8) + s1(6,8) + s1(8,6); % ell1*cos(t1) + ell2*cos(t2) s12 = -(s1(5,6) + s1(5,8) + s1(7,6) + s1(7,8)); S2 = [s11 s12; s12' s22]; % make sure we have proper covariances (sometimes numerical problems occur) try chol(S1); catch warning('matrix S1 not pos.def. (getPlotDistr)'); S1 = S1 + (1e-6 - min(eig(S1)))*eye(2); end try chol(S2); catch warning('matrix S2 not pos.def. (getPlotDistr)'); S2 = S2 + (1e-6 - min(eig(S2)))*eye(2); end
github
UCL-SML/pilco-matlab-master
draw_cp.m
.m
pilco-matlab-master/scenarios/cartPole/draw_cp.m
2,120
utf_8
7d6605b0e25af85fb84cf253639ba531
%% draw_cp.m % *Summary:* Draw the cart-pole system with reward, applied force, and % predictive uncertainty of the tip of the pendulum % % function draw_cp(x, theta, force, cost, text1, text2, M, S) % % % *Input arguments:* % % x position of the cart % theta angle of pendulum % force force applied to cart % cost cost structure % .fcn function handle (it is assumed to use saturating cost) % .<> other fields that are passed to cost % M (optional) mean of state % S (optional) covariance of state % text1 (optional) text field 1 % text2 (optional) text field 2 % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-07 function draw_cp(x, theta, force, cost, text1, text2, M, S) %% Code l = 0.6; xmin = -3; xmax = 3; height = 0.1; width = 0.3; maxU = 10; % Compute positions cart = [ x + width, height x + width, -height x - width, -height x - width, height x + width, height ]; pendulum = [x, 0; x+2*l*sin(theta), -cos(theta)*2*l]; clf; hold on plot(0,2*l,'k+','MarkerSize',20,'linewidth',2) plot([xmin, xmax], [-height-0.03, -height-0.03],'k','linewidth',2) % Plot force plot([0 force/maxU*xmax],[-0.3, -0.3],'g','linewidth',10) % Plot reward reward = 1-cost.fcn(cost,[x, 0, 0, theta]', zeros(4)); plot([0 reward*xmax],[-0.5, -0.5],'y','linewidth',10) % Plot the cart-pole fill(cart(:,1), cart(:,2),'k','edgecolor','k'); plot(pendulum(:,1), pendulum(:,2),'r','linewidth',4) % Plot the joint and the tip plot(x,0,'y.','markersize',24) plot(pendulum(2,1),pendulum(2,2),'y.','markersize',24) % plot ellipse around tip of pendulum (if M, S exist) try [M1 S1] = getPlotDistr_cp(M,S,2*l); error_ellipse(S1,M1,'style','b'); catch end % Text text(0,-0.3,'applied force') text(0,-0.5,'immediate reward') if exist('text1','var') text(0,-0.9, text1) end if exist('text2','var') text(0,-1.1, text2) end set(gca,'DataAspectRatio',[1 1 1],'XLim',[xmin xmax],'YLim',[-1.4 1.4]); axis off; drawnow;
github
UCL-SML/pilco-matlab-master
loss_cp.m
.m
pilco-matlab-master/scenarios/cartPole/loss_cp.m
4,079
utf_8
0dfef958e239873ab8f870cbcc59b496
%% loss_cp.m % *Summary:* Cart-Pole loss function; the loss is % $1-\exp(-0.5*d^2*a)$, where $a>0$ and $d^2$ is the squared difference % between the actual and desired position of tip of the pendulum. % The mean and the variance of the loss are computed by averaging over the % Gaussian state distribution $p(x) = \mathcal N(m,s)$ with mean $m$ % and covariance matrix $s$. % Derivatives of these quantities are computed when desired. % % % function [L, dLdm, dLds, S2] = loss_cp(cost, m, s) % % % *Input arguments:* % % cost cost structure % .p length of pendulum [1 x 1 ] % .width array of widths of the cost (summed together) % .expl (optional) exploration parameter % .angle (optional) array of angle indices % .target target state [D x 1 ] % m mean of state distribution [D x 1 ] % s covariance matrix for the state distribution [D x D ] % % *Output arguments:* % % L expected cost [1 x 1 ] % dLdm derivative of expected cost wrt. state mean vector [1 x D ] % dLds derivative of expected cost wrt. state covariance matrix [1 x D^2] % S2 variance of cost [1 x 1 ] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-05-16 % %% High-Level Steps % # Precomputations % # Define static penalty as distance from target setpoint % # Trigonometric augmentation % # Calculate loss function [L, dLdm, dLds, S2] = loss_cp(cost, m, s) %% Code if isfield(cost,'width'); cw = cost.width; else cw = 1; end if ~isfield(cost,'expl') || isempty(cost.expl); b = 0; else b = cost.expl; end % 1. Some precomputations D0 = size(s,2); % state dimension D1 = D0 + 2*length(cost.angle); % state dimension (with sin/cos) M = zeros(D1,1); M(1:D0) = m; S = zeros(D1); S(1:D0,1:D0) = s; Mdm = [eye(D0); zeros(D1-D0,D0)]; Sdm = zeros(D1*D1,D0); Mds = zeros(D1,D0*D0); Sds = kron(Mdm,Mdm); % 2. Define static penalty as distance from target setpoint ell = cost.p; % pendulum length Q = zeros(D1); Q([1 D0+1],[1 D0+1]) = [1 ell]'*[1 ell]; Q(D0+2,D0+2) = ell^2; % 3. Trigonometric augmentation if D1-D0 > 0 % augment target target = [cost.target(:); gTrig(cost.target(:), 0*s, cost.angle)]; % augment state i = 1:D0; k = D0+1:D1; [M(k) S(k,k) C mdm sdm Cdm mds sds Cds] = gTrig(M(i),S(i,i),cost.angle); % compute derivatives (for augmentation) X = reshape(1:D1*D1,[D1 D1]); XT = X'; % vectorized indices I=0*X; I(i,i)=1; ii=X(I==1)'; I=0*X; I(k,k)=1; kk=X(I==1)'; I=0*X; I(i,k)=1; ik=X(I==1)'; ki=XT(I==1)'; Mdm(k,:) = mdm*Mdm(i,:) + mds*Sdm(ii,:); % chainrule Mds(k,:) = mdm*Mds(i,:) + mds*Sds(ii,:); Sdm(kk,:) = sdm*Mdm(i,:) + sds*Sdm(ii,:); Sds(kk,:) = sdm*Mds(i,:) + sds*Sds(ii,:); dCdm = Cdm*Mdm(i,:) + Cds*Sdm(ii,:); dCds = Cdm*Mds(i,:) + Cds*Sds(ii,:); S(i,k) = S(i,i)*C; S(k,i) = S(i,k)'; % off-diagonal SS = kron(eye(length(k)),S(i,i)); CC = kron(C',eye(length(i))); Sdm(ik,:) = SS*dCdm + CC*Sdm(ii,:); Sdm(ki,:) = Sdm(ik,:); Sds(ik,:) = SS*dCds + CC*Sds(ii,:); Sds(ki,:) = Sds(ik,:); end % 4. Calculate loss! L = 0; dLdm = zeros(1,D0); dLds = zeros(1,D0*D0); S2 = 0; for i = 1:length(cw) % scale mixture of immediate costs cost.z = target; cost.W = Q/cw(i)^2; [r rdM rdS s2 s2dM s2dS] = lossSat(cost, M, S); L = L + r; S2 = S2 + s2; dLdm = dLdm + rdM(:)'*Mdm + rdS(:)'*Sdm; dLds = dLds + rdM(:)'*Mds + rdS(:)'*Sds; if (b~=0 || ~isempty(b)) && abs(s2)>1e-12 L = L + b*sqrt(s2); dLdm = dLdm + b/sqrt(s2) * ( s2dM(:)'*Mdm + s2dS(:)'*Sdm )/2; dLds = dLds + b/sqrt(s2) * ( s2dM(:)'*Mds + s2dS(:)'*Sds )/2; end end % normalize n = length(cw); L = L/n; dLdm = dLdm/n; dLds = dLds/n; S2 = S2/n;
github
UCL-SML/pilco-matlab-master
getPlotDistr_cp.m
.m
pilco-matlab-master/scenarios/cartPole/getPlotDistr_cp.m
2,037
utf_8
bd4a0c9d5da54b0aa0d1a011ee47db5b
%% getPlotDistr_cp.m % *Summary:* Compute means and covariances of the Cartesian coordinates of % the tips both the inner and outer pendulum assuming that the joint state % $x$ of the cart-double-pendulum system is Gaussian, i.e., $x\sim N(m, s)$ % % % function [M, S] = getPlotDistr_cp(m, s, ell) % % % % *Input arguments:* % % m mean of full state [4 x 1] % s covariance of full state [4 x 4] % ell length of pendulum % % Note: this code assumes that the following order of the state: % 1: cart pos., % 2: cart vel., % 3: pendulum angular velocity, % 4: pendulum angle % % *Output arguments:* % % M mean of tip of pendulum [2 x 1] % S covariance of tip of pendulum [2 x 2] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modification: 2013-03-27 % %% High-Level Steps % # Augment input distribution to complex angle representation % # Compute means of tips of pendulums (in Cartesian coordinates) % # Compute covariances of tips of pendulums (in Cartesian coordinates) function [M, S] = getPlotDistr_cp(m, s, ell) %% Code % 1. Augment input distribution to complex angle representation [m1 s1 c1] = gTrig(m,s,4,ell); % map input distribution through sin/cos m1 = [m; m1]; % mean of joint c1 = s*c1; % cross-covariance between input and prediction s1 = [s c1; c1' s1]; % covariance of joint % 2. Compute means of tips of pendulums (in Cartesian coordinates) M = [m1(1)+m1(5); -m1(6)]; % 3. Compute covariances of tips of pendulums (in Cartesian coordinates) s11 = s1(1,1) + s1(5,5) + s1(1,5) + s1(5,1); % x+l sin(theta) s22 = s1(6,6); % -l*cos(theta) s12 = -(s1(1,6)+s1(5,6)); % cov(x+l*sin(th), -l*cos(th) S = [s11 s12; s12' s22]; try chol(S); catch warning('matrix S not pos.def. (getPlotDistr)'); S = S + (1e-6 - min(eig(S)))*eye(2); end
github
UCL-SML/pilco-matlab-master
dynamics_cp.m
.m
pilco-matlab-master/scenarios/cartPole/dynamics_cp.m
1,720
utf_8
3782addcb8146afff9473fcc8b22a948
%% dynamics_cp.m % *Summary:* Implements ths ODE for simulating the cart-pole dynamics. % % function dz = dynamics_cp(t, z, f) % % % *Input arguments:* % % t current time step (called from ODE solver) % z state [4 x 1] % f (optional): force f(t) % % *Output arguments:* % % dz if 3 input arguments: state derivative wrt time % if only 2 input arguments: total mechanical energy % % % Note: It is assumed that the state variables are of the following order: % x: [m] position of cart % dx: [m/s] velocity of cart % dtheta: [rad/s] angular velocity % theta: [rad] angle % % % A detailed derivation of the dynamics can be found in: % % M.P. Deisenroth: % Efficient Reinforcement Learning Using Gaussian Processes, Appendix C, % KIT Scientific Publishing, 2010. % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-08 function dz = dynamics_cp(t,z,f) %% Code l = 0.5; % [m] length of pendulum m = 0.5; % [kg] mass of pendulum M = 0.5; % [kg] mass of cart b = 0.1; % [N/m/s] coefficient of friction between cart and ground g = 9.82; % [m/s^2] acceleration of gravity if nargin==3 dz = zeros(4,1); dz(1) = z(2); dz(2) = ( 2*m*l*z(3)^2*sin(z(4)) + 3*m*g*sin(z(4))*cos(z(4)) ... + 4*f(t) - 4*b*z(2) )/( 4*(M+m)-3*m*cos(z(4))^2 ); dz(3) = (-3*m*l*z(3)^2*sin(z(4))*cos(z(4)) - 6*(M+m)*g*sin(z(4)) ... - 6*(f(t)-b*z(2))*cos(z(4)) )/( 4*l*(m+M)-3*m*l*cos(z(4))^2 ); dz(4) = z(3); else dz = (M+m)*z(2)^2/2 + 1/6*m*l^2*z(3)^2 + m*l*(z(2)*z(3)-g)*cos(z(4))/2; end
github
UCL-SML/pilco-matlab-master
augment_unicycle.m
.m
pilco-matlab-master/scenarios/unicycle/augment_unicycle.m
2,372
utf_8
3d526959966588683c66fa49b3cf8b0b
%% augment_unicycle.m % *Summary:* The function computes the $(x,y)$ velocities of the contact point % in both absolute and unicycle coordinates as well as the the unicycle % coordinates of the contact point themselves. % % function r = augment(s) % % *Input arguments:* % % s state of the unicycle (including the torques). [1 x 18] % The state is assumed to be given as follows: % dx empty (to be filled by this function) % dy empty (to be filled by this function) % dxc empty (to be filled by this function) % dyc empty (to be filled by this function) % dtheta roll angular velocity % dphi yaw angular velocity % dpsiw wheel angular velocity % dpsif pitch angular velocity % dpsit turn table angular velocity % x x position % y y position % xc empty (to be filled by this function) % yc empty (to be filled by this function) % theta roll angle % phi yaw angle % psiw wheel angle % psif pitch angle % psit turn table angle % % *Output arguments:* % % r additional variables that are computed based on s: [1 x 6] % dx x velocity of contact point (global coordinates) % dy y velocity of contact point (global coordinates) % dxc x velocity of contact point (unicycle coordinates) % dyc y velocity of contact point (unicycle coordinates) % xc x position of contact point (unicycle coordinates) % yc y position of contact point (unicycle coordinates) % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-27 function r = augment_unicycle(s) %% Code rw = 0.225; % wheel radius in meters % x velocity of contact point (global coordinates) r(1) = rw*cos(s(15))*s(7); % y velocity of contact point (global coordinates) r(2) = rw*sin(s(15))*s(7); % (x,y) velocities of contact point (unicycle coordinates) A = -[cos(s(15)) sin(s(15)); -sin(s(15)) cos(s(15))]; dA = -s(6)*[-sin(s(15)) cos(s(15)); -cos(s(15)) -sin(s(15))]; r(3:4) = A*r(1:2)' + dA*s(10:11)'; % (x,y) coordinates of contact point (unicycle coordinates) r(5:6) = A*s(10:11)';
github
UCL-SML/pilco-matlab-master
loss_unicycle.m
.m
pilco-matlab-master/scenarios/unicycle/loss_unicycle.m
5,277
utf_8
b20d304ef5667ff9e596087b42191a58
%% loss_unicycle.m % Robotic unicycle loss function. The loss is $1-\exp(-0.5*a*d^2)$, where % $a$ is a (positive) constant and $d^2$ is the squared difference between % the current configuration of the unicycle and a target set point. % % The mean and the variance of the loss are computed by averaging over the % Gaussian distribution of the state $p(x) = \mathcal N(m,s)$ with mean $m$ % and covariance matrix $s$, plus cost.expl times the standard deviation of % the loss (averaged wrt the same Gaussian), where the exploration paramater % cost.expl defaults to zero. % % Negative values of the exploration parameter are used to encourage % exploration and positive values avoid regions of uncertainty in the % policy. Derivatives are computed when desired. % % The mean and the variance of the loss are computed by averaging over the % Gaussian distribution of the state $p(x) = \mathcal N(m,s)$ with mean $m$ % and covariance matrix $s$. % Derivatives of these quantities are computed when desired. % % % function [L, dLdm, dLds, S2] = loss_unicycle(cost, m, s) % % % *Input arguments:* % % % cost cost structure % .p parameters: [radius of wheel, length of rod] [2 x 1 ] % .width array of widths of the cost (summed together) % .expl (optional) exploration parameter; default: 0 % m mean of state distribution [D x 1 ] % s covariance matrix for the state distribution [D x D ] % % *Output arguments:* % % L expected cost [1 x 1 ] % dLdm derivative of expected cost wrt. state mean vector [1 x D ] % dLds derivative of expected cost wrt. state covariance matrix [1 x D^2] % S2 variance of cost [1 x 1 ] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-26 % %% High-Level Steps % # Precomputations % # Define static penalty as distance from target setpoint % # Trigonometric augmentation % # Calculate loss function [L, dLdm, dLds, S2] = loss_unicycle(cost, m, s) %% Code rw = cost.p(1); r = cost.p(2); if isfield(cost,'width'); cw = cost.width; else cw = 1; end if ~isfield(cost,'expl') || isempty(cost.expl); b = 0; else b = cost.expl; end I6 = 8; I9 = 10; % coordinates of theta and psi Ixc = 6; Iyc = 7; % coordinates of xc and yc % 1. Some precomputations D = size(s,2); % state dimension D0 = D + 2; % state dimension (augmented with I6-I9 and I6+I9) D1 = D0 + 8; % state dimension (with sin/cos) L = 0; dLdm = zeros(1,D); dLds = zeros(1,D*D); S2 = 0; P = [eye(D); zeros(2,D)]; P(D+1:end,I6) = [1;-1]; P(D+1:end,I9) = [1;1]; M = zeros(D1,1); M(1:D0) = P*m; S = zeros(D1); S(1:D0,1:D0) = P*s*P'; Mdm = [P; zeros(D1-D0,D)]; Sdm = zeros(D1*D1,D); Mds = zeros(D1,D*D); Sds = kron(Mdm,Mdm); % 2. Define static penalty as distance from target setpoint Q = zeros(D+10); C1 = [rw r/2 r/2]; Q([D+4 D+6 D+8],[D+4 D+6 D+8]) = 8*(C1'*C1); % dz C2 = [1 -r]; Q([Ixc D+9],[Ixc D+9]) = 0.5*(C2'*C2); % dx C3 = [1 -(r+rw)]; Q([Iyc D+3],[Iyc D+3]) = 0.5*(C3'*C3); % dy Q(9,9) = (1/(4*pi))^2; % yaw angle loss target = zeros(D1,1); target([D+4 D+6 D+8 D+10]) = 1; % target setpoint % 3. Trigonometric augmentation i = 1:D0; k = D0+1:D1; [M(k) S(k,k) C mdm sdm Cdm mds sds Cds] = ... gTrig(M(i),S(i,i),[I6 D+1 D+2 I9]); [S Mdm Mds Sdm Sds] = ... fillIn(S,C,mdm,sdm,Cdm,mds,sds,Cds,Mdm,Sdm,Mds,Sds,i,k,D1); % 4. Calculate loss for i = 1:length(cw) % scale mixture of immediate costs cost.z = target; cost.W = Q/cw(i)^2; [r rdM rdS s2 s2dM s2dS] = lossSat(cost, M, S); L = L + r; S2 = S2 + s2; dLdm = dLdm + rdM(:)'*Mdm + rdS(:)'*Sdm; dLds = dLds + rdM(:)'*Mds + rdS(:)'*Sds; if (b~=0 || ~isempty(b)) && abs(s2)>1e-12 L = L + b*sqrt(s2); dLdm = dLdm + b/sqrt(s2) * ( s2dM(:)'*Mdm + s2dS(:)'*Sdm )/2; dLds = dLds + b/sqrt(s2) * ( s2dM(:)'*Mds + s2dS(:)'*Sds )/2; end end % normalize n = length(cw); L = L/n; dLdm = dLdm/n; dLds = dLds/n; S2 = S2/n; % Fill in covariance matrix...and derivatives ---------------------------- function [S Mdm Mds Sdm Sds] = ... fillIn(S,C,mdm,sdm,Cdm,mds,sds,Cds,Mdm,Sdm,Mds,Sds,i,k,D) X = reshape(1:D*D,[D D]); XT = X'; % vectorized indices I=0*X; I(i,i)=1; ii=X(I==1)'; I=0*X; I(k,k)=1; kk=X(I==1)'; I=0*X; I(i,k)=1; ik=X(I==1)'; ki=XT(I==1)'; Mdm(k,:) = mdm*Mdm(i,:) + mds*Sdm(ii,:); % chainrule Mds(k,:) = mdm*Mds(i,:) + mds*Sds(ii,:); Sdm(kk,:) = sdm*Mdm(i,:) + sds*Sdm(ii,:); Sds(kk,:) = sdm*Mds(i,:) + sds*Sds(ii,:); dCdm = Cdm*Mdm(i,:) + Cds*Sdm(ii,:); dCds = Cdm*Mds(i,:) + Cds*Sds(ii,:); S(i,k) = S(i,i)*C; S(k,i) = S(i,k)'; % off-diagonal SS = kron(eye(length(k)),S(i,i)); CC = kron(C',eye(length(i))); Sdm(ik,:) = SS*dCdm + CC*Sdm(ii,:); Sdm(ki,:) = Sdm(ik,:); Sds(ik,:) = SS*dCds + CC*Sds(ii,:); Sds(ki,:) = Sds(ik,:);
github
UCL-SML/pilco-matlab-master
draw_unicycle.m
.m
pilco-matlab-master/scenarios/unicycle/draw_unicycle.m
5,222
utf_8
4e5a8f9508c83cf1118de1536b5b45b0
%% draw_unicycle.m % *Summary:* Draw the unicycle with cost and applied torques % % function draw_unicycle(latent, plant,t2,cost,text1, text2) % % % *Input arguments:* % % latent state of the unicycle (including the torques) % plant plant structure % .dt sampling time % .dyno state indices that are passed ont the cost function % t2 supersampling frequency (in case you want smoother plots) % cost cost structure % .fcn function handle (it is assumed to use saturating cost) % .<> other fields that are passed to cost % text1 (optional) text field 1 % text2 (optional) text field 2 % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-04-04 function draw_unicycle(latent,plant,t2,cost,text1, text2) %% Code clf; set(gca,'FontSize',16); t1 = plant.dt; rw = 0.225; % wheel radius rf = 0.54; % frame center of mass to wheel rt = 0.27; % frame centre of mass to turntable rr = rf+rt; % distance wheel to turntable M = 24; MM = 2*pi*(0:M)/M; RR = ['r-';'r-';'r-';'k-';'b-';'b-';'b-']; ii = 10000; qq = latent; clear q; xi = t1*(0:size(qq,1)-1); xn = 0:t2:(size(qq,1)-1)*t1; for i = 1:size(qq,2), q(:,i) = interp1(xi,qq(:,i),xn); end for i=1:size(q,1) x = q(i,10); y = q(i,11); theta = q(i,14); phi = q(i,15); psiw = -q(i,16); psif = q(i,17); psit = q(i,18); A = [ cos(phi) sin(phi) 0 -sin(phi)*cos(theta) cos(phi)*cos(theta) -sin(theta) -sin(phi)*sin(theta) cos(phi)*sin(theta) cos(theta) ]'; r = rw*[cos(psiw+MM); zeros(1,M+1); sin(psiw+MM)+1]; R{1} = bsxfun(@plus,A*r,[x; y; 0]); r = rw*[cos(psiw) -cos(psiw); 0 0; sin(psiw)+1 -sin(psiw)+1]; R{2} = bsxfun(@plus,A*r,[x; y; 0]); r = rw*[sin(psiw) -sin(psiw); 0 0; -cos(psiw)+1 cos(psiw)+1]; R{3} = bsxfun(@plus,A*r,[x; y; 0]); r = [0 rr*sin(psif); 0 0; rw rw+rr*cos(psif)]; R{4} = bsxfun(@plus,A*r,[x; y; 0]); r = [rr*sin(psif)+rw*cos(psif)*cos(psit+MM); rw*sin(psit+MM); rw+rr*cos(psif)-rw*sin(psif)*cos(psit+MM)]; R{5} = bsxfun(@plus,A*r,[x; y; 0]); r = [rr*sin(psif)+rw*cos(psif)*cos(psit) rr*sin(psif)-rw* ... cos(psif)*cos(psit); rw*sin(psit) -rw*sin(psit); rw+rr* ... cos(psif)-rw*sin(psif)*cos(psit) rw+rr*cos(psif)+rw* ... sin(psif)*cos(psit)]; R{6} = bsxfun(@plus,A*r,[x; y; 0]); r = [rr*sin(psif)+rw*cos(psif)*sin(psit) rr*sin(psif)-rw* ... cos(psif)*sin(psit); -rw*cos(psit) rw*cos(psit); rw+rr* ... cos(psif)-rw*sin(psif)*sin(psit) rw+rr*cos(psif)+rw* ... sin(psif)*sin(psit)]; R{7} = bsxfun(@plus,A*r,[x; y; 0]); hold off aa = linspace(0,2*pi,201); plot3(2*sin(aa),2*cos(aa),0*aa,'k:','LineWidth',2); hold on r = A*[0; 0; rw] + [x; y; 0]; P = [r R{1}(:,1:M/4+1) r]; fill3(P(1,:),P(2,:),P(3,:),'r','EdgeColor','none'); P = [r R{1}(:,M/2+1:3*M/4+1) r]; fill3(P(1,:),P(2,:),P(3,:),'r','EdgeColor','none'); r = A*[rr*sin(psif); 0; rw+rr*cos(psif) ] + [x; y; 0]; P = [r R{5}(:,1:M/4+1) r]; fill3(P(1,:),P(2,:),P(3,:),'b','EdgeColor','none'); P = [r R{5}(:,M/2+1:3*M/4+1) r]; fill3(P(1,:),P(2,:),P(3,:),'b','EdgeColor','none'); for j = [1 4 5]; plot3(R{j}(1,:),R{j}(2,:),R{j}(3,:),RR(j,:),'LineWidth',2) end axis equal; axis([-2 2 -2 2 0 1.5]); xlabel 'x [m]'; ylabel 'y [m]'; grid on % draw controls: ut = q(i,end-1); uw = q(i,end); L = cost.fcn(cost,q(i,plant.dyno)',zeros(length(plant.dyno))); utM = 10; uwM = 50; oo = [4 -3.07 0]/6.4; o1 = [-0.5 2 2.0]; o2 = [-0.5 2 1.6]; o3 = [-0.5 2 1.2]; o0 = 1.5*ut/utM; plot3([o1(1) o1(1)+o0*oo(1)],[o1(2) o1(2)+o0*oo(2)],[o1(3) o1(3)+o0*oo(3)],'b','LineWidth',5) plot3([o1(1)-1.5*oo(1) o1(1)+1.5*oo(1) o1(1)+1.5*oo(1) o1(1)-1.5*oo(1) o1(1)-1.5*oo(1)],... [o1(2)-1.5*oo(2) o1(2)+1.5*oo(2) o1(2)+1.5*oo(2) o1(2)-1.5*oo(2) o1(2)-1.5*oo(2)],... [o1(3)+0.04 o1(3)+0.04 o1(3)-0.04 o1(3)-0.04 o1(3)+0.04], 'b'); plot3([-0.5 -0.5],[2 2],o1(3)+[-0.06 0.06],'b'); o0 = 1.5*uw/uwM; plot3([o2(1) o2(1)+o0*oo(1)],[o2(2) o2(2)+o0*oo(2)],[o2(3) o2(3)+o0*oo(3)],'r','LineWidth',5) plot3([o2(1)-1.5*oo(1) o2(1)+1.5*oo(1) o2(1)+1.5*oo(1) o2(1)-1.5*oo(1) o2(1)-1.5*oo(1)],... [o2(2)-1.5*oo(2) o2(2)+1.5*oo(2) o2(2)+1.5*oo(2) o2(2)-1.5*oo(2) o2(2)-1.5*oo(2)],... [o2(3)+0.04 o2(3)+0.04 o2(3)-0.04 o2(3)-0.04 o2(3)+0.04], 'r'); plot3([-0.5 -0.5],[2 2],o2(3)+[-0.06 0.06],'r'); o0 = 3*L-1.5; plot3([o3(1)-1.5*oo(1) o3(1)+o0*oo(1)],[o3(2)-1.5*oo(2) o3(2)+o0*oo(2)],[o3(3)-1.5*oo(3) o3(3)+o0*oo(3)],'k','LineWidth',5) plot3([o3(1)-1.5*oo(1) o3(1)+1.5*oo(1) o3(1)+1.5*oo(1) o3(1)-1.5*oo(1) o3(1)-1.5*oo(1)],... [o3(2)-1.5*oo(2) o3(2)+1.5*oo(2) o3(2)+1.5*oo(2) o3(2)-1.5*oo(2) o3(2)-1.5*oo(2)],... [o3(3)+0.04 o3(3)+0.04 o3(3)-0.04 o3(3)-0.04 o3(3)+0.04], 'k'); text(-0.5-1.5*oo(1), 2-1.5*oo(2), 2.2,'Disc torque max \pm 10 Nm','Color','b'); text(-0.5-1.5*oo(1), 2-1.5*oo(2), 1.8,'Wheel torque max \pm 50 Nm','Color','r'); text(-0.5-1.5*oo(1), 2-1.5*oo(2), 1.4,'Instantaneous Cost','Color','k'); if nargin > 4 text(2,1,1.8,text1); text(2,1,1.4,text2); end drawnow % pause(plant.dt/2); end
github
UCL-SML/pilco-matlab-master
dynamics_unicycle.m
.m
pilco-matlab-master/scenarios/unicycle/dynamics_unicycle.m
10,284
utf_8
60b3423e2e04ed55c08fbc8bb164bf6c
%% dynamics_unicycle.m % *Summary:* Implements ths ODE for simulating the cart-pole dynamics. % % function dz = dz = dynamics_unicycle(t, z, V, U) % % % *Input arguments:* % % t current time step (called from ODE solver) % z state [12 x 1] % V torque applied to the flywheel % U torque applied to the wheel % % *Output arguments:* % % dz state derivative wrt time % % % Note: It is assumed that the state variables are of the following order: % state: z = [dtheta, dphi, dpsiw, dpsif, dspit, % x, y, theta, phi, psiw, psif, psit] % % theta: tilt of the unicycle % phi: orientation of the unicycle % psiw: angle of wheel (rotation) % psif: angle of fork % psit: angle of turntable (rotation) % % dtheta angular velocity of tilt of the unicycle % dphi angular velocity of orientation of the unicycle % dpsiw angular velocity of wheel % dpsif angular velocity of fork % dpsit angular velocity of turntable % x x-position of contact point in plane % y y-position of contact point in plane % theta tilt of the unicycle % phi orientation of the unicycle % psiw angle of wheel (rotation) % psif angle of fork % psit angle of turntable (rotation) % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen, % based on derivations by David Forster % % Last modified: 2013-03-18 function dz = dynamics_unicycle(t, z, V, U) %% Code T = 0; % no friction dtheta = z(1); dphi = z(2); dpsiw = z(3); dpsif = z(4); dpsit = z(5); x = z(6); y = z(7); theta = z(8); phi = z(9); psiw = z(10); psif = z(11); psit = z(12); clear psit psiw % dynamics can't possibly depend on these % plant characteristics mt = 10.0; % turntable mass mw = 1.0; % wheel mass mf = 23.5; % frame mass rw = 0.225; % wheel radius rf = 0.54; % frame center of mass to wheel rt = 0.27; % frame centre of mass to turntable r = rf+rt; % distance wheel to turntable Cw = 0.0484; % moment of inertia of wheel around axle Aw = 0.0242; % moment of inertia of wheel perpendicular to axle Cf = 0.8292; % moment of inertia of frame Bf = 0.4608; % moment of inertia of frame Af = 0.4248; % moment of inertia of frame Ct = 0.2; % moment of inertia of turntable around axle At = 1.3; % moment of inertia of turntable perpendicular to axle g = 9.82; % acceleration of gravity st = sin(theta); ct = cos(theta); sf = sin(psif); cf = cos(psif); A = [ -Ct*sf Ct*cf*ct 0 0 Ct; 0 Cw*st+At*st-rf*(-mf*(st*rf+cf*st*rw)-mt*(st*r+cf*st*rw))+rt*mt*(st*r+cf*st*rw) -cf*rw*(rf*(mf+mt)+rt*mt) -Cw-At-rf*(mf*rf+mt*r)-rt*mt*r 0; cf*(-Af*sf-Ct*sf)-sf*(-Bf*cf-At*cf+rf*(-mf*(cf*rf+rw)-mt*(cf*r+rw))-rt*mt*(cf*r+rw)) Aw*ct+cf*(Af*cf*ct+Ct*cf*ct)-sf*(-Bf*sf*ct-At*sf*ct+rf*(-mf*sf*ct*rf-mt*sf*ct*r)-rt*mt*sf*ct*r) 0 0 Ct*cf; -Aw-rw*(mf*(cf*rf+rw)+mw*rw+mt*(cf*r+rw))+sf*(-Af*sf-Ct*sf)+cf*(-Bf*cf-At*cf+rf*(-mf*(cf*rf+rw)-mt*(cf*r+rw))-rt*mt*(cf*r+rw)) -rw*(mt*sf*ct*r+mf*sf*ct*rf)+sf*(Af*cf*ct+Ct*cf*ct)+cf*(-Bf*sf*ct-At*sf*ct+rf*(-mf*sf*ct*rf-mt*sf*ct*r)-rt*mt*sf*ct*r) 0 0 Ct*sf; 0 2*Cw*st+At*st-rf*(-mt*(st*r+cf*st*rw)-mf*(st*rf+cf*st*rw))+rt*mt*(st*r+cf*st*rw)+rw*(mw*st*rw+sf*(mf*sf*st*rw+mt*sf*st*rw)+cf*(mt*(st*r+cf*st*rw)+mf*(st*rf+cf*st*rw))) -Cw-rt*mt*cf*rw+rw*(-mw*rw+sf*(-mf*sf*rw-mt*sf*rw)+cf*(-mf*cf*rw-mt*cf*rw))-rf*(mt*cf*rw+mf*cf*rw) -Cw-At-rf*(mf*rf+mt*r)-rt*mt*r-rw*cf*(mf*rf+mt*r) 0 ]; b = zeros(5,1); b(1) = -V(t)+Ct*(-dphi*sf*dpsif*ct-dphi*cf*st*dtheta-cf*dpsif*dtheta); b(2) = -U(t)+Cw*dphi*ct*dtheta-(-dphi*cf*ct+sf*dtheta)*Bf*(dphi*sf*ct+cf*dtheta)+(dphi*sf*ct+cf*dtheta)*Af*(-dphi*cf*ct+sf*dtheta)+At*dphi*ct*dtheta-(dphi*sf*ct+cf*dtheta)*Ct*(dphi*cf*ct-sf*dtheta+dpsit)+(dphi*cf*ct-sf*dtheta)*At*(dphi*sf*ct+cf*dtheta)-rf*(-mf*g*sf*ct-mf*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*cf*ct+sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*rf)+dphi*ct*dtheta*rf-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw)-mt*g*sf*ct-mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt))))-rt*(-mt*g*sf*ct-mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt)))); b(3) = -T*ct-2*dphi*st*Aw*dtheta-dtheta*Cw*(-dphi*st+dpsiw)+cf*(-Af*(dphi*sf*dpsif*ct+dphi*cf*st*dtheta+cf*dpsif*dtheta)-(dphi*sf*ct+cf*dtheta)*Cf*(-dphi*st+dpsif)+(-dphi*st+dpsif)*Bf*(dphi*sf*ct+cf*dtheta)+Ct*(-dphi*sf*dpsif*ct-dphi*cf*st*dtheta-cf*dpsif*dtheta))-sf*(-Bf*(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)-(-dphi*st+dpsif)*Af*(-dphi*cf*ct+sf*dtheta)+(-dphi*cf*ct+sf*dtheta)*Cf*(-dphi*st+dpsif)-At*(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)-(dphi*cf*ct-sf*dtheta)*At*(-dphi*st+dpsif)+(-dphi*st+dpsif)*Ct*(dphi*cf*ct-sf*dtheta+dpsit)+rf*(mf*g*st-mf*((dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*rf+(-dphi*cf*ct+sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*rf))+mt*g*st-mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw))+rt*(mt*g*st-mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw))); b(4) = -dphi^2*st*Aw*ct-dphi*ct*Cw*(-dphi*st+dpsiw)-rw*(mw*dphi*ct*(-dphi*st+dpsiw)*rw-mt*g*st-mw*g*st+mf*((dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*rf+(-dphi*cf*ct+sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*rf))-mf*g*st+mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw))+sf*(-Af*(dphi*sf*dpsif*ct+dphi*cf*st*dtheta+cf*dpsif*dtheta)-(dphi*sf*ct+cf*dtheta)*Cf*(-dphi*st+dpsif)+(-dphi*st+dpsif)*Bf*(dphi*sf*ct+cf*dtheta)+Ct*(-dphi*sf*dpsif*ct-dphi*cf*st*dtheta-cf*dpsif*dtheta))+cf*(-Bf*(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)-(-dphi*st+dpsif)*Af*(-dphi*cf*ct+sf*dtheta)+(-dphi*cf*ct+sf*dtheta)*Cf*(-dphi*st+dpsif)-At*(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)-(dphi*cf*ct-sf*dtheta)*At*(-dphi*st+dpsif)+(-dphi*st+dpsif)*Ct*(dphi*cf*ct-sf*dtheta+dpsit)+rf*(mf*g*st-mf*((dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*rf+(-dphi*cf*ct+sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*rf))+mt*g*st-mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw))+rt*(mt*g*st-mt*(-(dphi*cf*ct-sf*dtheta)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))+(dphi*cf*dpsif*ct-dphi*sf*st*dtheta-dpsif*sf*dtheta)*(rf+rt)+(dphi*sf*ct+cf*dtheta)*sf*(-dphi*st+dpsiw)*rw))); b(5) = -T*st+2*Cw*dphi*ct*dtheta+(dphi*sf*ct+cf*dtheta)*Af*(-dphi*cf*ct+sf*dtheta)-rt*(-mt*g*sf*ct-mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt))))-(dphi*sf*ct+cf*dtheta)*Ct*(dphi*cf*ct-sf*dtheta+dpsit)+At*dphi*ct*dtheta+rw*(2*mw*rw*dphi*ct*dtheta+sf*(mf*(-cf*dpsif*(-dphi*st+dpsiw)*rw+sf*dphi*ct*dtheta*rw+(dphi*sf*ct+cf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*rf)-(-dphi*st+dpsif)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*rf))-mf*g*cf*ct-mt*g*cf*ct-mt*(cf*dpsif*(-dphi*st+dpsiw)*rw-sf*dphi*ct*dtheta*rw+(-dphi*st+dpsif)*(-cf*(-dphi*st+dpsiw)*rw-(-dphi*st+dpsif)*(rf+rt))-(dphi*sf*ct+cf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt))))+cf*(mf*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*cf*ct+sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*rf)+dphi*ct*dtheta*rf-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw)+mt*g*sf*ct+mf*g*sf*ct+mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt)))))+(dphi*cf*ct-sf*dtheta)*At*(dphi*sf*ct+cf*dtheta)-rf*(-mt*g*sf*ct-mt*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw+dphi*ct*dtheta*(rf+rt)+(dphi*cf*ct-sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*(rf+rt)))-mf*g*sf*ct-mf*(sf*dpsif*(-dphi*st+dpsiw)*rw+cf*dphi*ct*dtheta*rw-(-dphi*cf*ct+sf*dtheta)*(dtheta*rw+(dphi*sf*ct+cf*dtheta)*rf)+dphi*ct*dtheta*rf-(-dphi*st+dpsif)*sf*(-dphi*st+dpsiw)*rw))-(-dphi*cf*ct+sf*dtheta)*Bf*(dphi*sf*ct+cf*dtheta); dz = zeros(12,1); dz(1:5) = -A\b; dz(6) = rw*cos(phi)*dpsiw; dz(7) = rw*sin(phi)*dpsiw; dz(8:12) = z(1:5);
github
UCL-SML/pilco-matlab-master
draw_cdp.m
.m
pilco-matlab-master/scenarios/cartDoublePendulum/draw_cdp.m
3,088
utf_8
04065885f673565eaffc1971cde2a74e
%% draw_cdp.m % *Summary:* Draw the cart-double-pendulum system with reward, applied force, % and predictive uncertainty of the tips of the pendulums % % function draw_cdp(x, theta2, theta3, force, cost, M, S, text1, text2) % % % *Input arguments:* % % x position of the cart % theta2 angle of inner pendulum % theta3 angle of outer pendulum % force force applied to cart % cost cost structure % .fcn function handle (it is assumed to use saturating cost) % .<> other fields that are passed to cost % M (optional) mean of state % S (optional) covariance of state % text1 (optional) text field 1 % text2 (optional) text field 2 % % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-27 function draw_cdp(x, theta2, theta3, force, cost, M, S, text1, text2) %% Code scale = 1; l = 0.3*scale; xmin = -3*scale; xmax = 3*scale; height = 0.07*scale; width = 0.25*scale; font_size = 12; % Compute positions cart = [ x + width, height x + width, -height x - width, -height x - width, height x + width, height ]; pend2 = [x, 0; x-2*l*sin(theta2), cos(theta2)*2*l]; pend3 = [x-2*l*sin(theta2), 2*l*cos(theta2); x-2*l*sin(theta2)-2*l*sin(theta3), 2*l*cos(theta2)+2*l*cos(theta3)]; % plot cart double pendulum clf hold on plot(0,4*l,'k+','MarkerSize',2*font_size,'linewidth',2); plot([xmin, xmax], [-height-0.03*scale, -height-0.03*scale], ... 'Color','b','LineWidth',3); plot([0 force/20*xmax],[-0.3, -0.3].*scale, 'Color', 'g', 'LineWidth', font_size); % Plot reward reward = 1-cost.fcn(cost, [x, 0, 0, 0, theta2, theta3]',zeros(6)); plot([0 reward*xmax],[-0.5, -0.5].*scale, 'Color', 'y', 'LineWidth', font_size); % Draw Cart plot(cart(:,1), cart(:,2),'Color','k','LineWidth',3); fill(cart(:,1), cart(:,2),'k'); % Draw Pendulum2 plot(pend2(:,1), pend2(:,2),'Color','r','LineWidth', round(font_size/2)); % Draw Pendulum3 plot(pend3(:,1), pend3(:,2),'Color','r','LineWidth', round(font_size/2)); % joint at cart plot(x,0,'o','MarkerSize', round((font_size+4)/2),'Color','y','markerface','y'); % 2nd joint plot(pend3(1,1),pend3(1,2),'o','MarkerSize', ... round((font_size+4)/2),'Color','y','markerface','y'); % tip of 2nd joint plot(pend3(2,1),pend3(2,2),'o','MarkerSize', ... round((font_size+4)/2),'Color','y','markerface','y'); % plot ellipses around tip of pendulum (if M, S exist) try if max(max(S))>0 [M1 S1 M2 S2] = getPlotDistr_cdp(M, S, 2*l, 2*l); error_ellipse(S1,M1,'style','b'); % inner pendulum error_ellipse(S2,M2,'style','r'); % outer pendulum end catch end text(0,-0.3*scale,'applied force','fontsize', font_size) text(0,-0.5*scale,'immediate reward','fontsize', font_size) if exist('text1','var') text(0,-0.7*scale, text1,'fontsize', font_size); if exist('text2','var') text(0,-0.9*scale, text2,'fontsize', font_size) end end set(gca,'DataAspectRatio',[1 1 1],'XLim',[xmin xmax],'YLim',[-1.4 1.4].*scale); axis off drawnow;
github
UCL-SML/pilco-matlab-master
getPlotDistr_cdp.m
.m
pilco-matlab-master/scenarios/cartDoublePendulum/getPlotDistr_cdp.m
2,860
utf_8
bd0fa24486bfa30d58e3ee07349684d0
%% getPlotDistr_cdp.m % *Summary:* Compute means and covariances of the Cartesian coordinates of % the tips both the inner and outer pendulum assuming that the joint state % $x$ of the cart-double-pendulum system is Gaussian, i.e., $x\sim N(m, s)$ % % % function [M1, S1, M2, S2] = getPlotDistr_cdp(m, s, ell1, ell2) % % % % *Input arguments:* % % m mean of full state [6 x 1] % s covariance of full state [6 x 6] % ell1 length of inner pendulum % ell2 length of outer pendulum % % Note: this code assumes that the following order of the state: % 1: cart pos., % 2: cart vel., % 3: pend1 angular velocity, % 4: pend2 angular velocity, % 5: pend1 angle, % 6: pend2 angle % % *Output arguments:* % % M1 mean of tip of inner pendulum [2 x 1] % S1 covariance of tip of inner pendulum [2 x 2] % M2 mean of tip of outer pendulum [2 x 1] % S2 covariance of tip of outer pendulum [2 x 2] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modification: 2013-03-06 % %% High-Level Steps % # Augment input distribution to complex angle representation % # Compute means of tips of pendulums (in Cartesian coordinates) % # Compute covariances of tips of pendulums (in Cartesian coordinates) function [M1, S1, M2, S2] = getPlotDistr_cdp(m, s, ell1, ell2) %% Code % 1. Augment input distribution (complex representation) [m1 s1 c1] = gTrig(m, s, [5 6], [ell1, ell2]); % map input through sin/cos m1 = [m; m1]; % mean of joint c1 = s*c1; % cross-covariance between input and prediction s1 = [s c1; c1' s1]; % covariance of joint % 2. Mean of the tips of the pendulums (Cart. coord.) M1 = [m1(1) - m1(7); m1(8)]; % p2: E[x -l1\sin\theta_2]; E[l2\cos\theta_2] M2 = [M1(1) - m1(9); M1(2) + m1(10)]; % p3: mean of cart. coord. % 2. Put covariance matrices together (Cart. coord.) % first set of coordinates (tip of 1st pendulum) S1(1,1) = s1(1,1) + s1(7,7) -2*s1(1,7); S1(2,2) = s1(8,8); S1(1,2) = s1(1,8) - s1(7,8); S1(2,1) = S1(1,2)'; % second set of coordinates (tip of 2nd pendulum) S2(1,1) = S1(1,1) + s1(9,9) + 2*(s1(1,9) - s1(7,9)); S2(2,2) = s1(8,8) + s1(10,10) + 2*s1(8,10); S2(1,2) = s1(1,8) - s1(7,8) - s1(9,8) ... + s1(1,10) - s1(7,10) - s1(9,10); S2(2,1) = S2(1,2)'; % make sure we have proper covariances (sometimes numerical problems occur) try chol(S1); catch warning('matrix S1 not pos.def. (getPlotDistr)'); S1 = S1 + (1e-6 - min(eig(S1)))*eye(2); end try chol(S2); catch warning('matrix S2 not pos.def. (getPlotDistr)'); S2 = S2 + (1e-6 - min(eig(S2)))*eye(2); end
github
UCL-SML/pilco-matlab-master
loss_cdp.m
.m
pilco-matlab-master/scenarios/cartDoublePendulum/loss_cdp.m
4,261
utf_8
50a62e605756c9036c520f7886803a73
%% loss_cdp.m % *Summary:* Cart-Double-Pendulum loss function; the loss is % $1-\exp(-0.5*d^2*a)$, where $a>0$ and $d^2$ is the squared difference % between the actual and desired position of the end of the outer pendulum. % The mean and the variance of the loss are computed by averaging over the % Gaussian distribution of the state $p(x) = \mathcal N(m,s)$ with mean $m$ % and covariance matrix $s$. % Derivatives of these quantities are computed when desired. % % % function [L, dLdm, dLds, S2] = loss_cdp(cost, m, s) % % % *Input arguments:* % cost cost structure % .p lengths of the 2 pendulums [2 x 1 ] % .width array of widths of the cost (summed together) % .expl (optional) exploration parameter % .angle (optional) array of angle indices % .target target state [D x 1 ] % m mean of state distribution [D x 1 ] % s covariance matrix for the state distribution [D x D ] % % *Output arguments:* % % L expected cost [1 x 1 ] % dLdm derivative of expected cost wrt. state mean vector [1 x D ] % dLds derivative of expected cost wrt. state covariance matrix [1 x D^2] % S2 variance of cost [1 x 1 ] % % Copyright (C) 2008-2013 by % Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen. % % Last modified: 2013-03-07 % %% High-Level Steps % # Precomputations % # Define static penalty as distance from target setpoint % # Trigonometric augmentation % # Calculate loss function [L, dLdm, dLds, S2] = loss_cdp(cost, m, s) %% Code if isfield(cost,'width'); cw = cost.width; else cw = 1; end if ~isfield(cost,'expl') || isempty(cost.expl); b = 0; else b = cost.expl; end % 1. Some precomputations D0 = size(s,2); D = D0; % state dimension D1 = D0 + 2*length(cost.angle); % state dimension (with sin/cos) M = zeros(D1,1); M(1:D0) = m; S = zeros(D1); S(1:D0,1:D0) = s; Mdm = [eye(D0); zeros(D1-D0,D0)]; Sdm = zeros(D1*D1,D0); Mds = zeros(D1,D0*D0); Sds = kron(Mdm,Mdm); % 2. Define static penalty as distance from target setpoint target = [cost.target(:); gTrig(cost.target(:), 0*s, cost.angle)]; ell1 = cost.p(1); ell2 = cost.p(2); C = [1 -ell1 0 -ell2 0; 0 0 ell1 0 ell2]; Q = zeros(D1); Q([1 D+1:D+4],[1 D+1:D+4]) = C'*C; % 3. Trigonometric augmentation i = 1:D0; k = D0+1:D1; [M(k) S(k,k) C mdm sdm Cdm mds sds Cds] = gTrig(M(i),S(i,i),cost.angle); [S Mdm Mds Sdm Sds] = ... fillIn(S,C,mdm,sdm,Cdm,mds,sds,Cds,Mdm,Sdm,Mds,Sds,i,k,D1); % 4. Calculate loss L = 0; dLdm = zeros(1,D0); dLds = zeros(1,D0*D0); S2 = 0; for i = 1:length(cw) % scale mixture of immediate costs cost.z = target; cost.W = Q/cw(i)^2; [r rdM rdS s2 s2dM s2dS] = lossSat(cost, M, S); L = L + r; S2 = S2 + s2; dLdm = dLdm + rdM(:)'*Mdm + rdS(:)'*Sdm; dLds = dLds + rdM(:)'*Mds + rdS(:)'*Sds; if (b~=0 || ~isempty(b)) && abs(s2)>1e-12 L = L + b*sqrt(s2); dLdm = dLdm + b/sqrt(s2) * ( s2dM(:)'*Mdm + s2dS(:)'*Sdm )/2; dLds = dLds + b/sqrt(s2) * ( s2dM(:)'*Mds + s2dS(:)'*Sds )/2; end end % normalize n = length(cw); L = L/n; dLdm = dLdm/n; dLds = dLds/n; S2 = S2/n; % Fill in covariance matrix...and derivatives ---------------------------- function [S Mdm Mds Sdm Sds] = ... fillIn(S,C,mdm,sdm,Cdm,mds,sds,Cds,Mdm,Sdm,Mds,Sds,i,k,D) X = reshape(1:D*D,[D D]); XT = X'; % vectorised indices I=0*X; I(i,i)=1; ii=X(I==1)'; I=0*X; I(k,k)=1; kk=X(I==1)'; I=0*X; I(i,k)=1; ik=X(I==1)'; ki=XT(I==1)'; Mdm(k,:) = mdm*Mdm(i,:) + mds*Sdm(ii,:); % chainrule Mds(k,:) = mdm*Mds(i,:) + mds*Sds(ii,:); Sdm(kk,:) = sdm*Mdm(i,:) + sds*Sdm(ii,:); Sds(kk,:) = sdm*Mds(i,:) + sds*Sds(ii,:); dCdm = Cdm*Mdm(i,:) + Cds*Sdm(ii,:); dCds = Cdm*Mds(i,:) + Cds*Sds(ii,:); S(i,k) = S(i,i)*C; S(k,i) = S(i,k)'; % off-diagonal SS = kron(eye(length(k)),S(i,i)); CC = kron(C',eye(length(i))); Sdm(ik,:) = SS*dCdm + CC*Sdm(ii,:); Sdm(ki,:) = Sdm(ik,:); Sds(ik,:) = SS*dCds + CC*Sds(ii,:); Sds(ki,:) = Sds(ik,:);