Posted
Comments None

I'm very excited about our next project because it includes very useful techniques for model selection and analysis. I'm also excited about adding the Go Grammar to the built-in programming languages of GeneXproTools. Below I outline the major features of this new project:

Cross-Validation

Being able to select the very best model from all the generated models is a crucial component of model design, with cross-validation at the heart of it. With this new project we will be implementing cross-validation in a way that is fully automatic and you just have to choose the fold and the metric. We will be implementing cross-validation for all Fitness Functions and Favorite Statistics in the Regression Framework, Classification & Logistic Regression.

Hits/Outliers Favorite Statistics

The Hits/Outliers statistics that are now only available when certain fitness functions are selected, will be extended to all fitness functions of the Regression Framework and Time Series Prediction. They'll have adjustable parameters both for the error type (absolute or relative) and error value. This way you'll be able to explore the new features introduced with Mini-Release 1 (especially multi-class classification in the Regression Framework) using all kinds of fitness functions and then easily evaluate the accuracy of your models.

Variable Importance

The Variable Importance Chart is an essential tool in model evaluation and analysis and GeneXproTools users tend to use it a lot. So we are bringing this chart more to the front both through a readily accessible icon and a menu.

Go Language

The Go Grammar, the amazing gift from Glenn Lewis to all GeneXproTools users a while back (see the forum discussion), will be added to the built-in programming languages of GeneXproTools with this mini-release. We will be building on Glenn's contribution (both the Math Grammar and all the Boolean Grammars) and also adding the new 39 math functions that were introduced with MR1. Again, many thanks to Glenn for his contribution!

R Language

When we introduced the R Grammar in GeneXproTools 5.0, we weren't sure about the usefulness of including also the Boolean Grammars and so we left them out. But users have been asking for them so we decided to add the R Boolean Grammars with this mini-release.

As with the previous project "New Project: Multi-class Classification & Trading Strategies", we will be blogging actively about this one too. So please join us and add your voice to the discussions!

Author

Posted
Comments None

As far as the new 39 math functions go, the Octave code is very similar to the MATLAB code, so it makes sense to use the MATLAB Grammar as our starting point.

Besides replacing "end" with "endif" and adding "endfunction" to mark the end of functions, we just have to remove the comma that is used after "if" and "elseif" expressions and also indent the code.

Here's the Octave code for the new 39 math functions that were added to the built-in math functions of GeneXproTools 5.0 with Mini-Release 1:

function result = gepRamp1(x)
    if (x > 0.0)
        result = x;
    else
        result = 0.0;
    endif
endfunction

function result = gepRamp2(x)
    if (x > 0.0)
        result = 0.0;
    else
        result = x;
    endif
endfunction

function result = gepRamp3(x)
    if (x > 0.0)
        result = 0.0;
    else
        result = -x;
    endif
endfunction

function result = gepRamp4(x)
    if (x > 0.0)
        result = -x;
    else
        result = 0.0;
    endif
endfunction

function result = gepStep1(x)
    if (x > 0.0)
        result = 1.0;
    else
        result = -1.0;
    endif
endfunction

function result = gepStep2(x)
    if (x > 0.0)
        result = 1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepStep3(x)
    if (x >= 1.0)
        result = 1.0;
    elseif (x <= -1.0)
        result = -1.0;
    else
        result = x;
    endif
endfunction

function result = gepStep4(x)
    if (x >= 1.0)
        result = 1.0;
    elseif (x <= 0.0)
        result = 0.0;
    else
        result = x;
    endif
endfunction

function result = gepCL2A(x, y)
    if (x > 0.0 && y > 0.0)
        result = 1.0;
    else
        result = -1.0;
    endif
endfunction

function result = gepCL2B(x, y)
    if (x >= 0.0 && y < 0.0)
        result = -1.0;
    else
        result = 1.0;
    endif
endfunction

function result = gepCL2C(x, y)
    if (x > 1.0 && y < -1.0)
        result = -1.0;
    else
        result = 1.0;
    endif
endfunction

function result = gepCL2D(x, y)
    if (x > 0.0 && y > 0.0)
        result = 1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepCL2E(x, y)
    if (x >= 0.0 && y <= 0.0)
        result = 0.0;
    else
        result = 1.0;
    endif
endfunction

function result = gepCL2F(x, y)
    if (x > 1.0 && y < -1.0)
        result = 0.0;
    else
        result = 1.0;
    endif
endfunction

function result = gepCL3A(x, y)
    if (x > 0.0 && y < 0.0)
        result = 1.0;
    elseif (x < 0.0 && y > 0.0)
        result = -1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepCL3B(x, y)
    if (x >= 1.0 && y >= 1.0)
        result = 1.0;
    elseif (x <= -1.0 && y <= -1.0)
        result = -1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepCL3C(x, y)
    if (x > 0.0 && y > 0.0)
        result = 1.0;
    elseif (x < 0.0 && y < 0.0)
        result = -1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepMap3A(x, y)
    SLACK = 10.0;
    if (y < (x - SLACK))
        result = -1.0;
    elseif (y > (x + SLACK))
        result = 1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepMap3B(x, y, z)
    minValue = min(x,y);
    maxValue = max(x,y);
    if (z < minValue)
        result = -1.0;
    elseif (z > maxValue)
        result = 1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepMap3C(a, b, c, d)
    minValue = min(min(a,b),c);
    maxValue = max(max(a,b),c);
    if (d < minValue)
        result = -1.0;
    elseif (d > maxValue)
        result = 1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepMap4A(x, y)
    SLACK = 10.0;
    if (y < (x - SLACK))
        result = 0.0;
    elseif (y >= (x - SLACK) && y < x)
        result = 1.0;
    elseif (y >= x && y < (x + SLACK))
        result = 2.0;
    elseif (y >= (x + SLACK))
        result = 3.0;
    endif
endfunction

function result = gepMap4B(x, y, z)
    % evaluate minValue(x,y), maxValue(x,y) and midrange
    minValue = min(x,y);
    maxValue = max(x,y);
    midrange = (maxValue + minValue)/2.0;

    if (z < minValue)
        result = 0.0;
    elseif (z >= minValue && z < midrange)
        result = 1.0;
    elseif (z >= midrange && z < maxValue)
        result = 2.0;
    elseif (z >= maxValue)
        result = 3.0;
    endif
endfunction

function result = gepMap4C(a, b, c, d)
    % evaluate minValue(a,b,c), maxValue(a,b,c) and midleValue(a,b,c)
    %
    % evaluate minValue(a,b,c) and argMin(a,b,c)
    minValue = a;
    argMin = 0;
    if (minValue > b)
        minValue = b;
        argMin = 1;
    endif
    if (minValue > c)
        minValue = c;
        argMin = 2;
    endif
    % evaluate maxValue(a,b,c) and argMax(a,b,c)
    maxValue = a;
    argMax = 0;
    if (maxValue < b)
        maxValue = b;
        argMax = 1;
    endif
    if (maxValue < c)
        maxValue = c;
        argMax = 2;
    endif
    % evaluate midleValue(a,b,c)
    midleValue = c;
    if (0 ~= argMin && 0 ~= argMax)
        midleValue = a;
    endif
    if (1 ~= argMin && 1 ~= argMax)
        midleValue = b;
    endif

    if (d < minValue)
        result = 0.0;
    elseif (d >= minValue && d < midleValue)
        result = 1.0;
    elseif (d >= midleValue && d < maxValue)
        result = 2.0;
    elseif (d >= maxValue)
        result = 3.0;
    endif
endfunction

function result = gepMap5A(x, y)
    SLACK = 15.0;
    if (y < (x - SLACK))
        result = 0.0;
    elseif (y >= (x - SLACK) && y < (x - SLACK/3.0))
        result = 1.0;
    elseif (y >= (x - SLACK/3.0) && y < (x + SLACK/3.0))
        result = 2.0;
    elseif (y >= (x + SLACK/3.0) && y < (x + SLACK))
        result = 3.0;
    elseif (y >= (x + SLACK))
        result = 4.0;
    endif
