/*************************************************************************
Problem testing
*************************************************************************/
static void testproblem(const ap::real_2d_array& a, int n)
{
    ap::real_2d_array b;
    ap::real_2d_array h;
    ap::real_2d_array q;
    ap::real_2d_array t1;
    ap::real_2d_array t2;
    ap::real_1d_array tau;
    int i;
    int j;
    double v;

    makeacopy(a, n, n, b);
    
    //
    // Decomposition
    //
    rmatrixhessenberg(b, n, tau);
    rmatrixhessenbergunpackq(b, n, tau, q);
    rmatrixhessenbergunpackh(b, n, h);
    
    //
    // Matrix properties
    //
    for(i = 0; i <= n-1; i++)
    {
        for(j = 0; j <= n-1; j++)
        {
            v = ap::vdotproduct(q.getcolumn(i, 0, n-1), q.getcolumn(j, 0, n-1));
            if( i==j )
            {
                v = v-1;
            }
            properrors = properrors||fabs(v)>threshold;
        }
    }
    for(i = 0; i <= n-1; i++)
    {
        for(j = 0; j <= i-2; j++)
        {
            properrors = properrors||h(i,j)!=0;
        }
    }
    
    //
    // Decomposition error
    //
    t1.setbounds(0, n-1, 0, n-1);
    t2.setbounds(0, n-1, 0, n-1);
    internalmatrixmatrixmultiply(q, 0, n-1, 0, n-1, false, h, 0, n-1, 0, n-1, false, t1, 0, n-1, 0, n-1);
    internalmatrixmatrixmultiply(t1, 0, n-1, 0, n-1, false, q, 0, n-1, 0, n-1, true, t2, 0, n-1, 0, n-1);
    decomperrors = decomperrors||matrixdiff(t2, a, n, n)>threshold;
}
Пример #2
0
Файл: ssdiff.c Проект: cran/amei
double ssdiff(double **A, double **B, unsigned int M1,
	      unsigned int M2)
{
  double sum;	
  double **C;
  unsigned int  i, j;
  
  C = matrixdiff(A,B,M1,M2);
  
  sum = 0;
  
  for(i=0; i<M1; i++){
    for(j=0; j<M2; j++){
      sum= sum + C[i][j] * C[i][j];
    }
  }
  
  delete_matrix(C);
  
  return(sqrt(sum)/(M1*M2));
}