Search in sources :

Example 6 with IASTAppendable

use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.

the class AbstractIntegerSym method factorInteger.

/**
 * {@inheritDoc}
 */
@Override
public IASTAppendable factorInteger() {
    IInteger factor;
    IInteger last = F.CN2;
    int count = 0;
    final IAST iFactors = factorize();
    IASTAppendable subList = null;
    int size = iFactors.size();
    final IASTAppendable list = F.ListAlloc(size);
    for (int i = 1; i < size; i++) {
        factor = (IInteger) iFactors.get(i);
        if (!last.equals(factor)) {
            if (subList != null) {
                subList.append(AbstractIntegerSym.valueOf(count));
                list.append(subList);
            }
            count = 0;
            subList = F.ListAlloc(2);
            subList.append(factor);
        }
        count++;
        last = factor;
    }
    if (subList != null) {
        subList.append(AbstractIntegerSym.valueOf(count));
        list.append(subList);
    }
    return list;
}
Also used : IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable) IInteger(org.matheclipse.core.interfaces.IInteger) IAST(org.matheclipse.core.interfaces.IAST)

Example 7 with IASTAppendable

use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.

the class AbstractIntegerSym method divisors.

@Override
public IAST divisors() {
    if (isOne() || isMinusOne()) {
        return F.CListC1;
    }
    Set<IInteger> set = divisorsSet();
    final IASTAppendable resultList = F.ListAlloc(set.size() + 1);
    for (IInteger divisor : set) {
        resultList.append(divisor);
    }
    return resultList;
}
Also used : IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable) IInteger(org.matheclipse.core.interfaces.IInteger)

Example 8 with IASTAppendable

use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.

the class ASTSeriesData method arg3.

@Override
public final IAST arg3() {
    int capacity = nMax - nMin;
    if (capacity <= 0) {
        capacity = 4;
    }
    IASTAppendable list = F.ListAlloc(capacity);
    for (int i = nMin; i < nMax; i++) {
        list.append(coefficient(i));
    }
    return list;
}
Also used : IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable)

Example 9 with IASTAppendable

use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.

the class ASTSeriesData method toSeriesData.

public IAST toSeriesData() {
    // list of coefficients
    IASTAppendable coefficientList = F.ListAlloc(16);
    for (int i = nMin; i < nMax; i++) {
        coefficientList.append(coefficient(i));
    }
    IAST seriesData = F.SeriesData(x, x0, coefficientList, F.ZZ(nMin), F.ZZ(truncate), F.ZZ(denominator));
    return seriesData;
}
Also used : IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable) IAST(org.matheclipse.core.interfaces.IAST)

Example 10 with IASTAppendable

use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.

the class AbstractAST method removeIf.

/**
 * {@inheritDoc}
 */
@Override
public IAST removeIf(Predicate<? super IExpr> predicate) {
    IASTAppendable result = F.NIL;
    for (int i = 1; i < size(); i++) {
        final IExpr arg = get(i);
        if (predicate.test(arg)) {
            continue;
        }
        if (!result.isPresent()) {
            result = copyHead(argSize());
        }
        result.appendRule(arg);
    }
    return result.orElse(this);
}
Also used : IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable) IExpr(org.matheclipse.core.interfaces.IExpr)

Aggregations

IASTAppendable (org.matheclipse.core.interfaces.IASTAppendable)363 IExpr (org.matheclipse.core.interfaces.IExpr)219 IAST (org.matheclipse.core.interfaces.IAST)130 ISymbol (org.matheclipse.core.interfaces.ISymbol)36 IASTMutable (org.matheclipse.core.interfaces.IASTMutable)30 IInteger (org.matheclipse.core.interfaces.IInteger)29 Map (java.util.Map)28 EvalEngine (org.matheclipse.core.eval.EvalEngine)20 PrettyPrint (edu.jas.kern.PrettyPrint)13 SortedMap (java.util.SortedMap)13 ArrayList (java.util.ArrayList)12 F (org.matheclipse.core.expression.F)12 BigRational (edu.jas.arith.BigRational)10 LogManager (org.apache.logging.log4j.LogManager)10 Logger (org.apache.logging.log4j.Logger)10 ExpVector (edu.jas.poly.ExpVector)9 HashMap (java.util.HashMap)9 IBuiltInSymbol (org.matheclipse.core.interfaces.IBuiltInSymbol)8 IStringX (org.matheclipse.core.interfaces.IStringX)8 ASTNode (org.matheclipse.parser.client.ast.ASTNode)8