-
Notifications
You must be signed in to change notification settings - Fork 2
/
D7Dist.h
1383 lines (1180 loc) · 49.5 KB
/
D7Dist.h
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
//
// CD7Dist.c
//
//
// Created by Herbert J. Bernstein and Lawrence C. Andrews on 3/04/17.
//
//
#ifndef D7DIST_H
#define D7DIST_H
#ifdef __cplusplus
extern "C" {
#endif
/* #define D7DIST_DEBUG */
#define D7DIST_NO_OUTER_PASS
#include <math.h>
#include <float.h>
/*#define D7DIST_DEBUG */
#ifdef D7DIST_DEBUG
static int changed=0;
static double oldvalue;
#include <stdio.h>
#define report_double(prolog,value,epilog) \
oldvalue=value; fprintf(stderr,"%s%g%s",prolog,value,epilog);
#define report_integer(prolog,value,epilog) \
fprintf(stderr,"%s%d%s",prolog,value,epilog);
#define report_double_if_changed(prolog,value,epilog) \
changed=0; if (fabs(value-oldvalue)>1.e-8*(fabs(value)+fabs(oldvalue)+1.e-12)) {oldvalue=value; changed=1; fprintf(stderr,"%s%g%s",prolog,value,epilog);}
#define also_if_changed_report(prolog,value,epilog) \
if(changed) {fprintf(stderr,"%s%s%s",prolog,value,epilog);}
#define also_if_changed_report_integer(prolog,value,epilog) \
if(changed) {fprintf(stderr,"%s%d%s",prolog,value,epilog);}
#define also_if_changed_report_double(prolog,value,epilog) \
if(changed) {fprintf(stderr,"%s%g%s",prolog,value,epilog);}
#define also_if_changed_report_double_vector(prolog,value,epilog) \
if(changed) {fprintf(stderr,"%s[%g, %g, %g, %g, %g, %g, %g]%s",prolog,value[0],value[1],value[2],value[3],value[4],value[5],value[6],epilog);}
#define report_double_vector(prolog,value,epilog) \
{fprintf(stderr,"%s[%g, %g, %g, %g, %g, %g, %g]%s",prolog,value[0],value[1],value[2],value[3],value[4],value[5],value[6],epilog);}
#else
#define report_double(prolog,value,epilog)
#define report_integer(prolog,value,epilog)
#define report_double_if_changed(prolog,value,epilog)
#define also_if_changed_report(prolog,value,epilog)
#define also_if_changed_report_integer(prolog,value,epilog)
#define also_if_changed_report_double(prolog,value,epilog)
#define also_if_changed_report_double_vector(prolog,value,epilog)
#define report_double_vector(prolog,value,epilog)
#endif
#define CD7M_min(a,b) (((a)<(b))?(a):(b))
#define CD7M_max(a,b) (((a)<(b))?(b):(a))
#define ND7BND 9
#define D7P_1 0
#define D7P_2 1
#define D7P_3 2
#define D7P_4 3
#define D7P_5 4
#define D7P_6 5
#define D7P_7 6
#define D7P_8 7
#define D7P_9 8
#define ND7BDPRJ 9
/* D7Dist Boundary projectors */
static double d7prj[ND7BDPRJ][49]= {
/*prj[D7P_1] ,1,*/
{0.3571428571428572,0.3571428571428572,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
0.3571428571428572,0.3571428571428572,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,0.8571428571428571,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
0.8571428571428571,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,0.8571428571428571,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,0.8571428571428571,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
0.8571428571428571},
/*prj[D7P_2] 2,*/
{0.8571428571428571,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,0.3571428571428572,0.3571428571428572,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,0.3571428571428572,0.357142571428572,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
0.8571428571428571,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,0.8571428571428571,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,0.8571428571428571,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
0.8571428571428571},
/*prj[D7P_3] 3,*/
{0.8571428571428571,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,0.8571428571428571,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,0.3571428571428572,
0.3571428571428572,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,0.3571428571428572,
0.3571428571428572,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,0.8571428571428571,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,0.8571428571428571,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
0.8571428571428571},
/*prj[D7P_4] 4,*/
{0.75,0.0,0.0,-0.25,0.0,0.25,0.25,
0.0,0.6666666666666666,-0.3333333333333333,0.0,
0.3333333333333333,0.0,0.0,
0.0,-0.3333333333333333,0.6666666666666666,0.0,
0.3333333333333333,0.0,0.0,-0.25,0.0,0.0,0.75,0.0,0.25,0.25,
0.0,0.3333333333333333,0.3333333333333333,0.0,
0.6666666666666666,0.0,0.0,0.25,0.0,0.0,0.25,0.0,0.75,-0.25,
0.25,0.0,0.0,0.25,0.0,-0.25,0.75},
/*prj[D7P_5] 5 */
{0.6666666666666666,0.0,0.0,-0.3333333333333333,
0.3333333333333333,0.0,0.0,0.0,0.75,-0.25,0.0,0.0,0.25,0.25,
0.0,-0.25,0.75,0.0,0.0,0.25,0.25,
-0.3333333333333333,0.0,0.0,0.6666666666666666,
0.3333333333333333,0.0,0.0,
0.3333333333333333,0.0,0.0,0.3333333333333333,
0.6666666666666666,0.0,0.0,0.0,0.25,0.25,0.0,0.0,0.75,-0.25,
0.0,0.25,0.25,0.0,0.0,-0.25,0.75},
/*prj[D7P_6] 6 */
{0.6666666666666666,0.0,-0.3333333333333333,0.0,0.0,
0.3333333333333333,0.0,0.0,0.75,0.0,-0.25,0.25,0.0,0.25,
-0.3333333333333333,0.0,0.6666666666666666,0.0,0.0,
0.3333333333333333,0.0,0.0,-0.25,0.0,0.75,0.25,0.0,0.25,
0.0,0.25,0.0,0.25,0.75,0.0,-0.25,
0.3333333333333333,0.0,0.3333333333333333,0.0,0.0,
0.6666666666666666,0.0,0.0,0.25,0.0,0.25,-0.25,0.0,0.75},
/*prj[D7P_7] 7 */
{0.75,0.0,-0.25,0.0,0.25,0.0,0.25,
0.0,0.6666666666666666,0.0,-0.3333333333333333,0.0,
0.3333333333333333,0.0,-0.25,0.0,0.75,0.0,0.25,0.0,0.25,
0.0,-0.3333333333333333,0.0,0.6666666666666666,0.0,
0.3333333333333333,0.0,0.25,0.0,0.25,0.0,0.75,0.0,-0.25,
0.0,0.3333333333333333,0.0,0.3333333333333333,0.0,
0.6666666666666666,0.0,0.25,0.0,0.25,0.0,-0.25,0.0,0.75},
/*prj[D7P_8] 8 */
{0.6666666666666666,-0.3333333333333333,0.0,0.0,0.0,0.0,
0.3333333333333333,
-0.3333333333333333,0.6666666666666666,0.0,0.0,0.0,0.0,
0.3333333333333333,0.0,0.0,0.75,-0.25,0.25,0.25,0.0,
0.0,0.0,-0.25,0.75,0.25,0.25,0.0,
0.0,0.0,0.25,0.25,0.75,-0.25,0.0,
0.0,0.0,0.25,0.25,-0.25,0.75,0.0,
0.3333333333333333,0.3333333333333333,0.0,0.0,0.0,0.0,
0.6666666666666666},
/*prj[D7P_9] 9 */
{0.75,-0.25,0.0,0.0,0.25,0.25,0.0,
-0.25,0.75,0.0,0.0,0.25,0.25,0.0,
0.0,0.0,0.6666666666666666,-0.3333333333333333,0.0,0.0,
0.3333333333333333,
0.0,0.0,-0.3333333333333333,0.6666666666666666,0.0,0.0,
0.3333333333333333,0.25,0.25,0.0,0.0,0.75,-0.25,0.0,
0.25,0.25,0.0,0.0,-0.25,0.75,0.0,
0.0,0.0,0.3333333333333333,0.3333333333333333,0.0,0.0,
0.6666666666666666}};
static double d7prj_perp[ND7BDPRJ][49]= {
/*prj_perp[D7P_1] 1 */
{0.6428571428571429,-0.3571428571428572,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
-0.3571428571428572,0.6428571428571429,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428},
/*prj_perp[D7P_2] 2 */
{0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.6428571428571429,-0.3571428571428572,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,-0.3571428571428572,0.6428571428571429,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428},
/*prj_perp[D7P_3] 3 */
{0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,0.6428571428571429,
-0.3571428571428572,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
0.1428571428571428,0.1428571428571428,-0.3571428571428572,
0.6428571428571429,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428,
-0.1428571428571428,-0.1428571428571428,-0.1428571428571428,
-0.1428571428571428,0.1428571428571428,0.1428571428571428,
0.1428571428571428},
/*prj_perp[D7P_4] 4 */
{0.25,0.0,0.0,0.25,0.0,-0.25,-0.25,
0.0,0.3333333333333333,0.3333333333333333,0.0,
-0.3333333333333333,0.0,0.0,
0.0,0.3333333333333333,0.3333333333333333,0.0,
-0.3333333333333333,0.0,0.0,
0.25,0.0,0.0,0.25,0.0,-0.25,-0.25,
0.0,-0.3333333333333333,-0.3333333333333333,0.0,
0.3333333333333333,0.0,0.0,
-0.25,0.0,0.0,-0.25,0.0,0.25,0.25,
-0.25,0.0,0.0,-0.25,0.0,0.25,0.25},
/*prj_perp[D7P_5] 5 */
{0.3333333333333333,0.0,0.0,0.3333333333333333,
-0.3333333333333333,0.0,0.0,
0.0,0.25,0.25,0.0,0.0,-0.25,-0.25,
0.0,0.25,0.25,0.0,0.0,-0.25,-0.25,
0.3333333333333333,0.0,0.0,0.3333333333333333,
-0.3333333333333333,0.0,0.0,
-0.3333333333333333,0.0,0.0,-0.3333333333333333,
0.3333333333333333,0.0,0.0,
0.0,-0.25,-0.25,0.0,0.0,0.25,0.25,
0.0,-0.25,-0.25,0.0,0.0,0.25,0.25},
/*prj_perp[D7P_6] 6 */
{0.3333333333333333,0.0,0.3333333333333333,0.0,0.0,
-0.3333333333333333,0.0,0.0,0.25,0.0,0.25,-0.25,0.0,-0.25,
0.3333333333333333,0.0,0.3333333333333333,0.0,0.0,
-0.3333333333333333,0.0,0.0,0.25,0.0,0.25,-0.25,0.0,-0.25,
0.0,-0.25,0.0,-0.25,0.25,0.0,0.25,
-0.3333333333333333,0.0,-0.3333333333333333,0.0,0.0,
0.3333333333333333,0.0,0.0,-0.25,0.0,-0.25,0.25,0.0,0.25},
/*prj_perp[D7P_7] 7 */
{0.25,0.0,0.25,0.0,-0.25,0.0,-0.25,
0.0,0.3333333333333333,0.0,0.3333333333333333,0.0,
-0.3333333333333333,0.0,0.25,0.0,0.25,0.0,-0.25,0.0,-0.25,
0.0,0.3333333333333333,0.0,0.3333333333333333,0.0,
-0.3333333333333333,0.0,-0.25,0.0,-0.25,0.0,0.25,0.0,0.25,
0.0,-0.3333333333333333,0.0,-0.3333333333333333,0.0,
0.3333333333333333,0.0,-0.25,0.0,-0.25,0.0,0.25,0.0,0.25},
/*prj_perp[D7P_8] 8 */
{0.3333333333333333,0.3333333333333333,0.0,0.0,0.0,0.0,
-0.3333333333333333,
0.3333333333333333,0.3333333333333333,0.0,0.0,0.0,0.0,
-0.3333333333333333,0.0,0.0,0.25,0.25,-0.25,-0.25,0.0,
0.0,0.0,0.25,0.25,-0.25,-0.25,0.0,
0.0,0.0,-0.25,-0.25,0.25,0.25,0.0,
0.0,0.0,-0.25,-0.25,0.25,0.25,0.0,
-0.3333333333333333,-0.3333333333333333,0.0,0.0,0.0,0.0,
0.3333333333333333},
/*prj_perp[D7P_9] 9 */
{0.25,0.25,0.0,0.0,-0.25,-0.25,0.0,
0.25,0.25,0.0,0.0,-0.25,-0.25,0.0,
0.0,0.0,0.3333333333333333,0.3333333333333333,0.0,0.0,
-0.3333333333333333,
0.0,0.0,0.3333333333333333,0.3333333333333333,0.0,0.0,
-0.3333333333333333,-0.25,-0.25,0.0,0.0,0.25,0.25,0.0,
-0.25,-0.25,0.0,0.0,0.25,0.25,0.0,
0.0,0.0,-0.3333333333333333,-0.3333333333333333,0.0,0.0,
0.3333333333333333}};
/* The following matrices are the transformation
matrices that may be applied at the associated
boundaries. *** An addition post permutation may
be needed to preserve D7 ordering *** */
/* D7 post permuations {1,2,3,4,5,6,7}, Ident
{1,2,4,3,6,5,7}, D7M_3
{1,3,2,4,5,7,6}, D7M_2
{1,3,4,2,7,5,6}, D7M_1.D7M_2
{1,4,2,3,6,7,5},
{1,4,3,2,7,6,5},
{3,1,2,4,7,5,6},
{4,1,2,3,7,6,5}
*/
#define D7Refl_1 0
#define D7Refl_2 6
#define D7Refl_3 2
#define D7Refl_4 1
#define D7Refl_term -1
static int D7Rord[24]= {0,1,2,3,4,5,12,18,6,7,8,9,10,11,13,14,15,16,17,19,20,21,22,23};
static int D7Refl[24][49]={
/*D7Refl_1 {1,2,3,4,5,6,7}, Ident*/
/*DR_0*/ {
1,0,0,0,0,0,0,
0,1,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1},
/*D7Refl_4 {1,2,4,3,6,5,7}, c <-> d */
/*DR_1*/ {
1,0,0,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1},
/*D7Refl_3 {1,3,2,4,5,7,6}, b <-> c */
/*DR_2*/ {
1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0},
/* {1,3,4,2,7,5,6} */
/*DR_3*/ {
1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,1,0,0,0,
0,1,0,0,0,0,0,
0,0,0,0,0,0,1,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0},
/* {1,4,2,3,6,7,5} */
/*DR_4*/ {
1,0,0,0,0,0,0,
0,0,0,1,0,0,0,
0,1,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1,
0,0,0,0,1,0,0},
/* {1,4,3,2,6.7,5} */
/*DR_5*/ {
1,0,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,1,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0},
/*D7Refl_2 {2,1,3,4,6,5,7}, a <-> b */
/*DR_6*/ {
0,1,0,0,0,0,0,
1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1},
/*DR_7*/ {
0,1,0,0,0,0,0,
1,0,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1},
/*DR_8*/ {
0,1,0,0,0,0,0,
0,0,1,0,0,0,0,
1,0,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1,
0,0,0,0,1,0,0},
/*DR_9*/ {
0,1,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,1,0,0,0,
1,0,0,0,0,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0},
/*DR_10*/ {
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0},
/*DR_11*/ {
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,1,0,0,0,0,
1,0,0,0,0,0,0,
0,0,0,0,0,0,1,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0},
/* {3,1,2,4,7,5,6} */
/*DR_12*/ {
0,0,1,0,0,0,0,
1,0,0,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,0,0,1,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0},
/*DR_13*/ {
0,0,1,0,0,0,0,
1,0,0,0,0,0,0,
0,0,0,1,0,0,0,
0,1,0,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0},
/*DR_14*/ {
0,0,1,0,0,0,0,
0,1,0,0,0,0,0,
1,0,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0},
/*DR_15*/ {
0,0,1,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
1,0,0,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1,
0,0,0,0,1,0,0},
/*DR_16*/ {
0,0,1,0,0,0,0,
0,0,0,1,0,0,0,
1,0,0,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1},
/*DR_17*/ {
0,0,1,0,0,0,0,
0,0,0,1,0,0,0,
0,1,0,0,0,0,0,
1,0,0,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1},
/*DR_18*/ {
0,0,0,1,0,0,0,
1,0,0,0,0,0,0,
0,1,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0},
/*DR_19*/ {
0,0,0,1,0,0,0,
1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1,
0,0,0,0,1,0,0},
/*DR_20*/ {
0,0,0,1,0,0,0,
0,1,0,0,0,0,0,
1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,0,0,1,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0},
/*DR_21*/ {
0,0,0,1,0,0,0,
0,1,0,0,0,0,0,
0,0,1,0,0,0,0,
1,0,0,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0},
/*DR_22*/ {
0,0,0,1,0,0,0,
0,0,1,0,0,0,0,
1,0,0,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1},
/*DR_23*/ {
0,0,0,1,0,0,0,
0,0,1,0,0,0,0,
0,1,0,0,0,0,0,
1,0,0,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1}
};
/* The 24 D7 permuations, the first 8 of which are seen in the
boundary transforms */
static int D7Perm[24][8] = {
/* D7Perm_1 {1,2,3,4,5,6,7}, Ident OK */
{D7Refl_1,D7Refl_term,0,0,0,0,0,0},
/* D7Perm_2 {1,2,4,3,6,5,7} OK */
{D7Refl_4,D7Refl_term,0,0,0,0,0,0},
/* D7Perm_3 {1,3,2,4,5,7,6} OK */
{D7Refl_3,D7Refl_term,0,0,0,0,0,0},
/* D7Perm_4 {1,3,4,2,7,5,6}, OK */
{D7Refl_4,D7Refl_3,D7Refl_term,0,0,0,0,0},
/* D7Perm_5 {1,4,2,3,6,7,5} OK */
{D7Refl_3,D7Refl_4,D7Refl_term,0,0,0,0,0},
/* D7Perm_6 {1,4,3,2,7,6,5} OK */
{D7Refl_4,D7Refl_3,D7Refl_4,D7Refl_term,0,0,0,0},
/* D7Perm_7 {3,1,2,4,7,5,6} OK */
{D7Refl_2,D7Refl_3,D7Refl_term,0,0,0,0,0},
/* D7Perm_8 {4,1,2,3,7,6,5} OK */
{D7Refl_2,D7Refl_3,D7Refl_4,D7Refl_term,0,0,0,0},
/* D7Perm_9 {2, 1, 3, 4} OK */
{D7Refl_2,D7Refl_term,0,0,0,0,0,0},
/* D7Perm_10 {2, 1 ,4, 3} OK */
{D7Refl_4,D7Refl_2,D7Refl_term,0,0,0,0,0},
/* D7Perm_11 {2, 3, 1, 4} OK */
{D7Refl_3,D7Refl_2,D7Refl_term,0,0,0,0,0},
/* D7Perm_12 {2, 3, 4, 1} OK */
{D7Refl_4,D7Refl_3,D7Refl_2,D7Refl_term,0,0,0,0},
/* D7Perm_13 {2, 4, 1, 3} OK */
{D7Refl_3,D7Refl_4,D7Refl_2,D7Refl_term,0,0,0,0},
/* D7Perm_14 {2, 4, 3, 1} OK */
{D7Refl_4,D7Refl_3,D7Refl_4,D7Refl_2,D7Refl_term,0,0,0},
/* D7Perm_15 {3, 1, 4, 2} OK */
{D7Refl_4,D7Refl_2,D7Refl_3,D7Refl_term,0,0,0,0},
/* D7Perm_16 {3, 2, 1, 4} OK */
{D7Refl_3,D7Refl_2,D7Refl_3,D7Refl_term,0,0,0,0},
/* D7Perm_17 {3, 2, 4, 1} OK */
{D7Refl_4,D7Refl_3,D7Refl_2,D7Refl_3,D7Refl_term,0,0,0},
/* D7Perm_18 {3, 4, 1, 2} OK */
{D7Refl_3,D7Refl_4,D7Refl_2,D7Refl_3,D7Refl_term,0,0,0},
/* D7Perm_19 {3, 4, 2, 1} OK */
{D7Refl_4,D7Refl_3,D7Refl_4,D7Refl_2,D7Refl_3,D7Refl_term,0,0},
/* D7Perm_20 {4, 1, 3, 2} OK */
{D7Refl_2,D7Refl_4,D7Refl_3,D7Refl_4,D7Refl_term,0,0,0},
/* D7Perm_21 {4, 2, 1, 3} OK */
{D7Refl_2,D7Refl_3,D7Refl_4,D7Refl_2,D7Refl_term,0,0,0},
/* D7Perm_22 {4, 2, 3, 1} OK */
{D7Refl_2,D7Refl_4,D7Refl_3,D7Refl_4,D7Refl_2,D7Refl_term,0,0},
/* D7Perm_23 {4, 3, 1, 2} OK */
{D7Refl_2,D7Refl_3,D7Refl_4,D7Refl_2,D7Refl_3,D7Refl_term,0,0},
/* D7Perm_24 {4, 3, 2, 1} OK */
{D7Refl_4,D7Refl_2,D7Refl_3,D7Refl_4,D7Refl_2,D7Refl_3,D7Refl_term,0}
};
static int D7MS[9][49] = {
/* D7M_1 d1 <-> d2, d5 <-> d6 {2,1,3,4,6,5,7} */
{0,1,0,0,0,0,0,
1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1},
/* D7M_2 d2 <-> d3, d6 <-> d7 {1,3,2,4,5,7,6} */
{1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1,
0,0,0,0,0,1,0},
/* D7M_3 d3 <-> d4, d5 <-> d6 {1,2,4,3,6,5,7}*/
{1,0,0,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1},
/* D7M_4 d1->d2, d2->d3, d3->d6, d4->d7, d5->d1, d6->d4, d7->2d2+2d3-d5
and post permutations 1,2,3,4,5,6,7,8
*/
{0,1,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1,
1,0,0,0,0,0,0,
0,0,0,1,0,0,0,
0,2,2,0,-1,0,0},
/* D7M_5 d2->d4, d3->d5, d4->d1, d5->d2, d6->d3, d7->-2d2-2d3+d5+2d6+2d7
and post permutations 1,2,3,4,5,6,7,8 */
{1,0,0,0,0,0,0,
0,0,0,1,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,0,0,1,
0,1,0,0,0,0,0,
0,0,1,0,0,0,0,
2,0,0,2,-1,0,0},
/* D7M_6 d2->d3, d3->d5, d4->d7, d5->d2, d6->d4, d6->2d1+2d3-d6
and post permutations 1,2,3,4,5,6,7,8 */
{1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1,
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
2,0,2,0,0,-1,0},
/* D7M_7 d2->d3, d3->d5, d4->d1, d5->d2, d6->d4, d6-2d1+2d3-d6
and post permutations 1,2,3,4,5,6,7,8, all are case 6 cells */
{1,0,0,0,0,0,0,
0,0,1,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,0,1,
0,1,0,0,0,0,0,
0,0,0,1,0,0,0,
2,0,2,0,0,-1,0},
/* D7M_8 d3->d5, d4->d6, d5->d3, d6->d4, d7->2d1+2d2-d7
and post permutations 1,2,3,5,8,7 */
{1,0,0,0,0,0,0,
0,1,0,0,0,0,0,
0,0,0,0,1,0,0,
0,0,0,0,0,1,0,
0,0,1,0,0,0,0,
0,0,0,1,0,0,0,
2,2,0,0,0,0,-1},
/* D7M_9 d1->d3, d2->d6, d3->d5, d5->-2d1-2d2+2d5+2d6+d7,d6->d2,d7->d1 */
{0,0,1,0,0,0,0,
0,0,0,0,0,1,0,
0,0,0,0,1,0,0,
0,0,0,1,0,0,0,
0,0,2,2,0,0,-1,
0,1,0,0,0,0,0,
1,0,0,0,0,0,0}
};
#undef M_E
#define M_1 0
#define M_2 1
#define M_3 2
#define M_4 3
#define M_5 4
#define M_6 5
#define M_7 6
#define M_8 7
#define M_9 8
#define M_A 9
#define M_B 10
#define M_C 11
#define M_D 12
#define M_E 13
#define M_F 14
#define NMPGS 65
#define NPGS 18
/* Test if outside D7 region
return 0 if outside */
int d7test(double g[7]);
/* Compute the dot product of 2 D7 vectors */
static double d7dotprod(double v1[7], double v2[7]) {
return v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]+v1[3]*v2[3]+v1[4]*v2[4]+v1[5]*v2[5]+v1[6]*v2[6];
}
/* Compute the simple Euclidean distance between 2 D7 vectors */
static double d7eucldistsq(double v1[7], double v2[7]) {
double vtemp;
int ii;
double distsq;
distsq = 0.;
for (ii = 0; ii < 7; ii++ ) {
vtemp = v1[ii]-v2[ii];
distsq += vtemp*vtemp;
}
return distsq;
}
static double d7eucldist(double v1[7], double v2[6]) {
return sqrt(d7eucldistsq(v1,v2));
}
#define CD7M_min2(a,b) (((a)<(b))?(a):(b))
#define CD7M_min3(a,b,c) ((CD7M_min2(a,b)<(c))?(CD7M_min2(a,b)):(c))
#define CD7M_min4(a,b,c,d) ((CD7M_min3(a,b,c)<(d))?(CD7M_min3(a,b,c)):(d))
#define CD7M_min5(a,b,c,d,e) ((CD7M_min4(a,b,c,d)<(e))?(CD7M_min4(a,b,c,d)):(e))
#define CD7M_min6(a,b,c,d,e,f) ((CD7M_min5(a,b,c,d,e)<(f))?(CD7M_min5(a,b,c,d,e)):(f))
#define CD7M_min7(a,b,c,d,e,f,g) ((CD7M_min6(a,b,c,d,e,f)<(g))?(CD7M_min6(a,b,c,d,e,f)):(g))
#define CD7M_min8(a,b,c,d,e,f,g,h) ((CD7M_min7(a,b,c,d,e,f,g)<(h))?(CD7M_min7(a,b,c,d,e,f,g)):(h))
/* Macro versions of distances */
#define CD7M_normsq(v) v[0]*v[0]+v[1]*v[1]+v[2]*v[2]+v[3]*v[3]+v[4]*v[4]+v[5]*v[5]
#define CD7M_norm(v) sqrt(CD7M_normsq(v))
#define CD7M_d7normsq(v) v[0]*v[0]+v[1]*v[1]+v[2]*v[2]+v[3]*v[3]+v[4]*v[4]+v[5]*v[5]+v[6]*v[6]
#define CD7M_d7norm(v) sqrt(CD7M_d7normsq(v))
#define CD7M_gdistsq(v1,v2) \
( \
(v1[0]-v2[0])*(v1[0]-v2[0])+\
(v1[1]-v2[1])*(v1[1]-v2[1])+\
(v1[2]-v2[2])*(v1[2]-v2[2])+\
(v1[3]-v2[3])*(v1[3]-v2[3])+\
(v1[4]-v2[4])*(v1[4]-v2[4])+\
(v1[5]-v2[5])*(v1[5]-v2[5]))
#define CD7M_gdist(v1,v2) sqrt(CD7M_gdistsq(v1,v2))
#define CD7M_d7eucldistsq(v1,v2) \
( \
(v1[0]-v2[0])*(v1[0]-v2[0])+\
(v1[1]-v2[1])*(v1[1]-v2[1])+\
(v1[2]-v2[2])*(v1[2]-v2[2])+\
(v1[3]-v2[3])*(v1[3]-v2[3])+\
(v1[4]-v2[4])*(v1[4]-v2[4])+\
(v1[5]-v2[5])*(v1[5]-v2[5])+\
(v1[6]-v2[6])*(v1[6]-v2[6])\
)
#define CD7M_d7eucldist(v1,v2) sqrt(CD7M_d7eucldistsq(v1,v2))
/* Compute the best distance between 2 d6 vectors
allowing for permulations of d1, d2, d3, d4
*/
#define CD7M_d7eucldistsq_byelem(v11,v12,v13,v14,v15,v16,v17,v21,v22,v23,v24,v25,v26,v27) \
fabs((v11-v21)*(v11-v21)+(v12-v22)*(v12-v22)+(v13-v23)*(v13-v23) + \
(v14-v24)*(v14-v24)+(v15-v25)*(v15-v25)+(v16-v26)*(v16-v26) + (v17-v27)*(v17-v27))
#define CD7M_d7prods_byelem(v11,v12,v13,v14,v15,v16,v17,v21,v22,v23,v24,v25,v26,v27) \
2.*(v11*v21+v12*v22+v13*v23+v14*v24+v15*v25+v16*v26+v17*v27)
#define CD7M_d71234distsq(v1,v2) \
CD7M_min3(\
CD7M_min8(\
CD7M_d7eucldistsq_byelem(v1[0],v1[1],v1[2],v1[3],v1[4],v1[5],v1[6],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[0],v1[1],v1[3],v1[2],v1[5],v1[4],v1[6],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[0],v1[2],v1[1],v1[3],v1[4],v1[6],v1[5],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[0],v1[2],v1[3],v1[1],v1[6],v1[4],v1[5],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[0],v1[3],v1[1],v1[2],v1[5],v1[6],v1[4],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[0],v1[3],v1[2],v1[1],v1[6],v1[5],v1[4],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[2],v1[0],v1[1],v1[3],v1[6],v1[4],v1[5],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[3],v1[0],v1[1],v1[2],v1[6],v1[5],v1[4],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6])),\
CD7M_min8(\
CD7M_d7eucldistsq_byelem(v1[1],v1[0],v1[2],v1[3],v1[5],v1[4],v1[6],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[1],v1[0],v1[3],v1[2],v1[4],v1[5],v1[6],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[1],v1[2],v1[0],v1[3],v1[5],v1[6],v1[4],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[1],v1[2],v1[3],v1[0],v1[6],v1[5],v1[4],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[1],v1[3],v1[0],v1[2],v1[4],v1[6],v1[5],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[1],v1[3],v1[2],v1[0],v1[6],v1[4],v1[5],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[2],v1[0],v1[3],v1[1],v1[4],v1[6],v1[5],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[2],v1[1],v1[0],v1[3],v1[6],v1[5],v1[4],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6])),\
CD7M_min8(\
CD7M_d7eucldistsq_byelem(v1[2],v1[1],v1[3],v1[0],v1[5],v1[6],v1[4],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[2],v1[3],v1[0],v1[1],v1[4],v1[5],v1[6],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[2],v1[3],v1[1],v1[0],v1[5],v1[4],v1[6],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[3],v1[0],v1[2],v1[1],v1[5],v1[6],v1[4],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[3],v1[1],v1[0],v1[2],v1[6],v1[4],v1[5],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[3],v1[1],v1[2],v1[0],v1[4],v1[6],v1[5],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[3],v1[2],v1[0],v1[1],v1[5],v1[4],v1[6],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]),\
CD7M_d7eucldistsq_byelem(v1[3],v1[2],v1[1],v1[0],v1[4],v1[5],v1[6],\
v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6])))
#define CD7M_d71234dist(v1,v2) sqrt(CD7M_d71234distsq(v1,v2))
static double d71234distsq(double v1[7], double v2[7]) {
double distsq;
double dwnby;
double dtrial[24];
int i;
distsq = v1[0]*v1[0] + v1[1]*v1[1] + v1[2]*v1[2] + v1[3]*v1[3] + v1[4]*v1[4] + v1[5]*v1[5] + v1[6]*v1[6]
+ v2[0]*v2[0] + v2[1]*v2[1] + v2[2]*v2[2] + v2[3]*v2[3] + v2[4]*v2[4] + v2[5]*v2[5] + v2[6]*v2[6];
dtrial[0] = CD7M_d7prods_byelem(v1[0],v1[1],v1[2],v1[3],v1[4],v1[5],v1[6],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[1] = CD7M_d7prods_byelem(v1[0],v1[1],v1[3],v1[2],v1[5],v1[4],v1[6],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[2] = CD7M_d7prods_byelem(v1[0],v1[2],v1[1],v1[3],v1[4],v1[6],v1[5],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[3] = CD7M_d7prods_byelem(v1[0],v1[2],v1[3],v1[1],v1[6],v1[4],v1[5],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[4] = CD7M_d7prods_byelem(v1[0],v1[3],v1[1],v1[2],v1[5],v1[6],v1[4],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[5] = CD7M_d7prods_byelem(v1[0],v1[3],v1[2],v1[1],v1[6],v1[5],v1[4],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[6] = CD7M_d7prods_byelem(v1[1],v1[0],v1[2],v1[3],v1[5],v1[4],v1[6],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[7] = CD7M_d7prods_byelem(v1[1],v1[0],v1[3],v1[2],v1[4],v1[5],v1[6],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[8] = CD7M_d7prods_byelem(v1[1],v1[2],v1[0],v1[3],v1[5],v1[6],v1[4],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[9] = CD7M_d7prods_byelem(v1[1],v1[2],v1[3],v1[0],v1[6],v1[5],v1[4],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[10] = CD7M_d7prods_byelem(v1[1],v1[3],v1[0],v1[2],v1[4],v1[6],v1[5],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[11] = CD7M_d7prods_byelem(v1[1],v1[3],v1[2],v1[0],v1[6],v1[4],v1[5],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[12] = CD7M_d7prods_byelem(v1[2],v1[0],v1[1],v1[3],v1[6],v1[4],v1[5],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[13] = CD7M_d7prods_byelem(v1[2],v1[0],v1[3],v1[1],v1[4],v1[6],v1[5],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[14] = CD7M_d7prods_byelem(v1[2],v1[1],v1[0],v1[3],v1[6],v1[5],v1[4],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[15] = CD7M_d7prods_byelem(v1[2],v1[1],v1[3],v1[0],v1[5],v1[6],v1[4],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[16] = CD7M_d7prods_byelem(v1[2],v1[3],v1[0],v1[1],v1[4],v1[5],v1[6],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[17] = CD7M_d7prods_byelem(v1[2],v1[3],v1[1],v1[0],v1[5],v1[4],v1[6],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[18] = CD7M_d7prods_byelem(v1[3],v1[0],v1[1],v1[2],v1[6],v1[5],v1[4],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[19] = CD7M_d7prods_byelem(v1[3],v1[0],v1[2],v1[1],v1[5],v1[6],v1[4],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[20] = CD7M_d7prods_byelem(v1[3],v1[1],v1[0],v1[2],v1[6],v1[4],v1[5],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[21] = CD7M_d7prods_byelem(v1[3],v1[1],v1[2],v1[0],v1[4],v1[6],v1[5],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[22] = CD7M_d7prods_byelem(v1[3],v1[2],v1[0],v1[1],v1[5],v1[4],v1[6],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dtrial[23] = CD7M_d7prods_byelem(v1[3],v1[2],v1[1],v1[0],v1[4],v1[5],v1[6],v2[0],v2[1],v2[2],v2[3],v2[4],v2[5],v2[6]);
dwnby = dtrial[0];
for (i = 1; i < 24; i++) if (dtrial[i] > dwnby) dwnby = dtrial[i];
return (fabs(distsq - dwnby));
}
#define d71234dist(v1,v2) sqrt(d71234distsq(v1,v2))
/* Compute the best distance between 2 G6 vectors
allowing for permulations of g1, g2, g3 as
well as sign changes
*/
static void d7cpyvn(int n, double src[], double dst[] ) {
int i;
for (i = 0; i < n; i++) {
dst[i] = src[i];
}
}
static void imv7 (double v1[7], int m[49], double v2[7]) {
int i, j;
double sum;
for (i = 0; i < 7; i++) {
sum = 0.0;
for(j=0; j < 7; j++) {
sum = sum + ((double)m[7*i+j])*v1[j];
}
v2[i] = sum;
}
}
static void rmv7 (double v1[7], double m[49], double v2[7]) {
int i, j;
double sum;
for (i = 0; i < 7; i++) {
sum = 0.0;
for(j=0; j < 7; j++) {
sum = sum + m[7*i+j]*v1[j];
}
v2[i] = sum;
}
}
static void d7twoPminusI(double pg[7], double g[7], double gout[7]) {
int i;
for (i=0; i<7; i++){
gout[i] = 2.*pg[i]-g[i];
}
}
/* Map a G6 vector onto the boundaries after
applying the 24-way unfolding */
#ifdef D7DIST_NO_OUTER_PASS
#define NREFL_OUTER_FULL 8
#define NREFL_OUTER_MIN 1
#define NREFL_OUTER_MID 4
#else
#define NREFL_OUTER_FULL 24
#define NREFL_OUTER_MID 16
#define NREFL_OUTER_MIN 8
#endif
static double d7bddist(double gvec[7],int bdnum) {
/* inward normals in D7 */
double D7N_1x[7]={-1./sqrt(2.),1./sqrt(2.),0.,0.,0.,0.,0.};
double D7N_2x[7]={0.,-1./sqrt(2.),1./sqrt(2.),0.,0.,0.,0.};
double D7N_3x[7]={0.,0.,-1./sqrt(2.),1./sqrt(2.),0.,0.,0.};
double D7N_4x[7]={-3/(2*sqrt(21)),2/sqrt(21),2/sqrt(21),-3/(2*sqrt(21)),
-2/sqrt(21),3/(2*sqrt(21)),3/(2*sqrt(21))};
double D7N_5x[7]={2/sqrt(21),-3/(2*sqrt(21)),-3/(2*sqrt(21)),2/sqrt(21),
-2/sqrt(21),3/(2*sqrt(21)),3/(2*sqrt(21))};
double D7N_6x[7]={2/sqrt(21),-3/(2*sqrt(21)),2/sqrt(21),-3/(2*sqrt(21)),
3/(2*sqrt(21)),-2/sqrt(21),3/(2*sqrt(21))};