none
pow(valarray, int) not supported?

    Question

  • I am using VS Community Edition.  Can someone explain why the calculation of 'out3' below doesn't work in visual studio? The cmath version works for double(double,int)

    #include <valarray>
    
    valarray<double> r = { 0,0,0 };
    valarray<double> exp = { 1 ,1, 1 };
    valarray<double> out1 = pow(r,exp); //works
    valarray<double> out2 = pow(r, 1.0); // works
    valarray<double> out3 = pow(r, 1);  //  doesn't compile, pow not found
    
    Thank you

    Monday, September 05, 2016 7:48 PM

Answers

  • Hi Adam00000,

    According to your code, r has been defined double, and this pow(r,1), 1 is int. so I think you should refer to the b of the following code to keep the same type.

    valarray<double> r = { 0,0,0 };
    
                    valarray<double> exp = { 1 ,1, 1 };
    
                    valarray<double> out1 = pow(r, exp); //works
    
                    valarray<double> out2 = pow(r, 1.0); // works
    
                    valarray<int> b = { 0,0,0 };
    
                    valarray<int> out3 = pow(b, 1);  //  it works
    

    Sincerely,

    Oscar


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Tuesday, September 06, 2016 2:04 AM
    Moderator