Annotation of OpenXM/src/OpenMath/ORG/openxm/tam/CMO_POLYNOMIAL_IN_ONE_VARIABLE.java, Revision 1.3
1.1 tam 1: /**
1.3 ! ohara 2: * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/CMO_POLYNOMIAL_IN_ONE_VARIABLE.java,v 1.2 2000/09/13 06:32:43 tam Exp $
1.1 tam 3: */
4: package ORG.openxm.tam;
5:
6: import java.io.*;
7:
8: /**
9: * CMO $B7A<0$N(B POLYNOMIAL IN ONE VARIABLE $B7?$rI=$7$^$9(B.
10: */
11: final public class CMO_POLYNOMIAL_IN_ONE_VARIABLE extends CMO{
12: private int variable;
13: private int[] degrees;
14: private CMO[] coefficients;
15:
16: /**
17: * $B78?t(B coefficients[], $B<!?t(B degrees[], variable $BHVL\$NJQ?t$NB?9`<0$rI=$7$^$9(B.
18: * $B%;%^%s%F%#%C%/%9$N%A%'%C%/$O9T$J$o$l$^$;$s(B.
19: */
20: public CMO_POLYNOMIAL_IN_ONE_VARIABLE(int variable,int[] degrees,CMO[] coefficients){
21: this.variable = variable;
22: this.degrees = degrees;
23: this.coefficients = coefficients;
24: }
25:
26: /**
27: * $B2?HVL\$NJQ?t$J$N$+$rF@$^$9(B.
28: */
29: public int getVariable(){
30: return variable;
31: }
32:
33: /**
34: * $B<!?t$rI=$9G[Ns$rF@$^$9(B.
35: */
36: public int[] getDegrees(){
37: return degrees;
38: }
39:
40: /**
41: * $B78?t$rI=$9G[Ns$rF@$^$9(B.
42: */
43: public CMO[] getCoefficients(){
44: return coefficients;
45: }
46:
47: public int DISCRIMINATOR(){
48: return CMO.POLYNOMIAL_IN_ONE_VARIABLE;
49: }
1.3 ! ohara 50:
! 51: public boolean allowQ (int[] datacap) {
! 52: if(CMO.allowQ_tag(datacap, DISCRIMINATOR())) {
! 53: for (int j=0; j < coefficients.length; j++) {
! 54: if (!coefficients[j].allowQ(datacap)) {
! 55: return false;
! 56: }
! 57: }
! 58: return true;
! 59: }
! 60: return false;
! 61: }
1.1 tam 62:
1.2 tam 63: protected void sendByObject(OpenXMstream os)
1.1 tam 64: throws IOException,MathcapViolation{
65: int m = degrees.length;
66:
67: new CMO_INT32(m).write(os);
68: new CMO_INT32(variable).write(os);
69: for(int i=0;i<m;i++){
70: new CMO_INT32(degrees[i]).write(os);
71: coefficients[i].write(os);
72: }
73: }
74:
1.2 tam 75: static protected CMO receive(OpenXMstream is) throws IOException{
1.1 tam 76: int variable;
77: int[] degrees;
78: CMO[] coefficients;
79: int m;
80:
81: m = is.readInt();
82: variable = is.readInt();
83:
84: degrees = new int[m];
85: coefficients = new CMO[m];
86: for(int i=0;i<m;i++){
87: degrees[i] = is.readInt();
88: coefficients[i] = CMO.receive(is);
89: }
90:
91: return new CMO_POLYNOMIAL_IN_ONE_VARIABLE(variable,degrees,coefficients);
92: }
93:
94: protected String toCMOexpressionByObject(){
95: String ret;
96:
97: ret = "CMO_POLYNOMIAL_IN_ONE_VARIABLE,"+ degrees.length +","+ variable;
98: for(int i=0;i<degrees.length;i++){
99: ret += ","+ degrees[i];
100: ret += ","+ coefficients[i].toCMOexpression();
101: }
102: return ret;
103: }
104: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>