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

File: [local] / OpenXM / src / OpenMath / ORG / openxm / tam / CMO_MONOMIAL32.java (download)

Revision 1.3, Sun Dec 3 12:40:40 2000 UTC (23 years, 7 months ago) by ohara
Branch: MAIN
CVS Tags: R_1_3_1-2, RELEASE_1_3_1_13b, RELEASE_1_2_3_12, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, KNOPPIX_2006, HEAD, DEB_REL_1_2_3-9
Changes since 1.2: +6 -1 lines

allowQ() methods are added.

In order to prevent a MathcapViolation,
we must inspect a CMObject by allowQ() before sending it to OXstream.

/**
 * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/CMO_MONOMIAL32.java,v 1.3 2000/12/03 12:40:40 ohara Exp $
 */
package ORG.openxm.tam;

import java.io.*;
import java.math.BigInteger;

/**
 * CMO $B7A<0$N(B MONOMIAL32 $B7?$rI=$7$^$9(B.
 * $B$3$N%/%i%9$OC19`<0$rI=8=$7$^$9(B.
 */
final public class CMO_MONOMIAL32 extends CMO{
  private int[] degree;
  private CMO coefficient;

  /**
   * $B78?t(B coefficient, $B<!?t(B degree[] $B$H$9$k(B MONOMIAL32 $B$r:n@.$7$^$9(B.
   */
  public CMO_MONOMIAL32(int[] degree,CMO coefficient){
    this.degree = degree;
    this.coefficient = coefficient;
  }

  public int DISCRIMINATOR(){
    return CMO.MONOMIAL32;
  }

    public boolean allowQ (int[] datacap) {
		return CMO.allowQ_tag(datacap, DISCRIMINATOR()) 
			&& coefficient.allowQ(datacap);
    }

  public void sendByObject(OpenXMstream os)
       throws IOException,MathcapViolation{
    os.writeInt(degree.length);
    for(int i=0;i<degree.length;i++){
      os.writeInt(degree[i]);
    }
    coefficient.write(os);
  }

  static protected CMO receive(OpenXMstream is) throws IOException{
    int n;
    int[] degree;
    CMO coefficient;

    n = is.readInt();
    degree = new int[n];

    for(int i=0;i<n;i++){
      degree[i] = is.readInt();
    }

    coefficient = CMO.receive(is);

    return new CMO_MONOMIAL32(degree,coefficient);
  }

  public String toCMOexpressionByObject(){
    String ret;

    ret = "CMO_MONOMIAL32,"+ degree.length;

    for(int i=0;i<degree.length;i++){
      ret += ","+ degree[i] ;
    }

    return ret +","+ coefficient.toCMOexpression();
  }

  /**
   * $B78?t$rF@$^$9(B.
   */
  public CMO getCoefficient(){
    return coefficient;
  }

  /**
   * $B<!?t$rF@$^$9(B.
   */
  public int[] getDegree(){
    return degree;
  }
}