endfunction

function result = gepMap5B(x, y, z)
    % evaluate minValue(x,y), maxValue(x,y), midpoint1, midpoint2
    minValue = min(x,y);
    maxValue = max(x,y);
    intervalLength = (maxValue - minValue)/3.0;
    midpoint1 = minValue + intervalLength;
    midpoint2 = minValue + 2.0*intervalLength;

    if (z < minValue)
        result = 0.0;
    elseif (z >= minValue && z < midpoint1)
        result = 1.0;
    elseif (z >= midpoint1 && z < midpoint2)
        result = 2.0;
    elseif (z >= midpoint2 && z < maxValue)
        result = 3.0;
    elseif (z >= maxValue)
        result = 4.0;
    endif
endfunction

function result = gepMap5C(a, b, c, d)
    % evaluate minValue(a,b,c), maxValue(a,b,c), midleValue(a,b,c), midrange1, midrange2
    %
    % evaluate minValue(a,b,c) and argMin(a,b,c)
    minValue = a;
    argMin = 0;
    if (minValue > b)
        minValue = b;
        argMin = 1;
    endif
    if (minValue > c)
        minValue = c;
        argMin = 2;
    endif
    % evaluate maxValue(a,b,c) and argMax(a,b,c)
    maxValue = a;
    argMax = 0;
    if (maxValue < b)
        maxValue = b;
        argMax = 1;
    endif
    if (maxValue < c)
        maxValue = c;
        argMax = 2;
    endif
    % evaluate midleValue(a,b,c)
    midleValue = c;
    if (0 ~= argMin && 0 ~= argMax)
        midleValue = a;
    endif
    if (1 ~= argMin && 1 ~= argMax)
        midleValue = b;
    endif
    midrange1 = (minValue + midleValue)/2.0;
    midrange2 = (midleValue + maxValue)/2.0;

    if (d < minValue)
        result = 0.0;
    elseif (d >= minValue && d < midrange1)
        result = 1.0;
    elseif (d >= midrange1 && d < midrange2)
        result = 2.0;
    elseif (d >= midrange2 && d < maxValue)
        result = 3.0;
    elseif (d >= maxValue)
        result = 4.0;
    endif
endfunction

function result = gepMap6A(x, y)
    SLACK = 10.0;
    if (y < (x - SLACK))
        result = 0.0;
    elseif (y >= (x - SLACK) && y < (x - SLACK/2.0))
        result = 1.0;
    elseif (y >= (x - SLACK/2.0) && y < x)
        result = 2.0;
    elseif (y >= x && y < (x + SLACK/2.0))
        result = 3.0;
    elseif (y >= (x + SLACK/2.0) && y < (x + SLACK))
        result = 4.0;
    elseif (y >= (x + SLACK))
        result = 5.0;
    endif
endfunction

function result = gepMap6B(x, y, z)
    minValue = min(x,y);
    maxValue = max(x,y);
    midrange = (minValue + maxValue)/2.0;
    midpoint1 = (minValue + midrange)/2.0;
    midpoint2 = (midrange + maxValue)/2.0;

    if (z < minValue)
        result = 0.0;
    elseif (z >= minValue && z < midpoint1)
        result = 1.0;
    elseif (z >= midpoint1 && z < midrange)
        result = 2.0;
    elseif (z >= midrange && z < midpoint2)
        result = 3.0;
    elseif (z >= midpoint2 && z < maxValue)
        result = 4.0;
    elseif (z >= maxValue)
        result = 5.0;
    endif
endfunction

function result = gepMap6C(a, b, c, d)
    % evaluate minValue(a,b,c), maxValue(a,b,c), midleValue(a,b,c), midrange1, midrange2
    %
    % evaluate minValue(a,b,c) and argMin(a,b,c)
    minValue = a;
    argMin = 0;
    if (minValue > b)
        minValue = b;
        argMin = 1;
    endif
    if (minValue > c)
        minValue = c;
        argMin = 2;
    endif
    % evaluate maxValue(a,b,c) and argMax(a,b,c)
    maxValue = a;
    argMax = 0;
    if (maxValue < b)
        maxValue = b;
        argMax = 1;
    endif
    if (maxValue < c)
        maxValue = c;
        argMax = 2;
    endif
    % evaluate midleValue(a,b,c)
    midleValue = c;
    if (0 ~= argMin && 0 ~= argMax)
        midleValue = a;
    endif
    if (1 ~= argMin && 1 ~= argMax)
        midleValue = b;
    endif
    % evaluate midrange1 and midrange2
    midrange1 = (minValue + midleValue)/2.0;
    midrange2 = (midleValue + maxValue)/2.0;

    if (d < minValue)
        result = 0.0;
    elseif (d >= minValue && d < midrange1)
        result = 1.0;
    elseif (d >= midrange1 && d < midleValue)
        result = 2.0;
    elseif (d >= midleValue && d < midrange2)
        result = 3.0;
    elseif (d >= midrange2 && d < maxValue)
        result = 4.0;
    elseif (d >= maxValue)
        result = 5.0;
    endif
endfunction

function result = gepECL3A(x, y, z)
    if (y > x && z < x)
        result = 1.0;
    elseif (y < x && z > x)
        result = -1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepECL3B(x, y, z)
    if (y > x && z > x)
        result = 1.0;
    elseif (y < x && z < x)
        result = -1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepECL3C(x, y, z)
    if (y >= x && z >= x)
        result = 1.0;
    elseif (y <= -x && z <= -x)
        result = -1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepECL3D(a, b, c, d)
    minValue = min(a,b);
    maxValue = max(a,b);
    if (c >= maxValue && d >= maxValue)
        result = 1.0;
    elseif (c <= minValue && d <= minValue)
        result = -1.0;
    else
        result = 0.0;
    endif
endfunction

function result = gepAMin2(x, y)
    if (x < y)
        result = 0.0;
    else
        result = 1.0;
    endif
endfunction

function result = gepAMin3(x, y, z)
    temp = x;
    argMin = 0.0;
    if (temp >= y)
        temp = y;
        argMin = 1.0;
    endif
    if (temp >= z)
        argMin = 2.0;
    endif
    result = argMin;
endfunction

function result = gepAMin4(a, b, c, d)
    temp = a;
    argMin = 0.0;
    if (temp >= b)
        temp = b;
        argMin = 1.0;
    endif
    if (temp >= c)
        temp = c;
        argMin = 2.0;
    endif
    if (temp >= d)
        argMin = 3.0;
    endif
    result = argMin;
endfunction

function result = gepAMax2(x, y)
    if (x >= y)
        result = 0.0;
    else
        result = 1.0;
    endif
endfunction

function result = gepAMax3(x, y, z)
    temp = x;
    argMax = 0.0;
    if (temp < y)
        temp = y;
        argMax = 1.0;
    endif
    if (temp < z)
        argMax = 2.0;
    endif
    result = argMax;
endfunction

function result = gepAMax4(a, b, c, d)
    temp = a;
    argMax = 0.0;
    if (temp < b)
        temp = b;
        argMax = 1.0;
    endif
    if (temp < c)
        temp = c;
        argMax = 2.0;
    endif
    if (temp < d)
        argMax = 3.0;
    endif
    result = argMax;
endfunction

Author

Posted
Comments None

Creating the MATLAB code for the new 39 math functions of GeneXproTools is very easy if we start from the VB.Net code.

First of all we need to replace "Then" by a comma and then convert "Else", "ElseIf" and "End If" to MATLAB style, that is, "else", "elseif" and "end".

Second, we need to put parentheses around all "if" and "elseif" expressions, which is perhaps the trickiest part. Then we need to replace "Return" by "result =", "And" by "&&", "<>" by "~=", "Min" and "Max" by "min" and "max", and also the comment marks by "%".

Third, we need to remove all type declaration keywords ("Dim", "As Double", "As Integer", and "Const") and put a semicolon at the end of lines.

