/*
* $Id$
*/
package edu.jas.integrate;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import edu.jas.poly.GenPolynomial;
import edu.jas.structure.GcdRingElem;
/**
* Container for a rational function integral, polynomial version.
* integral(num/den) = pol + sum_rat( rat_i/rat_{i+1} ) + sum_log( a_i log ( d_i
* ) )
* @author Heinz Kredel
* @param coefficient type
*/
public class Integral> implements Serializable {
/**
* Original numerator polynomial with coefficients from C.
*/
public final GenPolynomial num;
/**
* Original denominator polynomial with coefficients from C.
*/
public final GenPolynomial den;
/**
* Integral of the polynomial part.
*/
public final GenPolynomial pol;
/**
* Integral of the rational part.
*/
public final List> rational;
/**
* Integral of the logarithmic part.
*/
public final List> logarithm;
/**
* Constructor.
* @param n numerator GenPolynomial over C.
* @param d denominator GenPolynomial over C.
* @param p integral of polynomial part. n/d =
*/
public Integral(GenPolynomial n, GenPolynomial d, GenPolynomial p) {
this(n, d, p, new ArrayList>());
}
/**
* Constructor.
* @param n numerator GenPolynomial over C.
* @param d denominator GenPolynomial over C.
* @param p integral of polynomial part.
* @param rat list of rational integrals. n/d =
*/
public Integral(GenPolynomial n, GenPolynomial d, GenPolynomial p, List> rat) {
this(n, d, p, rat, new ArrayList>());
}
/**
* Constructor.
* @param n numerator GenPolynomial over C.
* @param d denominator GenPolynomial over C.
* @param p integral of polynomial part.
* @param rat list of rational integrals.
* @param log list of logarithmic part. n/d =
*/
public Integral(GenPolynomial n, GenPolynomial d, GenPolynomial p, List> rat,
List> log) {
num = n;
den = d;
pol = p;
rational = rat;
logarithm = log;
}
/**
* Get the String representation.
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("integral( (" + num.toString());
sb.append(") / (");
sb.append(den.toString() + ") )");
sb.append(" =\n");
if (!pol.isZERO()) {
sb.append(pol.toString());
}
boolean first = true;
if (rational.size() != 0) {
if (!pol.isZERO()) {
sb.append(" + ");
}
for (int i = 0; i < rational.size(); i++) {
if (first) {
first = false;
} else {
sb.append(" + ");
}
sb.append("(" + rational.get(i++) + ")/(");
sb.append(rational.get(i) + ")");
}
}
if (logarithm.size() != 0) {
if (!pol.isZERO() || rational.size() != 0) {
sb.append(" + ");
}
first = true;
for (LogIntegral pf : logarithm) {
if (first) {
first = false;
} else {
sb.append(" + ");
}
sb.append(pf);
}
sb.append("\n");
}
return sb.toString();
}
/**
* Hash code for Integral.
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int h = num.hashCode();
h = h * 37 + den.hashCode();
h = h * 37 + pol.hashCode();
h = h * 37 + rational.hashCode();
h = h * 37 + logarithm.hashCode();
return h;
}
/**
* Comparison with any other object.
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@SuppressWarnings("unchecked")
public boolean equals(Object B) {
Integral b = null;
try {
b = (Integral) B;
} catch (ClassCastException ignored) {
}
if (b == null) {
return false;
}
return num.equals(b.num) &&
den.equals(b.den) &&
pol.equals(b.pol) &&
rational.equals(b.rational) &&
logarithm.equals(b.logarithm);
}
}
Ads help maintain this website.