15 #ifndef INCLUDED_COMPLEXH
16 #define INCLUDED_COMPLEXH
18 #define COMPLEX complex<double>
26 template <
class T>
struct Real {
31 template <>
struct Real<complex<
Scl<MP_FLOAT> > > {
39 template <>
struct Real<double> {
41 static inline void assign(
double &
a,
const complex<double> & b) { a = b.real() ;};
47 template <>
struct Real<
Scl<MP_FLOAT> > {
54 template <
class T>
struct Real<complex<T> > {
56 static inline void assign(complex<T> &
a,
const complex<T> & b) { a = b ;};
57 static inline double absolute(
const complex<T> &
a) {
return abs(a); }
60 template <>
struct Real<int> {
62 static inline void assign(complex<int> &
a,
const complex<int> & b) { a = b.real() ;};
66 template <
class T>
inline void __div_1(T&
a, T& b,
const T&
c,
const T& d)
70 T
x(b); x*=
r; x+=
a;x/=s;
82 inline complex<Scl<MP_FLOAT> >& complex<Scl<MP_FLOAT> >::operator /=(
const complex<Scl<MP_FLOAT> > &
y) {
87 template<>
inline complex<Scl<MP_FLOAT> >
pow(
const complex<
Scl<MP_FLOAT> >& z,
int k) {
88 double mod =
sqrt(norm(complex<double>(ToDouble(z.real()),ToDouble(z.imag()))));
93 return complex<Scl<MP_FLOAT> >(z.real(),
Scl<MP_FLOAT>(-1.0*ToDouble(z.imag())/mod));
95 double argument = k * arg(complex<double>(ToDouble(z.real()),ToDouble(z.imag())));
97 return complex<Scl<MP_FLOAT> > (mod*cos(argument), mod*sin(argument));
101 inline complex<Scl<MP_FLOAT> >
104 return complex<Scl<MP_FLOAT> >(
x.real()/d,
x.imag()/d); }
106 inline complex<Scl<MP_FLOAT> >
108 complex<Scl<MP_FLOAT> > res(
x);
110 return complex<Scl<MP_FLOAT> >(res.real(),res.imag()); }
112 ostream & operator<<(ostream & os, const complex<Scl<MP_FLOAT> > & z){
113 os<<
"("<< z.real()<<
","<<z.imag()<<
")";
120 c = complex<T>(cos(8.0*atan(1.0)/n), sin(8.0*atan(1.0)/n));
123 template<
class T>
inline complex<T>
pow(
const complex<T>& z,
int k) {
124 T mod =
sqrt(norm(z));
125 if (k == 0)
return complex<T> (1, T(0));
128 return complex<T>(z.real(), -(z.imag())/mod);
130 double argument = k * arg(z);
132 return complex<T> (mod*cos(argument), mod*sin(argument));
143 #endif // // !INCLUDED_COMPLEXH
void Root_Unity(complex< T > &c, int n)
Definition: Complex.hpp:119
static void assign(complex< int > &a, const complex< int > &b)
Definition: Complex.hpp:62
static void assign(double &a, const complex< double > &b)
Definition: Complex.hpp:41
complex< T > pow(const complex< T > &z, int k)
Definition: Complex.hpp:123
Scl< T > & operator/(const Scl< T > &b1, const Scl< T > &b2)
Definition: BC.hpp:890
MSKcallbackcodee MSKsoltypee MSKprostae MSKsolstae MSKstakeye MSKstakeye MSKstakeye MSKrealt MSKrealt MSKrealt * y
Definition: mosek.h:2689
MSKaccmodee MSKint32t MSKsoltypee MSKstakeye MSKrealt * x
Definition: mosek.h:3209
Definition: Complex.hpp:24
MSKint32t k
Definition: mosek.h:2713
int TYPE
Definition: Complex.hpp:61
Definition: Complex.hpp:26
Scl< T > & sqrt(const Scl< T > &b)
Definition: BC.hpp:1103
MSKrealt * c
Definition: mosek.h:2678
#define abs(x)
Definition: f2c.H:161
MSKrescodee r
Definition: mosek.h:2321
MSKstreamtypee MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t a
Definition: mosek.h:3833
static double absolute(const complex< T > &a)
Definition: Complex.hpp:57
T TYPE
Definition: Complex.hpp:55
static double absolute(const double &a)
Definition: Complex.hpp:42
void __div_1(T &a, T &b, const T &c, const T &d)
Definition: Complex.hpp:66
double TYPE
Definition: Complex.hpp:40
static void assign(complex< T > &a, const complex< T > &b)
Definition: Complex.hpp:56
Warning_Value_Type_Not_Defined TYPE
Definition: Complex.hpp:27