Last active
January 16, 2023 16:00
-
-
Save mrbid/6fdb220f81e5a719bea5b67bf8575107 to your computer and use it in GitHub Desktop.
Neural Zodiac Love Compatibility Calculator for Polyamory (for science)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // v2 an improvement over the original. | |
| // github.com/mrbid | |
| // https://github.com/jcwml/neural_zodiac | |
| // gcc main.c -lm -Ofast -mfma -o main | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <math.h> | |
| #pragma GCC diagnostic ignored "-Wunused-result" | |
| float neural_zodiac_32(const float* input) | |
| { | |
| static const float li[] = {-4.507723,1.6185118,5.406696,3.3419151,6.864112,1.192958,-4.472139,3.8331385,5.0193634,2.4675412,-4.960107,1.6547736,1.6475176,0.85160166,-3.692882,0.74432546,-3.834596,3.2222624,3.3098104,0.71474665,3.835815,0.5663031,0.86987484,0.9647043,0.73636353,-0.4236415,-0.17104249,0.46970728,-0.09297984,0.707542,-0.23398057,0.7386719,0.38972262,0.43383107,-0.50519174,0.10210323,-0.87039423,1.0280963,0.35299188,0.2297131,0.063968875,-0.29853442,0.47104555,-0.3858751,-1.98916,-0.23628978,1.837826,-0.06563526,-0.53072494,-0.27380833,3.4200385,-1.1069288,-0.68657947,-4.294544,-0.050477523,-0.5675257,-4.2672024,-0.5742668,-0.25099212,-0.68155754,-4.012095,4.573043,-1.5205894,4.9680877,-1.7400955,5.084534,-0.8630055,-0.63338727,-1.1494864,-0.6588948,-1.519102,-5.324594,-1.2635682,0.98751605,-4.3194323,1.0814636,-0.9575127,0.6660498,0.46947363,1.1445695,5.857399,1.0311654,1.0696088,0.61687726,1.0066626,3.3860269,1.6283344,3.0002766,1.149417,7.3730974,4.5134516,4.1718497,4.814187,-3.6590023,4.5825353,-4.3974166,-3.2286544,-3.6278005,-1.0769198,-1.0685697,-0.9219049,-5.3470097,-0.50578195,4.2859993,-0.33545613,-0.8035554,-3.052506,-4.7819448,0.44416666,0.5149343,0.8927208,0.6937625,0.84196264,0.7581051,0.13102831,0.16103211,3.4658778,0.15289815,0.54928786,-3.3084593,0.42306075,-1.292395,-0.4539197,-0.32622758,-0.20829946,-0.89301914,-0.5456174,0.17622285,2.057355,0.17035271,-1.4248747,-0.071819045,-3.2698274,-0.57206047,-0.6041881,-0.42077208,-0.7855738,-1.7340825,-0.5829804,0.03232123,3.4896748,-0.040642045,1.9458203,-0.21037965,-2.0965233,0.13638231,0.30611163,0.043862652,0.33611992,0.41805962,0.5203451,-0.30822006,0.22774802,-0.35445678,0.20932929,0.013758556,0.42356923,-0.10812636,-0.35798994,-0.16452304,-0.2864319,-0.24835545,-0.26623285,0.82698303,1.9113103,0.24830554,-0.21960554,0.07029801,0.6370963,-0.98909545,-0.41427854,-0.2944999,-0.094845064,1.2327389,-0.4480225,0.17377326,2.0246768,0.13518085,-2.573879,-0.028934982,0.15506034,0.643721,-3.3591511,1.1340482,-0.9654471,4.277586,-0.07897204,0.7010268,5.5960593,0.81713206,0.6544781,0.5762778,4.2657995,2.5647616,-3.6033044,0.74549854,-4.5999556,3.5671365,3.3293812,0.8129028,3.4319627,0.7034027,6.4800553,0.9539926,-0.13778007,-0.019623628,-0.32222992,0.41205546,-0.48136324,-0.3910658,0.2214213,1.242132,-0.00035144883,0.69092816,-0.14750788,2.4065716,3.8664417,1.6505355,6.745378,1.8546776,-3.701394,1.0819438,-5.673021,1.3960364,-4.353586,1.5173955,-5.2631946,1.5002682,0.34911174,1.0317239,-4.567924,1.8217009,-3.4596632,-1.5474613,3.235022,1.6795061,6.759393,1.3809434,5.900653,1.0519592,0.3663362,0.16302419,-0.35495982,1.1805578,-0.013585216,-0.18477137,0.13517362,1.3843954,0.5592254,0.48753694,-0.16440149,1.6276072,-4.9334755,4.6517377,-2.1029892,-4.8015084,-3.336236,5.073896,-4.3524795,-7.73942,-3.7621052,-6.213146,-1.5619594,-4.93599,0.7002275,-0.4382921,-0.3331965,-0.08440189,-0.14078934,-0.6038613,-0.22932544,0.33449876,-0.25918075,0.28635696,-0.48073813,1.5916057,3.0787294,-4.6940093,0.5115356,0.34780735,0.38755885,-1.2638191,-0.052113246,0.052221637,-0.13534263,0.2102441,1.8413626,4.76695,0.2598331,-0.36327344,0.43969166,-1.1021829,0.343803,0.28564423,-0.3606882,-1.4251078,-0.2106711,-0.5739357,0.15560131,-2.4667432,-0.4441657,-0.974945,-1.8053024,-1.4003435,-3.7416751,1.2584491,-1.8118335,-1.3753731,3.5170853,-1.4201564,3.8607259,-4.006755,2.5781844,7.608785,2.3711548,7.110728,3.7103434,5.5715322,3.8642588,-4.1380424,1.2084917,-5.4034233,4.253376,4.559322,3.5344217,6.003099,2.5200572,6.180096,3.976243,6.9161844,3.5014014,-4.216906,1.3740348,-3.8348806,4.1623054,5.74849,-1.8912716,-5.9277277,-2.2329867,-5.017604,-2.311792,-2.969572,-2.2847185,4.940055,-1.6127554,3.965622,-3.1518667,-1.7582604,-0.7202449,0.08421025,0.28900167,0.11949617,0.14591394,0.288655,0.24215503,-0.7884457,-2.1957242,-0.26740733,0.20066693,-0.82339907,0.73453355,5.626112,1.0708033,-4.970974,1.1539319,5.701341,0.71048945,5.316463,1.7134157,5.8640184,4.9719334,-4.8228745,1.764759,-1.5479224,5.252739,-1.3210251,-4.1603274,-1.0021814,4.052444,-1.1077213,-5.8245306,-0.76964617,4.7668085,-0.96404684}; | |
| static const float lo[] = {9.627905,4.016688,-1.2825035,2.2889626,-3.399045,-10.8243475,3.8909402,8.375237,-3.1748455,3.4259613,-2.657309,-4.5433097,1.6306624,-2.3822577,-2.1895373,3.3645976,6.53664,-3.410491,11.519642,6.798699,-2.999775,-12.881387,-1.3379551,6.2442737,3.6879756,-5.860327,6.2801347,6.794637,-3.597708,3.134706,13.374014,-8.972237}; | |
| float o1[32] = {0}; | |
| for(int i = 0; i < 32; i++) | |
| { | |
| const int io = i*12; | |
| for(int j = 0; j < 12; j++) | |
| o1[i] += input[j] * li[io+j]; | |
| o1[i] = tanhf(o1[i]); | |
| } | |
| float o2 = 0.f; | |
| for(int i = 0; i < 32; i++) | |
| o2 += o1[i] * lo[i]; | |
| return o2; | |
| } | |
| int main(int argc, char *argv[]) | |
| { | |
| // dump to stdout | |
| if(argc == 13) | |
| { | |
| float input_vector[12]; | |
| for(int i = 0; i < 12; i++) | |
| input_vector[i] = atof(argv[i+1]); | |
| printf("%f", neural_zodiac_32(&input_vector[0])); | |
| return 0; | |
| } | |
| // PZLCC | |
| printf("Welcome to the Zodiac Love Compatibility Calculator v2.\n\nIn the relationship please tell me how many of each zodiac will be present.\n\n"); | |
| float input_vector[12] = {0}; | |
| char istr[8]; | |
| printf("How many Aries: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[0] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Taurus: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[1] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Gemini: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[2] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Cancer: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[3] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Leo: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[4] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Virgo: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[5] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Libera: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[6] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Scorpio: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[7] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Sagittarius: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[8] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Capricorn: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[9] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Aquarius: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[10] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("How many Pisces: "); | |
| fgets(istr, sizeof(istr), stdin); | |
| input_vector[11] = atof(istr); | |
| memset(&istr, 0, sizeof(istr)); | |
| printf("\nInput Vector: "); | |
| for(int i = 0; i < 12; i++) | |
| printf("%.0f", input_vector[i]); | |
| printf("\n\nCompatibility: %.2f%%\n\n", neural_zodiac_32(&input_vector[0])); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment