-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNormas.java
More file actions
91 lines (82 loc) · 2.75 KB
/
Normas.java
File metadata and controls
91 lines (82 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import java.util.Arrays;
public class Normas
{
// instance variables - replace the example below with your own
private int x;
Matrices matriz = new Matrices();
/**
* Constructor for objects of class Normas
*/
public Normas()
{
// initialise instance variables
}
public double normaInfinito(double[][] matrix)
{
System.out.println("Norma A\u221E");
double sumatoria = 0;
double mayor = 0;
String fraccion = "";
int n = matrix.length;
int m = matrix[0].length;
matriz.mostrarMatrix(matrix);
System.out.print(" "+n+"X"+m+"\n");
for(int i = 0;i < n;i++){
sumatoria = 0;
for(int j = 0;j< m;j++){
sumatoria = sumatoria + Math.abs(matrix[i][j]);
}
fraccion = matriz.decimalToFraction(sumatoria);
System.out.print("i = "+(i+1)+" "+sumatoria+" en fraccion: "+fraccion+"\n");
if(mayor<sumatoria){
mayor = sumatoria;
}
}
System.out.println("El mayor es "+mayor);
//System.out.println("\u03B1\u03B2\u03B3");
return mayor;
}
public double normaUno(double[][] matrix){
System.out.println("Norma A\u2081");
double sumatoria = 0;
int n = matrix.length;
int m = matrix[0].length;
double mayor = 0;
matriz.mostrarMatrix(matrix);
System.out.print(" "+n+"X"+m+"\n");
for(int i = 0;i <= m-1;i++){
sumatoria = 0;
for(int j = 0;j<=n-1;j++){
sumatoria = sumatoria + Math.abs(matrix[j][i]);
}
System.out.print("j = "+(i+1)+" "+sumatoria+"\n");
if(mayor<sumatoria){
mayor = sumatoria;
}
}
System.out.println("El mayor es A\u2081 = "+mayor);
return mayor;
}
public void normaDos(double[][] matrix){
System.out.println("Norma A\u2082");
double[][] transpuesta;
double[][] multiplicado;
transpuesta = matriz.matrixTranspuesta(matrix);
multiplicado = matriz.multiplicacion(transpuesta,matrix);
//En la formula es A^t*A = A transpuesta por A en ese orden OJO
matriz.mostrarMatrix(transpuesta);
matriz.mostrarMatrix(matrix);
System.out.println("");
matriz.mostrarMatrixJunta(multiplicado);
}
public double normaInfinitoColumna(double[] a){
double resultado = 0.0;
for(int i = 0; i < a.length;i++){
if(Math.abs(a[i]) > resultado){
resultado = Math.abs(a[i]);
}
}
System.out.printf("dexp: %f\n",resultado);
return resultado;
}
}