Namespaces
Variants
Views
Actions

Talk:cpp/numeric/complex/asin

From cppreference.com

Implementation

It may have sense to add the code of the routine, that evaluates asin. Some compilers do not support some functions. I supply below the example with asin

t~/Q/TORI/ARCSIN>more 03.cc
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
//using namespace std::complex;
#include<complex>
typedef complex<double> z_type;
#define Re(x) x.real()
#define Im(x) x.imag()
main(){ z_type z= z_type(.5,.5);
z_type c=asin(z);
printf("%9.8f %9.8f\n",Re(c),Im(c));
}
t~/Q/TORI/ARCSIN>make 03
g++     03.cc   -o 03
03.cc: In function ‘int main()’:
03.cc:12: error: no matching function for call to ‘asin(z_type&)’
/usr/include/architecture/i386/math.h:256: note: candidates are: double asin(double)
/usr/include/c++/4.2.1/cmath:123: note:                 long double std::asin(long double)
/usr/include/c++/4.2.1/cmath:119: note:                 float std::asin(float)
make: *** [03] Error 1

I search for any library that would support the complex double std::asin(complex double), but it seems to me to be easier to write the routine for asin by myself than to find it in the internet..

I think, that addition of the code of the routine could improve the article. Sincerely, DmitriiKouznetsov (talk) 07:02, 3 December 2013 (PST)

complex asin is a part of the C++11 language specification. Upgrade your GCC (4.2.1 is 7 years old) and use the commandline argument -std=c++11. You can see your program work online: http://coliru.stacked-crooked.com/a/f5e2d99d023df198 --Cubbi (talk) 09:29, 3 December 2013 (PST)