Anda di halaman 1dari 53

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsEliminacionGaussiana.java Domingo, 02 de Febrero de 2014 01:48 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; import javax.swing.JOptionPane; /** * * @author mario * Modificado por Johan Duran */ public class clsEliminacionGaussiana extends clsMatriz{ protected clsMatriz sistema; protected clsMatriz respaldo; private String solucion = ""; private String comentarios = "Sistema Compatible determinado";

public

clsEliminacionGaussiana(clsMatriz matriz){

super(matriz.getMxn().length,matriz.getMxn()[0].length); super.llenar(matriz); sistema = new clsMatriz(matriz.getMxn().length,matriz.getMxn()[0].length); sistema.llenar(matriz); respaldo = new clsMatriz(matriz.getMxn().length,matriz.getMxn()[0].length); respaldo.llenar(matriz); solucion = "\n" + sistema.toString() + "\n\n"; } public boolean seriedad(){

for(int fila = 0; fila < mxn.length ; fila++) { for(int columna = 0, ceros = 0; columna < mxn[fila].length;columna++) if(mxn[fila][columna].getNum() == 0){ ceros++; if(ceros == mxn[0].length){ JOptionPane.showMessageDialog(null, "Es una broma? parque que una fila nula?"); comentarios = "Es una broma? parque que una fila nula?"; return false;}} } for(int j = 0; j<mxn[0].length-1;j++){ for(int i = 0, ceros = 0; i<mxn.length;i++){ if(mxn[i][j].getNum()==0) ceros++; if(ceros == mxn.length){ JOptionPane.showMessageDialog(null, "Faltan variables"); comentarios = "Faltan variables"; return false;}

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsEliminacionGaussiana.java Domingo, 02 de Febrero de 2014 01:48 p.m.

} } return true;} public String resolver(){ double respa,respb,respc; llenar(respaldo); if(seriedad() == false) return getSolucion(); for(int i = 0; i<mxn.length;i++) {//Inicia eliminacion Gaussiana //Aqui se comprueba si en este punto el sistema sigue siendo compatible determinado //Si no lo es termina el metodo for(int x = 0, ceros = 0; x<mxn[i].length-1;x++){ //Inicia comprobacion if(mxn[i][x].getNum()==0) ceros++; if(ceros == mxn[i].length-1 && mxn[i][mxn[i].length-1].getNum()!=0){ JOptionPane.showMessageDialog(null,"Sistema inconsistente\n\n"); comentarios = "Sistema inconsistente\n\n"; return getSolucion(); } if(ceros == mxn[i].length-1 && mxn[i][mxn[i].length-1].getNum()==0){ JOptionPane.showMessageDialog(null,"Sistema con numero infinito de soluciones"); comentarios = "Sistema con numero infinito de soluciones"; return getSolucion(); } } // Termina comprobacion

if(mxn[i][i].getNum() == 0){ cambiarFilas(i, i+1); setSolucion(getSolucion() + "Cambio filas " + (i + 1) + " y " + (i + 2) + "\n\n"); } setSolucion(getSolucion() + "fila " + (i + 1) + " ].inversa(mxn[i][i]) + "\n\n"); introducirUNo(i,i); setSolucion(getSolucion() + toString() + "\n\n"); for(int j = i+1; j < mxn[i].length; j++){ if(j<mxn.length && mxn[j][i].getNum() != 0) setSolucion(getSolucion() + "fila " + (i + 1) + " * " + mxn[i][i].contrario( mxn[j][i]).toString() + " + fila " + (j + 1) + "\n\n"); factorCero(j<mxn.length ? mxn[i][i].contrario(mxn[j][i]):mxn[0][1],i,j); // solucion = solucion + toString() + "\n\n"; multiplicada por " + mxn[i][i

//Aqui se comprueba si en este punto el sistema sigue siendo compatible determinado //Si no lo es termina el metodo
-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsEliminacionGaussiana.java Domingo, 02 de Febrero de 2014 01:48 p.m.

for(int x = 0, ceros = 0; x<mxn[i].length-1;x++){//Inicia comprobacion if(mxn[i][x].getNum()==0) ceros++; if(ceros == mxn[i].length-1 && mxn[i][mxn[i].length-1].getNum()!=0){ JOptionPane.showMessageDialog(null,"Sistema inconsistente"); comentarios = "Sistema inconsistente"; return getSolucion(); } if(ceros == mxn[i].length-1 && mxn[i][mxn[i].length-1].getNum()==0){ JOptionPane.showMessageDialog(null,"Sistema con numero infinito de soluciones"); comentarios = "Sistema con numero infinito de soluciones"; return getSolucion(); } }//Termina comprobacion } setSolucion(getSolucion() + toString() + "\n\n"); }// Termina eliminacion Gaussiana setSolucion(getSolucion() + "Hasta aqui Gauss\nAhora Gauss-Jordan\n\n\n"); for(int i = mxn.length-1; i>0;i--){ for(int j = i-1;j>=0;j--){ if(j<mxn.length && mxn[j][i].getNum() != 0) setSolucion(getSolucion() + "fila " + (i + 1) + " * " + mxn[i][i].contrario( mxn[j][i]).toString() + " + fila " + (j + 1) + "\n\n"); factorCero(j<mxn.length ? mxn[0][0].contrario(mxn[j][i]):mxn[1][0],i,j); // solucion = solucion + toString() + "\n\n"; //prueba: } // if(i<mxn.length-1) setSolucion(getSolucion() + toString() + "\n\n"); for(int fila = 0; fila < mxn.length ; fila++){ for(int columnas = 0; columnas < mxn.length ; columnas++) if (fila==columnas){ respa=mxn[fila][mxn.length].getNum(); respb=mxn[fila][mxn.length].getDen(); respc=respa/respb; setSolucion(getSolucion()+"x("+(fila+1)+")="+ respc+"\n"); // setSolucion(getSolucion()+"x("+(fila+1)+")="+ mxn[fila][mxn.length]+"\n"); } } //prueba } return getSolucion(); } /** * @return the comentarios */ public String getComentarios() { return comentarios; } /**
-3-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsEliminacionGaussiana.java Domingo, 02 de Febrero de 2014 01:48 p.m.

* @return the sistema */ public clsMatriz getSistema() { return sistema; } /** * @param sistema the sistema to set */ public void setSistema(clsMatriz sistema) { this.sistema = sistema; } /** * @return the solucion */ public String getSolucion() { return solucion; } /** * @param solucion the solucion to set */ public void setSolucion(String solucion) { this.solucion = solucion; }

-4-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsFraccion.javaDomingo, 02 de Febrero de 2014 01:48 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; /** * * @author mario * Modificado por Johan Duran */ public class clsFraccion { private double num; private double den; public clsFraccion() { num=0; den=1; } public clsFraccion(double x) { num=x; den=1; } public clsFraccion(double x, double y) { num=x; den=y; } public static clsFraccion sumar(clsFraccion a, clsFraccion b){ clsFraccion c=new clsFraccion(); c.num=a.getNum()*b.getDen()+b.getNum()*a.getDen(); c.den=a.getDen()*b.getDen(); return c; } public static clsFraccion restar(clsFraccion a, clsFraccion b){ clsFraccion c=new clsFraccion(); c.num=a.getNum()*b.getDen()-b.getNum()*a.getDen(); c.den=a.getDen()*b.getDen(); return c; } public static clsFraccion multiplicar(clsFraccion a, clsFraccion b){ return new clsFraccion(a.getNum()*b.getNum(), a.getDen()*b.getDen()); } public static clsFraccion inversa(clsFraccion a){ return new clsFraccion(a.getDen(), a.getNum()); } public static clsFraccion contrario(clsFraccion a){

return new clsFraccion(-a.getNum(), a.getDen() > 0 ? a.getDen(): -a.getDen()); } public static clsFraccion dividir(clsFraccion a, clsFraccion b){ return multiplicar(a, inversa(b)); } private double mcd(){ double u=Math.abs(getNum()); double v=Math.abs(getDen());
-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsFraccion.javaDomingo, 02 de Febrero de 2014 01:48 p.m.

if(v==0){ return u; } double r; while(v!=0){ r=u%v; u=v; v=r; } return u; } public clsFraccion simplificar(){ double dividir=mcd(); num/=dividir; den/=dividir; if(num<0 && den<0){ num*=-1; den*=-1;} if(den<0 && num >0){ num*=-1; den*=-1; } return this; } public String toString(){ if(getDen() == 1 ){ String texto = getNum() + ""; return texto;} String texto=getNum()+"/"+getDen(); return texto; } /** * @return the num */ public double getNum() { return num; } /** * @return the den */ public double getDen() { return den; } }

-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsLimiteJ.java Domingo, 02 de Febrero de 2014 01:49 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; import javax.swing.text.*; /** * * @author mario * Modificado por Johan Duran */ //Esta clase limita la el tamano de la cadena que podemos ingresar public class clsLimiteJ extends PlainDocument{ private int limit; // optional uppercase conversion private boolean toUppercase = false; clsLimiteJ(int limit) { super(); this.limit = limit; } clsLimiteJ(int limit, boolean upper) { super(); this.limit = limit; toUppercase = upper; } public void insertString (int offset, String str, AttributeSet attr) throws BadLocationException { if (str == null) return; if ((getLength() + str.length()) <= limit) { if (toUppercase) str = str.toUpperCase(); super.insertString(offset, str, attr); } } }

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsLlenado.java Domingo, 02 de Febrero de 2014 01:49 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; import import import import import import import import import import import java.awt.GridLayout; java.awt.Container; java.awt.event.ActionListener; java.awt.event.ActionEvent; java.awt.event.KeyListener; java.awt.event.KeyAdapter; java.awt.event.KeyEvent; javax.swing.JFrame; javax.swing.JTextField; javax.swing.JPanel; javax.swing.JOptionPane;

/** * * @author mario * Modificado por Johan Duran */ public class clsLlenado extends JFrame{ private private private private private private JTextField formato[][]; GridLayout tabla; Container contenedor; JPanel panel; JPanel panelTabla; clsMatriz matriz;

public clsLlenado() {} public clsLlenado(int m, int n, int d) { super("Llenado de Matriz");

if(m > 0 && n > 0) formato = new JTextField[m][n];

matriz = new clsMatriz(m,n);

panelTabla = new JPanel();

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsLlenado.java Domingo, 02 de Febrero de 2014 01:49 p.m.

tabla = new GridLayout(m,n,5,5); contenedor = getContentPane(); panelTabla.setLayout(tabla);

for(int fila = 0; fila < formato.length ; fila++) { for(int columna = 0; columna < formato[fila].length;columna++) { formato[fila][columna] = new JTextField("",3); formato[fila][columna].setFont(new java.awt.Font ("Ubuntu", java.awt.Font.PLAIN, (300/formato.length)- (((300/formato.length)/100)*50))); //ESTO SOLO ES PRUEBA formato[fila][columna].setDocument(new clsLimiteJ(d)); formato[fila][columna].addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent evento){

char caracter = evento.getKeyChar(); if(Character.isDigit(caracter) == false && caracter != '-' && caracter != '.') evento.consume(); }

} );

formato[fila][columna].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evento) { if(correcto() == true){ llenar(); listo();

/* System.out.println(matriz.toString()); clsEliminacionGaussiana oso = new clsEliminacionGaussiana(matriz); System.out.println(oso.toString()); oso.resolver(); */

/*

System.out.println(matriz.toString()); matriz.introducirUNo(0, 0); System.out.println(matriz.toString());


-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsLlenado.java Domingo, 02 de Febrero de 2014 01:49 p.m.

matriz.factorCero(matriz.getElemento(1, 0).contrario(matriz.getElemento(1, 0)),0, 1); System.out.println(matriz.toString()); matriz.factorCero(matriz.getElemento(1, 0).contrario(matriz.getElemento(2, 0)),0, 2); System.out.println(matriz.toString()); */ // setVisible(false); } else JOptionPane.showMessageDialog(rootPane, "Llena " + "Correctamente la Matriz");

}) ; panelTabla.add(formato[fila][columna]); } }

add(panelTabla);

} public void listo(){ this.dispose(); } public void llenar() { getMatriz().llenar(formato); } public boolean correcto() { int faltantes = 0; for(int fila = 0; fila < formato.length ; fila++) for(int columna = 0; columna < formato[fila].length;columna++) if(formato[fila][columna].getText().equals("")) faltantes++; if(faltantes == 0) return true; else return false; }
-3-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsLlenado.java Domingo, 02 de Febrero de 2014 01:49 p.m.

/** * @return the matriz */ public clsMatriz getMatriz() { return matriz; }

-4-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsLlenadoGauss.java Domingo, 02 de Febrero de 2014 01:49 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; /** * * @author mario * Modificado por Johan Duran */ public class clsLlenadoGauss extends clsLlenado{ public clsLlenadoGauss() {} public clsLlenadoGauss(int m, int n,int d){ super(m,n,d); } public void listo(){ this.dispose(); GaussJOrdan gauss = new GaussJOrdan(new GaussIni(), true, getMatriz()); gauss.setLocationRelativeTo(null); gauss.setVisible(true);

} }

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsMatriz.java

Domingo, 02 de Febrero de 2014 01:50 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; import javax.swing.JOptionPane; import javax.swing.JTextField;

/** * * @author mario * Modificado por Johan Duran */ public class clsMatriz { // private String ax=""; double datos; protected clsFraccion mxn[][];

public clsMatriz(int m, int n) { if(m > 0 && n > 0) mxn = new clsFraccion[m][n];

} /** * @return the mxn */ public clsFraccion[][] getMxn() { return mxn; } /** * @param mxn the mxn to set */ public void setMxn(clsFraccion[][] mxn) { this.mxn = mxn; } public void llenar(JTextField[][] matriz) {

for(int fila = 0; fila < matriz.length ; fila++) { for(int columna = 0; columna < matriz[fila].length;columna++) mxn[fila][columna] = new clsFraccion(Double.parseDouble(matriz[fila][columna]. getText())); }
-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsMatriz.java

Domingo, 02 de Febrero de 2014 01:50 p.m.

} public void llenar(clsMatriz matriz) { for(int fila = 0; fila < matriz.getMxn().length ; fila++) { for(int columna = 0; columna < matriz.getMxn()[fila].length;columna++) mxn[fila][columna] = matriz.getMxn()[fila][columna];

} } public void cambiarFilas(int una, int otra){ clsFraccion aux = new clsFraccion(); for(int i = 0; i<mxn[una].length;i++){ aux = mxn[una][i]; mxn[una][i] = mxn[otra][i]; mxn[otra][i] = aux;

} } public void factorCero(clsFraccion factor, int una, int otra){

if(otra < mxn.length){ for(int i = 0; i<mxn[una].length;i++){ mxn[otra][i] = mxn[una][i].sumar(mxn[otra][i], mxn[una][i].multiplicar(mxn[una][i], factor)); mxn[otra][i].simplificar(); }} } public void introducirUNo(int fila, int columna){

if(mxn[fila][columna].getNum() != 0){ clsFraccion factor = new clsFraccion(); factor = factor.inversa(mxn[fila][columna]); for(int i = 0; i<mxn[fila].length;i++){ mxn[fila][i] = mxn[fila][i].multiplicar(factor, mxn[fila][i]); mxn[fila][i].simplificar();

-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsMatriz.java

Domingo, 02 de Febrero de 2014 01:50 p.m.

}} else JOptionPane.showMessageDialog(null, "No puedes cambiar un cero" + " por un uno si tener problemas"); }

public clsFraccion getElemento(int i, int j){ return mxn[i][j]; }

public String toString() {

String cadena = ""; for(int fila = 0; fila < mxn.length ; fila++) { for(int columna = 0; columna < mxn[fila].length;columna++){ if(mxn[fila][columna].getDen() == 1 || mxn[fila][columna].getDen() == -1) cadena = cadena + Double.toString(mxn[fila][columna].getNum()) + " "; else cadena = cadena + Double.toString(mxn[fila][columna].getNum()) + "/" + Double.toString(mxn[fila][columna].getDen()) + " "; } cadena = cadena + "\n"; } return cadena; } public static clsMatriz sumar(clsMatriz uno, clsMatriz dos){ clsMatriz resultado = new clsMatriz(uno.mxn.length, uno.mxn[0].length); for(int fila = 0; fila < resultado.getMxn().length ; fila++) { for(int columna = 0; columna < resultado.getMxn()[fila].length;columna++) resultado.mxn[fila][columna] = uno.getMxn()[fila][columna].sumar( uno.getMxn()[fila][columna], dos.getMxn()[fila][columna]);

-3-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsMatriz.java

Domingo, 02 de Febrero de 2014 01:50 p.m.

} System.out.println(resultado.toString()); return resultado; } public static clsMatriz restar(clsMatriz uno, clsMatriz dos){ clsMatriz resultado = new clsMatriz(uno.mxn.length, uno.mxn[0].length); for(int fila = 0; fila < resultado.getMxn().length ; fila++) { for(int columna = 0; columna < resultado.getMxn()[fila].length;columna++) resultado.mxn[fila][columna] = uno.getMxn()[fila][columna].restar( uno.getMxn()[fila][columna], dos.getMxn()[fila][columna]);

} System.out.println(resultado.toString()); return resultado; } public clsMatriz transponer(clsMatriz matriz){ clsMatriz resultado = new clsMatriz(matriz.mxn.length, matriz.mxn[0].length); for(int fila = 0 ; fila < matriz.mxn.length;fila++){ for(int columna = 0; columna < matriz.mxn[fila].length; columna ++) resultado.mxn[fila][columna] = matriz.mxn[columna][fila]; } return resultado; } public clsMatriz multiplicar(clsMatriz uno, clsMatriz dos){ int fila, columna; clsMatriz resultado = new clsMatriz(uno.mxn.length,dos.mxn[0].length); for(fila = 0; fila < resultado.getMxn().length ; fila++) { for(columna = 0; columna < resultado.getMxn()[fila].length;columna++){ resultado.mxn[fila][columna] = new clsFraccion(); for(int m = 0;m<resultado.getMxn().length;m++){ // System.out.println("" + resultado.mxn[fila][columna].toString() + // "+" + uno.mxn[columna][columna].toString() + " * " + dos.mxn[m][fila].toString() + "\n\n"); resultado.mxn[fila][columna] = resultado.mxn[fila][columna].sumar( resultado.mxn[fila][columna], resultado.mxn[fila][columna].multiplicar(uno.mxn[columna][m], dos.mxn[m][fila])); }}

} System.out.println(transponer(resultado).toString()); return transponer(resultado);}

-4-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\clsMatriz.java

Domingo, 02 de Febrero de 2014 01:50 p.m.

public clsMatriz calcularInversa(clsMatriz matriz){ clsMatriz inversa = new clsMatriz(matriz.mxn.length, matriz.mxn[0].length*2);

for(int fila = inversa.mxn.length -1; fila >= 0;fila--) for(int columna = inversa.mxn[fila].length -1; columna >= 0;columna --) inversa.mxn[fila][columna] = new clsFraccion();

for(int fila = 0; fila < matriz.mxn.length;fila++) for(int columna = 0; columna < matriz.mxn[fila].length;columna ++) inversa.mxn[fila][columna] = matriz.mxn[fila][columna]; for(int fila = 0, columna = matriz.mxn.length; fila < inversa.mxn.length;fila++, columna ++) inversa.mxn[fila][columna] = new clsFraccion(1,1);

clsEliminacionGaussiana oso = new clsEliminacionGaussiana(inversa); oso.resolver();

System.out.println(oso.toString()); return oso;

public Object[][] llenarTabla(clsMatriz matriz) { Object tabla[][] = new Object[matriz.mxn.length][matriz.mxn[0].length]; for(int fila = 0; fila < matriz.getMxn().length ; fila++) { for(int columna = 0; columna < matriz.getMxn()[fila].length;columna++) tabla[fila][columna] = matriz.getMxn()[fila][columna].getNum();

} return tabla; } }

-5-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\CrearArchivoTexto.java Domingo, 02 de Febrero de 2014 01:50 p.m.

/* * Modificado por Johan Duran */ package msquare;

import import import import import

java.io.FileNotFoundException; java.lang.SecurityException; java.util.Formatter; java.util.FormatterClosedException; java.util.Scanner;

public class CrearArchivoTexto { private Formatter salida;

public void abrirArchivo(String nombre) { try { salida = new Formatter( nombre ); } catch ( SecurityException securityException ) { System.err.println( "No tiene acceso de escritura a este archivo." ); System.exit( 1 ); } catch ( FileNotFoundException filesNotFoundException ) { System.err.println( "Error al crear el archivo." ); javax.swing.JOptionPane.showMessageDialog(null, "Error al crear el archivo"); } // fin de catch }

public void guardar(String paraGuardar) {

Scanner entrada = new Scanner( System.in );

try {

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\CrearArchivoTexto.java Domingo, 02 de Febrero de 2014 01:50 p.m.

salida.format( "%s\n", paraGuardar);

} catch ( FormatterClosedException formatterClosedException ) { System.err.println( "Error al escribir en el archivo." ); return; }

public void cerrarArchivo() { if ( salida != null ) salida.close(); } }

-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussIni.form

Domingo, 02 de Febrero de 2014 02:39 p.m.

<?xml version="1.0" encoding="UTF-8" ?> < -- Modificado por Johan Duran --> <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="3"/> <Property name="title" type="java.lang.String" value="Sistema de Ecuaciones"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="generateCenter" type="boolean" value="false"/> </SyntheticProperties> <AuxValues> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> </AuxValues> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace min="-2" pref="67" max="-2" attributes="0"/> <Group type="103" groupAlignment="1" attributes="0"> <Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <Component id="cuantas" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="variables" min="-2" pref="44" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="OK2" min="-2" pref="59" max="-2" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0"> <Component id="cuantas1" min="-2" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="Decimales" min="-2" pref="43" max="-2" attributes="0"/> </Group> </Group> </Group> </Group> <Group type="102" alignment="0" attributes="0"> <EmptySpace min="-2" pref="126" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/> </Group>
-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussIni.form

Domingo, 02 de Febrero de 2014 02:39 p.m.

</Group> <EmptySpace pref="105" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace min="-2" pref="29" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="cuantas" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="variables" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="cuantas1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="Decimales" alignment="3" min="-2" max="-2" attributes="0"/> </Group> </Group> <Group type="102" alignment="0" attributes="0"> <EmptySpace min="-2" pref="37" max="-2" attributes="0"/> <Component id="OK2" min="-2" max="-2" attributes="0"/> </Group> </Group> <EmptySpace pref="49" max="32767" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" pref="61" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Component class="javax.swing.JLabel" name="jLabel2"> <Properties> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Ubuntu" size="18" style="1"/> </Property> <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> <Color blue="99" green="33" red="0" type="rgb"/> </Property> <Property name="text" type="java.lang.String" value="Sistemas de Ecuaciones"/> </Properties> </Component> <Component class="javax.swing.JLabel" name="cuantas"> <Properties> <Property name="text" type="java.lang.String" value="Cuantas Variables "/> </Properties>
-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussIni.form

Domingo, 02 de Febrero de 2014 02:39 p.m.

</Component> <Component class="javax.swing.JTextField" name="variables"> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="variablesActionPerformed"/> <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="variablesKeyTyped"/> </Events> </Component> <Component class="javax.swing.JLabel" name="cuantas1"> <Properties> <Property name="text" type="java.lang.String" value="Cuantos Decimales"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="Decimales"> <Properties> <Property name="text" type="java.lang.String" value="5"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="DecimalesActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="OK2"> <Properties> <Property name="text" type="java.lang.String" value="OK"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="OK2ActionPerformed"/> </Events> </Component> <Component class="javax.swing.JLabel" name="jLabel1"> <Properties> <Property name="text" type="java.lang.String" value="Johan Duran -- 000241283"/> </Properties> </Component> </SubComponents> </Form>

-3-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussIni.java

Domingo, 02 de Febrero de 2014 01:51 p.m.

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package msquare; import javax.swing.JOptionPane; /** * * @author USUARIO * Modificado por Johan Duran */ public class GaussIni extends javax.swing.JFrame { /** * Creates new form GaussIni */ public GaussIni() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel2 = new javax.swing.JLabel(); cuantas = new javax.swing.JLabel(); variables = new javax.swing.JTextField(); cuantas1 = new javax.swing.JLabel(); Decimales = new javax.swing.JTextField(); OK2 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Sistema de Ecuaciones"); jLabel2.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N jLabel2.setForeground(new java.awt.Color(0, 51, 153)); jLabel2.setText("Sistemas de Ecuaciones"); cuantas.setText("Cuantas Variables "); variables.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { variablesActionPerformed(evt); } }); variables.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { variablesKeyTyped(evt);
-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussIni.java

Domingo, 02 de Febrero de 2014 01:51 p.m.

} }); cuantas1.setText("Cuantos Decimales"); Decimales.setText("5"); Decimales.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DecimalesActionPerformed(evt); } }); OK2.setText("OK"); OK2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { OK2ActionPerformed(evt); } }); jLabel1.setText("Johan Duran -- 000241283"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment. LEADING) .addGroup(layout.createSequentialGroup() .addGap(67, 67, 67) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout. Alignment.TRAILING) .addComponent(jLabel2) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout. Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(cuantas) .addGap(18, 18, 18) .addComponent(variables, javax.swing.GroupLayout. PREFERRED_SIZE, 44, javax.swing.GroupLayout. PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(OK2, javax.swing.GroupLayout.PREFERRED_SIZE , 59, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(cuantas1) .addGap(18, 18, 18) .addComponent(Decimales, javax.swing.GroupLayout. PREFERRED_SIZE, 43, javax.swing.GroupLayout. PREFERRED_SIZE))))) .addGroup(layout.createSequentialGroup() .addGap(126, 126, 126) .addComponent(jLabel1))) .addContainerGap(105, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussIni.java

Domingo, 02 de Febrero de 2014 01:51 p.m.

.addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel2) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment. LEADING) .addGroup(layout.createSequentialGroup() .addGap(29, 29, 29) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout. Alignment.BASELINE) .addComponent(cuantas) .addComponent(variables, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout. PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout. Alignment.BASELINE) .addComponent(cuantas1) .addComponent(Decimales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout. PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(37, 37, 37) .addComponent(OK2))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE) .addComponent(jLabel1) .addGap(61, 61, 61)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void variablesActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_variablesActionPerformed // TODO add your handling code here: }//GEN-LAST:event_variablesActionPerformed private void variablesKeyTyped(java.awt.event.KeyEvent evt) { //GEN-FIRST:event_variablesKeyTyped // TODO add your handling code here: char c = evt.getKeyChar(); if(Character.isDigit(c)==false) evt.consume(); }//GEN-LAST:event_variablesKeyTyped private void DecimalesActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_DecimalesActionPerformed // TODO add your handling code here: }//GEN-LAST:event_DecimalesActionPerformed private void OK2ActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_OK2ActionPerformed // TODO add your handling code here: int num; if(variables.getText().equals("") == false &&Double.parseDouble(variables.getText())>0 && Double.parseDouble(variables.getText())<21) {
-3-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussIni.java

