I just need a little help converting these lines of octave to opencl i guess i'm confused on the translation ^ to pow her is octave/opencl code but the results are not the same
v1=0.3;
E1=(207*(10^9));
E2=(3*(10^6));
v2=0.49;
octave
Er=1/(1/pi*((1-v1^2)/E1+(1-v2^2)/E2));%MPa
DEFACTOR=(6*n*U*B^2)/Er/(sigma^3);
my opencl attempt at translation
Er=(1.00/(1.00/pi*((1.00-pow(v1 ,2))/E1+(1.00-pow(v2, 2))/E2))); //MPa
DEFACTOR=6*n*U*pow(B,2)/Er/pow(sigma,3);
octave results
//er 1.2402e+07
//DEFACTOR 30.962
opencl results
Er 139.336666
DEFACTOR -0.000003
not sure what i've done wrong but if someone sees it please help
Thanks chocjulio
Solved! Go to Solution.
Thanks for your reply! No i was not able to figure out why i get different results it is very strange
n=0.01; //Pa-s
U=1; //m/s
how would you translate this line in opencl?
E1=(207*(10^9));
Thanks Choc
EDIT: I did figure out sry its been a long project the correct answer was in the c translation c99 translation
#include <math.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
double v1 = 0.3;
double E1 = (207*(1e9));
double E2 = (3*(1e6));
double v2 = 0.49;
double pi = M_PI;
double Ers = (1.00/(1.00/pi*((1.00-pow(v1,2))/E1+(1.00-pow(v2, 2))/E2)));
printf("Ers = %g\n", Ers);
return 0;
}
Is your issue resolved? We don't have the values of n and U to reproduce your problem.
Your OpenCL translation seems to be correct. Maybe expressing E1 and E2 also in terms of the pow() function would help, as n, U, E1, and E2 are the only variables (i.e. whose values can differ between the Octave version and the OpenCL version) that can influence the differing results.
Thanks for your reply! No i was not able to figure out why i get different results it is very strange
n=0.01; //Pa-s
U=1; //m/s
how would you translate this line in opencl?
E1=(207*(10^9));
Thanks Choc
EDIT: I did figure out sry its been a long project the correct answer was in the c translation c99 translation
#include <math.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
double v1 = 0.3;
double E1 = (207*(1e9));
double E2 = (3*(1e6));
double v2 = 0.49;
double pi = M_PI;
double Ers = (1.00/(1.00/pi*((1.00-pow(v1,2))/E1+(1.00-pow(v2, 2))/E2)));
printf("Ers = %g\n", Ers);
return 0;
}
Can you try the following translation for E1 and E2 and report back?:
E1 = (double)(207*pow((double)10, 9))
E2 = (double)(3*pow((double)10,6))
With this change, we got the same Er result in OpenCL as your Er result using Octave.
Defactor uses additional variables (B, sigma), so we could not verify the result for that variable.