text:
function [totalz, zscore, mdvs] = compareMultSamp(xglc, model, samps, measuredMetabolites)
% Compare the multiple sets of samples
%
% USAGE:
%
%    [totalz, zscore, mdvs] = compareMultSamp(xglc, model, samps, measuredMetabolites)
%
% INPUTS:
%    xglc:                   sugar distribution, a random sugar distribution is calculated if empty
%    model:                  model structure, expects `model.rxns` to contain a list of rxn names
%    samps:                  samples, expects to have a field named points containing an array of sampled points
%
% OPTIONAL INPUT:
%    measuredMetabolites:    parameter fed to `calcMDVfromSamp.m` which only calculates the MDVs for the metabolites listed in this array
%
% OUTPUTS:
%    totalz:                 sum of all zscores
%    zscore:                 calculated difference for each mdv element distributed across all the points
%    mdvs:                   contains fields:
%
%                              * mdv - the calculated mdv distribution converted from the idv
%                                solved from each point contained in their respective samples `sampX`
%                              * names - the names of the metabolites
%                              * ave - the average of each mdv element across all of the points
%                              * stdev - the standard dev for each mdv element across all points
%
% .. Author: - Wing Choi 2/11/08

if (nargin < 3)
    error '[totalz,zscore,mdvs] = compareMultSamp(xglc,model,samps,measuredMetabolites)';
end

if (nargin < 4)
    measuredMetabolites = [];
end

mdvs.ave = [];
mdvs.stdev = [];

if (isempty(xglc))
    % random glucose
    xglc = rand(64,1);
    xglc = xglc/sum(xglc);
    xglc = idv2cdv(6)*xglc;
end

    % generate the translation index array
    %   can shave time by not regenerating this array on every call.
    xltmdv = zeros(1,4096);
    for i = 1:4096
        xltmdv(i) = length(strrep(dec2base(i-1,2),'0',''));
    end

% calculate mdv for samp1 and samp2
for i = 1:length(samps)
    samp.points = samps(i).points;
    mdv = calcMDVfromSamp(model,xglc,samp,measuredMetabolites);
    l = length(mdv.ave);
    mdvs.ave(1:l,i) = mdv.ave;
    mdvs.stdev(1:l,i) = mdv.stdev;
%[mdv2] = calcMDVfromSamp(model,xglc,samp2,measuredMetabolites);
%[totalz,zscore] = compareTwoMDVs(mdv1,mdv2);
end

totalz = 0;
zscore = 0;
%mdvs = mdv;

return
end

%Here's what the function does.
%Apply slvrXXfast to each point
%for each field in the output, apply iso2mdv to get a much shorter vector.
%store all the mdv's for each point and for each metabolite in both sets.
%
%Compute the mean and standard deviation of each mdv and then get a z-score
% between them (=(mean1-mean2)/(sqrt(sd1^2+sd2^2))).
%Add up all the z-scores (their absolute value) and have this function return
% that value.
%
%Intuitively what we're doing here is comparing the two sets based on
% how different the mdv's appear.
%We're going to see if different glucose mixtures result in different values.
%I'm going to rewrite part of slvrXXfast so it doesn't return every metabolite
% but only those we can actually measure, but for now just make it generic.

function mdv = myidv2mdv (idv,xltmdv)

    % generate the mdv
    len = length(idv);
    %disp(sprintf('idv is %d long',len));
    mdv = zeros(1,xltmdv(len)+1);
    %disp(sprintf('mdv is %d long',length(mdv)));
    for i = 1:len
        idx = xltmdv(i) + 1;
        %disp(sprintf('idx is %d, currently on %d',idx,i));
        mdv(idx) = mdv(idx) + idv(i);
    end

return
end

author: opencobra

repo: cobratoolbox


