Skip to content

Commit

Permalink
minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
teknasd authored Feb 7, 2018
1 parent b890e0c commit 8d32615
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
33 changes: 27 additions & 6 deletions LatticeStuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 4,15 @@
void create_Bmat_bimodal(std::vector <float>& Bmat,float del)
{
long i = 0, var = 0, count1 = 0, count2 = 0;
std::uniform_int_distribution<int> distr(0, 1000);
std::uniform_int_distribution<int> distr(0, 10000);
std::random_device rand_dev;
std::mt19937 generator(rand_dev());
std::cout << "B mtrix ->" << tab;
for (i = 0; i < N; i )
{
//Bmat[i] = distr(generator);// floor(rand() / 1000);
var = distr(generator);
if (var < 500)
if (var < 5000)
{
Bmat[i] = del;
count1 ;
Expand All @@ -28,6 28,25 @@ void create_Bmat_bimodal(std::vector <float>& Bmat,float del)

}

//
void update_Bmat_bimodal(std::vector <float>& Bmat, float del)
{
for (int i = 0; i < N; i )
{

if (Bmat[i] > 0)
{
Bmat[i] = del;

}
else
{
Bmat[i] = -del;

}
//std::cout << Bmat[i] << d;
}
}
// http://www.cplusplus.com/reference/random/normal_distribution/
void create_Bmat_gaussian(std::vector <float>& Bmat,float del)
{
Expand Down Expand Up @@ -168,7 187,8 @@ void printMatrix(std::vector<int> & M, int len) {

void savedata(std::vector< int > & Mat,int l,float del,std::string s)
{
std::ofstream fobj(s "-" std::to_string(l) "-" std::to_string(del) ".csv");
int delta = int(del * 10);
std::ofstream fobj(s "-" std::to_string(l) "-" std::to_string(delta) ".csv");
//fobj << "iteration : " << l << "\ndelta : " << del << std::endl;
int j;
Mat.erase(Mat.begin() 1);
Expand All @@ -179,7 199,7 @@ void savedata(std::vector< int > & Mat,int l,float del,std::string s)

for (int i = 0; i < N; i )
{
if (i%VER == 0) fobj << std::endl;
if (i%VER == 0 && i) fobj << std::endl;
fobj << Mat[i]<<",";

}
Expand All @@ -195,15 215,16 @@ void savedata(std::vector< int > & Mat,int l,float del,std::string s)

void savedata(std::vector< float > & Mat, int l, float del, std::string s)
{
std::ofstream fobj(s "-" std::to_string(l) "-" std::to_string(del) ".csv");
int delta = int(del * 10);
std::ofstream fobj(s "-" std::to_string(l) "-" std::to_string(delta) ".csv");
//fobj << "iteration : " << l << "\ndelta : " << del << std::endl;



for (int i = 0; i < N; i )
{

if (i%VER == 0) fobj << std::endl;
if (i%VER == 0 && i) fobj << std::endl;
fobj << Mat[i] << ",";

}
Expand Down
5 changes: 3 additions & 2 deletions RFIM_2D_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 48,8 @@ int main(void) {

create_CapacityMat(CapacityMat, Exmat);
cout << "created CapacityMatrix" << endl;

/* =====================CREATING BMAT ===================================*/
create_Bmat_bimodal(Bmat, 1);
/* =================== LOOP TO ITERATE OVER RANGE OF DELTA ============= */

for (float del = del_beg; del <= del_end; del = del_inc)
Expand All @@ -58,7 59,7 @@ int main(void) {

/* =========================== BETA MATRIX (Bmat)======================= */

create_Bmat_bimodal(Bmat,del); // UNCOMMENT FOR BIMODAL DISTRIBUTION
update_Bmat_bimodal(Bmat,del); // UNCOMMENT FOR BIMODAL DISTRIBUTION
//create_Bmat_gaussian(Bmat,del); // UNCOMMENT FOR GAUSSIAN DISTRIBUTION
cout << "Bmat created" << endl;
//printMatrix(Bmat, N);
Expand Down

0 comments on commit 8d32615

Please sign in to comment.