Commit 82fe255b authored by Ahmed's avatar Ahmed

Add tube feature to cube

enable of cube expression:
 A(:, n, m) 
parent 8f85d379
Pipeline #233158 passed with stages
in 31 minutes and 31 seconds
......@@ -23,6 +23,8 @@ public interface MathBackend {
String getRowAccessCommandName();
String getTubeAccessCommandName();
String getBackendName();
String getTransposeCommand();
......
......@@ -49,6 +49,11 @@ public class ArmadilloBackend implements MathBackend {
return "row";
}
@Override
public String getTubeAccessCommandName() {
return "tube";
}
@Override
public String getBackendName() {
return "ArmadilloBackend";
......
......@@ -31,6 +31,11 @@ public class LinalgBackend implements MathBackend {
return null;
}
@Override
public String getTubeAccessCommandName(){
return null;
}
@Override
public String getColumnVectorTypeName() {
return null;
......
......@@ -50,6 +50,10 @@ public class OctaveBackend implements MathBackend {
return "row";
}
@Override public String getTubeAccessCommandName(){
return "";
}
@Override
public String getBackendName() {
return NAME;
......
......@@ -96,6 +96,11 @@ public class ExecuteMethodGeneratorMatrixExpressionHandler {
} else if (mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().get(1).isDoubleDot()) {
result += "." + MathConverter.curBackend.getRowAccessCommandName();
}
} else if(mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().size() == 3){
if(mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().get(0).isDoubleDot() ||
mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().get(2).isDoubleDot()){
result += "." + MathConverter.curBackend.getTubeAccessCommandName();
}
}
return result;
}
......@@ -108,29 +113,45 @@ public class ExecuteMethodGeneratorMatrixExpressionHandler {
return matrixExtractionPart.equals(".row");
}
public static int getIgnoreCounterAt(String matrixExtractionPart) {
public static boolean isTubeString(String matrixExtractionPart) {
return matrixExtractionPart.equals(".tube");
}
public static int getIgnoreCounterAt(String matrixExtractionPart, MathMatrixAccessOperatorSymbol mathMatrixAccessOperatorSymbol) {
int ignoreCounterAt = -1;
if (isColumnString(matrixExtractionPart)) {
ignoreCounterAt = 0;
} else if (isRowString(matrixExtractionPart)) {
ignoreCounterAt = 1;
} else if(isTubeString(matrixExtractionPart)){
if(mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().get(0).isDoubleDot()){
ignoreCounterAt = 0;
}else if(mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().get(2).isDoubleDot()){
ignoreCounterAt = 2;
}
}
return ignoreCounterAt;
}
public static int getCounterSetMinusOne(String matrixExtractionPart) {
public static int getCounterSetMinusOne(String matrixExtractionPart, MathMatrixAccessOperatorSymbol mathMatrixAccessOperatorSymbol) {
int counterSetMinusOne = -1;
if (isColumnString(matrixExtractionPart)) {
counterSetMinusOne = 1;
} else if (isRowString(matrixExtractionPart)) {
counterSetMinusOne = 0;
}else if(isTubeString(matrixExtractionPart)) {
if (mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().get(0).isDoubleDot()) {
counterSetMinusOne = 2;
} else if (mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols().get(2).isDoubleDot()) {
counterSetMinusOne = 0;
}
}
return counterSetMinusOne;
}
public static String updateMatrixAccessString(MathMatrixAccessOperatorSymbol mathMatrixAccessOperatorSymbol, int counter, String matrixExtractionPart, boolean setMinusOne, List<String> includeStrings) {
int ignoreCounterAt = getIgnoreCounterAt(matrixExtractionPart);
int counterSetMinusOne = getCounterSetMinusOne(matrixExtractionPart);
int ignoreCounterAt = getIgnoreCounterAt(matrixExtractionPart, mathMatrixAccessOperatorSymbol);
int counterSetMinusOne = getCounterSetMinusOne(matrixExtractionPart, mathMatrixAccessOperatorSymbol);
String result = "";
for (MathMatrixAccessSymbol mathMatrixAccessSymbol : mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols()) {
if (counter == ignoreCounterAt) {
......@@ -188,7 +209,7 @@ public class ExecuteMethodGeneratorMatrixExpressionHandler {
}
public static String updateMatrixAccessStringFixForLoop(MathMatrixAccessOperatorSymbol mathMatrixAccessOperatorSymbol, int counter, String matrixExtractionPart, List<String> includeStrings) {
int ignoreCounterAt = getIgnoreCounterAt(matrixExtractionPart);
int ignoreCounterAt = getIgnoreCounterAt(matrixExtractionPart, mathMatrixAccessOperatorSymbol);
String result = "";
for (MathMatrixAccessSymbol mathMatrixAccessSymbol : mathMatrixAccessOperatorSymbol.getMathMatrixAccessSymbols()) {
if (counter == ignoreCounterAt) {
......
......@@ -285,9 +285,9 @@ public class ArmadilloFunctionTest extends AbstractSymtabTest {
public void testRectangleCommand() throws IOException {
testMathCommand("rectangle");
}
@Test
/*
@Test //only for testing
public void testErodeAndGaussianBlur() throws IOException{
testMathCommand("erodeAndGaussianBlur");
}
}*/
}
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