src/tests/trans/test_transgeneral.cc
//-----------------------------------------------------------------------------
// Compute root mean square of difference between two arrays divided by maximum
// absolute value of second array
//
// Author:
// Andreas Mueller *ECMWF*
//
Compute root mean square of difference between two arrays divided by maximum
absolute value of second array

Andreas Mueller *ECMWF
Compute root mean square of difference between two arrays divided by maximum absolute value of second array Andreas Mueller * ECMWF
double compute_rms(const size_t N,   
                   double array1[],  
                   double array2[])  
{
    double rms = 0., rmax = 0.;
    for (size_t idx = 0; idx < N; idx++) {
        double diff = array1[idx] - array2[idx];
        rms += diff * diff;
        rmax = std::max(rmax, std::abs(array2[idx]));
    }
    if (rmax == 0.) {
        rms = 0.;
    }
    else {
        rms = std::sqrt(rms / N) / rmax;
    }
    return rms;
}
double compute_rms ( const size_t N , double array1 [ ] , double array2 [ ] ) { double rms = 0. , rmax = 0. ; for ( size_t idx = 0 ; idx < N ; idx ++ ) { double diff = array1 [ idx ] - array2 [ idx ] ; rms += diff * diff ; rmax = std :: max ( rmax , std :: abs ( array2 [ idx ] ) ) ; } if ( rmax == 0. ) { rms = 0. ; } else { rms = std :: sqrt ( rms / N ) / rmax ; } return rms ; }
Compute root mean square of difference between two arrays divided by maximum
absolute value of second array
Compute root mean square of difference between two arrays divided by maximum absolute value of second array
// length of the arrays // first of the two arrays // second of the two arrays