Domingo, 02 de Febrero de 2014 01:51 p.m.

num=Integer.parseInt(variables.getText()); clsLlenadoGauss ta = new clsLlenadoGauss( Integer.parseInt(variables.getText()), Integer.parseInt(variables.getText())+1,Integer.parseInt(Decimales.getText ())); ta.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE); if(num<15)num+=8; ta.setSize(num*50, num*35); ta.setLocationRelativeTo(null); ta.setVisible(true); } else JOptionPane.showMessageDialog(null, "Ingresa un numero de variables" + "valido"); }//GEN-LAST:event_OK2ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager. getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(GaussIni.class.getName()).log(java.util. logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(GaussIni.class.getName()).log(java.util. logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(GaussIni.class.getName()).log(java.util. logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(GaussIni.class.getName()).log(java.util. logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new GaussIni().setVisible(true);
-4-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussIni.java

Domingo, 02 de Febrero de 2014 01:51 p.m.

} }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField Decimales; private javax.swing.JButton OK2; private javax.swing.JLabel cuantas; private javax.swing.JLabel cuantas1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JTextField variables; // End of variables declaration//GEN-END:variables }

-5-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.form Domingo, 02 de Febrero de 2014 02:40 p.m.

< -- Modificado por Johan Duran --> <?xml version="1.0" encoding="UTF-8" ?> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> <NonVisualComponents> <Component class="javax.swing.ButtonGroup" name="buttonGroup1"> </Component> </NonVisualComponents> <Properties> <Property name="defaultCloseOperation" type="int" value="2"/> <Property name="title" type="java.lang.String" value="Metodo de Numericos (Gauss)"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="generateCenter" type="boolean" value="false"/> </SyntheticProperties> <AuxValues> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> </AuxValues> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <EmptySpace max="32767" attributes="0"/> <Component id="jLabel14" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="ruta" min="-2" pref="132" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Component id="guardar" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" pref="323" max="-2" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Component id="jScrollPane1" min="-2" pref="594" max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/> </Group> </Group> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <EmptySpace min="10" pref="10" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.form Domingo, 02 de Febrero de 2014 02:40 p.m.

