From 083453705c822e56394be69735586838b192e72d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 11 Jun 2017 04:35:34 +0300 Subject: [PATCH] Update documentation --- doc/html/mp11.html | 464 ++++++++++++++++++++++++++++++----- doc/mp11-docinfo-footer.html | 33 +++ doc/mp11.adoc | 1 + doc/mp11/algorithm.adoc | 132 +++++++--- 4 files changed, 533 insertions(+), 97 deletions(-) create mode 100644 doc/mp11-docinfo-footer.html diff --git a/doc/html/mp11.html b/doc/html/mp11.html index bb35201..e3ed9a3 100644 --- a/doc/html/mp11.html +++ b/doc/html/mp11.html @@ -2092,6 +2092,45 @@ using L2 = mp_list<int, float>; using R1 = mp_assign<L1, L2>; // std::pair<int, float> + + +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Illustration 1. mp_assign

L1

A1

A2

…​

An

L2

B1

B2

…​

Bn

mp_assign<L1, L2>

B1

B2

…​

Bn

mp_clear<L>

@@ -2152,7 +2191,7 @@ using R1 = mp_all<mp_transform<eq, L1, L2>>; // mp_true
- +@@ -2160,37 +2199,28 @@ using R1 = mp_all<mp_transform<eq, L1, L2>>; // mp_true - - - - - - - - - - - + + - + - - + + - +
Illustration 1. mp_transform on one listIllustration 2. mp_transform on one list
ListContents

L1

A0

A1

A1

A2

…​

An

An

mp_transform<F, L1>

F<A0>

F<A1>

F<A1>

F<A2>

…​

F<An>

F<An>

- +@@ -2198,42 +2228,33 @@ using R1 = mp_all<mp_transform<eq, L1, L2>>; // mp_true - - - - - - - - - - - + + - + - - + + - + - - + + - +
Illustration 2. mp_transform on two listsIllustration 3. mp_transform on two lists
ListContents

L1

A0

A1

A1

A2

…​

An

An

L2

B0

B1

B1

B2

…​

Bn

Bn

mp_transform<F, L1, L2>

F<A0,B0>

F<A1,B1>

F<A1,B1>

F<A2,B2>

…​

F<An,Bn>

F<An,Bn>

@@ -2258,6 +2279,45 @@ using R1 = mp_apply<mp_plus, mp_transform_q<mp_bind_front<std::is_same, void>, L1>>; // mp_int<2> + + +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Illustration 4. mp_transform_q on two lists

L1

A1

A2

…​

An

L2

B1

B2

…​

Bn

mp_transform_q<Q, L1, L2>

Q::fn<A1,B1>

Q::fn<A2,B2>

…​

Q::fn<An,Bn>

mp_transform_if<P, F, L…​>

@@ -2284,6 +2344,55 @@ using R1 = mp_transform_if<first_is_void, second, L1, L2>; // std::tuple<char[1], int, float, char[4], int>
+ + +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Illustration 5. mp_transform_if

L1

A1

A2

…​

An

P<Ai>

mp_false

mp_true

…​

mp_false

L2

B1

B2

…​

Bn

mp_transform_if<P, F, L1, L2>

A1

F<A2,B2>

…​

An

mp_transform_if_q<Qp, Qf, L…​>

@@ -2306,6 +2415,55 @@ using R1 = mp_transform_if_q<mp_bind<std::is_same, _1, void>, _2, L1, L // std::tuple<char[1], int, float, char[4], int>
+ + +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Illustration 6. mp_transform_if_q

L1

A1

A2

…​

An

Qp::fn<Ai>

mp_false

mp_true

…​

mp_false

L2

B1

B2

…​

Bn

mp_transform_if_q<Qp, _2, L1, L2>

A1

B2

…​

An

mp_fill<L, V>

@@ -2331,6 +2489,35 @@ using R1 = mp_fill<L1, double>; // std::tuple<double, double, double> using R1 = mp_fill<L1, void>; // std::pair<void, void>
+ + +++++++ + + + + + + + + + + + + + + + + + + + +
Illustration 7. mp_fill

L1

A1

A2

…​

An

mp_fill<L1, V>

V

V

…​

V

mp_count<L, V>

@@ -2400,7 +2587,7 @@ the Cartesian product of the lists, as if the elements Ui are forme It returns a list of type L1 containing the results of the application of F.

- +@@ -2408,51 +2595,51 @@ It returns a list of type L1 containing the results of the applicat - - - - - - - - - - - + + - + - - + + - + - - + + - + + + + + + + + + + + + + + + + + + +
Illustration 3. mp_product on two listsIllustration 8. mp_product on two lists
ListContents

L1

A0

A1

A1

A2

…​

An

An

L2

