Skip to content

Commit e8310ba

Browse files
authored
Merge pull request #5 from francesco086/multi_component_wf
Multi component wf
2 parents 5875efd + 5815249 commit e8310ba

File tree

7 files changed

+33
-19
lines changed

7 files changed

+33
-19
lines changed

debug/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class Gauss: public MCISamplingFunctionInterface
5959
}
6060
}
6161

62-
double getAcceptance()
62+
double getAcceptance(const double * protoold, const double * protonew)
6363
{
64-
return exp(-(getProtoNew(0)-getProtoOld(0)));
64+
return exp(-(protonew[0]-protoold[0]));
6565
}
6666
};
6767

doc/user_manual.pdf

180 Bytes
Binary file not shown.

doc/user_manual.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ \subsection{MCI sampling function interface} % (fold)
344344
\begin{verbatim}
345345
< MCISamplingFunctionInterface(const int &ndim, const int &nproto);
346346
< virtual void samplingFunction(const double *in, double * protovalue) = 0;
347-
< virtual double getAcceptance() = 0;
347+
< virtual double getAcceptance(const double * protoold, const double * protonew) = 0;
348348
> int getNDim();
349349
> int getNProto();
350350
> double getProtoNew(const int &i);
@@ -378,9 +378,9 @@ \subsection{MCI sampling function interface} % (fold)
378378
}
379379
}
380380
381-
double getAcceptance()
381+
double getAcceptance(const double * protoold, const double * protonew)
382382
{
383-
return exp(-( this->getProtoNew(0) - this->getProtoOld(0) ));
383+
return exp(-( protonew[0] - protoold[0] ));
384384
}
385385
};
386386
\end{verbatim}

examples/ex1/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class NormalizedLine: public MCISamplingFunctionInterface{
3939
protovalue[0] = 0.2 * abs(in[0]);
4040
}
4141

42-
double getAcceptance(){
43-
return this->getProtoNew(0) / this->getProtoOld(0);
42+
double getAcceptance(const double * protoold, const double * protonew){
43+
return protonew[0] / protoold[0];
4444
}
4545
};
4646

examples/ex2/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ class NN2Sampling: public MCISamplingFunctionInterface{
9696
protovalues[0] = v*v;
9797
}
9898

99-
double getAcceptance(){
100-
return getProtoNew(0)/getProtoOld(0);
99+
double getAcceptance(const double * protoold, const double * protonew){
100+
return protonew[0]/protoold[0];
101101
}
102102
};
103103

examples/ex3/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class MyInterfaces: public MCISamplingFunctionInterface, public MCIObservableFun
5252
protovalues[0] = v*v;
5353
}
5454

55-
double getAcceptance(){
56-
if (getProtoOld(0) == 0.) return 1.;
57-
return getProtoNew(0)/getProtoOld(0);
55+
double getAcceptance(const double * protoold, const double * protonew){
56+
if (protoold[0] == 0.) return 1.;
57+
return protonew[0]/protoold[0];
5858
}
5959

6060
void callBackFunction(const double * in, const bool flag_observation){

src/MCISamplingFunctionInterface.hpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,30 @@ class MCISamplingFunctionInterface
1313
public:
1414
MCISamplingFunctionInterface(const int &ndim, const int &nproto)
1515
{
16-
_ndim=ndim; _nproto=nproto;
17-
_protonew = new double[nproto]; _protoold = new double[nproto];
18-
for (int i=0; i<nproto; ++i){ _protonew[i]=0.; }
19-
for (int i=0; i<nproto; ++i){ _protoold[i]=0.; }
16+
_ndim=ndim;
17+
_protonew = 0; _protoold = 0;
18+
setNProto(nproto);
2019
}
2120
virtual ~MCISamplingFunctionInterface()
2221
{
2322
delete[] _protonew; delete[] _protoold;
2423
}
2524

25+
26+
// Setters
27+
void setNProto(const int &nproto){
28+
_nproto=nproto;
29+
if (_protonew != 0) delete[] _protonew;
30+
if (_protoold != 0) delete[] _protoold;
31+
_protonew = new double[_nproto]; _protoold = new double[_nproto];
32+
for (int i=0; i<_nproto; ++i){ _protonew[i]=0.; }
33+
for (int i=0; i<_nproto; ++i){ _protoold[i]=0.; }
34+
}
35+
36+
2637
// Getters
2738
int getNDim(){ return _ndim;}
2839
int getNProto(){ return _nproto;}
29-
double getProtoNew(const int &i){ return _protonew[i]; }
30-
double getProtoOld(const int &i){ return _protoold[i]; }
3140

3241
// Utilities
3342
void newToOld()
@@ -40,13 +49,18 @@ class MCISamplingFunctionInterface
4049
samplingFunction(in, _protonew);
4150
}
4251

52+
double getAcceptance(){
53+
return getAcceptance(_protoold, _protonew);
54+
}
55+
56+
4357
// --- METHODS THAT MUST BE IMPLEMENTED
4458
// Function that MCI uses for the proto-sampling function. Computes _protonew
4559
virtual void samplingFunction(const double *in, double * protovalues) = 0;
4660
// ^walker position ^resulting proto-values
4761

4862
// Acceptance function, that uses the new and old values of the proto sampling function
49-
virtual double getAcceptance() = 0;
63+
virtual double getAcceptance(const double * protoold, const double * protonew) = 0;
5064
};
5165

5266

0 commit comments

Comments
 (0)