And finally we also need to take care of the function headers and footers as they differ in both programming languages.

And here it is, the MATLAB code for the new 39 math functions that were added to the built-in math functions of GeneXproTools 5.0 with Mini-Release 1:

function result = gepRamp1(x)
if (x > 0.0),
    result = x;
else
    result = 0.0;
end

function result = gepRamp2(x)
if (x > 0.0),
    result = 0.0;
else
    result = x;
end

function result = gepRamp3(x)
if (x > 0.0),
    result = 0.0;
else
    result = -x;
end

function result = gepRamp4(x)
if (x > 0.0),
    result = -x;
else
    result = 0.0;
end

function result = gepStep1(x)
if (x > 0.0),
    result = 1.0;
else
    result = -1.0;
end

function result = gepStep2(x)
if (x > 0.0),
    result = 1.0;
else
    result = 0.0;
end

function result = gepStep3(x)
if (x >= 1.0),
    result = 1.0;
elseif (x <= -1.0),
    result = -1.0;
else
    result = x;
end

function result = gepStep4(x)
if (x >= 1.0),
    result = 1.0;
elseif (x <= 0.0),
    result = 0.0;
else
    result = x;
end

function result = gepCL2A(x, y)
if (x > 0.0 && y > 0.0),
    result = 1.0;
else
    result = -1.0;
end

function result = gepCL2B(x, y)
if (x >= 0.0 && y < 0.0),
    result = -1.0;
else
    result = 1.0;
end

function result = gepCL2C(x, y)
if (x > 1.0 && y < -1.0),
    result = -1.0;
else
    result = 1.0;
end

function result = gepCL2D(x, y)
if (x > 0.0 && y > 0.0),
    result = 1.0;
else
    result = 0.0;
end

function result = gepCL2E(x, y)
if (x >= 0.0 && y <= 0.0),
    result = 0.0;
else
    result = 1.0;
end

function result = gepCL2F(x, y)
if (x > 1.0 && y < -1.0),
    result = 0.0;
else
    result = 1.0;
end

function result = gepCL3A(x, y)
if (x > 0.0 && y < 0.0),
    result = 1.0;
elseif (x < 0.0 && y > 0.0),
    result = -1.0;
else
    result = 0.0;
end

function result = gepCL3B(x, y)
if (x >= 1.0 && y >= 1.0),
    result = 1.0;
elseif (x <= -1.0 && y <= -1.0),
    result = -1.0;
else
    result = 0.0;
end

function result = gepCL3C(x, y)
if (x > 0.0 && y > 0.0),
    result = 1.0;
elseif (x < 0.0 && y < 0.0),
    result = -1.0;
else
    result = 0.0;
end

function result = gepMap3A(x, y)
SLACK = 10.0;
if (y < (x - SLACK)),
    result = -1.0;
elseif (y > (x + SLACK)),
    result = 1.0;
else
    result = 0.0;
end

function result = gepMap3B(x, y, z)
minValue = min(x,y);
maxValue = max(x,y);
if (z < minValue),
    result = -1.0;
elseif (z > maxValue),
    result = 1.0;
else
    result = 0.0;
end

function result = gepMap3C(a, b, c, d)
minValue = min(min(a,b),c);
maxValue = max(max(a,b),c);
if (d < minValue),
    result = -1.0;
elseif (d > maxValue),
    result = 1.0;
else
    result = 0.0;
end

function result = gepMap4A(x, y)
SLACK = 10.0;
if (y < (x - SLACK)),
    result = 0.0;
elseif (y >= (x - SLACK) && y < x),
    result = 1.0;
elseif (y >= x && y < (x + SLACK)),
    result = 2.0;
elseif (y >= (x + SLACK)),
    result = 3.0;
end

function result = gepMap4B(x, y, z)
% evaluate minValue(x,y), maxValue(x,y) and midrange
minValue = min(x,y);
maxValue = max(x,y);
midrange = (maxValue + minValue)/2.0;

if (z < minValue),
    result = 0.0;
elseif (z >= minValue && z < midrange),
    result = 1.0;
elseif (z >= midrange && z < maxValue),
    result = 2.0;
elseif (z >= maxValue),
    result = 3.0;
end

function result = gepMap4C(a, b, c, d)
% evaluate minValue(a,b,c), maxValue(a,b,c) and midleValue(a,b,c)
%
% evaluate minValue(a,b,c) and argMin(a,b,c)
minValue = a;
argMin = 0;
if (minValue > b),
    minValue = b;
    argMin = 1;
end
if (minValue > c),
    minValue = c;
    argMin = 2;
end
% evaluate maxValue(a,b,c) and argMax(a,b,c)
maxValue = a;
argMax = 0;
if (maxValue < b),
    maxValue = b;
    argMax = 1;
end
if (maxValue < c),
    maxValue = c;
    argMax = 2;
end
% evaluate midleValue(a,b,c)
midleValue = c;
if (0 ~= argMin && 0 ~= argMax),
    midleValue = a;
end
if (1 ~= argMin && 1 ~= argMax),
    midleValue = b;
end

if (d < minValue),
    result = 0.0;
elseif (d >= minValue && d < midleValue),
    result = 1.0;
elseif (d >= midleValue && d < maxValue),
    result = 2.0;
elseif (d >= maxValue),
    result = 3.0;
end

function result = gepMap5A(x, y)
SLACK = 15.0;
if (y < (x - SLACK)),
    result = 0.0;
elseif (y >= (x - SLACK) && y < (x - SLACK/3.0)),
    result = 1.0;
elseif (y >= (x - SLACK/3.0) && y < (x + SLACK/3.0)),
    result = 2.0;
elseif (y >= (x + SLACK/3.0) && y < (x + SLACK)),
    result = 3.0;
elseif (y >= (x + SLACK)),
    result = 4.0;
end

function result = gepMap5B(x, y, z)
% evaluate minValue(x,y), maxValue(x,y), midpoint1, midpoint2
minValue = min(x,y);
maxValue = max(x,y);
intervalLength = (maxValue - minValue)/3.0;
midpoint1 = minValue + intervalLength;
midpoint2 = minValue + 2.0*intervalLength;

if (z < minValue),
    result = 0.0;
elseif (z >= minValue && z < midpoint1),
    result = 1.0;
elseif (z >= midpoint1 && z < midpoint2),
    result = 2.0;
elseif (z >= midpoint2 && z < maxValue),
    result = 3.0;
elseif (z >= maxValue),
    result = 4.0;
end

function result = gepMap5C(a, b, c, d)
% evaluate minValue(a,b,c), maxValue(a,b,c), midleValue(a,b,c), midrange1, midrange2
%
% evaluate minValue(a,b,c) and argMin(a,b,c)
minValue = a;
argMin = 0;
if (minValue > b),
    minValue = b;
    argMin = 1;
end
if (minValue > c),
    minValue = c;
    argMin = 2;
end
% evaluate maxValue(a,b,c) and argMax(a,b,c)
maxValue = a;
argMax = 0;
if (maxValue < b),
    maxValue = b;
    argMax = 1;
end
if (maxValue < c),
    maxValue = c;
    argMax = 2;
end
% evaluate midleValue(a,b,c)
midleValue = c;
if (0 ~= argMin && 0 ~= argMax),
    midleValue = a;
end
if (1 ~= argMin && 1 ~= argMax),
    midleValue = b;
end
midrange1 = (minValue + midleValue)/2.0;
midrange2 = (midleValue + maxValue)/2.0;

if (d < minValue),
    result = 0.0;
elseif (d >= minValue && d < midrange1),
    result = 1.0;
elseif (d >= midrange1 && d < midrange2),
    result = 2.0;
elseif (d >= midrange2 && d < maxValue),
    result = 3.0;
elseif (d >= maxValue),
    result = 4.0;
end

function result = gepMap6A(x, y)
SLACK = 10.0;
if (y < (x - SLACK)),
    result = 0.0;
