EURO_FXD.H 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. //****************************************************************************
  2. //****************************************************************************
  3. //
  4. //
  5. // FIXED point class ... a replacement for floats in Actua Soccer
  6. //
  7. // Format: Fixed (1,19,12)
  8. //
  9. // NOTES :
  10. // There is very little range checking at the moment so ...
  11. //
  12. // BE VERY CAREFUL
  13. //
  14. //
  15. //
  16. // Author : P.Rankin
  17. // Version: 1.00.01.08.95
  18. //
  19. //****************************************************************************
  20. //****************************************************************************
  21. #ifndef ABS
  22. #define ABS(a) (( (a) >= 0 ) ? (a):-(a))
  23. #endif
  24. #ifndef f2L
  25. #define f2L(f) ((fixed)((long)((f)*4096)))
  26. #endif
  27. #define ItoF(f) ((long) (f)*4096)
  28. #define FRACTION 12
  29. #define HALF_FRACTION 6
  30. extern "C" int mul_64bit(int,int);
  31. extern "C" int div_64bit(int,int);
  32. class fixed {
  33. public:
  34. long f;
  35. operator char();
  36. operator unsigned char();
  37. operator short();
  38. operator int();
  39. operator long();
  40. fixed();
  41. fixed( int );
  42. fixed( long );
  43. fixed( fixed const & );
  44. // fixed &operator = ( double );
  45. fixed &operator = ( fixed const & );
  46. // fixed &operator = ( float );
  47. fixed &operator = ( long );
  48. fixed &operator = ( int );
  49. fixed &operator = ( short );
  50. fixed &operator += ( fixed const & );
  51. fixed &operator += ( long );
  52. fixed &operator += ( int );
  53. fixed &operator += ( short );
  54. fixed &operator -= ( fixed const & );
  55. fixed &operator -= ( long );
  56. fixed &operator -= ( int );
  57. fixed &operator -= ( short );
  58. fixed &operator *= ( fixed const & );
  59. fixed &operator *= ( long );
  60. fixed &operator *= ( int );
  61. fixed &operator *= ( short );
  62. fixed &operator /= ( fixed const & );
  63. fixed &operator /= ( int );
  64. fixed &operator /= ( short );
  65. fixed &operator >>= ( int );
  66. fixed &operator <<= ( int );
  67. fixed operator + () const;
  68. fixed operator - () const;
  69. };
  70. fixed operator * ( fixed const &, fixed const &);
  71. fixed operator * ( fixed const &, int);
  72. fixed operator * ( fixed const &, short);
  73. fixed operator * ( fixed const &, long);
  74. fixed operator * ( int , fixed const & );
  75. fixed operator * ( short , fixed const & );
  76. fixed operator * ( long , fixed const &);
  77. fixed operator + ( fixed const &, fixed const &);
  78. fixed operator + ( fixed const &, long);
  79. fixed operator + ( fixed const &, int);
  80. fixed operator + ( fixed const &, short);
  81. fixed operator + ( long __f1 , fixed const &__f0 );
  82. fixed operator + ( int , fixed const & );
  83. fixed operator + ( short , fixed const & );
  84. fixed operator - ( fixed const &, fixed const &);
  85. fixed operator - ( fixed const &, long);
  86. fixed operator - ( fixed const &, int);
  87. fixed operator - ( fixed const &, short);
  88. fixed operator - ( long ,fixed const &);
  89. fixed operator - ( int ,fixed const &);
  90. //fixed operator - ( short ,fixed const &);
  91. fixed operator / ( fixed const &, fixed const &);
  92. fixed operator / ( fixed const &, long);
  93. fixed operator / ( fixed const &, int);
  94. fixed operator / ( fixed const &, short);
  95. fixed operator / ( long , fixed const & );
  96. fixed operator / ( int , fixed const & );
  97. int operator == ( fixed const &, fixed const & );
  98. int operator == ( fixed const &, int );
  99. int operator == ( fixed const &, short );
  100. int operator == ( int ,fixed const & );
  101. int operator == ( short ,fixed const & );
  102. int operator != ( fixed const &, fixed const & );
  103. int operator != ( fixed const &, int );
  104. int operator != ( fixed const &, short );
  105. int operator != ( int ,fixed const & );
  106. int operator != ( short ,fixed const & );
  107. int operator < ( fixed const &, fixed const & );
  108. int operator < ( fixed const &, long );
  109. int operator < ( fixed const &, int );
  110. int operator < ( fixed const &, short );
  111. int operator < ( long , fixed const & );
  112. int operator < ( int ,fixed const & );
  113. int operator < ( short ,fixed const & );
  114. int operator > ( fixed const &, fixed const & );
  115. int operator > ( fixed const &, long );
  116. int operator > ( fixed const &, int );
  117. int operator > ( fixed const &, short );
  118. int operator > ( long , fixed const & );
  119. int operator > ( int ,fixed const & );
  120. int operator > ( short ,fixed const & );
  121. int operator <= ( fixed const &, fixed const & );
  122. int operator <= ( fixed const &, long );
  123. int operator <= ( fixed const &, int );
  124. int operator <= ( fixed const &, short );
  125. int operator <= ( int ,fixed const & );
  126. int operator <= ( short ,fixed const & );
  127. int operator >= ( fixed const &, fixed const & );
  128. int operator >= ( fixed const &, long );
  129. int operator >= ( fixed const &, int );
  130. int operator >= ( fixed const &, short );
  131. int operator >= ( int ,fixed const & );
  132. int operator >= ( short ,fixed const & );
  133. //****************************************************************************
  134. //
  135. // Constructors
  136. //
  137. //****************************************************************************
  138. inline fixed::fixed() {
  139. }
  140. inline fixed::fixed( int __f0 ) {
  141. f = __f0 << FRACTION;
  142. }
  143. inline fixed::fixed( long __f0 ) {
  144. f = __f0 ;
  145. }
  146. inline fixed::fixed( fixed const &__f0 ) {
  147. f = __f0.f;
  148. }
  149. //****************************************************************************
  150. //
  151. // Casts
  152. //
  153. //****************************************************************************
  154. inline fixed:: operator char() {
  155. return( f>>FRACTION );
  156. }
  157. inline fixed:: operator unsigned char() {
  158. return( f>>FRACTION );
  159. }
  160. inline fixed:: operator short() {
  161. return( f>>FRACTION );
  162. }
  163. inline fixed:: operator int() {
  164. return( f>>FRACTION );
  165. }
  166. inline fixed:: operator long() {
  167. return( f );
  168. }
  169. //****************************************************************************
  170. //
  171. // =
  172. //
  173. //****************************************************************************
  174. inline fixed &fixed:: operator =(fixed const &__d) {
  175. f = (long) ( __d.f );
  176. return(*this);
  177. }
  178. inline fixed &fixed:: operator =(int __d) {
  179. f = ( ItoF(__d) );
  180. return(*this);
  181. }
  182. inline fixed &fixed:: operator =(long __d) {
  183. f = ( (__d) );
  184. return(*this);
  185. }
  186. inline fixed &fixed:: operator =(short __d) {
  187. f = ( ItoF(__d) );
  188. return(*this);
  189. }
  190. //****************************************************************************
  191. //
  192. // *
  193. //
  194. //****************************************************************************
  195. inline fixed operator * ( fixed const &__f0, fixed const &__f1 ) {
  196. return((long)mul_64bit(__f0.f,__f1.f));
  197. }
  198. inline fixed operator * ( fixed const &__f0, long __f1 ) {
  199. return((long)mul_64bit(__f0.f,__f1));
  200. }
  201. inline fixed operator * ( fixed const &__f0, int __f1 ) {
  202. return( ((long)(__f0.f)) * __f1 );
  203. }
  204. inline fixed operator * ( fixed const &__f0, short __f1 ) {
  205. return( ((long)(__f0.f)) * __f1 );
  206. }
  207. inline fixed operator * ( int __f1 , fixed const &__f0) {
  208. return( ((long)(__f0.f)) * __f1 );
  209. }
  210. inline fixed operator * ( short __f1 , fixed const &__f0) {
  211. return( ((long)(__f0.f)) * __f1 );
  212. }
  213. inline fixed operator * ( long __f1 , fixed const &__f0) {
  214. return((long)mul_64bit(__f1,__f0.f));
  215. }
  216. //****************************************************************************
  217. //
  218. // +
  219. //
  220. //****************************************************************************
  221. inline fixed operator + ( fixed const &__f0, fixed const &__f1 ) {
  222. return( __f0.f + __f1.f );
  223. }
  224. inline fixed operator + ( fixed const &__f0, long __f1 ) {
  225. return( __f0.f + ((long)__f1) );
  226. }
  227. inline fixed operator + ( fixed const &__f0, int __f1 ) {
  228. return( __f0.f + (((long)__f1)<<FRACTION) );
  229. }
  230. inline fixed operator + ( fixed const &__f0, short __f1 ) {
  231. return( __f0.f + (((long)__f1)<<FRACTION) );
  232. }
  233. inline fixed operator + ( long __f1 , fixed const &__f0 ) {
  234. return( __f0.f + ((long)__f1) );
  235. }
  236. inline fixed operator + ( int __f1 , fixed const &__f0 ) {
  237. return( __f0.f + (((long)__f1)<<FRACTION) );
  238. }
  239. inline fixed operator + ( short __f1 , fixed const &__f0 ) {
  240. return( __f0.f + (((long)__f1)<<FRACTION) );
  241. }
  242. //****************************************************************************
  243. //
  244. // -
  245. //
  246. //****************************************************************************
  247. inline fixed operator - ( fixed const &__f0, fixed const &__f1 ) {
  248. return( __f0.f - __f1.f );
  249. }
  250. inline fixed operator - ( fixed const &__f0, long __f1 ) {
  251. return( __f0.f - (((long)__f1)) );
  252. }
  253. inline fixed operator - ( fixed const &__f0, int __f1 ) {
  254. return( __f0.f - (((long)__f1)<<FRACTION) );
  255. }
  256. inline fixed operator - ( fixed const &__f0, short __f1 ) {
  257. return( __f0.f - (((long)__f1)<<FRACTION) );
  258. }
  259. inline fixed operator - ( long __f1 , fixed const &__f0 ) {
  260. return( ( (((long)__f1)) - __f0.f ) );
  261. }
  262. inline fixed operator - ( int __f1 , fixed const &__f0 ) {
  263. return( ( (((long)__f1)<<FRACTION) - __f0.f ) );
  264. }
  265. /*
  266. inline fixed operator - ( short __f1 , fixed const &__f0 ) {
  267. return( (((long)__f1)<<FRACTION) - __f0.f ) );
  268. }
  269. */
  270. //****************************************************************************
  271. //
  272. // /
  273. //
  274. //****************************************************************************
  275. inline fixed operator / ( fixed const &__f0, fixed const &__f1 ) {
  276. if(__f1.f!=0)
  277. return((long)div_64bit(__f0.f,__f1.f));
  278. else
  279. return(__f0);
  280. #if 0
  281. if(( __f0.f <= 0x3ffff )&&(__f0.f >= -0x3ffff))
  282. {
  283. if(__f1.f!=0)
  284. return ( ( (__f0.f << FRACTION) / __f1.f ) );
  285. else
  286. return ( __f0.f );
  287. }
  288. else
  289. {
  290. if(ABS(__f1.f) < (long)64 )
  291. return ( __f0.f );
  292. else
  293. return ( ( __f0.f / (__f1.f>>HALF_FRACTION) ) <<HALF_FRACTION );
  294. }
  295. #endif
  296. }
  297. inline fixed operator / ( fixed const &__f0, long __f1 ) {
  298. if(( __f0.f < 0x3ffff )&&(__f0.f > -0x3ffff))
  299. return ( ( (__f0.f << FRACTION) / __f1 ) );
  300. else
  301. return ( ( __f0.f / (__f1>>HALF_FRACTION) ) <<HALF_FRACTION );
  302. }
  303. inline fixed operator / ( fixed const &__f0, int __f1 ) {
  304. return ( ( __f0.f / __f1 ) );
  305. }
  306. inline fixed operator / ( fixed const &__f0, short __f1 ) {
  307. return ( ( __f0.f / __f1 ) );
  308. }
  309. inline fixed operator / ( long __f0 , fixed const &__f1 ) {
  310. if(__f1.f!=0)
  311. return((long)div_64bit(__f0,__f1.f));
  312. else
  313. return(__f0);
  314. #if 0
  315. if(( __f0 < 0x3ffff )&&(__f0 > -0x3ffff))
  316. return ( ( (__f0 << FRACTION) / __f1.f ) );
  317. else
  318. return ( ( __f0 / (__f1.f>>HALF_FRACTION) ) <<HALF_FRACTION );
  319. #endif
  320. }
  321. inline fixed operator / ( int __f0 , fixed const &__f1 ) {
  322. if(__f1.f!=0)
  323. return((long)div_64bit(__f0 << FRACTION,__f1.f));
  324. else
  325. return(__f0);
  326. #if 0
  327. if(( __f0 <= 0x7f )&&(__f0 >= -0x7f))
  328. {
  329. if( __f1.f != 0 )
  330. return ( ( (__f0 << (2*FRACTION)) / __f1.f ) );
  331. else
  332. return ( __f0 );
  333. }
  334. else
  335. {
  336. if(ABS(__f1.f)< (long)64 )
  337. return ( __f0 );
  338. else
  339. return ( ( (__f0 << FRACTION) / (__f1.f>>HALF_FRACTION) ) <<HALF_FRACTION );
  340. }
  341. #endif
  342. }
  343. //****************************************************************************
  344. //
  345. // +=
  346. //
  347. //****************************************************************************
  348. inline fixed &fixed::operator += ( fixed const &__cv ) {
  349. f += __cv.f;
  350. return ( *this );
  351. }
  352. inline fixed &fixed::operator += ( long __cv ) {
  353. f += ( __cv );
  354. return ( *this );
  355. }
  356. inline fixed &fixed::operator += ( int __cv ) {
  357. f += ( __cv<<FRACTION );
  358. return ( *this );
  359. }
  360. inline fixed &fixed::operator += ( short __cv ) {
  361. f += ( __cv<<FRACTION );
  362. return ( *this );
  363. }
  364. //****************************************************************************
  365. //
  366. // -=
  367. //
  368. //****************************************************************************
  369. inline fixed &fixed::operator -= ( fixed const &__cv ) {
  370. f -= __cv.f;
  371. return ( *this );
  372. }
  373. inline fixed &fixed::operator -= ( long __cv ) {
  374. f += ( __cv );
  375. return ( *this );
  376. }
  377. inline fixed &fixed::operator -= ( int __cv ) {
  378. f -= ( __cv<<FRACTION );
  379. return ( *this );
  380. }
  381. inline fixed &fixed::operator -= ( short __cv ) {
  382. f -= ( __cv<<FRACTION );
  383. return ( *this );
  384. }
  385. //****************************************************************************
  386. //
  387. // *=
  388. //
  389. //****************************************************************************
  390. inline fixed &fixed::operator *= ( fixed const &__cv ) {
  391. f = (f >> HALF_FRACTION ) * (__cv.f >> HALF_FRACTION);
  392. return ( *this );
  393. }
  394. inline fixed &fixed::operator *= ( long __cv ) {
  395. f = (f >> HALF_FRACTION ) * (__cv >> HALF_FRACTION);
  396. return ( *this );
  397. }
  398. inline fixed &fixed::operator *= ( int __cv ) {
  399. f *= ( __cv );
  400. return ( *this );
  401. }
  402. inline fixed &fixed::operator *= ( short __cv ) {
  403. f *= ( __cv );
  404. return ( *this );
  405. }
  406. //****************************************************************************
  407. //
  408. // /=
  409. //
  410. //****************************************************************************
  411. inline fixed &fixed::operator /= ( fixed const &__cv ) {
  412. if(ABS(__cv.f)<64)
  413. return (*this);
  414. else
  415. f = ( ( f / (__cv.f>>HALF_FRACTION) ) <<HALF_FRACTION );
  416. return( *this );
  417. }
  418. inline fixed &fixed::operator /= ( int __cv ) {
  419. if(f!=0)
  420. f /= ( __cv );
  421. return ( *this );
  422. }
  423. inline fixed &fixed::operator /= ( short __cv ) {
  424. if(f!=0)
  425. f /= ( __cv );
  426. return ( *this );
  427. }
  428. //****************************************************************************
  429. //
  430. // << >> <<= >>=
  431. //
  432. //****************************************************************************
  433. #if 0
  434. inline int operator << ( int __i ) {
  435. // f = f << __i;
  436. return ( f<<__i );
  437. }
  438. #endif
  439. inline fixed &fixed::operator <<= ( int __i ) {
  440. f <<= __i;
  441. return ( *this );
  442. }
  443. #if 0
  444. inline int operator >> ( int __i ) {
  445. // f = f >> __i;
  446. return (f >>__i );
  447. }
  448. #endif
  449. inline fixed &fixed::operator >>= ( int __i ) {
  450. f >>= __i;
  451. return ( *this );
  452. }
  453. inline fixed fixed::operator + () const {
  454. return( *this );
  455. }
  456. inline fixed fixed::operator - () const {
  457. return( -f );
  458. }
  459. //****************************************************************************
  460. //
  461. // Conditionals
  462. //
  463. // ==
  464. //
  465. //****************************************************************************
  466. inline int operator == ( fixed const &__f0, fixed const &__f1 ) {
  467. return ( __f0.f == __f1.f );
  468. }
  469. inline int operator == ( fixed const &__f0, int __f1 ) {
  470. return ( __f0.f == (__f1<<FRACTION) );
  471. }
  472. inline int operator == ( fixed const &__f0, short __f1 ) {
  473. return ( __f0.f == (__f1<<FRACTION) );
  474. }
  475. inline int operator == ( int __f1 , fixed const &__f0 ) {
  476. return ( __f0.f == (__f1<<FRACTION) );
  477. }
  478. inline int operator == ( short __f1 , fixed const &__f0 ) {
  479. return ( __f0.f == (__f1<<FRACTION) );
  480. }
  481. //****************************************************************************
  482. //
  483. // !=
  484. //
  485. //****************************************************************************
  486. inline int operator != ( fixed const &__f0, fixed const &__f1 ) {
  487. return ( __f0.f != __f1.f );
  488. }
  489. inline int operator != ( fixed const &__f0, int __f1 ) {
  490. return ( __f0.f != (__f1<<FRACTION) );
  491. }
  492. inline int operator != ( fixed const &__f0, short __f1 ) {
  493. return ( __f0.f != (__f1<<FRACTION) );
  494. }
  495. inline int operator != ( int __f1 , fixed const &__f0 ) {
  496. return ( __f0.f != (__f1<<FRACTION) );
  497. }
  498. inline int operator != ( short __f1 , fixed const &__f0 ) {
  499. return ( __f0.f != (__f1<<FRACTION) );
  500. }
  501. //****************************************************************************
  502. //
  503. // <
  504. //
  505. //****************************************************************************
  506. inline int operator < ( fixed const &__f0, fixed const &__f1 ) {
  507. return ( __f0.f < __f1.f );
  508. }
  509. inline int operator < ( fixed const &__f0, long __f1 ) {
  510. return ( __f0.f < __f1 );
  511. }
  512. inline int operator < ( fixed const &__f0, int __f1 ) {
  513. return ( (__f0.f) < (__f1<<FRACTION) );
  514. }
  515. inline int operator < ( fixed const &__f0, short __f1 ) {
  516. return ( (__f0.f) < (__f1<<FRACTION) );
  517. }
  518. inline int operator < ( long __f1 , fixed const &__f0 ) {
  519. return ( __f1 < __f0.f );
  520. }
  521. inline int operator < ( int __f1 , fixed const &__f0 ) {
  522. return ( (__f1<<FRACTION) < (__f0.f) );
  523. }
  524. inline int operator < ( short __f1 , fixed const &__f0 ) {
  525. return ( (__f1<<FRACTION) < (__f0.f) );
  526. }
  527. //****************************************************************************
  528. //
  529. // >
  530. //
  531. //****************************************************************************
  532. inline int operator > ( fixed const &__f0, fixed const &__f1 ) {
  533. return ( __f0.f > __f1.f );
  534. }
  535. inline int operator > ( fixed const &__f0, long __f1 ) {
  536. return ( __f0.f > __f1 );
  537. }
  538. inline int operator > ( fixed const &__f0, int __f1 ) {
  539. return ( (__f0.f) > (__f1<<FRACTION) );
  540. }
  541. inline int operator > ( fixed const &__f0, short __f1 ) {
  542. return ( (__f0.f) > (__f1<<FRACTION) );
  543. }
  544. inline int operator > ( long __f1 , fixed const &__f0 ) {
  545. return ( __f1 > __f0.f );
  546. }
  547. inline int operator > ( int __f1 , fixed const &__f0 ) {
  548. return ( (__f1<<FRACTION) > (__f0.f) );
  549. }
  550. inline int operator > ( short __f1 , fixed const &__f0 ) {
  551. return ( (__f1<<FRACTION) > (__f0.f) );
  552. }
  553. //****************************************************************************
  554. //
  555. // <=
  556. //
  557. //****************************************************************************
  558. inline int operator <= ( fixed const &__f0, fixed const &__f1 ) {
  559. return ( __f0.f <= __f1.f );
  560. }
  561. inline int operator <= ( fixed const &__f0, long __f1 ) {
  562. return ( __f0.f <= __f1 );
  563. }
  564. inline int operator <= ( fixed const &__f0, int __f1 ) {
  565. return ( (__f0.f) <= (__f1<<FRACTION) );
  566. }
  567. inline int operator <= ( fixed const &__f0, short __f1 ) {
  568. return ( (__f0.f) <= (__f1<<FRACTION) );
  569. }
  570. inline int operator <= ( int __f1 , fixed const &__f0 ) {
  571. return ( (__f1<<FRACTION) <= (__f0.f) );
  572. }
  573. inline int operator <= ( short __f1 , fixed const &__f0 ) {
  574. return ( (__f1<<FRACTION) <= (__f0.f) );
  575. }
  576. //****************************************************************************
  577. //
  578. // >=
  579. //
  580. //****************************************************************************
  581. inline int operator >= ( fixed const &__f0, fixed const &__f1 ) {
  582. return ( __f0.f >= __f1.f );
  583. }
  584. inline int operator >= ( fixed const &__f0, long __f1 ) {
  585. return ( __f0.f >= __f1 );
  586. }
  587. inline int operator >= ( fixed const &__f0, int __f1 ) {
  588. return ( (__f0.f) >= (__f1<<FRACTION) );
  589. }
  590. inline int operator >= ( fixed const &__f0, short __f1 ) {
  591. return ( (__f0.f) >= (__f1<<FRACTION) );
  592. }
  593. inline int operator >= ( int __f1 , fixed const &__f0 ) {
  594. return ( (__f1<<FRACTION) >= (__f0.f) );
  595. }
  596. inline int operator >= ( short __f1 , fixed const &__f0 ) {
  597. return ( (__f1<<FRACTION) >= (__f0.f) );
  598. }
  599. #if 0
  600. inline Complex conj( Complex const &__cv ) {
  601. return Complex( __cv.real(), -__cv.imag() );
  602. }
  603. inline double Complex::real() const {
  604. return( __r );
  605. }
  606. inline double real( Complex const &__cv ) {
  607. return( __cv.real() );
  608. }
  609. inline double norm( Complex const &__cv ) {
  610. return( __cv.real() * __cv.real() + __cv.imag() * __cv.imag() );
  611. }
  612. double abs ( Complex const & ); // magnitude of vector
  613. Complex acos ( Complex const & ); // arccosine
  614. Complex acosh( Complex const & ); // hyperbolic arccosine
  615. double arg ( Complex const & ); // angle of vector
  616. Complex asin ( Complex const & ); // arcsin
  617. Complex asinh( Complex const & ); // hyperbolic arcsin
  618. Complex atan ( Complex const & ); // arctangent
  619. Complex atanh( Complex const & ); // hyperbolic arctangent
  620. Complex conj ( Complex const & ); // conjugate
  621. Complex cos ( Complex const & ); // cosine
  622. Complex cosh ( Complex const & ); // hyperbolic cosine
  623. Complex exp ( Complex const & ); // e raised to a power
  624. double imag ( Complex const & ); // imaginary part
  625. Complex log ( Complex const & ); // log base e
  626. Complex log10( Complex const & ); // log base 10
  627. double norm ( Complex const & ); // square of magnitude
  628. Complex polar( double __mag,
  629. double __angle = 0 ); // polar to Complex
  630. Complex pow ( Complex const &__base, // Complex ** Complex
  631. Complex const &__power );
  632. Complex pow ( Complex const &__base, // Complex ** double
  633. double __power );
  634. Complex pow ( double __base, // double ** Complex
  635. Complex const &__power );
  636. Complex pow ( Complex const &__base, // Complex ** int
  637. int __power );
  638. double real ( Complex const & ); // real part
  639. Complex sin ( Complex const & ); // sin
  640. Complex sinh ( Complex const & ); // hyperbolic sin
  641. Complex sqrt ( Complex const & ); // square root
  642. Complex tan ( Complex const & ); // tan
  643. Complex tanh ( Complex const & ); // hyperbolic tangent
  644. #endif