本文整理汇总了Java中edu.jas.poly.ExpVector.getVal方法的典型用法代码示例。如果您正苦于以下问题:Java ExpVector.getVal方法的具体用法?Java ExpVector.getVal怎么用?Java ExpVector.getVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.jas.poly.ExpVector
的用法示例。
在下文中一共展示了ExpVector.getVal方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shift
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Shift coefficients.
* @param k shift index.
* @param r variable for the direction.
* @return new power series with coefficient(i) = old.coefficient(i-k).
*/
public MultiVarPowerSeries<C> shift(final int k, final int r) {
if (r < 0 || ring.nvar < r) {
throw new IllegalArgumentException("variable index out of bound");
}
int nt = Math.min(truncate + k, ring.truncate);
return new MultiVarPowerSeries<C>(ring, new MultiVarCoefficients<C>(ring) {
@Override
public C generate(ExpVector i) {
long d = i.getVal(r);
if (d - k < 0) {
return ring.coFac.getZERO();
}
ExpVector e = i.subst(r, i.getVal(r) - k);
return coefficient(e);
}
}, nt);
}
示例2: differentiate
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Differentiate with respect to variable r.
* @param r variable for the direction.
* @return differentiate(this).
*/
public MultiVarPowerSeries<C> differentiate(final int r) {
if (r < 0 || ring.nvar < r) {
throw new IllegalArgumentException("variable index out of bound");
}
return new MultiVarPowerSeries<C>(ring, new MultiVarCoefficients<C>(ring) {
@Override
public C generate(ExpVector i) {
long d = i.getVal(r);
ExpVector e = i.subst(r, d + 1);
C v = coefficient(e);
v = v.multiply(ring.coFac.fromInteger(d + 1));
return v;
}
});
}
示例3: integrate
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Integrate with respect to variable r and with given constant.
* @param c integration constant.
* @param r variable for the direction.
* @return integrate(this).
*/
public MultiVarPowerSeries<C> integrate(final C c, final int r) {
if (r < 0 || ring.nvar < r) {
throw new IllegalArgumentException("variable index out of bound");
}
int nt = Math.min(ring.truncate, truncate + 1);
return new MultiVarPowerSeries<C>(ring, new MultiVarCoefficients<C>(ring) {
@Override
public C generate(ExpVector i) {
if (i.isZERO()) {
return c;
}
long d = i.getVal(r);
if (d > 0) {
ExpVector e = i.subst(r, d - 1);
C v = coefficient(e);
v = v.divide(ring.coFac.fromInteger(d));
return v;
}
return ring.coFac.getZERO();
}
}, nt);
}
示例4: deriviative
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Multi-partial deriviative.
* @param i exponent vector.
* @return partial deriviative of this with respect to all variables.
*/
public TaylorFunction<C> deriviative(ExpVector i) {
GenPolynomial<C> p = pol;
long f = 1L;
if (i.signum() == 0 || pol.isZERO()) {
return new PolynomialTaylorFunction<C>(p, f);
}
for (int j = 0; j < i.length(); j++) {
long e = i.getVal(j);
if (e == 0) {
continue;
}
int jl = i.length() - 1 - j;
for (long k = 0; k < e; k++) {
p = PolyUtil.<C> baseDeriviative(p, jl);
f *= (k + 1);
if (p.isZERO()) {
return new PolynomialTaylorFunction<C>(p, f);
}
}
}
//System.out.println("i = " + i + ", f = " + f + ", der = " + p);
return new PolynomialTaylorFunction<C>(p, f);
}
示例5: substituteKronecker
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Kronecker substitution. Substitute x_i by x**d**(i-1) to construct a
* univariate polynomial.
* @param A polynomial to be converted.
* @return a univariate polynomial.
*/
public static <C extends GcdRingElem<C>> GenPolynomial<C> substituteKronecker(GenPolynomial<C> A, long d) {
if (A == null) {
return A;
}
RingFactory<C> cfac = A.ring.coFac;
GenPolynomialRing<C> ufac = new GenPolynomialRing<C>(cfac, 1);
GenPolynomial<C> B = ufac.getZERO().copy();
if (A.isZERO()) {
return B;
}
for (Map.Entry<ExpVector, C> y : A.getMap().entrySet()) {
ExpVector e = y.getKey();
C a = y.getValue();
long f = 0L;
long h = 1L;
for (int i = 0; i < e.length(); i++) {
long j = e.getVal(i) * h;
f += j;
h *= d;
}
ExpVector g = ExpVector.create(1, 0, f);
B.doPutToMap(g, a);
}
return B;
}
示例6: factorDegrees
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* BitSet for factor degree list.
* @param E exponent vector list.
* @return b_0,...,b_k} a BitSet of possible factor degrees.
*/
public BitSet factorDegrees(List<ExpVector> E, int deg) {
BitSet D = new BitSet(deg + 1);
D.set(0); // constant factor
for (ExpVector e : E) {
int i = (int) e.getVal(0);
BitSet s = new BitSet(deg + 1);
for (int k = 0; k < deg + 1 - i; k++) { // shift by i places
s.set(i + k, D.get(k));
}
//System.out.println("s = " + s);
D.or(s);
//System.out.println("D = " + D);
}
return D;
}
示例7: generate
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
@Override
public BigRational generate(ExpVector i) {
int[] v = i.dependencyOnVariables();
if (v.length == 1 && i.getVal(v[0]) == 1L) {
return pfac.coFac.getONE();
}
return pfac.coFac.getZERO();
}
示例8: fromPowerSeries
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Get a MultiVarPowerSeries<C> from a univariate power series.
* @param ps UnivPowerSeries<C>.
* @param r variable for the direction.
* @return a MultiVarPowerSeries<C>.
*/
public MultiVarPowerSeries<C> fromPowerSeries(final UnivPowerSeries<C> ps, final int r) {
if (ps == null) {
return ZERO;
}
return new MultiVarPowerSeries<C>(this, new MultiVarCoefficients<C>(this) {
@Override
public C generate(ExpVector i) {
if (i.isZERO()) {
return ps.coefficient(0);
}
int[] dep = i.dependencyOnVariables();
if (dep.length != 1) {
return coFac.getZERO();
}
if (dep[0] != r) {
return coFac.getZERO();
}
int j = (int) i.getVal(r);
if (j > 0) {
return ps.coefficient(j);
}
return coFac.getZERO();
}
});
}
示例9: backSubstituteKronecker
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Kronecker back substitution. Substitute x**d**(i-1) to x_i to construct a
* multivariate polynomial.
* @param A polynomial to be converted.
* @param fac result polynomial factory.
* @return a multivariate polynomial.
*/
public static <C extends GcdRingElem<C>> GenPolynomial<C> backSubstituteKronecker(
GenPolynomialRing<C> fac, GenPolynomial<C> A, long d) {
if (A == null) {
return A;
}
if (fac == null) {
throw new IllegalArgumentException("null factory not allowed ");
}
int n = fac.nvar;
GenPolynomial<C> B = fac.getZERO().copy();
if (A.isZERO()) {
return B;
}
for (Map.Entry<ExpVector, C> y : A.getMap().entrySet()) {
ExpVector e = y.getKey();
C a = y.getValue();
long f = e.getVal(0);
ExpVector g = ExpVector.create(n);
for (int i = 0; i < n; i++) {
long j = f % d;
f /= d;
g = g.subst(i, j);
}
B.doPutToMap(g, a);
}
return B;
}
示例10: degreeSum
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Sum of all degrees.
* @param L univariate polynomial list.
* @return sum deg(p) for p in L.
*/
public static <C extends RingElem<C>> long degreeSum(List<GenPolynomial<C>> L) {
long s = 0L;
for (GenPolynomial<C> p : L) {
ExpVector e = p.leadingExpVector();
long d = e.getVal(0);
s += d;
}
return s;
}
示例11: solve
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Solve Integer Program for new right hand side. Uses the GB (matrix A and
* C) from the last calculation.
* @param B restrictions right hand side
* @return solution s, such that s*C -> minimal and A*s = B, or s = null
* if no solution exists
*/
public long[] solve(long[] B) {
long[] returnMe = new long[n];
if (B.length != m) {
System.out.println("ERROR: Dimensions don't match: " + B.length + " != " + m);
return returnMe;
}
long[] l;
this.B = Arrays.copyOf(B, B.length);
if (DEBUG) {
logger.debug("GB=" + GB);
}
if (negVars) {
l = new long[m + n + 1];
long min = findMin(B);
if (min < 0) {
long r = -min;
l[m + n] = r;
for (int i = 0; i < m; i++) {
l[m + n - 1 - i] = B[i] + r;
}
} else {
for (int i = 0; i < m; i++) {
l[m + n - 1 - i] = B[i];
}
}
} else {
l = new long[m + n];
for (int i = 0; i < m; i++) {
l[m + n - 1 - i] = B[i];
}
}
ExpVector e = new ExpVectorLong(l);
S = new GenPolynomial<BigInteger>(I.getRing(), e);
S = GB.normalform(S);
ExpVector E = S.exponentIterator().next();
for (int i = 0; i < n; i++) {
returnMe[n - 1 - i] = E.getVal(i);
}
success = true;
for (int i = n; i < n + m; i++) {
if (E.getVal(i) != 0) {
success = false;
break;
}
}
if (success) {
if (DEBUG) {
logger.debug("The solution is: " + Arrays.toString(returnMe));
}
} else {
logger.warn("The Problem does not have a feasible solution.");
returnMe = null;
}
return returnMe;
}
示例12: redTerms
import edu.jas.poly.ExpVector; //导入方法依赖的package包/类
/**
* Compute the residues to given polynomial list.
* @return List of reduced terms
*/
public List<GenPolynomial<C>> redTerms(List<GenPolynomial<C>> groebnerBasis) {
if (groebnerBasis == null || groebnerBasis.size() == 0) {
throw new IllegalArgumentException("groebnerBasis may not be null or empty");
}
GenPolynomialRing<C> ring = groebnerBasis.get(0).ring;
int numberOfVariables = ring.nvar; //Number of Variables of the given Polynomial Ring
long[] degrees = new long[numberOfVariables]; //Array for the degree-limits for the reduced terms
List<GenPolynomial<C>> terms = new ArrayList<GenPolynomial<C>>(); //Instantiate the return object
for (GenPolynomial<C> g : groebnerBasis) { //For each polynomial of G
if (g.isONE()) {
terms.clear();
return terms; //If 1 e G, return empty list terms
}
ExpVector e = g.leadingExpVector(); //Take the exponent of the leading monomial
if (e.totalDeg() == e.maxDeg()) { //and check, whether a variable x_i is isolated
for (int i = 0; i < numberOfVariables; i++) {
long exp = e.getVal(i);
if (exp > 0) {
degrees[i] = exp; //if true, add the degree of univariate x_i to array degrees
}
}
}
}
long max = maxArray(degrees); //Find maximum in Array degrees
for (int i = 0; i < degrees.length; i++) { //Set all zero grades to maximum of array "degrees"
if (degrees[i] == 0) {
logger.info("dimension not zero, setting degree to " + max);
degrees[i] = max; //--> to "make" the ideal zero-dimensional
}
}
terms.add(ring.ONE); //Add the one-polynomial of the ring to the list of reduced terms
ReductionSeq<C> s = new ReductionSeq<C>(); //Create instance of ReductionSeq to use method isReducible
//Main Algorithm
for (int i = 0; i < numberOfVariables; i++) {
GenPolynomial<C> x = ring.univariate(i); //Create Linear Polynomial X_i
List<GenPolynomial<C>> S = new ArrayList<GenPolynomial<C>>(terms); //Copy all entries of return list "terms" into list "S"
for (GenPolynomial<C> t : S) {
for (int l = 1; l <= degrees[i]; l++) {
t = t.multiply(x); //Multiply current element t with Linear Polynomial X_i
if (!s.isReducible(groebnerBasis, t)) { //Check, if t is irreducible mod groebnerbase
terms.add(t); //Add t to return list terms
}
}
}
}
return terms;
}