use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class Limit method convert.
/** {@inheritDoc} */
public boolean convert(final StringBuffer buf, final IAST f, final int precedence) {
if (f.isAST2() && f.arg2().isRuleAST()) {
final IAST rule = (IAST) f.arg2();
buf.append("\\lim_{");
fFactory.convertSubExpr(buf, rule.arg1(), 0);
buf.append("\\to ");
fFactory.convertSubExpr(buf, rule.arg2(), 0);
buf.append(" }\\,");
fFactory.convertSubExpr(buf, f.arg1(), 0);
// fFactory.convert(buf, f.arg1(), 0);
return true;
}
return false;
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class Symbol method definitionToString.
/** {@inheritDoc} */
@Override
public String definitionToString() throws IOException {
StringWriter buf = new StringWriter();
OutputFormFactory off = OutputFormFactory.get(EvalEngine.get().isRelaxedSyntax());
off.setIgnoreNewLine(true);
List<IAST> list = definition();
buf.append("{");
for (int i = 0; i < list.size(); i++) {
off.convert(buf, list.get(i));
if (i < list.size() - 1) {
buf.append(",\n ");
off.setColumnCounter(0);
}
}
buf.append("}\n");
return buf.toString();
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class List method convert.
/** {@inheritDoc} */
public boolean convert(final StringBuffer buf, final IAST ast, final int precedence) {
int[] dims = ast.isMatrix();
if (dims != null) {
// create a LaTeX matrix
buf.append("\\left(\n\\begin{array}{");
for (int i = 0; i < dims[1]; i++) {
buf.append("c");
}
buf.append("}\n");
if (ast.size() > 1) {
for (int i = 1; i < ast.size(); i++) {
IAST row = ast.getAST(i);
for (int j = 1; j < row.size(); j++) {
fFactory.convert(buf, row.get(j), 0);
if (j < row.size() - 1) {
buf.append(" & ");
}
}
if (i < ast.size() - 1) {
buf.append(" \\\\\n");
} else {
buf.append(" \n");
}
}
}
buf.append("\\end{array}\n\\right) ");
// \begin{pmatrix} x & y \\ u & v \end{pmatrix}
// buf.append("\\begin{pmatrix} ");
// if (ast.size() > 1) {
// for (int i = 1; i < ast.size(); i++) {
// IAST row = ast.getAST(i);
// for (int j = 1; j < row.size(); j++) {
// fFactory.convert(buf, row.get(j), 0);
// if (j < row.size() - 1) {
// buf.append(" & ");
// }
// }
// if (i < ast.size() - 1) {
// buf.append(" \\\\ ");
// }
// }
// }
// buf.append(" \\end{pmatrix} ");
} else if ((ast.getEvalFlags() & IAST.IS_VECTOR) == IAST.IS_VECTOR) {
// create a LaTeX row vector
// \begin{pmatrix} x & y \end{pmatrix}
buf.append("\\begin{pmatrix} ");
if (ast.size() > 1) {
for (int j = 1; j < ast.size(); j++) {
fFactory.convert(buf, ast.get(j), 0);
if (j < ast.size() - 1) {
buf.append(" & ");
}
}
}
buf.append(" \\end{pmatrix} ");
} else {
buf.append("\\{");
if (ast.size() > 1) {
fFactory.convert(buf, ast.arg1(), 0);
for (int i = 2; i < ast.size(); i++) {
buf.append(',');
fFactory.convert(buf, ast.get(i), 0);
}
}
buf.append("\\}");
}
return true;
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class Plus method convert.
/** {@inheritDoc} */
@Override
public boolean convert(final StringBuffer buf, final IAST f, final int precedence) {
IExpr expr;
precedenceOpen(buf, precedence);
final Times timesConverter = new org.matheclipse.core.form.tex.reflection.Times();
timesConverter.setFactory(fFactory);
for (int i = 1; i < f.size(); i++) {
expr = f.get(i);
if ((i > 1) && (expr instanceof IAST) && expr.isTimes()) {
timesConverter.convertTimesFraction(buf, (IAST) expr, fPrecedence, Times.PLUS_CALL);
} else {
if (i > 1) {
if (expr.isNumber() && (((INumber) expr).complexSign() < 0)) {
buf.append("-");
expr = ((INumber) expr).negate();
} else if (expr.isNegativeSigned()) {
} else {
buf.append("+");
}
}
fFactory.convert(buf, expr, fPrecedence);
}
}
precedenceClose(buf, precedence);
return true;
}
use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.
the class OutputFormFactory method convertPlusArgument.
public void convertPlusArgument(final Appendable buf, IExpr plusArg, boolean caller) throws IOException {
if (plusArg.isTimes()) {
final IAST timesAST = (IAST) plusArg;
// IExpr arg1 = timesAST.arg1();
final InfixOperator TIMES_OPERATOR = (InfixOperator) ASTNodeFactory.MMA_STYLE_FACTORY.get("Times");
convertTimesFraction(buf, timesAST, TIMES_OPERATOR, ASTNodeFactory.TIMES_PRECEDENCE, caller);
} else {
if (plusArg.isNegativeSigned()) {
// special case negative number or -Infinity...
convert(buf, plusArg);
} else {
if (caller == PLUS_CALL) {
append(buf, "+");
}
convert(buf, plusArg, ASTNodeFactory.PLUS_PRECEDENCE, false);
}
}
}
Aggregations