/* * * $Author: work $ * $Revision: 1.13 $ * $Log: ASM.java,v $ * Revision 1.13 2000-03-31 18:50:49-06 work * replaced * computeColumnNumberOfFirstRowUnit * with * computeInvertedRowNumberOfLastColumnUnit * and adjusted corresponding algorithm * * Revision 1.12 2000-03-31 05:52:42-06 work * wrote printMatrix(), which is * toString() but without attributes display * * Revision 1.11 2000-03-31 05:05:05-06 work * fixed bug in toString(): * no longer prints attributes if null * * Revision 1.10 2000-03-31 03:59:03-06 work * Now compatible with write-once only * ASMattributes class. Compute methods * now return ints, except for umbrella * computeAttributes method which returns nothing * * Revision 1.9 2000-03-31 03:49:16-06 work * this version does NOT clone attributes field * * Revision 1.8 2000-03-31 03:14:17-06 work * implemented clone() * * Revision 1.7 2000-03-31 03:02:27-06 work * *** Empty log message *** * * Revision 1.6 2000-03-30 00:38:38-06 work * 1) start matrix indices from 0 instead of * more readable 1 to save space * 2) also fixed bug in computing inversion number * * Revision 1.5 2000-03-29 22:26:25-06 work * written (currently commented out) main() * method to test toString printouts which * appears to work correctly * * Revision 1.4 2000-03-29 22:11:41-06 work * uses ASMattributes and include toString (not tested) * * Revision 1.3 2000-03-29 20:44:48-06 work * first draft (typos corrected), now compiles cleanly * * Revision 1.2 2000-03-29 20:40:53-06 work * first draft * * Revision 1.1 2000-03-29 19:50:26-06 work * Initial revision * */ /* * Copyright (C) 2000 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.util.*; import java.io.*; final class ASM implements Cloneable, Serializable { public byte[][] matrix; public ASMattributes attributes; // constructor public ASM( final int dimension ) { matrix = new byte[dimension][dimension]; attributes = null; } // warning: does not clone attributes field public Object clone() { ASM thisClone = new ASM( matrix.length ); thisClone.matrix = new byte[matrix.length][]; for( int i=0; i=0; k-- ) if( matrix[k][matrix.length-1] == 1 ) break; return matrix.length-k; } public int computeNumberOfMinusOnes() { int m = 0; for( int i=0; i