Skip to content

Commit

Permalink
small improvements/fixes/workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
pcfreak9000 committed Jan 16, 2022
1 parent 457c0a7 commit 1626a80
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/main/java/de/pcfreak9000/command/SetCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,21 @@ public Integer call() throws Exception {
return Main.CODE_ERROR;
}
DataTablet dt = (DataTablet) t;
dt.setValues(Arrays.stream(params).map((s) -> EvalEngine.get().parse(s)).toArray(IExpr[]::new));
dt.setErrors(Arrays.stream(errors).map((s) -> EvalEngine.get().parse(s)).toArray(IExpr[]::new));
dt.setValues(Arrays.stream(params).map((s) -> EvalEngine.get().parse(fixNr(s))).toArray(IExpr[]::new));
dt.setErrors(Arrays.stream(errors).map((s) -> EvalEngine.get().parse(fixNr(s))).toArray(IExpr[]::new));
dt.setPreferredPropagation(preferredPropagation);
dt.setDataUsage(dataUsage);
System.out.println("Set the value(s) of tablet '" + tabletName + "' to '" + Arrays.toString(params)
+ "' and the error(s) to '" + Arrays.toString(errors) + "'.");
System.out.println("Set the value(s) of tablet '" + tabletName + "' to '" + Arrays.toString(dt.values)
+ "' and the error(s) to '" + Arrays.toString(dt.errors) + "'.");
}
return Main.CODE_NORMAL;
}
private String fixNr(String in) {
in = in.replace(',', '.');
if (in.contains("E")) {
String[] ar = in.split("E");
in = "((" + ar[0] + ")*10^(" + Main.evaluator().eval(ar[1]).toString() + "))";
}
return in;
}
}
7 changes: 6 additions & 1 deletion src/main/java/de/pcfreak9000/command/TexCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,16 @@ public Integer call() {
variables[i] = function.getInternalFromVar(variables[i]);
}
}
String prop = function.getErrorPropFunction(propType, variables);
String stt = prop;
for(String in : function.getInternalArgs()) {
stt = stt.replace(in, function.getVarFromInternal(in));
}
System.out.println("TeXForm of the error propagation of the function '" + function.getFunctionOriginal()
+ "' with respect to the variables " + Arrays.toString(function.getVarArgs()) + ":");
System.out.println(stt);//TODO make this better
if (split == 0) {
ExprEvaluator eval = new ExprEvaluator();
String prop = function.getErrorPropFunction(propType, variables);
String texString = eval.eval("TeXForm[" + prop + "]").toString();
texString = prepareDeltaTexString(texString, variables);
texString = prepareRawTexString(texString, function);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/de/pcfreak9000/main/DataTablet.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public static enum DataUsage {
Raw, MSD/* Mean and standard deviation */
}

private IExpr[] values;
private IExpr[] errors;
public IExpr[] values;
public IExpr[] errors;//TODO tmp public

private PropagationType preferredPropagation = PropagationType.Linear;
private DataUsage dataUsage;
Expand Down Expand Up @@ -150,4 +150,5 @@ public String toString() {
return stringRepresentation();
}


}

0 comments on commit 1626a80

Please sign in to comment.