-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgaussiana_2.cpp
64 lines (62 loc) · 1.3 KB
/
gaussiana_2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<iostream>
#include<fstream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;
double maxi, desv=0.1, pos;
double e=2.71828182;
double mini=-20.000;
double max=20.0000;
double paso=0.1;
int i;
int j;
int Nat;
void crear_gaussiana(double pos, double maxi, double desv, int num_ptos=400, string aux="salida.tmp")
{
//// UTILIZAR UN MESH REGULAR Y UNICO A TODAS LAS CAMPANAS GAUSSIANAS
double x, y; // capaz que ni se necesita
ofstream salida(aux,std::ios_base::app);
for(j=0;j<num_ptos;j++)
{
x=mini+(j*paso);
y=maxi*pow(e,-( pow(x-pos,2) )/( 2*pow(desv,2) ) );
salida<<x<<" "<<y<<endl;
}
}
int int_pipe(string cmd,int defecto=0)
{
string data;
FILE * stream;
const int max_buffer = 256;
char buffer[max_buffer];
cmd.append(" 2>&1");
stream = popen(cmd.c_str(), "r");
if (stream)
{
while (!feof(stream))
if (fgets(buffer, max_buffer, stream) != NULL) data.append(buffer);
pclose(stream);
}
if(data.length()>1)
{
return stoi(data);
}
else
{
return defecto;
}
}
int main(int argc, char **argv)
{
ifstream current(argv[1]);
Nat=stoi(argv[2]);
desv=stod(argv[3]);
for(i=0;i<Nat;i++)
{
current>>pos>>maxi;
crear_gaussiana(pos,maxi,desv);
}
current.close();
return 0;
}