summaryrefslogtreecommitdiff
path: root/mpc/doc/mpc.info
blob: 6b4167590801c2aa23e3d5e1d748bdf002915ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
This is mpc.info, produced by makeinfo version 5.2 from mpc.texi.

This manual is for GNU MPC, a library for multiple precision complex
arithmetic, version 1.0.3 of February 2015.

   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012 INRIA

     Permission is granted to copy, distribute and/or modify this
     document under the terms of the GNU Free Documentation License,
     Version 1.3 or any later version published by the Free Software
     Foundation; with no Invariant Sections.  A copy of the license is
     included in the section entitled "GNU Free Documentation License."
INFO-DIR-SECTION GNU Packages
START-INFO-DIR-ENTRY
* mpc: (mpc)Multiple Precision Complex Library.
END-INFO-DIR-ENTRY


File: mpc.info,  Node: Top,  Next: Copying,  Up: (dir)

GNU MPC
*******

This manual documents how to install and use the GNU Multiple Precision
Complex Library, version 1.0.3

* Menu:

* Copying::                     GNU MPC Copying Conditions (LGPL).
* Introduction to GNU MPC::         Brief introduction to GNU MPC.
* Installing GNU MPC::              How to configure and compile the GNU MPC library.
* Reporting Bugs::              How to usefully report bugs.
* GNU MPC Basics::                  What every GNU MPC user should know.
* Complex Functions::           Functions for arithmetic on complex numbers.
* References::
* Concept Index::
* Function Index::
* GNU Free Documentation License::


File: mpc.info,  Node: Copying,  Next: Introduction to GNU MPC,  Prev: Top,  Up: Top

GNU MPC Copying Conditions
**************************

GNU MPC is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

   GNU MPC is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
License along with this program.  If not, see
<http://www.gnu.org/licenses/>.


File: mpc.info,  Node: Introduction to GNU MPC,  Next: Installing GNU MPC,  Prev: Copying,  Up: Top

1 Introduction to GNU MPC
*************************

GNU MPC is a portable library written in C for arbitrary precision
arithmetic on complex numbers providing correct rounding.  It implements
a multiprecision equivalent of the C99 standard.  It builds upon the GNU
MP and the GNU MPFR libraries.

1.1 How to use this Manual
==========================

Everyone should read *note GNU MPC Basics::.  If you need to install the
library yourself, you need to read *note Installing GNU MPC::, too.

   The remainder of the manual can be used for later reference, although
it is probably a good idea to skim through it.


File: mpc.info,  Node: Installing GNU MPC,  Next: Reporting Bugs,  Prev: Introduction to GNU MPC,  Up: Top

2 Installing GNU MPC
********************

To build GNU MPC, you first have to install GNU MP (version 4.3.2 or
higher) and GNU MPFR (version 2.4.2 or higher) on your computer.  You
need a C compiler; GCC version 4.4 or higher is recommended, since GNU
MPC may trigger a bug in previous versions, see the thread at
<http://lists.gforge.inria.fr/pipermail/mpc-discuss/2011-February/000823.html>.
And you need a standard Unix 'make' program, plus some other standard
Unix utility programs.

   Here are the steps needed to install the library on Unix systems:

  1. 'tar xzf mpc-1.0.3.tar.gz'

  2. 'cd mpc-1.0.3'

  3. './configure'

     if GMP and GNU MPFR are installed into standard directories, that
     is, directories that are searched by default by the compiler and
     the linking tools.

     './configure --with-gmp=<gmp_install_dir>'

     is used to indicate a different location where GMP is installed.
     Alternatively, you can specify directly GMP include and GMP lib
     directories with './configure --with-gmp-lib=<gmp_lib_dir>
     --with-gmp-include=<gmp_include_dir>'.

     './configure --with-mpfr=<mpfr_install_dir>'

     is used to indicate a different location where GNU MPFR is
     installed.  Alternatively, you can specify directly GNU MPFR
     include and GNU MPFR lib directories with './configure
     --with-mpf-lib=<mpfr_lib_dir>
     --with-mpfr-include=<mpfr_include_dir>'.

     Another useful parameter is '--prefix', which can be used to
     specify an alternative installation location instead of
     '/usr/local'; see 'make install' below.

     To enable checking for memory leaks using 'valgrind' during 'make
     check', add the parameter '--enable-valgrind-tests'.

     If for debugging purposes you wish to log calls to GNU MPC
     functions from within your code, add the parameter
     '--enable-logging'.  In your code, replace the inclusion of 'mpc.h'
     by 'mpc-log.h' and link the executable dynamically.  Then all calls
     to functions with only complex arguments are printed to 'stderr' in
     the following form: First, the function name is given, followed by
     its type such as 'c_cc', meaning that the function has one complex
     result (one 'c' in front of the '_'), computed from two complex
     arguments (two 'c' after the '_').  Then, the precisions of the
     real and the imaginary part of the first result is given, followed
     by the second one and so on.  Finally, for each argument, the
     precisions of its real and imaginary part are specified and the
     argument itself is printed in hexadecimal via the function
     'mpc_out_str' (*note String and Stream Input and Output::).  The
     option requires a dynamic library, so it may not be combined with
     '--disable-shared'.

     Use './configure --help' for an exhaustive list of parameters.

  4. 'make'

     This compiles GNU MPC in the working directory.

  5. 'make check'

     This will make sure GNU MPC was built correctly.

     If you get error messages, please report them to
     'mpc-discuss@lists.gforge.inria.fr' (*Note Reporting Bugs::, for
     information on what to include in useful bug reports).

  6. 'make install'

     This will copy the file 'mpc.h' to the directory
     '/usr/local/include', the file 'libmpc.a' to the directory
     '/usr/local/lib', and the file 'mpc.info' to the directory
     '/usr/local/share/info' (or if you passed the '--prefix' option to
     'configure', using the prefix directory given as argument to
     '--prefix' instead of '/usr/local').  Note: you need write
     permissions on these directories.

