V
vaneric
hi
i am studying linear algebra and was reading thru some code processing
image data.i came across a piece of code that does some normalising as
below
public demoNorm(double[][] eigenfacesArray){
for(int i=0;i<eigenfacesArray.length;i++){
double norm=norm(eigenfacesArray);
for(int x=0;x<eigenfacesArray.length;x++){
double v=eigenfacesArray[x];
eigenfacesArray[x]=v/norm;
}
}
}
private double norm(double[][] x){
int nr= x.length;
int nc= x[0].length;
double val=0.0;
for(int r= 0; r< nr; r++){
for(int c= 0; c< nc; c++){
val+= (x[r][c])* (x[r][c]) ;
}
}
return val;
}
when i tried this for a sample double[][] as below
double[][]=new double[][]{
{2.4,6.4,1.2,7.6,4.3},
{1.5,3.1,6.4,5.7,2.5},
{7.8,6.8,4.6,3.5,4.3},
{9.8,7.8,6.5,1.2,3.3}
};
i found that norm() yields a value equal to square of Frobenius norm
( ie ,norm()==> 586.410 while Frob norm=24.2159)
I am no expert in linear algebra,so i want to know if this norm has
any particular name.Also,is the above way of normalisation valid? or
do i have to find the sq.root of norm before i divide the elements of
the double[][]? can some experts help me with this?
thanks
eric
i am studying linear algebra and was reading thru some code processing
image data.i came across a piece of code that does some normalising as
below
public demoNorm(double[][] eigenfacesArray){
for(int i=0;i<eigenfacesArray.length;i++){
double norm=norm(eigenfacesArray);
for(int x=0;x<eigenfacesArray.length;x++){
double v=eigenfacesArray[x];
eigenfacesArray[x]=v/norm;
}
}
}
private double norm(double[][] x){
int nr= x.length;
int nc= x[0].length;
double val=0.0;
for(int r= 0; r< nr; r++){
for(int c= 0; c< nc; c++){
val+= (x[r][c])* (x[r][c]) ;
}
}
return val;
}
when i tried this for a sample double[][] as below
double[][]=new double[][]{
{2.4,6.4,1.2,7.6,4.3},
{1.5,3.1,6.4,5.7,2.5},
{7.8,6.8,4.6,3.5,4.3},
{9.8,7.8,6.5,1.2,3.3}
};
i found that norm() yields a value equal to square of Frobenius norm
( ie ,norm()==> 586.410 while Frob norm=24.2159)
I am no expert in linear algebra,so i want to know if this norm has
any particular name.Also,is the above way of normalisation valid? or
do i have to find the sq.root of norm before i divide the elements of
the double[][]? can some experts help me with this?
thanks
eric