AI-FuzzyInference
view release on metacpan or search on metacpan
FuzzyInference/Set.pm view on Meta::CPAN
push @newCoords => @coords2 if @coords2;
return @newCoords;
}
sub complement {
my ($self, $name) = @_;
my @coords = $self->coords($name);
my $i = 0;
return map {++$i % 2 ? $_ : 1 - $_} @coords;
}
sub coords {
my ($self,
$name,
) = @_;
return undef unless $self->exists($name);
return @{$self->{TS}{$name}};
}
sub scale { # product implication
my ($self,
$name,
$scale,
) = @_;
my $i = 0;
my @c = map { $_ * ++$i % 2 ? 1 : $scale } $self->coords($name);
return @c;
}
sub clip { # min implication
my ($self,
$name,
$val,
) = @_;
my $i = 0;
my @c = map {
++$i % 2 ? $_ : $_ > $val ? $val : $_
}$self->coords($name);
return @c;
}
# had to roll my own centroid algorithm.
# not sure why standard algorithms didn't work
# correctly!
sub centroid { # center of mass.
( run in 0.300 second using v1.01-cache-2.11-cpan-49f99fa48dc )