Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 66cceaa9 authored by Ahmed's avatar Ahmed
Browse files

Merge branch 'voidFunc-branch' into adi-dev

parents ae510ae1 026a0f67
......@@ -29,6 +29,10 @@ public class BluePrint {
this.variables = variables;
}
public List<Variable> getVariables() {
return variables;
}
public void setName(String name) {
this.name = name;
}
......@@ -45,10 +49,6 @@ public class BluePrint {
return packageName;
}
public List<Variable> getVariables() {
return variables;
}
public int howManyVariables() {
return variables.size();
}
......@@ -60,7 +60,6 @@ public class BluePrint {
return Optional.empty();
}
public void addVariable(Variable v) {
variables.add(v);
}
......
......@@ -63,6 +63,7 @@ public class ErodeCommand extends MathCommand{
MathStringExpression stringExpression = new MathStringExpression("erode" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
}
......
......@@ -31,6 +31,7 @@ public class MathAbsCommand extends MathCommand {
convertUsingOctaveBackend(mathExpressionSymbol, bluePrint);
} else if (backendName.equals("ArmadilloBackend")) {
convertUsingArmadilloBackend(mathExpressionSymbol, bluePrint);
}
}
......@@ -72,5 +73,7 @@ public class MathAbsCommand extends MathCommand {
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
//((BluePrintCPP) bluePrint).addAdditionalIncludeString("octave/builtin-defun-decls");
//String name = bluePrint.getVariables().get(0).getNameTargetLanguageFormat();
}
}
......@@ -59,21 +59,34 @@ public class MathMaxCommand extends MathCommand {
public void convertUsingArmadilloBackend(MathExpressionSymbol mathExpressionSymbol, BluePrint bluePrint) {
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) mathExpressionSymbol;
mathMatrixNameExpressionSymbol.setNameToAccess("");
BluePrintCPP bluePrintCPP = (BluePrintCPP) bluePrint;
int parametersNumber = mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols().size();
String valueListString = "";
for (MathMatrixAccessSymbol accessSymbol : mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols())
MathFunctionFixer.fixMathFunctions(accessSymbol, (BluePrintCPP) bluePrint);
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
//OctaveHelper.getCallOctaveFunction(mathExpressionSymbol, "sum","Double", valueListString));
MathFunctionFixer.fixMathFunctions(accessSymbol,bluePrintCPP);
if (parametersNumber == 1){
convertMaxAramadillo(mathMatrixNameExpressionSymbol, bluePrintCPP);
}else if (parametersNumber == 2) {
convertMaxStd(mathMatrixNameExpressionSymbol, bluePrintCPP);
} else {
Log.error(String.format("No implementation found for max operation: \"max(%s)\". Possible syntax is \"max( X )\", \"max(a,b)\"", mathExpressionSymbol.getTextualRepresentation()));
}
}
private void convertMaxAramadillo(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, BluePrintCPP bluePrint){
String valueListString = ExecuteMethodGenerator.generateExecuteCode(mathMatrixNameExpressionSymbol, new ArrayList<>());
MathStringExpression stringExpression = new MathStringExpression("max(max" + valueListString + ")", mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
MathStringExpression stringExpression = new MathStringExpression("std::max"+valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
}
private void convertMaxStd(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, BluePrintCPP bluePrint){
String valueListString = ExecuteMethodGenerator.generateExecuteCode(mathMatrixNameExpressionSymbol, new ArrayList<>());
MathStringExpression stringExpression = new MathStringExpression("std::max" + valueListString, mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
}
}
......@@ -57,24 +57,37 @@ public class MathMinCommand extends MathCommand {
}
public void convertUsingArmadilloBackend(MathExpressionSymbol mathExpressionSymbol, BluePrint bluePrint) {
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) mathExpressionSymbol;
mathMatrixNameExpressionSymbol.setNameToAccess("");
BluePrintCPP bluePrintCPP = (BluePrintCPP) bluePrint;
int parametersNumber = mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols().size();
String valueListString = "";
for (MathMatrixAccessSymbol accessSymbol : mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols())
MathFunctionFixer.fixMathFunctions(accessSymbol, (BluePrintCPP) bluePrint);
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
//OctaveHelper.getCallOctaveFunction(mathExpressionSymbol, "sum","Double", valueListString));
MathFunctionFixer.fixMathFunctions(accessSymbol,bluePrintCPP);
if (parametersNumber == 1){
convertMinAramadillo(mathMatrixNameExpressionSymbol, bluePrintCPP);
}else if (parametersNumber == 2) {
convertMinStd(mathMatrixNameExpressionSymbol, bluePrintCPP);
} else {
Log.error(String.format("No implementation found for min operation: \"min(%s)\". Possible syntax is \"min( X )\", \"min(a,b)\"", mathExpressionSymbol.getTextualRepresentation()));
}
}
private void convertMinAramadillo(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, BluePrintCPP bluePrint){
String valueListString = ExecuteMethodGenerator.generateExecuteCode(mathMatrixNameExpressionSymbol, new ArrayList<>());
MathStringExpression stringExpression = new MathStringExpression("min(min" + valueListString + ")", mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
MathStringExpression stringExpression = new MathStringExpression("std::min"+valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
}
private void convertMinStd(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, BluePrintCPP bluePrint) {
String valueListString = ExecuteMethodGenerator.generateExecuteCode(mathMatrixNameExpressionSymbol, new ArrayList<>());
MathStringExpression stringExpression = new MathStringExpression("std::min" + valueListString, mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
}
}
......@@ -196,8 +196,21 @@ public class ArmadilloFunctionTest extends AbstractSymtabTest {
@Test
public void testCeilCommand() throws IOException {
testMathCommand("ceil");
}
@Test
public void testMaxCommand() throws IOException {
testMathCommand("max");
}
@Test
public void testMinCommand() throws IOException {
testMathCommand("min");
}
// Adding CV tests
@Test
......
......@@ -9,12 +9,16 @@ using namespace arma;
using namespace cv;
class test_math_erodeCommandTest{
public:
mat arrayIn;
mat arrayOut;
void init()
{
arrayIn=mat(n,m);
arrayOut=mat(n,m);
}
void execute()
{
double a = (erode(0, 0, 0, 0, 0));
arrayOut = (erode(arrayIn));
}
};
......
/* (c) https://github.com/MontiCore/monticore */
#ifndef TEST_MATH_MAXCOMMANDTEST
#define TEST_MATH_MAXCOMMANDTEST
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include "armadillo"
using namespace arma;
class test_math_maxCommandTest{
public:
void init()
{
}
void execute()
{
double a = (std::max(15, 4));
}
};
#endif
/* (c) https://github.com/MontiCore/monticore */
#ifndef TEST_MATH_MINCOMMANDTEST
#define TEST_MATH_MINCOMMANDTEST
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include "armadillo"
using namespace arma;
class test_math_minCommandTest{
public:
void init()
{
}
void execute()
{
double a = (std::min(15, 4));
}
};
#endif
......@@ -2,7 +2,11 @@
package test.math;
component ErodeCommandTest{
port
in Q^{n,m} arrayIn,
out Q^{n,m} arrayOut;
implementation Math{
Q a = erode(0,0,0,0,0);
arrayOut = erode(arrayIn);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment