Click here to Skip to main content
15,884,353 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: problem returning arrays Pin
aaadetos15-Feb-05 16:12
aaadetos15-Feb-05 16:12 
GeneralRe: problem returning arrays Pin
$8816-Feb-05 20:30
$8816-Feb-05 20:30 
GeneralRe: problem returning arrays Pin
Branislav17-Feb-05 0:19
Branislav17-Feb-05 0:19 
GeneralRe: problem returning arrays Pin
aaadetos22-Feb-05 1:27
aaadetos22-Feb-05 1:27 
GeneralRe: problem returning arrays Pin
Branislav22-Feb-05 22:56
Branislav22-Feb-05 22:56 
GeneralRe: problem returning arrays Pin
$8816-Feb-05 0:14
$8816-Feb-05 0:14 
GeneralRe: problem returning arrays Pin
Anonymous22-Feb-05 1:23
Anonymous22-Feb-05 1:23 
GeneralRe: problem returning arrays Pin
$8822-Feb-05 2:17
$8822-Feb-05 2:17 
The error is clear: You declared ei taking one parameter which is a array of double and you call it with a double value.

I don't know the rest of the code but the arrays x, a, b, expint are not usefull since you always use the value for the current index i.

Try that if you want to change them into single value


#include
#include "stdafx.h"
#include
#include
#include
using namespace std;

double a,b,expint,beta[10000],dimP2[10000];
double t[50],alpha[50],dimP[50];
int i,j;

