error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2009
Posts: 32
Reputation: sdmahapatra is an unknown quantity at this point 
Solved Threads: 0
sdmahapatra sdmahapatra is offline Offline
Light Poster

error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'

 
0
  #1
Jun 20th, 2009
I am getting an error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'.Will please anybody help me from this problem.I am new in C++.

Thanks

  1. #include<iostream>
  2. #include<cmath>
  3. #include<algorithm>
  4.  
  5. using namespace std; // you should not use this statement.
  6. void F_Ite(double,double,double,double,double,double);
  7. // never ever declare global data in C++
  8.  
  9. //Globally Data_type Declaration & Initialization :
  10. double z=0.0001;
  11. double NR=0.01;
  12. int NI=11;
  13. double RF;
  14.  
  15. int main(int argc, char* argv[]) // put the othe arguments for main (int argc, char* argv[])
  16. {
  17. //Result Of A Fibonacci_Search Algorithm Operation On A Given Function :
  18. std::cout <<"\nThe Function is ' F(x)=e^(-x)+x^2 '";
  19. std::cout <<"\n";
  20.  
  21. // declare your pointers outside of your function and pass them as parameters to F_Ite
  22. double *a,*b,*c,*d,*Fc,*Fd,I;
  23.  
  24. // you could optionally initialise them before passing them to your function
  25. int numElement =20;
  26.  
  27. a = new double[numElement];
  28. b = new double[numElement];
  29. c = new double[numElement];
  30. d = new double[numElement];
  31. Fc= new double[numElement];
  32. Fd= new double[numElement];
  33.  
  34. // now call the function
  35. F_Ite(a,b,c,d,Fc,Fd);
  36.  
  37. // Now you can cout your values, or do whatever with them
  38. // don't forget to delete them when you're done.
  39. // wherever you create something with 'new' you should
  40. // always call 'delete' when finished!
  41.  
  42. //User Specify The Interval :
  43. std::cout << "\nGive The Initian Point :" <<"\na1 =";
  44. std::cin >> a[1];
  45. std::cout << "\nGive The Final Point :" <<"\nb1 =";
  46. std::cin >> b[1];
  47.  
  48.  
  49. //Find Distance Between The Starting Interval :
  50. I=(b[1]-a[1]);
  51. std::cout << "\nInterval Reduction At The Initial Iteration :"<< "\nI(1) = " << I <<"\n";
  52.  
  53.  
  54. //For Accuracy Exactness Need A Small Pertubation At The Final Interval
  55. std::cout <<"\nFor Accuracy At The Final Interval, Taken The Small Perturbation z :";
  56. std::cout <<"\nTaken z = 0.0001" << "\n";
  57.  
  58. //Give The Prescribe Interval Reduction :
  59. std::cout <<"\nNeeded The Prescribe Interval Reduction :" <<"\nNR = 0.01 units";
  60. std::cout <<"\n";
  61.  
  62. //Calculate The Number Of Iteration From The Given Interval Reduction :
  63. //By Fibonacci Series
  64. std::cout <<"\nAccording To The Interval Reduction";
  65. std::cout <<"\nThe Requring Number Of Iteration :" << "\nNI = 11 times";
  66. std::cout <<"\n";
  67. std::cout <<"\n";
  68.  
  69.  
  70. system("pause"); // this is a platform specific call. do not use this.
  71.  
  72.  
  73.  
  74. //To Calculate The Ratio of two consecutive Fibo_Num (F(m-1)/Fm) :
  75. //Function (F(m-1)/Fm) Declaration :
  76. double R_Fibo();
  77. std::cout <<"\nBefore The Start Of Interval Reduction";
  78. std::cout << "\nThe Ratio of two consecutive Fibo_Num :"<<"\nRF = 0.618056";
  79. std::cout <<"\n";
  80.  
  81.  
  82. //Here The Beginnins Of Iteration Technique
  83.  
  84. //We Introduce Two Another Points For Getting Two New Interval Of Uncertainty
  85. //First Point 'c1' And Second Point 'd1' :
  86. c[1]=b[1]-(R_Fibo()*I);
  87. std::cout << "\nPlaced A Point c1 Within The Initial Interval :"<< c[1];
  88. d[1]=a[1]+(R_Fibo()*I);
  89. std::cout <<"\nPlaced Another Point d1 Within The Initial Interval :"<<d[1];
  90. std::cout <<"\n";
  91. std::cout <<"\n";
  92.  
  93. //Showing The Starting Reduction :
  94. //----------------
  95. //----------------
  96. std::cout <<"At The First Iteration :\n";
  97. std::cout <<"The Value Of a1=" << a[1] << "\n";
  98. std::cout <<"The Value Of b1=" << b[1] << "\n";
  99. std::cout <<"The Value Of c1=" << c[1] << "\n";
  100. std::cout <<"The Value Of d1=" << d[1] ;
  101. //Function 'Fc1' at point 'c1' And Function 'Fd1' at point 'd1':
  102. //--------------------
  103.  
  104. // write a function which takes one argument and returns the value. use it here instead of explicit coding.
  105. Fc[1]=(exp(-c[1]))+(c[1]*c[1]);
  106. std::cout << "\nAt c1 The Function Value Fc1=" << Fc[1];
  107. //std::cout <<"\n";
  108. Fd[1]=(exp(-d[1]))+(d[1]*d[1]);
  109. std::cout << "\nAt d1 The Function Value Fd1=" << Fd[1];
  110. std::cout <<"\n";
  111. std::cout <<"\n";
  112. //---------------------
  113. //---------------------
  114.  
  115. //system("pause");
  116.  
  117. // this must be defined outside of main and called here explicitly.
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. double In=b[NI]-a[NI];
  125. std::cout <<"\nThe Interval Reduction At The Final Iteration :" <<"\nI(n)= " << In;
  126. std::cout<<"\n";
  127.  
  128. delete [] a;
  129. delete [] b;
  130. delete [] c;
  131. delete [] d;
  132. delete [] Fc;
  133. delete [] Fd;
  134.  
  135.  
  136. std::cout << std::endl;
  137. system("pause");
  138. //return 0;
  139. }
  140.  
  141.  
  142.  
  143. //Ratio of two successive terms of Fibonacci Sequence is obtained using Binet's Formula
  144. //Function (F(m-1)/Fm) Defination :
  145. double R_Fibo()
  146. {
  147. double n1=1-(sqrt((double)5));
  148. double n2=1+(sqrt((double)5));
  149. double s=(n1/n2);
  150. //cout << "\nsThe Value Of s = " << s <<"\n";
  151.  
  152. double s1=(sqrt((double)5)-1)/2;
  153. //cout << "\nThe Value Of s1 = " << s1 <<"\n";
  154.  
  155. double RF=s1*((1-pow(s,NI))/(1-pow(s,(NI+1))));
  156.  
  157. //std::cout << "\nThe Ratio of two consecutive Fibo_Num :"<<"\nRF = " << RF <<"\n";
  158. //std::cout << RF;
  159.  
  160. return RF;
  161.  
  162. }
  163.  
  164.  
  165. // pass values into F_Ite() function
  166. void F_Ite(double *a, double *b, double *c, double *d, double *Fc, double *Fd)
  167. { //F_Ite Function Start
  168.  
  169. for(int k=1;k<(NI-1);k++)
  170. { //Main 'for' Loop Start
  171. std::cout <<"\n";
  172. system("pause");
  173. std::cout <<"\n";
  174. std::cout <<"At The "<<k+1<<" Iteration :\n";
  175.  
  176. if(Fc[k]<Fd[k])
  177. { //Outer 'if' Start
  178. a[k+1]=a[k];
  179. cout <<"The Value Of a" << k+1 << "=" << a[k+1] << "\n";
  180. b[k+1]=d[k];
  181. cout <<"The Value Of b" << k+1 << "=" << b[k+1] << "\n";
  182. //c[k+1]=b[k+1]-(0.618034*((1-pow(-0.381966,NI-k))/(1-pow(-0.381966,NI-k+1))))*(b[k+1]-a[k+1]);
  183. //cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
  184. if(k==(NI-1))
  185. {
  186. c[k+1]=c[k+1]+z;
  187. cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
  188. }
  189. else
  190. {
  191. c[k+1]=b[k+1]-(0.618034*((1-pow(-0.381966,NI-k))/(1-pow(-0.381966,NI-k+1))))*(b[k+1]-a[k+1]);
  192. cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
  193. }
  194. d[k+1]=c[k];
  195. cout <<"The Value Of d" << k+1 << "=" << d[k+1] << "\n";
  196.  
  197. Fc[k+1]=(exp(-c[k+1]))+(c[k+1]*c[k+1]);
  198. std::cout <<"The Value Of Fc" << k+1 << "=" << Fc[k+1] << "\n";
  199. //std::cout <<"The Value Of Fc" << k+1 << "=" << Fc[k] << "\n";
  200.  
  201. Fd[k+1]=Fc[k];
  202. //std::cout <<"The Value Of Fd" << k+1 << "=" << Fc[k] << "\n";
  203. std::cout <<"The Value Of Fd" << k+1 << "=" << Fd[k+1] << "\n";
  204.  
  205.  
  206. } //Outer 'if' Close
  207. else
  208. { //Outer 'else' Start
  209. a[k+1]=c[k];
  210. std::cout <<"The Value Of a" << k+1 << "=" << a[k+1] << "\n";
  211. b[k+1]=b[k];
  212. std::cout <<"The Value Of b" << k+1 << "=" << b[k+1] << "\n";
  213. c[k+1]=d[k];
  214. std::cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
  215. //d[k+1]=a[k+1]+((0.618034)*((1-pow((-0.381966),(NI-k)))/(1-pow((-0.381966),(NI-k+1)))))*(b[k+1]-a[k+1]);
  216. //std::cout <<"The Value Of d" << k+1 << "=" << d[k+1] << "\n";
  217.  
  218. if(k==(NI-1))
  219. {
  220. d[k+1]=d[k+1]+z;
  221. std::cout <<"The Value Of d" << k+1 << "=" << d[k+1] << "\n";
  222. }
  223.  
  224. else
  225. {
  226. d[k+1]=a[k+1]+((0.618034)*((1-pow((-0.381966),(NI-k)))/(1-pow((-0.381966),(NI-k+1)))))*(b[k+1]-a[k+1]);
  227. std::cout <<"The Value Of d" << k+1 << "=" << d[k+1] << "\n";
  228. }
  229.  
  230.  
  231. Fc[k+1]=Fd[k];
  232. //std::cout <<"The Value Of Fc" << k+1 << "=" << Fd[k] << "\n";
  233. std::cout <<"The Value Of Fc" << k+1 << "=" << Fc[k+1] << "\n";
  234. Fd[k+1]=(exp(-d[k+1]))+(d[k+1]*d[k+1]);
  235. std::cout <<"The Value Of Fd" << k+1 << "=" << Fd[k+1] << "\n";
  236. //std::cout <<"The Value Of Fd" << k+1 << "=" << Fd[k] << "\n";
  237.  
  238. } //Outer 'else' Close
  239. } //Main 'for' Loop Close
  240.  
  241. //Another 'if' Condition Start But Within The 'for' Loop
  242. if(Fc[10]<Fd[10])
  243. {
  244. std::cout <<"\n";
  245. std::cout <<"\nAt Final Iteration :\n";
  246. a[NI]=a[NI-1];
  247. b[NI]=d[NI-1];
  248. std::cout <<"The Value Of a11 =" << a[NI] << "\n";
  249. std::cout <<"The Value Of b11 =" << b[NI] << "\n";
  250. }
  251. else
  252. {
  253. a[NI]=c[NI-1];
  254. b[NI]=b[NI-1];
  255. std::cout <<"The Value Of a11 =" << a[NI] << "\n";
  256. std::cout <<"The Value Of b11 =" << b[NI] << "\n";
  257. }
  258.  
  259. } //F_Ite Function Close
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'

 
0
  #2
