Annotation of OpenXM/src/OpenMath/ORG/openxm/tam/CMO_POLYNOMIAL_IN_ONE_VARIABLE.java, Revision 1.2
1.1 tam 1: /**
1.2 ! tam 2: * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/CMO_POLYNOMIAL_IN_ONE_VARIABLE.java,v 1.1 2000/09/12 07:05:06 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: }
50:
1.2 ! tam 51: protected void sendByObject(OpenXMstream os)
1.1 tam 52: throws IOException,MathcapViolation{
53: int m = degrees.length;
54:
55: new CMO_INT32(m).write(os);
56: new CMO_INT32(variable).write(os);
57: for(int i=0;i<m;i++){
58: new CMO_INT32(degrees[i]).write(os);
59: coefficients[i].write(os);
60: }
61: }
62:
1.2 ! tam 63: static protected CMO receive(OpenXMstream is) throws IOException{
1.1 tam 64: int variable;
65: int[] degrees;
66: CMO[] coefficients;
67: int m;
68:
69: m = is.readInt();
70: variable = is.readInt();
71:
72: degrees = new int[m];
73: coefficients = new CMO[m];
74: for(int i=0;i<m;i++){
75: degrees[i] = is.readInt();
76: coefficients[i] = CMO.receive(is);
77: }
78:
79: return new CMO_POLYNOMIAL_IN_ONE_VARIABLE(variable,degrees,coefficients);
80: }
81:
82: protected String toCMOexpressionByObject(){
83: String ret;
84:
85: ret = "CMO_POLYNOMIAL_IN_ONE_VARIABLE,"+ degrees.length +","+ variable;
86: for(int i=0;i<degrees.length;i++){
87: ret += ","+ degrees[i];
88: ret += ","+ coefficients[i].toCMOexpression();
89: }
90: return ret;
91: }
92: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>