-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsubset_prb.cpp
18798 lines (16049 loc) · 346 KB
/
subset_prb.cpp
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
# include <cmath>
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <ctime>
using namespace std;
# include "subset.hpp"
int main ( );
void asm_enum_test ( );
void asm_triangle_test ( );
void bell_test ( );
void catalan_test ( );
void catalan_row_next_test ( );
void cfrac_to_rat_test ( );
void cfrac_to_rfrac_test ( );
void change_greedy_test ( );
void change_next_test ( );
void chinese_check_test ( );
void chinese_to_i4_test ( );
void comb_next_test ( );
void comb_row_next_test ( );
void comb_unrank_test ( );
void comp_enum_test ( );
void comp_next_test ( );
void comp_next_grlex_test ( );
void comp_random_test ( );
void comp_random_grlex_test ( );
void comp_rank_grlex_test ( );
void comp_to_ksub_test ( );
void comp_unrank_grlex_test ( );
void compnz_next_test ( );
void compnz_random_test ( );
void compnz_to_ksub_test ( );
void congruence_test ( );
void count_pose_random_test ( );
void debruijn_test ( );
void dec_add_test ( );
void dec_div_test ( );
void dec_mul_test ( );
void dec_round_test ( );
void dec_to_r8_test ( );
void dec_to_rat_test ( );
void dec_to_s_test ( );
void dec_width_test ( );
void decmat_det_test ( );
void decmat_print_test ( );
void derange_enum_test ( );
void derange_enum2_test ( );
void derange_enum3_test ( );
void derange0_back_next_test ( );
void derange0_check_test ( );
void derange0_weed_next_test ( );
void digraph_arc_euler_test ( );
void digraph_arc_print_test ( );
void diophantine_test ( );
void diophantine_solution_minimize_test ( );
void dvec_add_test ( );
void dvec_complementx_test ( );
void dvec_mul_test ( );
void dvec_print_test ( );
void dvec_sub_test ( );
void dvec_to_i4_test ( );
void equiv_next_test ( );
void equiv_next2_test ( );
void equiv_print_test ( );
void equiv_print2_test ( );
void equiv_random_test ( );
void euler_row_test ( );
void frobenius_number_order2_test ( );
void gray_next_test ( );
void gray_rank_test ( );
void gray_rank2_test ( );
void gray_unrank_test ( );
void gray_unrank2_test ( );
void i4_bclr_test ( );
void i4_bset_test ( );
void i4_btest_test ( );
void i4_choose_test ( );
void i4_factor_test ( );
void i4_fall_test ( );
void i4_gcd_test ( );
void i4_huge_test ( );
void i4_log_10_test ( );
void i4_modp_test ( );
void i4_moebius_test ( );
void i4_partition_conj_test ( );
void i4_partition_count_test ( );
void i4_partition_count2_test ( );
void i4_partition_next_test ( );
void i4_partition_next2_test ( );
void i4_partition_print_test ( );
void i4_partition_random_test ( );
void i4_partitions_next_test ( );
void i4_rise_test ( );
void i4_sqrt_test ( );
void i4_sqrt_cf_test ( );
void i4_to_chinese_test ( );
void i4_to_dvec_test ( );
void i4_to_i4poly_test ( );
void i4_to_van_der_corput_test ( );
void i4mat_01_rowcolsum_test ( );
void i4mat_u1_inverse_test ( );
void i4mat_perm0_test ( );
void i4mat_2perm0_test ( );
void i4poly_test ( );
void i4poly_add_test ( );
void i4poly_cyclo_test ( );
void i4poly_degree_test ( );
void i4poly_dif_test ( );
void i4poly_div_test ( );
void i4poly_mul_test ( );
void i4poly_print_test ( );
void i4poly_to_i4_test ( );
void i4vec_backtrack_test ( );
void i4vec_descends_test ( );
void i4vec_frac_test ( );
void i4vec_index_test ( );
void i4vec_maxloc_last_test ( );
void i4vec_pairwise_prime_test ( );
void i4vec_reverse_test ( );
void i4vec_sort_bubble_a_test ( );
void i4vec_sort_heap_index_d_test ( );
void i4vec_transpose_print_test ( );
void i4vec_uniform_ab_test ( );
void index_box_next_2d_test ( );
void index_box_next_3d_test ( );
void index_box2_next_2d_test ( );
void index_box2_next_3d_test ( );
void index_next0_test ( );
void index_next1_test ( );
void index_next2_test ( );
void index_rank0_test ( );
void index_rank1_test ( );
void index_rank2_test ( );
void index_unrank0_test ( );
void index_unrank1_test ( );
void index_unrank2_test ( );
void inverse_mod_n_test ( );
void inversion_to_perm0_test ( );
void involute_enum_test ( );
void jfrac_to_rfrac_test ( );
void josephus_test ( );
void ksub_next_test ( );
void ksub_next2_test ( );
void ksub_next3_test ( );
void ksub_next4_test ( );
void ksub_random_test ( );
void ksub_random2_test ( );
void ksub_random3_test ( );
void ksub_random4_test ( );
void ksub_random5_test ( );
void ksub_rank_test ( );
void ksub_to_comp_test ( );
void ksub_to_compnz_test ( );
void ksub_unrank_test ( );
void l4vec_next_test ( );
void matrix_product_opt_test ( );
void moebius_matrix_test ( );
void monomial_count_test ( );
void monomial_counts_test ( );
void morse_thue_test ( );
void multinomial_coef1_test ( );
void multinomial_coef2_test ( );
void multiperm_enum_test ( );
void multiperm_next_test ( );
void nim_sum_test ( );
void padovan_test ( );
void pell_basic_test ( );
void pell_next_test ( );
void pent_enum_test ( );
void perm_ascend_test ( );
void perm_fixed_enum_test ( );
void perm0_break_count_test ( );
void perm0_check_test ( );
void perm0_cycle_test ( );
void perm0_distance_test ( );
void perm0_free_test ( );
void perm0_inverse_test ( );
void perm0_inverse2_test ( );
void perm0_inverse3_new_test ( );
void perm0_lex_next_test ( );
void perm0_mul_test ( );
void perm0_next_test ( );
void perm0_next2_test ( );
void perm0_next3_test ( );
void perm0_print_test ( );
void perm0_random_test ( );
void perm0_random2_test ( );
void perm0_rank_test ( );
void perm0_sign_test ( );
void perm0_to_equiv_test ( );
void perm0_to_inversion_test ( );
void perm0_to_ytb_test ( );
void perm0_unrank_test ( );
void perm1_canon_to_cycle_test ( );
void perm1_check_test ( );
void perm1_cycle_to_canon_test ( );
void perm1_cycle_to_index_test ( );
void perm1_index_to_cycle_test ( );
void perm1_print_test ( );
void perrin_test ( );
void pord_check_test ( );
void power_mod_test ( );
void power_series1_test ( );
void power_series2_test ( );
void power_series3_test ( );
void power_series4_test ( );
void prime_test ( );
void pythag_triple_next_test ( );
void r8_agm_test ( );
void r8_choose_test ( );
void r8_epsilon_test ( );
void r8_fall_test ( );
void r8_rise_test ( );
void r8_to_cfrac_test ( );
void r8_to_dec_test ( );
void r8_to_rat_test ( );
void r8mat_det_test ( );
void r8mat_perm0_test ( );
void r8mat_2perm0_test ( );
void r8mat_permanent_test ( );
void r8poly_test ( );
void r8poly_add_test ( );
void r8poly_degree_test ( );
void r8poly_dif_test ( );
void r8poly_div_test ( );
void r8poly_f2p_test ( );
void r8poly_fval_test ( );
void r8poly_mul_test ( );
void r8poly_n2p_test ( );
void r8poly_nval_test ( );
void r8poly_nx_test ( );
void r8poly_p2f_test ( );
void r8poly_p2n_test ( );
void r8poly_p2t_test ( );
void r8poly_power_test ( );
void r8poly_print_test ( );
void r8poly_pval_test ( );
void r8poly_t2p_test ( );
void r8vec_backtrack_test ( );
void r8vec_frac_test ( );
void r8vec_mirror_next_test ( );
void rat_add_test ( );
void rat_div_test ( );
void rat_farey_test ( );
void rat_farey2_test ( );
void rat_mul_test ( );
void rat_normalize_test ( );
void rat_sum_formula_test ( );
void rat_to_cfrac_test ( );
void rat_to_dec_test ( );
void rat_to_r8_test ( );
void rat_to_s_test ( );
void rat_width_test ( );
void ratmat_det_test ( );
void ratmat_print_test ( );
void regro_next_test ( );
void rfrac_to_cfrac_test ( );
void rfrac_to_jfrac_test ( );
void schroeder_test ( );
void sort_heap_external_test ( );
void subset_by_size_next_test ( );
void subset_lex_next_test ( );
void subset_gray_next_test ( );
void subset_random_test ( );
void subset_gray_rank_test ( );
void subset_gray_unrank_test ( );
void subcomp_next_test ( );
void subcompnz_next_test ( );
void subcompnz2_next_test ( );
void subtriangle_next_test ( );
void thue_binary_next_test ( );
void thue_ternary_next_test ( );
void triang_test ( );
void tuple_next_test ( );
void tuple_next_fast_test ( );
void tuple_next_ge_test ( );
void tuple_next2_test ( );
void ubvec_add_test ( );
void ubvec_print_test ( );
void ubvec_to_ui4_test ( );
void ubvec_xor_test ( );
void ui4_to_ubvec_test ( );
void vec_colex_next_test ( );
void vec_colex_next2_test ( );
void vec_colex_next3_test ( );
void vec_gray_next_test ( );
void vec_gray_rank_test ( );
void vec_gray_unrank_test ( );
void vec_lex_next_test ( );
void vec_random_test ( );
void vector_constrained_next_test ( );
void vector_constrained_next2_test ( );
void vector_constrained_next3_test ( );
void vector_constrained_next4_test ( );
void vector_constrained_next5_test ( );
void vector_constrained_next6_test ( );
void vector_constrained_next7_test ( );
void vector_next_test ( );
void ytb_enum_test ( );
void ytb_next_test ( );
void ytb_random_test ( );
//****************************************************************************80
int main ( )
//****************************************************************************80
//
// Purpose:
//
// MAIN is the main program for SUBSET_PRB.
//
// Discussion:
//
// SUBSET_PRB tests the SUBSET library.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 24 June 2015
//
// Author:
//
// John Burkardt
//
{
timestamp ( );
cout << "\n";
cout << "SUBSET_PRB\n";
cout << " C++ version\n";
cout << " Test the SUBSET library.\n";
asm_enum_test ( );
asm_triangle_test ( );
bell_test ( );
catalan_test ( );
catalan_row_next_test ( );
cfrac_to_rat_test ( );
cfrac_to_rfrac_test ( );
change_greedy_test ( );
change_next_test ( );
chinese_check_test ( );
chinese_to_i4_test ( );
comb_next_test ( );
comb_row_next_test ( );
comb_unrank_test ( );
comp_enum_test ( );
comp_next_test ( );
comp_next_grlex_test ( );
comp_random_test ( );
comp_random_grlex_test ( );
comp_rank_grlex_test ( );
comp_to_ksub_test ( );
comp_unrank_grlex_test ( );
compnz_next_test ( );
compnz_random_test ( );
compnz_to_ksub_test ( );
congruence_test ( );
count_pose_random_test ( );
debruijn_test ( );
dec_add_test ( );
dec_div_test ( );
dec_mul_test ( );
dec_round_test ( );
dec_to_r8_test ( );
dec_to_rat_test ( );
dec_to_s_test ( );
dec_width_test ( );
decmat_det_test ( );
decmat_print_test ( );
derange_enum_test ( );
derange_enum2_test ( );
derange_enum3_test ( );
derange0_back_next_test ( );
derange0_check_test ( );
derange0_weed_next_test ( );
digraph_arc_euler_test ( );
digraph_arc_print_test ( );
diophantine_test ( );
diophantine_solution_minimize_test ( );
dvec_add_test ( );
dvec_complementx_test ( );
dvec_mul_test ( );
dvec_print_test ( );
dvec_sub_test ( );
dvec_to_i4_test ( );
equiv_next_test ( );
equiv_next2_test ( );
equiv_print_test ( );
equiv_print2_test ( );
equiv_random_test ( );
euler_row_test ( );
frobenius_number_order2_test ( );
gray_next_test ( );
gray_rank_test ( );
gray_rank2_test ( );
gray_unrank_test ( );
gray_unrank2_test ( );
i4_bclr_test ( );
i4_bset_test ( );
i4_btest_test ( );
i4_choose_test ( );
i4_factor_test ( );
i4_fall_test ( );
i4_gcd_test ( );
i4_huge_test ( );
i4_log_10_test ( );
i4_modp_test ( );
i4_moebius_test ( );
i4_partition_conj_test ( );
i4_partition_count_test ( );
i4_partition_count2_test ( );
i4_partition_next_test ( );
i4_partition_next2_test ( );
i4_partition_print_test ( );
i4_partition_random_test ( );
i4_partitions_next_test ( );
i4_rise_test ( );
i4_sqrt_test ( );
i4_sqrt_cf_test ( );
i4_to_chinese_test ( );
i4_to_dvec_test ( );
i4_to_i4poly_test ( );
i4_to_van_der_corput_test ( );
i4mat_01_rowcolsum_test ( );
i4mat_u1_inverse_test ( );
i4mat_perm0_test ( );
i4mat_2perm0_test ( );
i4poly_test ( );
i4poly_add_test ( );
i4poly_cyclo_test ( );
i4poly_degree_test ( );
i4poly_dif_test ( );
i4poly_div_test ( );
i4poly_mul_test ( );
i4poly_print_test ( );
i4poly_to_i4_test ( );
i4vec_backtrack_test ( );
i4vec_descends_test ( );
i4vec_frac_test ( );
i4vec_index_test ( );
i4vec_maxloc_last_test ( );
i4vec_pairwise_prime_test ( );
i4vec_reverse_test ( );
i4vec_sort_bubble_a_test ( );
i4vec_sort_heap_index_d_test ( );
i4vec_transpose_print_test ( );
i4vec_uniform_ab_test ( );
index_box_next_2d_test ( );
index_box_next_3d_test ( );
index_box2_next_2d_test ( );
index_box2_next_3d_test ( );
index_next0_test ( );
index_next1_test ( );
index_next2_test ( );
index_rank0_test ( );
index_rank1_test ( );
index_rank2_test ( );
index_unrank0_test ( );
index_unrank1_test ( );
index_unrank2_test ( );
inverse_mod_n_test ( );
inversion_to_perm0_test ( );
involute_enum_test ( );
jfrac_to_rfrac_test ( );
josephus_test ( );
ksub_next_test ( );
ksub_next2_test ( );
ksub_next3_test ( );
ksub_next4_test ( );
ksub_random_test ( );
ksub_random2_test ( );
ksub_random3_test ( );
ksub_random4_test ( );
ksub_random5_test ( );
ksub_rank_test ( );
ksub_to_comp_test ( );
ksub_to_compnz_test ( );
ksub_unrank_test ( );
l4vec_next_test ( );
matrix_product_opt_test ( );
moebius_matrix_test ( );
monomial_count_test ( );
monomial_counts_test ( );
morse_thue_test ( );
multinomial_coef1_test ( );
multinomial_coef2_test ( );
multiperm_enum_test ( );
multiperm_next_test ( );
nim_sum_test ( );
padovan_test ( );
pell_basic_test ( );
pell_next_test ( );
pent_enum_test ( );
perm_ascend_test ( );
perm_fixed_enum_test ( );
perm0_break_count_test ( );
perm0_check_test ( );
perm0_cycle_test ( );
perm0_distance_test ( );
perm0_free_test ( );
perm0_inverse_test ( );
perm0_inverse2_test ( );
perm0_inverse3_new_test ( );
perm0_lex_next_test ( );
perm0_mul_test ( );
perm0_next_test ( );
perm0_next2_test ( );
perm0_next3_test ( );
perm0_print_test ( );
perm0_random_test ( );
perm0_random2_test ( );
perm0_rank_test ( );
perm0_sign_test ( );
perm0_to_equiv_test ( );
perm0_to_inversion_test ( );
perm0_to_ytb_test ( );
perm0_unrank_test ( );
perm1_canon_to_cycle_test ( );
perm1_check_test ( );
perm1_cycle_to_canon_test ( );
perm1_cycle_to_index_test ( );
perm1_index_to_cycle_test ( );
perm1_print_test ( );
perrin_test ( );
pord_check_test ( );
power_mod_test ( );
power_series1_test ( );
power_series2_test ( );
power_series3_test ( );
power_series4_test ( );
prime_test ( );
pythag_triple_next_test ( );
r8_agm_test ( );
r8_choose_test ( );
r8_epsilon_test ( );
r8_fall_test ( );
r8_rise_test ( );
r8_to_cfrac_test ( );
r8_to_dec_test ( );
r8_to_rat_test ( );
r8mat_det_test ( );
r8mat_perm0_test ( );
r8mat_2perm0_test ( );
r8mat_permanent_test ( );
r8poly_test ( );
r8poly_add_test ( );
r8poly_degree_test ( );
r8poly_dif_test ( );
r8poly_div_test ( );
r8poly_f2p_test ( );
r8poly_fval_test ( );
r8poly_mul_test ( );
r8poly_n2p_test ( );
r8poly_nval_test ( );
r8poly_nx_test ( );
r8poly_p2f_test ( );
r8poly_p2n_test ( );
r8poly_p2t_test ( );
r8poly_power_test ( );
r8poly_print_test ( );
r8poly_pval_test ( );
r8poly_t2p_test ( );
r8vec_backtrack_test ( );
r8vec_frac_test ( );
r8vec_mirror_next_test ( );
rat_add_test ( );
rat_div_test ( );
rat_farey_test ( );
rat_farey2_test ( );
rat_mul_test ( );
rat_normalize_test ( );
rat_sum_formula_test ( );
rat_to_cfrac_test ( );
rat_to_dec_test ( );
rat_to_r8_test ( );
rat_to_s_test ( );
rat_width_test ( );
ratmat_det_test ( );
ratmat_print_test ( );
regro_next_test ( );
rfrac_to_cfrac_test ( );
rfrac_to_jfrac_test ( );
schroeder_test ( );
sort_heap_external_test ( );
subset_by_size_next_test ( );
subset_lex_next_test ( );
subset_gray_next_test ( );
subset_random_test ( );
subset_gray_rank_test ( );
subset_gray_unrank_test ( );
subcomp_next_test ( );
subcompnz_next_test ( );
subcompnz2_next_test ( );
subtriangle_next_test ( );
thue_binary_next_test ( );
thue_ternary_next_test ( );
triang_test ( );
tuple_next_test ( );
tuple_next_fast_test ( );
tuple_next_ge_test ( );
tuple_next2_test ( );
ubvec_add_test ( );
ubvec_print_test ( );
ubvec_to_ui4_test ( );
ubvec_xor_test ( );
ui4_to_ubvec_test ( );
vec_colex_next_test ( );
vec_colex_next2_test ( );
vec_colex_next3_test ( );
vec_gray_next_test ( );
vec_gray_rank_test ( );
vec_gray_unrank_test ( );
vec_lex_next_test ( );
vec_random_test ( );
vector_constrained_next_test ( );
vector_constrained_next2_test ( );
vector_constrained_next3_test ( );
vector_constrained_next4_test ( );
vector_constrained_next5_test ( );
vector_constrained_next6_test ( );
vector_constrained_next7_test ( );
vector_next_test ( );
ytb_enum_test ( );
ytb_next_test ( );
ytb_random_test ( );
//
// Terminate.
//
cout << "\n";
cout << "SUBSET_PRB\n";
cout << " Normal end of execution.\n";
cout << "\n";
timestamp ( );
return 0;
}
//****************************************************************************80
void asm_enum_test ( )
//****************************************************************************80
//
// Purpose:
//
// ASM_ENUM_TEST tests ASM_ENUM.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 11 October 2006
//
// Author:
//
// John Burkardt
//
{
int n;
cout << "\n";
cout << "ASM_ENUM_TEST\n";
cout << " ASM_ENUM returns the number of alternating sign\n";
cout << " matrices of a given order.\n";
cout << "\n";
for ( n = 0; n <= 7; n++ )
{
cout << setw(4) << n << " "
<< setw(6) << asm_enum ( n ) << "\n";
}
return;
}
//****************************************************************************80
void asm_triangle_test ( )
//****************************************************************************80
//
// Purpose:
//
// ASM_TRIANGLE_TEST tests ASM_TRIANGLE.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 11 October 2006
//
// Author:
//
// John Burkardt
//
{
# define N_MAX 7
int a[N_MAX+1];
int i;
int n;
cout << "\n";
cout << "ASM_TRIANGLE_TEST\n";
cout << " ASM_TRIANGLE returns a row of the alternating sign\n";
cout << " matrix triangle.\n";
cout << "\n";
for ( n = 0; n <= N_MAX; n++ )
{
asm_triangle ( n, a );
cout << setw(4) << n << " ";
for ( i = 0; i <= n; i++ )
{
cout << setw(8) << a[i] << " ";
}
cout << "\n";
}
return;
# undef N_MAX
}
//****************************************************************************80
void bell_test ( )
//****************************************************************************80
//
// Purpose:
//
// BELL_TEST tests BELL.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 07 November 2012
//
// Author:
//
// John Burkardt
//
{
int c;
int *c2;
int n;
int n_data;
cout << "\n";
cout << "BELL_TEST\n";
cout << " BELL computes Bell numbers.\n";
cout << "\n";
cout << " N exact C(I) computed C(I)\n";
cout << "\n";
n_data = 0;
for ( ; ; )
{
bell_values ( n_data, n, c );
if ( n_data == 0 )
{
break;
}
c2 = new int[n+1];
bell ( n, c2 );
cout << " "
<< setw(4) << n << " "
<< setw(8) << c << " "
<< setw(8) << c2[n] << "\n";
delete [] c2;
}
return;
}
//****************************************************************************80
void catalan_test ( )
//****************************************************************************80
//
// Purpose:
//
// CATALAN_TEST tests CATALAN.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 07 November 2012
//
// Author:
//
// John Burkardt
//
{
int c;
int *c2;
int n;
int n_data;
cout << "\n";
cout << "CATALAN_TEST\n";
cout << " CATALAN computes Catalan numbers.\n";
cout << "\n";
cout << " N exact C(I) computed C(I)\n";
cout << "\n";
n_data = 0;
for ( ; ; )
{
catalan_values ( n_data, n, c );
if ( n_data == 0 )
{
break;
}
c2 = new int[n+1];
catalan ( n, c2 );
cout << " "
<< setw(4) << n << " "
<< setw(8) << c << " "
<< setw(8) << c2[n] << "\n";
delete [] c2;
}
return;
}
//****************************************************************************80
void catalan_row_next_test ( )
//****************************************************************************80
//
// Purpose:
//
// CATALAN_ROW_NEXT_TEST tests CATALAN_ROW_NEXT.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 11 October 2006
//
// Author:
//
// John Burkardt
//
{
# define N_MAX 10
int c[N_MAX+1];
int i;
int n;
bool next;
cout << "\n";
cout << "CATALAN_ROW_NEXT_TEST\n";
cout << " CATALAN_ROW_NEXT computes a row of the Catalan triangle.\n";
cout << "\n";
cout << " First, compute row 7:\n";
next = false;
n = 7;
catalan_row_next ( next, n, c );
cout << setw(4) << n << " ";
for ( i = 0; i <= n; i++ )
{
cout << setw(8) << c[i] << " ";
}
cout << "\n";
cout << "\n";
cout << " Now compute rows consecutively, one at a time:\n";
cout << "\n";
next = false;
for ( n = 0; n <= N_MAX; n++ )
{
catalan_row_next ( next, n, c );
next = true;
cout << setw(4) << n << " ";
for ( i = 0; i <= n; i++ )
{
cout << setw(6) << c[i] << " ";
}
cout << "\n";
}
return;
# undef N_MAX
}
//****************************************************************************80
void cfrac_to_rat_test ( )
//****************************************************************************80
//
// Purpose:
//
// CFRAC_TO_RAT_TEST tests CFRAC_TO_RAT.
//
// Discussion:
//
// Compute the continued fraction form of 4096/15625.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 11 October 2006
//
// Author:
//
// John Burkardt
//
{
# define M 10
int a[M];
int bot = 15625;
bool error;
int i;
int n;
int p[M];
int q[M];
int top = 4096;
cout << "\n";
cout << "CFRAC_TO_RAT_TEST\n";
cout << " CFRAC_TO_RAT continued fraction => fraction.\n";
cout << "\n";
cout << " Regular fraction is " << top << "/" << bot << "\n";
rat_to_cfrac ( top, bot, M, n, a, error );
i4vec1_print ( n, a, " Continued fraction coefficients:" );
cfrac_to_rat ( n, a, p, q );
cout << "\n";
cout << " The continued fraction convergents.\n";
cout << " The last row contains the value of the continued\n";
cout << " fraction, written as a common fraction.\n";
cout << "\n";
cout << " I, P(I), Q(I), P(I)/Q(I)\n";
cout << "\n";
for ( i = 0; i < n; i++ )
{
cout << setw(3) << i << " "
<< setw(6) << p[i] << " "
<< setw(6) << q[i] << " "
<< setw(14) << ( double ) p[i] / ( double ) q[i] << "\n";
}
return;
# undef M
}
//****************************************************************************80
void cfrac_to_rfrac_test ( )
//****************************************************************************80
//