2.1 Other 'make' Targets
========================

There are some other useful make targets:

   * 'info'

     Create an info version of the manual, in 'mpc.info'.

   * 'pdf'

     Create a PDF version of the manual, in 'doc/mpc.pdf'.

   * 'dvi'

     Create a DVI version of the manual, in 'doc/mpc.dvi'.

   * 'ps'

     Create a Postscript version of the manual, in 'doc/mpc.ps'.

   * 'html'

     Create an HTML version of the manual, in several pages in the
     directory 'doc/mpc.html'; if you want only one output HTML file,
     then type 'makeinfo --html --no-split mpc.texi' instead.

   * 'clean'

     Delete all object files and archive files, but not the
     configuration files.

   * 'distclean'

     Delete all files not included in the distribution.

   * 'uninstall'

     Delete all files copied by 'make install'.

2.2 Known Build Problems
========================

On AIX, if GMP was built with the 64-bit ABI, before building and
testing GNU MPC, it might be necessary to set the 'OBJECT_MODE'
environment variable to 64 by, e.g.,

   'export OBJECT_MODE=64'

   This has been tested with the C compiler IBM XL C/C++ Enterprise
Edition V8.0 for AIX, version: 08.00.0000.0021, GMP 4.2.4 and GNU MPFR
2.4.1.

   Please report any other problems you encounter to
'mpc-discuss@lists.gforge.inria.fr'.  *Note Reporting Bugs::.


File: mpc.info,  Node: Reporting Bugs,  Next: GNU MPC Basics,  Prev: Installing GNU MPC,  Up: Top

3 Reporting Bugs
****************

If you think you have found a bug in the GNU MPC library, please
investigate and report it.  We have made this library available to you,
and it is not to ask too much from you, to ask you to report the bugs
that you find.

   There are a few things you should think about when you put your bug
report together.

   You have to send us a test case that makes it possible for us to
reproduce the bug.  Include instructions on how to run the test case.

   You also have to explain what is wrong; if you get a crash, or if the
results printed are incorrect and in that case, in what way.

   Please include compiler version information in your bug report.  This
can be extracted using 'gcc -v', or 'cc -V' on some machines.  Also,
include the output from 'uname -a'.

   If your bug report is good, we will do our best to help you to get a
corrected version of the library; if the bug report is poor, we will not
do anything about it (aside of chiding you to send better bug reports).

   Send your bug report to: 'mpc-discuss@lists.gforge.inria.fr'.

   If you think something in this manual is unclear, or downright
incorrect, or if the language needs to be improved, please send a note
to the same address.


File: mpc.info,  Node: GNU MPC Basics,  Next: Complex Functions,  Prev: Reporting Bugs,  Up: Top

4 GNU MPC Basics
****************

All declarations needed to use GNU MPC are collected in the include file
'mpc.h'.  It is designed to work with both C and C++ compilers.  You
should include that file in any program using the GNU MPC library by
adding the line
        #include "mpc.h"

4.1 Nomenclature and Types
==========================

"Complex number" or "Complex" for short, is a pair of two arbitrary
precision floating-point numbers (for the real and imaginary parts).
The C data type for such objects is 'mpc_t'.

The "Precision" is the number of bits used to represent the mantissa of
the real and imaginary parts; the corresponding C data type is
'mpfr_prec_t'.  For more details on the allowed precision range, *note
(mpfr.info)Nomenclature and Types::.

The "rounding mode" specifies the way to round the result of a complex
operation, in case the exact result can not be represented exactly in
the destination mantissa; the corresponding C data type is 'mpc_rnd_t'.
A complex rounding mode is a pair of two rounding modes: one for the
real part, one for the imaginary part.

4.2 Function Classes
====================

There is only one class of functions in the GNU MPC library, namely
functions for complex arithmetic.  The function names begin with 'mpc_'.
The associated type is 'mpc_t'.

4.3 GNU MPC Variable Conventions
================================

As a general rule, all GNU MPC functions expect output arguments before
input arguments.  This notation is based on an analogy with the
assignment operator.

   GNU MPC allows you to use the same variable for both input and output
in the same expression.  For example, the main function for
floating-point multiplication, 'mpc_mul', can be used like this:
'mpc_mul (x, x, x, rnd_mode)'.  This computes the square of X with
rounding mode 'rnd_mode' and puts the result back in X.

   Before you can assign to an GNU MPC variable, you need to initialize
it by calling one of the special initialization functions.  When you are
done with a variable, you need to clear it out, using one of the
functions for that purpose.

   A variable should only be initialized once, or at least cleared out
between each initialization.  After a variable has been initialized, it
may be assigned to any number of times.

   For efficiency reasons, avoid to initialize and clear out a variable
in loops.  Instead, initialize it before entering the loop, and clear it
out after the loop has exited.

   You do not need to be concerned about allocating additional space for
GNU MPC variables, since each of its real and imaginary part has a
mantissa of fixed size.  Hence unless you change its precision, or clear
and reinitialize it, a complex variable will have the same allocated
space during all its life.

4.4 Rounding Modes
==================

A complex rounding mode is of the form 'MPC_RNDxy' where 'x' and 'y' are
one of 'N' (to nearest), 'Z' (towards zero), 'U' (towards plus
infinity), 'D' (towards minus infinity).  The first letter refers to the
rounding mode for the real part, and the second one for the imaginary
part.  For example 'MPC_RNDZU' indicates to round the real part towards
zero, and the imaginary part towards plus infinity.

   The 'round to nearest' mode works as in the IEEE P754 standard: in