double ei(double x)
{
double a0,a1,a2,a3,a4,a5,b1,b2,b3,b4,c1,c2,c3,c4;

a0 = -0.57721566;
a1 = 0.99999193;
a2 = -0.24991055;
a3 = 0.05519968;
a4 = -0.00976004;
a5 = 0.00107857;

b1 = 8.5733287401;
b2 = 18.059016973;
b3 = 8.6347608925;
b4 = 0.2677737343;

c1 = 9.5733223454;
c2 = 25.6329561486;
c3 = 21.0996530827;
c4 = 3.9584969228;

if (x<=0)
{
expint = -999;
}

if (x>=1)
{
a = pow(x,4)+(b1*pow(x,3))+(b2*pow(x,2))+(b3*x)+b4;
b = pow(x,4)+(c1*pow(x,3))+(c2*pow(x,2))+(c3*x)+c4;
expint = (1/(x*exp(x)))*a/b;
}

if((0 { //THIS SHALL NOT COMPILE PROPERLY Frown | :-(
expint = a0+(a1*x)+(a2*pow(x,2))+(a3*pow(x,3))+(a4*pow(x,4))+(a5*pow(x,5))-log(x);
}
return expint;
}

double time_hr()
{
double N=49.0;
for (int i=0;i<50;i++)
{
t[i] = 0.01*exp((i/N)*log(10/0.01));
}
return t[i];
}

double pD()
{
double rw = 0.25;
double ac = 43560;
double A = 80*ac;

double len_b = sqrt(0.5*A);
double len_a = 2*len_b;
double len_ri =0.5*sqrt(pow(len_a,2)+pow(len_b,2));

alpha[i] = (-(pow(rw,2)/(4*A*t[i])));

for(int i=0;i<50;i++)
{
for(int j=0;j<10000;j++)
{
dimP2[j] +=-(0.5*ei(-(1/(4*A*t[i]))*(j+1)*pow(len_ri,2)));//*
}
dimP[i]=(-0.5*ei(alpha[i]))+dimP2[j];//**
}
return dimP[i];
}





Or try that if you need to keep the intermediate arrays:

#include
#include "stdafx.h"
#include
#include
#include
using namespace std;

double a[10000],b[10000],x[10000],expint[10000],beta[10000],dimP2[10000];
double t[50],alpha[50],dimP[50];
int i,j;

double ei(double v)
{
double a0,a1,a2,a3,a4,a5,b1,b2,b3,b4,c1,c2,c3,c4;

x[i]=v;

a0 = -0.57721566;
a1 = 0.99999193;
a2 = -0.24991055;
a3 = 0.05519968;
a4 = -0.00976004;
a5 = 0.00107857;

b1 = 8.5733287401;
b2 = 18.059016973;
b3 = 8.6347608925;
b4 = 0.2677737343;

c1 = 9.5733223454;
c2 = 25.6329561486;
c3 = 21.0996530827;
c4 = 3.9584969228;

if (x[i]<=0)
{
expint[i] = -999;
}

if (x[i]>=1)
{
a[i] = pow(x[i],4)+(b1*pow(x[i],3))+(b2*pow(x[i],2))+(b3*x[i])+b4;
b[i] = pow(x[i],4)+(c1*pow(x[i],3))+(c2*pow(x[i],2))+(c3*x[i])+c4;
expint[i] = (1/(x[i]*exp(x[i])))*a[i]/b[i];
}

if((0 {
expint[i] = a0+(a1*x[i])+(a2*pow(x[i],2))+(a3*pow(x[i],3))+(a4*pow(x[i],4))+(a5*pow(x[i],5))-log(x[i]);
}
return expint[i];
}

double time_hr()
{
double N=49.0;
for (int i=0;i<50;i++)
{
t[i] = 0.01*exp((i/N)*log(10/0.01));
}
return t[i];
}

double pD()
{
double rw = 0.25;
double ac = 43560;
double A = 80*ac;

double len_b = sqrt(0.5*A);
double len_a = 2*len_b;
double len_ri =0.5*sqrt(pow(len_a,2)+pow(len_b,2));

alpha[i] = (-(pow(rw,2)/(4*A*t[i])));

for(i=0;i<50;i++) // USE THE GLOBAL i because it is used in ei function
{ // but it is certainly the j that you want ...
// sorry I can't imagine whatyou want to do !
for(int j=0;j<10000;j++)
{
dimP2[j] +=-(0.5*ei(-(1/(4*A*t[i]))*(j+1)*pow(len_ri,2)));//*
}
dimP[i]=(-0.5*ei(alpha[i]))+dimP2[j];//**
}
return dimP[i];
}



Last thing: In function pD, you should initialize the dimP2 otherwise you use it without any initialization.
for(int j=0;j<10000;j++) {
dimP2[j]=0;
}


]
GeneralPrecompiled Headers Pin
JWood15-Feb-05 12:38
JWood15-Feb-05 12:38 
GeneralRe: Precompiled Headers Pin
Selvam R15-Feb-05 22:27
professionalSelvam R15-Feb-05 22:27 
GeneralRe: Precompiled Headers Pin
ionzarate16-Feb-05 2:56
ionzarate16-Feb-05 2:56 
QuestionWindow's Client RECT in Screen Coordinates? Pin
InflatableGarfield15-Feb-05 12:22
InflatableGarfield15-Feb-05 12:22 
AnswerRe: Window's Client RECT in Screen Coordinates? Pin
Ravi Bhavnani15-Feb-05 12:34
professionalRavi Bhavnani15-Feb-05 12:34 
AnswerRe: Window's Client RECT in Screen Coordinates? Pin
ThatsAlok15-Feb-05 18:09
ThatsAlok15-Feb-05 18:09 
AnswerRe: Window's Client RECT in Screen Coordinates? Pin
InflatableGarfield15-Feb-05 22:09
InflatableGarfield15-Feb-05 22:09 
GeneralwaveInOpen and waveInProc problem. Pin
anaknakal15-Feb-05 11:39
anaknakal15-Feb-05 11:39 
GeneralRe: waveInOpen and waveInProc problem. Pin
vinnzy15-Feb-05 18:53
vinnzy15-Feb-05 18:53 
GeneralRe: waveInOpen and waveInProc problem. Pin
anaknakal15-Feb-05 20:46
anaknakal15-Feb-05 20:46 
GeneralRe: waveInOpen and waveInProc problem. Pin
Sapto Priyono15-Feb-05 20:09
Sapto Priyono15-Feb-05 20:09 
GeneralRe: waveInOpen and waveInProc problem. Pin
anaknakal15-Feb-05 20:52
anaknakal15-Feb-05 20:52 
Questionfor ( ; i < 5; i++) ? Pin
Link260015-Feb-05 11:33
Link260015-Feb-05 11:33 
AnswerRe: for ( ; i &lt; 5; i++) ? Pin
Maximilien15-Feb-05 12:28
Maximilien15-Feb-05 12:28 
GeneralRe: for ( ; i < 5; i++) ? Pin
Link260015-Feb-05 17:29
Link260015-Feb-05 17:29 
GeneralRe: for ( ; i &lt; 5; i++) ? Pin
Antony M Kancidrowski15-Feb-05 23:09
Antony M Kancidrowski15-Feb-05 23:09 
AnswerRe: for ( ; i &lt; 5; i++) ? Pin
Ryan Binns15-Feb-05 17:34
Ryan Binns15-Feb-05 17:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.