Commit f1a96504 authored by Randall Morgan's avatar Randall Morgan

[GB.GSL] * NEW: Initial commit of working code. Currently

  only basic math functions.

git-svn-id: svn://localhost/gambas/trunk@4431 867c0c6c-44f3-4631-809d-bfa615b0a4ec
parent 14aed2a6
This diff is collapsed.
ACLOCAL_AMFLAGS = -I m4 --install
SUBDIRS = @__UNAME##_DIR@
SUBDIRS = @GSL_DIR@
EXTRA_DIST = reconf gambas.h gb*.h
####################################################
# Gambas GSL Project #
####################################################
This project aims to port the functionality of the
GNU Scientific library (GSL) to Gambas Basic.
Please see the README file for more information.
################################################################
# #
# Gambas GSL Component #
# #
################################################################
Author: Randall Morgan <rmorgan62@gmail.com>
Author: Jeurgen ??? <???>
The gb.gsl component provides high level mathatics functions to
Gambas3. It replies on the GNU Scientific Library (GSL) to provide
it's underlying functionality. This component simply wraps the GSL
in a Gambas API wrapper.
Not all GSL functions are implemented. It made little sense to
implement GSL functions that support data types that Gambas does
not support.
This component is exerimental and still in the development stage.
The code and component is highly volitile at this stage of development.
Use it at your own risk!
../component.am
\ No newline at end of file
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Architecture */
#define ARCHITECTURE "x86"
/* Target architecture is ARM */
/* #undef ARCH_ARM */
/* Target architecture is PowerPC */
/* #undef ARCH_PPC */
/* Target architecture is x86 */
#define ARCH_X86 1
/* Target architecture is x86_64 */
/* #undef ARCH_X86_64 */
/* Full Gambas version */
#define GAMBAS_FULL_VERSION 0x03000090
/* Gambas full version string */
#define GAMBAS_FULL_VERSION_STRING "3.0"
/* Gambas minor version */
#define GAMBAS_MINOR_VERSION 0
/* Gambas bytecode version */
#define GAMBAS_PCODE_VERSION 0x03010000
/* Minimum Gambas bytecode version */
#define GAMBAS_PCODE_VERSION_MIN 0x03000000
/* Gambas version */
#define GAMBAS_VERSION 3
/* Gambas version string */
#define GAMBAS_VERSION_STRING "3"
/* Define to 1 if you have the `cfmakeraw' function. */
#define HAVE_CFMAKERAW 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Whether gcc supports -fvisibility=hidden */
#define HAVE_GCC_VISIBILITY 1
/* Define to 1 if you have the `getdomainname' function. */
#define HAVE_GETDOMAINNAME 1
/* Define to 1 if you have the `getpt' function. */
#define HAVE_GETPT 1
/* Have GNU Scientific Library component */
#define HAVE_GSL_COMPONENT 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if the type `long double' works and has more range or precision
than `double'. */
#define HAVE_LONG_DOUBLE 1
/* Define to 1 if the type `long double' works and has more range or precision
than `double'. */
#define HAVE_LONG_DOUBLE_WIDER 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `setenv' function. */
#define HAVE_SETENV 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `unsetenv' function. */
#define HAVE_UNSETENV 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Target system is of BSD family */
/* #undef OS_BSD */
/* Target system is Cygwin/Windows */
/* #undef OS_CYGWIN */
/* Target system is FreeBSD */
/* #undef OS_FREEBSD */
/* Target system is Linux */
#define OS_LINUX 1
/* Target system is MacOS X */
/* #undef OS_MACOSX */
/* Target system is NetBSD */
/* #undef OS_NETBSD */
/* Target system is OpenBSD */
/* #undef OS_OPENBSD */
/* Target system is Solaris */
/* #undef OS_SOLARIS */
/* Name of package */
#define PACKAGE "gambas3-gb-gsl"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Shared library extension is '.so' */
#define SHARED_LIBRARY_EXT "so"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Operating system */
#define SYSTEM "Linux"
/* Version number of package */
#define VERSION "3.0.90"
/* config.h.in. Generated from configure.ac by autoheader. */
/* Architecture */
#undef ARCHITECTURE
/* Target architecture is ARM */
#undef ARCH_ARM
/* Target architecture is PowerPC */
#undef ARCH_PPC
/* Target architecture is x86 */
#undef ARCH_X86
/* Target architecture is x86_64 */
#undef ARCH_X86_64
/* Full Gambas version */
#undef GAMBAS_FULL_VERSION
/* Gambas full version string */
#undef GAMBAS_FULL_VERSION_STRING
/* Gambas minor version */
#undef GAMBAS_MINOR_VERSION
/* Gambas bytecode version */
#undef GAMBAS_PCODE_VERSION
/* Minimum Gambas bytecode version */
#undef GAMBAS_PCODE_VERSION_MIN
/* Gambas version */
#undef GAMBAS_VERSION
/* Gambas version string */
#undef GAMBAS_VERSION_STRING
/* Define to 1 if you have the `cfmakeraw' function. */
#undef HAVE_CFMAKERAW
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Whether gcc supports -fvisibility=hidden */
#undef HAVE_GCC_VISIBILITY
/* Define to 1 if you have the `getdomainname' function. */
#undef HAVE_GETDOMAINNAME
/* Define to 1 if you have the `getpt' function. */
#undef HAVE_GETPT
/* Have GNU Scientific Library component */
#undef HAVE_GSL_COMPONENT
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if the type `long double' works and has more range or precision
than `double'. */
#undef HAVE_LONG_DOUBLE
/* Define to 1 if the type `long double' works and has more range or precision
than `double'. */
#undef HAVE_LONG_DOUBLE_WIDER
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `unsetenv' function. */
#undef HAVE_UNSETENV
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Target system is of BSD family */
#undef OS_BSD
/* Target system is Cygwin/Windows */
#undef OS_CYGWIN
/* Target system is FreeBSD */
#undef OS_FREEBSD
/* Target system is Linux */
#undef OS_LINUX
/* Target system is MacOS X */
#undef OS_MACOSX
/* Target system is NetBSD */
#undef OS_NETBSD
/* Target system is OpenBSD */
#undef OS_OPENBSD
/* Target system is Solaris */
#undef OS_SOLARIS
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Shared library extension is '.so' */
#undef SHARED_LIBRARY_EXT
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Operating system */
#undef SYSTEM
/* Version number of package */
#undef VERSION
This diff is collapsed.
dnl ---- configure.ac for __COMPONENT
dnl ---- configure.ac for gb.gsl
AC_INIT(configure.ac)
AC_CONFIG_MACRO_DIR([m4])
GB_INIT(__COMPONENT)
GB_INIT(gb.gsl)
AC_PROG_LIBTOOL
#if __USE_XWINDOW || __USE_QT
GB_CHECK_XWINDOW
#endif
#if __USE_QT
GB_FIND_QT_MOC
#endif
#if __USE_PKGCONFIG
GB_COMPONENT_PKG_CONFIG(
__NAME,
__UNAME,
[__DESCRIPTION],
gsl,
GSL,
[GNU Scientific Library component],
[src],
__PKGCONFIG_NAME)
#else
#if __USE_C
#define __LIBRARY_C $C_LIB
#else
#define __LIBRARY_C
#endif
#if __USE_CPP
#define __LIBRARY_CPP $CXX_LIB
#else
#define __LIBRARY_CPP
#endif
#if __USE_THREAD
#define __LIBRARY_THREAD $THREAD_LIB
#define __INCLUDE_THREAD $THREAD_INC
#else
#define __LIBRARY_THREAD
#define __INCLUDE_THREAD
#endif
GB_COMPONENT(
__NAME,
__UNAME,
[__DESCRIPTION],
[src],
#ifdef __SEARCH_INCLUDE
[GB_FIND(__SEARCH_INCLUDE, __SEARCH_INCLUDE_PATH, __SEARCH_INCLUDE_DIR)],
#else
[],
#endif
#ifdef __SEARCH_LIBRARY
[GB_FIND(__SEARCH_LIBRARY, __SEARCH_LIBRARY_PATH, __SEARCH_LIBRARY_DIR)],
#else
[],
#endif
[__LIBRARY_C __LIBRARY_CPP __LIBRARY_THREAD __LIBRARY],
[__INCLUDE_THREAD __INCLUDE])
#endif
AC_OUTPUT( \
Makefile \
src/Makefile \
)
gsl)
AC_OUTPUT( Makefile src/Makefile )
GB_PRINT_MESSAGES
../main/share/gambas.h
\ No newline at end of file
../main/share/gb_common.h
\ No newline at end of file
../reconf
\ No newline at end of file
This diff is collapsed.
COMPONENT = __COMPONENT
COMPONENT = gb.gsl
include $(top_srcdir)/component.am
INCLUDES = #@#__UNAME##_INC@
INCLUDES = @GSL_INC@
gblib_LTLIBRARIES = __COMPONENT.la
__COMPONENT_UNDERSCORE##_la_LIBADD = #@#__UNAME##_LIB@
__COMPONENT_UNDERSCORE##_la_LDFLAGS = -module @LD_FLAGS@ #@#__UNAME##_LDFLAGS@
__COMPONENT_UNDERSCORE##_la_SOURCES = __SOURCES
gblib_LTLIBRARIES = gb.gsl.la
gb_gsl_la_LIBADD = @GSL_LIB@
gb_gsl_la_LDFLAGS = -module @LD_FLAGS@ @GSL_LDFLAGS@
gb_gsl_la_SOURCES = main.c main.h c_gsl.c c_gsl.h
This diff is collapsed.
/***************************************************************************
gsl.c
gb.gsl component
(c) 2012 Randall Morgan <rmorgan62@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
***************************************************************************/
#ifndef __C_GSL_C
#define __C_GSL_C
#include "gambas.h"
#include "gb_common.h"
#include "c_gsl.h"
#include "/usr/local/include/gsl/gsl_math.h"
#include <gsl/gsl_sf.h>
#endif
/*--------------------------------
Number testing functions
--------------------------------*/
BEGIN_METHOD(GSL_ISNAN, GB_FLOAT x;)
// This function returns 1 if x is not-a-number.
// Call GSL Function int gsl_isnan(const double x)
int c;
c = gsl_isnan(VARG(x));
GB.ReturnBoolean((c==1?1:-1));
END_METHOD
BEGIN_METHOD(GSL_ISINF, GB_FLOAT x;)
// This function returns +1 if x is positive infinity,
// -1 if x is negative infinity and 0 otherwise.
// Call GSL Function int gsl_isinf(const double x)
int c;
c= gsl_isinf(VARG(x));
GB.ReturnBoolean((c==1?1:-1));
END_METHOD
BEGIN_METHOD(GSL_ISFINITE, GB_FLOAT x;)
// This function returns 1 if x is a real number,
// and -1 if it is infinite or not-a-number.
// Call GSL Function int gsl_isfinite(const double x)
int c;
c = gsl_isfinite(VARG(x));
GB.ReturnBoolean((c == 1?1:-1));
END_METHOD
/*-----------------------------------------------
Elementary Functions
-----------------------------------------------*/
BEGIN_METHOD(GSL_LOGLP, GB_FLOAT x;)
// This function computes the value of \log(1+x)
// in a way that is accurate for small x.
// Call GSL Function int gsl_isnan(const double x)
GB.ReturnFloat(gsl_log1p (VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_EXPML, GB_FLOAT x;)
// This function computes the value of \exp(x)-1
// in a way that is accurate for small x.
GB.ReturnFloat(gsl_expm1 (VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_HYPOT, GB_FLOAT x; GB_FLOAT y;)
// This function computes the value of
// \sqrt{x^2 + y^2} in a way that avoids overflow.
// Call GSL function double gsl_hypot (const double x, const double y)
GB.ReturnFloat(gsl_hypot(VARG(x), VARG(y)));
END_METHOD
BEGIN_METHOD(GSL_HYPOT3, GB_FLOAT x; GB_FLOAT y; GB_FLOAT z;)
// This function computes the value of \sqrt{x^2 + y^2 + z^2}
// in a way that avoids overflow.
// Call GSL function double gsl_hypot3 (const double x, const double y, const double z)
GB.ReturnFloat(gsl_hypot3(VARG(x), VARG(y), VARG(z)));
END_METHOD
BEGIN_METHOD(GSL_ACOSH, GB_FLOAT x;)
// This function computes the value of \arccosh(x).
// It provides an alternative to the standard math function acosh(x).
GB.ReturnFloat(gsl_acosh(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_ASINH, GB_FLOAT x;)
// Function: double gsl_asinh (const double x)
// This function computes the value of arcsinh(x).
// It provides an alternative to the standard math function asinh(x).
GB.ReturnFloat(gsl_asinh(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_ATANH, GB_FLOAT x;)
// Function: double gsl_atanh (const double x)
// This function computes the value of \arctanh(x).
// It provides an alternative to the standard math function atanh(x).
GB.ReturnFloat(gsl_atanh(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_LDEXP, GB_FLOAT x; GB_INTEGER e;)
// Function: double gsl_ldexp (double x, int e)
// This function computes the value of x * 2^e.
// It provides an alternative to the standard math function ldexp(x,e).
GB.ReturnFloat(gsl_ldexp(VARG(x), VARG(e)));
END_METHOD
/*
BEGIN_METHOD(GSL_FREXP, GB_FLOAT x; GB_INTEGER e;)
// Function: double gsl_frexp (double x, int * e)
// This function splits the number x into its normalized fraction f
// and exponent e, such that x = f * 2^e and 0.5 <= f < 1. The function
// returns f and stores the exponent in e. If x is zero, both f and e
// are set to zero. This function provides an alternative to the
// standard math function frexp(x, e).
GB.ReturnFloat(gsl_frexp(VARG(x), VARG(e)));
END_METHOD
*/
/*-----------------------------------------------
Small Integer Power Functions
-----------------------------------------------*/
BEGIN_METHOD(GSL_INTPOW2, GB_FLOAT x;)
// Return x^2 using a small int safe method
// call gsl native function double gsl_pow_2(double x)
GB.ReturnFloat(gsl_pow_2(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_INTPOW3, GB_FLOAT x;)
// Return x^3 using a small int safe method
// call gsl native function double gsl_pow_3(double x)
GB.ReturnFloat(gsl_pow_3(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_INTPOW4, GB_FLOAT x;)
// Return x^4 using a small int safe method
// call gsl native function double gsl_pow_3(double x)
GB.ReturnFloat(gsl_pow_4(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_INTPOW5, GB_FLOAT x;)
// Return x^5 using a small int safe method
// call gsl native function double gsl_pow_3(double x)
GB.ReturnFloat(gsl_pow_5(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_INTPOW6, GB_FLOAT x;)
// Return x^6 using a small int safe method
// call gsl native function double gsl_pow_3(double x)
GB.ReturnFloat(gsl_pow_6(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_INTPOW7, GB_FLOAT x;)
// Return x^7 using a small int safe method
// call gsl native function double gsl_pow_3(double x)
GB.ReturnFloat(gsl_pow_7(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_INTPOW8, GB_FLOAT x;)
// Return x^8 using a small int safe method
// call gsl native function double gsl_pow_3(double x)
GB.ReturnFloat(gsl_pow_8(VARG(x)));
END_METHOD
BEGIN_METHOD(GSL_INTPOW9, GB_FLOAT x;)
// Return x^9 using a small int safe method
// call gsl native function double gsl_pow_3(double x)
GB.ReturnFloat(gsl_pow_9(VARG(x)));
END_METHOD
/**************************************************
Describe Class properties and methods to Gambas
**************************************************/
GB_DESC CGslDesc[] =
{
GB_DECLARE("GSL",0), GB_NOT_CREATABLE(),
// Number testing functions
GB_STATIC_METHOD("IsNAN", "f", GSL_ISNAN, "(x)f"),
GB_STATIC_METHOD("IsINF", "f", GSL_ISINF, "(x)f"),
GB_STATIC_METHOD("IsFinite", "f", GSL_ISFINITE, "(x)f"),
// Elementary Functions
GB_STATIC_METHOD("LogLP", "f", GSL_LOGLP, "(x)f"),
GB_STATIC_METHOD("Expml", "f", GSL_EXPML, "(x)f"),
GB_STATIC_METHOD("Hypot", "f", GSL_HYPOT, "[(x)f(y)f]"),
GB_STATIC_METHOD("Hypot3", "f", GSL_HYPOT3, "[(x)f(y)f(z)f]"),
GB_STATIC_METHOD("Acosh", "f", GSL_ACOSH, "(x)f"),
GB_STATIC_METHOD("Asinh", "f", GSL_ASINH, "(x)f"),
GB_STATIC_METHOD("Atanh", "f", GSL_ATANH, "(x)f"),
GB_STATIC_METHOD("Ldexp", "f", GSL_LDEXP, "[(x)f(e)i]"),
//GB_STATIC_METHOD("Frexp", "f", GSL_FREXP, "[(x)f(e)i]"),
// Return x^y using a small int safe method
GB_STATIC_METHOD("IntPow2", "f", GSL_INTPOW2, "(x)f"),
GB_STATIC_METHOD("IntPow3", "f", GSL_INTPOW3, "(x)f"),
GB_STATIC_METHOD("IntPow4", "f", GSL_INTPOW4, "(x)f"),
GB_STATIC_METHOD("IntPow5", "f", GSL_INTPOW5, "(x)f"),
GB_STATIC_METHOD("IntPow6", "f", GSL_INTPOW6, "(x)f"),
GB_STATIC_METHOD("IntPow7", "f", GSL_INTPOW7, "(x)f"),
GB_STATIC_METHOD("IntPow8", "f", GSL_INTPOW8, "(x)f"),
GB_STATIC_METHOD("IntPow9", "f", GSL_INTPOW9, "(x)f"),
GB_END_DECLARE
};
/***************************************************************************
c_gsl.h
gb.gsl component
(c) 2012 Randall Morgan <rmorgan62@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
***************************************************************************/
#ifndef __C_GSL_H
#define __C_GSL_H
#include "gambas.h"
GB_INTERFACE GB EXPORT;
extern GB_DESC CGslDesc[];
//extern GSL_INTPOW2;
#endif /* __C_GSL_H */