-
Notifications
You must be signed in to change notification settings - Fork 24
/
datapoints-watkins.c
153 lines (117 loc) · 3.77 KB
/
datapoints-watkins.c
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
/* Original Author: Peter Meyer
Conversion to C of Matthew Watkins' Maple code for
his formula for the 384 TWZ data points.
Last mod.: 1996-05-27
*/
// Ported to Linux
// 18 Jan 2016
// John A Phelps
// kl4yfd@gmail.com
// Fixed compilation warnings and indentations
// 28 Dec 2019
// John A Phelps
// kl4yfd@gmail.com
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
09 Dec 2012
*/
#include <stdio.h>
#include <stdlib.h>
int h[64], w[400];
void main(void);
void initialize_h(void);
int mod_64(int i);
int exp_minus_one(int i);
void print_data_points(void);
/*-------------------*/
// This is the KING WEN sequence without the half-twist
void initialize_h(void)
{
/* The "first order of differences"
i.e. the number of lines which change
from one hexagram to the next. */
h[1] = 6; h[2] = 2; h[3] = 4; h[4] = 4; h[5] = 4; h[6] = 3;
h[7] = 2; h[8] = 4; h[9] = 2; h[10] = 4; h[11] = 6; h[12] = 2;
h[13] = 2; h[14] = 4; h[15] = 2; h[16] = 2; h[17] = 6; h[18] = 3;
h[19] = 4; h[20] = 3; h[21] = 2; h[22] = 2; h[23] = 2; h[24] = 3;
h[25] = 4; h[26] = 2; h[27] = 6; h[28] = 2; h[29] = 6; h[30] = 3;
h[31] = 2; h[32] = 3; h[33] = 4; h[34] = 4; h[35] = 4; h[36] = 2;
h[37] = 4; h[38] = 6; h[39] = 4; h[40] = 3; h[41] = 2; h[42] = 4;
h[43] = 2; h[44] = 3; h[45] = 4; h[46] = 3; h[47] = 2; h[48] = 3;
h[49] = 4; h[50] = 4; h[51] = 4; h[52] = 1; h[53] = 6; h[54] = 2;
h[55] = 2; h[56] = 3; h[57] = 4; h[58] = 3; h[59] = 2; h[60] = 1;
h[61] = 6; h[62] = 3; h[63] = 6; h[64] = h[0] = 3;
}
/*-----------*/
void main(void)
{
int k, a, b;
initialize_h();
for ( k=0; k<=383; k++ ) {
a = (exp_minus_one((k-1)/32))
* ( h[mod_64(k-1)] - h[mod_64(k-2)]
+ h[mod_64(-k)] - h[mod_64(1-k)] )
+ 3 * ( (exp_minus_one((k-3)/96))
* ( h[mod_64((k/3)-1)]
- h[mod_64((k/3)-2)]
+ h[mod_64(-1*(k/3))]
- h[mod_64(1-(k/3))] ) )
+ 6 * ( (exp_minus_one((k-6)/192))
* ( h[mod_64((k/6)-1)]
- h[mod_64((k/6)-2)]
+ h[mod_64(-1*(k/6))]
- h[mod_64(1-(k/6))] ) );
b = ( 9 - h[mod_64(-k)] - h[mod_64(k-1)] )
+ 3 * ( 9 - h[mod_64(-1*(k/3))] - h[mod_64((k/3)-1)] ),
+ 6 * ( 9 - h[mod_64(-1*(k/6))] - h[mod_64((k/6)-1)] );
w[k] = abs(a) + abs(b);
}
print_data_points();
}
/*-------------*/
int mod_64(int i)
{
while ( i < 0 )
i += 64;
return ( i%64 );
}
/*--------------------*/
int exp_minus_one(int i)
{
if ( i < 0 )
i *= -1;
return ( i%2 ? -1 : 1 );
}
/*------------------------*/
void print_data_points(void)
{
int j, k=18;
printf("\n%*s",k,"");
for ( j=0; j<384; j++ ) {
printf("%3d",w[j]);
if ( j < 383 )
printf(",");
if ( !((j+1)%10) )
printf("\n%*s",k,"");
}
printf("\n");
}