use of org.matheclipse.core.interfaces.IComplexNum in project symja_android_library by axkr.
the class OutputFormFactory method convert.
public void convert(final Appendable buf, final IExpr o, final int precedence, boolean isASTHead) throws IOException {
if (o instanceof IAST) {
final IAST list = (IAST) o;
IExpr header = list.head();
if (!header.isSymbol()) {
// print expressions like: f(#1, y)& [x]
IAST[] derivStruct = list.isDerivativeAST1();
if (derivStruct != null) {
IAST a1Head = derivStruct[0];
IAST headAST = derivStruct[1];
if (a1Head.isAST1() && a1Head.arg1().isInteger() && headAST.isAST1() && headAST.arg1().isSymbol() && derivStruct[2] != null) {
try {
int n = ((IInteger) a1Head.arg1()).toInt();
// IExpr arg1 = listArg1.arg1();
if (n == 1 || n == 2) {
ISymbol f = (ISymbol) headAST.arg1();
convertSymbol(buf, f);
if (n == 1) {
append(buf, "'");
} else if (n == 2) {
append(buf, "''");
}
convertArgs(buf, f, list);
return;
}
} catch (ArithmeticException ae) {
}
}
}
convert(buf, header, Integer.MIN_VALUE, true);
convertFunctionArgs(buf, list);
return;
}
ISymbol head = list.topHead();
final Operator operator = getOperator(head);
if (operator != null) {
if (operator instanceof PostfixOperator) {
if (list.isAST1()) {
convertPostfixOperator(buf, list, (PostfixOperator) operator, precedence);
return;
}
} else {
if (convertOperator(operator, list, buf, isASTHead ? Integer.MAX_VALUE : precedence, head)) {
return;
}
}
}
if (list.isList() || list instanceof ASTRealVector || list instanceof ASTRealMatrix) {
convertList(buf, list);
return;
}
if (head.equals(F.Part) && (list.size() >= 3)) {
convertPart(buf, list);
return;
}
if (head.equals(F.Slot) && (list.isAST1()) && (list.arg1() instanceof IInteger)) {
convertSlot(buf, list);
return;
}
if (head.equals(F.SlotSequence) && (list.isAST1()) && (list.arg1() instanceof IInteger)) {
convertSlotSequence(buf, list);
return;
}
if ((head.equals(F.HoldForm) || head.equals(F.Defer)) && (list.isAST1())) {
convert(buf, list.arg1());
return;
}
if (head.equals(F.SeriesData) && (list.size() == 7)) {
if (convertSeriesData(buf, list, precedence)) {
return;
}
}
if (list.isDirectedInfinity()) {
// {
if (list.isAST0()) {
append(buf, "ComplexInfinity");
return;
}
if (list.isAST1()) {
if (list.arg1().isOne()) {
append(buf, "Infinity");
return;
} else if (list.arg1().isMinusOne()) {
if (ASTNodeFactory.PLUS_PRECEDENCE < precedence) {
append(buf, "(");
}
append(buf, "-Infinity");
if (ASTNodeFactory.PLUS_PRECEDENCE < precedence) {
append(buf, ")");
}
return;
} else if (list.arg1().isImaginaryUnit()) {
append(buf, "I*Infinity");
return;
} else if (list.arg1().isNegativeImaginaryUnit()) {
append(buf, "-I*Infinity");
return;
}
}
}
convertAST(buf, list);
return;
}
if (o instanceof ISignedNumber) {
convertNumber(buf, (ISignedNumber) o, precedence, NO_PLUS_CALL);
return;
}
if (o instanceof IComplexNum) {
convertDoubleComplex(buf, (IComplexNum) o, precedence, NO_PLUS_CALL);
return;
}
if (o instanceof IComplex) {
convertComplex(buf, (IComplex) o, precedence, NO_PLUS_CALL);
return;
}
if (o instanceof ISymbol) {
convertSymbol(buf, (ISymbol) o);
return;
}
if (o instanceof IPatternObject) {
convertPattern(buf, (IPatternObject) o);
return;
}
convertString(buf, o.toString());
}
use of org.matheclipse.core.interfaces.IComplexNum in project symja_android_library by axkr.
the class TeXFormFactory method convert.
public void convert(final StringBuffer buf, final Object o, final int precedence) {
if (o instanceof IExpr) {
IExpr expr = (IExpr) o;
String str = CONSTANT_EXPRS.get(expr);
if (str != null) {
buf.append(str);
return;
}
}
if (o instanceof IAST) {
final IAST f = ((IAST) o);
IExpr h = f.head();
if (h.isSymbol()) {
IConverter converter = reflection(((ISymbol) h).getSymbolName());
if ((converter != null) && (converter.convert(buf, f, precedence))) {
return;
}
}
convertAST(buf, f);
return;
}
if (o instanceof IInteger) {
convertInteger(buf, (IInteger) o, precedence);
return;
}
if (o instanceof IFraction) {
convertFraction(buf, (IFraction) o, precedence);
return;
}
if (o instanceof INum) {
convertDouble(buf, (INum) o, precedence);
return;
}
if (o instanceof IComplexNum) {
convertDoubleComplex(buf, (IComplexNum) o, precedence);
return;
}
if (o instanceof IComplex) {
convertComplex(buf, (IComplex) o, precedence);
return;
}
if (o instanceof ISymbol) {
convertSymbol(buf, (ISymbol) o);
return;
}
if (o instanceof BigFraction) {
convertFraction(buf, (BigFraction) o, precedence);
return;
}
convertString(buf, o.toString());
}
Aggregations