Last active
November 11, 2021 10:21
-
-
Save hughrawlinson/d78f8faf459fab0341f7 to your computer and use it in GitHub Desktop.
A small operation of basic fuzzy logic functions in C++
This file contains 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
/** | |
@file fuzzylogic.c | |
@ingroup mc2liveAlg | |
hugh rawlinson - [email protected] | |
**/ | |
#include <stdio.h> | |
double fuzzyOR(double a, double b){ | |
if(a>b){ | |
return a; | |
} else{ | |
return b; | |
} | |
} | |
double fuzzyAND(double a, double b){ | |
if(a<b){ | |
return a; | |
} else{ | |
return b; | |
} | |
} | |
double fuzzyNOT(double a){ | |
return 1.0 - a; | |
} | |
double fuzzyNOR(double a, double b){ | |
return fuzzyNOT(fuzzyOR(a,b)); | |
} | |
double fuzzyNAND(double a, double b){ | |
return fuzzyNOT(fuzzyAND(a,b)); | |
} | |
double fuzzyIMPLY(double a, double b){ | |
return fuzzyOR(fuzzyNOT(a),b); | |
} | |
double fuzzyXOR(double a, double b){ | |
double or = fuzzyOR(a,b); | |
return fuzzyAND(or,fuzzyNOT(or)); | |
} | |
double fuzzyEQUIV(double a, double b){ | |
return fuzzyNOT(fuzzyXOR(a,b)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment