default IInteger div(final int that) { if (that == 1) { return this; } return div(F.ZZ(that)); }
default IInteger mod(final int that) { if (that == 1) { return F.C0; } return mod(F.ZZ(that)); }
private IASTAppendable createIndexes(int[] indx) { IASTAppendable list = F.ListAlloc(indx.length); for (int i = 0; i < indx.length; i++) { list.append(F.ZZ(indx[i])); } return list; }
@Override public IExpr visit(ISymbol element) { for (int i = 1; i < astSlots.size(); i++) { if (astSlots.get(i).equals(element)) { return F.Slot(F.ZZ(i)); } } return F.NIL; }
public static IAST Times(final long num, final IExpr... a) { IASTAppendable ast = ast(Times, a.length + 1, false); ast.append(ZZ(num)); ast.appendAll(a, 0, a.length); return ast; }
public static IAST Plus(final long num, final IExpr... a) { IASTAppendable ast = ast(Plus, a.length + 1, false); ast.append(ZZ(num)); ast.appendAll(a, 0, a.length); return ast; }
@Override public IExpr evaluateArg1(final IExpr arg1) { if (arg1.isInteger() && arg1.isPositive()) { int n = ((IInteger) arg1).toIntDefault(Integer.MIN_VALUE); if (n > 0) { if (n > NumberTheory.MPE_45.length) { return F.NIL; } return F.ZZ(NumberTheory.MPE_45[n - 1]); } } return F.NIL; }
public static IExpr flatTopWindow(IExpr x) { return // [$ Piecewise({{(215578947 + 416631580*Cos(2*Pi*x) + 277263158*Cos(4*Pi*x) + 83578947*Cos(6*Pi*x) + // 6947368*Cos(8*Pi*x))/1000000000, -(1/2) <= x <= 1/2}}, 0) $] F.Piecewise(F.List(F.List( F.Times(F.QQ(1L, 1000000000L), F.Plus(F.ZZ(215578947L), F.Times(F.ZZ(416631580L), F.Cos(F.Times(F.C2, F.Pi, x))), F.Times(F.ZZ(277263158L), F.Cos(F.Times(F.C4, F.Pi, x))), F.Times(F.ZZ(83578947L), F.Cos(F.Times(F.C6, F.Pi, x))), F.Times(F.ZZ(6947368L), F.Cos(F.Times(F.C8, F.Pi, x))))), F.LessEqual(F.CN1D2, x, F.C1D2))), F.C0); // $$; }
public static IExpr nuttallWindow(IExpr x) { return // [$ Piecewise[{{(88942 + 121849*Cos(2*Pi*x) + 36058*Cos(4*Pi*x) + 3151*Cos(6*Pi*x))/250000, -(1/2) <= x <= // 1/2}}, 0] $] F.Piecewise(F.List(F.List( F.Times(F.QQ(1L, 250000L), F.Plus(F.ZZ(88942L), F.Times(F.ZZ(121849L), F.Cos(F.Times(F.C2, F.Pi, x))), F.Times(F.ZZ(36058L), F.Cos(F.Times(F.C4, F.Pi, x))), F.Times(F.ZZ(3151L), F.Cos(F.Times(F.C6, F.Pi, x))))), F.LessEqual(F.CN1D2, x, F.C1D2))), F.C0); // $$; }
public static IExpr blackmanHarrisWindow(IExpr x) { return // [$ Piecewise({{(35875 + 48829*Cos(2*Pi*x) + 14128*Cos(4*Pi*x) + 1168*Cos(6*Pi*x))/100000, -(1/2) <= x <= // 1/2}}, 0) // $] F.Piecewise(F.List(F.List( F.Times(F.QQ(1L, 100000L), F.Plus(F.ZZ(35875L), F.Times(F.ZZ(48829L), F.Cos(F.Times(F.C2, F.Pi, x))), F.Times(F.ZZ(14128L), F.Cos(F.Times(F.C4, F.Pi, x))), F.Times(F.ZZ(1168L), F.Cos(F.Times(F.C6, F.Pi, x))))), F.LessEqual(F.CN1D2, x, F.C1D2))), F.C0); // $$; }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkSize(ast, 2); BigInteger[] array = Validate.checkListOfBigIntegers(ast.arg1(), true); BigInteger result = org.matheclipse.core.frobenius.FrobeniusNumber.frobeniusNumber(array); return F.ZZ(result); }
public static IExpr blackmanNuttallWindow(IExpr x) { return // [$ Piecewise({{(4891775*Cos(2*Pi*x) + 1365995*Cos(4*Pi*x) + 106411*Cos(6*Pi*x) + 3635819)/10000000, -(1/2) <= // x // <= 1/2}}, 0) // $] F.Piecewise(F.List(F.List( F.Times(F.QQ(1L, 10000000L), F.Plus(F.Times(F.ZZ(4891775L), F.Cos(F.Times(F.C2, F.Pi, x))), F.Times(F.ZZ(1365995L), F.Cos(F.Times(F.C4, F.Pi, x))), F.Times(F.ZZ(106411L), F.Cos(F.Times(F.C6, F.Pi, x))), F.ZZ(3635819L))), F.LessEqual(F.CN1D2, x, F.C1D2))), F.C0); // $$; }
@Override public IExpr randomVariate(Random random, IAST dist) { if (dist.isAST1()) { double p = dist.arg1().evalDouble(); if (0 <= p && p <= 1) { return F.ZZ(new BinomialGenerator(1, p, random).nextValue()); } } return F.NIL; }
@Override public IExpr randomVariate(Random random, IAST dist) { if (dist.isAST1()) { double mean = dist.arg1().evalDouble(); return F.ZZ(new PoissonGenerator(mean, random).nextValue()); } return F.NIL; } }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkSize(ast, 2); if (ast.arg1().isList()) { IAST list = (IAST) ast.arg1(); List<Integer> intList = LinearAlgebra.dimensions((IAST) ast.arg1(), list.head(), Integer.MAX_VALUE); return F.ZZ(intList.size()); } return F.NIL; }
@Override public IExpr randomVariate(Random random, IAST dist) { IExpr[] minMax = minmax(dist); if (minMax != null) { int min = minMax[0].toIntDefault(Integer.MIN_VALUE); int max = minMax[1].toIntDefault(Integer.MIN_VALUE); if (min < max && min != Integer.MIN_VALUE) { return F.ZZ(new DiscreteUniformGenerator(min, max, random).nextValue()); } } return F.NIL; } }
private static IExpr termPartitionsQ1(EvalEngine engine, IInteger n, int k) { // DivisorSigma(1, k)*PartitionsQ(n - k) IInteger k2 = F.ZZ(k); return engine.evaluate(Times(F.DivisorSigma(C1, k2), F.PartitionsQ(Plus(Negate(k2), n)))); }
private static IExpr termPartitionsQ2(EvalEngine engine, IInteger n, int k) { // DivisorSigma(1, k)*PartitionsQ(n - 2*k) IInteger k2 = F.ZZ(k); return engine.evaluate(Times(F.DivisorSigma(C1, k2), F.PartitionsQ(Plus(Times(F.CN2, k2), n)))); }
public static IExpr blackmanWindow(IExpr x) { return // [$ Piecewise({{(1/50)*(21 + 25*Cos(2*Pi*x) + 4*Cos(4*Pi*x)), -(1/2) <= x <= 1/2}}, 0) $] F.Piecewise( F.List(F.List( F.Times(F.QQ(1L, 50L), F.Plus(F.ZZ(21L), F.Times(F.ZZ(25L), F.Cos(F.Times(F.C2, F.Pi, x))), F.Times(F.C4, F.Cos(F.Times(F.C4, F.Pi, x))))), F.LessEqual(F.CN1D2, x, F.C1D2))), F.C0); // $$; }
public static IExpr gaussianWindow(IExpr x) { return // [$ Piecewise({{E^(-((50*x^2)/9)), -(1/2) <= x <= 1/2}}, 0) $] F.Piecewise(F.List( F.List(F.Exp(F.Times(F.CN1, F.QQ(1L, 9L), F.ZZ(50L), F.Sqr(x))), F.LessEqual(F.CN1D2, x, F.C1D2))), F.C0); // $$; }