Sistemas De Ecuaciones

Páginas: 6 (1408 palabras) Publicado: 9 de junio de 2012
////////// SistemaEcuaciones.java

package com.welsungo.math;

import com.welsungo.math.exceptions.NoUniqueSolutionException;

/*

* Created on 13-feb-04

*

* To change the template for this generated file go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

/**

* @author felipe

*

* To change the template for this generated type commentgo to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

public class SistemaEcuaciones {

private double mCoef[][];

private int mNumEcs;

/**

* @return

*/

public int getNumEcs() {

return mNumEcs;

}

/**

* @param i

*/

public void setNumEcs(int i) {

mNumEcs = i;

}

/**

* @return

*/

public double[][] getCoef() {return mCoef;

}

/**

* @param ds

*/

public void setCoef(double[][] ds) {

mCoef = ds;

}

public double[] getSolucion() {

double x;

double y;

int j;

int i;

int k;

for(j=0; j < mNumEcs; j++) {

//Encontramos la primera ecuacion con un coeficiente no cero

//en la columna (ecuación) que estemos mirando (j)

for(i=j; i < mNumEcs; i++){if(mCoef[i][j] != 0D) {

break;

}

throw new NoUniqueSolutionException(

Messages.getString("SistemaEcuaciones.SolucionNoUnica"));

}

//(+) Movemos esa ecuación a la primera fila

for(k=0; k < mNumEcs+1; k++){

x = mCoef[j][k];

mCoef[j][k] = mCoef[i][k];

mCoef[i][k] = x;

}

//(+) Obtenemos un coeficiente unidad en la primera columna no cero

y = 1/mCoef[j][j];

for(k=0; k< mNumEcs+1; k++){

mCoef[j][k]=y*mCoef[j][k];

}

for(i=0; i < mNumEcs; i++){

y = -mCoef[i][j];

for(k=0; k < mNumEcs+1; k++){

if(i==j) break;

mCoef[i][k]=mCoef[i][k]+y*mCoef[j][k];

}

}

}

double dRet[] = new double[mNumEcs];

for(i=0; i < mNumEcs; i++){

double dRes1 = mCoef[i][mNumEcs]*1000+0.5;

int iRes = (int)dRes1;

double dRes2 = iRes/1000D;dRet[i] = dRes2;

}

for(i=0; i < mNumEcs; i++){

System.out.println("x("+i+")= "+dRet[i]);

}

return dRet;

}

}

////////// AppSystemEqs.java

/*

* Created on 22-feb-2004

*

* To change the template for this generated file go to

* Window>Preferences>Java>Code Generation>Code and Comments

*/

package com.welsungo.math;

importjava.applet.Applet;

import java.awt.*;

import java.awt.im.*;

import java.awt.event.*;

import java.beans.PropertyVetoException;

import symantec.itools.awt.BorderPanel;

import symantec.itools.awt.DirectionButton;

import com.welsungo.math.exceptions.NoUniqueSolutionException;

/**

* @author felipe

*

* To change the template for this generated type comment go to

*Window>Preferences>Java>Code Generation>Code and Comments

*/

public class AppSystemEqs extends Applet {

private boolean mHayComa;

private Label labNumEcs = null;  

private Label labEc = null;

private TextField txtNumEcs = null;

private TextField txtCoef = null;

private Label labCoef = null;

private Button btnOk = null;

private DirectionButton btnNext = null;

privateBorderPanel panSol = null;

private double[][] mCoef;

private int mNumEcs;

private Button btnCalcular = null;

/**

* This is the default constructor

*/

public AppSystemEqs() {

super();

init();

}

/**

* This method initializes this

*

* @return void

*/

public void init() {

this.setLayout(null);

this.add(getLabCoef(), null);

this.add(getTxtNumEcs(),null);

this.add(getBtnOk(), null);

this.add(getTxtCoef(), null);

this.add(getLabEc(), null);

this.add(getLabNumEcs(), null);

this.add(getBtnNext(), null);

this.add(getBtnCalcular(), null);

this.add(getPanSol(), null);

this.setBackground(new Color(154,169,194));

this.setSize(364, 300);

}

/**

* This method initializes labNumEcs

*

* @return Label

*/...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • SISTEMA DE ECUACIONES
  • Sistema De Ecuaciones
  • Que Es Un Sistema De Ecuacion
  • sistemas de ecuaciones
  • Sistema de ecuaciones
  • Sistema de ecuaciones
  • Sistemas De Ecuaciones
  • Sistemas de Ecuaciones

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS