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 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.
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
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
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
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;
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.
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;
}
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.