Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
f8903b14
Commit
f8903b14
authored
Jul 12, 2018
by
Christoph Richter
Browse files
fixup! Fixed element-wise multiplication generation armadillo (gitlab
#13
)
parent
b83d0854
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/MathBackend.java
View file @
f8903b14
...
...
@@ -37,6 +37,7 @@ public interface MathBackend {
String
getDivisionEEString
(
MathMatrixArithmeticExpressionSymbol
mathExpressionSymbol
,
String
valueListString
);
String
getMultiplicationEEString
(
MathMatrixArithmeticExpressionSymbol
mathExpressionSymbol
,
String
valueListString
);
/**
* Does the backend use 0-based or 1-based indexing for matrix element access?
*
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/ArmadilloBackend.java
View file @
f8903b14
...
...
@@ -104,6 +104,12 @@ public class ArmadilloBackend implements MathBackend {
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
.
getRightExpression
(),
new
ArrayList
<>());
}
@Override
public
String
getMultiplicationEEString
(
MathMatrixArithmeticExpressionSymbol
mathExpressionSymbol
,
String
valueListString
)
{
return
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
.
getLeftExpression
(),
new
ArrayList
<>())
+
" % "
+
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
.
getRightExpression
(),
new
ArrayList
<>());
}
@Override
public
boolean
usesZeroBasedIndexing
()
{
return
true
;
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/LinalgBackend.java
View file @
f8903b14
...
...
@@ -89,6 +89,12 @@ public class LinalgBackend implements MathBackend {
return
null
;
}
@Override
public
String
getMultiplicationEEString
(
MathMatrixArithmeticExpressionSymbol
mathExpressionSymbol
,
String
valueListString
)
{
Log
.
debug
(
"Not supported yet"
,
"Not Implemented"
);
return
null
;
}
@Override
public
boolean
usesZeroBasedIndexing
()
{
// TODO: check this! Do not know this backend...
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/MathFunctionFixer.java
View file @
f8903b14
...
...
@@ -185,13 +185,8 @@ public class MathFunctionFixer extends BaseMathFunctionFixerHandler {
public
static
void
fixMathFunctions
(
MathMatrixArithmeticExpressionSymbol
mathExpressionSymbol
,
BluePrintCPP
bluePrintCPP
)
{
fixMathFunctions
(
mathExpressionSymbol
.
getLeftExpression
(),
bluePrintCPP
);
if
(
mathExpressionSymbol
.
getRightExpression
()
!=
null
)
{
if
(
mathExpressionSymbol
.
getRightExpression
()
!=
null
)
fixMathFunctions
(
mathExpressionSymbol
.
getRightExpression
(),
bluePrintCPP
);
// fix element wise multiplication
if
(
mathExpressionSymbol
.
getOperator
().
contentEquals
(
".*"
))
{
mathExpressionSymbol
.
setOperator
(
"%"
);
}
}
}
public
static
void
fixMathFunctions
(
MathMatrixNameExpressionSymbol
mathExpressionSymbol
,
BluePrintCPP
bluePrintCPP
)
{
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/OctaveBackend.java
View file @
f8903b14
...
...
@@ -92,6 +92,12 @@ public class OctaveBackend implements MathBackend {
return
OctaveHelper
.
getCallOctaveFunctionFirstResult
(
mathExpressionSymbol
.
getLeftExpression
(),
"ldivide"
,
valueListString
,
false
);
}
@Override
public
String
getMultiplicationEEString
(
MathMatrixArithmeticExpressionSymbol
mathExpressionSymbol
,
String
valueListString
)
{
Log
.
warn
(
"Backend deprecated"
);
return
OctaveHelper
.
getCallOctaveFunctionFirstResult
(
mathExpressionSymbol
.
getLeftExpression
(),
".*"
,
valueListString
,
false
);
}
@Override
public
boolean
usesZeroBasedIndexing
()
{
return
false
;
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/ExecuteMethodGeneratorMatrixExpressionHandler.java
View file @
f8903b14
...
...
@@ -24,6 +24,8 @@ public class ExecuteMethodGeneratorMatrixExpressionHandler {
result
=
generateExecuteCodeMatrixEEPowerOf
(
mathMatrixArithmeticExpressionSymbol
,
includeStrings
);
}
else
if
(
mathMatrixArithmeticExpressionSymbol
.
getMathOperator
().
equals
(
"./"
))
{
result
=
generateExecuteCodeMatrixEEDivide
(
mathMatrixArithmeticExpressionSymbol
,
includeStrings
);
}
else
if
(
mathMatrixArithmeticExpressionSymbol
.
getMathOperator
().
equals
(
".*"
))
{
result
=
generateExecuteCodeMatrixEEMult
(
mathMatrixArithmeticExpressionSymbol
,
includeStrings
);
/*} else if (mathArithmeticExpressionSymbol.getMathOperator().equals("./")) {
Log.error("reace");
result += "\"ldivide\"";
...
...
@@ -44,6 +46,11 @@ public class ExecuteMethodGeneratorMatrixExpressionHandler {
return
result
;
}
private
static
String
generateExecuteCodeMatrixEEMult
(
MathMatrixArithmeticExpressionSymbol
mathMatrixArithmeticExpressionSymbol
,
List
<
String
>
includeStrings
)
{
String
valueListString
=
calculateValueListString
(
mathMatrixArithmeticExpressionSymbol
);
return
MathConverter
.
curBackend
.
getMultiplicationEEString
(
mathMatrixArithmeticExpressionSymbol
,
valueListString
);
}
public
static
String
calculateValueListString
(
IArithmeticExpression
mathExpressionSymbol
)
{
List
<
MathExpressionSymbol
>
list
=
new
ArrayList
<
MathExpressionSymbol
>();
list
.
add
(
mathExpressionSymbol
.
getLeftExpression
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment