本文整理汇总了Java中edu.jas.poly.Monomial.coefficient方法的典型用法代码示例。如果您正苦于以下问题:Java Monomial.coefficient方法的具体用法?Java Monomial.coefficient怎么用?Java Monomial.coefficient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.jas.poly.Monomial
的用法示例。
在下文中一共展示了Monomial.coefficient方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bitHeight
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Method bitHeight returns the bitlength of the greatest number occurring
* during the computation of a Groebner base.
*/
public int bitHeight(List<GenPolynomial<BigRational>> list) {
BigInteger denom = BigInteger.ONE;
BigInteger num = BigInteger.ONE;
for (GenPolynomial<BigRational> g : list) {
for (Monomial<BigRational> m : g) {
BigRational bi = m.coefficient();
BigInteger i = bi.denominator().abs();
BigInteger j = bi.numerator().abs();
if (i.compareTo(denom) > 0)
denom = i;
if (j.compareTo(num) > 0)
num = j;
}
}
int erg;
if (denom.compareTo(num) > 0) {
erg = denom.bitLength();
} else {
erg = num.bitLength();
}
return erg;
}
示例2: monomialListModulus
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Get the monomial list of a univariate polynomial with coefficients reduced by a modulo value.
*
* @param polynomial
* @param variable
* @param termOrder
* the JAS term ordering
* @param option
* the "Modulus" option
* @return the list of monomials of the univariate polynomial.
*/
private static IAST monomialListModulus(IExpr polynomial, List<IExpr> variablesList, final TermOrder termOrder,
IExpr option) throws JASConversionException {
try {
// found "Modulus" option => use ModIntegerRing
ModLongRing modIntegerRing = JASModInteger.option2ModLongRing((ISignedNumber) option);
JASModInteger jas = new JASModInteger(variablesList, modIntegerRing);
GenPolynomial<ModLong> polyExpr = jas.expr2JAS(polynomial);
IASTAppendable list = F.ListAlloc(polyExpr.length());
for (Monomial<ModLong> monomial : polyExpr) {
ModLong coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
IASTAppendable monomTimes = F.TimesAlloc(exp.length() + 1);
jas.monomialToExpr(F.integer(coeff.getVal()), exp, monomTimes);
list.append(monomTimes);
}
return list;
} catch (ArithmeticException ae) {
// toInt() conversion failed
if (Config.DEBUG) {
ae.printStackTrace();
}
}
return F.NIL;
}
示例3: isQuadratic
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Check if the polynomial has maximum degree 2 in 1 variable and return the coefficients.
*
* @param poly
* @return <code>false</code> if the polynomials degree > 2 and number of variables <> 1
*/
public static boolean isQuadratic(GenPolynomial<BigRational> poly, BigRational[] result) {
if (poly.degree() <= 2 && poly.numberOfVariables() == 1) {
result[0] = BigRational.ZERO;
result[1] = BigRational.ZERO;
result[2] = BigRational.ZERO;
for (Monomial<BigRational> monomial : poly) {
BigRational coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
for (int i = 0; i < exp.length(); i++) {
result[(int) exp.getVal(i)] = coeff;
}
}
return true;
}
return false;
}
示例4: isQuadratic
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Check if the polynomial has maximum degree 2 in 1 variable and return the
* coefficients.
*
* @param poly
* @return <code>null</code> if the polynomials degree > 2 and number of
* variables <> 1
*/
public static boolean isQuadratic(GenPolynomial<BigRational> poly, BigRational[] result) {
if (poly.degree() <= 2 && poly.numberOfVariables() == 1) {
result[0] = BigRational.ZERO;
result[1] = BigRational.ZERO;
result[2] = BigRational.ZERO;
for (Monomial<BigRational> monomial : poly) {
BigRational coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
for (int i = 0; i < exp.length(); i++) {
result[(int) exp.getVal(i)] = coeff;
}
}
return true;
}
return false;
}
示例5: integerPoly2Expr
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Convert a JAS integer polynomial to <code>IExpr</code>.
*
* @param poly
* @return
* @throws ArithmeticException
* @throws ClassCastException
*/
public IExpr integerPoly2Expr(final GenPolynomial<edu.jas.arith.BigInteger> poly)
throws ArithmeticException, ClassCastException {
if (poly.length() == 0) {
return F.C0;
}
IASTAppendable result = F.PlusAlloc(poly.length());
for (Monomial<edu.jas.arith.BigInteger> monomial : poly) {
edu.jas.arith.BigInteger coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
IASTAppendable monomTimes = F.TimesAlloc(exp.length()+1);
monomialToExpr(coeff, exp, monomTimes);
result.append(monomTimes.getOneIdentity(F.C1));
}
return result.getOneIdentity(F.C0);
}
示例6: complexPoly2Expr
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Convert a JAS complex polynomial to <code>IExpr</code>.
*
* @param poly
* @return
* @throws ArithmeticException
* @throws ClassCastException
*/
public IExpr complexPoly2Expr(final GenPolynomial<Complex<BigRational>> poly)
throws ArithmeticException, ClassCastException {
if (poly.length() == 0) {
return F.C0;
}
IASTAppendable result = F.PlusAlloc(poly.length());
for (Monomial<Complex<BigRational>> monomial : poly) {
Complex<BigRational> coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
IASTAppendable monomTimes = F.TimesAlloc(exp.length()+1);
monomialToExpr(coeff, exp, monomTimes);
result.append(monomTimes.getOneIdentity(F.C1));
}
return result.getOneIdentity(F.C0);
}
示例7: rationalPoly2Expr
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Converts a <a href="http://krum.rz.uni-mannheim.de/jas/">JAS</a>
* polynomial to a MathEclipse AST with head <code>Plus</code>
*
* @param poly
* a JAS polynomial
* @param variable
* @return
* @throws ArithmeticException
* @throws ClassCastException
*/
public IAST rationalPoly2Expr(final GenPolynomial<BigRational> poly)
throws ArithmeticException, ClassCastException {
if (poly.length() == 0) {
return F.Plus(F.C0);
}
IASTAppendable result = F.PlusAlloc(poly.length());
for (Monomial<BigRational> monomial : poly) {
BigRational coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
IASTAppendable monomTimes = F.TimesAlloc(exp.length()+1);
monomialToExpr(coeff, exp, monomTimes);
result.append(monomTimes.getOneIdentity(F.C1));
}
return result;
}
示例8: exprPoly2Expr
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Converts a <a href="http://krum.rz.uni-mannheim.de/jas/">JAS</a> polynomial to a MathEclipse AST with head
* <code>Plus</code>
*
* @param poly
* a JAS polynomial
* @param variable
* @return
* @throws ArithmeticException
* @throws ClassCastException
*/
public IExpr exprPoly2Expr(final GenPolynomial<IExpr> poly, IExpr variable) {
if (poly.length() == 0) {
return F.C0;
}
IASTAppendable result = F.PlusAlloc(poly.length());
for (Monomial<IExpr> monomial : poly) {
IExpr coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
IASTAppendable monomTimes = F.TimesAlloc(exp.length() + 1);
monomialToExpr(coeff, exp, monomTimes);
result.append(monomTimes.getOneIdentity(F.C1));
}
return result.getOneIdentity(F.C0);
}
示例9: coefficientRules
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Get exponent vectors and coefficients of monomials of a polynomial expression.
*
* @param polynomial
* @param variable
* @param termOrder
* the JAS term ordering
* @return the list of monomials of the univariate polynomial.
*/
public static IAST coefficientRules(IExpr polynomial, final List<IExpr> variablesList,
final TermOrder termOrder) throws JASConversionException {
JASIExpr jas = new JASIExpr(variablesList, ExprRingFactory.CONST, termOrder, false);
GenPolynomial<IExpr> polyExpr = jas.expr2IExprJAS(polynomial);
IASTAppendable resultList = F.ListAlloc(polyExpr.length());
for (Monomial<IExpr> monomial : polyExpr) {
IExpr coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
int len = exp.length();
IASTAppendable ruleList = F.ListAlloc(len);
for (int i = 0; i < len; i++) {
ruleList.append(F.integer(exp.getVal(len - i - 1)));
}
resultList.append(F.Rule(ruleList, coeff));
}
return resultList;
}
示例10: complexPoly2Expr
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Convert a JAS complex polynomial to <code>IExpr</code>.
*
* @param poly
* @return
* @throws ArithmeticException
* @throws ClassCastException
*/
public IExpr complexPoly2Expr(final GenPolynomial<Complex<BigRational>> poly)
throws ArithmeticException, ClassCastException {
if (poly.length() == 0) {
return F.C0;
}
IASTAppendable result = F.PlusAlloc(poly.length());
for (Monomial<Complex<BigRational>> monomial : poly) {
Complex<BigRational> coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
BigRational re = coeff.getRe();
BigRational im = coeff.getIm();
IASTAppendable monomTimes = F.Times(F.complex(F.fraction(re.numerator(), re.denominator()),
F.fraction(im.numerator(), im.denominator())));
long lExp;
for (int i = 0; i < exp.length(); i++) {
lExp = exp.getVal(i);
if (lExp != 0) {
monomTimes.append(F.Power(fVariables.get(i), F.integer(lExp)));
}
}
if (monomTimes.isAST1()) {
result.append(monomTimes.arg1());
} else {
result.append(monomTimes);
}
}
if (result.isAST1()) {
return result.arg1();
} else {
return result;
}
}
示例11: integerPoly2Expr
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Convert a JAS integer polynomial to <code>IExpr</code>.
*
* @param poly
* @return
* @throws ArithmeticException
* @throws ClassCastException
*/
public IExpr integerPoly2Expr(final GenPolynomial<edu.jas.arith.BigInteger> poly)
throws ArithmeticException, ClassCastException {
if (poly.length() == 0) {
return F.C0;
}
IASTAppendable result = F.PlusAlloc(poly.length());
for (Monomial<edu.jas.arith.BigInteger> monomial : poly) {
edu.jas.arith.BigInteger coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
IInteger coeffValue = F.integer(coeff.getVal());
IASTAppendable monomTimes = F.TimesAlloc(exp.length() + 1);
monomTimes.append(coeffValue);
long lExp;
for (int i = 0; i < exp.length(); i++) {
lExp = exp.getVal(i);
if (lExp != 0) {
monomTimes.append(F.Power(fVariables.get(i), F.integer(lExp)));
}
}
if (monomTimes.isAST1()) {
result.append(monomTimes.arg1());
} else {
result.append(monomTimes);
}
}
if (result.isAST1()) {
return result.arg1();
} else {
return result;
}
}
示例12: modLongPoly2Expr
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
public IExpr modLongPoly2Expr(final GenPolynomial<ModLong> poly) throws ArithmeticException, ClassCastException {
if (poly.length() == 0) {
return F.Plus(F.C0);
}
IASTAppendable result = F.PlusAlloc(poly.length());
for (Monomial<ModLong> monomial : poly) {
ModLong coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
IInteger coeffValue = F.integer(coeff.getVal());
IASTAppendable monomTimes = F.TimesAlloc(exp.length() + 1);
monomialToExpr(coeffValue, exp, monomTimes);
result.append(monomTimes.getOneIdentity(F.C1));
}
return result.getOneIdentity(F.C0);
}
示例13: coefficientRulesModulus
import edu.jas.poly.Monomial; //导入方法依赖的package包/类
/**
* Get exponent vectors and coefficients of monomials of a polynomial expression.
*
* @param polynomial
* @param variable
* @param termOrder
* the JAS term ordering
* @param option
* the "Modulus" option
* @return the list of monomials of the univariate polynomial.
*/
private static IAST coefficientRulesModulus(IExpr polynomial, List<IExpr> variablesList,
final TermOrder termOrder, IExpr option) throws JASConversionException {
try {
// found "Modulus" option => use ModIntegerRing
ModLongRing modIntegerRing = JASModInteger.option2ModLongRing((ISignedNumber) option);
JASModInteger jas = new JASModInteger(variablesList, modIntegerRing);
GenPolynomial<ModLong> polyExpr = jas.expr2JAS(polynomial);
IASTAppendable resultList = F.ListAlloc(polyExpr.length());
for (Monomial<ModLong> monomial : polyExpr) {
ModLong coeff = monomial.coefficient();
ExpVector exp = monomial.exponent();
int len = exp.length();
IASTAppendable ruleList = F.ListAlloc(len);
for (int i = 0; i < len; i++) {
ruleList.append(F.integer(exp.getVal(len - i - 1)));
}
resultList.append(F.Rule(ruleList, F.integer(coeff.getVal())));
}
return resultList;
} catch (ArithmeticException ae) {
// toInt() conversion failed
if (Config.DEBUG) {
ae.printStackTrace();
}
}
return null;
}