case the number to be rounded lies exactly in the middle of two
representable numbers, it is rounded to the one with the least
significant bit set to zero.  For example, the number 5, which is
represented by (101) in binary, is rounded to (100)=4 with a precision
of two bits, and not to (110)=6.

4.5 Return Value
================

Most GNU MPC functions have a return value of type 'int', which is used
to indicate the position of the rounded real and imaginary parts with
respect to the exact (infinite precision) values.  If this integer is
'i', the macros 'MPC_INEX_RE(i)' and 'MPC_INEX_IM(i)' give 0 if the
corresponding rounded value is exact, a negative value if the rounded
value is less than the exact one, and a positive value if it is greater
than the exact one.  Similarly, functions computing a result of type
'mpfr_t' return an integer that is 0, positive or negative depending on
whether the rounded value is the same, larger or smaller then the exact
result.

   Some functions, such as 'mpc_sin_cos', compute two complex results;
the macros 'MPC_INEX1(i)' and 'MPC_INEX2(i)', applied to the return
value 'i' of such a function, yield the exactness value corresponding to
the first or the second computed value, respectively.

4.6 Branch Cuts And Special Values
==================================

Some complex functions have branch cuts, across which the function is
discontinous.  In GNU MPC, the branch cuts chosen are the same as those
specified for the corresponding functions in the ISO C99 standard.

   Likewise, when evaluated at a point whose real or imaginary part is
either infinite or a NaN or a signed zero, a function returns the same
value as those specified for the corresponding function in the ISO C99
standard.


File: mpc.info,  Node: Complex Functions,  Next: References,  Prev: GNU MPC Basics,  Up: Top

5 Complex Functions
*******************

The complex functions expect arguments of type 'mpc_t'.

   The GNU MPC floating-point functions have an interface that is
similar to the GNU MP integer functions.  The function prefix for
operations on complex numbers is 'mpc_'.

   The precision of a computation is defined as follows: Compute the
requested operation exactly (with "infinite precision"), and round the
result to the destination variable precision with the given rounding
mode.

   The GNU MPC complex functions are intended to be a smooth extension
of the IEEE P754 arithmetic.  The results obtained on one computer
should not differ from the results obtained on a computer with a
different word size.

* Menu:

* Initializing Complex Numbers::
* Assigning Complex Numbers::
* Converting Complex Numbers::
* String and Stream Input and Output::
* Complex Comparison::
* Projection & Decomposing::
* Basic Arithmetic::
* Power Functions and Logarithm::
* Trigonometric Functions::
* Miscellaneous Complex Functions::
* Advanced Functions::
* Internals::


File: mpc.info,  Node: Initializing Complex Numbers,  Next: Assigning Complex Numbers,  Up: Complex Functions

5.1 Initialization Functions
============================

An 'mpc_t' object must be initialized before storing the first value in
it.  The functions 'mpc_init2' and 'mpc_init3' are used for that
purpose.

 -- Function: void mpc_init2 (mpc_t Z, mpfr_prec_t PREC)
     Initialize Z to precision PREC bits and set its real and imaginary
     parts to NaN. Normally, a variable should be initialized once only
     or at least be cleared, using 'mpc_clear', between initializations.

 -- Function: void mpc_init3 (mpc_t Z, mpfr_prec_t PREC_R, mpfr_prec_t
          PREC_I)
     Initialize Z with the precision of its real part being PREC_R bits
     and the precision of its imaginary part being PREC_I bits, and set
     the real and imaginary parts to NaN.

 -- Function: void mpc_clear (mpc_t Z)
     Free the space occupied by Z.  Make sure to call this function for
     all 'mpc_t' variables when you are done with them.

   Here is an example on how to initialize complex variables:
     {
       mpc_t x, y;
       mpc_init2 (x, 256);		/* precision _exactly_ 256 bits */
       mpc_init3 (y, 100, 50);	/* 100/50 bits for the real/imaginary part */
       ...
       mpc_clear (x);
       mpc_clear (y);
     }

   The following function is useful for changing the precision during a
calculation.  A typical use would be for adjusting the precision
gradually in iterative algorithms like Newton-Raphson, making the
computation precision closely match the actual accurate part of the
numbers.

 -- Function: void mpc_set_prec (mpc_t X, mpfr_prec_t PREC)
     Reset the precision of X to be *exactly* PREC bits, and set its
     real/imaginary parts to NaN. The previous value stored in X is
     lost.  It is equivalent to a call to 'mpc_clear(x)' followed by a
     call to 'mpc_init2(x, prec)', but more efficient as no allocation
     is done in case the current allocated space for the mantissa of X
     is sufficient.

 -- Function: mpfr_prec_t mpc_get_prec (mpc_t X)
     If the real and imaginary part of X have the same precision, it is
     returned, otherwise, 0 is returned.

 -- Function: void mpc_get_prec2 (mpfr_prec_t* PR, mpfr_prec_t* PI,
          mpc_t X)
     Returns the precision of the real part of X via PR and of its
     imaginary part via PI.


File: mpc.info,  Node: Assigning Complex Numbers,  Next: Converting Complex Numbers,  Prev: Initializing Complex Numbers,  Up: Complex Functions

5.2 Assignment Functions
========================