</Group> <Component id="jPanel1" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <Component id="jScrollPane1" min="-2" pref="402" max="-2" attributes="1"/> <EmptySpace type="separate" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="guardar" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="ruta" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" pref="47" max="-2" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0"> <Component id="jPanel1" max="32767" attributes="1"/> <EmptySpace min="-2" pref="14" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/> </Group> </Group> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Container class="javax.swing.JScrollPane" name="jScrollPane1"> <AuxValues> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTextArea" name="texto"> <Properties> <Property name="editable" type="boolean" value="false"/> <Property name="columns" type="int" value="30"/> <Property name="rows" type="int" value="5"/> </Properties> </Component> </SubComponents> </Container> <Container class="javax.swing.JPanel" name="jPanel1"> <Properties> <Property name="background" type="java.awt.Color"
-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.form Domingo, 02 de Febrero de 2014 02:40 p.m.

editor="org.netbeans.beaninfo.editors.ColorEditor"> <Color blue="ff" green="ff" red="ff" type="rgb"/> </Property> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <TitledBorder title="Opciones de Solucion"/> </Border> </Property> </Properties> <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0"> <Component id="jButton2" alignment="1" max="32767" attributes="0"/> <Group type="102" alignment="1" attributes="0"> <EmptySpace min="0" pref="0" max="32767" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Component id="jRadioButton1" min="-2" max="-2" attributes="0"/> <Group type="102" alignment="0" attributes="0"> <EmptySpace min="-2" pref="13" max="-2" attributes="0"/> <Component id="mOperaciones" min="-2" max="-2" attributes="0"/> </Group> </Group> </Group> </Group> <EmptySpace min="-2" pref="32" max="-2" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0"> <Component id="jButton1" min="-2" pref="121" max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0"> <Component id="resolver" min="-2" pref="121" max="-2" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/> </Group> </Group> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Component id="jRadioButton1" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
-3-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.form Domingo, 02 de Febrero de 2014 02:40 p.m.

