Created
October 12, 2018 05:30
-
-
Save Saren-Arterius/8d0e6b49127585d16251e9eeb1df7612 to your computer and use it in GitHub Desktop.
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
# https://sourceforge.net/p/octave/fuzzy-logic-toolkit/ci/00e05af94b3762d2e051ad28fb436da089160f40/tree/inst/defuzz.m?diff=77eb4af15ee2e6deeb30c94eacb8bd2a782d019d | |
--- a/inst/defuzz.m | |
+++ b/inst/defuzz.m | |
@@ -1,4 +1,4 @@ | |
-## Copyright (C) 2011-2014 L. Markowsky <lmarkov@users.sourceforge.net> | |
+## Copyright (C) 2011-2018 L. Markowsky <lmarkov@users.sourceforge.net> | |
## | |
## This file is part of the fuzzy-logic-toolkit. | |
## | |
@@ -162,7 +162,16 @@ | |
function crisp_x = mom (x, y) | |
max_y = max (y); | |
- y_val = @(y_val) if (y_val == max_y) 1 else 0 endif; | |
+ | |
+ function y_val = calc_yval(y_val) | |
+ if (y_val == max_y) | |
+ y_val = 1; | |
+ else | |
+ y_val = 0; | |
+ endif | |
+ endfunction | |
+ | |
+ y_val = @(y_val) calc_yval(y_val); | |
max_y_locations = arrayfun (y_val, y); | |
crisp_x = sum (x .* max_y_locations) / sum (max_y_locations); | |
@@ -185,7 +194,16 @@ | |
function crisp_x = som (x, y) | |
max_y = max (y); | |
- y_val = @(y_val) if (y_val == max_y) 1 else (NaN) endif; | |
+ | |
+ function y_val = calc_yval(y_val) | |
+ if (y_val == max_y) | |
+ y_val = 1; | |
+ else | |
+ y_val = (NaN); | |
+ endif | |
+ endfunction | |
+ | |
+ y_val = @(y_val) calc_yval(y_val); | |
max_y_locations = arrayfun (y_val, y); | |
crisp_x = min (x .* max_y_locations); | |
@@ -207,7 +225,16 @@ | |
function crisp_x = lom (x, y) | |
max_y = max (y); | |
- y_val = @(y_val) if (y_val == max_y) 1 else (NaN) endif; | |
+ | |
+ function y_val = calc_yval(y_val) | |
+ if (y_val == max_y) | |
+ y_val = 1; | |
+ else | |
+ y_val = (NaN); | |
+ endif | |
+ endfunction | |
+ | |
+ y_val = @(y_val) calc_yval(y_val); | |
max_y_locations = arrayfun (y_val, y); | |
crisp_x = max (x .* max_y_locations); | |
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
# | |
# Maintainer: Clemens Buchacher <drizzd@aon.at> | |
# Contributor: wangjiezhe <wangjiezhe AT yandex DOT com> | |
# | |
# You can use the newpkg script from | |
# https://github.com/drizzd/octave-forge-archlinux to automatically generate | |
# new octave-forge PKGBUILDs or update existing ones. Patches welcome. | |
# | |
_pack=fuzzy-logic-toolkit | |
pkgname=octave-$_pack | |
pkgver=0.4.5 | |
pkgrel=3 | |
pkgdesc="A mostly MATLAB-compatible fuzzy logic toolkit for Octave." | |
arch=(any) | |
url="http://octave.sourceforge.net/$_pack/" | |
license=('GPL3') | |
groups=('octave-forge') | |
depends=('octave>=3.2.4') | |
makedepends=() | |
optdepends=() | |
backup=() | |
options=() | |
install=$pkgname.install | |
_archive=$_pack-$pkgver.tar.gz | |
source=("http://downloads.sourceforge.net/octave/$_archive") | |
noextract=("$_archive") | |
md5sums=('9f9e88a7d7c4dd2e3ba6958982af75aa') | |
_octave_run() { | |
octave --no-history --no-init-file --no-window-system -q -f --eval "$*" | |
} | |
_install_dir() { | |
src=$1 | |
dst=$2 | |
mkdir -p "$(dirname "$dst")" | |
cp -rT "$src" "$dst" | |
} | |
prepare() { | |
tar -xf $_archive | |
cd fuzzy-logic-toolkit | |
patch -Np1 -i ../../build.patch | |
cd .. | |
rm $_archive | |
echo tar -acf $_archive fuzzy-logic-toolkit | |
tar -acf $_archive fuzzy-logic-toolkit | |
} | |
build() { | |
_prefix="$srcdir"/install_prefix | |
_archprefix="$srcdir"/install_archprefix | |
mkdir -p "$_prefix" "$_archprefix" | |
cd "$srcdir" | |
_octave_run "$(cat <<-EOF | |
pkg local_list octave_packages; | |
pkg prefix $_prefix $_archprefix; | |
pkg install -verbose -nodeps $_archive; | |
EOF | |
)" | |
} | |
package() { | |
prefix=$pkgdir/usr/share/octave/packages | |
archprefix=$pkgdir/usr/lib/octave/packages | |
_install_dir "$srcdir"/install_prefix "$prefix" | |
_install_dir "$srcdir"/install_archprefix "$archprefix" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment