Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
62f4551a
Commit
62f4551a
authored
Jul 12, 2018
by
Christoph Richter
Browse files
Fixed element-wise multiplication generation armadillo (gitlab
#13
)
parent
bfdd83c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/MathFunctionFixer.java
View file @
62f4551a
...
...
@@ -185,8 +185,13 @@ 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/test/java/de/monticore/lang/monticar/generator/cpp/armadillo/BasicMathGenerationArmadilloTest.java
View file @
62f4551a
...
...
@@ -130,4 +130,18 @@ public class BasicMathGenerationArmadilloTest extends AbstractSymtabTest {
String
restPath
=
"armadillo/test/custom/l0/"
;
testFilesAreEqual
(
files
,
restPath
);
}
@Test
public
void
elementwiseMultTest
()
throws
IOException
{
TaggingResolver
symtab
=
createSymTabAndTaggingResolver
(
"src/test/resources"
);
ExpandedComponentInstanceSymbol
componentSymbol
=
symtab
.<
ExpandedComponentInstanceSymbol
>
resolve
(
"test.math.elementwiseMultTest"
,
ExpandedComponentInstanceSymbol
.
KIND
).
orElse
(
null
);
assertNotNull
(
componentSymbol
);
GeneratorCPP
generatorCPP
=
new
GeneratorCPP
();
generatorCPP
.
useArmadilloBackend
();
generatorCPP
.
setGenerationTargetPath
(
"./target/generated-sources-cpp/armadillo/testMath/l0"
);
List
<
File
>
files
=
generatorCPP
.
generateFiles
(
symtab
,
componentSymbol
,
symtab
);
String
restPath
=
"armadillo/testMath/l0/"
;
testFilesAreEqual
(
files
,
restPath
);
}
}
src/test/resources/results/armadillo/testMath/l0/test_math_elementwiseMultTest.h
0 → 100644
View file @
62f4551a
#ifndef TEST_MATH_ELEMENTWISEMULTTEST
#define TEST_MATH_ELEMENTWISEMULTTEST
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include
"armadillo.h"
using
namespace
arma
;
class
test_math_elementwiseMultTest
{
public:
mat
CONSTANTCONSTANTVECTOR0
;
mat
CONSTANTCONSTANTVECTOR1
;
void
init
()
{
CONSTANTCONSTANTVECTOR0
=
mat
(
2
,
2
);
CONSTANTCONSTANTVECTOR0
(
0
,
0
)
=
1
;
CONSTANTCONSTANTVECTOR0
(
0
,
1
)
=
1
;
CONSTANTCONSTANTVECTOR0
(
1
,
0
)
=
1
;
CONSTANTCONSTANTVECTOR0
(
1
,
1
)
=
1
;
CONSTANTCONSTANTVECTOR1
=
mat
(
2
,
2
);
CONSTANTCONSTANTVECTOR1
(
0
,
0
)
=
1
;
CONSTANTCONSTANTVECTOR1
(
0
,
1
)
=
2
;
CONSTANTCONSTANTVECTOR1
(
1
,
0
)
=
3
;
CONSTANTCONSTANTVECTOR1
(
1
,
1
)
=
4
;
}
void
execute
()
{
mat
A
=
CONSTANTCONSTANTVECTOR0
;
mat
B
=
CONSTANTCONSTANTVECTOR1
;
mat
C
=
A
%
B
;
}
};
#endif
src/test/resources/test/math/ElementwiseMultTest.emam
0 → 100644
View file @
62f4551a
package
test
.
math
;
component
ElementwiseMultTest
{
implementation
Math
{
Q
^{
2
,
2
}
A
=
[
1
,
1
;
1
,
1
];
Q
^{
2
,
2
}
B
=
[
1
,
2
;
3
,
4
];
Q
^{
2
,
2
}
C
=
A
.*
B
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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