Add FuzzyImplicationCapable protocol
This commit is contained in:
parent
522530f69a
commit
84ac87abe5
|
@ -36,24 +36,28 @@ public enum ImplicationMethod {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension AnyFuzzySet {
|
public protocol FuzzyImplicationCapable: FuzzySet {
|
||||||
func implication(_ other: Self, method: ImplicationMethod = .mamdani) -> Self {
|
func implication(_ other: Self, method: ImplicationMethod) -> Self
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AnyFuzzySet: FuzzyImplicationCapable {
|
||||||
|
public func implication(_ other: Self, method: ImplicationMethod = .mamdani) -> Self {
|
||||||
.init {
|
.init {
|
||||||
method.function(self[$0], other[$0])
|
method.function(self[$0], other[$0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension IterableFuzzySet {
|
extension IterableFuzzySet: FuzzyImplicationCapable {
|
||||||
func implication(_ other: Self, method: ImplicationMethod = .mamdani) -> Self {
|
public func implication(_ other: Self, method: ImplicationMethod = .mamdani) -> Self {
|
||||||
.init(sequence) {
|
.init(sequence) {
|
||||||
method.function(self[$0], other[$0])
|
method.function(self[$0], other[$0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension DiscreteMutableFuzzySet {
|
extension DiscreteMutableFuzzySet: FuzzyImplicationCapable {
|
||||||
func implication(_ other: Self, method: ImplicationMethod = .mamdani) -> Self {
|
public func implication(_ other: Self, method: ImplicationMethod = .mamdani) -> Self {
|
||||||
var result = self
|
var result = self
|
||||||
result.formImplication(other, method: method)
|
result.formImplication(other, method: method)
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in New Issue