//metodos public int encontrarMatriz(string nombre) { int resultado = 1; for (int i = 0; i < Coleccion.Count; i++) { Matrices tmpMatriz = (Matrices)Coleccion[i]; string dato = tmpMatriz.getNombre(); if (nombre.Equals(dato)) { resultado = i; } } return(resultado); }
public Matrices resta(Matrices matrizA, Matrices matrizB) { Matrices resultado; resultado = new Matrices(matrizA.getRenglon(), matrizA.getColumna()); resultado.setNombre("Resta de " + matrizA.getNombre() + " - " + matrizB.getNombre()); for (int i = 0; i < matrizA.getRenglon(); i++) { for (int j = 0; j < matrizA.getColumna(); j++) { resultado.setElemento(i, j, matrizA.getElemento(i, j) - matrizB.getElemento(i, j)); }//i Console.WriteLine(""); }//j return resultado; }
public void MenuOM() { try { Console.Clear(); this.NombreMenu("Multiplicacion"); Matrices primeraMatriz = new Matrices(); Matrices segundaMatriz = new Matrices(); Matrices resultadoMatriz = new Matrices(); Operaciones miOperacion = new Operaciones(); string nombre1, nombre2; Console.Clear(); this.Instrucciones("Ingrese el nombre de la matriz 1: "); nombre1 = Console.ReadLine(); for (int i = 0; i < Coleccion.Count; i++) { Matrices tmpMatriz = (Matrices)Coleccion[i]; if (tmpMatriz.getNombre() == nombre1) { this.setPosicion1(i); } } this.Instrucciones("Ingrese el nombre de la matriz 2: "); nombre2 = Console.ReadLine(); for (int j = 0; j < Coleccion.Count; j++) { Matrices tmpMatriz = (Matrices)Coleccion[j]; if (tmpMatriz.getNombre() == nombre2) { this.setPosicion2(j); } } primeraMatriz = (Matrices)Coleccion[this.getPosicion1()]; segundaMatriz = (Matrices)Coleccion[this.getPosicion2()]; //se realiza la operacion resultadoMatriz = miOperacion.multiplicacion(primeraMatriz, segundaMatriz); Coleccion[0] = resultadoMatriz; } catch (Exception) { this.MenuOM(); } this.MenuO(); }
public void MenuVI() { string nombre; Console.Clear(); this.NombreMenu("Individual"); Console.WriteLine("NOTA: El nombre debe ser como lo guardo, de lo contrario no va a aparecer"); this.Instrucciones("Ingrese el nombre de la matriz a buscar: "); nombre = Console.ReadLine(); for (int i = 0; i < Coleccion.Count; i++) { Matrices tmpMatriz = (Matrices)Coleccion[i]; if (tmpMatriz.getNombre() == nombre) { Console.Clear(); tmpMatriz.verContenido(); } } this.espera(); this.MenuV(); }
public Matrices multiplicacion(Matrices matrizA, Matrices matrizB) { Matrices resultado; resultado = new Matrices(matrizA.getRenglon(), matrizB.getColumna()); resultado.setNombre("Multiplicacion de " + matrizA.getNombre() + " * " + matrizB.getNombre()); int tope = matrizA.getColumna(); double tmp = 0; for (int i = 0; i < tope; i++) { for (int j = 0; j < tope; j++) { tmp = 0; for (int k = 0; k < tope; k++) { tmp = tmp + (matrizA.getElemento(k, i) * matrizB.getElemento(j, k)); } resultado.setElemento(j, i, tmp); } } return resultado; }