Professional Documents
Culture Documents
int j = 0;
while( j < this.cantCol){
if(varPiv > this.elem[i][j]) return false;
varPiv = this.elem[i][j];
j = j + 1;
}
i = i + 1;
}
return true;
}
public void intercambiar(int i1, int i2){
int j =0 , p = 0;
while( j < this.cantCol){
p= this.elem[i1][j];
this.elem[i1][j] = this.elem[i2][j];
this.elem[i2][j] = p;
j = j + 1;
}
}
public void generarSec(int a , int k){
int i = 0, cont = a;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
this.elem[i][j] = cont;
cont = cont + k;
j = j + 1;
}
i = i + 1;
}
}
public int aleatorio(int a , int b){
int p = Math.abs(a-b), men = 0;
if(a < b) men = a;
else men = b;
return (int)(p* Math.random())+ men;
}
i = i + 1;
j = j - 1;
}
return sum;
}
public int menorDiagP(){
int i = 0 , menor = this.elem[0][0];
while(i < this.cantFil && i < this.cantCol){
if( menor > this.elem[i][i]) menor = this.elem[i][i];
i = i + 1;
}
return menor;
}
public int menorDiagS(){
int i = 0 ,j = this.cantCol, menor = this.elem[0][this.cantCol];;
while(i < this.cantFil && j >= 0){
if( menor > this.elem[i][j]) menor = this.elem[i][i];
i = i + 1;
j = j - 1;
}
return menor;
}
public boolean igualesDiagP(){
int i = 0 , igual = this.elem[0][0];
while(i < this.cantFil && i < this.cantCol){
if( igual != this.elem[i][i]) return false;
i = i + 1;
}
return true;
}
public boolean matrizIdentidad(){
int i = 0;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
if(i == j){
if(this.elem[i][j] != 1) return false;
}
else{
if(this.elem[i][j] != 0) return false;
}
j = j + 1;
}
i = i + 1;
}
return true;
}
public void menoresCols( ArrayList L1 ){
int j = 0;
while( j < this.cantCol){
int i = 0 , men= this.elem[i][j];
while( i < this.cantFil){
if(men > this.elem[i][j])men = this.elem[i][j];
i = i + 1;
}
L1.add(men);
j = j + 1;
}
}
public void menoresFilas( ArrayList L1 ){
int i = 0;
while( i < this.cantFil){
int j = 0 , men= this.elem[i][j];
while( i < this.cantCol){
if(men > this.elem[i][j])men = this.elem[i][j];
j = j + 1;
}
L1.add(men);
i = i + 1;
}
}
public void DiagonalPrincipal( ArrayList L1){
int i = 0 ;
while(i < this.cantFil && i < this.cantCol){
L1.add(this.elem[i][i]);
i = i + 1;
}
}
public void DiagonalSecundaria( ArrayList L1){
int i = 0 ,j = this.cantCol;
while(i < this.cantFil && j >= 0){
L1.add(this.elem[i][j]);
i = i + 1;
j = j - 1;
}
}
public void sumaCols( ArrayList L1 ){
int j = 0;
while( j < this.cantCol){
int i = 0 , sum = 0;
while( i < this.cantFil){
sum = sum + this.elem[i][j];
i = i + 1;
}
L1.add(sum);
j = j + 1;
}
}
public void sumaFilas( ArrayList L1 ){
int i = 0;
while( i < this.cantFil){
int j = 0 , sum = 0;
while( i < this.cantCol){
sum = sum + this.elem[i][j];
j = j + 1;
}
L1.add(sum);
i = i + 1;
}
}
public void generarRandom( int a , int b){
int i = 0;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
this.elem[i][j] = aleatorio(a,b);
j = j + 1;
}
i = i + 1;
}
}
public void generarRandomDif( int a , int b){
int i = 0;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
int alea= 0;
alea = aleatorio(a,b);
while(this.frecuencia(alea)> 0){
alea = aleatorio(a,b);
}
this.elem[i][j] = alea;
j = j + 1;
}
i = i + 1;
}
}
public void generarRandomFila( int a , int b){
int j = 0;
while( j < this.cantCol){
int i = 0, alea = aleatorio(a,b) ;
while( j < this.cantFil){
this.elem[i][j] = alea;
i = i + 1;
}
j = j + 1;
}
}
public void generarSecuencia( int a , int k){
int i = 0, Secu = a;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
this.elem[i][j] = Secu;
Secu = Secu + k;
j = j + 1;
}
i = i + 1;
}
}
public void generarFilas(){
int i = 0;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
this.elem[i][j] = i;
j = j + 1;
}
i = i + 1;
}
}
public void generarCols(){
int j = 0;
while( j < this.cantCol){
int i = 0;
while( j < this.cantFil){
this.elem[i][j] = j;
i = i + 1;
}
j = j + 1;
}
}
public boolean mismosElem1( Matriz m2){
int i = 0;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
if(m2.frecuencia(this.elem[i][j]) == 0) return false;
j = j + 1;
}
i = i + 1;
}
return true;
}
public boolean mismosElem( Matriz m2){
return (this.mismosElem1(m2)&& m2.mismosElem1(this));
}
public boolean interseccion( Matriz m2){
int i = 0;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
if(m2.frecuencia(this.elem[i][j])> 0) return true;
j = j + 1;
}
i = i + 1;
}
return false;
}
public boolean exclusion( Matriz m2){
int i = 0;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
if(m2.frecuencia(this.elem[i][j])> 0) return false;
j = j + 1;
}
i = i + 1;
}
return true;
}
public boolean transpuesta( Matriz m2){
int i = 0;
while( i < this.cantFil){
int j = 0;
while( j < this.cantCol){
this.elem[i][j] = m2.elem[j][i];
j = j + 1;
}
i = i + 1;
}
return true;
}
public boolean subMatriz( Matriz m2){
int i = 0, m1Elem= this.cantCol* this.cantFil ;
while( i < m2.cantFil){
int j = 0;
while( j < m2.cantCol){
if(m2.elem[i][j] == this.elem[0][0]){
int m = i, i2 = 0, acum= 0 ;
while( m < m2.cantFil){
int n = j, j2 = 0;
while( n < m2.cantCol){
if(this.elem[i2][j2] == m2.elem[m][n]) acum=
acum + 1;
n = n + 1;
j2 = j2 + 1;
}
m = m + 1;
i2 = i2 + 1;
}
if( acum == m1Elem) return true;
}
j = j + 1;
}
i = i + 1;
}
return false;
}