B0

B1

B1

B2

…​

Bm

Bm

mp_product<F, L1, L2>

F<A0,B0> -F<A0,B1> -…​ -F<A0,Bm>

F<A1,B0> -F<A1,B1> -…​ -F<A1,Bm>

F<A1,B1>

F<A1,B2>

…​

F<An,B0> -F<An,B1> -…​ -F<An,Bm>

F<A1,Bm>

F<A2,B1>

F<A2,B2>

…​

F<A2,Bm>

…​

F<An,B1>

F<An,B2>

…​

F<An,Bm>

@@ -2513,6 +2700,25 @@ F<An,Bm>

mp_list<std::integral_constant<T, 0>, std::integral_constant<T, 1>, …​, std::integral_constant<T, N::value-1>> where T is the type of N::value.

+ + +++++++ + + + + + + + + + +
Illustration 9. mp_iota

mp_iota<mp_int<4>>

mp_int<0>

mp_int<1>

mp_int<2>

mp_int<3>

mp_at_c<L, I>

@@ -2616,6 +2822,35 @@ where T is the type of N::value.

Replaces all V elements of L with W and returns the result.

+ + +++++++ + + + + + + + + + + + + + + + + + + + +
Illustration 10. mp_replace

L1

A1

V

…​

An

mp_replace<L1, V, W>

A1

W

…​

An

mp_replace_if<L, P, W>

@@ -2627,6 +2862,45 @@ where T is the type of N::value.

Replaces all T elements of L for which mp_to_bool<P<T>> is mp_true with W and returns the result.

+ + +++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Illustration 11. mp_replace_if

L1

A1

A2

…​

An

P<Ai>

mp_false

mp_true

…​

mp_false

mp_replace_if<L1, P, W>

A1

W

…​

An

mp_replace_at_c<L, I, W>

@@ -2750,6 +3024,35 @@ is mp_size<L>.

mp_reverse<L<T1, T2, …​, Tn>> is L<Tn, …​, T2, T1>.

+ + +++++++ + + + + + + + + + + + + + + + + + + + +
Illustration 12. mp_reverse

L1

A1

A2

…​

An

mp_reverse<L1>

An

An-1

…​

A1

mp_fold<L, V, F>

