Commit ce277f76 authored by Christoph Richter's avatar Christoph Richter
Browse files

MathBackend: Introduced usesZeroBasedIndexing to define indexing type

parent c1d25d27
...@@ -37,4 +37,11 @@ public interface MathBackend { ...@@ -37,4 +37,11 @@ public interface MathBackend {
String getDivisionEEString(MathMatrixArithmeticExpressionSymbol mathExpressionSymbol, String valueListString); String getDivisionEEString(MathMatrixArithmeticExpressionSymbol mathExpressionSymbol, String valueListString);
/**
* Does the backend use 0-based or 1-based indexing for matrix element access?
*
* @return whether the backend uses zero based indexing (true) or one based indexing (false)
*/
boolean usesZeroBasedIndexing();
} }
...@@ -101,4 +101,9 @@ public class ArmadilloBackend implements MathBackend { ...@@ -101,4 +101,9 @@ public class ArmadilloBackend implements MathBackend {
return ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol.getLeftExpression(), new ArrayList<>()) + "/" + return ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol.getLeftExpression(), new ArrayList<>()) + "/" +
ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol.getRightExpression(), new ArrayList<>()); ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol.getRightExpression(), new ArrayList<>());
} }
@Override
public boolean usesZeroBasedIndexing() {
return true;
}
} }
...@@ -88,4 +88,10 @@ public class LinalgBackend implements MathBackend { ...@@ -88,4 +88,10 @@ public class LinalgBackend implements MathBackend {
Log.error("Not supported yet"); Log.error("Not supported yet");
return null; return null;
} }
@Override
public boolean usesZeroBasedIndexing() {
// TODO: check this! Do not know this backend...
return false;
}
} }
...@@ -92,5 +92,8 @@ public class OctaveBackend implements MathBackend { ...@@ -92,5 +92,8 @@ public class OctaveBackend implements MathBackend {
return OctaveHelper.getCallOctaveFunctionFirstResult(mathExpressionSymbol.getLeftExpression(), "ldivide", valueListString, false); return OctaveHelper.getCallOctaveFunctionFirstResult(mathExpressionSymbol.getLeftExpression(), "ldivide", valueListString, false);
} }
@Override
public boolean usesZeroBasedIndexing() {
return false;
}
} }
Supports Markdown
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