Created
May 11, 2021 08:33
-
-
Save felipealfonsog/382eb406a23bbee6d81f7c45ecb8dbaa 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
/** A small operation of basic fuzzy logic functions in C++ **/ | |
/** | |
@file fuzzylogic.c | |
@ingroup mc2liveAlg | |
co-developer : Felipe A. Gonzalez [email protected] | |
collaboration - 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