mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-04 13:45:33 +00:00
- inlined builtin_funcs methods, removed builtin_funcs.cpp
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@159 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
PROJECT(projectM)
|
||||
ADD_LIBRARY(projectM SHARED projectM.cpp projectM.h pbuffer.cpp pbuffer.h InitCond.cpp InitCond.h console_interface.cpp Expr.cpp PCM.cpp Parser.cpp Preset.cpp common.h BeatDetect.cpp PCM.h PerPixelEqn.cpp Eval.h SplayTree.cpp Param.cpp CustomWave.cpp CustomShape.h CustomShape.cpp Param.h CustomWave.h BeatDetect.h Preset.h menu.cpp console_interface.h Func.h Func.cpp Eval.cpp wipemalloc.h browser.cpp builtin_funcs.cpp PerFrameEqn.cpp PerPointEqn.cpp editor.cpp fftsg.cpp glConsole.cpp CValue.h Expr.h timer.cpp wipemalloc.cpp PerFrameEqn.h PerPixelEqn.h PerPointEqn.h browser.h builtin_funcs.h compare.h editor.h event.h fatal.h SplayTree.h fftsg.h glConsole.h menu.h timer.h SplayNode.cpp SplayNode.h)
|
||||
ADD_LIBRARY(projectM SHARED projectM.cpp projectM.h pbuffer.cpp pbuffer.h InitCond.cpp InitCond.h console_interface.cpp Expr.cpp PCM.cpp Parser.cpp Preset.cpp common.h BeatDetect.cpp PCM.h PerPixelEqn.cpp Eval.h SplayTree.cpp Param.cpp CustomWave.cpp CustomShape.h CustomShape.cpp Param.h CustomWave.h BeatDetect.h Preset.h menu.cpp console_interface.h Func.h Func.cpp Eval.cpp wipemalloc.h browser.cpp PerFrameEqn.cpp PerPointEqn.cpp editor.cpp fftsg.cpp glConsole.cpp CValue.h Expr.h timer.cpp wipemalloc.cpp PerFrameEqn.h PerPixelEqn.h PerPointEqn.h browser.h builtin_funcs.h compare.h editor.h event.h fatal.h SplayTree.h fftsg.h glConsole.h menu.h timer.h SplayNode.cpp SplayNode.h)
|
||||
|
||||
ADD_DEFINITIONS(-DLINUX -DUSE_FTGL -DFBO)
|
||||
FIND_PACKAGE(OpenGL)
|
||||
|
||||
@ -1,205 +0,0 @@
|
||||
/**
|
||||
* projectM -- Milkdrop-esque visualisation SDK
|
||||
* Copyright (C)2003-2004 projectM Team
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* See 'LICENSE.txt' included within this release
|
||||
*
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "projectM.h"
|
||||
|
||||
/* Values to optimize the sigmoid function */
|
||||
#define R 32767
|
||||
#define RR 65534
|
||||
|
||||
float int_wrapper(float * arg_list) {
|
||||
|
||||
return floor(arg_list[0]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
float sqr_wrapper(float * arg_list) {
|
||||
|
||||
return pow(2, arg_list[0]);
|
||||
}
|
||||
|
||||
|
||||
float sign_wrapper(float * arg_list) {
|
||||
|
||||
return -arg_list[0];
|
||||
}
|
||||
|
||||
float min_wrapper(float * arg_list) {
|
||||
|
||||
if (arg_list[0] > arg_list[1])
|
||||
return arg_list[1];
|
||||
|
||||
return arg_list[0];
|
||||
}
|
||||
|
||||
float max_wrapper(float * arg_list) {
|
||||
|
||||
if (arg_list[0] > arg_list[1])
|
||||
return arg_list[0];
|
||||
|
||||
return arg_list[1];
|
||||
}
|
||||
|
||||
/* consult your AI book */
|
||||
float sigmoid_wrapper(float * arg_list) {
|
||||
return (RR / (1 + exp( -(((float)(arg_list[0])) * arg_list[1]) / R) - R));
|
||||
}
|
||||
|
||||
|
||||
float bor_wrapper(float * arg_list) {
|
||||
|
||||
return (float)((int)arg_list[0] || (int)arg_list[1]);
|
||||
}
|
||||
|
||||
float band_wrapper(float * arg_list) {
|
||||
return (float)((int)arg_list[0] && (int)arg_list[1]);
|
||||
}
|
||||
|
||||
float bnot_wrapper(float * arg_list) {
|
||||
return (float)(!(int)arg_list[0]);
|
||||
}
|
||||
|
||||
float if_wrapper(float * arg_list) {
|
||||
|
||||
if ((int)arg_list[0] == 0)
|
||||
return arg_list[2];
|
||||
return arg_list[1];
|
||||
}
|
||||
|
||||
|
||||
float rand_wrapper(float * arg_list) {
|
||||
float l=1;
|
||||
|
||||
// printf("RAND ARG:(%d)\n", (int)arg_list[0]);
|
||||
if ((int)arg_list[0] > 0)
|
||||
l = (float)((rand()) % ((int)arg_list[0]));
|
||||
//printf("VAL: %f\n", l);
|
||||
return l;
|
||||
}
|
||||
|
||||
float equal_wrapper(float * arg_list) {
|
||||
|
||||
return (arg_list[0] == arg_list[1]);
|
||||
}
|
||||
|
||||
|
||||
float above_wrapper(float * arg_list) {
|
||||
|
||||
return (arg_list[0] > arg_list[1]);
|
||||
}
|
||||
|
||||
|
||||
float below_wrapper(float * arg_list) {
|
||||
|
||||
return (arg_list[0] < arg_list[1]);
|
||||
}
|
||||
|
||||
float sin_wrapper(float * arg_list) {
|
||||
return (sin (arg_list[0]));
|
||||
}
|
||||
|
||||
|
||||
float cos_wrapper(float * arg_list) {
|
||||
return (cos (arg_list[0]));
|
||||
}
|
||||
|
||||
float tan_wrapper(float * arg_list) {
|
||||
return (tan(arg_list[0]));
|
||||
}
|
||||
|
||||
float asin_wrapper(float * arg_list) {
|
||||
return (asin (arg_list[0]));
|
||||
}
|
||||
|
||||
float acos_wrapper(float * arg_list) {
|
||||
return (acos (arg_list[0]));
|
||||
}
|
||||
|
||||
float atan_wrapper(float * arg_list) {
|
||||
return (atan (arg_list[0]));
|
||||
}
|
||||
|
||||
float atan2_wrapper(float * arg_list) {
|
||||
return (atan2 (arg_list[0], arg_list[1]));
|
||||
}
|
||||
|
||||
float pow_wrapper(float * arg_list) {
|
||||
return (pow (arg_list[0], arg_list[1]));
|
||||
}
|
||||
|
||||
float exp_wrapper(float * arg_list) {
|
||||
return (exp(arg_list[0]));
|
||||
}
|
||||
|
||||
float abs_wrapper(float * arg_list) {
|
||||
return (fabs(arg_list[0]));
|
||||
}
|
||||
|
||||
float log_wrapper(float* arg_list) {
|
||||
return (log (arg_list[0]));
|
||||
}
|
||||
|
||||
float log10_wrapper(float * arg_list) {
|
||||
return (log10 (arg_list[0]));
|
||||
}
|
||||
|
||||
float sqrt_wrapper(float * arg_list) {
|
||||
return (sqrt (arg_list[0]));
|
||||
}
|
||||
|
||||
|
||||
float nchoosek_wrapper(float * arg_list) {
|
||||
unsigned long cnm = 1UL;
|
||||
int i, f;
|
||||
int n, m;
|
||||
|
||||
n = (int)arg_list[0];
|
||||
m = (int)arg_list[1];
|
||||
|
||||
if (m*2 >n) m = n-m;
|
||||
for (i=1 ; i <= m; n--, i++)
|
||||
{
|
||||
if ((f=n) % i == 0)
|
||||
f /= i;
|
||||
else cnm /= i;
|
||||
cnm *= f;
|
||||
}
|
||||
return (float)cnm;
|
||||
}
|
||||
|
||||
|
||||
float fact_wrapper(float * arg_list) {
|
||||
|
||||
|
||||
int result = 1;
|
||||
|
||||
int n = (int)arg_list[0];
|
||||
|
||||
while (n > 1) {
|
||||
result = result * n;
|
||||
n--;
|
||||
}
|
||||
return (float)result;
|
||||
}
|
||||
@ -24,7 +24,7 @@
|
||||
* $Log$
|
||||
*/
|
||||
|
||||
/* Wrappers for all the builtin functions
|
||||
/* Wrappers for all the builtin functions
|
||||
The arg_list pointer is a list of floats. Its
|
||||
size is equal to the number of arguments the parameter
|
||||
takes */
|
||||
@ -33,36 +33,187 @@
|
||||
#define _BUILTIN_FUNCS_H
|
||||
|
||||
#include "projectM.h"
|
||||
|
||||
inline float below_wrapper(float * arg_list);
|
||||
inline float above_wrapper(float * arg_list);
|
||||
inline float equal_wrapper(float * arg_list);
|
||||
inline float if_wrapper(float * arg_list);
|
||||
inline float bnot_wrapper(float * arg_list);
|
||||
inline float rand_wrapper(float * arg_list);
|
||||
inline float bor_wrapper(float * arg_list);
|
||||
inline float band_wrapper(float * arg_list);
|
||||
inline float sigmoid_wrapper(float * arg_list);
|
||||
inline float max_wrapper(float * arg_list);
|
||||
inline float min_wrapper(float * arg_list);
|
||||
inline float sign_wrapper(float * arg_list);
|
||||
inline float sqr_wrapper(float * arg_list);
|
||||
inline float int_wrapper(float * arg_list);
|
||||
inline float nchoosek_wrapper(float * arg_list);
|
||||
inline float sin_wrapper(float * arg_list);
|
||||
inline float cos_wrapper(float * arg_list);
|
||||
inline float tan_wrapper(float * arg_list);
|
||||
inline float fact_wrapper(float * arg_list);
|
||||
inline float asin_wrapper(float * arg_list);
|
||||
inline float acos_wrapper(float * arg_list);
|
||||
inline float atan_wrapper(float * arg_list);
|
||||
inline float atan2_wrapper(float * arg_list);
|
||||
|
||||
inline float pow_wrapper(float * arg_list);
|
||||
inline float exp_wrapper(float * arg_list);
|
||||
inline float abs_wrapper(float * arg_list);
|
||||
inline float log_wrapper(float *arg_list);
|
||||
inline float log10_wrapper(float * arg_list);
|
||||
inline float sqrt_wrapper(float * arg_list);
|
||||
|
||||
/* Values to optimize the sigmoid function */
|
||||
#define R 32767
|
||||
#define RR 65534
|
||||
|
||||
|
||||
|
||||
inline float int_wrapper(float * arg_list) {
|
||||
|
||||
return floor(arg_list[0]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline float sqr_wrapper(float * arg_list) {
|
||||
|
||||
return pow(2, arg_list[0]);
|
||||
}
|
||||
|
||||
|
||||
inline float sign_wrapper(float * arg_list) {
|
||||
|
||||
return -arg_list[0];
|
||||
}
|
||||
|
||||
inline float min_wrapper(float * arg_list) {
|
||||
|
||||
if (arg_list[0] > arg_list[1])
|
||||
return arg_list[1];
|
||||
|
||||
return arg_list[0];
|
||||
}
|
||||
|
||||
inline float max_wrapper(float * arg_list) {
|
||||
|
||||
if (arg_list[0] > arg_list[1])
|
||||
return arg_list[0];
|
||||
|
||||
return arg_list[1];
|
||||
}
|
||||
|
||||
/* consult your AI book */
|
||||
inline float sigmoid_wrapper(float * arg_list) {
|
||||
return (RR / (1 + exp( -(((float)(arg_list[0])) * arg_list[1]) / R) - R));
|
||||
}
|
||||
|
||||
|
||||
inline float bor_wrapper(float * arg_list) {
|
||||
|
||||
return (float)((int)arg_list[0] || (int)arg_list[1]);
|
||||
}
|
||||
|
||||
inline float band_wrapper(float * arg_list) {
|
||||
return (float)((int)arg_list[0] && (int)arg_list[1]);
|
||||
}
|
||||
|
||||
inline float bnot_wrapper(float * arg_list) {
|
||||
return (float)(!(int)arg_list[0]);
|
||||
}
|
||||
|
||||
inline float if_wrapper(float * arg_list) {
|
||||
|
||||
if ((int)arg_list[0] == 0)
|
||||
return arg_list[2];
|
||||
return arg_list[1];
|
||||
}
|
||||
|
||||
|
||||
inline float rand_wrapper(float * arg_list) {
|
||||
float l=1;
|
||||
|
||||
// printf("RAND ARG:(%d)\n", (int)arg_list[0]);
|
||||
if ((int)arg_list[0] > 0)
|
||||
l = (float)((rand()) % ((int)arg_list[0]));
|
||||
//printf("VAL: %f\n", l);
|
||||
return l;
|
||||
}
|
||||
|
||||
inline float equal_wrapper(float * arg_list) {
|
||||
return (arg_list[0] == arg_list[1]);
|
||||
}
|
||||
|
||||
|
||||
inline float above_wrapper(float * arg_list) {
|
||||
|
||||
return (arg_list[0] > arg_list[1]);
|
||||
}
|
||||
|
||||
|
||||
inline float below_wrapper(float * arg_list) {
|
||||
|
||||
return (arg_list[0] < arg_list[1]);
|
||||
}
|
||||
|
||||
inline float sin_wrapper(float * arg_list) {
|
||||
return (sin (arg_list[0]));
|
||||
}
|
||||
|
||||
|
||||
inline float cos_wrapper(float * arg_list) {
|
||||
return (cos (arg_list[0]));
|
||||
}
|
||||
|
||||
inline float tan_wrapper(float * arg_list) {
|
||||
return (tan(arg_list[0]));
|
||||
}
|
||||
|
||||
inline float asin_wrapper(float * arg_list) {
|
||||
return (asin (arg_list[0]));
|
||||
}
|
||||
|
||||
inline float acos_wrapper(float * arg_list) {
|
||||
return (acos (arg_list[0]));
|
||||
}
|
||||
|
||||
inline float atan_wrapper(float * arg_list) {
|
||||
return (atan (arg_list[0]));
|
||||
}
|
||||
|
||||
inline float atan2_wrapper(float * arg_list) {
|
||||
return (atan2 (arg_list[0], arg_list[1]));
|
||||
}
|
||||
|
||||
inline float pow_wrapper(float * arg_list) {
|
||||
return (pow (arg_list[0], arg_list[1]));
|
||||
}
|
||||
|
||||
inline float exp_wrapper(float * arg_list) {
|
||||
return (exp(arg_list[0]));
|
||||
}
|
||||
|
||||
inline float abs_wrapper(float * arg_list) {
|
||||
return (fabs(arg_list[0]));
|
||||
}
|
||||
|
||||
inline float log_wrapper(float* arg_list) {
|
||||
return (log (arg_list[0]));
|
||||
}
|
||||
|
||||
inline float log10_wrapper(float * arg_list) {
|
||||
return (log10 (arg_list[0]));
|
||||
}
|
||||
|
||||
inline float sqrt_wrapper(float * arg_list) {
|
||||
return (sqrt (arg_list[0]));
|
||||
}
|
||||
|
||||
|
||||
inline float nchoosek_wrapper(float * arg_list) {
|
||||
unsigned long cnm = 1UL;
|
||||
int i, f;
|
||||
int n, m;
|
||||
|
||||
n = (int)arg_list[0];
|
||||
m = (int)arg_list[1];
|
||||
|
||||
if (m*2 >n) m = n-m;
|
||||
for (i=1 ; i <= m; n--, i++)
|
||||
{
|
||||
if ((f=n) % i == 0)
|
||||
f /= i;
|
||||
else cnm /= i;
|
||||
cnm *= f;
|
||||
}
|
||||
return (float)cnm;
|
||||
}
|
||||
|
||||
|
||||
inline float fact_wrapper(float * arg_list) {
|
||||
|
||||
|
||||
int result = 1;
|
||||
|
||||
int n = (int)arg_list[0];
|
||||
|
||||
while (n > 1) {
|
||||
result = result * n;
|
||||
n--;
|
||||
}
|
||||
return (float)result;
|
||||
}
|
||||
|
||||
#endif /** !_BUILTIN_FUNCS_H */
|
||||
|
||||
Reference in New Issue
Block a user