elseif (y >= (x - SLACK) && y < (x - SLACK/2.0)),
    result = 1.0;
elseif (y >= (x - SLACK/2.0) && y < x),
    result = 2.0;
elseif (y >= x && y < (x + SLACK/2.0)),
    result = 3.0;
elseif (y >= (x + SLACK/2.0) && y < (x + SLACK)),
    result = 4.0;
elseif (y >= (x + SLACK)),
    result = 5.0;
end

function result = gepMap6B(x, y, z)
minValue = min(x,y);
maxValue = max(x,y);
midrange = (minValue + maxValue)/2.0;
midpoint1 = (minValue + midrange)/2.0;
midpoint2 = (midrange + maxValue)/2.0;

if (z < minValue),
    result = 0.0;
elseif (z >= minValue && z < midpoint1),
    result = 1.0;
elseif (z >= midpoint1 && z < midrange),
    result = 2.0;
elseif (z >= midrange && z < midpoint2),
    result = 3.0;
elseif (z >= midpoint2 && z < maxValue),
    result = 4.0;
elseif (z >= maxValue),
    result = 5.0;
end

function result = gepMap6C(a, b, c, d)
% evaluate minValue(a,b,c), maxValue(a,b,c), midleValue(a,b,c), midrange1, midrange2
%
% evaluate minValue(a,b,c) and argMin(a,b,c)
minValue = a;
argMin = 0;
if (minValue > b),
    minValue = b;
    argMin = 1;
end
if (minValue > c),
    minValue = c;
    argMin = 2;
end
% evaluate maxValue(a,b,c) and argMax(a,b,c)
maxValue = a;
argMax = 0;
if (maxValue < b),
    maxValue = b;
    argMax = 1;
end
if (maxValue < c),
    maxValue = c;
    argMax = 2;
end
% evaluate midleValue(a,b,c)
midleValue = c;
if (0 ~= argMin && 0 ~= argMax),
    midleValue = a;
end
if (1 ~= argMin && 1 ~= argMax),
    midleValue = b;
end
% evaluate midrange1 and midrange2
midrange1 = (minValue + midleValue)/2.0;
midrange2 = (midleValue + maxValue)/2.0;

if (d < minValue),
    result = 0.0;
elseif (d >= minValue && d < midrange1),
    result = 1.0;
elseif (d >= midrange1 && d < midleValue),
    result = 2.0;
elseif (d >= midleValue && d < midrange2),
    result = 3.0;
elseif (d >= midrange2 && d < maxValue),
    result = 4.0;
elseif (d >= maxValue),
    result = 5.0;
end

function result = gepECL3A(x, y, z)
if (y > x && z < x),
    result = 1.0;
elseif (y < x && z > x),
    result = -1.0;
else
    result = 0.0;
end

function result = gepECL3B(x, y, z)
if (y > x && z > x),
    result = 1.0;
elseif (y < x && z < x),
    result = -1.0;
else
    result = 0.0;
end

function result = gepECL3C(x, y, z)
if (y >= x && z >= x),
    result = 1.0;
elseif (y <= -x && z <= -x),
    result = -1.0;
else
    result = 0.0;
end

function result = gepECL3D(a, b, c, d)
minValue = min(a,b);
maxValue = max(a,b);
if (c >= maxValue && d >= maxValue),
    result = 1.0;
elseif (c <= minValue && d <= minValue),
    result = -1.0;
else
    result = 0.0;
end

function result = gepAMin2(x, y)
if (x < y),
    result = 0.0;
else
    result = 1.0;
end

function result = gepAMin3(x, y, z)
temp = x;
argMin = 0.0;
if (temp >= y),
    temp = y;
    argMin = 1.0;
end
if (temp >= z),
    argMin = 2.0;
end
result = argMin;

function result = gepAMin4(a, b, c, d)
temp = a;
argMin = 0.0;
if (temp >= b),
    temp = b;
    argMin = 1.0;
end
if (temp >= c),
    temp = c;
    argMin = 2.0;
end
if (temp >= d),
    argMin = 3.0;
end
result = argMin;

function result = gepAMax2(x, y)
if (x >= y),
    result = 0.0;
else
    result = 1.0;
end

function result = gepAMax3(x, y, z)
temp = x;
argMax = 0.0;
if (temp < y),
    temp = y;
    argMax = 1.0;
end
if (temp < z),
    argMax = 2.0;
end
result = argMax;

function result = gepAMax4(a, b, c, d)
temp = a;
argMax = 0.0;
if (temp < b),
    temp = b;
    argMax = 1.0;
end
if (temp < c),
    temp = c;
    argMax = 2.0;
end
if (temp < d),
    argMax = 3.0;
end
result = argMax;

Author

Posted
Comments None

For the Perl code of the new 39 math functions of GeneXproTools, using the PHP code as the starting point seemed like the right choice since both programming languages prefix their variables and constants with "$". However, I decided to use the C++ code instead as I could easily replace "double", "int", and "const double" by "my". Moreover, since both C++ and Perl lack built-in min and max functions, I didn't have to make great changes to the C++ code, which again is important for debugging and testing. Then I just had to replace "else if" with "elsif" and the comment marks by "#".

The declaration of functions is also very different in both languages, but it's no trouble replacing the headers of all the four different types of functions (functions of 1, 2, 3, and 4 arguments) by the appropriate one.

The trickier part is placing all the curly braces correctly around all "if" and "else" expressions, which is a requirement of the Perl language.

Here's the Perl code for the new 39 math functions that were added to the built-in math functions of GeneXproTools 5.0 with Mini-Release 1:

sub gepRamp1
{
    (my $x) = $_[0];
    if ($x > 0.0)
    {
        return $x;
    }
    else
    {
        return 0.0;
    }
}

sub gepRamp2
{
    (my $x) = $_[0];
    if ($x > 0.0)
    {
        return 0.0;
    }
    else
    {
        return $x;
    }
}

sub gepRamp3
{
    (my $x) = $_[0];
    if ($x > 0.0)
    {
        return 0.0;
    }
    else
    {
        return -$x;
    }
}

sub gepRamp4
{
    (my $x) = $_[0];
    if ($x > 0.0)
    {
        return -$x;
    }
    else
    {
        return 0.0;
    }
}

sub gepStep1
{
    (my $x) = $_[0];
    if ($x > 0.0)
    {
        return 1.0;
    }
    else
    {
        return -1.0;
    }
}

