Nice/src/mlsub/typing/lowlevel BitMatrix.java,1.9,1.10 K0.java,1.26,1.27

Arjan Boeijink <[email protected]> Wed, 30 Mar 2005 21:24:19 +0000
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/src/mlsub/typing/lowlevel
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24920/F:/nice/src/mlsub/typing/lowlevel

Modified Files:
	BitMatrix.java K0.java 
Log Message:
Use copy-constructor instead of clone for BitMatrix.

Index: K0.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/K0.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** K0.java	29 Mar 2005 22:51:57 -0000	1.26
--- K0.java	30 Mar 2005 21:24:02 -0000	1.27
***************
*** 550,556 ****
      // put in R and Rt, the constraint saturated under
      // x < y and y < z => x < z
!     R = (BitMatrix)C.clone();
      R.closure();
!     Rt = (BitMatrix)Ct.clone();
      Rt.closure();
      m0 = m = n;
--- 550,556 ----
      // put in R and Rt, the constraint saturated under
      // x < y and y < z => x < z
!     R = new BitMatrix(C);
      R.closure();
!     Rt = new BitMatrix(Ct);
      Rt.closure();
      m0 = m = n;
***************
*** 1079,1083 ****
      throws Unsatisfiable
    {
!     BitMatrix T=(BitMatrix)C.clone();
      T.closure();
      condense(T);
--- 1079,1083 ----
      throws Unsatisfiable
    {
!     BitMatrix T = new BitMatrix(C);
      T.closure();
      condense(T);
***************
*** 1109,1113 ****
        }
      }
!     BitMatrix Tt = (BitMatrix)Ct.clone();
      Tt.closure();
  
--- 1109,1113 ----
        }
      }
!     BitMatrix Tt = new BitMatrix(Ct);
      Tt.closure();
  
***************
*** 1157,1161 ****
    private void prepareConstraint() throws Unsatisfiable {
      collapseMinimal();
!     BitMatrix leq = (BitMatrix)C.clone();
      leq.closure();
      computeArrows(leq);
--- 1157,1161 ----
    private void prepareConstraint() throws Unsatisfiable {
      collapseMinimal();
!     BitMatrix leq = new BitMatrix(C);
      leq.closure();
      computeArrows(leq);
***************
*** 1301,1307 ****
    public void rigidify() {
      S.assume(S.a&& hasBeenInitialized);
!     R = (BitMatrix)C.clone();
      R.closure();
!     Rt = (BitMatrix)Ct.clone();
      Rt.closure();
      m = n;
--- 1301,1307 ----
    public void rigidify() {
      S.assume(S.a&& hasBeenInitialized);
!     R = new BitMatrix(C);
      R.closure();
!     Rt = new BitMatrix(Ct);
      Rt.closure();
      m = n;
***************
*** 1356,1360 ****
        // others can't be modified anyway.
        if (K0.this.m != K0.this.n)
!         this.savedC = (BitMatrix) K0.this.C.clone();
  
        this.savedGarbage = K0.this.garbage.cloneVector();
--- 1356,1360 ----
        // others can't be modified anyway.
        if (K0.this.m != K0.this.n)
!         this.savedC = new BitMatrix(K0.this.C);
  
        this.savedGarbage = K0.this.garbage.cloneVector();
***************
*** 1654,1660 ****
        this.simplified = simplified;
        this.initN = simplified.getLowestSetBit();
!       R = (BitMatrix)C.clone();
        R.closure();
!       Rt = (BitMatrix)Ct.clone();
        Rt.closure();
  
--- 1654,1660 ----
        this.simplified = simplified;
        this.initN = simplified.getLowestSetBit();
!       R = new BitMatrix(C);
        R.closure();
!       Rt = new BitMatrix(Ct);
        Rt.closure();
  

Index: BitMatrix.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/lowlevel/BitMatrix.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** BitMatrix.java	29 Mar 2005 22:51:58 -0000	1.9
--- BitMatrix.java	30 Mar 2005 21:23:58 -0000	1.10
***************
*** 10,14 ****
     @author Daniel Bonniot (Optimization for sparse and reflexives matrices)
   **/
! final public class BitMatrix implements Cloneable {
    /**
     * a vector of BitVectors. rows.get(i) is the ith line of
--- 10,14 ----
     @author Daniel Bonniot (Optimization for sparse and reflexives matrices)
   **/
! final public class BitMatrix {
    /**
     * a vector of BitVectors. rows.get(i) is the ith line of
***************
*** 35,38 ****
--- 35,56 ----
  
    /**
+    * Creates a copy of a matrix
+    **/
+   public BitMatrix(BitMatrix old) {
+     BitVector[] oldRows = old.rows;
+     BitVector[] newRows = new BitVector[oldRows.length];
+     for (int i = old.size-1; i >= 0; i--)
+       {
+         BitVector row = oldRows[i];
+         if (row != null && !row.isEmpty())
+           newRows[i] = row.cloneVector();
+       }
+ 
+     this.rows = newRows;
+     this.size = old.size;
+     this.reflexive = old.reflexive;
+   }
+ 
+   /**
     * Returns the number of rows and columns of this matrix
     **/
***************
*** 191,196 ****
    public void closure() {
      if (S.debug) {
!       BitMatrix testcopy = (BitMatrix)this.clone();
!       BitMatrix original = (BitMatrix)this.clone();
        this.closure2();
        testcopy.closure1();
--- 209,214 ----
    public void closure() {
      if (S.debug) {
!       BitMatrix testcopy = new BitMatrix(this);
!       BitMatrix original = new BitMatrix(this);
        this.closure2();
        testcopy.closure1();
***************
*** 322,350 ****
    }
  
-   public Object clone() {
-     try {
-       BitMatrix m = (BitMatrix)super.clone();
-       BitVector[] v = (BitVector[])rows.clone();
-       
-       for (int i = 0; i < size; i++) {
-         BitVector row = v[i];
-         if (row != null) {
-           if (!row.isEmpty())
- 	    v[i] = row.cloneVector();
-           else
-  	    v[i] = null;
-         }
-       }
-       m.rows = v;
-       m.size = size;
-       m.reflexive = reflexive;
-       return m;
-     } catch (CloneNotSupportedException e) {
-       throw new InternalError
- 	("Should never happen, since BitMatrix implements Cloneable");
-     }
-   }
- 
-   
    public String toString() {
      StringBuffer sb = new StringBuffer("{");
--- 340,343 ----



-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30