These functions assign new values to already initialized complex numbers
(*note Initializing Complex Numbers::).  When using any functions with
'intmax_t' or 'uintmax_t' parameters, you must include '<stdint.h>' or
'<inttypes.h>' _before_ 'mpc.h', to allow 'mpc.h' to define prototypes
for these functions.  Similarly, functions with parameters of type
'complex' or 'long complex' are defined only if '<complex.h>' is
included _before_ 'mpc.h'.  If you need assignment functions that are
not in the current API, you can define them using the 'MPC_SET_X_Y'
macro (*note Advanced Functions::).

 -- Function: int mpc_set (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set the value of ROP from OP, rounded to the precision of ROP with
     the given rounding mode RND.

 -- Function: int mpc_set_ui (mpc_t ROP, unsigned long int OP, mpc_rnd_t
          RND)
 -- Function: int mpc_set_si (mpc_t ROP, long int OP, mpc_rnd_t RND)
 -- Function: int mpc_set_uj (mpc_t ROP, uintmax_t OP, mpc_rnd_t RND)
 -- Function: int mpc_set_sj (mpc_t ROP, intmax_t OP, mpc_rnd_t RND)
 -- Function: int mpc_set_d (mpc_t ROP, double OP, mpc_rnd_t RND)
 -- Function: int mpc_set_ld (mpc_t ROP, long double OP, mpc_rnd_t RND)
 -- Function: int mpc_set_dc (mpc_t ROP, double _Complex OP, mpc_rnd_t
          RND)
 -- Function: int mpc_set_ldc (mpc_t ROP, long double _Complex OP,
          mpc_rnd_t RND)
 -- Function: int mpc_set_z (mpc_t ROP, mpz_t OP mpc_rnd_t RND)
 -- Function: int mpc_set_q (mpc_t ROP, mpq_t OP mpc_rnd_t RND)
 -- Function: int mpc_set_f (mpc_t ROP, mpf_t OP mpc_rnd_t RND)
 -- Function: int mpc_set_fr (mpc_t ROP, mpfr_t OP, mpc_rnd_t RND)
     Set the value of ROP from OP, rounded to the precision of ROP with
     the given rounding mode RND.  The argument OP is interpreted as
     real, so the imaginary part of ROP is set to zero with a positive
     sign.  Please note that even a 'long int' may have to be rounded,
     if the destination precision is less than the machine word width.
     For 'mpc_set_d', be careful that the input number OP may not be
     exactly representable as a double-precision number (this happens
     for 0.1 for instance), in which case it is first rounded by the C
     compiler to a double-precision number, and then only to a complex
     number.

 -- Function: int mpc_set_ui_ui (mpc_t ROP, unsigned long int OP1,
          unsigned long int OP2, mpc_rnd_t RND)
 -- Function: int mpc_set_si_si (mpc_t ROP, long int OP1, long int OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_set_uj_uj (mpc_t ROP, uintmax_t OP1, uintmax_t
          OP2, mpc_rnd_t RND)
 -- Function: int mpc_set_sj_sj (mpc_t ROP, intmax_t OP1, intmax_t OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_set_d_d (mpc_t ROP, double OP1, double OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_set_ld_ld (mpc_t ROP, long double OP1, long double
          OP2, mpc_rnd_t RND)
 -- Function: int mpc_set_z_z (mpc_t ROP, mpz_t OP1, mpz_t OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_set_q_q (mpc_t ROP, mpq_t OP1, mpq_t OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_set_f_f (mpc_t ROP, mpf_t OP1, mpf_t OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_set_fr_fr (mpc_t ROP, mpfr_t OP1, mpfr_t OP2,
          mpc_rnd_t RND)
     Set the real part of ROP from OP1, and its imaginary part from OP2,
     according to the rounding mode RND.

     Beware that the behaviour of 'mpc_set_fr_fr' is undefined if OP1 or
     OP2 is a pointer to the real or imaginary part of ROP.  To exchange
     the real and the imaginary part of a complex number, either use
     'mpfr_swap (mpc_realref (rop), mpc_imagref (rop))', which also
     exchanges the precisions of the two parts; or use a temporary
     variable.

   For functions assigning complex variables from strings or input
streams, *note String and Stream Input and Output::.

 -- Function: void mpc_set_nan (mpc_t ROP)
     Set ROP to Nan+i*NaN.

 -- Function: void mpc_swap (mpc_t OP1, mpc_t OP2)
     Swap the values of OP1 and OP2 efficiently.  Warning: The
     precisions are exchanged, too; in case these are different,
     'mpc_swap' is thus not equivalent to three 'mpc_set' calls using a
     third auxiliary variable.


File: mpc.info,  Node: Converting Complex Numbers,  Next: String and Stream Input and Output,  Prev: Assigning Complex Numbers,  Up: Complex Functions

5.3 Conversion Functions
========================

The following functions are available only if '<complex.h>' is included
_before_ 'mpc.h'.

 -- Function: double _Complex mpc_get_dc (mpc_t OP, mpc_rnd_t RND)
 -- Function: long double _Complex mpc_get_ldc (mpc_t OP, mpc_rnd_t RND)
     Convert OP to a C complex number, using the rounding mode RND.

   For functions converting complex variables to strings or stream
output, *note String and Stream Input and Output::.


File: mpc.info,  Node: String and Stream Input and Output,  Next: Complex Comparison,  Prev: Converting Complex Numbers,  Up: Complex Functions

5.4 String and Stream Input and Output
======================================

 -- Function: int mpc_strtoc (mpc_t ROP, const char *NPTR, char
          **ENDPTR, int BASE, mpc_rnd_t RND)
     Read a complex number from a string NPTR in base BASE, rounded to
     the precision of ROP with the given rounding mode RND.  The BASE
     must be either 0 or a number from 2 to 36 (otherwise the behaviour
     is undefined).  If NPTR starts with valid data, the result is
     stored in ROP, the usual inexact value is returned (*note Return
     Value: return-value.) and, if ENDPTR is not the null pointer,
     *ENDPTR points to the character just after the valid data.
     Otherwise, ROP is set to 'NaN + i * NaN', -1 is returned and, if
     ENDPTR is not the null pointer, the value of NPTR is stored in the
     location referenced by ENDPTR.

     The expected form of a complex number string is either a real
     number (an optional leading whitespace, an optional sign followed
     by a floating-point number), or a pair of real numbers in
     parentheses separated by whitespace.  If a real number is read, the
     missing imaginary part is set to +0.  The form of a floating-point
     number depends on the base and is described in the documentation of
     'mpfr_strtofr' (*note (mpfr.info)Assignment Functions::).  For
     instance, '"3.1415926"', '"(1.25e+7 +.17)"', '"(@nan@ 2)"' and
     '"(-0 -7)"' are valid strings for BASE = 10.  If BASE = 0, then a
     prefix may be used to indicate the base in which the floating-point
     number is written.  Use prefix '0b' for binary numbers, prefix '0x'
     for hexadecimal numbers, and no prefix for decimal numbers.  The
     real and imaginary part may then be written in different bases.
     For instance, '"(1.024e+3 +2.05e+3)"' and '"(0b1p+10 +0x802)"' are
     valid strings for 'base'=0 and represent the same value.

 -- Function: int mpc_set_str (mpc_t ROP, const char *S, int BASE,
          mpc_rnd_t rnd)
     Set ROP to the value of the string S in base BASE, rounded to the
     precision of ROP with the given rounding mode RND.  See the
     documentation of 'mpc_strtoc' for a detailed description of the
     valid string formats.  Contrarily to 'mpc_strtoc', 'mpc_set_str'
     requires the _whole_ string to represent a valid complex number
     (potentially followed by additional white space).  This function
     returns the usual inexact value (*note Return Value: return-value.)
     if the entire string up to the final null character is a valid
     number in base BASE; otherwise it returns -1, and ROP is set to
     NaN+i*NaN.

 -- Function: char * mpc_get_str (int B, size_t N, mpc_t OP, mpc_rnd_t
          RND)
     Convert OP to a string containing its real and imaginary parts,
     separated by a space and enclosed in a pair of parentheses.  The
     numbers are written in base B (which may vary from 2 to 36) and
     rounded according to RND.  The number of significant digits, at
     least 2, is given by N.  It is also possible to let N be zero, in
     which case the number of digits is chosen large enough so that
     re-reading the printed value with the same precision, assuming both
     output and input use rounding to nearest, will recover the original
     value of OP.  Note that 'mpc_get_str' uses the decimal point of the
     current locale if available, and '.' otherwise.

     The string is generated using the current memory allocation
     function ('malloc' by default, unless it has been modified using
     the custom memory allocation interface of 'gmp'); once it is not
     needed any more, it should be freed by calling 'mpc_free_str'.

 -- Function: void mpc_free_str (char *STR)
     Free the string STR, which needs to have been allocated by a call
     to 'mpc_get_str'.

   The following two functions read numbers from input streams and write
them to output streams.  When using any of these functions, you need to
include 'stdio.h' _before_ 'mpc.h'.

 -- Function: int mpc_inp_str (mpc_t ROP, FILE *STREAM, size_t *READ,
          int BASE, mpc_rnd_t RND)
     Input a string in base BASE in the same format as for 'mpc_strtoc'
     from stdio stream STREAM, rounded according to RND, and put the
     read complex number into ROP.  If STREAM is the null pointer, ROP
     is read from 'stdin'.  Return the usual inexact value; if an error
     occurs, set ROP to 'NaN + i * NaN' and return -1.  If READ is not
     the null pointer, it is set to the number of read characters.

     Unlike 'mpc_strtoc', the function 'mpc_inp_str' does not possess
     perfect knowledge of the string to transform and has to read it
     character by character, so it behaves slightly differently: It
     tries to read a string describing a complex number and processes
     this string through a call to 'mpc_set_str'.  Precisely, after
     skipping optional whitespace, a minimal string is read according to
     the regular expression 'mpfr | '(' \s* mpfr \s+ mpfr \s* ')'',
     where '\s' denotes a whitespace, and 'mpfr' is either a string
     containing neither whitespaces nor parentheses, or
     'nan(n-char-sequence)' or '@nan@(n-char-sequence)' (regardless of
     capitalisation) with 'n-char-sequence' a string of ascii letters,
     digits or ''_''.

     For instance, upon input of '"nan(13 1)"', the function
     'mpc_inp_str' starts to recognise a value of NaN followed by an
     n-char-sequence indicated by the opening parenthesis; as soon as
     the space is reached, it becocmes clear that the expression in
     parentheses is not an n-char-sequence, and the error flag -1 is
     returned after 6 characters have been consumed from the stream (the
     whitespace itself remaining in the stream).  The function
     'mpc_strtoc', on the other hand, may track back when reaching the
     whitespace; it treats the string as the two successive complex
     numbers 'NaN + i * 0' and '13 + i'.  It is thus recommended to have
     a whitespace follow each floating point number to avoid this
     problem.

 -- Function: size_t mpc_out_str (FILE *STREAM, int BASE, size_t
          N_DIGITS, mpc_t OP, mpc_rnd_t RND)
     Output OP on stdio stream STREAM in base BASE, rounded according to
     RND, in the same format as for 'mpc_strtoc' If STREAM is the null
     pointer, ROP is written to 'stdout'.

     Return the number of characters written.


File: mpc.info,  Node: Complex Comparison,  Next: Projection & Decomposing,  Prev: String and Stream Input and Output,  Up: Complex Functions

5.5 Comparison Functions
========================

 -- Function: int mpc_cmp (mpc_t OP1, mpc_t OP2)
 -- Function: int mpc_cmp_si_si (mpc_t OP1, long int OP2R, long int
          OP2I)
 -- Macro: int mpc_cmp_si (mpc_t OP1, long int OP2)

     Compare OP1 and OP2, where in the case of 'mpc_cmp_si_si', OP2 is
     taken to be OP2R + i OP2I.  The return value C can be decomposed
     into 'x = MPC_INEX_RE(c)' and 'y = MPC_INEX_IM(c)', such that X is
     positive if the real part of OP1 is greater than that of OP2, zero
     if both real parts are equal, and negative if the real part of OP1
     is less than that of OP2, and likewise for Y.  Both OP1 and OP2 are
     considered to their full own precision, which may differ.  It is
     not allowed that one of the operands has a NaN (Not-a-Number) part.

     The storage of the return value is such that equality can be simply
     checked with 'mpc_cmp (op1, op2) == 0'.


File: mpc.info,  Node: Projection & Decomposing,  Next: Basic Arithmetic,  Prev: Complex Comparison,  Up: Complex Functions

5.6 Projection and Decomposing Functions
========================================

 -- Function: int mpc_real (mpfr_t ROP, mpc_t OP, mpfr_rnd_t RND)
     Set ROP to the value of the real part of OP rounded in the
     direction RND.

 -- Function: int mpc_imag (mpfr_t ROP, mpc_t OP, mpfr_rnd_t RND)
     Set ROP to the value of the imaginary part of OP rounded in the
     direction RND.

 -- Macro: mpfr_t mpc_realref (mpc_t OP)
 -- Macro: mpfr_t mpc_imagref (mpc_t OP)
     Return a reference to the real part and imaginary part of OP,
     respectively.  The 'mpfr' functions can be used on the result of
     these macros (note that the 'mpfr_t' type is itself a pointer).

 -- Function: int mpc_arg (mpfr_t ROP, mpc_t OP, mpfr_rnd_t RND)
     Set ROP to the argument of OP, with a branch cut along the negative
     real axis.

 -- Function: int mpc_proj (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Compute a projection of OP onto the Riemann sphere.  Set ROP to OP
     rounded in the direction RND, except when at least one part of OP
     is infinite (even if the other part is a NaN) in which case the
     real part of ROP is set to plus infinity and its imaginary part to
     a signed zero with the same sign as the imaginary part of OP.


File: mpc.info,  Node: Basic Arithmetic,  Next: Power Functions and Logarithm,  Prev: Projection & Decomposing,  Up: Complex Functions

5.7 Basic Arithmetic Functions
==============================

All the following functions are designed in such a way that, when
working with real numbers instead of complex numbers, their complexity
should essentially be the same as with the GNU MPFR library, with only a
marginal overhead due to the GNU MPC layer.

 -- Function: int mpc_add (mpc_t ROP, mpc_t OP1, mpc_t OP2, mpc_rnd_t
          RND)
 -- Function: int mpc_add_ui (mpc_t ROP, mpc_t OP1, unsigned long int
          OP2, mpc_rnd_t RND)
 -- Function: int mpc_add_fr (mpc_t ROP, mpc_t OP1, mpfr_t OP2,
          mpc_rnd_t RND)
     Set ROP to OP1 + OP2 rounded according to RND.

 -- Function: int mpc_sub (mpc_t ROP, mpc_t OP1, mpc_t OP2, mpc_rnd_t
          RND)
 -- Function: int mpc_sub_fr (mpc_t ROP, mpc_t OP1, mpfr_t OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_fr_sub (mpc_t ROP, mpfr_t OP1, mpc_t OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_sub_ui (mpc_t ROP, mpc_t OP1, unsigned long int
          OP2, mpc_rnd_t RND)
 -- Macro: int mpc_ui_sub (mpc_t ROP, unsigned long int OP1, mpc_t OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_ui_ui_sub (mpc_t ROP, unsigned long int RE1,
          unsigned long int IM1, mpc_t OP2, mpc_rnd_t RND)
     Set ROP to OP1 - OP2 rounded according to RND.  For
     'mpc_ui_ui_sub', OP1 is RE1 + IM1.

 -- Function: int mpc_neg (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to -OP rounded according to RND.  Just changes the sign if
     ROP and OP are the same variable.

 -- Function: int mpc_mul (mpc_t ROP, mpc_t OP1, mpc_t OP2, mpc_rnd_t
          RND)
 -- Function: int mpc_mul_ui (mpc_t ROP, mpc_t OP1, unsigned long int
          OP2, mpc_rnd_t RND)
 -- Function: int mpc_mul_si (mpc_t ROP, mpc_t OP1, long int OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_mul_fr (mpc_t ROP, mpc_t OP1, mpfr_t OP2,
          mpc_rnd_t RND)
     Set ROP to OP1 times OP2 rounded according to RND.  Note: for
     'mpc_mul', in case OP1 and OP2 have the same value, use 'mpc_sqr'
     for better efficiency.

 -- Function: int mpc_mul_i (mpc_t ROP, mpc_t OP, int SGN, mpc_rnd_t
          RND)
     Set ROP to OP times the imaginary unit i if SGN is non-negative,
     set ROP to OP times -i otherwise, in both cases rounded according
     to RND.

 -- Function: int mpc_sqr (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the square of OP rounded according to RND.

 -- Function: int mpc_fma (mpc_t ROP, mpc_t OP1, mpc_t OP2, mpc_t OP3,
          mpc_rnd_t RND)
     Set ROP to OP1*OP2+OP3, rounded according to RND, with only one
     final rounding.

 -- Function: int mpc_div (mpc_t ROP, mpc_t OP1, mpc_t OP2, mpc_rnd_t
          RND)
 -- Function: int mpc_div_ui (mpc_t ROP, mpc_t OP1, unsigned long int
          OP2, mpc_rnd_t RND)
 -- Function: int mpc_div_fr (mpc_t ROP, mpc_t OP1, mpfr_t OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_ui_div (mpc_t ROP, unsigned long int OP1, mpc_t
          OP2, mpc_rnd_t RND)
 -- Function: int mpc_fr_div (mpc_t ROP, mpfr_t OP1, mpc_t OP2,
          mpc_rnd_t RND)
     Set ROP to OP1/OP2 rounded according to RND.

 -- Function: int mpc_conj (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the conjugate of OP rounded according to RND.  Just
     changes the sign of the imaginary part if ROP and OP are the same
     variable.

 -- Function: int mpc_abs (mpfr_t ROP, mpc_t OP, mpfr_rnd_t RND)
     Set the floating-point number ROP to the absolute value of OP,
     rounded in the direction RND.

 -- Function: int mpc_norm (mpfr_t ROP, mpc_t OP, mpfr_rnd_t RND)
     Set the floating-point number ROP to the norm of OP (i.e., the
     square of its absolute value), rounded in the direction RND.

 -- Function: int mpc_mul_2ui (mpc_t ROP, mpc_t OP1, unsigned long int
          OP2, mpc_rnd_t RND)
 -- Function: int mpc_mul_2si (mpc_t ROP, mpc_t OP1, long int OP2,
          mpc_rnd_t RND)
     Set ROP to OP1 times 2 raised to OP2 rounded according to RND.
     Just modifies the exponents of the real and imaginary parts by OP2
     when ROP and OP1 are identical.

 -- Function: int mpc_div_2ui (mpc_t ROP, mpc_t OP1, unsigned long int
          OP2, mpc_rnd_t RND)
 -- Function: int mpc_div_2si (mpc_t ROP, mpc_t OP1, long int OP2,
          mpc_rnd_t RND)
     Set ROP to OP1 divided by 2 raised to OP2 rounded according to RND.
     Just modifies the exponents of the real and imaginary parts by OP2
     when ROP and OP1 are identical.


File: mpc.info,  Node: Power Functions and Logarithm,  Next: Trigonometric Functions,  Prev: Basic Arithmetic,  Up: Complex Functions

5.8 Power Functions and Logarithm
=================================

 -- Function: int mpc_sqrt (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the square root of OP rounded according to RND.  The
     returned value ROP has a non-negative real part, and if its real
     part is zero, a non-negative imaginary part.

 -- Function: int mpc_pow (mpc_t ROP, mpc_t OP1, mpc_t OP2, mpc_rnd_t
          RND)
 -- Function: int mpc_pow_d (mpc_t ROP, mpc_t OP1, double OP2, mpc_rnd_t
          RND)
 -- Function: int mpc_pow_ld (mpc_t ROP, mpc_t OP1, long double OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_pow_si (mpc_t ROP, mpc_t OP1, long OP2, mpc_rnd_t
          RND)
 -- Function: int mpc_pow_ui (mpc_t ROP, mpc_t OP1, unsigned long OP2,
          mpc_rnd_t RND)
 -- Function: int mpc_pow_z (mpc_t ROP, mpc_t OP1, mpz_t OP2, mpc_rnd_t
          RND)
 -- Function: int mpc_pow_fr (mpc_t ROP, mpc_t OP1, mpfr_t OP2,
          mpc_rnd_t RND)
     Set ROP to OP1 raised to the power OP2, rounded according to RND.
     For 'mpc_pow_d', 'mpc_pow_ld', 'mpc_pow_si', 'mpc_pow_ui',
     'mpc_pow_z' and 'mpc_pow_fr', the imaginary part of OP2 is
     considered as +0.  When both OP1 and OP2 are zero, the result has
     real part 1, and imaginary part 0, with sign being the opposite of
     that of OP2.

 -- Function: int mpc_exp (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the exponential of OP, rounded according to RND with the
     precision of ROP.

 -- Function: int mpc_log (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
 -- Function: int mpc_log10 (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the natural and base-10 logarithm of OP respectively,
     rounded according to RND with the precision of ROP.  The principal
     branch is chosen, with the branch cut on the negative real axis, so
     that the imaginary part of the result lies in ]-\pi , \pi] and
     ]-\pi/log(10) , \pi/log(10)] respectively.


File: mpc.info,  Node: Trigonometric Functions,  Next: Miscellaneous Complex Functions,  Prev: Power Functions and Logarithm,  Up: Complex Functions

5.9 Trigonometric Functions
===========================

 -- Function: int mpc_sin (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the sine of OP, rounded according to RND with the
     precision of ROP.

 -- Function: int mpc_cos (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the cosine of OP, rounded according to RND with the
     precision of ROP.

 -- Function: int mpc_sin_cos (mpc_t ROP_SIN, mpc_t ROP_COS, mpc_t OP,
          mpc_rnd_t RND_SIN, mpc_rnd_t RND_COS)
     Set ROP_SIN to the sine of OP, rounded according to RND_SIN with
     the precision of ROP_SIN, and ROP_COS to the cosine of OP, rounded
     according to RND_COS with the precision of ROP_COS.

 -- Function: int mpc_tan (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the tangent of OP, rounded according to RND with the
     precision of ROP.

 -- Function: int mpc_sinh (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the hyperbolic sine of OP, rounded according to RND with
     the precision of ROP.

 -- Function: int mpc_cosh (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the hyperbolic cosine of OP, rounded according to RND
     with the precision of ROP.

 -- Function: int mpc_tanh (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the hyperbolic tangent of OP, rounded according to RND
     with the precision of ROP.

 -- Function: int mpc_asin (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
 -- Function: int mpc_acos (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
 -- Function: int mpc_atan (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the inverse sine, inverse cosine, inverse tangent of OP,
     rounded according to RND with the precision of ROP.

 -- Function: int mpc_asinh (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
 -- Function: int mpc_acosh (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
 -- Function: int mpc_atanh (mpc_t ROP, mpc_t OP, mpc_rnd_t RND)
     Set ROP to the inverse hyperbolic sine, inverse hyperbolic cosine,
     inverse hyperbolic tangent of OP, rounded according to RND with the
     precision of ROP.  The branch cut of MPC_ACOSH is (-\infty, 1).


File: mpc.info,  Node: Miscellaneous Complex Functions,  Next: Advanced Functions,  Prev: Trigonometric Functions,  Up: Complex Functions

5.10 Miscellaneous Functions
============================

 -- Function: int mpc_urandom (mpc_t ROP, gmp_randstate_t STATE)
     Generate a uniformly distributed random complex in the unit square
     [0, 1] x [0, 1].  Return 0, unless an exponent in the real or
     imaginary part is not in the current exponent range, in which case
     that part is set to NaN and a zero value is returned.  The second
     argument is a 'gmp_randstate_t' structure which should be created
     using the GMP 'rand_init' function, see the GMP manual.

 -- Function: const char * mpc_get_version (void)
     Return the GNU MPC version, as a null-terminated string.

 -- Macro: MPC_VERSION
 -- Macro: MPC_VERSION_MAJOR
 -- Macro: MPC_VERSION_MINOR
 -- Macro: MPC_VERSION_PATCHLEVEL
 -- Macro: MPC_VERSION_STRING
     'MPC_VERSION' is the version of GNU MPC as a preprocessing
     constant.  'MPC_VERSION_MAJOR', 'MPC_VERSION_MINOR' and
     'MPC_VERSION_PATCHLEVEL' are respectively the major, minor and
     patch level of GNU MPC version, as preprocessing constants.
     'MPC_VERSION_STRING' is the version as a string constant, which can
     be compared to the result of 'mpc_get_version' to check at run time
     the header file and library used match:
          if (strcmp (mpc_get_version (), MPC_VERSION_STRING))
            fprintf (stderr, "Warning: header and library do not match\n");
     Note: Obtaining different strings is not necessarily an error, as
     in general, a program compiled with some old GNU MPC version can be
     dynamically linked with a newer GNU MPC library version (if allowed
     by the library versioning system).

 -- Macro: long MPC_VERSION_NUM (MAJOR, MINOR, PATCHLEVEL)
     Create an integer in the same format as used by 'MPC_VERSION' from
     the given MAJOR, MINOR and PATCHLEVEL.  Here is an example of how
     to check the GNU MPC version at compile time:
          #if (!defined(MPC_VERSION) || (MPC_VERSION<MPC_VERSION_NUM(2,1,0)))
          # error "Wrong GNU MPC version."
          #endif


File: mpc.info,  Node: Advanced Functions,  Next: Internals,  Prev: Miscellaneous Complex Functions,  Up: Complex Functions

5.11 Advanced Functions
=======================

 -- Macro: MPC_SET_X_Y (REAL_SUFFIX, IMAG_SUFFIX, ROP, REAL, IMAG, RND)
     The macro MPC_SET_X_Y is designed to serve as the body of an
     assignment function and cannot be used by itself.  The REAL_SUFFIX
     and IMAG_SUFFIX parameters are the types of the real and imaginary
     part, that is, the 'x' in the 'mpfr_set_x' function one would use
     to set the part; for the mpfr type, use 'fr'.  REAL (respectively
     IMAG) is the value you want to assign to the real (resp.
     imaginary) part, its type must conform to REAL_SUFFIX (resp.
     IMAG_SUFFIX).  RND is the 'mpc_rnd_t' rounding mode.  The return
     value is the usual inexact value (*note Return Value:
     return-value.).

     For instance, you can define mpc_set_ui_fr as follows:
          int mpc_set_ui_fr (mpc_t rop, long int re, double im, mpc_rnd_t rnd)
              MPC_SET_X_Y (ui, fr, rop, re, im, rnd);


File: mpc.info,  Node: Internals,  Prev: Advanced Functions,  Up: Complex Functions

5.12 Internals
==============

These macros and functions are mainly designed for the implementation of
GNU MPC, but may be useful for users too.  However, no upward
compatibility is guaranteed.  You need to include 'mpc-impl.h' to use
them.

   The macro 'MPC_MAX_PREC(z)' gives the maximum of the precisions of
the real and imaginary parts of a complex number.


File: mpc.info,  Node: References,  Next: Concept Index,  Prev: Complex Functions,  Up: Top

References
**********

   * Torbjo"rn Granlund et al.  'gmp' - GNU multiprecision library.
     Version 4.2.4, <http://gmplib.org/>.

   * Guillaume Hanrot, Vincent Lefe`vre, Patrick Pe'lissier, Paul
     Zimmermann et al.  'mpfr' - A library for multiple-precision
     floating-point computations with exact rounding.  Version 2.4.1,
     <http://www.mpfr.org>.

   * IEEE standard for binary floating-point arithmetic, Technical
     Report ANSI-IEEE Standard 754-1985, New York, 1985.  Approved March
     21, 1985: IEEE Standards Board; approved July 26, 1985: American
     National Standards Institute, 18 pages.

   * Donald E. Knuth, "The Art of Computer Programming", vol 2,
     "Seminumerical Algorithms", 2nd edition, Addison-Wesley, 1981.

   * ISO/IEC 9899:1999, Programming languages — C.


File: mpc.info,  Node: Concept Index,  Next: Function Index,  Prev: References,  Up: Top

Concept Index
*************