• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Conceptual Requirements for Real Number Types</title>
5<link rel="stylesheet" href="../math.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../index.html" title="Math Toolkit 2.12.0">
8<link rel="up" href="../using_udt.html" title="Chapter 20. Use with User-Defined Floating-Point Types - Boost.Multiprecision and others">
9<link rel="prev" href="high_precision/using_test.html" title="Using without expression templates for Boost.Test and others">
10<link rel="next" href="dist_concept.html" title="Conceptual Requirements for Distribution Types">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="high_precision/using_test.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../using_udt.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="dist_concept.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h2 class="title" style="clear: both">
27<a name="math_toolkit.real_concepts"></a><a class="link" href="real_concepts.html" title="Conceptual Requirements for Real Number Types">Conceptual Requirements for
28    Real Number Types</a>
29</h2></div></div></div>
30<p>
31      The functions and statistical distributions in this library can be used with
32      any type <span class="emphasis"><em>RealType</em></span> that meets the conceptual requirements
33      given below. All the built-in floating-point types like <code class="computeroutput"><span class="keyword">double</span></code>
34      will meet these requirements. (Built-in types are also called <a href="http://en.cppreference.com/w/cpp/language/types" target="_top">fundamental
35      (built-in) types</a>).
36    </p>
37<p>
38      User-defined types that meet the conceptual requirements can also be used.
39      For example, with <a class="link" href="high_precision/use_ntl.html" title="Using NTL Library">a thin
40      wrapper class</a> one of the types provided with <a href="http://shoup.net/ntl/" target="_top">NTL
41      (RR)</a> can be used. But now that <a href="../../../../../libs/multiprecision/doc/html/index.html" target="_top">Boost.Multiprecision</a>
42      library is available, this has become the preferred real-number type, typically
43      <a href="../../../../../libs/multiprecision/doc/html/boost_multiprecision/tut/floats/cpp_dec_float.html" target="_top">cpp_dec_float</a>
44      or <a href="../../../../../libs/multiprecision/doc/html/boost_multiprecision/tut/floats/cpp_bin_float.html" target="_top">cpp_bin_float</a>.
45    </p>
46<p>
47      Submissions of binding to other extended precision types would also still be
48      welcome.
49    </p>
50<p>
51      The guiding principal behind these requirements is that a <span class="emphasis"><em>RealType</em></span>
52      behaves just like a built-in floating-point type.
53    </p>
54<h5>
55<a name="math_toolkit.real_concepts.h0"></a>
56      <span class="phrase"><a name="math_toolkit.real_concepts.basic_arithmetic_requirements"></a></span><a class="link" href="real_concepts.html#math_toolkit.real_concepts.basic_arithmetic_requirements">Basic Arithmetic
57      Requirements</a>
58    </h5>
59<p>
60      These requirements are common to all of the functions in this library.
61    </p>
62<p>
63      In the following table <span class="emphasis"><em>r</em></span> is an object of type <code class="computeroutput"><span class="identifier">RealType</span></code>, <span class="emphasis"><em>cr</em></span> and <span class="emphasis"><em>cr2</em></span>
64      are objects of type <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">RealType</span></code>,
65      and <span class="emphasis"><em>ca</em></span> is an object of type <code class="computeroutput"><span class="keyword">const</span>
66      <span class="identifier">arithmetic</span><span class="special">-</span><span class="identifier">type</span></code> (arithmetic types include all the built
67      in integers and floating point types).
68    </p>
69<div class="informaltable"><table class="table">
70<colgroup>
71<col>
72<col>
73<col>
74</colgroup>
75<thead><tr>
76<th>
77              <p>
78                Expression
79              </p>
80            </th>
81<th>
82              <p>
83                Result Type
84              </p>
85            </th>
86<th>
87              <p>
88                Notes
89              </p>
90            </th>
91</tr></thead>
92<tbody>
93<tr>
94<td>
95              <p>
96                <code class="computeroutput"><span class="identifier">RealType</span><span class="special">(</span><span class="identifier">cr</span><span class="special">)</span></code>
97              </p>
98            </td>
99<td>
100              <p>
101                RealType
102              </p>
103            </td>
104<td>
105              <p>
106                RealType is copy constructible.
107              </p>
108            </td>
109</tr>
110<tr>
111<td>
112              <p>
113                <code class="computeroutput"><span class="identifier">RealType</span><span class="special">(</span><span class="identifier">ca</span><span class="special">)</span></code>
114              </p>
115            </td>
116<td>
117              <p>
118                RealType
119              </p>
120            </td>
121<td>
122              <p>
123                RealType is copy constructible from the arithmetic types.
124              </p>
125            </td>
126</tr>
127<tr>
128<td>
129              <p>
130                <code class="computeroutput"><span class="identifier">r</span> <span class="special">=</span>
131                <span class="identifier">cr</span></code>
132              </p>
133            </td>
134<td>
135              <p>
136                RealType&amp;
137              </p>
138            </td>
139<td>
140              <p>
141                Assignment operator.
142              </p>
143            </td>
144</tr>
145<tr>
146<td>
147              <p>
148                <code class="computeroutput"><span class="identifier">r</span> <span class="special">=</span>
149                <span class="identifier">ca</span></code>
150              </p>
151            </td>
152<td>
153              <p>
154                RealType&amp;
155              </p>
156            </td>
157<td>
158              <p>
159                Assignment operator from the arithmetic types.
160              </p>
161            </td>
162</tr>
163<tr>
164<td>
165              <p>
166                <code class="computeroutput"><span class="identifier">r</span> <span class="special">+=</span>
167                <span class="identifier">cr</span></code>
168              </p>
169            </td>
170<td>
171              <p>
172                RealType&amp;
173              </p>
174            </td>
175<td>
176              <p>
177                Adds cr to r.
178              </p>
179            </td>
180</tr>
181<tr>
182<td>
183              <p>
184                <code class="computeroutput"><span class="identifier">r</span> <span class="special">+=</span>
185                <span class="identifier">ca</span></code>
186              </p>
187            </td>
188<td>
189              <p>
190                RealType&amp;
191              </p>
192            </td>
193<td>
194              <p>
195                Adds ar to r.
196              </p>
197            </td>
198</tr>
199<tr>
200<td>
201              <p>
202                <code class="computeroutput"><span class="identifier">r</span> <span class="special">-=</span>
203                <span class="identifier">cr</span></code>
204              </p>
205            </td>
206<td>
207              <p>
208                RealType&amp;
209              </p>
210            </td>
211<td>
212              <p>
213                Subtracts cr from r.
214              </p>
215            </td>
216</tr>
217<tr>
218<td>
219              <p>
220                <code class="computeroutput"><span class="identifier">r</span> <span class="special">-=</span>
221                <span class="identifier">ca</span></code>
222              </p>
223            </td>
224<td>
225              <p>
226                RealType&amp;
227              </p>
228            </td>
229<td>
230              <p>
231                Subtracts ca from r.
232              </p>
233            </td>
234</tr>
235<tr>
236<td>
237              <p>
238                <code class="computeroutput"><span class="identifier">r</span> <span class="special">*=</span>
239                <span class="identifier">cr</span></code>
240              </p>
241            </td>
242<td>
243              <p>
244                RealType&amp;
245              </p>
246            </td>
247<td>
248              <p>
249                Multiplies r by cr.
250              </p>
251            </td>
252</tr>
253<tr>
254<td>
255              <p>
256                <code class="computeroutput"><span class="identifier">r</span> <span class="special">*=</span>
257                <span class="identifier">ca</span></code>
258              </p>
259            </td>
260<td>
261              <p>
262                RealType&amp;
263              </p>
264            </td>
265<td>
266              <p>
267                Multiplies r by ca.
268              </p>
269            </td>
270</tr>
271<tr>
272<td>
273              <p>
274                <code class="computeroutput"><span class="identifier">r</span> <span class="special">/=</span>
275                <span class="identifier">cr</span></code>
276              </p>
277            </td>
278<td>
279              <p>
280                RealType&amp;
281              </p>
282            </td>
283<td>
284              <p>
285                Divides r by cr.
286              </p>
287            </td>
288</tr>
289<tr>
290<td>
291              <p>
292                <code class="computeroutput"><span class="identifier">r</span> <span class="special">/=</span>
293                <span class="identifier">ca</span></code>
294              </p>
295            </td>
296<td>
297              <p>
298                RealType&amp;
299              </p>
300            </td>
301<td>
302              <p>
303                Divides r by ca.
304              </p>
305            </td>
306</tr>
307<tr>
308<td>
309              <p>
310                <code class="computeroutput"><span class="special">-</span><span class="identifier">r</span></code>
311              </p>
312            </td>
313<td>
314              <p>
315                RealType
316              </p>
317            </td>
318<td>
319              <p>
320                Unary Negation.
321              </p>
322            </td>
323</tr>
324<tr>
325<td>
326              <p>
327                <code class="computeroutput"><span class="special">+</span><span class="identifier">r</span></code>
328              </p>
329            </td>
330<td>
331              <p>
332                RealType&amp;
333              </p>
334            </td>
335<td>
336              <p>
337                Identity Operation.
338              </p>
339            </td>
340</tr>
341<tr>
342<td>
343              <p>
344                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">+</span>
345                <span class="identifier">cr2</span></code>
346              </p>
347            </td>
348<td>
349              <p>
350                RealType
351              </p>
352            </td>
353<td>
354              <p>
355                Binary Addition
356              </p>
357            </td>
358</tr>
359<tr>
360<td>
361              <p>
362                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">+</span>
363                <span class="identifier">ca</span></code>
364              </p>
365            </td>
366<td>
367              <p>
368                RealType
369              </p>
370            </td>
371<td>
372              <p>
373                Binary Addition
374              </p>
375            </td>
376</tr>
377<tr>
378<td>
379              <p>
380                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">+</span>
381                <span class="identifier">cr</span></code>
382              </p>
383            </td>
384<td>
385              <p>
386                RealType
387              </p>
388            </td>
389<td>
390              <p>
391                Binary Addition
392              </p>
393            </td>
394</tr>
395<tr>
396<td>
397              <p>
398                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">-</span>
399                <span class="identifier">cr2</span></code>
400              </p>
401            </td>
402<td>
403              <p>
404                RealType
405              </p>
406            </td>
407<td>
408              <p>
409                Binary Subtraction
410              </p>
411            </td>
412</tr>
413<tr>
414<td>
415              <p>
416                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">-</span>
417                <span class="identifier">ca</span></code>
418              </p>
419            </td>
420<td>
421              <p>
422                RealType
423              </p>
424            </td>
425<td>
426              <p>
427                Binary Subtraction
428              </p>
429            </td>
430</tr>
431<tr>
432<td>
433              <p>
434                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">-</span>
435                <span class="identifier">cr</span></code>
436              </p>
437            </td>
438<td>
439              <p>
440                RealType
441              </p>
442            </td>
443<td>
444              <p>
445                Binary Subtraction
446              </p>
447            </td>
448</tr>
449<tr>
450<td>
451              <p>
452                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">*</span>
453                <span class="identifier">cr2</span></code>
454              </p>
455            </td>
456<td>
457              <p>
458                RealType
459              </p>
460            </td>
461<td>
462              <p>
463                Binary Multiplication
464              </p>
465            </td>
466</tr>
467<tr>
468<td>
469              <p>
470                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">*</span>
471                <span class="identifier">ca</span></code>
472              </p>
473            </td>
474<td>
475              <p>
476                RealType
477              </p>
478            </td>
479<td>
480              <p>
481                Binary Multiplication
482              </p>
483            </td>
484</tr>
485<tr>
486<td>
487              <p>
488                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">*</span>
489                <span class="identifier">cr</span></code>
490              </p>
491            </td>
492<td>
493              <p>
494                RealType
495              </p>
496            </td>
497<td>
498              <p>
499                Binary Multiplication
500              </p>
501            </td>
502</tr>
503<tr>
504<td>
505              <p>
506                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">/</span>
507                <span class="identifier">cr2</span></code>
508              </p>
509            </td>
510<td>
511              <p>
512                RealType
513              </p>
514            </td>
515<td>
516              <p>
517                Binary Subtraction
518              </p>
519            </td>
520</tr>
521<tr>
522<td>
523              <p>
524                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">/</span>
525                <span class="identifier">ca</span></code>
526              </p>
527            </td>
528<td>
529              <p>
530                RealType
531              </p>
532            </td>
533<td>
534              <p>
535                Binary Subtraction
536              </p>
537            </td>
538</tr>
539<tr>
540<td>
541              <p>
542                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">/</span>
543                <span class="identifier">cr</span></code>
544              </p>
545            </td>
546<td>
547              <p>
548                RealType
549              </p>
550            </td>
551<td>
552              <p>
553                Binary Subtraction
554              </p>
555            </td>
556</tr>
557<tr>
558<td>
559              <p>
560                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">==</span>
561                <span class="identifier">cr2</span></code>
562              </p>
563            </td>
564<td>
565              <p>
566                bool
567              </p>
568            </td>
569<td>
570              <p>
571                Equality Comparison
572              </p>
573            </td>
574</tr>
575<tr>
576<td>
577              <p>
578                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">==</span>
579                <span class="identifier">ca</span></code>
580              </p>
581            </td>
582<td>
583              <p>
584                bool
585              </p>
586            </td>
587<td>
588              <p>
589                Equality Comparison
590              </p>
591            </td>
592</tr>
593<tr>
594<td>
595              <p>
596                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">==</span>
597                <span class="identifier">cr</span></code>
598              </p>
599            </td>
600<td>
601              <p>
602                bool
603              </p>
604            </td>
605<td>
606              <p>
607                Equality Comparison
608              </p>
609            </td>
610</tr>
611<tr>
612<td>
613              <p>
614                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">!=</span>
615                <span class="identifier">cr2</span></code>
616              </p>
617            </td>
618<td>
619              <p>
620                bool
621              </p>
622            </td>
623<td>
624              <p>
625                Inequality Comparison
626              </p>
627            </td>
628</tr>
629<tr>
630<td>
631              <p>
632                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">!=</span>
633                <span class="identifier">ca</span></code>
634              </p>
635            </td>
636<td>
637              <p>
638                bool
639              </p>
640            </td>
641<td>
642              <p>
643                Inequality Comparison
644              </p>
645            </td>
646</tr>
647<tr>
648<td>
649              <p>
650                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">!=</span>
651                <span class="identifier">cr</span></code>
652              </p>
653            </td>
654<td>
655              <p>
656                bool
657              </p>
658            </td>
659<td>
660              <p>
661                Inequality Comparison
662              </p>
663            </td>
664</tr>
665<tr>
666<td>
667              <p>
668                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&lt;=</span>
669                <span class="identifier">cr2</span></code>
670              </p>
671            </td>
672<td>
673              <p>
674                bool
675              </p>
676            </td>
677<td>
678              <p>
679                Less than equal to.
680              </p>
681            </td>
682</tr>
683<tr>
684<td>
685              <p>
686                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&lt;=</span>
687                <span class="identifier">ca</span></code>
688              </p>
689            </td>
690<td>
691              <p>
692                bool
693              </p>
694            </td>
695<td>
696              <p>
697                Less than equal to.
698              </p>
699            </td>
700</tr>
701<tr>
702<td>
703              <p>
704                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">&lt;=</span>
705                <span class="identifier">cr</span></code>
706              </p>
707            </td>
708<td>
709              <p>
710                bool
711              </p>
712            </td>
713<td>
714              <p>
715                Less than equal to.
716              </p>
717            </td>
718</tr>
719<tr>
720<td>
721              <p>
722                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&gt;=</span>
723                <span class="identifier">cr2</span></code>
724              </p>
725            </td>
726<td>
727              <p>
728                bool
729              </p>
730            </td>
731<td>
732              <p>
733                Greater than equal to.
734              </p>
735            </td>
736</tr>
737<tr>
738<td>
739              <p>
740                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&gt;=</span>
741                <span class="identifier">ca</span></code>
742              </p>
743            </td>
744<td>
745              <p>
746                bool
747              </p>
748            </td>
749<td>
750              <p>
751                Greater than equal to.
752              </p>
753            </td>
754</tr>
755<tr>
756<td>
757              <p>
758                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">&gt;=</span>
759                <span class="identifier">cr</span></code>
760              </p>
761            </td>
762<td>
763              <p>
764                bool
765              </p>
766            </td>
767<td>
768              <p>
769                Greater than equal to.
770              </p>
771            </td>
772</tr>
773<tr>
774<td>
775              <p>
776                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&lt;</span>
777                <span class="identifier">cr2</span></code>
778              </p>
779            </td>
780<td>
781              <p>
782                bool
783              </p>
784            </td>
785<td>
786              <p>
787                Less than comparison.
788              </p>
789            </td>
790</tr>
791<tr>
792<td>
793              <p>
794                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&lt;</span>
795                <span class="identifier">ca</span></code>
796              </p>
797            </td>
798<td>
799              <p>
800                bool
801              </p>
802            </td>
803<td>
804              <p>
805                Less than comparison.
806              </p>
807            </td>
808</tr>
809<tr>
810<td>
811              <p>
812                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">&lt;</span>
813                <span class="identifier">cr</span></code>
814              </p>
815            </td>
816<td>
817              <p>
818                bool
819              </p>
820            </td>
821<td>
822              <p>
823                Less than comparison.
824              </p>
825            </td>
826</tr>
827<tr>
828<td>
829              <p>
830                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&gt;</span>
831                <span class="identifier">cr2</span></code>
832              </p>
833            </td>
834<td>
835              <p>
836                bool
837              </p>
838            </td>
839<td>
840              <p>
841                Greater than comparison.
842              </p>
843            </td>
844</tr>
845<tr>
846<td>
847              <p>
848                <code class="computeroutput"><span class="identifier">cr</span> <span class="special">&gt;</span>
849                <span class="identifier">ca</span></code>
850              </p>
851            </td>
852<td>
853              <p>
854                bool
855              </p>
856            </td>
857<td>
858              <p>
859                Greater than comparison.
860              </p>
861            </td>
862</tr>
863<tr>
864<td>
865              <p>
866                <code class="computeroutput"><span class="identifier">ca</span> <span class="special">&gt;</span>
867                <span class="identifier">cr</span></code>
868              </p>
869            </td>
870<td>
871              <p>
872                bool
873              </p>
874            </td>
875<td>
876              <p>
877                Greater than comparison.
878              </p>
879            </td>
880</tr>
881<tr>
882<td>
883              <p>
884                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">digits</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
885              </p>
886            </td>
887<td>
888              <p>
889                int
890              </p>
891            </td>
892<td>
893              <p>
894                The number of digits in the significand of RealType.
895              </p>
896            </td>
897</tr>
898<tr>
899<td>
900              <p>
901                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">max_value</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
902              </p>
903            </td>
904<td>
905              <p>
906                RealType
907              </p>
908            </td>
909<td>
910              <p>
911                The largest representable number by type RealType.
912              </p>
913            </td>
914</tr>
915<tr>
916<td>
917              <p>
918                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">min_value</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
919              </p>
920            </td>
921<td>
922              <p>
923                RealType
924              </p>
925            </td>
926<td>
927              <p>
928                The smallest representable number by type RealType.
929              </p>
930            </td>
931</tr>
932<tr>
933<td>
934              <p>
935                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">log_max_value</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
936              </p>
937            </td>
938<td>
939              <p>
940                RealType
941              </p>
942            </td>
943<td>
944              <p>
945                The natural logarithm of the largest representable number by type
946                RealType.
947              </p>
948            </td>
949</tr>
950<tr>
951<td>
952              <p>
953                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">log_min_value</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
954              </p>
955            </td>
956<td>
957              <p>
958                RealType
959              </p>
960            </td>
961<td>
962              <p>
963                The natural logarithm of the smallest representable number by type
964                RealType.
965              </p>
966            </td>
967</tr>
968<tr>
969<td>
970              <p>
971                <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tools</span><span class="special">::</span><span class="identifier">epsilon</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;()</span></code>
972              </p>
973            </td>
974<td>
975              <p>
976                RealType
977              </p>
978            </td>
979<td>
980              <p>
981                The machine epsilon of RealType.
982              </p>
983            </td>
984</tr>
985</tbody>
986</table></div>
987<p>
988      Note that:
989    </p>
990<div class="orderedlist"><ol class="orderedlist" type="1">
991<li class="listitem">
992          The functions <code class="computeroutput"><span class="identifier">log_max_value</span></code>
993          and <code class="computeroutput"><span class="identifier">log_min_value</span></code> can be
994          synthesised from the others, and so no explicit specialisation is required.
995        </li>
996<li class="listitem">
997          The function <code class="computeroutput"><span class="identifier">epsilon</span></code> can
998          be synthesised from the others, so no explicit specialisation is required
999          provided the precision of RealType does not vary at runtime (see the header
1000          <a href="../../../../../boost/math/bindings/rr.hpp" target="_top">boost/math/bindings/rr.hpp</a>
1001          for an example where the precision does vary at runtime).
1002        </li>
1003<li class="listitem">
1004          The functions <code class="computeroutput"><span class="identifier">digits</span></code>,
1005          <code class="computeroutput"><span class="identifier">max_value</span></code> and <code class="computeroutput"><span class="identifier">min_value</span></code>, all get synthesised automatically
1006          from <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span></code>. However, if <code class="computeroutput"><span class="identifier">numeric_limits</span></code> is not specialised for
1007          type RealType, then you will get a compiler error when code tries to use
1008          these functions, <span class="emphasis"><em>unless</em></span> you explicitly specialise
1009          them. For example if the precision of RealType varies at runtime, then
1010          <code class="computeroutput"><span class="identifier">numeric_limits</span></code> support
1011          may not be appropriate, see <a href="../../../../../boost/math/bindings/rr.hpp" target="_top">boost/math/bindings/rr.hpp</a>
1012          for examples.
1013        </li>
1014</ol></div>
1015<div class="warning"><table border="0" summary="Warning">
1016<tr>
1017<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
1018<th align="left">Warning</th>
1019</tr>
1020<tr><td align="left" valign="top">
1021<p>
1022        If <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;&gt;</span></code>
1023        is <span class="bold"><strong>not specialized</strong></span> for type <span class="emphasis"><em>RealType</em></span>
1024        then the default float precision of 6 decimal digits will be used by other
1025        Boost programs including:
1026      </p>
1027<p>
1028        Boost.Test: giving misleading error messages like
1029      </p>
1030<p>
1031        <span class="emphasis"><em>"difference between {9.79796} and {9.79796} exceeds 5.42101e-19%".</em></span>
1032      </p>
1033<p>
1034        Boost.LexicalCast and Boost.Serialization when converting the number to a
1035        string, causing potentially serious loss of accuracy on output.
1036      </p>
1037<p>
1038        Although it might seem obvious that RealType should require <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span></code>
1039        to be specialized, this is not sensible for <code class="computeroutput"><span class="identifier">NTL</span><span class="special">::</span><span class="identifier">RR</span></code> and
1040        similar classes where the <span class="bold"><strong>number of digits is a runtime
1041        parameter</strong></span> (whereas for <code class="computeroutput"><span class="identifier">numeric_limits</span></code>
1042        everything has to be fixed at compile time).
1043      </p>
1044</td></tr>
1045</table></div>
1046<h5>
1047<a name="math_toolkit.real_concepts.h1"></a>
1048      <span class="phrase"><a name="math_toolkit.real_concepts.standard_library_support_require"></a></span><a class="link" href="real_concepts.html#math_toolkit.real_concepts.standard_library_support_require">Standard
1049      Library Support Requirements</a>
1050    </h5>
1051<p>
1052      Many (though not all) of the functions in this library make calls to standard
1053      library functions, the following table summarises the requirements. Note that
1054      most of the functions in this library will only call a small subset of the
1055      functions listed here, so if in doubt whether a user-defined type has enough
1056      standard library support to be useable the best advise is to try it and see!
1057    </p>
1058<p>
1059      In the following table <span class="emphasis"><em>r</em></span> is an object of type <code class="computeroutput"><span class="identifier">RealType</span></code>, <span class="emphasis"><em>cr1</em></span> and <span class="emphasis"><em>cr2</em></span>
1060      are objects of type <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">RealType</span></code>,
1061      and <span class="emphasis"><em>i</em></span> is an object of type <code class="computeroutput"><span class="keyword">int</span></code>.
1062    </p>
1063<div class="informaltable"><table class="table">
1064<colgroup>
1065<col>
1066<col>
1067</colgroup>
1068<thead><tr>
1069<th>
1070              <p>
1071                Expression
1072              </p>
1073            </th>
1074<th>
1075              <p>
1076                Result Type
1077              </p>
1078            </th>
1079</tr></thead>
1080<tbody>
1081<tr>
1082<td>
1083              <p>
1084                <code class="computeroutput"><span class="identifier">fabs</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1085              </p>
1086            </td>
1087<td>
1088              <p>
1089                RealType
1090              </p>
1091            </td>
1092</tr>
1093<tr>
1094<td>
1095              <p>
1096                <code class="computeroutput"><span class="identifier">abs</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1097              </p>
1098            </td>
1099<td>
1100              <p>
1101                RealType
1102              </p>
1103            </td>
1104</tr>
1105<tr>
1106<td>
1107              <p>
1108                <code class="computeroutput"><span class="identifier">ceil</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1109              </p>
1110            </td>
1111<td>
1112              <p>
1113                RealType
1114              </p>
1115            </td>
1116</tr>
1117<tr>
1118<td>
1119              <p>
1120                <code class="computeroutput"><span class="identifier">floor</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1121              </p>
1122            </td>
1123<td>
1124              <p>
1125                RealType
1126              </p>
1127            </td>
1128</tr>
1129<tr>
1130<td>
1131              <p>
1132                <code class="computeroutput"><span class="identifier">exp</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1133              </p>
1134            </td>
1135<td>
1136              <p>
1137                RealType
1138              </p>
1139            </td>
1140</tr>
1141<tr>
1142<td>
1143              <p>
1144                <code class="computeroutput"><span class="identifier">pow</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">,</span>
1145                <span class="identifier">cr2</span><span class="special">)</span></code>
1146              </p>
1147            </td>
1148<td>
1149              <p>
1150                RealType
1151              </p>
1152            </td>
1153</tr>
1154<tr>
1155<td>
1156              <p>
1157                <code class="computeroutput"><span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1158              </p>
1159            </td>
1160<td>
1161              <p>
1162                RealType
1163              </p>
1164            </td>
1165</tr>
1166<tr>
1167<td>
1168              <p>
1169                <code class="computeroutput"><span class="identifier">log</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1170              </p>
1171            </td>
1172<td>
1173              <p>
1174                RealType
1175              </p>
1176            </td>
1177</tr>
1178<tr>
1179<td>
1180              <p>
1181                <code class="computeroutput"><span class="identifier">frexp</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">,</span>
1182                <span class="special">&amp;</span><span class="identifier">i</span><span class="special">)</span></code>
1183              </p>
1184            </td>
1185<td>
1186              <p>
1187                RealType
1188              </p>
1189            </td>
1190</tr>
1191<tr>
1192<td>
1193              <p>
1194                <code class="computeroutput"><span class="identifier">ldexp</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">,</span>
1195                <span class="identifier">i</span><span class="special">)</span></code>
1196              </p>
1197            </td>
1198<td>
1199              <p>
1200                RealType
1201              </p>
1202            </td>
1203</tr>
1204<tr>
1205<td>
1206              <p>
1207                <code class="computeroutput"><span class="identifier">cos</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1208              </p>
1209            </td>
1210<td>
1211              <p>
1212                RealType
1213              </p>
1214            </td>
1215</tr>
1216<tr>
1217<td>
1218              <p>
1219                <code class="computeroutput"><span class="identifier">sin</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1220              </p>
1221            </td>
1222<td>
1223              <p>
1224                RealType
1225              </p>
1226            </td>
1227</tr>
1228<tr>
1229<td>
1230              <p>
1231                <code class="computeroutput"><span class="identifier">asin</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1232              </p>
1233            </td>
1234<td>
1235              <p>
1236                RealType
1237              </p>
1238            </td>
1239</tr>
1240<tr>
1241<td>
1242              <p>
1243                <code class="computeroutput"><span class="identifier">tan</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1244              </p>
1245            </td>
1246<td>
1247              <p>
1248                RealType
1249              </p>
1250            </td>
1251</tr>
1252<tr>
1253<td>
1254              <p>
1255                <code class="computeroutput"><span class="identifier">atan</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1256              </p>
1257            </td>
1258<td>
1259              <p>
1260                RealType
1261              </p>
1262            </td>
1263</tr>
1264<tr>
1265<td>
1266              <p>
1267                <code class="computeroutput"><span class="identifier">fmod</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1268              </p>
1269            </td>
1270<td>
1271              <p>
1272                RealType
1273              </p>
1274            </td>
1275</tr>
1276<tr>
1277<td>
1278              <p>
1279                <code class="computeroutput"><span class="identifier">round</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1280              </p>
1281            </td>
1282<td>
1283              <p>
1284                RealType
1285              </p>
1286            </td>
1287</tr>
1288<tr>
1289<td>
1290              <p>
1291                <code class="computeroutput"><span class="identifier">iround</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1292              </p>
1293            </td>
1294<td>
1295              <p>
1296                int
1297              </p>
1298            </td>
1299</tr>
1300<tr>
1301<td>
1302              <p>
1303                <code class="computeroutput"><span class="identifier">trunc</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1304              </p>
1305            </td>
1306<td>
1307              <p>
1308                RealType
1309              </p>
1310            </td>
1311</tr>
1312<tr>
1313<td>
1314              <p>
1315                <code class="computeroutput"><span class="identifier">itrunc</span><span class="special">(</span><span class="identifier">cr1</span><span class="special">)</span></code>
1316              </p>
1317            </td>
1318<td>
1319              <p>
1320                int
1321              </p>
1322            </td>
1323</tr>
1324</tbody>
1325</table></div>
1326<p>
1327      Note that the table above lists only those standard library functions known
1328      to be used (or likely to be used in the near future) by this library. The following
1329      functions: <code class="computeroutput"><span class="identifier">acos</span></code>, <code class="computeroutput"><span class="identifier">atan2</span></code>, <code class="computeroutput"><span class="identifier">fmod</span></code>,
1330      <code class="computeroutput"><span class="identifier">cosh</span></code>, <code class="computeroutput"><span class="identifier">sinh</span></code>,
1331      <code class="computeroutput"><span class="identifier">tanh</span></code>, <code class="computeroutput"><span class="identifier">log10</span></code>,
1332      <code class="computeroutput"><span class="identifier">lround</span></code>, <code class="computeroutput"><span class="identifier">llround</span></code>,
1333      <code class="computeroutput"><span class="identifier">ltrunc</span></code>, <code class="computeroutput"><span class="identifier">lltrunc</span></code>
1334      and <code class="computeroutput"><span class="identifier">modf</span></code> are not currently
1335      used, but may be if further special functions are added.
1336    </p>
1337<p>
1338      Note that the <code class="computeroutput"><span class="identifier">round</span></code>, <code class="computeroutput"><span class="identifier">trunc</span></code> and <code class="computeroutput"><span class="identifier">modf</span></code>
1339      functions are not part of the current C++ standard: they are part of the additions
1340      added to C99 which will likely be in the next C++ standard. There are Boost
1341      versions of these provided as a backup, and the functions are always called
1342      unqualified so that argument-dependent-lookup can take place.
1343    </p>
1344<p>
1345      In addition, for efficient and accurate results, a <a class="link" href="lanczos.html" title="The Lanczos Approximation">Lanczos
1346      approximation</a> is highly desirable. You may be able to adapt an existing
1347      approximation from <a href="../../../../../boost/math/special_functions/lanczos.hpp" target="_top">boost/math/special_functions/lanczos.hpp</a>
1348      or <a href="../../../../../boost/math/bindings/detail/big_lanczos.hpp" target="_top">boost/math/bindings/detail/big_lanczos.hpp</a>:
1349      in the former case you will need change <code class="computeroutput"><span class="keyword">static_cast</span></code>'s
1350      to <code class="computeroutput"><span class="identifier">lexical_cast</span></code>'s, and the
1351      constants to <span class="emphasis"><em>strings</em></span> (in order to ensure the coefficients
1352      aren't truncated to <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code>)
1353      and then specialise <code class="computeroutput"><span class="identifier">lanczos_traits</span></code>
1354      for type T. Otherwise you may have to hack <a href="../../../tools/lanczos_generator.cpp" target="_top">libs/math/tools/lanczos_generator.cpp</a>
1355      to find a suitable approximation for your RealType. The code will still compile
1356      if you don't do this, but both accuracy and efficiency will be somewhat compromised
1357      in any function that makes use of the gamma/beta/erf family of functions.
1358    </p>
1359</div>
1360<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
1361<td align="left"></td>
1362<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
1363      Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
1364      Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
1365      Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
1366      Daryle Walker and Xiaogang Zhang<p>
1367        Distributed under the Boost Software License, Version 1.0. (See accompanying
1368        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
1369      </p>
1370</div></td>
1371</tr></table>
1372<hr>
1373<div class="spirit-nav">
1374<a accesskey="p" href="high_precision/using_test.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../using_udt.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="dist_concept.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
1375</div>
1376</body>
1377</html>
1378