Click here to Skip to main content
16,017,788 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I need this code in c language, I don't know the instructions of cpp language can anyone help me to convert Parallel-Conjugate-Gradient to c

What I have tried:

----
Posted
Updated 5-Mar-18 9:29am
v8

1 solution

Quote:
I don't know the instructions of cpp language
It's time to learn, then. You are lucky: that's very C-like code. You have basically to replace new/delete[^] calls with malloc/free ones, some output streams statements with corresponding C standard printf calls and very little else.
 
Share this answer
 
Comments
Rick York 1-Mar-18 17:34pm    
Also the use of string and comparisons using those variables need to change.

It looks like a straight-forward task to me.
Lilyanaa 1-Mar-18 18:08pm    
Ok, Now I'm trying
Lilyanaa 1-Mar-18 18:12pm    
I have problem in this part can you help how can translate it to c
if(argc > 2) {
T = argv[2];
if(argc > 3) {
P = argv[3];
if(argc > 4) {
Db = argv[4];
}
}
}
CPallini 2-Mar-18 3:34am    
You have to replace C++ strings with char pointers (char *).
For instance:
char * T;
//...
T = argv[2];
//..
if ( T && ( strcmp(T,"-p")==0)) // this replaces if (T == "-p")
//..
Lilyanaa 2-Mar-18 10:24am    
Thank you so much, I have this error and to other files why? incompatible type for argument 2 of ‘fprintf’fprintf(matrixfile, a[i][j]); note: expected ‘const char * restrict’ but argument is of type ‘double’
extern int fprintf (FILE *__restrict __stream,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900