<Component id="mOperaciones" min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/> <Component id="resolver" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="jButton1" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="jButton2" min="-2" max="-2" attributes="0"/> <EmptySpace pref="296" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Component class="javax.swing.JButton" name="resolver"> <Properties> <Property name="text" type="java.lang.String" value="Gauss Jordan"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resolverActionPerformed"/> </Events> </Component> <Component class="javax.swing.JRadioButton" name="jRadioButton1"> <Properties> <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> <Color blue="ff" green="ff" red="ff" type="rgb"/> </Property> <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> <ComponentRef name="buttonGroup1"/> </Property> <Property name="selected" type="boolean" value="true"/> <Property name="text" type="java.lang.String" value="Solucion Automatica"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jRadioButton1ActionPerformed"/> </Events> </Component> <Component class="javax.swing.JCheckBox" name="mOperaciones"> <Properties> <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> <Color blue="ff" green="ff" red="ff" type="rgb"/> </Property> <Property name="selected" type="boolean" value="true"/> <Property name="text" type="java.lang.String" value="Mostrar"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mOperacionesActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="jButton1"> <Properties> <Property name="text" type="java.lang.String" value="Gauss Seidel"/>
-4-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.form Domingo, 02 de Febrero de 2014 02:40 p.m.

</Properties> <Events> <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton1MouseClicked"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="jButton2"> <Properties> <Property name="text" type="java.lang.String" value="Gauss Inversa"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> </Events> </Component> </SubComponents> </Container> <Component class="javax.swing.JButton" name="guardar"> <Properties> <Property name="text" type="java.lang.String" value="Guardar"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="guardarActionPerformed"/> </Events> </Component> <Component class="javax.swing.JTextField" name="ruta"> </Component> <Component class="javax.swing.JLabel" name="jLabel14"> <Properties> <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> <Color blue="ff" green="ff" red="ff" type="rgb"/> </Property> <Property name="text" type="java.lang.String" value="Nombre"/> </Properties> </Component> <Component class="javax.swing.JLabel" name="jLabel1"> <Properties> <Property name="text" type="java.lang.String" value="Johan Duran -- 000241283"/> </Properties> </Component> </SubComponents> </Form>

