Beispiel #1
0
Datei: kz.c Projekt: cran/kza
SEXP kz1d(SEXP x, SEXP window, SEXP iterations)
{
	int p;
	int i, k;
	int m;
	SEXP ans, tmp;
//	int n;

	m = (2 * INTEGER_VALUE(window)) + 1; 
	p = (m-1)/2;
	
//	dim = GET_DIM(x);
//	n = LENGTH(x);
	
	PROTECT(tmp = allocVector(REALSXP, LENGTH(x)));
	PROTECT(ans = allocVector(REALSXP, LENGTH(x)));
    copyVector(tmp, x);

	for(k=0; k<INTEGER_VALUE(iterations); k++) {
        for(i=0;i<LENGTH(x);i++) {
            REAL(ans)[i] = mavg1d(tmp, i, p);
        }
        /* copyMatrix (destination, source, byrow) */
   	    copyVector(tmp, ans); 
	}
	UNPROTECT(2);
	return ans;
}
Beispiel #2
0
QVector<double> KolmogorovZurbenko::kz1d(int iterations)
{
    QVector<double> *tmp = new QVector<double>(y);
    QVector<double> *ans = new QVector<double>(y.size());
    ans->fill(0.0);
    for(int i = 0; i < iterations; i++){
        for(int yi = 0; yi < y.size(); yi++){
            ans->operator [](yi) = mavg1d(*tmp, yi, WINDOW);
        }
        ans->swap(*tmp);
    }

    return *ans;
}