sub gepStep2
{
    (my $x) = $_[0];
    if ($x > 0.0)
    {
        return 1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepStep3
{
    (my $x) = $_[0];
    if ($x >= 1.0)
    {
        return 1.0;
    }
    elsif ($x <= -1.0)
    {
        return -1.0;
    }
    else
    {
        return $x;
    }
}

sub gepStep4
{
    (my $x) = $_[0];
    if ($x >= 1.0)
    {
        return 1.0;
    }
    elsif ($x <= 0.0)
    {
        return 0.0;
    }
    else
    {
        return $x;
    }
}

sub gepCL2A
{
    (my $x, my $y) = @_ ;
    if ($x > 0.0 && $y > 0.0)
    {
        return 1.0;
    }
    else
    {
        return -1.0;
    }
}

sub gepCL2B
{
    (my $x, my $y) = @_ ;
    if ($x >= 0.0 && $y < 0.0)
    {
        return -1.0;
    }
    else
    {
        return 1.0;
    }
}

sub gepCL2C
{
    (my $x, my $y) = @_ ;
    if ($x > 1.0 && $y < -1.0)
    {
        return -1.0;
    }
    else
    {
        return 1.0;
    }
}

sub gepCL2D
{
    (my $x, my $y) = @_ ;
    if ($x > 0.0 && $y > 0.0)
    {
        return 1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepCL2E
{
    (my $x, my $y) = @_ ;
    if ($x >= 0.0 && $y <= 0.0)
    {
        return 0.0;
    }
    else
    {
        return 1.0;
    }
}

sub gepCL2F
{
    (my $x, my $y) = @_ ;
    if ($x > 1.0 && $y < -1.0)
    {
        return 0.0;
    }
    else
    {
        return 1.0;
    }
}

sub gepCL3A
{
    (my $x, my $y) = @_ ;
    if ($x > 0.0 && $y < 0.0)
    {
        return 1.0;
    }
    elsif ($x < 0.0 && $y > 0.0)
    {
        return -1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepCL3B
{
    (my $x, my $y) = @_ ;
    if ($x >= 1.0 && $y >= 1.0)
    {
        return 1.0;
    }
    elsif ($x <= -1.0 && $y <= -1.0)
    {
        return -1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepCL3C
{
    (my $x, my $y) = @_ ;
    if ($x > 0.0 && $y > 0.0)
    {
        return 1.0;
    }
    elsif ($x < 0.0 && $y < 0.0)
    {
        return -1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepMap3A
{
    (my $x, my $y) = @_ ;
    my $SLACK = 10.0;
    my $outVal = 0.0;
    if ($y < ($x - $SLACK))
    {
        $outVal = -1.0;
    }
    elsif ($y > ($x + $SLACK))
    {
        $outVal = 1.0;
    }
    return $outVal;
}

sub gepMap3B
{
    (my $x, my $y, my $z) = @_ ;
    # evaluate minValue(x,y) and maxValue(x,y)
    my $minValue = $x;
    my $maxValue = $y;
    if ($minValue > $y)
    {
        $minValue = $y;
        $maxValue = $x;
    }
    
    my $outVal = 0.0;
    if ($z < $minValue)
    {
        $outVal = -1.0;
    }
    elsif ($z > $maxValue)
    {
        $outVal = 1.0;
    }
    return $outVal;
}

sub gepMap3C
{
    (my $a, my $b, my $c, my $d) = @_ ;
    # evaluate minValue(a,b,c) and maxValue(a,b,c)
    #
    # evaluate minValue(a,b,c)
    my $minValue = $a;
    if ($minValue > $b)
    {
        $minValue = $b;
    }
    if ($minValue > $c)
    {
        $minValue = $c;
    }
    # evaluate maxValue(a,b,c)
    my $maxValue = $a;
    if ($maxValue < $b)
    {
        $maxValue = $b;
    }
    if ($maxValue < $c)
    {
        $maxValue = $c;
    }

    my $outVal = 0.0;
    if ($d < $minValue)
    {
        $outVal = -1.0;
    }
    elsif ($d > $maxValue)
    {
        $outVal = 1.0;
    }
    return $outVal;
}

sub gepMap4A
{
    (my $x, my $y) = @_ ;
    my $SLACK = 10.0;
    my $outVal = 0.0;
    if ($y < ($x - $SLACK))
    {
        $outVal = 0.0;
    }
    elsif ($y >= ($x - $SLACK) && $y < $x)
    {
        $outVal = 1.0;
    }
    elsif ($y >= $x && $y < ($x + $SLACK))
    {
        $outVal = 2.0;
    }
    elsif ($y >= ($x + $SLACK))
    {
        $outVal = 3.0;
    }
    return $outVal;
}

sub gepMap4B
{
    (my $x, my $y, my $z) = @_ ;
    # evaluate minValue(x,y), maxValue(x,y) and midrange
    my $minValue = $x;
    my $maxValue = $y;
    if ($minValue > $y)
    {
        $minValue = $y;
        $maxValue = $x;
    }
    my $midrange = ($maxValue + $minValue)/2.0;
    
    my $outVal = 0.0;
    if ($z < $minValue)
    {
        $outVal = 0.0;
    }
    elsif ($z >= $minValue && $z < $midrange)
    {
        $outVal = 1.0;
    }
    elsif ($z >= $midrange && $z < $maxValue)
    {
        $outVal = 2.0;
    }
    elsif ($z >= $maxValue)
    {
        $outVal = 3.0;
    }
    return $outVal;
}

sub gepMap4C
{
    (my $a, my $b, my $c, my $d) = @_ ;
    # evaluate minValue(a,b,c), maxValue(a,b,c) and midleValue(a,b,c)
    #
    # evaluate minValue(a,b,c)
    my $minValue = $a;
    my $argMin = 0;
    if ($minValue > $b)
    {
        $minValue = $b;
        $argMin = 1;
    }
    if ($minValue > $c)
    {
        $minValue = $c;
        $argMin = 2;
    }
    # evaluate maxValue(a,b,c)
    my $maxValue = $a;
    my $argMax = 0;
    if ($maxValue < $b)
    {
        $maxValue = $b;
        $argMax = 1;
    }
    if ($maxValue < $c)
    {
        $maxValue = $c;
        $argMax = 2;
    }
    # evaluate midleValue(a,b,c)
    my $midleValue = $c;
    if (0 != $argMin && 0 != $argMax)
    {
        $midleValue = $a;
    }
    if (1 != $argMin && 1 != $argMax)
    {
        $midleValue = $b;
    }

    my $outVal = 0.0;
    if ($d < $minValue)
    {
        $outVal = 0.0;
    }
    elsif ($d >= $minValue && $d < $midleValue)
    {
        $outVal = 1.0;
    }
    elsif ($d >= $midleValue && $d < $maxValue)
    {
        $outVal = 2.0;
    }
    elsif ($d >= $maxValue)
    {
        $outVal = 3.0;
    }
    return $outVal;
}

sub gepMap5A
{
    (my $x, my $y) = @_ ;
    my $SLACK = 15.0;
    my $outVal = 0.0;
    if ($y < ($x - $SLACK))
    {
        $outVal = 0.0;
    }
    elsif ($y >= ($x - $SLACK) && $y < ($x - $SLACK/3.0))
    {
        $outVal = 1.0;
    }
    elsif ($y >= ($x - $SLACK/3.0) && $y < ($x + $SLACK/3.0))
    {
        $outVal = 2.0;
    }
    elsif ($y >= ($x + $SLACK/3.0) && $y < ($x + $SLACK))
    {
        $outVal = 3.0;
    }
    elsif ($y >= ($x + $SLACK))
    {
        $outVal = 4.0;
    }
    return $outVal;
}

sub gepMap5B
{
    (my $x, my $y, my $z) = @_ ;
    # evaluate minValue(x,y), maxValue(x,y), midpoint1, midpoint2
    my $minValue = $x;
    my $maxValue = $y;
    if ($minValue > $y)
    {
        $minValue = $y;
        $maxValue = $x;
    }
    my $intervalLength = ($maxValue - $minValue)/3.0;
    my $midpoint1 = $minValue + $intervalLength;
    my $midpoint2 = $minValue + 2.0*$intervalLength;
    
    my $outVal = 0.0;
    if ($z < $minValue)
    {
        $outVal = 0.0;
    }
    elsif ($z >= $minValue && $z < $midpoint1)
    {
        $outVal = 1.0;
    }
    elsif ($z >= $midpoint1 && $z < $midpoint2)
    {
        $outVal = 2.0;
    }
    elsif ($z >= $midpoint2 && $z < $maxValue)
    {
        $outVal = 3.0;
    }
    elsif ($z >= $maxValue)
    {
        $outVal = 4.0;
    }
    return $outVal;
}

sub gepMap5C
{
    (my $a, my $b, my $c, my $d) = @_ ;
    # evaluate minValue(a,b,c), maxValue(a,b,c), midleValue(a,b,c), midrange1, midrange2
    #
    # evaluate minValue(a,b,c)
    my $minValue = $a;
    my $argMin = 0;
    if ($minValue > $b)
    {
        $minValue = $b;
        $argMin = 1;
    }
    if ($minValue > $c)
    {
        $minValue = $c;
        $argMin = 2;
    }
    # evaluate maxValue(a,b,c)
    my $maxValue = $a;
    my $argMax = 0;
    if ($maxValue < $b)
    {
        $maxValue = $b;
        $argMax = 1;
    }
    if ($maxValue < $c)
    {
        $maxValue = $c;
        $argMax = 2;
    }
    # evaluate midleValue(a,b,c)
    my $midleValue = $c;
    if (0 != $argMin && 0 != $argMax)
    {
        $midleValue = $a;
    }
    if (1 != $argMin && 1 != $argMax)
    {
        $midleValue = $b;
    }
    # evaluate midrange1 and midrange2
    my $midrange1 = ($minValue + $midleValue)/2.0;
    my $midrange2 = ($midleValue + $maxValue)/2.0;

    my $outVal = 0.0;
    if ($d < $minValue)
    {
        $outVal = 0.0;
    }
    elsif ($d >= $minValue && $d < $midrange1)
    {
        $outVal = 1.0;
    }
    elsif ($d >= $midrange1 && $d < $midrange2)
    {
        $outVal = 2.0;
    }
    elsif ($d >= $midrange2 && $d < $maxValue)
    {
        $outVal = 3.0;
    }
    elsif ($d >= $maxValue)
    {
        $outVal = 4.0;
    }
    return $outVal;
}

sub gepMap6A
{
    (my $x, my $y) = @_ ;
    my $SLACK = 10.0;
    my $outVal = 0.0;
    if ($y < ($x - $SLACK))
    {
        $outVal = 0.0;
    }
    elsif ($y >= ($x - $SLACK) && $y < ($x - $SLACK/2.0))
    {
        $outVal = 1.0;
    }
    elsif ($y >= ($x - $SLACK/2.0) && $y < $x)
    {
        $outVal = 2.0;
    }
    elsif ($y >= $x && $y < ($x + $SLACK/2.0))
    {
        $outVal = 3.0;
    }
    elsif ($y >= ($x + $SLACK/2.0) && $y < ($x + $SLACK))
    {
        $outVal = 4.0;
    }
    elsif ($y >= ($x + $SLACK))
    {
        $outVal = 5.0;
    }
    return $outVal;
}

sub gepMap6B
{
    (my $x, my $y, my $z) = @_ ;
    # evaluate minValue(x,y), maxValue(x,y), midrange, midpoint1, midpoint2
    my $minValue = $x;
    my $maxValue = $y;
    if ($minValue > $y)
    {
        $minValue = $y;
        $maxValue = $x;
    }
    my $midrange = ($minValue + $maxValue)/2.0;
    my $midpoint1 = ($minValue + $midrange)/2.0;
    my $midpoint2 = ($midrange + $maxValue)/2.0;
    
    my $outVal = 0.0;
    if ($z < $minValue)
    {
        $outVal = 0.0;
    }
    elsif ($z >= $minValue && $z < $midpoint1)
    {
        $outVal = 1.0;
    }
    elsif ($z >= $midpoint1 && $z < $midrange)
    {
        $outVal = 2.0;
    }
    elsif ($z >= $midrange && $z < $midpoint2)
    {
        $outVal = 3.0;
    }
    elsif ($z >= $midpoint2 && $z < $maxValue)
    {
        $outVal = 4.0;
    }
    elsif ($z >= $maxValue)
    {
        $outVal = 5.0;
    }
    return $outVal;
}

sub gepMap6C
{
    (my $a, my $b, my $c, my $d) = @_ ;
    # evaluate minValue(a,b,c), maxValue(a,b,c), midleValue(a,b,c), midrange1, midrange2
    #
    # evaluate minValue(a,b,c)
    my $minValue = $a;
    my $argMin = 0;
    if ($minValue > $b)
    {
        $minValue = $b;
        $argMin = 1;
    }
    if ($minValue > $c)
    {
        $minValue = $c;
        $argMin = 2;
    }
    # evaluate maxValue(a,b,c)
    my $maxValue = $a;
    my $argMax = 0;
    if ($maxValue < $b)
    {
        $maxValue = $b;
        $argMax = 1;
    }
    if ($maxValue < $c)
    {
        $maxValue = $c;
        $argMax = 2;
    }
    # evaluate midleValue(a,b,c)
    my $midleValue = $c;
    if (0 != $argMin && 0 != $argMax)
    {
        $midleValue = $a;
    }
    if (1 != $argMin && 1 != $argMax)
    {
        $midleValue = $b;
    }
    # evaluate midrange1 and midrange2
    my $midrange1 = ($minValue + $midleValue)/2.0;
    my $midrange2 = ($midleValue + $maxValue)/2.0;

    my $outVal = 0.0;
    if ($d < $minValue)
    {
        $outVal = 0.0;
    }
    elsif ($d >= $minValue && $d < $midrange1)
    {
        $outVal = 1.0;
    }
    elsif ($d >= $midrange1 && $d < $midleValue)
    {
        $outVal = 2.0;
    }
    elsif ($d >= $midleValue && $d < $midrange2)
    {
        $outVal = 3.0;
    }
    elsif ($d >= $midrange2 && $d < $maxValue)
    {
        $outVal = 4.0;
    }
    elsif ($d >= $maxValue)
    {
        $outVal = 5.0;
    }
    return $outVal;
}

sub gepECL3A
{
    (my $x, my $y, my $z) = @_ ;
    if ($y > $x && $z < $x)
    {
        return 1.0;
    }
    elsif ($y < $x && $z > $x)
    {
        return -1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepECL3B
{
    (my $x, my $y, my $z) = @_ ;
    if ($y > $x && $z > $x)
    {
        return 1.0;
    }
    elsif ($y < $x && $z < $x)
    {
        return -1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepECL3C
{
    (my $x, my $y, my $z) = @_ ;
    if ($y >= $x && $z >= $x)
    {
        return 1.0;
    }
    elsif ($y <= -$x && $z <= -$x)
    {
        return -1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepECL3D
{
    (my $a, my $b, my $c, my $d) = @_ ;
    # evaluate minValue(a,b) and maxValue(a,b)
    my $minValue = $a;
    my $maxValue = $b;
    if ($minValue > $b)
    {
        $minValue = $b;
        $maxValue = $a;
    }

    if ($c >= $maxValue && $d >= $maxValue)
    {
        return 1.0;
    }
    elsif ($c <= $minValue && $d <= $minValue)
    {
        return -1.0;
    }
    else
    {
        return 0.0;
    }
}

sub gepAMin2
{
    (my $x, my $y) = @_ ;
    if ($x < $y)
    {
        return 0.0;
    }
    else
    {
        return 1.0;
    }
}

sub gepAMin3
{
    (my $x, my $y, my $z) = @_ ;
    my $temp = $x;
    my $argMin = 0.0;    
    if ($temp >= $y)
    {
        $temp = $y;
        $argMin = 1.0;
    }
    if ($temp >= $z)
    {
        $argMin = 2.0;
    }
    return $argMin;
}

sub gepAMin4
{
    (my $a, my $b, my $c, my $d) = @_ ;
    my $temp = $a;
    my $argMin = 0.0;    
    if ($temp >= $b)
    {
        $temp = $b;
        $argMin = 1.0;
    }
    if ($temp >= $c)
    {
        $temp = $c;
        $argMin = 2.0;
    }
    if ($temp >= $d)
    {
        $argMin = 3.0;
    }
    return $argMin;
}

sub gepAMax2
{
    (my $x, my $y) = @_ ;
    if ($x >= $y)
    {
        return 0.0;
    }
    else
    {
        return 1.0;
    }
}

sub gepAMax3
{
    (my $x, my $y, my $z) = @_ ;
    my $temp = $x;
    my $argMax = 0.0;    
    if ($temp < $y)
    {
        $temp = $y;
        $argMax = 1.0;
    }
    if ($temp < $z)
    {
        $argMax = 2.0;
    }
    return $argMax;
}

sub gepAMax4
{
    (my $a, my $b, my $c, my $d) = @_ ;
    my $temp = $a;
    my $argMax = 0.0;    
    if ($temp < $b)
    {
        $temp = $b;
        $argMax = 1.0;
    }
    if ($temp < $c)
    {
        $temp = $c;
        $argMax = 2.0;
    }
    if ($temp < $d)
    {
        $argMax = 3.0;
    }
    return $argMax;
}

Author

Posted
Comments None

The PHP code for the new 39 math functions of GeneXproTools is easily created form the C# code. We just have to get rid of all the type keywords (double, int, const) in the declaration of variables and constants and prefix all variables and constants with "$".

Then we just need to replace "else if" by "elseif" and "Math.Min" and "Math.Max" by "min" and "max" in the places where min and max values of just 2 numbers are evaluated; where min and max take 3 arguments, we simplified the code a bit by making good use of the more versatile implementation of the native min/max functions of PHP.

Also different in both programming languages are the function declarations, but again by using grammar templates we can easily replace the C# headers with the corresponding PHP headers.

Here's the PHP code for the new 39 math functions that were added to the built-in math functions of GeneXproTools 5.0 with Mini-Release 1:

function gepRamp1($x)
{
    if ($x > 0.0)
        return $x;
    else
        return 0.0;
}

function gepRamp2($x)
{
    if ($x > 0.0)
        return 0.0;
    else
        return $x;
}

function gepRamp3($x)
{
    if ($x > 0.0)
        return 0.0;
    else
        return -$x;
}

function gepRamp4($x)
{
    if ($x > 0.0)
        return -$x;
    else
        return 0.0;
}

function gepStep1($x)
{
    if ($x > 0.0)
        return 1.0;
    else
        return -1.0;
}

function gepStep2($x)
{
    if ($x > 0.0)
        return 1.0;
    else
        return 0.0;
}

function gepStep3($x)
{
    if ($x >= 1.0)
        return 1.0;
    elseif ($x <= -1.0)
        return -1.0;
    else
        return $x;
}

function gepStep4($x)
{
    if ($x >= 1.0)
        return 1.0;
    elseif ($x <= 0.0)
        return 0.0;
    else
        return $x;
}

function gepCL2A($x, $y)
{
    if ($x > 0.0 && $y > 0.0)
        return 1.0;
    else
        return -1.0;
}

function gepCL2B($x, $y)
{
    if ($x >= 0.0 && $y < 0.0)
        return -1.0;
    else
        return 1.0;
}

function gepCL2C($x, $y)
{
    if ($x > 1.0 && $y < -1.0)
        return -1.0;
    else
        return 1.0;
}

function gepCL2D($x, $y)
{
    if ($x > 0.0 && $y > 0.0)
        return 1.0;
    else
        return 0.0;
}

function gepCL2E($x, $y)
{
    if ($x >= 0.0 && $y <= 0.0)
        return 0.0;
    else
        return 1.0;
}

function gepCL2F($x, $y)
{
    if ($x > 1.0 && $y < -1.0)
        return 0.0;
    else
        return 1.0;
}

function gepCL3A($x, $y)
{
    if ($x > 0.0 && $y < 0.0)
        return 1.0;
    elseif ($x < 0.0 && $y > 0.0)
        return -1.0;
    else
        return 0.0;
}

function gepCL3B($x, $y)
{
    if ($x >= 1.0 && $y >= 1.0)
        return 1.0;
    elseif ($x <= -1.0 && $y <= -1.0)
        return -1.0;
    else
        return 0.0;
}

function gepCL3C($x, $y)
{
    if ($x > 0.0 && $y > 0.0)
        return 1.0;
    elseif ($x < 0.0 && $y < 0.0)
        return -1.0;
    else
        return 0.0;
}

function gepMap3A($x, $y)
{
    $SLACK = 10.0;
    $outVal = 0.0;
    if ($y < ($x - $SLACK))
        $outVal = -1.0;
    elseif ($y > ($x + $SLACK))
        $outVal = 1.0;
    return $outVal;
}

function gepMap3B($x, $y, $z)
{
    $minValue = min($x,$y);
    $maxValue = max($x,$y);
    $outVal = 0.0;
    if ($z < $minValue)
        $outVal = -1.0;
    elseif ($z > $maxValue)
        $outVal = 1.0;
    return $outVal;
}

function gepMap3C($a, $b, $c, $d)
{
    $minValue = min($a,$b,$c);
    $maxValue = max($a,$b,$c);
    $outVal = 0.0;
    if ($d < $minValue)
        $outVal = -1.0;
    elseif ($d > $maxValue)
        $outVal = 1.0;
    return $outVal;
}

function gepMap4A($x, $y)
{
    $SLACK = 10.0;
    $outVal = 0.0;
    if ($y < ($x - $SLACK))
        $outVal = 0.0;
    elseif ($y >= ($x - $SLACK) && $y < $x)
        $outVal = 1.0;
    elseif ($y >= $x && $y < ($x + $SLACK))
        $outVal = 2.0;
    elseif ($y >= ($x + $SLACK))
        $outVal = 3.0;
    return $outVal;
}

function gepMap4B($x, $y, $z)
{
    // evaluate minValue(x,y), maxValue(x,y) and midrange
    $minValue = min($x,$y);
    $maxValue = max($x,$y);
    $midrange = ($maxValue + $minValue)/2.0;
    
    $outVal = 0.0;
    if ($z < $minValue)
        $outVal = 0.0;
    elseif ($z >= $minValue && $z < $midrange)
        $outVal = 1.0;
    elseif ($z >= $midrange && $z < $maxValue)
        $outVal = 2.0;
    elseif ($z >= $maxValue)
        $outVal = 3.0;
    return $outVal;
}

function gepMap4C($a, $b, $c, $d)
{
    // evaluate minValue(a,b,c), maxValue(a,b,c) and midleValue(a,b,c)
    //
    // evaluate minValue(a,b,c)
    $minValue = $a;
    $argMin = 0;
    if ($minValue > $b)
    {
        $minValue = $b;
        $argMin = 1;
    }
    if ($minValue > $c)
    {
        $minValue = $c;
        $argMin = 2;
    }
    // evaluate maxValue(a,b,c)
    $maxValue = $a;
    $argMax = 0;
    if ($maxValue < $b)
    {
        $maxValue = $b;
        $argMax = 1;
    }
    if ($maxValue < $c)
    {
        $maxValue = $c;
        $argMax = 2;
    }
    // evaluate midleValue(a,b,c)
    $midleValue = $c;
    if (0 != $argMin && 0 != $argMax)
        $midleValue = $a;
    if (1 != $argMin && 1 != $argMax)
        $midleValue = $b;

    $outVal = 0.0;
    if ($d < $minValue)
        $outVal = 0.0;
    elseif ($d >= $minValue && $d < $midleValue)
        $outVal = 1.0;
    elseif ($d >= $midleValue && $d < $maxValue)
        $outVal = 2.0;
    elseif ($d >= $maxValue)
        $outVal = 3.0;
    return $outVal;
}

function gepMap5A($x, $y)
{
    $SLACK = 15.0;
    $outVal = 0.0;
    if ($y < ($x - $SLACK))
        $outVal = 0.0;
    elseif ($y >= ($x - $SLACK) && $y < ($x - $SLACK/3.0))
        $outVal = 1.0;
    elseif ($y >= ($x - $SLACK/3.0) && $y < ($x + $SLACK/3.0))
        $outVal = 2.0;
    elseif ($y >= ($x + $SLACK/3.0) && $y < ($x + $SLACK))
        $outVal = 3.0;
    elseif ($y >= ($x + $SLACK))
        $outVal = 4.0;
    return $outVal;
}

function gepMap5B($x, $y, $z)
{
    // evaluate minValue(x,y), maxValue(x,y), midpoint1, midpoint2
    $minValue = min($x,$y);
    $maxValue = max($x,$y);
    $intervalLength = ($maxValue - $minValue)/3.0;
    $midpoint1 = $minValue + $intervalLength;
    $midpoint2 = $minValue + 2.0*$intervalLength;
    
    $outVal = 0.0;
    if ($z < $minValue)
        $outVal = 0.0;
    elseif ($z >= $minValue && $z < $midpoint1)
        $outVal = 1.0;
    elseif ($z >= $midpoint1 && $z < $midpoint2)
        $outVal = 2.0;
    elseif ($z >= $midpoint2 && $z < $maxValue)
        $outVal = 3.0;
    elseif ($z >= $maxValue)
        $outVal = 4.0;
    return $outVal;
}

function gepMap5C($a, $b, $c, $d)
{
    // evaluate minValue(a,b,c), maxValue(a,b,c), midleValue(a,b,c), midrange1, midrange2
    //
    // evaluate minValue(a,b,c)
    $minValue = $a;
    $argMin = 0;
    if ($minValue > $b)
    {
        $minValue = $b;
        $argMin = 1;
    }
    if ($minValue > $c)
    {
        $minValue = $c;
        $argMin = 2;
    }
    // evaluate maxValue(a,b,c)
    $maxValue = $a;
    $argMax = 0;
    if ($maxValue < $b)
    {
        $maxValue = $b;
        $argMax = 1;
    }
    if ($maxValue < $c)
    {
        $maxValue = $c;
        $argMax = 2;
    }
    // evaluate midleValue(a,b,c)
    $midleValue = $c;
    if (0 != $argMin && 0 != $argMax)
        $midleValue = $a;
    if (1 != $argMin && 1 != $argMax)
        $midleValue = $b;
    // evaluate midrange1 and midrange2
    $midrange1 = ($minValue + $midleValue)/2.0;
    $midrange2 = ($midleValue + $maxValue)/2.0;

    $outVal = 0.0;
    if ($d < $minValue)
        $outVal = 0.0;
    elseif ($d >= $minValue && $d < $midrange1)
        $outVal = 1.0;
    elseif ($d >= $midrange1 && $d < $midrange2)
        $outVal = 2.0;
    elseif ($d >= $midrange2 && $d < $maxValue)
        $outVal = 3.0;
    elseif ($d >= $maxValue)
        $outVal = 4.0;
    return $outVal;
}

function gepMap6A($x, $y)
{
    $SLACK = 10.0;
    $outVal = 0.0;
    if ($y < ($x - $SLACK))
        $outVal = 0.0;
    elseif ($y >= ($x - $SLACK) && $y < ($x - $SLACK/2.0))
        $outVal = 1.0;
    elseif ($y >= ($x - $SLACK/2.0) && $y < $x)
        $outVal = 2.0;
    elseif ($y >= $x && $y < ($x + $SLACK/2.0))
        $outVal = 3.0;
    elseif ($y >= ($x + $SLACK/2.0) && $y < ($x + $SLACK))
        $outVal = 4.0;
    elseif ($y >= ($x + $SLACK))
        $outVal = 5.0;
    return $outVal;
}

function gepMap6B($x, $y, $z)
{
    // evaluate minValue(x,y), maxValue(x,y), midrange, midpoint1, midpoint2
    $minValue = min($x,$y);
    $maxValue = max($x,$y);
    $midrange = ($minValue + $maxValue)/2.0;
    $midpoint1 = ($minValue + $midrange)/2.0;
    $midpoint2 = ($midrange + $maxValue)/2.0;
    
    $outVal = 0.0;
    if ($z < $minValue)
        $outVal = 0.0;
    elseif ($z >= $minValue && $z < $midpoint1)
        $outVal = 1.0;
    elseif ($z >= $midpoint1 && $z < $midrange)
        $outVal = 2.0;
    elseif ($z >= $midrange && $z < $midpoint2)
        $outVal = 3.0;
    elseif ($z >= $midpoint2 && $z < $maxValue)
        $outVal = 4.0;
    elseif ($z >= $maxValue)
        $outVal = 5.0;
    return $outVal;
}

function gepMap6C($a, $b, $c, $d)
{
    // evaluate minValue(a,b,c), maxValue(a,b,c), midleValue(a,b,c), midrange1, midrange2
    //
    // evaluate minValue(a,b,c)
    $minValue = $a;
    $argMin = 0;
    if ($minValue > $b)
    {
        $minValue = $b;
        $argMin = 1;
    }
    if ($minValue > $c)
    {
        $minValue = $c;
        $argMin = 2;
    }
    // evaluate maxValue(a,b,c)
    $maxValue = $a;
    $argMax = 0;
    if ($maxValue < $b)
    {
        $maxValue = $b;
        $argMax = 1;
    }
    if ($maxValue < $c)
    {
        $maxValue = $c;
        $argMax = 2;
    }
    // evaluate midleValue(a,b,c)
    $midleValue = $c;
    if (0 != $argMin && 0 != $argMax)
        $midleValue = $a;
    if (1 != $argMin && 1 != $argMax)
        $midleValue = $b;
    // evaluate midrange1 and midrange2
    $midrange1 = ($minValue + $midleValue)/2.0;
    $midrange2 = ($midleValue + $maxValue)/2.0;

    $outVal = 0.0;
    if ($d < $minValue)
        $outVal = 0.0;
    elseif ($d >= $minValue && $d < $midrange1)
        $outVal = 1.0;
    elseif ($d >= $midrange1 && $d < $midleValue)
        $outVal = 2.0;
    elseif ($d >= $midleValue && $d < $midrange2)
        $outVal = 3.0;
    elseif ($d >= $midrange2 && $d < $maxValue)
        $outVal = 4.0;
    elseif ($d >= $maxValue)
        $outVal = 5.0;
    return $outVal;
}

function gepECL3A($x, $y, $z)
{
    if ($y > $x && $z < $x)
        return 1.0;
    elseif ($y < $x && $z > $x)
        return -1.0;
    else return 0.0;
}

function gepECL3B($x, $y, $z)
{
    if ($y > $x && $z > $x)
        return 1.0;
    elseif ($y < $x && $z < $x)
        return -1.0;
    else return 0.0;
}

function gepECL3C($x, $y, $z)
{
    if ($y >= $x && $z >= $x)
        return 1.0;
    elseif ($y <= -$x && $z <= -$x)
        return -1.0;
    else return 0.0;
}

function gepECL3D($a, $b, $c, $d)
{
    $minValue = min($a,$b);
    $maxValue = max($a,$b);
    if ($c >= $maxValue && $d >= $maxValue)
        return 1.0;
    elseif ($c <= $minValue && $d <= $minValue)
        return -1.0;
    else return 0.0;
}

function gepAMin2($x, $y)
{
    if ($x < $y)
        return 0.0;
    else
        return 1.0;
}

function gepAMin3($x, $y, $z)
{
    $temp = $x;
    $argMin = 0.0;    
    if ($temp >= $y)
    {
        $temp = $y;
        $argMin = 1.0;
    }
    if ($temp >= $z)
    {
        $argMin = 2.0;
    }
    return $argMin;
}

function gepAMin4($a, $b, $c, $d)
{
    $temp = $a;
    $argMin = 0.0;    
    if ($temp >= $b)
    {
        $temp = $b;
        $argMin = 1.0;
    }
    if ($temp >= $c)
    {
        $temp = $c;
        $argMin = 2.0;
    }
    if ($temp >= $d)
    {
        $argMin = 3.0;
    }
    return $argMin;
}

function gepAMax2($x, $y)
{
    if ($x >= $y)
        return 0.0;
    else
        return 1.0;
}

function gepAMax3($x, $y, $z)
{
    $temp = $x;
    $argMax = 0.0;    
    if ($temp < $y)
    {
        $temp = $y;
        $argMax = 1.0;
    }
    if ($temp < $z)
    {
        $argMax = 2.0;
    }
    return $argMax;
}

function gepAMax4($a, $b, $c, $d)
{
    $temp = $a;
    $argMax = 0.0;    
    if ($temp < $b)
    {
        $temp = $b;
        $argMax = 1.0;
    }
    if ($temp < $c)
    {
        $temp = $c;
        $argMax = 2.0;
    }
    if ($temp < $d)
    {
        $argMax = 3.0;
    }
    return $argMax;
}

Author

← Older Newer →