/*
 * matrix.java
 *
 * Created on 26 de julio de 2002, 11:47 PM
 */

/**
 *
 * @author  Juan Martín Barrios Vargas  
 * @version Java SDK 1.3.1
 */
public class matrix {

    /** Creates new matrix */
    public int n;           // Create n field
    
    public double [ ][ ]x; // Create x field
    
    // Create matrix(int) constructor 
    public matrix(int n) {
        this.n = n;
        x = new double [n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                x[i][j] = 0.0;
            }
        }
    }
    // End matrix(int) constructor
    
    // Create matrix(double[][]) constructor
    public matrix(double[ ][ ] y) {
        this.x = y;
        n = y.length;
    }
    // End matrix(double[][]) constructor
    
    // Create toString method
    public String toString ( ) {
        String text = "\n";
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                text += "\t" + (double)Math.round(1000 * x[i][j])/1000;
            }
            text += "\n";
        }
        text += "\n";
        return text;
    }
    // End toString method

}
