[BACK]Return to CMO_DISTRIBUTED_POLYNOMIAL.java CVS log [TXT][DIR] Up to [local] / OpenXM / src / OpenMath / ORG / openxm / tam

Annotation of OpenXM/src/OpenMath/ORG/openxm/tam/CMO_DISTRIBUTED_POLYNOMIAL.java, Revision 1.3

1.1       tam         1: /**
1.3     ! ohara       2:  * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/CMO_DISTRIBUTED_POLYNOMIAL.java,v 1.2 2000/09/13 06:32:42 tam Exp $
1.1       tam         3:  */
                      4: package ORG.openxm.tam;
                      5:
                      6: import java.io.*;
                      7:
                      8: /**
                      9:  * CMO $B7A<0$N(B distributed polynomial $B7?$rI=$7$^$9(B.
                     10:  */
                     11: final public class CMO_DISTRIBUTED_POLYNOMIAL extends CMO{
                     12:   private CMO ring;
                     13:   private CMO_MONOMIAL32[] monomials;
                     14:
                     15:   /**
                     16:    * $B4D(B ring $B>e$N(B MONOMIAL32 $B7?$NG[Ns(B monomials $B$r;}$DB?9`<0$r:n@.$7$^$9(B.
                     17:    */
                     18:   public CMO_DISTRIBUTED_POLYNOMIAL(CMO ring,CMO_MONOMIAL32[] monomials){
                     19:     this.ring = ring;
                     20:     this.monomials = monomials;
                     21:   }
                     22:
                     23:   public int DISCRIMINATOR(){
                     24:     return CMO.DISTRIBUTED_POLYNOMIAL;
                     25:   }
1.3     ! ohara      26:
        !            27:     public boolean allowQ (int[] datacap) {
        !            28:                if(CMO.allowQ_tag(datacap, DISCRIMINATOR())) {
        !            29:                        if (ring.allowQ(datacap)) {
        !            30:                                for (int j=0; j < monomials.length; j++) {
        !            31:                                        if (!monomials[j].allowQ(datacap)) {
        !            32:                                                return false;
        !            33:                                        }
        !            34:                                }
        !            35:                                return true;
        !            36:                        }
        !            37:         }
        !            38:         return false;
        !            39:     }
1.1       tam        40:
1.2       tam        41:   public void sendByObject(OpenXMstream os)
1.1       tam        42:        throws IOException,MathcapViolation{
                     43:     if(monomials.length == 0){
                     44:       os.writeInt(1);
                     45:       ring.write(os);
                     46:       new CMO_ZERO().write(os);
                     47:     }else{
                     48:       os.writeInt(monomials.length);
                     49:       ring.write(os);
                     50:       for(int i=0;i<monomials.length;i++){
                     51:        monomials[i].write(os);
                     52:       }
                     53:     }
                     54:   }
                     55:
1.2       tam        56:   static protected CMO receive(OpenXMstream is) throws IOException{
1.1       tam        57:     CMO ring;
                     58:     CMO_MONOMIAL32[] monomials;
                     59:     CMO tmp;
                     60:     int m;
                     61:
                     62:     m = is.readInt();
                     63:
                     64:     tmp = CMO.receive(is);
                     65:     if(!(tmp instanceof CMO_DMS_GENERIC)){
                     66:       System.err.println("not CMOobject");
                     67:     }
                     68:     ring = tmp;
                     69:
                     70:     tmp = (CMO_MONOMIAL32)CMO.receive(is);
                     71:     if(tmp instanceof CMO_ZERO && m == 1){
                     72:       monomials = new CMO_MONOMIAL32[0];
                     73:     }else{
                     74:       monomials = new CMO_MONOMIAL32[m];
                     75:       monomials[0] = (CMO_MONOMIAL32)tmp;
                     76:     }
                     77:
                     78:     for(int i=1;i<m;i++){
                     79:       monomials[i] = (CMO_MONOMIAL32)CMO.receive(is);
                     80:     }
                     81:
                     82:     return new CMO_DISTRIBUTED_POLYNOMIAL(ring,monomials);
                     83:   }
                     84:
                     85:   public String toCMOexpressionByObject(){
                     86:     String ret = "CMO_DISTRIBUTED_POLYNOMIAL,";
                     87:
                     88:     if(monomials.length == 0){
                     89:       ret += 1 +",";
                     90:       ret += ring.toCMOexpression();
                     91:       ret += ","+ new CMO_ZERO().toCMOexpression();
                     92:     }else{
                     93:       ret += monomials.length +",";
                     94:       ret += ring.toCMOexpression();
                     95:       for(int i=0;i<monomials.length;i++){
                     96:        ret += ","+ monomials[i].toCMOexpression();
                     97:       }
                     98:     }
                     99:
                    100:     return ret;
                    101:   }
                    102:
                    103:   /**
                    104:    * $BB?9`<0$,Dj5A$5$l$F$$$k4D$rF@$^$9(B.
                    105:    */
                    106:   public CMO getRing(){
                    107:     return ring;
                    108:   }
                    109:
                    110:   /**
                    111:    * $BB?9`<0$N3F(B monomial $B$rF@$^$9(B.
                    112:    */
                    113:   public CMO_MONOMIAL32[] getMonomials(){
                    114:     return monomials;
                    115:   }
                    116: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>