text:
function [t, measurement_overhead, measurement_details] = timeit(f, num_outputs)
%TIMEIT Measure time required to run function.
%   T = TIMEIT(F) measures the time (in seconds) required to run F, which is a
%   function handle.  TIMEIT calls F with either no output arguments or one
%   output argument depending on nargout(F).
%
%   T = TIMEIT(F,N) calls F with N output arguments.  N can be 0, 1, 2, 3, 4, or 5.
%
%   TIMEIT handles automatically the usual benchmarking procedures of "warming
%   up" F, figuring out how many times to repeat F in a timing loop, etc.
%   TIMEIT also compensates for the estimated time-measurement overhead
%   associated with tic/toc and with calling function handles.  TIMEIT returns
%   the median of several repeated measurements.
%
%   Examples
%   --------
%   How much time does it take to compute sum(A.' .* B, 1), where A is
%   12000-by-400 and B is 400-by-12000?
%
%       A = rand(12000, 400);
%       B = rand(400, 12000);
%       f = @() sum(A.' .* B, 1);
%       timeit(f)
%
%   How much time does it take to call svd with three output arguments?
%
%       X = [1 2; 3 4; 5 6; 7 8];
%       f = @() svd(X);
%       timeit(f, 3)
%
%   How much time does it take to dilate the text.png image with
%   a 25-by-25 all-ones structuring element? (This example uses Image Processing
%   Toolbox functions.)
%
%       bw = imread('text.png');
%       se = strel(ones(25, 25));
%       g = @() imdilate(bw, se);
%       timeit(g)

%   Steve Eddins
%   Copyright 2008-2010 The MathWorks, Inc.

if nargin < 2
    num_outputs = min(numOutputs(f), 1);
else
    if num_outputs > 5
        warning('MATLAB:timeit:tooManyOutputs', ...
            'Too many function output arguments specified. timeit will call your function with 5 output arguments.');
    end
end

t_rough = roughEstimate(f, num_outputs);

% Calculate the number of inner-loop repetitions so that the inner for-loop
% takes at least about 1ms to execute.
desired_inner_loop_time = 0.001;
num_inner_iterations = max(ceil(desired_inner_loop_time / t_rough), 1);

% Run the outer loop enough times to give a reasonable set of inputs to median.
num_outer_iterations = 11;

% If the estimated running time for the timing loops is too long,
% reduce the number of outer loop iterations.
estimated_running_time = num_outer_iterations * num_inner_iterations * t_rough;
long_time = 15;
min_outer_iterations = 3;
if estimated_running_time > long_time
    num_outer_iterations = ceil(long_time / (num_inner_iterations * t_rough));
    num_outer_iterations = max(num_outer_iterations, min_outer_iterations);
end

times = zeros(num_outer_iterations, 1);

for k = 1:num_outer_iterations
    % Coding note: An earlier version of this code constructed an "outputs" cell
    % array, which was used in comma-separated form for the left-hand side of
    % the call to f().  It turned out, though, that the comma-separated output
    % argument added significant measurement overhead.  Therefore, the cases
    % for different numbers of output arguments are hard-coded into the switch
    % statement below.
    switch num_outputs
        case 0
            tic();
            for p = 1:num_inner_iterations
                f();
            end
            times(k) = toc();

        case 1
            tic();
            for p = 1:num_inner_iterations
                output = f();
            end
            times(k) = toc();

        case 2
            tic();
            for p = 1:num_inner_iterations
                [output1, output2] = f();
            end
            times(k) = toc();

        case 3
            tic();
            for p = 1:num_inner_iterations
                [output1, output2, output3] = f();
            end
            times(k) = toc();

        case 4
            tic();
            for p = 1:num_inner_iterations
                [output1, output2, output3, output4] = f();
            end
            times(k) = toc();

        otherwise
            tic();
            for p = 1:num_inner_iterations
                [output1, output2, output3, output4, output5] = f();
            end
            times(k) = toc();
    end

end

t = median(times) / num_inner_iterations;

measurement_details.EmptyFunctionCallTime = emptyFunctionCallTime();
measurement_details.SimpleFunctionHandleCallTime = simpleFunctionHandleCallTime();
measurement_details.AnonymousFunctionHandleCallTime = anonFunctionHandleCallTime();
measurement_details.TicTocCallTime = tictocCallTime();
measurement_overhead = (tictocCallTime() / num_inner_iterations) + ...
    functionHandleCallOverhead(f);

t = max(t - measurement_overhead, 0);

if t < (5 * measurement_overhead)
    warning('MATLAB:timeit:HighOverhead', 'The measured time for F may be inaccurate because it is close to the estimated time-measurement overhead (%.1e seconds).  Try measuring something that takes longer.', measurement_overhead);
end

function t = roughEstimate(f, num_f_outputs)
%   Return rough estimate of time required for one execution of
%   f().  Basic warmups are done, but no fancy looping, medians,
%   etc.

% Warm up tic/toc.
tic();
elapsed = toc();
tic();
elapsed = toc();

% Call f() in a loop for at least a millisecond.
times = [];
time_threshold = 3;
iter_count = 0;
while sum(times) < 0.001
    iter_count = iter_count + 1;

    switch num_f_outputs
        case 0
            tic();
            f();
            times(end+1) = toc();

        case 1
            tic();
            output1 = f();
            times(end+1) = toc();

        case 2
            tic();
            [output1, output2] = f();
            times(end+1) = toc();

        case 3
            tic();
            [output1, output2, output3] = f();
            times(end+1) = toc();

        case 4
            tic();
            [output1, output2, output3, output4] = f();
            times(end+1) = toc();

        otherwise
            tic();
            [output1, output2, output3, output4, output5] = f();
            times(end+1) = toc();
    end

    if iter_count == 1
        if times > time_threshold
            % If the first call to f() takes more than time_threshold to run,
            % then just use the result from that call.  The assumption is that
            % first-time effects are negligible compared to the running time for
            % f().
            break;
        else
            % Discard first timing.
            times = [];
        end
    end
end

t = median(times);

function n = numOutputs(f)
%   Return the number of output arguments to be used when calling the function
%   handle f.
%   * If nargout(f) > 0, return 1.
%   * If nargout(f) == 0, return 0.
%   * If nargout(f) < 0, use try/catch to determine whether to call f with one
%     or zero output arguments.
%     Note: It is not documented (as of R2008b) that nargout can return -1.
%     However, it appears to do so for functions that use varargout and for
%     anonymous function handles.

n = nargout(f);
if n < 0
   try
      a = f();
      % If the line above doesn't throw an error, then it's OK to call f() with
      % one output argument.
      n = 1;

   catch %#ok<CTCH>
      % If we get here, assume it's because f() has zero output arguments.  In
      % recent versions of MATLAB we could catch the specific exception ID
      % MATLAB:maxlhs, but that would limit the use of timeit to MATLAB versions
      % since the introduction of MExceptions.
      n = 0;
   end
end

function t = tictocCallTime
% Return the estimated time required to call tic/toc.

persistent ttct
if ~isempty(ttct)
    t = ttct;
    return
end

% Warm up tic/toc.
temp = tic(); elapsed = toc();
temp = tic(); elapsed = toc();
temp = tic(); elapsed = toc();

num_repeats = 11;
times = zeros(1, num_repeats);

for k = 1:num_repeats
   times(k) = tictocTimeExperiment();
end

t = min(times);
ttct = t;

function t = tictocTimeExperiment
% Call tic/toc 100 times and return the average time required.

elapsed = 0;
% Call tic/toc 100 times.
tic(); elapsed = elapsed +  toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();
tic(); elapsed = elapsed + toc();

t = elapsed / 100;

function emptyFunction()

function t = functionHandleCallOverhead(f)
% Return the estimated overhead, in seconds, for calling a function handle
% compared to calling a normal function.

fcns = functions(f);
if strcmp(fcns.type, 'anonymous')
    t = anonFunctionHandleCallTime();
else
    t = simpleFunctionHandleCallTime();
end

t = max(t - emptyFunctionCallTime(), 0);

function t = simpleFunctionHandleCallTime
% Return the estimated time required to call a simple function handle to a
% function with an empty body.
%
% A simple function handle fh has the form @foo.

persistent sfhct
if ~isempty(sfhct)
    t = sfhct;
    return
end

num_repeats = 101;
% num_repeats chosen to take about 100 ms, assuming that
% timeFunctionHandleCall() takes about 1 ms.
times = zeros(1, num_repeats);

fh = @emptyFunction;

% Warm up fh().
fh();
fh();
fh();

for k = 1:num_repeats
   times(k) = functionHandleTimeExperiment(fh);
end

t = min(times);
sfhct = t;

function t = anonFunctionHandleCallTime
% Return the estimated time required to call an anonymous function handle that
% calls a function with an empty body.
%
% An anonymous function handle fh has the form @(arg_list) expression. For
% example:
%
%       fh = @(thetad) sin(thetad * pi / 180)

persistent afhct
if ~isempty(afhct)
    t = afhct;
    return
end

num_repeats = 101;
% num_repeats chosen to take about 100 ms, assuming that timeFunctionCall()
% takes about 1 ms.
times = zeros(1, num_repeats);

fh = @() emptyFunction();

% Warm up fh().
fh();
fh();
fh();

for k = 1:num_repeats
   times(k) = functionHandleTimeExperiment(fh);
end

t = min(times);
afhct = t;

function t = functionHandleTimeExperiment(fh)
% Call the function handle fh 2000 times and return the average time required.

% Record starting time.
tic();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();
fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh(); fh();

t = toc() / 2000;

function t = emptyFunctionCallTime()
% Return the estimated time required to call a function with an empty body.

persistent efct
if ~isempty(efct)
    t = efct;
    return
end

% Warm up emptyFunction.
emptyFunction();
emptyFunction();
emptyFunction();

num_repeats = 101;
% num_repeats chosen to take about 100 ms, assuming that timeFunctionCall()
% takes about 1 ms.
times = zeros(1, num_repeats);

for k = 1:num_repeats
   times(k) = emptyFunctionTimeExperiment();
end

t = min(times);
efct = t;

function t = emptyFunctionTimeExperiment()
% Call emptyFunction() 2000 times and return the average time required.

% Record starting time.
tic();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();
emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction(); emptyFunction();

t = toc() / 2000;

% Copyright (c) 2010, The MathWorks, Inc.
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
%     * Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%     * Redistributions in binary form must reproduce the above copyright
%       notice, this list of conditions and the following disclaimer in
%       the documentation and/or other materials provided with the distribution
%     * Neither the name of the The MathWorks, Inc. nor the names
%       of its contributors may be used to endorse or promote products derived
%       from this software without specific prior written permission.
%
% 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.

author: alecjacobson

repo: gptoolbox


text:
%kWaveletSpots 'localizes spots based on wavelet analysis '
% This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros WaveletSpots.pane file
%
% Parameters:
% InputFile: i 'Input ', required: 'First Input data object'
% Integer: nw 'Wavelet Levels', default: 3: 'number of wavelet levels to account for'
% Integer: mw 'First Wavelet', default: 1: 'number of first wavelet that counts for thresholding (starting with 0)'
% Double: krel 'Relative k', default: 3: 'this factor defines the threshold for the wavelet images prior to multiplication'
% OutputFile: o1 'Filtered', optional: 'Filtered images'
% OutputFile: o2 'Wavelet', optional: 'Wavelet decomposition (a trous)'
% OutputFile: o3 'Output', required: 'Multiplication of the wavelets to be thresholded'
%
% Example: [o1, o2, o3] = kWaveletSpots(i, {'i','';'nw',3;'mw',1;'krel',3;'o1','';'o2','';'o3',''})
%
% Khoros helpfile follows below:
%
%  PROGRAM
% WaveletSpots - localizes spots based on wavelet analysis
%
%  DESCRIPTION
%
%
%
%  EXAMPLES
%
%  "SEE ALSO"
%
%  RESTRICTIONS
%
%  REFERENCES
%
%  COPYRIGHT
% Copyright (C) 1996-2003, Rainer Heintzmann,  All rights reserved.
%

function varargout = kWaveletSpots(varargin)
if nargin ==0
  Inputs={};arglist={'',''};
elseif nargin ==1
  Inputs=varargin{1};arglist={'',''};
elseif nargin ==2
  Inputs=varargin{1}; arglist=varargin{2};
else error('Usage: [out1,..] = kWaveletSpots(Inputs,arglist).');
end
if size(arglist,2)~=2
  error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
 end
narglist={'i', '__input';'nw', 3;'mw', 1;'krel', 3;'o1', '__output';'o2', '__output';'o3', '__output'};
maxval={0,2,1,0,1,1,0};
minval={0,2,1,0,1,1,0};
istoggle=[0,0,0,1,1,1,0];
was_set=istoggle * 0;
paramtype={'InputFile','Integer','Integer','Double','OutputFile','OutputFile','OutputFile'};
% identify the input arrays and assign them to the arguments as stated by the user
if ~iscell(Inputs)
Inputs = {Inputs};
end
NumReqOutputs=1; nextinput=1; nextoutput=1;
  for ii=1:size(arglist,1)
  wasmatched=0;
  for jj=1:size(narglist,1)
   if strcmp(arglist{ii,1},narglist{jj,1})  % a given argument was matched to the possible arguments
     wasmatched = 1;
     was_set(jj) = 1;
     if strcmp(narglist{jj,2}, '__input')
      if (nextinput > length(Inputs))
        error(['Input ' narglist{jj,1} ' has no corresponding input!']);
      end
      narglist{jj,2} = 'OK_in';
      nextinput = nextinput + 1;
     elseif strcmp(narglist{jj,2}, '__output')
      if (nextoutput > nargout)
        error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
      end
      if (isempty(arglist{ii,2}))
        narglist{jj,2} = 'OK_out';
      else
        narglist{jj,2} = arglist{ii,2};
      end

      nextoutput = nextoutput + 1;
      if (minval{jj} == 0)
         NumReqOutputs = NumReqOutputs - 1;
      end
     elseif isstr(arglist{ii,2})
      narglist{jj,2} = arglist{ii,2};
     else
        if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
            error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
        end
        if (minval{jj} ~= 0 | maxval{jj} ~= 0)
          if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
            error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
          elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
            error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
          elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
            error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
          elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
            error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
          elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
            error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
          elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
            error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
          end
        end
     end
     if ~strcmp(narglist{jj,2},'OK_out') &  ~strcmp(narglist{jj,2},'OK_in')
       narglist{jj,2} = arglist{ii,2};
     end
   end
   end
   if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
        error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
   end
end
% match the remaining inputs/outputs to the unused arguments and test for missing required inputs
 for jj=1:size(narglist,1)
     if  strcmp(paramtype{jj}, 'Toggle')
        if (narglist{jj,2} ==0)
          narglist{jj,1} = '';
        end;
        narglist{jj,2} = '';
     end;
     if  ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
          narglist{jj,1} = '';
          narglist{jj,2} = '';
     end;
     if strcmp(narglist{jj,2}, '__input')
      if (minval{jj} == 0)  % meaning this input is required
        if (nextinput > size(Inputs))
           error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
        else
          narglist{jj,2} = 'OK_in';
          nextinput = nextinput + 1;
        end
      else  % this is an optional input
        if (nextinput <= length(Inputs))
          narglist{jj,2} = 'OK_in';
          nextinput = nextinput + 1;
        else
          narglist{jj,1} = '';
          narglist{jj,2} = '';
        end;
      end;
     else
     if strcmp(narglist{jj,2}, '__output')
      if (minval{jj} == 0) % this is a required output
        if (nextoutput > nargout & nargout > 1)
           error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
        else
          narglist{jj,2} = 'OK_out';
          nextoutput = nextoutput + 1;
          NumReqOutputs = NumReqOutputs-1;
        end
      else % this is an optional output
        if (nargout - nextoutput >= NumReqOutputs)
          narglist{jj,2} = 'OK_out';
          nextoutput = nextoutput + 1;
        else
          narglist{jj,1} = '';
          narglist{jj,2} = '';
        end;
      end
     end
  end
end
if nargout
   varargout = cell(1,nargout);
else
  varargout = cell(1,1);
end
global KhorosRoot
if exist('KhorosRoot') && ~isempty(KhorosRoot)
w=['"' KhorosRoot];
else
if ispc
  w='"C:\Program Files\dip\khorosBin\';
else
[s,w] = system('which cantata');
w=['"' w(1:end-8)];
end
end
[varargout{:}]=callKhoros([w 'waveletspots"  -k'],Inputs,narglist);

author: aludnam

repo: MATLAB

save_path: github-repos/MATLAB/aludnam-MATLAB


text:
%  This program is free software; you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published by
%  the Free Software Foundation; either version 2 of the License, or
%  (at your option) any later version.
%
%  This program is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.
%
%  You should have received a copy of the GNU General Public License
%  along with this program; if not, write to the Free Software
%  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
%function tfrridht
%TFRRIDHT Unit test for the function TFRRIDH.

%       F. Auger, Dec. 1995 - O. Lemoine, March 1996.

% We test each property of the corresponding TFR :

N=128;

% Covariance by translation in time
t1=55; t2=70; f=0.3;
sig1=amgauss(N,t1).*fmconst(N,f,t1);
sig2=amgauss(N,t2).*fmconst(N,f,t2);
tfr1=tfrridh(sig1);
tfr2=tfrridh(sig2);
[tr,tc]=size(tfr1);
nu=round(f*(tc-1)*2)+1;
tfr=tfr1-tfr2(:,modulo((1:tc)-t1+t2,tc));
if any(any(abs(tfr)>sqrt(eps))),
 error('tfrridh test 1 failed');
end

% Reality of the TFR
sig=noisecg(N);
tfr=tfrridh(sig);
if sum(any(abs(imag(tfr))>sqrt(eps)))~=0,
 error('tfrridh test 2 failed');
end

% Energy conservation
sig=noisecg(N);
tfr=tfrridh(sig);
Es=norm(sig)^2;
Etfr=sum(mean(tfr));
if abs(Es-Etfr)>sqrt(eps),
 error('tfrridh test 3 failed');
end

% Time-marginal
sig=noisecg(N);
tfr=tfrridh(sig);
ip1=abs(sig).^2;
ip2=mean(tfr)';
if any(abs(ip1-ip2)>sqrt(eps)),
 error('tfrridh test 4 failed');
end

% Frequency-marginal
sig=noisecg(N);
tfr=tfrridh(sig,1:N,N,[1],ones(N-1,1));
FFT=fft(sig);
psd1=abs(FFT(2:N/2)).^2/(2*N);
psd2=mean(tfr(1:2:N,:)')';
if any(abs(psd1-psd2(2:N/2))>sqrt(eps)),
 error('tfrridh test 5 failed');
end

% Conservation of the time support (wide-sense)
sig=[zeros(N/4,1);noisecg(N/2);zeros(N/4,1)];
tfr=tfrridh(sig);
if sum(any(abs(tfr(:,1:N/4-1))>sqrt(eps))) | ...
   sum(any(abs(tfr(:,(3*N/4+1):N))>sqrt(eps))),
 error('tfrridh test 6 failed');
end

% time localization
t0=30; sig=((1:N)'==t0);
tfr=tfrridh(sig);
[ik,jk]=find(tfr~=0.0);
if any(jk~=t0)|any(ik'-(1:N)),
 error('tfrridh test 7 failed');
end;

% frequency localization
f0=10;
sig=fmconst(N+6,f0/N);
tfr=tfrridh(sig,N/2+2,N,tftb_window(11,'rect'),tftb_window(N+1,'rect'));
if (find(tfr>1/N)~=2*f0+1)|(abs(mean(tfr)-1.0)>2.0*eps),
 error('tfrridh test 8 failed');
end;

clear; N=131;

% Covariance by translation in time
t1=55; t2=70; f=0.3;
sig1=amgauss(N,t1).*fmconst(N,f,t1);
sig2=amgauss(N,t2).*fmconst(N,f,t2);
tfr1=tfrridh(sig1);
tfr2=tfrridh(sig2);
[tr,tc]=size(tfr1);
nu=round(f*(tc-1)*2)+1;
tfr=tfr1-tfr2(:,modulo((1:tc)-t1+t2,tc));
if any(any(abs(tfr)>sqrt(eps))),
 error('tfrridh test 9 failed');
end

% Reality of the TFR
sig=noisecg(N);
tfr=tfrridh(sig);
if sum(any(abs(imag(tfr))>sqrt(eps)))~=0,
 error('tfrridh test 10 failed');
end

% Energy conservation
sig=noisecg(N);
tfr=tfrridh(sig);
Es=norm(sig)^2;
Etfr=sum(mean(tfr));
if abs(Es-Etfr)>sqrt(eps),
 error('tfrridh test 11 failed');
end

% Time-marginal
sig=noisecg(N);
tfr=tfrridh(sig);
ip1=abs(sig).^2;
ip2=mean(tfr)';
if any(abs(ip1-ip2)>sqrt(eps)),
 error('tfrridh test 12 failed');
end

% Frequency-marginal
sig=noisecg(N);
tfr=tfrridh(sig,1:N,N,[1],ones(N,1));
FFT=fft(sig);
psd1=abs(FFT(3:fix(N/2)-3)).^2/(2*N);
psd2=mean(tfr(1:2:N,:)')';
if any(abs(psd1-psd2(3:fix(N/2)-3))>5e-2),
 error('tfrridh test 13 failed');
end

% Conservation of the time support (wide-sense)
sig=[zeros(round(N/4),1);noisecg(round(N/2));zeros(round(N/4),1)];
tfr=tfrridh(sig);
if sum(any(abs(tfr(:,1:round(N/4)-1))>sqrt(eps))) | ...
   sum(any(abs(tfr(:,(round(3*N/4)+2):N))>sqrt(eps))),
 error('tfrridh test 14 failed');
end

% time localization
t0=30; sig=((1:N)'==t0);
tfr=tfrridh(sig);
[ik,jk]=find(tfr~=0.0);
if any(jk~=t0)|any(ik'-(1:N)),
 error('tfrridh test 15 failed');
end;

% frequency localization
f0=10;
sig=fmconst(N+6,f0/N);
tfr=tfrridh(sig,round(N/2)+2,N,tftb_window(11,'rect'),tftb_window(N,'rect'));
if (find(tfr>1/N)~=2*f0+1)|(abs(mean(tfr)-1.0)>sqrt(eps)),
 error('tfrridh test 16 failed');
end;

author: HeLiangHIT


text:
clc; clear all; close all;

dd = 'C:\Users\Doyeunlee\Desktop\Analysis\rawdata\convert\';
filelist = 'dslim_multigrasp_MI';

%% Band topography
[cnt, mrk, mnt]=eegfile_loadMatlab([dd filelist]);

% band power
band= [4 8];
ival=[0 45000];
[b,a]= butter(5, band/cnt.fs*2);
cnt_flt= proc_filt(cnt, b, a);

epo = cntToEpo(cnt_flt, mrk, ival);

spec= proc_spectrum(epo, [4 8]);

% H = scalpPlot(mnt, spec);
figure('Name', 'CSP Patterns');
plotCSPatterns(csp_fv, mnt, csp_w, csp_fv.y)

plotCSPatterns(fv, mnt, W, la);

author: PatternRecognition

repo: OpenBMI


text:
function [subtree, nroot_node] = min_subtree_con_nodes(jtree, root, nodes)
%min_subtree_con_nodes get the minimum subtree of tree which contains the nodes

if isempty(jtree) | isempty(nodes)
    subtree = [];
    nroot_node = [];
    return;
end

rnodes = min_subtree_nodes(jtree, nodes);
nea_node = nearest_node(jtree, root, nodes);
node_num = length(jtree);
subtree = zeros(node_num);
subtree(rnodes, rnodes) = jtree(rnodes, rnodes);
nroot_node = nea_node;

function rnodes = min_subtree_nodes(tree, nodes)
rnodes = [];
if isempty(tree) | isempty(nodes)
    return
end

rnodes = nodes(1);
newnodes = neighbors(tree, nodes(1));
while ~mysubset(nodes, rnodes)
    swapnodes = newnodes;
    newnodes = [];
    added = 0;
    for i=1:length(swapnodes)
        inode = swapnodes(i);
        tnodes = myunion(inode, rnodes);
        if mysubset(nodes, tnodes)
            added = 1;
            break;
        end
        nns = neighbors(tree, inode);
        add_nodes = mysetdiff(nns, tnodes);
        newnodes = myunion(newnodes, add_nodes);
    end
    if added
        rnodes = tnodes;
    else
        rnodes = myunion(rnodes, newnodes);
    end
end

function nea_node = nearest_node(tree, inode, nodes)
if myismember(inode, nodes)
    nea_node = inode;
    return;
end
cs = children(tree, inode);
for i = 1:length(cs)
    n = cs(i);
    nea_node = nearest_node(tree, n, nodes);
end

author: bayesnet

repo: bnt

save_path: github-repos/MATLAB/bayesnet-bnt


text:
function x=lincon(a,b,n)
%System of linear congruences
%   X = LINCON(A,B,N) solves the system of linear congruences
%
%       A(1) * X == B(1)  (mod N(1))
%       A(2) * X == B(2)  (mod N(2))
%       ...
%       A(m) * X == B(m)  (mod N(m))
%
%   The solution, X, will be given as a vector [x1 x2]
%   representing the general solution
%
%              X == x1  (mod x2)
%
%   Any specific answer can be found by letting
%   X = x1 + x2 * k  for any integer value of k.
%
%   If no solution exists [NaN NaN] will be returned.
%
%   A scalar input functions as a constant vector of the
%   same size as the other inputs.
%
%   Program is compatible with Variable Precision Integer
%   Arithmetic Toolbox available on File Exchange (#22725)
%   Use of VPI is recommended for large magnitude inputs
%   or outputs. If VPI is not used and internal calculations
%   exceed largest consecutive flint a warning will be given
%   that results may be inaccurate, along with [NaN NaN].
%
%   Example #1:
%   Solve the following system of linear congruences
%      2x == 2  (mod 6)
%      3x == 2  (mod 7)
%      2x == 4  (mod 8)
%
%   Solution:
%      a=[2 3 2]; b=[2 2 4]; n=[6 7 8];
%      x=lincon(a,b,n)
%
%   Verify:
%      isequal( mod(a*x(1),n) , b)
%
%
%   Example #2:
%   Use of VPI for large magnitude numbers. Solve the following
%   system of linear congruences
%         (1234567)x == 89       (mod 2^32)
%         (9876543)x == 21       (mod 3^50)
%            (5555)x == 62830211 (mod 7^10)
%
%   Solution:
%     a=[1234567 9876543 5555]; b=[89 21 62830211];
%     n=[vpi(2)^32 vpi(3)^50 vpi(7)^10];
%     x=lincon(a,b,n)
%
%   Verify:
%     isequal( mod(a*x(1),n) , b)
%

%   Mike Sheppard
%   Last Modified 11-Sep-2011

%Check Inputs
[a,b,n,isvpi]=LinConCheckInputs(a,b,n);

%Initialize
b=mod(b,n);  % Make all positive for consistency
m=length(a); % Number of congruences
x=[0 1];     % Initialize to x==0  (mod 1)
k=0;         % line number

while k<m

  k=k+1;

  % Go line by line, using previous solutions of X
  % as starting points for each line

  % Original k'th Equation, shown as scalar valued:
  %    a * X == b  (mod n)
  % However, X == x1  (mod x2), substituting in for X
  %    a * (x1 + x2*V) == b  (mod n)
  % Simplifying
  %    a * x2 * V == (b - a*x1)  (mod n)
  % Relabel, and now solve for V for the modified equation
  %    ak * V == bk  (mod n)

  ak=a(k)*x(2);
  bk=mod(b(k)-a(k)*x(1),n(k)); %Positive for consistency
  nk=n(k);

  % Use Linear congruence theorem
  % Solving ak * V = bk  (mod n) for V

  if isvpi
      [gk,ck,dk]=vpigcd2(ak,nk); %Subfunction below
  else
      [gk,ck,dk]=gcd(ak,nk);
  end

  % GK = CK*[AK] + DK*[NK]
  % (Extended Euclidean algorithm)

  if mod(bk,gk)==0 % Solution exists
      % V == v1  (mod v2)
      v2=nk/gk;
      v1=mod(ck*bk/gk,v2); %Positive for consistency
      v=[v1 v2];
  else % No valid solution
      v=[NaN NaN];
      k=Inf; %Terminate loop
  end

  % Solution to modified equation is
  %    V == v1  (mod v2)
  % From before, X is given by
  %    X = x1 + x2*V
  % Substituting in for V yields
  %    X == (x1+x2*v1) (mod x2*v2)
  % Redefine new solution for X for use in next iteration

  if isfinite(k)
      x=[x(1)+x(2)*v(1) x(2)*v(2)];
  else
      x=[NaN NaN]; %No valid solution
  end

end

% Solution is found
%    X == x1  (mod x2)

end

%SUBFUNCTIONS
%------------
function [a,b,n,isvpi]=LinConCheckInputs(a,b,n)

%Make column vectors
a=a(:); b=b(:); n=n(:);

%Check to see if all are integer valued
if any(a~=round(a)) || any(b~=round(b)) || any(n~=round(n))
   error('LINCON : Input vectors must be same size')
end

%Check sizes, they can either be scalar or same-sized vectors
na=length(a); nb=length(b); nn=length(n); m=max([na nb nn]);
if ~all([na nb nn]==m | [na nb nn]==1)
   error('LINCON : Non-scalar arguments must match in size.')
end

%If scalar, redefine as vectors of same size as other inputs
if na==1, a=a*ones(m,1); end
if nb==1, b=b*ones(m,1); end
if nn==1, n=n*ones(m,1); end

%Check to see if using VPI (Variable Precision Integers)
%Toolbox is available here:
%http://www.mathworks.com/matlabcentral/fileexchange/22725
isvpi=any(strcmp({class(a) class(b) class(n)},'vpi'));

end

function [g,c,d] = vpigcd2(a,b)
% Built-in GCD code given in VPI Toolbox solves
% for just the GCD; however, the coefficients for
% G = C*[A] + D*[B]
% are needed. This subfunction replaces the
% built-in GCD algorithm in VPI with one that
% uses the Extended Euclidean Algorithm
% (Simplified version of Matlab's built-in GCD)

c = 0; d = 0; g = 0;
u = [1 0 abs(a)];
v = [0 1 abs(b)];

while v(3)~=0
    q = quotient(u(3),v(3));
    t = u - v*q;
    u = v;
    v = t;
end

c = u(1) * sign(a);
d = u(2) * sign(b);
g = u(3);

end

author: Sable

repo: mcbench-benchmarks


text:
function [tmpS study] = dicomrt_d2c_SPECT(SPECTInitS,study)
% dicomrt_d2c_SPECT(SPECTInitS,study)
%
% converts the passed PET Cell to CERR structure.
% SPECTInitS is the initialized CERR structure representing PET scan.
%
% study is the actual PET Cell with following structure
%         PETCell{1} = PET_Scan_Info;
%         PETCell{2} = PET_Scan;
%         PETCell{3} = xVec;
%         PETCell{4} = yVec;
%         PETCell{5} = sort(ZSlice);
%
% Created DK

tmpS.scanArray            = study{2};
tmpS.scanType             = 'NM';
tmpS.scanInfo             = SPECTInitS;
tmpS.uniformScanInfo      = '';
tmpS.scanArraySuperior    = '';
tmpS.scanArrayInferior    = '';
tmpS.scanUID              = createUID('SCAN');

[tags study]=dicomrt_d2c_SPECTcoordsystem(study);

type = 'NM';
info = study{1};
xmesh = study{3};
ymesh = study{4};
zmesh = study{5};
% Scan info
for i=1:length(study{5}) % loop through the number of slices
    % it would be possible to retrive dimensions from the CT images info
    % however for consistency we get ct_xmesh ct_ymesh and ct_zmesh already calculated

    % Fill SPECTInitS
    SPECTInitS(i).imageNumber            = i;
    SPECTInitS(i).imageType              = type;
    SPECTInitS(i).patientName            = [info.PatientName.FamilyName];
    try
        SPECTInitS(i).patientName            = [SPECTInitS(i).patientName,' ', ...
            info.PatientName.GivenName]; % may be not present in anonymized studies
    end
    SPECTInitS(i).scanType               = info.ImageType;
    SPECTInitS(i).grid1Units             = tags.grid1Units;
    SPECTInitS(i).grid2Units             = tags.grid2Units;
    SPECTInitS(i).numberRepresentation   = 'TWO''S COMPLEMENT INTEGER';                 % LEAVE FOR NOW
    SPECTInitS(i).bytesPerPixel          = 2;                                           % LEAVE FOR NOW
    SPECTInitS(i).numberOfDimensions     = length(info.PixelSpacing);
    SPECTInitS(i).sizeOfDimension1       = double(info.Rows);
    SPECTInitS(i).sizeOfDimension2       = double(info.Columns);
    SPECTInitS(i).zValue                 = zmesh(i);
    SPECTInitS(i).xOffset                = tags.xOffset;
    SPECTInitS(i).yOffset                = tags.yOffset;
    SPECTInitS(i).CTOffset               = 0;
    SPECTInitS(i).sliceThickness         = info.SliceThickness.*0.1;
    try
        SPECTInitS(i).siteOfInterest         = info.StudyDescription;
    catch
        SPECTInitS(i).siteOfInterest         = info.StudyID;
    end

    try
        SPECTInitS(i).scanDescription        = info.StudyDescription;
    catch
        SPECTInitS(i).scanDescription        = info.StudyID;
    end

    SPECTInitS(i).scannerType            = info.Manufacturer;
    SPECTInitS(i).scanFileName           = info.Filename;
    try
        SPECTInitS(i).headInOut              = tags.hio;
    end
    try
        SPECTInitS(i).positionInScan         = tags.pos;
    end

    SPECTInitS(i).scanNumber             = info.InstanceNumber;

    try
        SPECTInitS(i).scanDate           = info.ImageDate;
    catch
        SPECTInitS(i).scanDate           ='';
    end
    SPECTInitS(i).transferProtocol       = 'DICOM';
    SPECTInitS(i).DICOMHeaders           = info;
    try
        SPECTInitS(i).PatientAge               = info.PatientAge;
    end
    try
        SPECTInitS(i).PatientWeight            = info.PatientWeight;
    end

    SPECTInitS(i).RadiopharmaceuticalInformationSequence  = info.RadiopharmaceuticalInformationSequence;
    SPECTInitS(i).PatientOrientationCodeSequence          = info.PatientOrientationCodeSequence ;
    SPECTInitS(i).PatientGantryRelationshipCodeSequence   = info.PatientGantryRelationshipCodeSequence;
end

% Update nimages
tags.nimages = size(info,2); % number of PET images

% Writing CERR scan data
tmpS.scanInfo             = SPECTInitS;

author: cerr

repo: CERR

save_path: github-repos/MATLAB/cerr-CERR


text:
function varargout = gamma(varargin)

switch class(varargin{1})

    case 'sdpvar'
        varargout{1} = InstantiateElementWise(mfilename,varargin{:});

    case 'char'

        operator = CreateBasicOperator('convex','positive','callback');
        operator.derivative =@(x)psi(0,x).*gamma(x);
        operator.stationary = [1.46163214496836234126 8.856031944108888e-01];
        operator.range = [gamma(1.46163214496836234126) inf];
        operator.domain = [0 inf];

        varargout{1} = [];
        varargout{2} = operator;
        varargout{3} = varargin{3};

    otherwise
        error(['SDPVAR/' upper(mfilename) ' called with weird argument']);
end

author: yalmip

repo: YALMIP

save_path: github-repos/MATLAB/yalmip-YALMIP


text:
function [roiFile, labelFile] = roiSaveAllAsNifti(vw, fname)
% Export all current ROIs in a mrVista view as a nifti segmentation file,
% with each ROI corresponding to a different layer (integer) in the nifti
% file.
%
% [roiFile, labelFile] = roiSaveAllAsNifti(vw, fname, roiColor)
%
% Oct 2008: JW
%
% See roiSaveAsNifti.m

% global variables
mrGlobals;

% get the view struct
if notDefined('vw'), vw = getCurView; end

% check that it's a gray or volume view
viewType = viewGet(vw, 'viewtype');
switch lower(viewType)
    case {'gray', 'volume'}
        nROIs = numel(vw.ROIs);
    otherwise
        error('[%s]: Must be in gray view', mfilename);
end

% check the name of the file to save
if notDefined('fname'),
    fname = [fileparts(vANATOMYPATH) filesep  'ROIs-' datestr(now,1) '.nii.gz'];
end

% make a 3D image with all points set to zero except ROI = roiColor
roiData = zeros(size(vw.anat));

% loop through all ROIs in view struct
for rois = 1:nROIs
    vw = viewSet(vw, 'selected ROI', rois);

    %get ROI coords
    coords = getCurROIcoords(vw);
    nVoxels = size(coords, 2);

    % assign all voxels within the ROI a unique value (the roinum). this
    % will be the label number if the nifti file is imported to itkGray.
    thelabel = rois;

    for voxel = 1:nVoxels
        roiData(coords(1,voxel), coords(2,voxel),coords(3,voxel)) = thelabel;
    end

end

% save the file
roiFile = niftiSaveVistaVolume(vw, roiData, fname);

% create a label file for itkGray
useV1V2V3V4colors = true;
labelFile = saveLabels(vw, useV1V2V3V4colors);

message = sprintf...
    ('ROI file saved as %s.\n\nLabel file save as %s.', roiFile, labelFile);
disp(message);

%------------------------------------------------------------------------

end

%------------------------------------------------------------------------
function fname = saveLabels(vw, useV1V2V3V4colors)
% create and save an itkGray-compatible label file

mrGlobals
if notDefined('useV1V2V3V4colors'), useV1V2V3V4colors = true; end

% create a blank file
fname = [fileparts(vANATOMYPATH) filesep  'ROIs-' datestr(now,1), '.lbl'];
fid = fopen(fname, 'w');

% print some typical headers
h{1} = '################################################';
h{2} = '# ITK-SnAP Label Description File';
h{3} = '# File format:';
h{4} = '# IDX   -R-  -G-  -B-  -A--  VIS MSH  LABEL';
h{5} = '# Fields:';
h{6} = '#    IDX:   Zero-based index ';
h{7} = '#    -R-:   Red color component (0..255)';
h{8} = '#    -G-:   Green color component (0..255)';
h{9} = '#    -B-:   Blue croiSaveAllForItkGrayolor component (0..255)';
h{10} = '#    -A-:   Label transparency (0.00 .. 1.00)';
h{11} = '#    VIS:   Label visibility (0 or 1)';
h{12} = '#    IDX:   Label mesh visibility (0 or 1)';
h{13} = '#  LABEL:   Label description ';
h{14} = '################################################';
for ii = 1:14
    fwrite(fid, sprintf('%s\n',h{ii}));
end

% count the ROIs
nROIs = length(viewGet(vw, 'ROIs'));

% make some colors for the different labels
theColors   = hsv(nROIs);

% type out a line of text into the label file for each ROI
for roi = 1:nROIs

    c = theColors(roi, :);
    rname = vw.ROIs(roi).name;
    % -----------------------------------------------------------
    if useV1V2V3V4colors
        % force a color scheme on the labels for v1/v2/v3/v4
        if strfind(lower(rname), 'v1')
            c = [255 0 0 ];
        elseif strfind(lower(rname), 'v2')
            c = [255 255 0 ];
        elseif strfind(lower(rname), 'v3a')
            c = [255 255 255];
        elseif strfind(lower(rname), 'v3b')
            c = [0 255 255];
        elseif strfind(lower(rname), 'v3')
            c = [0 255 0 ];
        elseif strfind(lower(rname), 'v4')
            c = [0 0 255 ];
        elseif strfind(lower(rname), 'vo1')
            c = [255 255 255 ];
        elseif strfind(lower(rname), 'vo2')
            c = [0 255 255 ];
        elseif strfind(lower(rname), 'lo1')
            c = [255 0 255 ];
        elseif strfind(lower(rname), 'lo2')
            c = [127 127 255 ];
        elseif strfind(lower(rname), 'to1')
            c = [0 255 0];
        elseif strfind(lower(rname), 'to2')
            c = [255 0 0 ];
        end
    end
    %------------------------------------------------------------

    a = sprintf('%d\t%d\t%d\t%d\t1\t1\t1\t"%s"\n', ...
        roi, c(1), c(2), c(3), rname);
    fwrite(fid, a);
end
%fclose('all');

end

author: vistalab

repo: vistasoft

save_path: github-repos/MATLAB/vistalab-vistasoft


text:
function javaview(surface_handle, filename, destination, source, open_html )
% Syntax:
%    javaview(surface_handle, filename, destination, source, open_html)
%
% Description:
%    This function generates output files for Javaview (www.javaview.de).
%    It allows to display and interact with 3d-Graph not only in the
%    javaview engine, but also in html-Documents. See javaview
%    documentation for more information about how to interact.
%
%    There are 4 output files:
%        a) first file (.stl)is generated by the surf2stl function (Many
%           thanks to Bill McDonald, this function is availabe at the MCFE
%           and was pick of the week on June 5th, 2009)
%        b) the second and third file (jvx) and (jvd) are input files for
%           javaview and are generated by mupad. The jvx-file describes the
%           3d-graph, the jvd file descrribes scene options
%        c) the last file is an html file, were the 3d-Graph is displayed
%
%   Because the applet in html file need the javaruntime for javaview the
%   jars directory from the "source" (input parameter) directory is copied
%   to the destination folder.
%   open_html is true or false. When it is true your standard webbrowser is
%   opened and you will see the surface in the html file.
%
%   Parameter:
%       1. surface_handle - handle to surface graph
%       2. filename       - filename for *.stl, .jvx, *.jvd, *.html
%       3. destination    - folder where all files are saved
%       4. source         - source folder of jars (see jvaview installation path)
%       5. open_html      - shows the result html in your standard webbrowser
%
%  Sorry for the work around with the handmade copy and paste when to
%  generate the javaview files. But evalin(symengine, ...) does not produce
%  the required files.
%
% Online Example:
%       http://wwwpub.zih.tu-dresden.de/~s9034647/peaksurface.html
%
% Example:
%       [X,Y,Z] = peaks(30);
%       h = surf(X,Y,Z);
%       javaview(h, 'peaksurface', 'C:\Users\sk\Desktop\3d-PDF\jvtest', 'C:\Program Files (x86)\JavaView\jars', 1)
%
%
% Bugs and suggestions:
%    Please send to Sven Koerner: koerner(underline)sven(add)gmx.de
%
% You need to download and install first:
%    www.javaview.de
%    http://blogs.mathworks.com/pick/2009/06/5/writing-to-stl-files/
%    Symbolic Math Toolbox with MuPad
%
%
% License to use and modify this code is granted freely to all interested, as long as the original author is
% referenced and attributed as such. The original author maintains the right to be solely associated with this work.
%
% Programmed by Sven Koerner: koerner(underline)sven(add)gmx.de
% Date: 2010/04/20

%% Test - Configuration parameter
% open_html       = 0;
% filename        = 'jvfile';
% source          = 'C:\Program Files (x86)\JavaView\jars';  % source folder of jars (installed with javaview)
% destination     = 'C:\Users\sk\Desktop\3d-PDF\jvtest';     % destination folder

%% Get a couple of surface and axis properties
X               = get(surface_handle, 'XData');
Y               = get(surface_handle, 'YData');
Z               = get(surface_handle, 'ZData');

ah              = get(get(surface_handle,'Parent'));
x_lb            = get(ah.XLabel, 'String');
y_lb            = get(ah.YLabel, 'String');
z_lb            = get(ah.ZLabel, 'String');
header          = get(ah.Title,  'String');

%% Generate stl-File
stl_file        = [destination '\' filename '.stl'];
surf2stl(stl_file,X,Y,Z);

%% String generation
p1              =  strrep(stl_file,'\','\\');
p2              =  [filename,'.jvx'];
p3              =  [filename,'.jvd'];

mupad_str1 = ['plot(plot::SurfaceSTL("' p1 ' "), Scaling = Unconstrained, FillColorType=Rainbow, XLinesVisible = FALSE, YLinesVisible = FALSE,MeshVisible = FALSE, Header="' header ...
             '", XAxisTitle=" ' x_lb '", YAxisTitle=" ' y_lb '",  ZAxisTitle="' z_lb '", GridVisible=FALSE, Lighting = None, OutputFile="' p2 '")'];
mupad_str2 = ['plot(plot::SurfaceSTL("' p1 ' "), Scaling = Unconstrained, FillColorType=Rainbow, XLinesVisible = FALSE, YLinesVisible = FALSE,MeshVisible = FALSE, Header="' header ...
             '", XAxisTitle=" ' x_lb '", YAxisTitle=" ' y_lb '",  ZAxisTitle="' z_lb '", GridVisible=FALSE, Lighting = None, OutputFile="' p3 '")'];

%% MUPAD
clipboard('copy',[mupad_str1 ': ' mupad_str2]);
mpnb = mupad;

%% now a strange workaround
% evalin(symengine,mupad_str1);  % --> actually this doesn't work
% evalin(symengine,mupad_str2);  % --> actually this doesn't work
clc;
reply = input('please press "strg-v" in open mupad notebook after the [-bracket (the text need to be red in mupad nb)! Then press first enter in mupad and then any key in matlab prompt here! ', 's');
try
    movefile([cd '\' filename '.jvd'], destination);
    movefile([cd '\' filename '.jvx'], destination);
catch
    disp('Have you really pasted the clipboard to mupad and press enter? - Try again')
end;
close(mpnb);

%% Generate html-File
fid         =   fopen([destination '\' filename '.html' ], 'w');
html_str    =   {'<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>';
                    '';
                    '';
                    '<meta generator="JavaView v.3.95.001"/>';
                    '<meta date="Fri Sep 15 20:45:51 CEST 1978"/>';
                    ['<title>' filename '.jvx</title>'];
                    '';
                    '';
                    ['
 Applet shows ' filename  '.jvx (select a point with "h")
'];
                    '<applet height="512" archive="http://www.javaview.de/demo/jars/javaview.jar" width="640" code="http://www.javaview.de/demo/javaview.class">';
                    ['<param name=model value=" ' filename '.jvx">'];
                    ['<param name=displayFile value=" ' filename '.jvd">'];
                    '<param name=panel value="material">';
                    '</applet>';
                    '';
                    ''};
                for i=1:1:size(html_str,1)
                    fprintf(fid, char(html_str(i,1)));
                end;

fclose(fid);

%% Copy source for applet
copyfile(source, [destination '\jars'] );

%% open the html result in standard html-viewer (e.g. ie)
if open_html
    winopen([destination '\' filename '.html' ]);
end;