From 9bc7cbe32906c97e864df0ad76ba0801333b71a9 Mon Sep 17 00:00:00 2001 From: bansodanurag Date: Tue, 26 Feb 2019 13:22:28 +0530 Subject: Add files via upload --- .../Resources/Include/gsl_per_alloc.c | 30 + .../Resources/Include/gsl_per_free.c | 7 + .../Resources/Include/gsl_per_init.c | 10 + .../Resources/Library/linux64/libaplusb.so | Bin 0 -> 7872 bytes .../Resources/Library/linux64/libgsl.a | Bin 0 -> 20284394 bytes .../Resources/Library/linux64/libgslcblas.a | Bin 0 -> 475386 bytes .../Resources/Library/linux64/libsq_root.so | Bin 0 -> 8008 bytes External_Functions/a.mo | 710 +++++++++++++++++++++ 8 files changed, 757 insertions(+) create mode 100644 External_Functions/Resources/Include/gsl_per_alloc.c create mode 100644 External_Functions/Resources/Include/gsl_per_free.c create mode 100644 External_Functions/Resources/Include/gsl_per_init.c create mode 100644 External_Functions/Resources/Library/linux64/libaplusb.so create mode 100644 External_Functions/Resources/Library/linux64/libgsl.a create mode 100644 External_Functions/Resources/Library/linux64/libgslcblas.a create mode 100644 External_Functions/Resources/Library/linux64/libsq_root.so create mode 100644 External_Functions/a.mo diff --git a/External_Functions/Resources/Include/gsl_per_alloc.c b/External_Functions/Resources/Include/gsl_per_alloc.c new file mode 100644 index 0000000..3faa008 --- /dev/null +++ b/External_Functions/Resources/Include/gsl_per_alloc.c @@ -0,0 +1,30 @@ +#include +#include +/*typedef struct{ +size_t size; +int* data; +}OM_gsl_permutation; +*/ + + +void* gsl_per_alloc(size_t N) +{ + gsl_permutation* p = gsl_permutation_alloc(N); + for(int i = 0; i < N; i++) + { + (p->data)[i] = 0; + } + return (void*) p; + /*OM_gsl_permutation* OM_gsl_per = malloc(sizeof(OM_gsl_permutation)); + if ( OM_gsl_per == NULL ) ModelicaError("Not enough memory"); + return (void*) OM_gsl_per;*/ +} + +/*void OM_gsl_permutation_free(void* p) +{ + OM_gsl_permutation* OM_gsl_per = (OM_gsl_permutation*) p; + if (OM_gsl_per != NULL) + { + free(OM_gsl_per); + } +}*/ diff --git a/External_Functions/Resources/Include/gsl_per_free.c b/External_Functions/Resources/Include/gsl_per_free.c new file mode 100644 index 0000000..dc5d8e3 --- /dev/null +++ b/External_Functions/Resources/Include/gsl_per_free.c @@ -0,0 +1,7 @@ +#include +#include + +void gsl_per_free(gsl_permutation *p) +{ + gsl_permutation_free(p); +} diff --git a/External_Functions/Resources/Include/gsl_per_init.c b/External_Functions/Resources/Include/gsl_per_init.c new file mode 100644 index 0000000..18a4ca0 --- /dev/null +++ b/External_Functions/Resources/Include/gsl_per_init.c @@ -0,0 +1,10 @@ +#include +#include + +int* gsl_per_init(size_t N, int* y, void *p) +{ + gsl_permutation* op = (gsl_permutation*)p; + gsl_permutation_init(op); + y = (op -> data); + return y; +} diff --git a/External_Functions/Resources/Library/linux64/libaplusb.so b/External_Functions/Resources/Library/linux64/libaplusb.so new file mode 100644 index 0000000..c6f28b5 Binary files /dev/null and b/External_Functions/Resources/Library/linux64/libaplusb.so differ diff --git a/External_Functions/Resources/Library/linux64/libgsl.a b/External_Functions/Resources/Library/linux64/libgsl.a new file mode 100644 index 0000000..f07981c Binary files /dev/null and b/External_Functions/Resources/Library/linux64/libgsl.a differ diff --git a/External_Functions/Resources/Library/linux64/libgslcblas.a b/External_Functions/Resources/Library/linux64/libgslcblas.a new file mode 100644 index 0000000..d0cf1ba Binary files /dev/null and b/External_Functions/Resources/Library/linux64/libgslcblas.a differ diff --git a/External_Functions/Resources/Library/linux64/libsq_root.so b/External_Functions/Resources/Library/linux64/libsq_root.so new file mode 100644 index 0000000..14453b7 Binary files /dev/null and b/External_Functions/Resources/Library/linux64/libsq_root.so differ diff --git a/External_Functions/a.mo b/External_Functions/a.mo new file mode 100644 index 0000000..7c67be0 --- /dev/null +++ b/External_Functions/a.mo @@ -0,0 +1,710 @@ +package gsl + package data_types + model gsl_permutation + extends ExternalObject; + + function constructor + input Integer N; + output gsl_permutation p; + + external "C" p = gsl_permutation_alloc(N) annotation( + Include = "#include ", + Library = "gsl", + Library = "gslcblas"); + end constructor; + + function destructor "Release storage of p" + input gsl_permutation p; + + external "C" gsl_permutation_free(p) annotation( + Include = "#include ", + Library = "gsl", + Library = "gslcblas"); + end destructor; + end gsl_permutation; + + /* model gsl_complex + extends ExternalObject; + + function constructor + input Integer N; + output gsl_complex k; + + external "C" annotation( + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end constructor; + + function destructor + input gsl_complex k; + + external "C" annotation( + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end destructor; + end gsl_complex; + */ + end data_types; + + package mathematical + function gsl_log1p + //This function computes the value of log(1 + x) in a way that is accurate for small x + input Real x; + output Real y; + + external "C" y = log1p(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_log1p; + + function gsl_expm1 + //this function computes the value of exp(x)-1 + input Real x; + output Real y; + + external "C" y = gsl_expm1(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_expm1; + + function gsl_hypot + //this function computes the value of sqrt(x^2+y^2) in a way which avoids overflow + input Real x; + input Real y; + output Real z; + + external "C" z = gsl_hypot(x, y) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_hypot; + + function gsl_hypot3 + //This function calculates the value of sqrt(x^2+y^2+z^2) + input Real x; + input Real y; + input Real z; + output Real o; + + external "C" o = gsl_hypot3(x, y, z) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_hypot3; + + function gsl_acosh + // this function calculates the value of arccosh(x) + input Real x; + output Real y; + + external "C" y = acosh(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_acosh; + + function gsl_asinh + // this function calculates the value of arcsinh(x) + input Real x; + output Real y; + + external "C" y = asinh(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_asinh; + + function gsl_atanh + // this function calculates the value of arctanh(x) + input Real x; + output Real y; + + external "C" y = atanh(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_atanh; + + function gsl_ldexp + //this function computes the value of x*2^e + input Real x; + // y should be given the value e + output Real z; + protected + constant Real y = Modelica.Constants.e; + + external "C" z = gsl_ldexp(x, y) annotation( + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end gsl_ldexp; + + function gsl_frexp + //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. + input Real x; + output Integer e; + // it stores the exponent in y + output Real z; + + external "C" z = gsl_frexp(x, e) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_frexp; + + function gsl_pow_int + //this function computes x^n + input Real x; + input Integer n; + output Real y; + + external "C" y = gsl_pow_int(x, n) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_int; + + function gsl_pow_2 + //This function calculates square fo the given number + input Real x; + output Real y; + + external "C" y = gsl_pow_2(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_2; + + function gsl_pow_3 + //This function calculates cube of the given number + input Real x; + output Real y; + + external "C" y = gsl_pow_3(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_3; + + function gsl_pow_4 + //This function calculates number to the power of 4 of the given number + input Real x; + output Real y; + + external "C" y = gsl_pow_4(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_4; + + function gsl_pow_5 + //This function calculates number to the power of 5 of the given number + input Real x; + output Real y; + + external "C" y = gsl_pow_5(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_5; + + function gsl_pow_6 + //This function calculates number to the power of 6 of the given number + input Real x; + output Real y; + + external "C" y = gsl_pow_6(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_6; + + function gsl_pow_7 + //This function calculates number to the power of 6 of the given number + input Real x; + output Real y; + + external "C" y = gsl_pow_7(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_7; + + function gsl_pow_8 + //This function calculates number to the power of 6 of the given number + input Real x; + output Real y; + + external "C" y = gsl_pow_8(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_8; + + function gsl_pow_9 + //This function calculates number to the power of 6 of the given number + input Real x; + output Real y; + + external "C" y = gsl_pow_9(x) annotation( + Library = "gsl", + Library = "gslcblas"); + end gsl_pow_9; + + function GSL_SIGN + //This function outputs -1 for negative number and +1 if the number is positive + input Real x; + output Integer y; + + external "C" y = GSL_SIGN(x) annotation( + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_SIGN; + + function GSL_IS_ODD + //This function outputs 1 if number is odd else if number is even it returns zero + input Integer x; + output Integer y; + + external "C" y = GSL_IS_ODD(x) annotation( + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_IS_ODD; + + function GSL_IS_EVEN + //This function outputs 0 if number is odd else if number is even it returns 1 + input Integer x; + output Integer y; + + external "C" y = GSL_IS_EVEN(x) annotation( + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_IS_EVEN; + + function GSL_MAX + // This function calculates the maximum of two numbers + input Real a; + input Real b; + output Real c; + + external "C" c = GSL_MAX(a, b) annotation( + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_MAX; + + function GSL_MAX_DBL + // This function calculates the maximum of the given two floating point numbers + input Real a; + input Real b; + output Real c; + + external "C" c = GSL_MAX_DBL(a, b) annotation( + Inline = true, + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_MAX_DBL; + + function GSL_MIN_DBL + //This function calculates the minimum of two given floating point numbers + input Real a; + input Real b; + output Real c; + + external "C" c = GSL_MIN_DBL(a, b) annotation( + Inline = true, + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_MIN_DBL; + + function GSL_MAX_INT + // This function calculates the maximum of two given integers + input Real a; + input Real b; + output Real c; + + external "C" c = GSL_MAX_INT(a, b) annotation( + Inline = true, + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_MAX_INT; + + function GSL_MIN_INT + // This function calculates the minimum of the two numbers + input Real a; + input Real b; + output Real c; + + external "C" c = GSL_MIN_INT(a, b) annotation( + Inline = true, + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_MIN_INT; + + function GSL_MAX_LDBL + // This function calculates the maximum of two long double numbers + input Real a; + input Real b; + output Real c; + + external "C" c = GSL_MAX_LDBL(a, b) annotation( + Inline = true, + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_MAX_LDBL; + + function GSL_MIN_LDBL + // This function calculates the minimum of two long double numbers + input Real a; + input Real b; + output Real c; + + external "C" c = GSL_MIN_LDBL(a, b) annotation( + Inline = true, + Library = "gsl", + Library = "gslcblas", + Include = "#include"); + end GSL_MIN_LDBL; + + function gsl_fcmp + //This function determines whether x and y are approximately equal if they are equal within the range of epsilon it returns zero,if a>b it returns -1 and if bb + parameter Real a = 4.0; + parameter Real b = 2.2; + Real c; + algorithm + c := gsl.mathematical.gsl_fcmp(a, b); + end gsl_fcmp; + + /**/ + end Mathematical; + + package Permutation + /*this model initialise the permutation with 10 elements to {0,1,2,3,4,5,6,7,8,9}*/ + //this model calls the function gsl_permutation_init(p) to initialize the permutation to {0,1,2,3,4,5,6,7,8,9} + //this model calls the function gsl_permutation_init(p) to initialize the permutation to {0,1,2,3,4,5,6,7,8,9} + //this model calls the function gsl_permutation_init(p) to initialize the permutation to {0,1,2,3,4,, + + model gsl_per_init + /*this model initializes the permutation p to{0,1,2,3,4,5,6,7,8,9}*/ + parameter Integer N = 10; + gsl.data_types.gsl_permutation p = gsl.data_types.gsl_permutation(N); + Integer y[10]; + algorithm + gsl.Permutation.gsl_permutation_init(p); + for i in 1:10 loop + y[i] := gsl.Permutation.gsl_permutation_get(p, i - 1); + end for; + end gsl_per_init; + end Permutation; + + package COMPLEX + end COMPLEX; + end Examples; +end gsl; \ No newline at end of file -- cgit