void Backflow_pf_wf::updateVal(Wavefunction_data * wfdata,
                        Sample_point * sample)
{

  assert(sampleAttached);
  assert(dataAttached);

  Backflow_pf_wf_data * pfaffdata;
  recast(wfdata, pfaffdata);

  if(updateEverythingVal){ 
    calcVal(sample);
    updateEverythingVal=0;
    electronIsStaleVal=0;
  }
  else { 
    for(int e=0; e< nelectrons(0)+nelectrons(1); e++) {
      if(electronIsStaleVal(e)) {
	calcVal(sample);
	//updateVal(e,sample);
	electronIsStaleVal=0;
      }
    }
  }
  
  assert(sampleAttached);
  assert(dataAttached);
}
Пример #2
0
PNM* NoiseBilateral::transform()
{
    int width  = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, image->format());

    sigma_d = getParameter("sigma_d").toInt();
    sigma_r = getParameter("sigma_r").toInt();
    radius = sigma_d;

    if(image->format() == QImage::Format_Indexed8)
    {
       for(int x=0; x<width; x++)
           for(int y=0; y<height; y++)
           {
               int l = calcVal(x, y, LChannel);
               newImage->setPixel(x, y, l);
           }
    }
    else {
       for(int x=0; x<width; x++)
           for(int y=0; y<height; y++)
           {
              int r = calcVal(x, y, RChannel);
              int g = calcVal(x, y, GChannel);
              int b = calcVal(x, y, BChannel);

              QColor newPixel = QColor(r,g,b);
              newImage->setPixel(x, y, newPixel.rgb());
           }
       }

    return newImage;
}
Пример #3
0
// optimierte Implementierung; es werden Symmetrien genutzt
int alignsDyn (int m, int n, int* counter)
{
	// Deklaration Schleifenvariablen und Wert des aktuellen Feldes
	int i,j;
	// Deklaration der Tabelle (m+1)x(n+1)  mit den Aligns; und
	// Speicherreservierung
	int* table = (int *) malloc((m+1)*(n+1)*sizeof(int));
	// an dieser Stelle Verabschiedung von m und n,
	// es sind nur max und min wichtig; moeglich, da m und n bei der
	// Anzahl Aligns kommutieren [aligns(m,n) = aligns(n,m)]
	int min = MIN(m,n);
	int max = MAX(m,n);
	/* fuellen der dynamischen Tabelle
	   zentrale Tricks fuer Minimierung der Zugriffe:
	   1. nutze Symmetrien wenn moeglich (fuer die min x min Submatrix)
	   2. Berechnung der halben Matrix ist ausreichend
	   ANMERKUNG: die Anzahl der Zeilen ist min+1, die Anzahl der Spalten
	   ist max+1;
	   asymptotische Laufzeit bleibt aber O(n*m) */
	for (i = 0; i <= min; i++)
	{
		for (j = i; j <= min; j++)
		{
			calcVal(table, i, j, max+1, counter);
		}
	}
	*counter += 1;
	// nutze Eigenschaft, dass Anzahl Spalten max+1 und Anzahl Zeilen min+1
	//
	for (i = 0; i <= min; i++)
	{
		for (j = min+1; j <= max; j++)
		{
			calcVal(table, i, j, max+1, counter);
		}
	}
	// nur Kontrolle: Ausgabe der Tablle (auch hier: max+1 Spalten)
	printf("--- Dynamische Tabelle ---\n");
	for (i = 0; i <= min; i++)
	{
		for (j = 0; j <= max; j++)
		{
			printf("%d;", table[i*(max+1)+j]);
		}
		printf("\n");
	}
	printf("--------------------------\n");
	
	// das Ergebnis befindet sich in dem letzten Feld des Arrays
	int result = table[(m+1)*(n+1)-1];
	free (table);
	return result;
}
Пример #4
0
float trapeziumIntegrate(TreeNode* tree, float a, float b, int n)
{
	if (a > b)
		throw "a must be less than b";

	float h = (b - a) / n;

	float result = 0;
	float prevX = calcVal(tree, a);
	for (int i = 1; i <= n; i++)
	{
		float curX = calcVal(tree, a + h * i);
		result += prevX + curX;
		prevX = curX;
	}

	return result * h / 2;
}
// The core integration routine. 
static void doIntegrate(
	// specify function and endpoints
	QuadFcn			quadFcn,
	int				x1,
	int				x2,
	
	// quadrature parameters
	QuadType		quadType,			// QT_Gaussian, etc.
	int				primaryPrecision,
	int				secondaryPrecision,
	
	// result written here
	mp_real			&result)
{
    ArprecIntegrate<mp_real> *integrator;
	int tableSize = TABLE_SIZE_DEF;
	
	if(primaryPrecision > 800) {
		tableSize = TABLE_SIZE_LARGE;
	}
	switch(quadType) {
		case QT_Gaussian:
			integrator = new QuadGS(LEVEL_GAUSS_DEF, tableSize, 
				-primaryPrecision, -primaryPrecision,
				DEBUG_LEVEL_DEF);
			break;
		case QT_ErrFunc:
			integrator = new QuadErf(LEVEL_DEF, tableSize, 
				-primaryPrecision, -secondaryPrecision,
				DEBUG_LEVEL_DEF);
			break;
		case QT_TanhSinh:
			integrator = new QuadTS(LEVEL_DEF, tableSize, 
				-primaryPrecision, -secondaryPrecision,
				DEBUG_LEVEL_DEF);
			break;
	}
	
    int nwords1 = integrator->getPrecWd1();
    int nwords2 = integrator->getPrecWd2();

	// Create endpoints with precision getPrecWd2()
    mp::mpsetprecwords(nwords2);
    mp_real x1Real((double)x1);
	mp_real x2Real((double)x2);
	
	// Create result with precision getPrecWd1()
    mp::mpsetprecwords(nwords1);
    mp_real calcVal(0.0);
	
    calcVal = integrator->integrate(quadFcn, x1Real, x2Real);
	result = calcVal;
}
PNM* NoiseBilateral::transform()
{
    int width  = image->width();
    int height = image->height();

    PNM* newImage = new PNM(width, height, image->format());

    sigma_d = getParameter("sigma_d").toInt();
    sigma_r = getParameter("sigma_r").toInt();
    radius = sigma_d;
    Mode mode = RepeatEdge;
    QRgb pixel;
    int r,g,b;
    if(image->format() == QImage::Format_RGB32){
        for(int x=0;x<width;x++){
            for(int y=0;y<height;y++){
                pixel = getPixel(x,y,mode);

                r=calcVal(x,y,RChannel);
                g=calcVal(x,y,GChannel);
                b=calcVal(x,y,BChannel);
                QColor newPixel = QColor(r,g,b);
                newImage->setPixel(x,y,newPixel.rgb());
            }
        }
    }
    else if(image->format() == QImage::Format_Indexed8){
        for(int x=0;x<width;x++){
            for(int y=0;y<height;y++){
                int temp = calcVal(x,y,LChannel);
                newImage->setPixel(x,y,temp);
            }
        }
    }
    return newImage;
}
void Backflow_pf_wf::updateVal(int e, Sample_point * sample) { 
  int nlist; Array1 <int> list;
  parent->bfwrapper.getNeighbors(sample,jast,e,list,nlist);
  cout << "nlist " << nlist << endl;
  calcVal(sample);
}