1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@videolan.org>
8 * code from projectM http://xmms-projectm.sourceforge.net
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
27 /* Values to optimize the sigmoid function */
31 inline double int_wrapper(double * arg_list) {
33 return floor(arg_list[0]);
38 inline double sqr_wrapper(double * arg_list) {
40 return pow(2, arg_list[0]);
44 inline double sign_wrapper(double * arg_list) {
49 inline double min_wrapper(double * arg_list) {
51 if (arg_list[0] > arg_list[1])
57 inline double max_wrapper(double * arg_list) {
59 if (arg_list[0] > arg_list[1])
65 /* consult your AI book */
66 inline double sigmoid_wrapper(double * arg_list) {
67 return (RR / (1 + exp( -(((double)(arg_list[0])) * arg_list[1]) / R) - R));
71 inline double bor_wrapper(double * arg_list) {
73 return (double)((int)arg_list[0] || (int)arg_list[1]);
76 inline double band_wrapper(double * arg_list) {
77 return (double)((int)arg_list[0] && (int)arg_list[1]);
80 inline double bnot_wrapper(double * arg_list) {
81 return (double)(!(int)arg_list[0]);
84 inline double if_wrapper(double * arg_list) {
86 if ((int)arg_list[0] == 0)
92 inline double rand_wrapper(double * arg_list) {
95 // printf("RAND ARG:(%d)\n", (int)arg_list[0]);
96 l = (double)((rand()) % ((int)arg_list[0]));
97 //printf("VAL: %f\n", l);
101 inline double equal_wrapper(double * arg_list) {
103 return (arg_list[0] == arg_list[1]);
107 inline double above_wrapper(double * arg_list) {
109 return (arg_list[0] > arg_list[1]);
113 inline double below_wrapper(double * arg_list) {
115 return (arg_list[0] < arg_list[1]);
118 inline double sin_wrapper(double * arg_list) {
119 return (sin (arg_list[0]));
123 inline double cos_wrapper(double * arg_list) {
124 return (cos (arg_list[0]));
127 inline double tan_wrapper(double * arg_list) {
128 return (tan(arg_list[0]));
131 inline double asin_wrapper(double * arg_list) {
132 return (asin (arg_list[0]));
135 inline double acos_wrapper(double * arg_list) {
136 return (acos (arg_list[0]));
139 inline double atan_wrapper(double * arg_list) {
140 return (atan (arg_list[0]));
143 inline double atan2_wrapper(double * arg_list) {
144 return (atan2 (arg_list[0], arg_list[1]));
147 inline double pow_wrapper(double * arg_list) {
148 return (pow (arg_list[0], arg_list[1]));
151 inline double exp_wrapper(double * arg_list) {
152 return (exp(arg_list[0]));
155 inline double abs_wrapper(double * arg_list) {
156 return (fabs(arg_list[0]));
159 inline double log_wrapper(double *arg_list) {
160 return (log (arg_list[0]));
163 inline double log10_wrapper(double * arg_list) {
164 return (log10 (arg_list[0]));
167 inline double sqrt_wrapper(double * arg_list) {
168 return (sqrt (arg_list[0]));
172 inline double nchoosek_wrapper(double * arg_list) {
173 unsigned long cnm = 1UL;
177 n = (int)arg_list[0];
178 m = (int)arg_list[1];
181 for (i=1 ; i <= m; n--, i++)
192 inline double fact_wrapper(double * arg_list) {
197 int n = (int)arg_list[0];
203 return (double)result;