-5-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.java Domingo, 02 de Febrero de 2014 01:50 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * GaussJOrdan.java * * Created on 7/05/2011, 06:27:09 PM * Modificado por Johan Duran */ package msquare; import javax.swing.JOptionPane; import msquare.clsMatriz; //import msquare.ClonicoApp2; import java.io.*; /** * * @author mario */ public class GaussJOrdan extends JDialogConFondo { // BufferedReader h; clsEliminacionGaussiana oso; public String parsed; clsEliminacionGaussiana usuario; // public ClonicoApp2 mtr; LibreriaBase Seidel; InicioInv Inversa; public int num1, num2; javax.swing.SpinnerModel modelo; // private Matriz matriz; /** Creates new form GaussJOrdan */ public GaussJOrdan(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); } public GaussJOrdan(java.awt.Frame parent, boolean modal, clsMatriz matriz) { super(parent, modal); initComponents(); mOperaciones.setVisible(false); jRadioButton1.setVisible(false); // mtr =new ClonicoApp2(matriz); oso = new clsEliminacionGaussiana(matriz); usuario = new clsEliminacionGaussiana(matriz); // String parsed;// = new double[10][10]; modelo = new javax.swing.SpinnerNumberModel(1,1, matriz.getMxn().length,1); parsed=matriz.toString(); num1=matriz.getMxn().length; num2=matriz.getMxn()[0].length; texto.setText(matriz.toString());

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.java Domingo, 02 de Febrero de 2014 01:50 p.m.

} /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); jScrollPane1 = new javax.swing.JScrollPane(); texto = new javax.swing.JTextArea(); jPanel1 = new javax.swing.JPanel(); resolver = new javax.swing.JButton(); jRadioButton1 = new javax.swing.JRadioButton(); mOperaciones = new javax.swing.JCheckBox(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); guardar = new javax.swing.JButton(); ruta = new javax.swing.JTextField(); jLabel14 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Metodo de Gauss-Jordan"); texto.setEditable(false); texto.setColumns(30); texto.setRows(5); jScrollPane1.setViewportView(texto); jPanel1.setBackground(new java.awt.Color(255, 255, 255)); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Opciones de Solucion" )); resolver.setText("Gauss Jordan"); resolver.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { resolverActionPerformed(evt); } }); jRadioButton1.setBackground(new java.awt.Color(255, 255, 255)); buttonGroup1.add(jRadioButton1); jRadioButton1.setSelected(true); jRadioButton1.setText("Solucion Automatica"); jRadioButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton1ActionPerformed(evt); } }); mOperaciones.setBackground(new java.awt.Color(255, 255, 255)); mOperaciones.setSelected(true); mOperaciones.setText("Mostrar");
-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.java Domingo, 02 de Febrero de 2014 01:50 p.m.