Jun 20th, 2009
double *a,*b,*c,*d,*Fc,*Fd,I;

They're all pointers, so to get the contents of a pointer

float f = *a;

F_Ite( *a, *b, *c, *d, *Fc, *Fd );
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1,968
Reputation: tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute 
Solved Threads: 214
tux4life's Avatar
tux4life tux4life is offline Offline
Posting Virtuoso

Re: error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'

 
0
  #3
Jun 20th, 2009
It's better to avoid using system("pause");

Use cin.get(); as a replacement of system("pause"); , less typing and more portable !!

Check out this if you want to know why
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 32
Reputation: sdmahapatra is an unknown quantity at this point 
Solved Threads: 0
sdmahapatra sdmahapatra is offline Offline
Light Poster

Re: error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'

 
0
  #4
Jun 20th, 2009
Originally Posted by wildgoose View Post
double *a,*b,*c,*d,*Fc,*Fd,I;

They're all pointers, so to get the contents of a pointer

float f = *a;

F_Ite( *a, *b, *c, *d, *Fc, *Fd );
After doing float f = *a;

F_Ite( *a, *b, *c, *d, *Fc, *Fd );
I am getting two Linking error shown below

(1) error LNK2019: unresolved external symbol "void __cdecl F_Ite(double,double,double,double,double,double)" (?F_Ite@@YAXNNNNNN@Z) referenced in function _main

(2) fatal error LNK1120: 1 unresolved externals
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 32
Reputation: sdmahapatra is an unknown quantity at this point 
Solved Threads: 0
sdmahapatra sdmahapatra is offline Offline
Light Poster

Re: error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'

 
1
  #5
Jun 20th, 2009
Originally Posted by tux4life View Post
It's better to avoid using system("pause");

Use cin.get(); as a replacement of system("pause"); , less typing and more portable !!

Check out this if you want to know why
Your suggestion i sreally good.I will obviously follow this.

Thank you very much my frnd
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 32
Reputation: sdmahapatra is an unknown quantity at this point 
Solved Threads: 0
sdmahapatra sdmahapatra is offline Offline
Light Poster

Re: error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'

 
0
  #6
Jun 20th, 2009
Thanks to everybody as it has been solved with all of yours suggestion.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC