|
[Sponsors] |
February 27, 2017, 16:05 |
printing the output of the given program
|
#1 |
New Member
Ashutosh Sharma
Join Date: Jan 2017
Posts: 11
Rep Power: 9 |
I need to print the values of 'ff' in the following program, how can i do it:
#include <stdlib.h> #include <math.h> #define fmin 1 #define fmax 100 #define DeltaF 1 #define NumSeg 100 #define NumFre 50 #define dF 1 float Normal_Distribution_Random(double mean, double stand_val); main() { double func_val[3]; double fnm[NumFre][NumSeg]; double fmean[NumSeg]; double x1, x2; double ff; double Rjnm[3][NumFre][NumSeg]; int ii, j, k; fmean[0]=fmin; for (ii=1; ii<NumSeg; ii++) { fmean[ii]=fmean[ii-1]+dF; } for (j=0; j<NumSeg; j++) { for (k=0; k<NumFre; k++) { Normal_Distribution_Random(fmean[j], DeltaF); fnm[k][j]=ff; } } for (ii=0; ii<3; ii++) { for (j=0; j<NumSeg; j++) { for (k=0; k<NumFre; k++) { Normal_Distribution_Random(0, 1); Rjnm[ii][k][j]=ff; } } } } float Normal_Distribution_Random(double mean, double stand_val) { double u1, u2, w, mult,call,ff; int flag; double x1,x2; flag=1; w=0; if (call==1) { call=!call; ff=mean+stand_val*x2; } else { while (flag==1) { u1=-1+((double)rand()/RAND_MAX)*2; u2=-1+((double)rand()/RAND_MAX)*2; w=pow(u1, 2)+pow(u2, 2); if (w>0 && w<1) { flag=0; } } mult=sqrt((-2*log(w))/w); x1=u1*mult; x2=u2*mult; call=!call; ff=mean+stand_val*x1; } return(ff); } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Polyflow- Parameterize Torque and fowrate output | jy tey | ANSYS | 0 | December 20, 2016 23:57 |
Output of velocity gradients | wersoe | OpenFOAM Programming & Development | 13 | June 24, 2016 10:54 |
error in program: | mani.rajendiran | Fluent UDF and Scheme Programming | 0 | March 22, 2012 12:25 |
Questions about data output | aki_yafuji | OpenFOAM Running, Solving & CFD | 3 | September 9, 2010 02:59 |
lift and drag on ship superstructures | vaina74 | OpenFOAM Running, Solving & CFD | 3 | June 8, 2010 13:30 |