Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem w/ error c2664...

Status
Not open for further replies.

aaadetos

Programmer
Nov 21, 2004
54
US
Hi, the ffg code gave the ffg 2 errors:
Code:
'ei':cannot convert parameter 1 from double to double[]
on both lines * and ** in the code below:
Code:
#include <math>
#include "stdafx.h"
#include <fstream>
#include <iomanip>
#include <iostream>
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 x[10000])
{
	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[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<x[i])&&(x[i]<1))
	{
		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(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];
}
Please what is the cause of this error?

 
Well, as the stament suggests, you're trying to pass a double to a function
Code:
ei(alpha[i]))
that wants an array of 10000 doubles.

There's a lot to be said about putting 10000 doubles on the stack, global variables and a total lack of comments, but I won't go into that....

/Per
[sub]
www.perfnurt.se[/sub]
 
I thought it would be okay, since the prototype for the ei function is:
Code:
double ei(double x[10000])
, which passes an array to the ei function.
 
Code:
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];//**
}
This code is not passing an array of doubles to ei(), it's passing 1 double at a time, 500000 times.

Also, since ei() doesn't modify the x parameter, you should make it const.
This might be better:
Code:
double ei( const double* x, size_t arraySize );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top