mOperaciones.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mOperacionesActionPerformed(evt); } }); jButton1.setText("Gauss Seidel"); jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Gauss Inversa"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment .LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout. createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout. Alignment.TRAILING) .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addComponent(jRadioButton1) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(13, 13, 13) .addComponent(mOperaciones))))) .addGap(32, 32, 32)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short. MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(resolver, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))))
-3-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.java Domingo, 02 de Febrero de 2014 01:50 p.m.

); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jRadioButton1) .addGap(15, 15, 15) .addComponent(mOperaciones) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(resolver) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2) .addContainerGap(296, Short.MAX_VALUE)) ); guardar.setText("Guardar"); guardar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { guardarActionPerformed(evt); } }); jLabel14.setForeground(new java.awt.Color(255, 255, 255)); jLabel14.setText("Nombre"); jLabel1.setText("Johan Duran -000241283");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout. createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment. LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short. MAX_VALUE) .addComponent(jLabel14) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ruta, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(guardar) .addGap(323, 323, 323)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 594, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment. LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10)
-4-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.java Domingo, 02 de Febrero de 2014 01:50 p.m.

.addComponent(jLabel1)) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax. swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment. LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 402, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout. Alignment.BASELINE) .addComponent(guardar) .addComponent(ruta, javax.swing.GroupLayout.PREFERRED_SIZE, javax .swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout. PREFERRED_SIZE) .addComponent(jLabel14)) .addGap(47, 47, 47)) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax. swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(14, 14, 14) .addComponent(jLabel1)))) ); pack(); }// </editor-fold>//GEN-END:initComponents private void guardarActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_guardarActionPerformed // TODO add your handling code here: if(ruta.getText().equals("")==false){ CrearArchivoTexto archivo = new CrearArchivoTexto(); archivo.abrirArchivo("/" + ruta.getText() + ".txt"); archivo.guardar(texto.getText()); archivo.cerrarArchivo(); ruta.setText(""); JOptionPane.showMessageDialog(null, "Solucion Guardada"); } else{ JOptionPane.showMessageDialog(null, "Introduce un nombre de guardado"); } }//GEN-LAST:event_guardarActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: String inversatext; inversatext=""; inversatext=Inversa.Inicios(parsed,num1,num2); //texto.setText(Seidel.inicio(parsed,num1,num2));
-5-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.java Domingo, 02 de Febrero de 2014 01:50 p.m.

texto.setText(parsed + "\n\n" + inversatext ); }//GEN-LAST:event_jButton2ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: ////ciar(); // super(mtr,matriz) ; String seideltext; seideltext=""; seideltext=Seidel.inicio(parsed,num1,num2); texto.setText(Seidel.inicio(parsed,num1,num2)); texto.setText(parsed + "\n\n" + seideltext ); //texto.setText(Seidel.impresion()); }//GEN-LAST:event_jButton1ActionPerformed private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { //GEN-FIRST:event_jButton1MouseClicked // TODO add your handling code here: }//GEN-LAST:event_jButton1MouseClicked private void mOperacionesActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_mOperacionesActionPerformed // TODO add your handling code here: }//GEN-LAST:event_mOperacionesActionPerformed private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_jRadioButton1ActionPerformed // TODO add your handling code here: mOperaciones.setEnabled(true); resolver.setEnabled(true); texto.setText(usuario.toString()); }//GEN-LAST:event_jRadioButton1ActionPerformed private void resolverActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_resolverActionPerformed // TODO add your handling code here: String solucion = oso.resolver(); if(mOperaciones.isSelected()){ texto.setText(solucion + "\n\n" + oso.getComentarios()); oso.setSolucion(oso.respaldo.toString());} else{ texto.setText(oso.toString() + "\n\n" + oso.getComentarios()); oso.setSolucion(oso.respaldo.toString()); } }//GEN-LAST:event_resolverActionPerformed /** * @param args the command line arguments */ /* public static void main(String args[]) {
-6-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\GaussJOrdan.java Domingo, 02 de Febrero de 2014 01:50 p.m.

