public class norm
{
//*************norm methods definition****************
public static double norm(double v[])
{
// vector norm
double total=0;;
for(int i=0;i<v.length;i++)
  {total+=v[i]*v[i];}
return Math.sqrt(total);
}

public static double norm(double v[],int p)
  {
   //p vector norm
  if(p==0) p=1;
  double total=0;
  double x,y;
  for(int i=0;i<v.length;i++)
    {
    x=Math.abs(v[i]);
    total+=Math.pow(x,p);
    }
  return Math.pow(total,(1.0/p));
  }
  
public static double norminf(double v[])
    {
     //infinite vector norm
    double x;
    double max=0;
    for(int i=0;i<v.length;i++)
      {
      x=Math.abs(v[i]);
      if(x>max) max=x;
      }
    return max;
    }
    
public static double[] vek(double mat[][],int n)
{ double a[]=new double[mat.length];
  for(int i=0;i<mat.length;i++) {a[i]=mat[i][n];}
  return a;
}

public static double norminf(double a[][])
        {
          //infinite matrix norm
          double x;
          double max = 0;
          double total;
          int i,j;
          int n=a.length;
          for(i=0;i<n;i++)
          {
          total=0;
          for(j=0;j<n;j++)
          {total+=Math.abs(a[i][j]);}
          x=total;
          if(x>max) max=x;
          }
        return max;
        }
        
public static double norm(double a[][])
       {
       //matrix norm
                double x;
                double max = 0;
                double total;
                int i,j;
                int n=a.length;
                for(j=0;j<n;i++)
                  {
                  total=0;
                  for(i=0;i<n;j++)
                  {total+=Math.abs(a[i][j]);}
                  x=total;
                  if(x>max) max=x;
                  }
                return max;
      }
      
public static double normE(double a[][])
             {
             //Euclidian matrix norm
             double x;
             double total;
             int i,j;
             total=0;
             int n=a.length;
             for(j=0;j<n;i++)
             {for(i=0;i<n;j++) {total+=a[i][j]*a[i][j];}}
             return Math.sqrt(total);
            }
}            