@@ -3377,8 +3680,41 @@ expression f(std::get<J>(std::forward<Tp>(tp))) for + + + \ No newline at end of file diff --git a/doc/mp11-docinfo-footer.html b/doc/mp11-docinfo-footer.html new file mode 100644 index 0000000..8cf495c --- /dev/null +++ b/doc/mp11-docinfo-footer.html @@ -0,0 +1,33 @@ + + + diff --git a/doc/mp11.adoc b/doc/mp11.adoc index d6bc842..c6f06ac 100644 --- a/doc/mp11.adoc +++ b/doc/mp11.adoc @@ -14,6 +14,7 @@ Peter Dimov :idprefix: :listing-caption: Code Example :table-caption: Illustration +:docinfo: private-footer :leveloffset: +1 diff --git a/doc/mp11/algorithm.adoc b/doc/mp11/algorithm.adoc index eac9086..8ba3884 100644 --- a/doc/mp11/algorithm.adoc +++ b/doc/mp11/algorithm.adoc @@ -35,6 +35,16 @@ using L2 = mp_list; using R1 = mp_assign; // std::pair ``` +.mp_assign +[cols="<.^4m,4*^.^1m",width=85%] +|=== +|*L1*|A~1~|A~2~|...|A~n~ +5+| +|*L2*|B~1~|B~2~|...|B~n~ +5+| +|*mp_assign*|B~1~|B~2~|...|B~n~ +|=== + ## mp_clear template using mp_clear = mp_assign>; @@ -81,27 +91,21 @@ using R1 = mp_all>; // mp_true ``` .mp_transform on one list -[cols="<.^4m,4*^.^1m",options="header",width=85%] +[cols="<.^4m,4*^.^1m",width=85%] |=== -^|List -4+|Contents +|*L1*|A~1~|A~2~|...|A~n~ 5+| -|*L1*|A0|A1|...|An -5+| -|*mp_transform*|F|F|...|F +|*mp_transform*|F|F|...|F |=== .mp_transform on two lists -[cols="<.^4m,4*^.^1m",options="header",width=85%] +[cols="<.^4m,4*^.^1m",width=85%] |=== -^|List -4+|Contents +|*L1*|A~1~|A~2~|...|A~n~ 5+| -|*L1*|A0|A1|...|An +|*L2*|B~1~|B~2~|...|B~n~ 5+| -|*L2*|B0|B1|...|Bn -5+| -|*mp_transform*|F|F|...|F +|*mp_transform*|F|F|...|F |=== ## mp_transform_q @@ -119,6 +123,16 @@ using R1 = mp_apply, L1>>; // mp_int\<2> ``` +[cols="<.^4m,4*^.^1m",width=85%] +.mp_transform_q on two lists +|=== +|*L1*|A~1~|A~2~|...|A~n~ +5+| +|*L2*|B~1~|B~2~|...|B~n~ +5+| +|*mp_transform_q*|Q::fn|Q::fn|...|Q::fn +|=== + ## mp_transform_if template class P, template class F, class L...> @@ -139,6 +153,18 @@ using R1 = mp_transform_if; // std::tuple ``` +.mp_transform_if +[cols="<.^4m,4*^.^1m",width=85%] +|=== +|*L1*|A~1~|A~2~|...|A~n~ +5+| +|*P*|mp_false|mp_true|...|mp_false +5+| +|*L2*|B~1~|B~2~|...|B~n~ +5+| +|*mp_transform_if*|A~1~|F|...|A~n~ +|=== + ## mp_transform_if_q template using mp_transform_if_q = @@ -155,6 +181,18 @@ using R1 = mp_transform_if_q, _2, L1, L2>; // std::tuple ``` +.mp_transform_if_q +[cols="<.^4m,4*^.^1m",width=85%] +|=== +|*L1*|A~1~|A~2~|...|A~n~ +5+| +|*Qp::fn*|mp_false|mp_true|...|mp_false +5+| +|*L2*|B~1~|B~2~|...|B~n~ +5+| +|*mp_transform_if_q*|A~1~|B~2~|...|A~n~ +|=== + ## mp_fill template using mp_fill = /*...*/; @@ -173,6 +211,14 @@ using L1 = std::pair; using R1 = mp_fill; // std::pair ``` +.mp_fill +[cols="<.^4m,4*^.^1m",width=85%] +|=== +|*L1*|A~1~|A~2~|...|A~n~ +5+| +|*mp_fill*|V|V|...|V +|=== + ## mp_count template using mp_count = /*...*/; @@ -212,29 +258,17 @@ the Cartesian product of the lists, as if the elements `Ui` are formed by `n` ne It returns a list of type `L1` containing the results of the application of `F`. .mp_product on two lists -[cols="<.^4m,4*^.^1m",options="header",width=85%] +[cols="<.^4m,4*^.^1m",width=85%] |=== -^|List -4+|Contents +|*L1*|A~1~|A~2~|...|A~n~ 5+| -|*L1*|A0|A1|...|An +|*L2*|B~1~|B~2~|...|B~m~ 5+| -|*L2*|B0|B1|...|Bm -5+| -|*mp_product* -|F -F -... -F -|F -F -... -F -|... -|F -F -... -F +|*mp_product*|F|F|...|F +||F|F|...|F +| +4+|... +||F|F|...|F |=== ## mp_product_q @@ -269,6 +303,12 @@ Same as `mp_iota_c`, but with a type argument `N`. `N::value` must be a nonnegat `mp_list, std::integral_constant, ..., std::integral_constant>` where `T` is the type of `N::value`. +.mp_iota +[cols="<.^4m,4*^.^1m",width=85%] +|=== +|*mp_iota>*|mp_int<0>|mp_int<1>|mp_int<2>|mp_int<3> +|=== + ## mp_at_c template using mp_at_c = /*...*/; @@ -327,12 +367,30 @@ Same as `mp_erase_c`, but with a type arguments `I` and `J`. Replaces all `V` elements of `L` with `W` and returns the result. +.mp_replace +[cols="<.^4m,4*^.^1m",width=85%] +|=== +|*L1*|A~1~|V|...|A~n~ +5+| +|*mp_replace*|A~1~|W|...|A~n~ +|=== + ## mp_replace_if template class P, class W> using mp_replace_if = /*...*/; Replaces all `T` elements of `L` for which `mp_to_bool>` is `mp_true` with `W` and returns the result. +.mp_replace_if +[cols="<.^4m,4*^.^1m",width=85%] +|=== +|*L1*|A~1~|A~2~|...|A~n~ +5+| +|*P*|mp_false|mp_true|...|mp_false +5+| +|*mp_replace_if*|A~1~|W|...|A~n~ +|=== + ## mp_replace_at_c template using mp_replace_at_c = /*...*/; @@ -405,6 +463,14 @@ is `mp_size`. `mp_reverse>` is `L`. +.mp_reverse +[cols="<.^4m,4*^.^1m",width=85%] +|=== +|*L1*|A~1~|A~2~|...|A~n~ +5+| +|*mp_reverse*|A~n~|A~n-1~|...|A~1~ +|=== + ## mp_fold template class F> using mp_fold = /*...*/;