java.awt.EventQueue.invokeLater(new Runnable() { public void run() { GaussJOrdan dialog = new GaussJOrdan(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); }*/ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton guardar; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel14; private javax.swing.JPanel jPanel1; private javax.swing.JRadioButton jRadioButton1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JCheckBox mOperaciones; private javax.swing.JButton resolver; private javax.swing.JTextField ruta; private javax.swing.JTextArea texto; // End of variables declaration//GEN-END:variables }

-7-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\InicioInv.java

Domingo, 02 de Febrero de 2014 01:52 p.m.

/* * Modificado por Johan Duran */ package msquare; import msquare.Lectura; import java.io.*; public class InicioInv {

public static String Inicios(String solucion,int t, int t1){ //throws IOException{ InicioInv obj=new InicioInv (); Lectura l=new Lectura(); String s = solucion; String[] ls; ls = s.split("\\s* \\s*"); double[][] inver = new double[t][t]; double[] indep = new double[t]; int k=0; for(int i=0;i<=((t)-1);i++){ for(int j=0;j<=((t)-1);j++){ double d = Double.parseDouble(ls[k]); inver[i][j] = Double.valueOf(ls[k]); k++; } indep[i] = Double.valueOf(ls[k]); k++; } k=0; double[][] m = new double[t][t]; for(int i=0;i<=((t)-1);i++){ for(int j=0;j<=((t)-1);j++){ m[i][j]= inver[i][j]; System.out.println(m[i][j]); } } double[] B = new double[t]; for(int i=0;i<=((t)-1);i++){ B[i]= indep[i]; } //double m[][]=l.leermatriz(l.leerentero("INGRESA EL TAMA O DE LA MATRIZ")); String cadenainv; cadenainv=""; l.vermatriz(m); double deter=obj.determinante(m); //System.out.println("\nDETRMINANTE = "+deter); cadenainv=cadenainv+("\nDETRMINANTE = "+deter); double mad[][]=obj.adjunta(m); //System.out.println("\nMATRIZ ADJUNTA"); cadenainv=cadenainv+("\nMATRIZ ADJUNTA \n")+l.vermatriz(mad); //l.vermatriz(mad); double mtr[][]=obj.transpuesta(mad); //System.out.println("\nMATRIZ TRANSPUESTA DE LA MATRIZ ADJUNTA"); cadenainv=cadenainv+("\nMATRIZ TRANSPUESTA DE LA MATRIZ ADJUNTA \n ")+l.vermatriz(mtr); //l.vermatriz(mtr);
-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\InicioInv.java

Domingo, 02 de Febrero de 2014 01:52 p.m.

double minversa[][]=obj.inversa(mtr,deter); //System.out.println("\nMATRIZ INVERSA"); cadenainv=cadenainv+("\nMATRIZ INVERSA \n")+l.vermatrizinv(mtr, deter); //l.vermatrizinv(mtr, deter); //System.out.println("\n MATRIZ INVERSA FINAL"); cadenainv=cadenainv+("\n MATRIZ INVERSA FINAL \n")+l.vermatriz(minversa); cadenainv=cadenainv+("\n Resultado Metodo Gauss - Inversa \n")+gaussinversa(minversa,B); //l.vermatriz(minversa); return cadenainv; }

public double determinante(double mt[][]){ InicioInv obj=new InicioInv (); double dp=0,ds=0,deter=0; double mul=1; if(mt.length>2){ //DIAGONALES PRINCIPALES for (int i=0;i<mt.length;i++){ double aux[][]=obj.cambiarp(mt, i); mul=1; for (int j=0;j<aux.length;j++){ for (int k=0;k<aux.length;k++){ if(j==k){ mul=mul*aux[j][k]; } } } dp=dp+mul; } //DIAGONALES SECUNDARIAS for (int i=0;i<mt.length;i++){ double aux[][]=obj.cambiars(mt, i); mul=1; for (int j=0;j<aux.length;j++){ for (int k=0;k<aux.length;k++){ if((j+k)==mt.length-1){ mul=mul*aux[j][k]; } } } ds=ds+mul; } } else{ for (int j=0;j<mt.length;j++){ for (int k=0;k<mt.length;k++){ if(j==k){ mul=mul*mt[j][k]; } } } dp=mul; mul=1;
-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\InicioInv.java

Domingo, 02 de Febrero de 2014 01:52 p.m.

for (int j=0;j<mt.length;j++){ for (int k=0;k<mt[0].length;k++){ if((j+k)==(mt.length-1)){ mul=mul*mt[j][k]; } } } ds=mul; } deter=dp-ds; return deter; } public double [][] cambiarp(double mt[][],int c){ double m[][]=new double[mt.length][mt.length]; for (int j=0;j<mt.length;j++){ for (int k=0;k<mt.length;k++){ m[k][j]=mt[k][c]; } c++; if(c>(mt.length-1)){ c=0; } } return m; } public double [][] cambiars(double mt[][],int c){ double m[][]=new double[mt.length][mt.length]; int fl=0; for (int j=(mt.length-1);j>=0;j--){ for (int k=0;k<mt.length;k++){ m[k][fl]=mt[k][c]; } fl++; c++; if(c>=mt.length){ c=0; } } return m; } public double [][] adjunta(double mt[][]){ double ma[][]=new double[mt.length][mt.length]; int con=-1; for (int i=0;i<mt.length;i++){ int f=0,c=-1; for (int a=0;a<mt.length;a++){ double m[][]=new double[mt.length-1][mt.length-1]; f=0; c=-1; for (int j=0;j<mt.length;j++){ c=-1; for (int k=0;k<mt.length;k++){ if ((j!=i)&&(k!=a)){ c++;
-3-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\InicioInv.java

Domingo, 02 de Febrero de 2014 01:52 p.m.

m[f][c]=mt[j][k]; } } if(c!=-1){ f++; } } con++; if (m.length==1){ ma[i][a]=m[0][0]; } else{ ma[i][a]=determinante(m); } if (con%2!=0){ ma[i][a]=ma[i][a]*-1; } } } return ma; } public double [][] transpuesta(double m[][]){ double mt[][]=new double[m.length][m.length]; for (int j=0;j<m.length;j++){ for (int k=0;k<m.length;k++){ mt[j][k]=m[k][j]; } } return mt; } public double [][] inversa(double m[][],double deter){ double minv[][]=new double[m.length][m.length]; double d=1/deter; for (int j=0;j<m.length;j++){ for (int k=0;k<m.length;k++){ minv[j][k]=d*m[j][k]; } } return minv; } public static String gaussinversa(double m[][], double vec[]){ int n; n= m.length; double minv[][]=new double[n][n]; double resp=0; String Resultado; Resultado=""; //int k=0; //double resultado []; //int j=0; //double d=1/deter; for (int j=0;j<n;j++){
-4-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\InicioInv.java

Domingo, 02 de Febrero de 2014 01:52 p.m.

for (int k=0;k<n;k++){ resp+=m[j][k]*vec[k]; } Resultado+="X["+(j+1)+"] = "+resp+"\n"; resp=0; } return Resultado; } }

-5-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\JDialogConFondo.java Domingo, 02 de Febrero de 2014 01:51 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; /** * * @author flor * Modificado por Johan Duran */ import java.awt.Image; import javax.swing.JDialog; public class JDialogConFondo extends JDialog { private final JPanelConFondo contenedor = new JPanelConFondo(); public JDialogConFondo(java.awt.Frame parent, boolean modal) { setContentPane(contenedor); } public void setImagen(String nombreImagen) { contenedor.setImagen(nombreImagen); } public void setImagen(Image nuevaImagen) { contenedor.setImagen(nuevaImagen); } }

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\JFrameConFondo.java Domingo, 02 de Febrero de 2014 01:51 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; /** * * @author flor * Modificado por Johan Duran */ import java.awt.Image; import javax.swing.JFrame; import msquare.JPanelConFondo; public class JFrameConFondo extends JFrame { private final JPanelConFondo contenedor = new JPanelConFondo(); public JFrameConFondo() { // setContentPane(contenedor); } public void setImagen(String nombreImagen) { contenedor.setImagen(nombreImagen); }

//

public void setImagen(Image nuevaImagen) { // contenedor.setImagen(nuevaImagen); } }

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\JPanelConFondo.java Domingo, 02 de Febrero de 2014 01:51 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; /** * * @author flor * Modificado por Johan Duran */ import java.awt.Graphics; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JPanel; public class JPanelConFondo extends JPanel { private Image imagen; public JPanelConFondo() { } public JPanelConFondo(String nombreImagen) { if (nombreImagen != null) { // imagen = new ImageIcon(getClass().getResource(nombreImagen)).getImage(); } } public JPanelConFondo(Image imagenInicial) { if (imagenInicial != null) { imagen = imagenInicial; } } public void setImagen(String nombreImagen) { if (nombreImagen != null) { imagen = new ImageIcon(getClass().getResource(nombreImagen)).getImage(); } else { imagen = null; } repaint(); } public void setImagen(Image nuevaImagen) { imagen = nuevaImagen; repaint(); } @Override public void paint(Graphics g) { if (imagen != null) { g.drawImage(imagen, 0, 0, getWidth(), getHeight(), this);

//

-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\JPanelConFondo.java Domingo, 02 de Febrero de 2014 01:51 p.m.

setOpaque(false); } else { setOpaque(true); } super.paint(g); } }

-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\Lectura.java

Domingo, 02 de Febrero de 2014 01:52 p.m.

/* * Modificado por Johan Duran */

package msquare; import java.io.*; public class Lectura { BufferedReader h; public Lectura(){ iniciabuf(); } void iniciabuf(){ h= new BufferedReader(new InputStreamReader(System.in)); } public int leerentero(String cad)throws IOException{ int nm; System.out.println(cad); nm=Integer.parseInt(h.readLine()); return nm; } public double[][] leermatriz(int f)throws IOException{ double md[][]=new double[f][f]; for (int i=0;i<f;i++){ for (int j=0;j<f;j++){ System.out.println("INGRESAR ELEMENTO ["+(i+1)+"] "+"["+(j+1)+"]"); md[i][j]=Double.parseDouble(h.readLine()); } } return md; } public String vermatriz(double mt[][]){ String verma; verma=""; for (int i=0;i<mt.length;i++){ for (int j=0;j<mt.length;j++){ //System.out.print(mt[i][j]+" "); verma+=(mt[i][j]+" "); // return verma; } verma+='\n'; // return verma; // //System.out.println(); } return verma; } public String vermatrizinv(double mt[][], double deter){ String vermainv; vermainv="";
-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\Lectura.java

Domingo, 02 de Febrero de 2014 01:52 p.m.

for (int i=0;i<mt.length;i++){ for (int j=0;j<mt.length;j++){ //System.out.print(mt[i][j]+"/"+deter+" "); vermainv+=(mt[i][j]+"/"+deter+" "); } //System.out.println(); vermainv+='\n'; } return vermainv; } }

-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\LibreriaBase.java Domingo, 02 de Febrero de 2014 01:52 p.m.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package msquare; import javax.swing.JOptionPane; /** * Esta Clase contiene los metodos basicos para solucionar los sistemas de ecuaciones * <p> * Cada metodo de esta clase es declarado como estatico para facilitar su uso por otras clases * <p> * La version Actual (2.0) ha sido mejorada para utilizar mas metodos, y perfeccionar algunos metodos que estaban funcionando mal * @author The NuMethod Team * Modificado por Johan Duran * @version 2.0 */ public class LibreriaBase { public static double[] Seidel (double[][]A, double []B){ int n = A.length; double aux; boolean ind=false,validacion=false; // double[][] AA = new double[n][n + 1]; double[] VectorC = new double[n]; double[] Vector1 = new double[n]; double[] CVector1 = new double[n]; double[][] Matriz = new double[n][n]; for(int y=0;y<n;y++){ CVector1[y]=0; Vector1[y]=0; } Matriz=A; VectorC=B;

for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ if (i==j){ aux=Matriz[i][j]; for (int k=0;k<n;k++){ if (Matriz[i][k]>aux){ validacion=true; } } } } if (validacion==true){ ind=false; System.out.print("\n la Validacin no Fue EXITOSA\n"); Vector1[0]=-969989.65555; } } if (validacion!=true){ System.out.println("\nVALIDACION EXITOSA\n");
-1-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\LibreriaBase.java Domingo, 02 de Febrero de 2014 01:52 p.m.

for (int it=0;it<20;it++){ for(int y=0;y<n;y++){ for(int x=0;x<n;x++) CVector1[y]-=(Matriz[y][x]*Vector1[x])/Matriz[y][y]; CVector1[y]+=(VectorC[y]/Matriz[y][y]); Vector1[y]=CVector1[y]; } } } return Vector1; } public static String inicio(String solucion,int t, int t1) { String s = solucion; String[] ls; ls = s.split("\\s* \\s*"); double[][] parsed = new double[t][t]; double[] indep = new double[t]; int k=0; for(int i=0;i<=((t)-1);i++){ for(int j=0;j<=((t)-1);j++){ double d = Double.parseDouble(ls[k]); parsed[i][j] = Double.valueOf(ls[k]); k++; } indep[i] = Double.valueOf(ls[k]); k++; } k=0; double[][] test = new double[t][t]; for(int i=0;i<=((t)-1);i++){ for(int j=0;j<=((t)-1);j++){ test[i][j]= parsed[i][j]; // System.out.println(test[i][j]); } } double[] B = new double[t]; for(int i=0;i<=((t)-1);i++){ B[i]= indep[i]; } // double[] B = {12.5,36.5,105.5}; // int iter; //iter= Integer.parseInt(JOptionPane.showInputDialog(null, " Numero Iteraciones ")); double[]X = LibreriaBase.Seidel(test, B); //double[]X = LibreriaBase.sustitucionRegresiva(test2); String Cadena; Cadena=""; String Cadena2; Cadena2=""; for (int i = 0; i< X.length; i++){ System.out.println("X["+ (i+1) + "] = " + X[i]); if (X[i]==-969989.65555){ X[i]=0; Cadena+=("Matriz no cumple con el Metodo \n"); }
-2-

C:\Documents and Settings\USUARIO\Mis documentos\NetBeansProjects\msQuere\MS-QUARE\src\msquare\LibreriaBase.java Domingo, 02 de Febrero de 2014 01:52 p.m.

Cadena+=("X["+ (i+1) + "] = " + X[i])+"\n"; } return Cadena; } }

-3-

Anda mungkin juga menyukai