Search is not available for this dataset
text
string
meta
dict
/** * Copyright (C) 2019 Samsung Electronics Co., Ltd. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * * @file tensor.h * @date 04 December 2019 * @brief This is Tensor class for calculation * @see https://github.com/nnstreamer/nntrainer * @author Jijoong Moon <jijoong.moon@samsung.com> * @bug No known bugs except for NYI items * */ #ifndef __TENSOR_H__ #define __TENSOR_H__ #ifdef __cplusplus #ifdef USE_BLAS extern "C" { #include <cblas.h> } #endif #include <cmath> #include <fstream> #include <iostream> #include <memory> #include <regex> #include <vector> namespace nntrainer { #define MAXDIM 4 class TensorDim { public: TensorDim() { for (int i = 0; i < MAXDIM; ++i) { dim[i] = 1; } } ~TensorDim(){}; unsigned int batch() { return dim[0]; }; unsigned int channel() { return dim[1]; }; unsigned int height() { return dim[2]; }; unsigned int width() { return dim[3]; }; void batch(unsigned int b) { dim[0] = b; }; void channel(unsigned int c) { dim[1] = c; }; void height(unsigned int h) { dim[2] = h; }; void width(unsigned int w) { dim[3] = w; }; unsigned int *getDim() { return dim; } int setTensorDim(std::string input_shape); private: unsigned int dim[4]; }; /** * @class Tensor Class for Calculation * @brief Tensor Class for Calculation */ class Tensor { public: /** * @brief Constructor of Tensor */ Tensor() : height(0), width(0), batch(0), ndim(0), len(0){}; /** * @brief Constructor of Tensor with batch size one * @param[in] heihgt Height of Tensor * @param[in] width Width of Tensor */ Tensor(int height, int width); /** * @brief Constructor of Tensor * @param[in] batch Batch of Tensor * @param[in] heihgt Height of Tensor * @param[in] width Width of Tensor */ Tensor(int batch, int height, int width); /** * @brief Constructor of Tensor * @param[in] d data for the Tensor with batch size one */ Tensor(std::vector<std::vector<float>> const &d); /** * @brief Constructor of Tensor * @param[in] d data for the Tensor */ Tensor(std::vector<std::vector<std::vector<float>>> const &d); /** * @brief return value at specific location * @param[in] batch batch location * @param[in] h height location * @param[in] w width location */ float getValue(int batch, int h, int w); /** * @brief Multiply value element by element * @param[in] value multiplier * @retval Calculated Tensor */ Tensor multiply(float const &value); /** * @brief Divide value element by element * @param[in] value Divisor * @retval Calculated Tensor */ Tensor divide(float const &value); /** * @brief Add Tensor Element by Element * @param[in] m Tensor to be added * @retval Calculated Tensor */ Tensor add(Tensor const &m) const; /** * @brief Add value Element by Element * @param[in] value value to be added * @retval Calculated Tensor */ Tensor add(float const &value); /** * @brief Substract Tensor Element by Element * @param[in] m Tensor to be added * @retval Calculated Tensor */ Tensor subtract(Tensor const &m) const; /** * @brief subtract value Element by Element * @param[in] value value to be added * @retval Calculated Tensor */ Tensor subtract(float const &value); /** * @brief Multiply Tensor Element by Element ( Not the MxM ) * @param[in] m Tensor to be multiplied * @retval Calculated Tensor */ Tensor multiply(Tensor const &m) const; /** * @brief Divide Tensor Element by Element * @param[in] m Divisor Tensor * @retval Calculated Tensor */ Tensor divide(Tensor const &m) const; /** * @brief Dot Product of Tensor ( equal MxM ) * @param[in] m Tensor * @retval Calculated Tensor */ Tensor dot(Tensor const &m) const; /** * @brief Transpose Tensor * @retval Calculated Tensor */ Tensor transpose() const; /** * @brief sum all the Tensor elements according to the batch * @retval Calculated Tensor(batch, 1, 1) */ Tensor sum() const; /** * @brief sum all the Tensor elements according to the axis * @retval Calculated Tensor */ Tensor sum(int axis) const; /** * @brief Averaging the Tensor elements according to the batch * @retval Calculated Tensor(1, height, width) */ Tensor average() const; /** * @brief Softmax the Tensor elements * @retval Calculated Tensor */ Tensor softmax() const; /** * @brief l2norm the Tensor elements * @retval Calculated l2norm */ float l2norm() const; /** * @brief Normalize the Tensor elements * @retval Calculated Tensor */ Tensor normalization() const; /** * @brief Standardize the Tensor elements * @retval Calculated Tensor */ Tensor standardization() const; /** * @brief Fill the Tensor elements with zero */ void setZero(); /** * @brief Reduce Rank ( Tensor to Vector ) * @retval Saved vector */ std::vector<float> mat2vec(); /** * @brief Apply function element by element * @param[in] *function function pointer applied * @retval Tensor */ Tensor apply(float (*function)(float)) const; /** * @brief Apply function to Tensor * @param[in] *function function pointer applied * @retval Tensor */ Tensor apply(Tensor (*function)(Tensor)) const; /** * @brief Print element * @param[in] out out stream * @retval Tensor */ void print(std::ostream &out) const; /** * @brief Get Width of Tensor * @retval int Width */ int getWidth() { return width; }; /** * @brief Get Height of Tensor * @retval int Height */ int getHeight() { return height; }; /** * @brief Get Batch of Tensor * @retval int Batch */ int getBatch() { return batch; }; /** * @brief Set the elelemnt value * @param[in] batch batch location * @param[in] i height location * @param[in] j width location * @param[in] value value to be stored */ void setValue(int batch, int i, int j, float value); /** * @brief Copy the Tensor * @param[in] from Tensor to be Copyed * @retval Matix */ Tensor &copy(Tensor const &from); /** * @brief Save the Tensor into file * @param[in] file output file stream */ void save(std::ofstream &file); /** * @brief Read the Tensor from file * @param[in] file input file stream */ void read(std::ifstream &file); /** * @brief return argument index which value is max * @retval int argument index */ int argmax(); /** * @brief return Data pointer of Tensor * @retval float pointer */ float *getData() { return data.data(); } private: /**< handle the data as a std::vector type */ std::vector<float> data; int height; int width; int batch; int ndim; int len; }; /** * @brief Overriding output stream */ std::ostream &operator<<(std::ostream &out, Tensor const &m); } /* namespace nntrainer */ #endif /* __cplusplus */ #endif /* __TENSOR_H__ */
{ "alphanum_fraction": 0.6202775636, "avg_line_length": 23.0919881306, "ext": "h", "hexsha": "2dfb80db126045ada6172fd82c304e945e99e62b", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3fd8368ac14c1242129edb788cbc65229f61087b", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "zhoonit/nntrainer", "max_forks_repo_path": "nntrainer/include/tensor.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "3fd8368ac14c1242129edb788cbc65229f61087b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "zhoonit/nntrainer", "max_issues_repo_path": "nntrainer/include/tensor.h", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "3fd8368ac14c1242129edb788cbc65229f61087b", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "zhoonit/nntrainer", "max_stars_repo_path": "nntrainer/include/tensor.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2097, "size": 7782 }
#include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <math.h> #include <string.h> #include "cconfigspace_internal.h" #include "distribution_internal.h" struct _ccs_distribution_multivariate_data_s { _ccs_distribution_common_data_t common_data; size_t num_distributions; ccs_distribution_t *distributions; size_t *dimensions; ccs_interval_t *bounds; }; typedef struct _ccs_distribution_multivariate_data_s _ccs_distribution_multivariate_data_t; static ccs_result_t _ccs_distribution_multivariate_del(ccs_object_t o) { struct _ccs_distribution_multivariate_data_s *data = (struct _ccs_distribution_multivariate_data_s *)(((ccs_distribution_t)o)->data); for (size_t i = 0; i < data->num_distributions; i++) { ccs_release_object(data->distributions[i]); } return CCS_SUCCESS; } static ccs_result_t _ccs_distribution_multivariate_get_bounds(_ccs_distribution_data_t *data, ccs_interval_t *interval_ret); static ccs_result_t _ccs_distribution_multivariate_samples(_ccs_distribution_data_t *data, ccs_rng_t rng, size_t num_values, ccs_numeric_t *values); static ccs_result_t _ccs_distribution_multivariate_strided_samples(_ccs_distribution_data_t *data, ccs_rng_t rng, size_t num_values, size_t stride, ccs_numeric_t *values); static ccs_result_t _ccs_distribution_multivariate_soa_samples(_ccs_distribution_data_t *data, ccs_rng_t rng, size_t num_values, ccs_numeric_t **values); static _ccs_distribution_ops_t _ccs_distribution_multivariate_ops = { { &_ccs_distribution_multivariate_del }, &_ccs_distribution_multivariate_samples, &_ccs_distribution_multivariate_get_bounds, &_ccs_distribution_multivariate_strided_samples, &_ccs_distribution_multivariate_soa_samples }; ccs_result_t ccs_create_multivariate_distribution(size_t num_distributions, ccs_distribution_t *distributions, ccs_distribution_t *distribution_ret) { CCS_CHECK_ARY(num_distributions, distributions); CCS_CHECK_PTR(distribution_ret); if (!num_distributions || num_distributions > INT64_MAX) return -CCS_INVALID_VALUE; ccs_result_t err; size_t i = 0; size_t dimension = 0; ccs_distribution_t distrib; _ccs_distribution_multivariate_data_t *distrib_data; for (i = 0; i < num_distributions; i++) { size_t dim; CCS_VALIDATE(ccs_distribution_get_dimension(distributions[i], &dim)); dimension += dim; } uintptr_t mem, cur_mem; mem = (uintptr_t)calloc(1, sizeof(struct _ccs_distribution_s) + sizeof(_ccs_distribution_multivariate_data_t) + sizeof(ccs_distribution_t)*num_distributions + sizeof(size_t)*num_distributions + sizeof(ccs_interval_t)*dimension + sizeof(ccs_numeric_type_t)*dimension); if (!mem) return -CCS_OUT_OF_MEMORY; cur_mem = mem; distrib = (ccs_distribution_t)cur_mem; cur_mem += sizeof(struct _ccs_distribution_s); _ccs_object_init(&(distrib->obj), CCS_DISTRIBUTION, (_ccs_object_ops_t *)&_ccs_distribution_multivariate_ops); distrib_data = (_ccs_distribution_multivariate_data_t *)(cur_mem); cur_mem += sizeof(_ccs_distribution_multivariate_data_t); distrib_data->common_data.type = CCS_MULTIVARIATE; distrib_data->common_data.dimension = dimension; distrib_data->num_distributions = num_distributions; distrib_data->distributions = (ccs_distribution_t *)(cur_mem); cur_mem += sizeof(ccs_distribution_t)*num_distributions; distrib_data->dimensions = (size_t *)(cur_mem); cur_mem += sizeof(size_t)*num_distributions; distrib_data->bounds = (ccs_interval_t *)(cur_mem); cur_mem += sizeof(ccs_interval_t)*dimension; distrib_data->common_data.data_types = (ccs_numeric_type_t *)(cur_mem); cur_mem += sizeof(ccs_numeric_type_t)*dimension; dimension = 0; for (i = 0; i < num_distributions; i++) { size_t dim; CCS_VALIDATE_ERR_GOTO(err, ccs_distribution_get_data_types(distributions[i], distrib_data->common_data.data_types + dimension), errmemory); CCS_VALIDATE_ERR_GOTO(err, ccs_distribution_get_bounds(distributions[i], distrib_data->bounds + dimension), errmemory); CCS_VALIDATE_ERR_GOTO(err, ccs_distribution_get_dimension(distributions[i], &dim), errmemory); distrib_data->dimensions[i] = dim; dimension += dim; } for (i = 0; i < num_distributions; i++) { CCS_VALIDATE_ERR_GOTO(err, ccs_retain_object(distributions[i]), distrib); distrib_data->distributions[i] = distributions[i]; } distrib->data = (_ccs_distribution_data_t *)distrib_data; *distribution_ret = distrib; return CCS_SUCCESS; distrib: for (i = 0; i < num_distributions; i++) { if (distrib_data->distributions[i]) ccs_release_object(distributions[i]); } errmemory: free((void *)mem); return err; } static ccs_result_t _ccs_distribution_multivariate_get_bounds(_ccs_distribution_data_t *data, ccs_interval_t *interval_ret) { _ccs_distribution_multivariate_data_t *d = (_ccs_distribution_multivariate_data_t *)data; memcpy(interval_ret, d->bounds, d->common_data.dimension*sizeof(ccs_interval_t)); return CCS_SUCCESS; } static inline _ccs_distribution_ops_t * ccs_distribution_get_ops(ccs_distribution_t distribution) { return (_ccs_distribution_ops_t *)distribution->obj.ops; } static ccs_result_t _ccs_distribution_multivariate_samples(_ccs_distribution_data_t *data, ccs_rng_t rng, size_t num_values, ccs_numeric_t *values) { _ccs_distribution_multivariate_data_t *d = (_ccs_distribution_multivariate_data_t *)data; for (size_t i = 0; i < d->num_distributions; i++) { CCS_VALIDATE(ccs_distribution_get_ops(d->distributions[i])->strided_samples( d->distributions[i]->data, rng, num_values, d->common_data.dimension, values)); values += d->dimensions[i]; } return CCS_SUCCESS; } static ccs_result_t _ccs_distribution_multivariate_strided_samples(_ccs_distribution_data_t *data, ccs_rng_t rng, size_t num_values, size_t stride, ccs_numeric_t *values) { _ccs_distribution_multivariate_data_t *d = (_ccs_distribution_multivariate_data_t *)data; for (size_t i = 0; i < d->num_distributions; i++) { CCS_VALIDATE(ccs_distribution_get_ops(d->distributions[i])->strided_samples( d->distributions[i]->data, rng, num_values, stride, values)); values += d->dimensions[i]; } return CCS_SUCCESS; } static ccs_result_t _ccs_distribution_multivariate_soa_samples(_ccs_distribution_data_t *data, ccs_rng_t rng, size_t num_values, ccs_numeric_t **values) { _ccs_distribution_multivariate_data_t *d = (_ccs_distribution_multivariate_data_t *)data; for (size_t i = 0; i < d->num_distributions; i++) { CCS_VALIDATE(ccs_distribution_get_ops(d->distributions[i])->soa_samples( d->distributions[i]->data, rng, num_values, values)); values += d->dimensions[i]; } return CCS_SUCCESS; } ccs_result_t ccs_multivariate_distribution_get_num_distributions(ccs_distribution_t distribution, size_t *num_distributions_ret) { CCS_CHECK_DISTRIBUTION(distribution, CCS_MULTIVARIATE); CCS_CHECK_PTR(num_distributions_ret); _ccs_distribution_multivariate_data_t * data = (_ccs_distribution_multivariate_data_t *)distribution->data; *num_distributions_ret = data->num_distributions; return CCS_SUCCESS; } ccs_result_t ccs_multivariate_distribution_get_distributions(ccs_distribution_t distribution, size_t num_distributions, ccs_distribution_t *distributions, size_t *num_distributions_ret) { CCS_CHECK_DISTRIBUTION(distribution, CCS_MULTIVARIATE); CCS_CHECK_ARY(num_distributions, distributions); if (!distributions && !num_distributions_ret) return -CCS_INVALID_VALUE; _ccs_distribution_multivariate_data_t * data = (_ccs_distribution_multivariate_data_t *)distribution->data; if (distributions) { if (num_distributions < data->num_distributions) return -CCS_INVALID_VALUE; for (size_t i = 0; i < data->num_distributions; i++) distributions[i] = data->distributions[i]; for (size_t i = data->num_distributions; i < num_distributions; i++) distributions[i] = NULL; } if (num_distributions_ret) *num_distributions_ret = data->num_distributions; return CCS_SUCCESS; }
{ "alphanum_fraction": 0.6558750517, "avg_line_length": 40.4518828452, "ext": "c", "hexsha": "a685c99e522868eb2557ec779fee95bb5d7cafff", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-12-07T17:54:11.000Z", "max_forks_repo_forks_event_min_datetime": "2021-09-16T18:20:47.000Z", "max_forks_repo_head_hexsha": "dd8c976eca2a510c995862cc5c871e81932f3ff4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "deephyper/CCS", "max_forks_repo_path": "src/distribution_multivariate.c", "max_issues_count": 1, "max_issues_repo_head_hexsha": "dd8c976eca2a510c995862cc5c871e81932f3ff4", "max_issues_repo_issues_event_max_datetime": "2021-12-15T10:48:24.000Z", "max_issues_repo_issues_event_min_datetime": "2021-12-15T10:37:41.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "deephyper/CCS", "max_issues_repo_path": "src/distribution_multivariate.c", "max_line_length": 111, "max_stars_count": 1, "max_stars_repo_head_hexsha": "dd8c976eca2a510c995862cc5c871e81932f3ff4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "deephyper/CCS", "max_stars_repo_path": "src/distribution_multivariate.c", "max_stars_repo_stars_event_max_datetime": "2021-11-29T16:31:28.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-29T16:31:28.000Z", "num_tokens": 2105, "size": 9668 }
/***************************************************************************** Copyright (c) 2011-2014, The OpenBLAS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the OpenBLAS project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************************/ #include "openblas_utest.h" #include <sys/types.h> #include <sys/wait.h> #include <cblas.h> void* xmalloc(size_t n) { void* tmp; tmp = malloc(n); if (tmp == NULL) { fprintf(stderr, "You are about to die\n"); exit(1); } else { return tmp; } } void check_dgemm(double *a, double *b, double *result, double *expected, int n) { int i; cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, n, n, 1.0, a, n, b, n, 0.0, result, n); for(i = 0; i < n * n; ++i) { ASSERT_DBL_NEAR_TOL(expected[i], result[i], DOUBLE_EPS); } } CTEST(fork, safety) { int n = 1000; int i; double *a, *b, *c, *d; size_t n_bytes; pid_t fork_pid; pid_t fork_pid_nested; n_bytes = sizeof(*a) * n * n; a = xmalloc(n_bytes); b = xmalloc(n_bytes); c = xmalloc(n_bytes); d = xmalloc(n_bytes); // Put ones in a and b for(i = 0; i < n * n; ++i) { a[i] = 1; b[i] = 1; } // Compute a DGEMM product in the parent process prior to forking to // ensure that the OpenBLAS thread pool is initialized. cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, n, n, 1.0, a, n, b, n, 0.0, c, n); fork_pid = fork(); if (fork_pid == -1) { CTEST_ERR("Failed to fork process."); } else if (fork_pid == 0) { // Compute a DGEMM product in the child process to check that the // thread pool as been properly been reinitialized after the fork. check_dgemm(a, b, d, c, n); // Nested fork to check that the pthread_atfork protection can work // recursively fork_pid_nested = fork(); if (fork_pid_nested == -1) { CTEST_ERR("Failed to fork process."); exit(1); } else if (fork_pid_nested == 0) { check_dgemm(a, b, d, c, n); exit(0); } else { check_dgemm(a, b, d, c, n); int child_status = 0; pid_t wait_pid = wait(&child_status); ASSERT_EQUAL(wait_pid, fork_pid_nested); ASSERT_EQUAL(0, WEXITSTATUS (child_status)); exit(0); } } else { check_dgemm(a, b, d, c, n); // Wait for the child to finish and check the exit code. int child_status = 0; pid_t wait_pid = wait(&child_status); ASSERT_EQUAL(wait_pid, fork_pid); ASSERT_EQUAL(0, WEXITSTATUS (child_status)); } }
{ "alphanum_fraction": 0.6199376947, "avg_line_length": 33.6532258065, "ext": "c", "hexsha": "9e0244305b38526517005f93a26fb2ffaa9e4af4", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "47bf0dba8f7a9cbd559e2f9cabe0bf2c7d3ee7a8", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "fenrus75/OpenBLAS", "max_forks_repo_path": "utest/test_fork.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "47bf0dba8f7a9cbd559e2f9cabe0bf2c7d3ee7a8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "fenrus75/OpenBLAS", "max_issues_repo_path": "utest/test_fork.c", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "47bf0dba8f7a9cbd559e2f9cabe0bf2c7d3ee7a8", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "fenrus75/OpenBLAS", "max_stars_repo_path": "utest/test_fork.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1049, "size": 4173 }
#include "kepler.h" #include <math.h> #include <stdlib.h> #include <stdio.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_math.h> #include <gsl/gsl_roots.h> #define OVERPHASE(x) ( 2.0 * M_PI * floor ( 0.5 + 0.5 * x * M_1_PI ) ) #define DEBUG 0 /****************************************************************************/ struct delta_params { double ecosmu, esinmu; }; static double delta_f ( double delta, void *params ) { struct delta_params * op = ( struct delta_params * ) params; double ecosmu = op->ecosmu; double esinmu = op->esinmu; return ecosmu * sin(delta) + esinmu * cos(delta) - delta; } static double delta_df ( double delta, void *params ) { struct delta_params * op = ( struct delta_params * ) params; double ecosmu = op->ecosmu; double esinmu = op->esinmu; return ecosmu * cos(delta) - esinmu * sin(delta) - 1.0; } static void delta_fdf ( double delta, void *params, double * f, double * df ) { struct delta_params * op = ( struct delta_params * ) params; double ecosmu = op->ecosmu; double esinmu = op->esinmu; double cosdelta = cos(delta); double sindelta = sin(delta); *f = ecosmu * sindelta + esinmu * cosdelta - delta; *df = ecosmu * cosdelta - esinmu * sindelta - 1.0; } double kepler_psiofmu ( double mu, double ecc ) { int status; int iter = 0, max_iter = 100; double x0, x, x_expected; gsl_function_fdf FDF; static gsl_root_fdfsolver * solver; static int solverexists = 0; struct delta_params params = { ecc * cos(mu), ecc * sin(mu) }; if ( ! solverexists ) { solverexists = 1; solver = gsl_root_fdfsolver_alloc ( gsl_root_fdfsolver_newton ); } if ( DEBUG ) printf( "kepler_psiofmu ( mu = %lg, ecc = %lg )\n", mu, ecc ); /* early exit make this more tollerant */ if ( 0.0 == ecc ) return mu; if ( 0.0 == mu - OVERPHASE(mu) ) return 0.0; FDF.f = &delta_f; FDF.df = &delta_df; FDF.fdf = &delta_fdf; FDF.params = &params; x_expected = x = (&params)->esinmu; gsl_root_fdfsolver_set (solver, &FDF, x); if ( DEBUG ) printf ("using %s method\n", gsl_root_fdfsolver_name (solver)); if ( DEBUG ) printf ("%-5s %10s %10s\n", "iter", "root", "err"); do { iter++; status = gsl_root_fdfsolver_iterate (solver); x0 = x; x = gsl_root_fdfsolver_root (solver); status = gsl_root_test_delta (x, x0, 0, 1e-3); if ( DEBUG && status == GSL_SUCCESS ) printf ("Converged:\n"); if ( DEBUG ) printf ("%5d %10.7f %+10.7f\n", iter, x, x - x_expected); } while (status == GSL_CONTINUE && iter < max_iter); if ( DEBUG ) printf( "kepler_psiofmu ( mu = %lg, ecc = %lg ) = %lg\n", mu, ecc, mu+x ); return mu + x; } /****************************************************************************/ double kepler_thetaofmu ( double mu, double ecc ) { double overmu = OVERPHASE(mu), psi, theta; psi = kepler_psiofmu ( mu, ecc ); theta = 2.0 * atan( sqrt((1.0+ecc)/(1.0-ecc)) * tan(0.5*psi) ); return overmu + theta; } /****************************************************************************/ double kepler_rv ( double mu, double ecc, double omega ) { double psi, theta; psi = kepler_psiofmu ( mu, ecc ); theta = 2.0 * atan( sqrt((1.0+ecc)/(1.0-ecc)) * tan(0.5*psi) ); return cos(theta + omega) + ecc*cos(omega); } /****************************************************************************/ double kepler_lite ( double mu, double ecc, double omega ) { double psi, theta; psi = kepler_psiofmu ( mu, ecc ); theta = 2.0 * atan( sqrt((1.0+ecc)/(1.0-ecc)) * tan(0.5*psi) ); return (1.0 - ecc*ecc) * sin(theta + omega) / (1.0 + ecc*cos(theta)); } /****************************************************************************/ double kepler_sep ( double mu, double ecc, double omega, double inc ) { double psi, theta, tmpd; psi = kepler_psiofmu ( mu, ecc ); theta = 2.0 * atan( sqrt((1.0+ecc)/(1.0-ecc)) * tan(0.5*psi) ); tmpd = sin(theta + omega) * sin(inc); tmpd = sqrt(1.0 - tmpd*tmpd); return tmpd * (1.0 - ecc*ecc) / (1.0 + ecc * cos(theta)); } /****************************************************************************/
{ "alphanum_fraction": 0.5503631961, "avg_line_length": 27.1710526316, "ext": "c", "hexsha": "fecfcab6f8aabc1e677c075b2db11d42b3c0ae19", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "26b78a12df53d9a1a477fcf247cbf2dad8c39836", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mrawls/FDBinary-tools", "max_forks_repo_path": "fd3_Jul2014update/kepler.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "26b78a12df53d9a1a477fcf247cbf2dad8c39836", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mrawls/FDBinary-tools", "max_issues_repo_path": "fd3_Jul2014update/kepler.c", "max_line_length": 79, "max_stars_count": 2, "max_stars_repo_head_hexsha": "26b78a12df53d9a1a477fcf247cbf2dad8c39836", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mrawls/FDBinary-tools", "max_stars_repo_path": "fd3_Jul2014update/kepler.c", "max_stars_repo_stars_event_max_datetime": "2020-08-28T14:43:53.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-25T09:45:03.000Z", "num_tokens": 1269, "size": 4130 }
/* * ----------------------------------------------------------------- * pmsr_lib.h * Pairwise Mixing Stirred Reactor Library * Version: 2.0 * Last Update: Oct 1, 2019 * * This is the header file of a computational library with * routines to implement a Pairwise Mixing Stirred Reactor * (PMSR) model. * ----------------------------------------------------------------- * Programmer: Americo Barbosa da Cunha Junior * americo.cunhajr@gmail.com * ----------------------------------------------------------------- * Copyright (c) 2019 by Americo Barbosa da Cunha Junior * ----------------------------------------------------------------- */ #ifndef __PMSR_LIB_H__ #define __PMSR_LIB_H__ #include <gsl/gsl_vector.h> #include <gsl/gsl_rng.h> /* * ------------------------------------------------------------ * Types: struct pmsr, pmsr_wrk * ------------------------------------------------------------ * This structure contains fields of PMSR model. * * last update: Nov 5, 2009 * ------------------------------------------------------------ */ typedef struct pmsr { int *pmsr_idx; /* particles index vector */ gsl_vector **pmsr_ps; /* particle system */ } pmsr_wrk; /*------------------------------------------------------------*/ /* *------------------------------------------------------------ * function prototypes *------------------------------------------------------------ */ void pmsr_title(); int pmsr_input(unsigned long int *seed, unsigned int *Np, unsigned int *Ndt, double *t0, double *delta_t, double *tau_res, double *tau_mix, double *tau_pair, double *Tmax, double *Tmin, double *atol, double *rtol); pmsr_wrk *pmsr_alloc(); int pmsr_init(int Np, int Neq, pmsr_wrk *pmsr); void pmsr_free(int Np, void **pmsr_bl); void pmsr_set_all(int Np, gsl_vector *phi, pmsr_wrk *pmsr); int pmsr_Nexc(int Np, double delta_t, double tau_res); int pmsr_Npair(int Np, double delta_t, double tau_pair); void pmsr_meanvar(int Np, int k, gsl_vector **ps, double *mean, double *var); void pmsr_mixture(int Np, int Neq, double delta_t, double tau_mix, int *idx, gsl_vector **ps); void pmsr_iops(int Np, int Nexc, int Npair, gsl_rng *r, gsl_vector *phi, pmsr_wrk *pmsr); #endif /* __PMSR_LIB_H__ */
{ "alphanum_fraction": 0.4083750895, "avg_line_length": 23.8803418803, "ext": "h", "hexsha": "33eb2f2593edf8c3658279953788aaa7c49d511f", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-12-30T01:44:13.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-15T03:57:44.000Z", "max_forks_repo_head_hexsha": "35b67f798c1c33118c028691f42b98ba06220eeb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "americocunhajr/CRFlowLib", "max_forks_repo_path": "CRFlowLib-2.0/include/pmsr_lib.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "35b67f798c1c33118c028691f42b98ba06220eeb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "americocunhajr/CRFlowLib", "max_issues_repo_path": "CRFlowLib-2.0/include/pmsr_lib.h", "max_line_length": 68, "max_stars_count": 1, "max_stars_repo_head_hexsha": "35b67f798c1c33118c028691f42b98ba06220eeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "americocunhajr/CRFlowLib", "max_stars_repo_path": "CRFlowLib-2.0/include/pmsr_lib.h", "max_stars_repo_stars_event_max_datetime": "2020-12-29T12:56:14.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-29T12:56:14.000Z", "num_tokens": 611, "size": 2794 }
/* Copyright (C) 2002 M. Marques, A. Castro, A. Rubio, G. Bertsch, M. Oliveira 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 2, 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. */ #include <config.h> #include <stdio.h> #include <math.h> #include <stdlib.h> #include <gsl/gsl_sf.h> #include <gsl/gsl_combination.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include "string_f.h" #include <fortran_types.h> /* Numerical threshold for oct_bessel_k0 and oct_bessel_k1 */ #define BESSEL_K_THRES 1.0e2 /* ---------------------- Interface to GSL functions ------------------------ */ /* Special Functions */ double FC_FUNC_(oct_gamma, OCT_GAMMA) (const double *x) { return gsl_sf_gamma(*x); } double FC_FUNC_(oct_incomplete_gamma, OCT_INCOMPLETE_GAMMA) (const double *a, const double *x) { return gsl_sf_gamma_inc_Q(*a, *x); } double FC_FUNC_(oct_sph_bessel, OCT_SPH_BESSEL) (const fint *l, const double*x) { return gsl_sf_bessel_jl(*l, *x); } double FC_FUNC_(oct_bessel, OCT_BESSEL) (const fint *n, const double *x) { return gsl_sf_bessel_Jn(*n, *x); } double FC_FUNC_(oct_bessel_in, OCT_BESSEL_IN) (const fint *n, const double *x) { return gsl_sf_bessel_In(*n, *x); } double FC_FUNC_(oct_bessel_j0, OCT_BESSEL_J0) (const double *x) { return gsl_sf_bessel_J0(*x); } double FC_FUNC_(oct_bessel_j1, OCT_BESSEL_J1) (const double *x) { return gsl_sf_bessel_J1(*x); } double FC_FUNC_(oct_bessel_k0, OCT_BESSEL_K0) (const double *x) { if( *x > BESSEL_K_THRES ) { return 0.0e0; } else { return gsl_sf_bessel_K0(*x); } } double FC_FUNC_(oct_bessel_k1, OCT_BESSEL_K1) (const double *x) { if( *x > BESSEL_K_THRES ) { return 0.0e0; } else { return gsl_sf_bessel_K1(*x); } } /* the GSL headers specify double x, not const double x */ double FC_FUNC_(oct_erfc, OCT_ERFC) (const double *x) { /* avoid floating invalids in the asymptotic limit */ if(*x > 20.0) return 0.0; if(*x < -20.0) return 2.0; /* otherwise call gsl */ return gsl_sf_erfc(*x); } /* the GSL headers specify double x, not const double x */ double FC_FUNC_(oct_erf, OCT_ERF) (const double *x) { /* avoid floating invalids in the asymptotic limit */ if(*x > 20.0) return 1.0; if(*x < -20.0) return -1.0; /* otherwise call gsl */ return gsl_sf_erf(*x); } double FC_FUNC_(oct_legendre_sphplm, OCT_LEGENDRE_SPHPLM) (const fint *l, const int *m, const double *x) { return gsl_sf_legendre_sphPlm(*l, *m, *x); } /* generalized Laguerre polynomials */ double FC_FUNC_(oct_sf_laguerre_n, OCT_SF_LAGUERRE_N) (const int *n, const double *a, const double *x) { return gsl_sf_laguerre_n(*n, *a, *x); } /* Combinations */ void FC_FUNC_(oct_combination_init, OCT_COMBINATION_INIT) (gsl_combination **c, const fint *n, const fint *k) { *c = gsl_combination_calloc (*n, *k); } void FC_FUNC_(oct_combination_next, OCT_COMBINATION_NEXT) (gsl_combination **c, fint *next) { *next = gsl_combination_next (((gsl_combination *)(*c))); } void FC_FUNC_(oct_get_combination, OCT_GET_COMBINATION) (gsl_combination **c, fint *comb) { int i; for (i=0;i< ((gsl_combination *)(*c))->k; i++) { comb[i]=(fint)((gsl_combination *)(*c))->data[i]; } } void FC_FUNC_(oct_combination_end, OCT_COMBINATION_END) (gsl_combination **c) { gsl_combination_free (((gsl_combination *)(*c))); } /* Random Number Generation */ void FC_FUNC_(oct_ran_init, OCT_RAN_INIT) (gsl_rng **r) { gsl_rng_env_setup(); *r = gsl_rng_alloc(gsl_rng_default); } void FC_FUNC_(oct_ran_end, OCT_RAN_END) (gsl_rng **r) { gsl_rng_free(*r); } /* Random Number Distributions */ double FC_FUNC_(oct_ran_gaussian, OCT_RAN_GAUSSIAN) (const gsl_rng **r, const double *sigma) { return gsl_ran_gaussian(*r, *sigma); } double FC_FUNC_(oct_ran_flat, OCT_RAN_FLAT) (const gsl_rng **r, const double *a, const double *b) { return gsl_ran_flat(*r, *a, *b); } void FC_FUNC_(oct_strerror, OCT_STRERROR) (const fint *err, STR_F_TYPE res STR_ARG1) { const char *c; c = gsl_strerror(*err); TO_F_STR1(c, res); }
{ "alphanum_fraction": 0.6843657817, "avg_line_length": 22.6, "ext": "c", "hexsha": "936c5b04ac972e40f7cb87bf8d86f3e81384c7a3", "lang": "C", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2020-05-29T23:24:51.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-22T20:30:46.000Z", "max_forks_repo_head_hexsha": "dcf68a185cdb13708395546b1557ca46aed969f6", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "shunsuke-sato/octopus", "max_forks_repo_path": "src/math/oct_gsl_f.c", "max_issues_count": 1, "max_issues_repo_head_hexsha": "dcf68a185cdb13708395546b1557ca46aed969f6", "max_issues_repo_issues_event_max_datetime": "2020-08-11T19:14:06.000Z", "max_issues_repo_issues_event_min_datetime": "2020-08-11T19:14:06.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "shunsuke-sato/octopus", "max_issues_repo_path": "src/math/oct_gsl_f.c", "max_line_length": 80, "max_stars_count": 4, "max_stars_repo_head_hexsha": "dcf68a185cdb13708395546b1557ca46aed969f6", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "shunsuke-sato/octopus", "max_stars_repo_path": "src/math/oct_gsl_f.c", "max_stars_repo_stars_event_max_datetime": "2019-10-17T06:31:08.000Z", "max_stars_repo_stars_event_min_datetime": "2016-11-17T09:03:11.000Z", "num_tokens": 1473, "size": 4746 }
/* rng/ranlxs.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000 James Theiler, Brian Gough * * 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 2 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <config.h> #include <stdlib.h> #include <gsl/gsl_rng.h> /* This is an implementation of M. Luescher's second generation version of the RANLUX generator. Thanks to Martin Luescher for providing information on this generator. */ static unsigned long int ranlxs_get (void *vstate); static inline double ranlxs_get_double (void *vstate); static void ranlxs_set_lux (void *state, unsigned long int s, unsigned int luxury); static void ranlxs0_set (void *state, unsigned long int s); static void ranlxs1_set (void *state, unsigned long int s); static void ranlxs2_set (void *state, unsigned long int s); static const int next[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0}; static const int snext[24] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0}; static const double sbase = 16777216.0; /* 2^24 */ static const double sone_bit = 1.0 / 16777216.0; /* 1/2^24 */ static const double one_bit = 1.0 / 281474976710656.0; /* 1/2^48 */ static const double shift = 268435456.0; /* 2^28 */ #define RANLUX_STEP(x1,x2,i1,i2,i3) \ x1=xdbl[i1] - xdbl[i2]; \ if (x2 < 0) \ { \ x1-=one_bit; \ x2+=1; \ } \ xdbl[i3]=x2 typedef struct { double xdbl[12], ydbl[12]; /* doubles first so they are 8-byte aligned */ double carry; float xflt[24]; unsigned int ir; unsigned int jr; unsigned int is; unsigned int is_old; unsigned int pr; } ranlxs_state_t; static void increment_state (ranlxs_state_t * state); static void increment_state (ranlxs_state_t * state) { int k, kmax, m; double x, y1, y2, y3; float *xflt = state->xflt; double *xdbl = state->xdbl; double *ydbl = state->ydbl; double carry = state->carry; unsigned int ir = state->ir; unsigned int jr = state->jr; for (k = 0; ir > 0; ++k) { y1 = xdbl[jr] - xdbl[ir]; y2 = y1 - carry; if (y2 < 0) { carry = one_bit; y2 += 1; } else { carry = 0; } xdbl[ir] = y2; ir = next[ir]; jr = next[jr]; } kmax = state->pr - 12; for (; k <= kmax; k += 12) { y1 = xdbl[7] - xdbl[0]; y1 -= carry; RANLUX_STEP (y2, y1, 8, 1, 0); RANLUX_STEP (y3, y2, 9, 2, 1); RANLUX_STEP (y1, y3, 10, 3, 2); RANLUX_STEP (y2, y1, 11, 4, 3); RANLUX_STEP (y3, y2, 0, 5, 4); RANLUX_STEP (y1, y3, 1, 6, 5); RANLUX_STEP (y2, y1, 2, 7, 6); RANLUX_STEP (y3, y2, 3, 8, 7); RANLUX_STEP (y1, y3, 4, 9, 8); RANLUX_STEP (y2, y1, 5, 10, 9); RANLUX_STEP (y3, y2, 6, 11, 10); if (y3 < 0) { carry = one_bit; y3 += 1; } else { carry = 0; } xdbl[11] = y3; } kmax = state->pr; for (; k < kmax; ++k) { y1 = xdbl[jr] - xdbl[ir]; y2 = y1 - carry; if (y2 < 0) { carry = one_bit; y2 += 1; } else { carry = 0; } xdbl[ir] = y2; ydbl[ir] = y2 + shift; ir = next[ir]; jr = next[jr]; } ydbl[ir] = xdbl[ir] + shift; for (k = next[ir]; k > 0;) { ydbl[k] = xdbl[k] + shift; k = next[k]; } for (k = 0, m = 0; k < 12; ++k) { x = xdbl[k]; y2 = ydbl[k] - shift; if (y2 > x) y2 -= sone_bit; y1 = (x - y2) * sbase; xflt[m++] = (float) y1; xflt[m++] = (float) y2; } state->ir = ir; state->is = 2 * ir; state->is_old = 2 * ir; state->jr = jr; state->carry = carry; } static inline double ranlxs_get_double (void *vstate) { ranlxs_state_t *state = (ranlxs_state_t *) vstate; const unsigned int is = snext[state->is]; state->is = is; if (is == state->is_old) increment_state (state); return state->xflt[state->is]; } static unsigned long int ranlxs_get (void *vstate) { return ranlxs_get_double (vstate) * 16777216.0; /* 2^24 */ } static void ranlxs_set_lux (void *vstate, unsigned long int s, unsigned int luxury) { ranlxs_state_t *state = (ranlxs_state_t *) vstate; int ibit, jbit, i, k, m, xbit[31]; double x, y; long int seed; if (s == 0) s = 1; /* default seed is 1 */ seed = s; i = seed & 0xFFFFFFFFUL; for (k = 0; k < 31; ++k) { xbit[k] = i % 2; i /= 2; } ibit = 0; jbit = 18; for (k = 0; k < 12; ++k) { x = 0; for (m = 1; m <= 48; ++m) { y = (double) xbit[ibit]; x += x + y; xbit[ibit] = (xbit[ibit] + xbit[jbit]) % 2; ibit = (ibit + 1) % 31; jbit = (jbit + 1) % 31; } state->xdbl[k] = one_bit * x; } state->carry = 0; state->ir = 0; state->jr = 7; state->is = 23; state->is_old = 0; state->pr = luxury; } static void ranlxs0_set (void *vstate, unsigned long int s) { ranlxs_set_lux (vstate, s, 109); } void ranlxs1_set (void *vstate, unsigned long int s) { ranlxs_set_lux (vstate, s, 202); } static void ranlxs2_set (void *vstate, unsigned long int s) { ranlxs_set_lux (vstate, s, 397); } static const gsl_rng_type ranlxs0_type = {"ranlxs0", /* name */ 0x00ffffffUL, /* RAND_MAX */ 0, /* RAND_MIN */ sizeof (ranlxs_state_t), &ranlxs0_set, &ranlxs_get, &ranlxs_get_double}; static const gsl_rng_type ranlxs1_type = {"ranlxs1", /* name */ 0x00ffffffUL, /* RAND_MAX */ 0, /* RAND_MIN */ sizeof (ranlxs_state_t), &ranlxs1_set, &ranlxs_get, &ranlxs_get_double}; static const gsl_rng_type ranlxs2_type = {"ranlxs2", /* name */ 0x00ffffffUL, /* RAND_MAX */ 0, /* RAND_MIN */ sizeof (ranlxs_state_t), &ranlxs2_set, &ranlxs_get, &ranlxs_get_double}; const gsl_rng_type *gsl_rng_ranlxs0 = &ranlxs0_type; const gsl_rng_type *gsl_rng_ranlxs1 = &ranlxs1_type; const gsl_rng_type *gsl_rng_ranlxs2 = &ranlxs2_type;
{ "alphanum_fraction": 0.5728009607, "avg_line_length": 21.9867986799, "ext": "c", "hexsha": "0a3275defc788925c55116be70af9d4a8276321d", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_forks_event_min_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ICML14MoMCompare/spectral-learn", "max_forks_repo_path": "code/em/treba/gsl-1.0/rng/ranlxs.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ICML14MoMCompare/spectral-learn", "max_issues_repo_path": "code/em/treba/gsl-1.0/rng/ranlxs.c", "max_line_length": 83, "max_stars_count": 14, "max_stars_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ICML14MoMCompare/spectral-learn", "max_stars_repo_path": "code/em/treba/gsl-1.0/rng/ranlxs.c", "max_stars_repo_stars_event_max_datetime": "2021-06-10T11:31:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-12-18T18:09:25.000Z", "num_tokens": 2470, "size": 6662 }
/* code to do weak lensing power spectrum computations Matthew Becker, UofC 2011 */ #include <gsl/gsl_spline.h> #ifndef _WEAKLENS_ #define _WEAKLENS_ typedef struct { int wlNum; double lmin; double lmax; double tmin; double tmax; } weaklensData; extern weaklensData wlData; typedef struct { int initFlag; int currCosmoNum; int currWLNum; double zs1; double zs2; double chis1; double chis2; double chiLim; double sn; double ell; //temp var for integrals gsl_spline *spline; gsl_interp_accel *accel; } _lensPowerSpectra; typedef _lensPowerSpectra *lensPowerSpectra; typedef struct { int initFlag; int currCosmoNum; int currWLNum; lensPowerSpectra lps; double theta; //temp var for integrals gsl_spline *splineP; gsl_interp_accel *accelP; gsl_spline *splineM; gsl_interp_accel *accelM; } _lensCorrFunc; typedef _lensCorrFunc * lensCorrFunc; //functions to compute lensing power and cross spectra double nonlinear_powspec_for_lens(double k, double a); double lens_power_spectrum(double ell, lensPowerSpectra lps); lensPowerSpectra init_lens_power_spectrum(double zs1, double zs2); void free_lens_power_spectrum(lensPowerSpectra lps); //functions to compute lens corr func. double lens_corr_func_minus(double theta, lensCorrFunc lcf); double lens_corr_func_plus(double theta, lensCorrFunc lcf); lensCorrFunc init_lens_corr_func(lensPowerSpectra lps); void free_lens_corr_func(lensCorrFunc lcf); #endif /* _WEAKLENS_ */
{ "alphanum_fraction": 0.7789757412, "avg_line_length": 22.4848484848, "ext": "h", "hexsha": "e2e650ad7f64c3dbfd4cac125da3fde385db97aa", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2017-08-11T17:31:51.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-14T12:17:31.000Z", "max_forks_repo_head_hexsha": "aa7d7cb58f05a36d446e02b45a9117d93eb16556", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "beckermr/cosmocalc", "max_forks_repo_path": "src/weaklens.h", "max_issues_count": 1, "max_issues_repo_head_hexsha": "aa7d7cb58f05a36d446e02b45a9117d93eb16556", "max_issues_repo_issues_event_max_datetime": "2016-04-05T19:36:21.000Z", "max_issues_repo_issues_event_min_datetime": "2016-04-05T19:10:45.000Z", "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "beckermr/cosmocalc", "max_issues_repo_path": "src/weaklens.h", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa7d7cb58f05a36d446e02b45a9117d93eb16556", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "beckermr/cosmocalc", "max_stars_repo_path": "src/weaklens.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 438, "size": 1484 }
/* * ----------------------------------------------------------------- * Utilities Library --- util_lib.h * Version: 1.6180 * Date: Feb 19, 2010 * ----------------------------------------------------------------- * Programmer: Americo Barbosa da Cunha Junior * americo.cunhajr@gmail.com * ----------------------------------------------------------------- * Copyright (c) 2010 by Americo Barbosa da Cunha Junior * * 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 3 of * the License, 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. * * A copy of the GNU General Public License is available in * LICENSE.txt or http://www.gnu.org/licenses/. * ----------------------------------------------------------------- * This is the header file for a library with miscelaneous * functions witch have a lot of applications. * ----------------------------------------------------------------- */ #ifndef __UTIL_LIB_H__ #define __UTIL_LIB_H__ #include <time.h> #include <gsl/gsl_vector.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_rng.h> /* *------------------------------------------------------------ * function prototypes *------------------------------------------------------------ */ int gsl_fprint_vector(FILE* file, gsl_vector *v); int gsl_print_vector(gsl_vector *v); int gsl_print_matrix_line(unsigned int i, gsl_matrix *M); int gsl_print_matrix_column(unsigned int j, gsl_matrix *M); int gsl_print_matrix(gsl_matrix *M); int gsl_rand_vector(gsl_rng *r, gsl_vector *v); int gsl_rand_matrix(gsl_rng *r, gsl_matrix *M); int gsl_diagonal_matrix(gsl_vector *v, gsl_matrix *D); void util_time_used(clock_t cpu_start, clock_t cpu_end, time_t wall_start, time_t wall_end); #endif /* __UTIL_LIB_H__ */
{ "alphanum_fraction": 0.5350649351, "avg_line_length": 28.875, "ext": "h", "hexsha": "9526673c0218e5502bac4668447091d250fdb1df", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-12-30T01:44:13.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-15T03:57:44.000Z", "max_forks_repo_head_hexsha": "35b67f798c1c33118c028691f42b98ba06220eeb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "americocunhajr/CRFlowLib", "max_forks_repo_path": "CRFlowLib-1.0/include/util_lib.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "35b67f798c1c33118c028691f42b98ba06220eeb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "americocunhajr/CRFlowLib", "max_issues_repo_path": "CRFlowLib-1.0/include/util_lib.h", "max_line_length": 68, "max_stars_count": 1, "max_stars_repo_head_hexsha": "35b67f798c1c33118c028691f42b98ba06220eeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "americocunhajr/CRFlowLib", "max_stars_repo_path": "CRFlowLib-1.0/include/util_lib.h", "max_stars_repo_stars_event_max_datetime": "2020-12-29T12:56:14.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-29T12:56:14.000Z", "num_tokens": 469, "size": 2310 }
/* specfunc/gegenbauer.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman * * 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 2 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Author: G. Jungman */ #include <config.h> #include <gsl/gsl_math.h> #include <gsl/gsl_errno.h> #include "gsl_sf_gegenbauer.h" #include "error.h" /* See: [Thompson, Atlas for Computing Mathematical Functions] */ int gsl_sf_gegenpoly_1_e(double lambda, double x, gsl_sf_result * result) { /* CHECK_POINTER(result) */ if(lambda == 0.0) { result->val = 2.0*x; result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val); return GSL_SUCCESS; } else { result->val = 2.0*lambda*x; result->err = 4.0 * GSL_DBL_EPSILON * fabs(result->val); return GSL_SUCCESS; } } int gsl_sf_gegenpoly_2_e(double lambda, double x, gsl_sf_result * result) { /* CHECK_POINTER(result) */ if(lambda == 0.0) { const double txx = 2.0*x*x; result->val = -1.0 + txx; result->err = 2.0 * GSL_DBL_EPSILON * fabs(txx); result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val); return GSL_SUCCESS; } else { result->val = lambda*(-1.0 + 2.0*(1.0+lambda)*x*x); result->err = GSL_DBL_EPSILON * (2.0 * fabs(result->val) + fabs(lambda)); return GSL_SUCCESS; } } int gsl_sf_gegenpoly_3_e(double lambda, double x, gsl_sf_result * result) { /* CHECK_POINTER(result) */ if(lambda == 0.0) { result->val = x*(-2.0 + 4.0/3.0*x*x); result->err = GSL_DBL_EPSILON * (2.0 * fabs(result->val) + fabs(x)); return GSL_SUCCESS; } else { double c = 4.0 + lambda*(6.0 + 2.0*lambda); result->val = 2.0*lambda * x * ( -1.0 - lambda + c*x*x/3.0 ); result->err = GSL_DBL_EPSILON * (2.0 * fabs(result->val) + fabs(lambda * x)); return GSL_SUCCESS; } } int gsl_sf_gegenpoly_n_e(int n, double lambda, double x, gsl_sf_result * result) { /* CHECK_POINTER(result) */ if(lambda <= -0.5 || n < 0) { DOMAIN_ERROR(result); } else if(n == 0) { result->val = 1.0; result->err = 0.0; return GSL_SUCCESS; } else if(n == 1) { return gsl_sf_gegenpoly_1_e(lambda, x, result); } else if(n == 2) { return gsl_sf_gegenpoly_2_e(lambda, x, result); } else if(n == 3) { return gsl_sf_gegenpoly_3_e(lambda, x, result); } else { if(lambda == 0.0 && (x >= -1.0 || x <= 1.0)) { /* 2 T_n(x)/n */ const double z = n * acos(x); result->val = 2.0 * cos(z) / n; result->err = 2.0 * GSL_DBL_EPSILON * fabs(z * result->val); return GSL_SUCCESS; } else { int k; gsl_sf_result g2; gsl_sf_result g3; int stat_g2 = gsl_sf_gegenpoly_2_e(lambda, x, &g2); int stat_g3 = gsl_sf_gegenpoly_3_e(lambda, x, &g3); int stat_g = GSL_ERROR_SELECT_2(stat_g2, stat_g3); double gkm2 = g2.val; double gkm1 = g3.val; double gk = 0.0; for(k=4; k<=n; k++) { gk = (2.0*(k+lambda-1.0)*x*gkm1 - (k+2.0*lambda-2.0)*gkm2) / k; gkm2 = gkm1; gkm1 = gk; } result->val = gk; result->err = 2.0 * GSL_DBL_EPSILON * 0.5 * n * fabs(gk); return stat_g; } } } int gsl_sf_gegenpoly_array(int nmax, double lambda, double x, double * result_array) { int k; /* CHECK_POINTER(result_array) */ if(lambda <= -0.5 || nmax < 0) { GSL_ERROR("domain error", GSL_EDOM); } /* n == 0 */ result_array[0] = 1.0; if(nmax == 0) return GSL_SUCCESS; /* n == 1 */ if(lambda == 0.0) result_array[1] = 2.0*x; else result_array[1] = 2.0*lambda*x; /* n <= nmax */ for(k=2; k<=nmax; k++) { double term1 = 2.0*(k+lambda-1.0) * x * result_array[k-1]; double term2 = (k+2.0*lambda-2.0) * result_array[k-2]; result_array[k] = (term1 - term2) / k; } return GSL_SUCCESS; } /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/ #include "eval.h" double gsl_sf_gegenpoly_1(double lambda, double x) { EVAL_RESULT(gsl_sf_gegenpoly_1_e(lambda, x, &result)); } double gsl_sf_gegenpoly_2(double lambda, double x) { EVAL_RESULT(gsl_sf_gegenpoly_2_e(lambda, x, &result)); } double gsl_sf_gegenpoly_3(double lambda, double x) { EVAL_RESULT(gsl_sf_gegenpoly_3_e(lambda, x, &result)); } double gsl_sf_gegenpoly_n(int n, double lambda, double x) { EVAL_RESULT(gsl_sf_gegenpoly_n_e(n, lambda, x, &result)); }
{ "alphanum_fraction": 0.620480711, "avg_line_length": 25.3897435897, "ext": "c", "hexsha": "ac8b6e57c7b5c9d85063579e06f724641765c88f", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_forks_event_min_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ICML14MoMCompare/spectral-learn", "max_forks_repo_path": "code/em/treba/gsl-1.0/specfunc/gegenbauer.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ICML14MoMCompare/spectral-learn", "max_issues_repo_path": "code/em/treba/gsl-1.0/specfunc/gegenbauer.c", "max_line_length": 81, "max_stars_count": 14, "max_stars_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ICML14MoMCompare/spectral-learn", "max_stars_repo_path": "code/em/treba/gsl-1.0/specfunc/gegenbauer.c", "max_stars_repo_stars_event_max_datetime": "2021-06-10T11:31:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-12-18T18:09:25.000Z", "num_tokens": 1665, "size": 4951 }
#include <gsl/gsl_vector.h> #include <gsl/gsl_multiroots.h>
{ "alphanum_fraction": 0.7666666667, "avg_line_length": 20, "ext": "h", "hexsha": "79a88e26d7607bf962f8188e566acfaef4f044af", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-01-23T01:20:00.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-21T00:57:12.000Z", "max_forks_repo_head_hexsha": "48bbf11afd3237d0984755c74968920ce52c0cd9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "datamole-ai/gomez", "max_forks_repo_path": "gsl-wrapper/gsl-sys/wrapper.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "48bbf11afd3237d0984755c74968920ce52c0cd9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "datamole-ai/gomez", "max_issues_repo_path": "gsl-wrapper/gsl-sys/wrapper.h", "max_line_length": 31, "max_stars_count": 18, "max_stars_repo_head_hexsha": "48bbf11afd3237d0984755c74968920ce52c0cd9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "datamole-ai/gomez", "max_stars_repo_path": "gsl-wrapper/gsl-sys/wrapper.h", "max_stars_repo_stars_event_max_datetime": "2022-01-31T00:31:31.000Z", "max_stars_repo_stars_event_min_datetime": "2021-12-20T19:24:17.000Z", "num_tokens": 19, "size": 60 }
#ifndef SIGNAL_H_ #define SIGNAL_H_ #include <gsl/gsl_statistics_double.h> #include <complex> #include <fftw3.h> #include <math.h> #include <iostream> #include "fourier_transform.h" #include "array.h" #include "rng.h" #include <assert.h> // this is slowly turning into sth that should maybe rather be called // "stochastic processes" rather than signal namespace neurophys { class SpectrumDescriptor { public: virtual double get(const double f) const = 0; }; class WhiteSpectrum: public SpectrumDescriptor { public: WhiteSpectrum(const double s0): s0_(s0) {} virtual double get(const double f) const { return s0_; } private: const double s0_; }; class BandLimitedFlatSpectrum: public SpectrumDescriptor { public: BandLimitedFlatSpectrum(const double s0, const double f0, const double f1): s0_(s0), f0_(f0), f1_(f1) {} virtual double get(const double f) const { return (f >= f0_ && f < f1_) ? s0_ : 0.; } private: const double s0_; const double f0_; const double f1_; }; class PowerLawSpectrum: public SpectrumDescriptor { public: PowerLawSpectrum(const double expo, const double f0, const double f1): expo_(expo), f0_(f0), f1_(f1), A_(0) { // normalization, so that variance = 1 A_ = 1./2 * (1.-expo) / (pow(f1,1.-expo) - expo*pow(f0,1.-expo)); } virtual double get(const double f) const { if (f < f0_) return A_ * pow(f0_, -expo_); else if (f < f1_) return A_ * pow(f, -expo_); else return 0.; } private: const double expo_; const double f0_; const double f1_; double A_; }; namespace signal { Array<double> generate_gaussian(RNG& rng, const C2RFourierTransform& c2rft, const SpectrumDescriptor& spec, const size_t N, const double T); }; } #endif /* SIGNAL_H */
{ "alphanum_fraction": 0.6546336207, "avg_line_length": 22.3614457831, "ext": "h", "hexsha": "1957d114e26d4f81c9b789f390f2b9cb22ebf5a1", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8f641f73bcac2700b476663fe656fcad7d63470d", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "ModelDBRepository/228604", "max_forks_repo_path": "simulation/neurophys/signal.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "8f641f73bcac2700b476663fe656fcad7d63470d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "ModelDBRepository/228604", "max_issues_repo_path": "simulation/neurophys/signal.h", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "8f641f73bcac2700b476663fe656fcad7d63470d", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "ModelDBRepository/228604", "max_stars_repo_path": "simulation/neurophys/signal.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 517, "size": 1856 }
/* @copyright Russell Standish 2000-2013 @author Russell Standish This file is part of EcoLab Open source licensed under the MIT license. See LICENSE for details. */ #include <classdesc_access.h> #include <pack_stl.h> #include <analysis.h> #if defined(GNUSL) #include <gsl/gsl_errno.h> #include <gsl/gsl_odeiv2.h> #endif using namespace ecolab; typedef map<NautyRep,double> archetype; using namespace classdesc; using array_ns::array; struct Gsl_matrix; struct GaussianMarkovModel { /// lags and replications used calculating causal density and ilk int lags; Gsl_matrix* runData; typedef ConcreteGraph<DiGraph> G; G& g; gaussrand gran; GaussianMarkovModel(G& g): lags(10), runData(NULL), g(g) {} ~GaussianMarkovModel(); /// run the model for lags+repetitions steps to populate the matrices void run(TCL_args repetitions); /// output the rundata into a file: each node has separate row, each /// sample column void outputRunData(TCL_args); /// calculate the causal density for a Gaussian Markov process /// running on the network. double causalDensity(); double bipartitionCausalDensity(); }; // RAII data structure for GSL Runge-Kutta algorithm struct RKdata { #if defined(GNUSL) gsl_odeiv2_system sys; gsl_odeiv2_driver* driver; template <class DynSysGen> RKdata(const DynSysGen& dynSys) { sys.function=DynSysGen::RKfunction; sys.dimension=dynSys.dim; sys.params=(void*)&dynSys; const gsl_odeiv2_step_type* stepper=gsl_odeiv2_step_rkf45; driver = gsl_odeiv2_driver_alloc_y_new (&sys, stepper, dynSys.stepMax, dynSys.epsAbs, dynSys.epsRel); gsl_odeiv2_driver_set_hmax(driver, dynSys.stepMax); gsl_odeiv2_driver_set_hmin(driver, dynSys.stepMin); } ~RKdata() {gsl_odeiv2_driver_free(driver);} #else int sys, driver; // dummies, to keep classdesc happy #endif }; // dynamic system network generators template <class DynSys> struct DynSysGen: public DynSys, public NetworkFromTimeSeries { static int RKfunction(double t, const double x[], double f[], void *params) { #if defined(GNUSL) if (params==NULL) return GSL_EBADFUNC; try { ((const DynSys*)params)->f(t,x,f); } catch (std::exception& e) { Tcl_AppendResult(interp(),e.what(),NULL); Tcl_AppendResult(interp(),"\n",NULL); return GSL_EBADFUNC; } return GSL_SUCCESS; #else return 0; #endif } // RK parameters double stepMin; // minimum step size double stepMax; // maximum step size double epsAbs; // absolute error double epsRel; // relative error DynSysGen(): stepMin(1e-5), stepMax(1e-3), epsAbs(1e-3), epsRel(1e-2) { resize(DynSys::dim); n.resize(DynSys::dim,100); } void fillNet(int nsteps) { #if defined(GNUSL) RKdata rkData(*this); vector<double> x(DynSys::dim); for (size_t i=0; i<x.size(); ++i) x[i]=uni.rand(); double t=0; gsl_odeiv2_driver_set_nmax(rkData.driver, 1); for (int i=0; i<nsteps; ++i) { gsl_odeiv2_driver_apply(rkData.driver,&t,1,&x[0]); for (size_t j=0; j<size(); ++j) (*this)[j]<<=x[j]; } constructNet(); #endif } double complexity() const {return ::complexity(net);} urand uni; void random_rewire() {::random_rewire(net,uni);} }; // example dynamical systems defined here struct Lorenz { static const unsigned dim=3; double sigma, rho, beta; Lorenz(): sigma(10), rho(28), beta(8/3.0) {} void f(double t, const double x[3], double y[3]) const { y[0]=sigma*(x[1]-x[0]); y[1]=x[0]*(rho-x[2])-x[1]; y[2]=x[0]*x[1]-beta*x[2]; } }; struct HenonHeiles { static const unsigned dim=4; double lambda; HenonHeiles(): lambda(1) {} void f(double t, const double x[4], double y[4]) const { y[0]=x[1]; y[1]=-x[0]-2*lambda*x[0]*x[2]; y[2]=x[3]; y[3]=-x[2]-lambda*(x[0]*x[0]-x[2]*x[2]); } }; // small 1D cellular automata struct Small1DCA { unsigned rule; ///< rule in 1..255 unsigned nCells; ///< no cells < 0..8*sizeof(state) unsigned long state; /// 3 bit neighbourhood of cell i unsigned nbhd(unsigned i) { if (i==0) return ((state&3)<<1) | ((state>>(nCells-1)) & 1); else if (i==nCells-1) return ((state>>(i-1))&3) | ((state&1)<<2); else return state>>(i-1)&7; } // ratio of 1 bits out of 8 double lambda() { int sum=0; for (int i=0; i<8; ++i) sum+=(rule>>i)&1; return sum/8.0; } void step() { unsigned long newState=0; for (unsigned i=0; i<nCells; ++i) { unsigned n=nbhd(i); newState |= ((rule>>n) & 1) << i; } state=newState; } }; struct Larger1DCA { // number of states a cell can take, and neighbourhood size (always odd) unsigned nStates; int nbhdSz; vector<unsigned> rule,cells; urand uni; size_t nbhd(unsigned i) { size_t r=0; for (int j=-nbhdSz/2; j<=nbhdSz/2; ++j) { int ii=i+j; if (ii<0) ii+=cells.size(); if (ii>int(cells.size())-1) ii-=cells.size(); r*=nStates; r+=cells[ii]; } return r; } // ratio of non-quiescent states in rule to total double lambda() { int sum=0; for (unsigned i=0; i<rule.size(); ++i) sum+=rule[i]>0; return double(sum)/rule.size(); } // resize rule vector, given nStates and nbhdSz void resizeRule() { rule.resize(pow(nStates,nbhdSz)); } // installs a random rule matching a given lambda void initRandomRule(double lambda) { resizeRule(); for (size_t i=0; i<rule.size(); ++i) if (uni.rand()>lambda) rule[i]=0; else rule[i]=(nStates-1)*uni.rand()+1; } void initRandom() { for (size_t i=0; i<cells.size(); ++i) cells[i]=nStates*uni.rand(); } void step() { vector<unsigned> newState(cells.size()); for (unsigned i=0; i<cells.size(); ++i) newState[i] = rule[nbhd(i)]; cells.swap(newState); } }; template <class T> struct NodeMap: map<T,unsigned> { unsigned nextId; NodeMap(): nextId(0) {} unsigned operator[](const T& x) { typename map<T,unsigned>::iterator i=this->find(x); if (i!=this->end()) return i->second; else return map<T,unsigned>::operator[](x)=nextId++; } }; struct NetworkFromSmall1DCA: public Small1DCA, public NetworkFromTimeSeries { void fillNet(int nsteps, int transient) { resize(1); back().clear(); state=pow(2,nCells)*uni.rand(); NodeMap<unsigned long> nodeMap; // throw away the intial transient for (int i=0; i<transient; ++i) step(); for (int i=0; i<nsteps; ++i) { step(); back()<<=nodeMap[state]; // if (nodeMap.nextId>10) // cout << back() << " "; } // cout<<endl; n.resize(1); n[0]=nodeMap.nextId; constructNet(); } double complexity() const {return ::complexity(net);} urand uni; void random_rewire() {::random_rewire(net,uni);} }; struct NetworkFromLarger1DCA: public Larger1DCA, public NetworkFromTimeSeries { void fillNet(int nsteps, int transient) { resize(1); back().clear(); initRandom(); // throw away the intial transient for (int i=0; i<transient; ++i) step(); // map of state to node tag NodeMap<vector<unsigned> > nodeMap; unsigned tagid=1; for (int i=0; i<nsteps; ++i) { step(); back()<<=nodeMap[cells]; } n.resize(1); n[0]=nodeMap.nextId; constructNet(); } double complexity() const {return ::complexity(net);} urand uni; void random_rewire() {::random_rewire(net,uni);} }; class netc_t { archetype archc; Iterator<archetype> ic; bool fill_curr(); CLASSDESC_ACCESS(netc_t); public: netc_t(): weight_dist("one"), gProcess(g) {} unsigned currc; void reset_arch() {archc.clear();} bool first(); bool next(); bool last() {return ic==archc.end();} unsigned size() {return archc.size();} double ODcomplexity() {return ::ODcomplexity(g);} double MA() {return ::MA(g);} void exhaust_search(TCL_args); // void gen_uniq_rand(TCL_args); ConcreteGraph<DiGraph> g; Degrees degrees; void update_degrees() {degrees=::degrees(g);} urand uni; double complexity() {return ::complexity(g);} double lnomega() {BitRep eCanon; return canonical(eCanon,g);} double nauty_complexity() {return ::complexity(NautyRep(g));} double nauty_lnomega() {return NautyRep(g).lnomega();} double saucy_lnomega() {return ::saucy_lnomega(g);} /** race algorithms against each other in separate processes. Best run on a multicore machine with as many or more cores than there are algorithms (currently 4). @param time (in seconds) limiting the race @return the number of te winning algorithm, or 0 if the race times out */ int automorphism_race(TCL_args); /** races variants of the bliss algorithm with different values of the splitting heuristic @param time (in seconds) limiting the race @return the winning splitting heuristic, or -1 if the race times out */ int bliss_race(TCL_args); /// returns a string representation of the algorithm given by the /// integer argument string automorphism_algorithm_name(TCL_args); TCL_obj_ref<random_gen> weight_dist; array<float> weights() { array<float> r; for (ConcreteGraph<DiGraph>::const_iterator e=g.begin(); e!=g.end(); ++e) r<<=e->weight; return r; } void genRandom(TCL_args args) { ErdosRenyi_generate(g,args[0],args[1],uni,*weight_dist);} void prefAttach(TCL_args args) { TCL_obj_ref<random_gen> indegree_dist; indegree_dist.set(args[1]); PreferentialAttach_generate(g,args[0],uni,*indegree_dist,*weight_dist); } void random_rewire() {::random_rewire(g,uni);} /// generate a fully connected directed graph, with each node having /// same indegree and outdegree. Only works if graph degree is odd. void genFullDirected(TCL_args args); bool testAgainstNauty(); GaussianMarkovModel gProcess; DynSysGen<Lorenz> lorenzGen; DynSysGen<HenonHeiles> henonHeilesGen; NetworkFromSmall1DCA small1DCA; NetworkFromLarger1DCA large1DCA; };
{ "alphanum_fraction": 0.6426110072, "avg_line_length": 26.3134715026, "ext": "h", "hexsha": "1b1e4623fee35ec89cccb976152ed2f457634cd5", "lang": "C", "max_forks_count": 10, "max_forks_repo_forks_event_max_datetime": "2021-11-29T19:11:21.000Z", "max_forks_repo_forks_event_min_datetime": "2016-01-17T20:32:04.000Z", "max_forks_repo_head_hexsha": "52751dfa805b67b775ea50e37c5d02c2735ed0d2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "digiperfect/ecolab", "max_forks_repo_path": "models/netcomplexity_model.h", "max_issues_count": 9, "max_issues_repo_head_hexsha": "52751dfa805b67b775ea50e37c5d02c2735ed0d2", "max_issues_repo_issues_event_max_datetime": "2020-01-28T13:18:28.000Z", "max_issues_repo_issues_event_min_datetime": "2016-01-17T21:14:29.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "digiperfect/ecolab", "max_issues_repo_path": "models/netcomplexity_model.h", "max_line_length": 77, "max_stars_count": 10, "max_stars_repo_head_hexsha": "52751dfa805b67b775ea50e37c5d02c2735ed0d2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "digiperfect/ecolab", "max_stars_repo_path": "models/netcomplexity_model.h", "max_stars_repo_stars_event_max_datetime": "2021-02-18T05:03:56.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-19T15:02:23.000Z", "num_tokens": 3041, "size": 10157 }
#ifndef LUM_H #define LUM_H #include <LHAPDF/LHAPDF.h> #include <cmath> #include <iostream> #include <gsl/gsl_chebyshev.h> #include <gsl/gsl_math.h> #include <gsl/gsl_sf_log.h> #include <gsl/gsl_sf_gamma.h> #include <gsl/gsl_sf_zeta.h> #include <gsl/gsl_sf_psi.h> #include <gsl/gsl_sf_dilog.h> #include <algorithm> #include <gsl/gsl_integration.h> class Luminosity { public: typedef std::complex<long double> dcomplex; typedef LHAPDF::PDF* PDF_ptr; Luminosity(PDF_ptr thePDF, double MUF, unsigned short NF = 5, std::size_t order=20); Luminosity(const Luminosity& Lumi); virtual ~Luminosity(); void Cheb_Lum(double ); void c_large(); dcomplex CLum_N(dcomplex N, unsigned channel) const; long double CLum_x(long double z, unsigned channel) const; dcomplex CLum_gg_N(dcomplex N) const { return CLum_N(N,0); } long double CLum_gg_x(long double z) const { return CLum_x(z,0); } dcomplex CLum_gq_N(dcomplex N) const { return CLum_N(N,1); } long double CLum_gq_x(long double z) const { return CLum_x(z,1); } dcomplex CLum_qqbar_N(dcomplex N) const { return CLum_N(N,2); } long double CLum_qqbar_x(long double z) const { return CLum_x(z,2); } dcomplex CLum_qq_N(dcomplex N) const { return CLum_N(N,3); } long double CLum_qq_x(long double z) const { return CLum_x(z,3); } dcomplex CLum_qqbarprime_N(dcomplex N) const { return CLum_N(N,4); } long double CLum_qqbarprime_x(long double z) const { return CLum_x(z,4); } dcomplex CLum_qqprime_N(dcomplex N) const { return CLum_N(N,5); } long double CLum_qqprime_x(long double z) const { return CLum_x(z,5); } double xfxQ(int channel, double x){ return (_PDF->xfxQ(channel,x,_Muf)/x); } inline PDF_ptr get_PDF(){ return _PDF; } inline double get_muf(){ return _Muf; } inline size_t get_n(){ return _n; } struct par_struct{ double Muf; PDF_ptr PDF; double t; unsigned int Nf; }; void setNf(unsigned short NF){ if ( (NF < 1) || (NF > 6) ){ std::cout << "ERROR: INCONGRUENT NUMBER OF FLAVOUR (1-6 ACCEPTED)" << std::endl; NF=5.; } _Nf=NF; } //void cheb_approx(double , double); private: size_t _n; //Order of Chebishev approximation std::array< gsl_cheb_series*,3> Chebseries; std::array< std::vector<double> ,3> C_larges; // std::array< gsl_cheb_series*,6> Chebseries; // std::array< std::vector<double> ,6> C_larges; std::vector< std::vector< double > > _T; LHAPDF::PDF* _PDF; double _Muf; unsigned short _Nf; }; #endif
{ "alphanum_fraction": 0.6793713163, "avg_line_length": 26.2371134021, "ext": "h", "hexsha": "0503385997ddf60b06a3ab153b6ba5df6e887385", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f320d8f4e2ef27af19cf62bded85afce8e0de7a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "gvita/RHEHpt", "max_forks_repo_path": "src/Luminosity.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "f320d8f4e2ef27af19cf62bded85afce8e0de7a7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "gvita/RHEHpt", "max_issues_repo_path": "src/Luminosity.h", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "f320d8f4e2ef27af19cf62bded85afce8e0de7a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "gvita/RHEHpt", "max_stars_repo_path": "src/Luminosity.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 866, "size": 2545 }
//c++ network author : liqi //Nangjing University of Posts and Telecommunications //date 2017.5.21,20:27 #ifndef NETWORK_H #define NETWORK_H #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include <algorithm> #include <stdlib.h> #include <memory.h> #include <fstream> #include <cstring> #include <cblas.h> #include <string> #include <math.h> #include "pBox.h" using namespace cv; void addbias(struct pBox *pbox, mydataFmt *pbias); void image2Matrix(const Mat &image, const struct pBox *pbox); void featurePad(const pBox *pbox, const pBox *outpBox, const int pad); void feature2Matrix(const pBox *pbox, pBox *Matrix, const Weight *weight); void maxPooling(const pBox *pbox, pBox *Matrix, int kernelSize, int stride); void relu(struct pBox *pbox, mydataFmt *pbias); void prelu(struct pBox *pbox, mydataFmt *pbias, mydataFmt *prelu_gmma); void convolution(const Weight *weight, const pBox *pbox, pBox *outpBox, const struct pBox *matrix); void fullconnect(const Weight *weight, const pBox *pbox, pBox *outpBox); void readData(string filename, long dataNumber[], mydataFmt *pTeam[]); long initConvAndFc(struct Weight *weight, int schannel, int lchannel, int kersize, int stride, int pad); void initpRelu(struct pRelu *prelu, int width); void softmax(const struct pBox *pbox); void image2MatrixInit(Mat &image, struct pBox *pbox); void featurePadInit(const pBox *pbox, pBox *outpBox, const int pad); void maxPoolingInit(const pBox *pbox, pBox *Matrix, int kernelSize, int stride); void feature2MatrixInit(const pBox *pbox, pBox *Matrix, const Weight *weight); void convolutionInit(const Weight *weight, const pBox *pbox, pBox *outpBox, const struct pBox *matrix); void fullconnectInit(const Weight *weight, pBox *outpBox); bool cmpScore(struct orderScore lsh, struct orderScore rsh); void nms(vector<struct Bbox> &boundingBox_, vector<struct orderScore> &bboxScore_, const float overlap_threshold, string modelname = "Union"); void refineAndSquareBbox(vector<struct Bbox> &vecBbox, const int &height, const int &width); #endif
{ "alphanum_fraction": 0.7540437678, "avg_line_length": 46.7111111111, "ext": "h", "hexsha": "c10e4fd13463fb407e19af08cffdfe758866cceb", "lang": "C", "max_forks_count": 208, "max_forks_repo_forks_event_max_datetime": "2022-03-31T07:27:08.000Z", "max_forks_repo_forks_event_min_datetime": "2017-05-30T14:42:17.000Z", "max_forks_repo_head_hexsha": "ca62865010917085ec9d7c56c0b3ef13d0cf87c3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "gaojie0105/MTCNN-light", "max_forks_repo_path": "src/network.h", "max_issues_count": 32, "max_issues_repo_head_hexsha": "ca62865010917085ec9d7c56c0b3ef13d0cf87c3", "max_issues_repo_issues_event_max_datetime": "2020-09-20T06:21:59.000Z", "max_issues_repo_issues_event_min_datetime": "2017-05-31T06:08:35.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "gaojie0105/MTCNN-light", "max_issues_repo_path": "src/network.h", "max_line_length": 143, "max_stars_count": 580, "max_stars_repo_head_hexsha": "9d4c6cfdf7072df2b959c30df6ef1dbfabbcb1c4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ChrisKong93/MTCNN-light", "max_stars_repo_path": "src/network.h", "max_stars_repo_stars_event_max_datetime": "2022-03-28T13:26:45.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-30T14:41:03.000Z", "num_tokens": 580, "size": 2102 }
#ifndef ADD_TO_CONFIG_INCLUDE #define ADD_TO_CONFIG_INCLUDE #include <optional> #include <stdexcept> #include <string> #include <utility> #include <vector> #include <gsl/pointers> #include "config/variablesMap.h" #include "base-utils/nonEmptyString.h" namespace execHelper::test { inline void addToConfig(const execHelper::config::SettingsKeys& key, const std::string& value, gsl::not_null<execHelper::config::VariablesMap*> config) { if(!config->add(key, value)) { throw std::runtime_error("Failed to add key " + key.back() + " with value '" + value + "' to config"); } } inline void addToConfig(const execHelper::config::SettingsKeys& key, const NonEmptyString& value, gsl::not_null<execHelper::config::VariablesMap*> config) { if(!config->add(key, *value)) { throw std::runtime_error("Failed to add key " + key.back() + " with value '" + *value + "' to config"); } } template <typename T> inline void addToConfig(const execHelper::config::SettingsKeys& key, const std::vector<T>& value, gsl::not_null<execHelper::config::VariablesMap*> config) { if(!config->add(key, value)) { throw std::runtime_error("Failed to add key " + key.back() + " with first value '" + value.front() + "' to config"); } } inline void addToConfig(const execHelper::config::SettingsKeys& key, bool value, gsl::not_null<execHelper::config::VariablesMap*> config) { if(value) { if(!config->add(key, "yes")) { throw std::runtime_error("Failed to add key " + key.back() + " with value 'true' to config"); } } if(!config->add(key, "no")) { throw std::runtime_error("Failed to add key " + key.back() + " with value 'false' to config"); } } inline void addToConfig(execHelper::config::SettingsKeys key, const std::pair<std::string, std::string>& value, gsl::not_null<execHelper::config::VariablesMap*> config) { key.push_back(value.first); if(!config->add(key, value.second)) { throw std::runtime_error("Failed to add key " + value.first + " with first value '" + value.second + "' to config"); } } template <typename T> inline void addToConfig(const execHelper::config::SettingsKeys& key, const std::optional<T>& value, gsl::not_null<execHelper::config::VariablesMap*> config) { if(value) { addToConfig(key, *value, config); } } template <typename T> inline void addToConfig(const execHelper::config::SettingsKey& key, const T& value, gsl::not_null<execHelper::config::VariablesMap*> config) { addToConfig(execHelper::config::SettingsKeys({key}), value, config); } } // namespace execHelper::test #endif /* ADD_TO_CONFIG_INCLUDE */
{ "alphanum_fraction": 0.5891750897, "avg_line_length": 32.2842105263, "ext": "h", "hexsha": "72fcfc9f89fa18cba403237ea2794c4a28c5f3f2", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-07-03T11:11:19.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-03T11:11:19.000Z", "max_forks_repo_head_hexsha": "8869989a59b352f340406ae8859958bf343be776", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "exec-helper/source", "max_forks_repo_path": "test/utils/include/utils/addToConfig.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "8869989a59b352f340406ae8859958bf343be776", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "exec-helper/source", "max_issues_repo_path": "test/utils/include/utils/addToConfig.h", "max_line_length": 75, "max_stars_count": 1, "max_stars_repo_head_hexsha": "8869989a59b352f340406ae8859958bf343be776", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "exec-helper/source", "max_stars_repo_path": "test/utils/include/utils/addToConfig.h", "max_stars_repo_stars_event_max_datetime": "2020-01-28T13:24:30.000Z", "max_stars_repo_stars_event_min_datetime": "2020-01-28T13:24:30.000Z", "num_tokens": 693, "size": 3067 }
/* * * * The functions in this file are directly taken from https://github.com/s5248/cppconvnet The license and the copying notice are replicated below. ---------- LICENSE ---------- Copyright (c) 2015, BiaoZhi Huang. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of cppconvnet nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------- COPYING --------------- Copyright (c) 2014 The MatConvNet team. Copyright (c) 2015 BiaoZhi Huang. All rights reserved. Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed by the <organization>. The name of the <organization> may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include "common_types.h" #include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <cblas.h> #include "utils.h" static inline int floor_divide(int a, int b) { if (a >= 0) return a / b; else return (a - b + 1) / b; } static inline int ceil_divide(int a, int b) { if (a >= 0) return (a + b - 1) / b; else return a / b; } static inline int min (int a, int b) { return a < b ? a : b; } static void CppConvnetIm2Row(float* stacked, const float* data, int numPatchesX, int numPatchesY, int numRows, const TensorDim input_dim, const TensorDim filter_dim, int stride, int pad) { /* Fill a row of the stacked image at a time. Since patches are stored aint the columns, scanning a row menas visiting all patche once. Each row corresponds to a particular offset within each patch. In this manner, as we fill a row we tend to access spatially adiacent elements in the input image, particulary for small strides. */ float *im2row = stacked; // numRows = KxKXC, numPatchesX = H, numPatchesY = W for (int row = 0; row < numRows; ++row) { /* Get the patch offset corresponding to this row of the stacked image. */ int u = row; int v = u / filter_dim.w; int z = v / filter_dim.h; // filter channel no u %= filter_dim.w; // filter col no v %= filter_dim.h; // filter row no /* Filling this row amounts to visiting all the pixels in the input image that appear at a given offset in the outut patches. Accounting for the subsampling of the output patches and input padding, these pixels are given by x_data(x) = x * m_stride[1] + u - m_pad[2], 0 <= x < numPatchesX y_data(y) = y * m_stride[0] + v - m_pad[0], 0 <= y < numPatchesY z_data(z) = z. Here (x,y) are the spatial indexes of the output patches. Depending on the padding, some of these values will read pixels outised the input image, which should default to 0. In particular, x lands on a x_data(x) within the image if x0 <= x < x1 where: x_data(x) >= 0 <=> x >= (m_pad[2] - u) / stride <=> x >= ceil((m_pad[2] - u) / stride) = x0 x_data(x) <= m_inputDims[1]-1 <=> x <= (m_inputDims[1]-1 + m_pad[2] - u) / stride <=> x <= floor((m_inputDims[1]-1 + m_pad[2] - u) / stride) <=> x < floor((m_inputDims[1]-1 + m_pad[2] - u) / stride) + 1 = x1 and the same for y. Note that, while usually x0 <= x1, there are special cases for which x1 < x0. This is accounted for in the loops below. */ int x0 = min(numPatchesX, (int)ceil_divide(pad - u, stride)); int y0 = min(numPatchesY, (int)ceil_divide(pad - v, stride)); int x1 = min(numPatchesX, (int)floor_divide(input_dim.w - 1 + pad - u, stride) + 1); int y1 = min(numPatchesY, (int)floor_divide(input_dim.h - 1 + pad - v, stride) + 1); int x; int y; for (y = 0; y < y0; ++y) { for (x = 0; x < numPatchesX; ++x) { *stacked++ = 0; } } for (; y < y1; ++y) { for (x = 0; x < x0; ++x) { *stacked++ = 0; } int y_data = y * stride + v - pad; int x_data = x * stride + u - pad; float const * b = data + (z * input_dim.h + y_data) * input_dim.w + x_data; for (; x < x1; ++x) { *stacked++ = *b; b += stride; } for (; x < numPatchesX; ++x) { *stacked++ = 0; } } for (; y < numPatchesY; ++y) { for (x = 0; x < numPatchesX; ++x) { *stacked++ = 0; } } } PrintMat("im2row", im2row, 1, numRows*numPatchesX*numPatchesY, CblasRowMajor); } // Not working for group != 1 bool CppConvnetConvLayer(const float *in_data, const float *filters, const float *bias, TensorDim in_dim, TensorDim filt_dim, int stride, int pad, int group, float *output) { float dataMult=1.0; float outputMult=0.0; TensorDim out_dim; out_dim.w = (in_dim.w + (pad + pad) - filt_dim.w) / stride + 1; out_dim.h = (in_dim.h + (pad + pad) - filt_dim.h) / stride + 1; out_dim.c = filt_dim.n; out_dim.n = in_dim.n; int m_biasDims = out_dim.c; //int numGroups = in_dim.c / filt_dim.c;// assume = 1 bool fullyConnectedMode = (out_dim.w == 1 && out_dim.h == 1 && stride == 1 && pad == 0 && group == 1); if (fullyConnectedMode){ return false; } printf("---------Inputs------\n"); PrintTensor(in_data, in_dim); printf("---------------------\n"); printf("-------Filters-------\n"); PrintTensor(filters, filt_dim); int numFiltersPerGroup = filt_dim.n / group; // M int numOutputPixels = out_dim.w * out_dim.h; // H*W int filtersVolume = filt_dim.w * filt_dim.h * filt_dim.c/group; // K*K*C int tempVolume = numOutputPixels * filtersVolume * group; // H*W*K*K*C --> looks to be size of im2row buffer float* tempMemory = malloc( sizeof(float) *tempVolume); // im2row buffer? float* tempOnes = malloc(sizeof(float)*numOutputPixels); // buffer of size H*W all set to 1 for (int i = 0; i < numOutputPixels; i++) tempOnes[i] = 1.0; for (int image = 0; image < in_dim.n; ++image) { int dataOffset = (in_dim.w * in_dim.h * in_dim.c) * image;// pointer to batch of images int outputOffset = (out_dim.w * out_dim.h * out_dim.c) * image;// pointer to batch of output maps. //under sample CppConvnetIm2Row(tempMemory, in_data + dataOffset, out_dim.w, out_dim.h, filtersVolume*group, in_dim, filt_dim, stride, pad); for (int g = 0; g < group; ++g) { int filterGrpOffset = filtersVolume * numFiltersPerGroup * g;//0 int tempGrpOffset = numOutputPixels * filtersVolume * g;//0 int outputGrpOffset = numOutputPixels * numFiltersPerGroup * g;//0 float alpha = dataMult; float beta = outputMult; //convolution // A -> MxK B-> KxN PrintMat("im2row", tempMemory + tempGrpOffset, numOutputPixels, filtersVolume, CblasColMajor); PrintMat("filters", filters + filterGrpOffset, filtersVolume, numFiltersPerGroup, CblasColMajor); //PrintMat("im2row", tempMemory, 1, filtersVolume* numOutputPixels, CblasColMajor); cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, numOutputPixels/*m = HxW*/, numFiltersPerGroup/*n = M*/, filtersVolume/*k = KxKxC/group*/, alpha, tempMemory + tempGrpOffset, /*A*/ numOutputPixels/*lda*/, filters + filterGrpOffset, // B filtersVolume, // ldb beta, output + outputOffset + outputGrpOffset, // C numOutputPixels // ldc ); } if (bias!=NULL) { float alpha = 1; float beta = 1; int k = 1; //add bias cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, numOutputPixels, m_biasDims, k, alpha, tempOnes, numOutputPixels, bias, k, beta, output + outputOffset, numOutputPixels); } } free(tempMemory); free(tempOnes); return true; }
{ "alphanum_fraction": 0.642417926, "avg_line_length": 37.48046875, "ext": "c", "hexsha": "dfb18a82c875bae36d1f5165d1a2544a963e2264", "lang": "C", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-12-21T14:16:14.000Z", "max_forks_repo_forks_event_min_datetime": "2017-10-24T05:17:21.000Z", "max_forks_repo_head_hexsha": "c5f612d35888e224aa610408a7fc9f08f232147c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "chayitw/convolution-flavors", "max_forks_repo_path": "src/cpp_convnet_conv.c", "max_issues_count": 1, "max_issues_repo_head_hexsha": "c5f612d35888e224aa610408a7fc9f08f232147c", "max_issues_repo_issues_event_max_datetime": "2021-10-16T02:49:23.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-16T02:49:23.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "chayitw/convolution-flavors", "max_issues_repo_path": "src/cpp_convnet_conv.c", "max_line_length": 110, "max_stars_count": 54, "max_stars_repo_head_hexsha": "c5f612d35888e224aa610408a7fc9f08f232147c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "gplhegde/convolution-flavors", "max_stars_repo_path": "src/cpp_convnet_conv.c", "max_stars_repo_stars_event_max_datetime": "2022-01-12T06:38:50.000Z", "max_stars_repo_stars_event_min_datetime": "2017-10-03T18:10:24.000Z", "num_tokens": 2654, "size": 9595 }
/* # This file is part of the Astrometry.net suite. # Licensed under a 3-clause BSD style license - see LICENSE */ #include <stdio.h> #include <assert.h> #include <string.h> #include <math.h> #include <gsl/gsl_matrix_double.h> #include <gsl/gsl_vector_double.h> #include "sip-utils.h" #include "tweak.h" #include "healpix.h" #include "dualtree_rangesearch.h" #include "kdtree_fits_io.h" #include "mathutil.h" #include "log.h" #include "permutedsort.h" #include "gslutils.h" #include "errors.h" #include "fit-wcs.h" // TODO: // // 1. Write the document which explains every step of tweak in detail with // comments relating exactly to the code. // 2. Implement polynomial terms - use order parameter to zero out A matrix // 3. Make it robust to outliers // - Make jitter evolve as fit evolves // - Sigma clipping // 4. Need test image with non-trivial rotation to test CD transpose problem // // // - Put CD inverse into its own function // // BUG? transpose of CD matrix is similar to CD matrix! // BUG? inverse when computing sx/sy (i.e. same transpose issue) // Ability to fit without re-doing correspondences // Split fit x/y (i.e. two fits one for x one for y) #define KERNEL_SIZE 5 #define KERNEL_MARG ((KERNEL_SIZE-1)/2) sip_t* tweak_just_do_it(const tan_t* wcs, const starxy_t* imagexy, const double* starxyz, const double* star_ra, const double* star_dec, const double* star_radec, int nstars, double jitter_arcsec, int order, int inverse_order, int iterations, anbool weighted, anbool skip_shift) { tweak_t* twee = NULL; sip_t* sip = NULL; twee = tweak_new(); twee->jitter = jitter_arcsec; twee->sip->a_order = twee->sip->b_order = order; twee->sip->ap_order = twee->sip->bp_order = inverse_order; twee->weighted_fit = weighted; if (skip_shift) tweak_skip_shift(twee); tweak_push_image_xy(twee, imagexy); if (starxyz) tweak_push_ref_xyz(twee, starxyz, nstars); else if (star_ra && star_dec) tweak_push_ref_ad(twee, star_ra, star_dec, nstars); else if (star_radec) tweak_push_ref_ad_array(twee, star_radec, nstars); else { logerr("Need starxyz, (star_ra and star_dec), or star_radec"); return NULL; } tweak_push_wcs_tan(twee, wcs); tweak_iterate_to_order(twee, order, iterations); // Steal the resulting SIP structure sip = twee->sip; twee->sip = NULL; tweak_free(twee); return sip; } static void get_dydx_range(double* ximg, double* yimg, int nimg, double* xcat, double* ycat, int ncat, double *mindx, double *mindy, double *maxdx, double *maxdy) { int i, j; *maxdx = -1e100; *mindx = 1e100; *maxdy = -1e100; *mindy = 1e100; for (i = 0; i < nimg; i++) { for (j = 0; j < ncat; j++) { double dx = ximg[i] - xcat[j]; double dy = yimg[i] - ycat[j]; *maxdx = MAX(dx, *maxdx); *maxdy = MAX(dy, *maxdy); *mindx = MIN(dx, *mindx); *mindy = MIN(dy, *mindy); } } } static void get_shift(double* ximg, double* yimg, int nimg, double* xcat, double* ycat, int ncat, double mindx, double mindy, double maxdx, double maxdy, double* xshift, double* yshift) { int i, j; int themax, themaxind, ys, xs; // hough transform int hsz = 1000; // hough histogram size (per side) int *hough = calloc(hsz * hsz, sizeof(int)); // allocate bins int kern[] = {0, 2, 3, 2, 0, // approximate gaussian smoother 2, 7, 12, 7, 2, // should be KERNEL_SIZE x KERNEL_SIZE 3, 12, 20, 12, 3, 2, 7, 12, 7, 2, 0, 2, 3, 2, 0}; assert(sizeof(kern) == KERNEL_SIZE * KERNEL_SIZE * sizeof(int)); for (i = 0; i < nimg; i++) { // loop over all pairs of source-catalog objs for (j = 0; j < ncat; j++) { double dx = ximg[i] - xcat[j]; double dy = yimg[i] - ycat[j]; int hszi = hsz - 1; int iy = hszi * ( (dy - mindy) / (maxdy - mindy) ); // compute deltay using implicit floor int ix = hszi * ( (dx - mindx) / (maxdx - mindx) ); // compute deltax using implicit floor // check to make sure the point is in the box if (KERNEL_MARG <= iy && iy < hsz - KERNEL_MARG && KERNEL_MARG <= ix && ix < hsz - KERNEL_MARG) { int kx, ky; for (ky = -2; ky <= 2; ky++) for (kx = -2; kx <= 2; kx++) hough[(iy - ky)*hsz + (ix - kx)] += kern[(ky + 2) * 5 + (kx + 2)]; } } } // find argmax in hough themax = 0; themaxind = -1; for (i = 0; i < hsz*hsz; i++) { if (themax < hough[i]) { themaxind = i; themax = hough[i]; } } // which hough bin is the max? ys = themaxind / hsz; xs = themaxind % hsz; *yshift = (ys / (double)hsz) * (maxdy - mindy) + mindy; *xshift = (xs / (double)hsz) * (maxdx - mindx) + mindx; debug("xs = %d, ys = %d\n", xs, ys); debug("get_shift: mindx=%g, maxdx=%g, mindy=%g, maxdy=%g\n", mindx, maxdx, mindy, maxdy); debug("get_shift: xs=%g, ys=%g\n", *xshift, *yshift); free(hough); } static sip_t* do_entire_shift_operation(tweak_t* t, double rho) { get_shift(t->x, t->y, t->n, t->x_ref, t->y_ref, t->n_ref, rho*t->mindx, rho*t->mindy, rho*t->maxdx, rho*t->maxdy, &t->xs, &t->ys); wcs_shift(&(t->sip->wcstan), t->xs, t->ys); return NULL; } /* This function is intended only for initializing newly allocated tweak * structures, NOT for operating on existing ones.*/ void tweak_init(tweak_t* t) { memset(t, 0, sizeof(tweak_t)); t->sip = sip_create(); } tweak_t* tweak_new() { tweak_t* t = malloc(sizeof(tweak_t)); tweak_init(t); return t; } void tweak_iterate_to_order(tweak_t* t, int maxorder, int iterations) { int order; int k; for (order=1; order<=maxorder; order++) { logverb("\n"); logverb("--------------------------------\n"); logverb("Order %i\n", order); logverb("--------------------------------\n"); t->sip->a_order = t->sip->b_order = order; //t->sip->ap_order = t->sip->bp_order = order; tweak_go_to(t, TWEAK_HAS_CORRESPONDENCES); for (k=0; k<iterations; k++) { logverb("\n"); logverb("--------------------------------\n"); logverb("Iterating tweak: order %i, step %i\n", order, k); t->state &= ~TWEAK_HAS_LINEAR_CD; tweak_go_to(t, TWEAK_HAS_LINEAR_CD); tweak_clear_correspondences(t); } } } #define CHECK_STATE(x) if (state & x) sl_append(s, #x) static char* state_string(unsigned int state) { sl* s = sl_new(4); char* str; CHECK_STATE(TWEAK_HAS_SIP); CHECK_STATE(TWEAK_HAS_IMAGE_XY); CHECK_STATE(TWEAK_HAS_IMAGE_XYZ); CHECK_STATE(TWEAK_HAS_IMAGE_AD); CHECK_STATE(TWEAK_HAS_REF_XY); CHECK_STATE(TWEAK_HAS_REF_XYZ); CHECK_STATE(TWEAK_HAS_REF_AD); CHECK_STATE(TWEAK_HAS_CORRESPONDENCES); CHECK_STATE(TWEAK_HAS_COARSLY_SHIFTED); CHECK_STATE(TWEAK_HAS_FINELY_SHIFTED); CHECK_STATE(TWEAK_HAS_REALLY_FINELY_SHIFTED); CHECK_STATE(TWEAK_HAS_LINEAR_CD); str = sl_join(s, " "); sl_free2(s); return str; } char* tweak_get_state_string(const tweak_t* t) { return state_string(t->state); } #undef CHECK_STATE void tweak_clear_correspondences(tweak_t* t) { if (t->state & TWEAK_HAS_CORRESPONDENCES) { // our correspondences are also now toast assert(t->image); assert(t->ref); assert(t->dist2); il_free(t->image); il_free(t->ref); dl_free(t->dist2); if (t->weight) dl_free(t->weight); t->image = NULL; t->ref = NULL; t->dist2 = NULL; t->weight = NULL; t->state &= ~TWEAK_HAS_CORRESPONDENCES; } assert(!t->image); assert(!t->ref); assert(!t->dist2); assert(!t->weight); } void tweak_clear_on_sip_change(tweak_t* t) { // tweak_clear_correspondences(t); tweak_clear_image_ad(t); tweak_clear_ref_xy(t); tweak_clear_image_xyz(t); } // ref_xy are the catalog star positions in image coordinates void tweak_clear_ref_xy(tweak_t* t) { if (t->state & TWEAK_HAS_REF_XY) { //assert(t->x_ref); free(t->x_ref); //assert(t->y_ref); t->x_ref = NULL; free(t->y_ref); t->y_ref = NULL; t->state &= ~TWEAK_HAS_REF_XY; } assert(!t->x_ref); assert(!t->y_ref); } // radec of catalog stars void tweak_clear_ref_ad(tweak_t* t) { if (t->state & TWEAK_HAS_REF_AD) { assert(t->a_ref); free(t->a_ref); t->a_ref = NULL; assert(t->d_ref); free(t->d_ref); t->d_ref = NULL; t->n_ref = 0; tweak_clear_correspondences(t); tweak_clear_ref_xy(t); t->state &= ~TWEAK_HAS_REF_AD; } assert(!t->a_ref); assert(!t->d_ref); } // image objs in ra,dec according to current tweak void tweak_clear_image_ad(tweak_t* t) { if (t->state & TWEAK_HAS_IMAGE_AD) { assert(t->a); free(t->a); t->a = NULL; assert(t->d); free(t->d); t->d = NULL; t->state &= ~TWEAK_HAS_IMAGE_AD; } assert(!t->a); assert(!t->d); } void tweak_clear_image_xyz(tweak_t* t) { if (t->state & TWEAK_HAS_IMAGE_XYZ) { assert(t->xyz); free(t->xyz); t->xyz = NULL; t->state &= ~TWEAK_HAS_IMAGE_XYZ; } assert(!t->xyz); } void tweak_clear_image_xy(tweak_t* t) { if (t->state & TWEAK_HAS_IMAGE_XY) { assert(t->x); free(t->x); t->x = NULL; assert(t->y); free(t->y); t->y = NULL; t->state &= ~TWEAK_HAS_IMAGE_XY; } assert(!t->x); assert(!t->y); } // tell us (from outside tweak) where the catalog stars are void tweak_push_ref_ad(tweak_t* t, const double* a, const double *d, int n) { assert(a); assert(d); assert(n); tweak_clear_ref_ad(t); assert(!t->a_ref); assert(!t->d_ref); t->a_ref = malloc(sizeof(double) * n); t->d_ref = malloc(sizeof(double) * n); memcpy(t->a_ref, a, n*sizeof(double)); memcpy(t->d_ref, d, n*sizeof(double)); t->n_ref = n; t->state |= TWEAK_HAS_REF_AD; } void tweak_push_ref_ad_array(tweak_t* t, const double* ad, int n) { int i; assert(ad); assert(n); tweak_clear_ref_ad(t); assert(!t->a_ref); assert(!t->d_ref); t->a_ref = malloc(sizeof(double) * n); t->d_ref = malloc(sizeof(double) * n); for (i=0; i<n; i++) { t->a_ref[i] = ad[2*i + 0]; t->d_ref[i] = ad[2*i + 1]; } t->n_ref = n; t->state |= TWEAK_HAS_REF_AD; } static void ref_xyz_from_ad(tweak_t* t) { int i; assert(t->state & TWEAK_HAS_REF_AD); assert(!t->xyz_ref); t->xyz_ref = malloc(sizeof(double) * 3 * t->n_ref); assert(t->xyz_ref); for (i = 0; i < t->n_ref; i++) radecdeg2xyzarr(t->a_ref[i], t->d_ref[i], t->xyz_ref + 3 * i); t->state |= TWEAK_HAS_REF_XYZ; } static void ref_ad_from_xyz(tweak_t* t) { int i, n; assert(t->state & TWEAK_HAS_REF_XYZ); assert(!t->a_ref); assert(!t->d_ref); n = t->n_ref; t->a_ref = malloc(sizeof(double) * n); t->d_ref = malloc(sizeof(double) * n); assert(t->a_ref); assert(t->d_ref); for (i=0; i<n; i++) xyzarr2radecdeg(t->xyz_ref + 3*i, t->a_ref + i, t->d_ref + i); t->state |= TWEAK_HAS_REF_XYZ; } // tell us (from outside tweak) where the catalog stars are void tweak_push_ref_xyz(tweak_t* t, const double* xyz, int n) { assert(xyz); assert(n); tweak_clear_ref_ad(t); assert(!t->xyz_ref); t->xyz_ref = malloc(sizeof(double) * 3 * n); assert(t->xyz_ref); memcpy(t->xyz_ref, xyz, 3*n*sizeof(double)); t->n_ref = n; t->state |= TWEAK_HAS_REF_XYZ; } void tweak_push_image_xy(tweak_t* t, const starxy_t* xy) { tweak_clear_image_xy(t); t->x = starxy_copy_x(xy); t->y = starxy_copy_y(xy); t->n = starxy_n(xy); t->state |= TWEAK_HAS_IMAGE_XY; } void tweak_skip_shift(tweak_t* t) { t->state |= (TWEAK_HAS_COARSLY_SHIFTED | TWEAK_HAS_FINELY_SHIFTED | TWEAK_HAS_REALLY_FINELY_SHIFTED); } // DualTree RangeSearch callback. We want to keep track of correspondences. // Potentially the matching could be many-to-many; we allow this and hope the // optimizer can take care of it. static void dtrs_match_callback(void* extra, int image_ind, int ref_ind, double dist2) { tweak_t* t = extra; image_ind = kdtree_permute(t->kd_image, image_ind); ref_ind = kdtree_permute(t->kd_ref, ref_ind); il_append(t->image, image_ind); il_append(t->ref, ref_ind); dl_append(t->dist2, dist2); if (t->weight) dl_append(t->weight, exp(-dist2 / (2.0 * t->jitterd2))); } void tweak_push_correspondence_indices(tweak_t* t, il* image, il* ref, dl* distsq, dl* weight) { t->image = image; t->ref = ref; t->dist2 = distsq; t->weight = weight; t->state |= TWEAK_HAS_CORRESPONDENCES; } // The jitter is in radians static void find_correspondences(tweak_t* t, double jitter) { double dist; double* data_image = malloc(sizeof(double) * t->n * 3); double* data_ref = malloc(sizeof(double) * t->n_ref * 3); assert(t->state & TWEAK_HAS_IMAGE_XYZ); assert(t->state & TWEAK_HAS_REF_XYZ); tweak_clear_correspondences(t); memcpy(data_image, t->xyz, 3*t->n*sizeof(double)); memcpy(data_ref, t->xyz_ref, 3*t->n_ref*sizeof(double)); t->kd_image = kdtree_build(NULL, data_image, t->n, 3, 4, KDTT_DOUBLE, KD_BUILD_BBOX); t->kd_ref = kdtree_build(NULL, data_ref, t->n_ref, 3, 4, KDTT_DOUBLE, KD_BUILD_BBOX); // Storage for correspondences t->image = il_new(600); t->ref = il_new(600); t->dist2 = dl_new(600); if (t->weighted_fit) t->weight = dl_new(600); dist = rad2dist(jitter); logverb("search radius = %g arcsec\n", rad2arcsec(jitter)); // Find closest neighbours dualtree_rangesearch(t->kd_image, t->kd_ref, RANGESEARCH_NO_LIMIT, dist, FALSE, NULL, dtrs_match_callback, t, NULL, NULL); kdtree_free(t->kd_image); kdtree_free(t->kd_ref); t->kd_image = NULL; t->kd_ref = NULL; free(data_image); free(data_ref); logverb("Number of correspondences: %zu\n", il_size(t->image)); } static double correspondences_rms_arcsec(tweak_t* t, int weighted) { double err2 = 0.0; int i; double totalweight = 0.0; for (i=0; i<il_size(t->image); i++) { double imgxyz[3]; double refxyz[3]; double weight; int refi, imgi; if (weighted && t->weight) weight = dl_get(t->weight, i); else weight = 1.0; totalweight += weight; imgi = il_get(t->image, i); sip_pixelxy2xyzarr(t->sip, t->x[imgi], t->y[imgi], imgxyz); refi = il_get(t->ref, i); radecdeg2xyzarr(t->a_ref[refi], t->d_ref[refi], refxyz); err2 += weight * distsq(imgxyz, refxyz, 3); } return distsq2arcsec( err2 / totalweight ); } #if 0 // in arcseconds^2 on the sky (chi-sq) static double figure_of_merit(tweak_t* t, double *rmsX, double *rmsY) { double sqerr = 0.0; int i; for (i = 0; i < il_size(t->image); i++) { double a, d; double xyzpt[3]; double xyzpt_ref[3]; sip_pixelxy2radec(t->sip, t->x[il_get(t->image, i)], t->y[il_get(t->image, i)], &a, &d); // xref and yref should be intermediate WC's not image x and y! radecdeg2xyzarr(a, d, xyzpt); radecdeg2xyzarr(t->a_ref[il_get(t->ref, i)], t->d_ref[il_get(t->ref, i)], xyzpt_ref); sqerr += distsq(xyzpt, xyzpt_ref, 3); } return rad2arcsec(1)*rad2arcsec(1)*sqerr; } static double figure_of_merit2(tweak_t* t) { // find error in pixels^2 double sqerr = 0.0; int i; for (i = 0; i < il_size(t->image); i++) { double x, y, dx, dy; Unused anbool ok; ok = sip_radec2pixelxy(t->sip, t->a_ref[il_get(t->ref, i)], t->d_ref[il_get(t->ref, i)], &x, &y); assert(ok); dx = t->x[il_get(t->image, i)] - x; dy = t->y[il_get(t->image, i)] - y; sqerr += dx * dx + dy * dy; } // convert to arcsec^2 return sqerr * square(sip_pixel_scale(t->sip)); } #endif // FIXME: adapt this function to take as input the correspondences to use VVVVV // wic is World Intermediate Coordinates, either along ra or dec // i.e. canonical image coordinates // wic_corr is the list of corresponding indexes for wip // pix_corr is the list of corresponding indexes for pixels // pix is raw image pixels (either u or v) // siporder is the sip order up to MAXORDER (defined in sip.h) // the correspondences are passed so that we can stick RANSAC around the whole // thing for better estimation. // Run a polynomial tweak static void do_sip_tweak(tweak_t* t) { sip_t sipout; size_t i, M; // a_order and b_order should be the same! assert(t->sip->a_order == t->sip->b_order); debug("do_sip_tweak starting.\n"); logverb("RMS error of correspondences: %g arcsec\n", correspondences_rms_arcsec(t, 0)); if (t->weighted_fit) logverb("Weighted RMS error of correspondences: %g arcsec\n", correspondences_rms_arcsec(t, 1)); M = il_size(t->image); double* starxyz = malloc(M * 3 * sizeof(double)); double* fieldxy = malloc(M * 2 * sizeof(double)); double* weights = NULL; if (t->weighted_fit) weights = malloc(M * sizeof(double)); int result; for (i=0; i<M; i++) { int refi; int imi; imi = il_get(t->image, i); fieldxy[2*i + 0] = t->x[imi]; fieldxy[2*i + 1] = t->y[imi]; refi = il_get(t->ref, i); radecdeg2xyzarr(t->a_ref[refi], t->d_ref[refi], starxyz + i*3); if (t->weighted_fit) weights[i] = dl_get(t->weight, i); } int doshift = 1; result = fit_sip_wcs(starxyz, fieldxy, weights, M, &(t->sip->wcstan), t->sip->a_order, t->sip->ap_order, doshift, &sipout); free(starxyz); free(fieldxy); free(weights); if (result) { ERROR("fit_sip_wcs failed\n"); return; } memcpy(t->sip, &sipout, sizeof(sip_t)); // recalc using new SIP tweak_clear_on_sip_change(t); tweak_go_to(t, TWEAK_HAS_IMAGE_AD); tweak_go_to(t, TWEAK_HAS_REF_XY); logverb("RMS error of correspondences: %g arcsec\n", correspondences_rms_arcsec(t, 0)); if (t->weighted_fit) logverb("Weighted RMS error of correspondences: %g arcsec\n", correspondences_rms_arcsec(t, 1)); } // Really what we want is some sort of fancy dependency system... DTDS! // Duct-tape dependencey system (DTDS) #define done(x) t->state |= x; return x; #define want(x) \ if (flag == x && t->state & x) \ return x; \ else if (flag == x) #define ensure(x) \ if (!(t->state & x)) { \ return tweak_advance_to(t, x); \ } unsigned int tweak_advance_to(tweak_t* t, unsigned int flag) { want(TWEAK_HAS_IMAGE_AD) { int jj; ensure(TWEAK_HAS_SIP); ensure(TWEAK_HAS_IMAGE_XY); debug("Satisfying TWEAK_HAS_IMAGE_AD\n"); // Convert to ra dec assert(!t->a); assert(!t->d); t->a = malloc(sizeof(double) * t->n); t->d = malloc(sizeof(double) * t->n); for (jj = 0; jj < t->n; jj++) sip_pixelxy2radec(t->sip, t->x[jj], t->y[jj], t->a + jj, t->d + jj); done(TWEAK_HAS_IMAGE_AD); } want(TWEAK_HAS_REF_AD) { if (!(t->a_ref && t->d_ref)) { ensure(TWEAK_HAS_REF_XYZ); debug("Satisfying TWEAK_HAS_REF_AD\n"); ref_ad_from_xyz(t); } assert(t->a_ref && t->d_ref); done(TWEAK_HAS_REF_AD); } want(TWEAK_HAS_REF_XYZ) { if (!t->xyz_ref) { ensure(TWEAK_HAS_REF_AD); debug("Satisfying TWEAK_HAS_REF_XYZ\n"); ref_xyz_from_ad(t); } assert(t->xyz_ref); done(TWEAK_HAS_REF_XYZ); } want(TWEAK_HAS_REF_XY) { int jj; ensure(TWEAK_HAS_REF_AD); debug("Satisfying TWEAK_HAS_REF_XY\n"); assert(t->state & TWEAK_HAS_REF_AD); assert(t->n_ref); assert(!t->x_ref); assert(!t->y_ref); t->x_ref = malloc(sizeof(double) * t->n_ref); t->y_ref = malloc(sizeof(double) * t->n_ref); for (jj = 0; jj < t->n_ref; jj++) { Unused anbool ok; ok = sip_radec2pixelxy(t->sip, t->a_ref[jj], t->d_ref[jj], t->x_ref + jj, t->y_ref + jj); assert(ok); } done(TWEAK_HAS_REF_XY); } want(TWEAK_HAS_IMAGE_XYZ) { int i; ensure(TWEAK_HAS_IMAGE_AD); debug("Satisfying TWEAK_HAS_IMAGE_XYZ\n"); assert(!t->xyz); t->xyz = malloc(3 * t->n * sizeof(double)); for (i = 0; i < t->n; i++) radecdeg2xyzarr(t->a[i], t->d[i], t->xyz + 3*i); done(TWEAK_HAS_IMAGE_XYZ); } want(TWEAK_HAS_COARSLY_SHIFTED) { ensure(TWEAK_HAS_REF_XY); ensure(TWEAK_HAS_IMAGE_XY); debug("Satisfying TWEAK_HAS_COARSLY_SHIFTED\n"); get_dydx_range(t->x, t->y, t->n, t->x_ref, t->y_ref, t->n_ref, &t->mindx, &t->mindy, &t->maxdx, &t->maxdy); do_entire_shift_operation(t, 1.0); tweak_clear_image_ad(t); tweak_clear_ref_xy(t); done(TWEAK_HAS_COARSLY_SHIFTED); } want(TWEAK_HAS_FINELY_SHIFTED) { ensure(TWEAK_HAS_REF_XY); ensure(TWEAK_HAS_IMAGE_XY); ensure(TWEAK_HAS_COARSLY_SHIFTED); debug("Satisfying TWEAK_HAS_FINELY_SHIFTED\n"); // Shrink size of hough box do_entire_shift_operation(t, 0.3); tweak_clear_image_ad(t); tweak_clear_ref_xy(t); done(TWEAK_HAS_FINELY_SHIFTED); } want(TWEAK_HAS_REALLY_FINELY_SHIFTED) { ensure(TWEAK_HAS_REF_XY); ensure(TWEAK_HAS_IMAGE_XY); ensure(TWEAK_HAS_FINELY_SHIFTED); debug("Satisfying TWEAK_HAS_REALLY_FINELY_SHIFTED\n"); // Shrink size of hough box do_entire_shift_operation(t, 0.03); tweak_clear_image_ad(t); tweak_clear_ref_xy(t); done(TWEAK_HAS_REALLY_FINELY_SHIFTED); } want(TWEAK_HAS_CORRESPONDENCES) { ensure(TWEAK_HAS_REF_XYZ); ensure(TWEAK_HAS_IMAGE_XYZ); debug("Satisfying TWEAK_HAS_CORRESPONDENCES\n"); t->jitterd2 = arcsec2distsq(t->jitter); find_correspondences(t, 6.0 * arcsec2rad(t->jitter)); done(TWEAK_HAS_CORRESPONDENCES); } want(TWEAK_HAS_LINEAR_CD) { ensure(TWEAK_HAS_SIP); ensure(TWEAK_HAS_REALLY_FINELY_SHIFTED); ensure(TWEAK_HAS_REF_XY); ensure(TWEAK_HAS_REF_AD); ensure(TWEAK_HAS_IMAGE_XY); ensure(TWEAK_HAS_CORRESPONDENCES); debug("Satisfying TWEAK_HAS_LINEAR_CD\n"); do_sip_tweak(t); tweak_clear_on_sip_change(t); done(TWEAK_HAS_LINEAR_CD); } // small memleak -- but it's a major bug if this happens, so suck it up. logerr("die for dependence: %s\n", state_string(flag)); assert(0); return -1; } void tweak_push_wcs_tan(tweak_t* t, const tan_t* wcs) { memcpy(&(t->sip->wcstan), wcs, sizeof(tan_t)); t->state |= TWEAK_HAS_SIP; } void tweak_go_to(tweak_t* t, unsigned int dest_state) { while (!(t->state & dest_state)) tweak_advance_to(t, dest_state); } #define SAFE_FREE(xx) {free((xx)); xx = NULL;} void tweak_clear(tweak_t* t) { if (!t) return ; SAFE_FREE(t->a); SAFE_FREE(t->d); SAFE_FREE(t->x); SAFE_FREE(t->y); SAFE_FREE(t->xyz); SAFE_FREE(t->a_ref); SAFE_FREE(t->d_ref); SAFE_FREE(t->x_ref); SAFE_FREE(t->y_ref); SAFE_FREE(t->xyz_ref); if (t->sip) { sip_free(t->sip); t->sip = NULL; } il_free(t->image); il_free(t->ref); dl_free(t->dist2); if (t->weight) dl_free(t->weight); t->image = NULL; t->ref = NULL; t->dist2 = NULL; t->weight = NULL; kdtree_free(t->kd_image); kdtree_free(t->kd_ref); } void tweak_free(tweak_t* t) { tweak_clear(t); free(t); }
{ "alphanum_fraction": 0.5739534514, "avg_line_length": 30.6674786845, "ext": "c", "hexsha": "9082b3ad7a8c3fe1550ca63a2adbfb6caabebc9e", "lang": "C", "max_forks_count": 173, "max_forks_repo_forks_event_max_datetime": "2022-03-27T07:27:04.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-08T18:01:54.000Z", "max_forks_repo_head_hexsha": "47849f0443b890c4a875360f881d2e60d1cba630", "max_forks_repo_licenses": [ "Net-SNMP", "Xnet" ], "max_forks_repo_name": "juandesant/astrometry.net", "max_forks_repo_path": "solver/tweak.c", "max_issues_count": 208, "max_issues_repo_head_hexsha": "47849f0443b890c4a875360f881d2e60d1cba630", "max_issues_repo_issues_event_max_datetime": "2022-03-25T15:21:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-08T20:26:38.000Z", "max_issues_repo_licenses": [ "Net-SNMP", "Xnet" ], "max_issues_repo_name": "juandesant/astrometry.net", "max_issues_repo_path": "solver/tweak.c", "max_line_length": 105, "max_stars_count": 460, "max_stars_repo_head_hexsha": "47849f0443b890c4a875360f881d2e60d1cba630", "max_stars_repo_licenses": [ "Net-SNMP", "Xnet" ], "max_stars_repo_name": "juandesant/astrometry.net", "max_stars_repo_path": "solver/tweak.c", "max_stars_repo_stars_event_max_datetime": "2022-03-29T00:37:55.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-06T13:20:04.000Z", "num_tokens": 7575, "size": 25178 }
/* Copyright (c) 2020 Felix Kutzner (github.com/fkutzner) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. */ #pragma once #include <libincmonk/verifier/Clause.h> #include <cassert> #include <cstdint> #include <functional> #include <gsl/span> #include <iterator> #include <limits> #include <optional> #include <ostream> // // Implementation of inline function declared in Clause.h // namespace incmonk::verifier { constexpr Var::Var(uint32_t id) : m_rawValue(id) {} constexpr Var::Var() : m_rawValue{0} {} constexpr auto Var::getRawValue() const -> uint32_t { return m_rawValue; } constexpr auto Var::operator==(Var rhs) const -> bool { return m_rawValue == rhs.m_rawValue; } constexpr auto Var::operator!=(Var rhs) const -> bool { return m_rawValue != rhs.m_rawValue; } constexpr auto Var::operator<(Var rhs) const -> bool { return m_rawValue < rhs.m_rawValue; } constexpr auto Var::operator<=(Var rhs) const -> bool { return m_rawValue <= rhs.m_rawValue; } constexpr auto Var::operator>(Var rhs) const -> bool { return m_rawValue > rhs.m_rawValue; } constexpr auto Var::operator>=(Var rhs) const -> bool { return m_rawValue >= rhs.m_rawValue; } inline auto operator""_Var(unsigned long long cnfValue) -> Var { return Var{static_cast<uint32_t>(cnfValue)}; } constexpr auto Key<Var>::get(Var const& item) -> std::size_t { return item.getRawValue(); } constexpr Lit::Lit(Var v, bool positive) : m_rawValue{(v.getRawValue() << 1) + (positive ? 1 : 0)} { } constexpr Lit::Lit() : m_rawValue{0} {} constexpr auto Lit::getRawValue() const -> uint32_t { return m_rawValue; } constexpr auto Lit::getVar() const -> Var { return Var{m_rawValue >> 1}; } constexpr auto Lit::isPositive() const -> bool { return (m_rawValue & 1) == 1; } constexpr auto Lit::operator-() const -> Lit { return Lit{getVar(), !isPositive()}; } constexpr auto Lit::operator==(Lit rhs) const -> bool { return m_rawValue == rhs.m_rawValue; } constexpr auto Lit::operator!=(Lit rhs) const -> bool { return m_rawValue != rhs.m_rawValue; } constexpr auto Lit::operator<(Lit rhs) const -> bool { return m_rawValue < rhs.m_rawValue; } constexpr auto Lit::operator<=(Lit rhs) const -> bool { return m_rawValue <= rhs.m_rawValue; } constexpr auto Lit::operator>(Lit rhs) const -> bool { return m_rawValue > rhs.m_rawValue; } constexpr auto Lit::operator>=(Lit rhs) const -> bool { return m_rawValue >= rhs.m_rawValue; } inline auto operator""_Lit(unsigned long long cnfValue) -> Lit { Var var{static_cast<uint32_t>(cnfValue)}; return Lit{var, cnfValue > 0}; } constexpr auto Key<Lit>::get(Lit const& item) -> std::size_t { return item.getRawValue(); } inline auto Clause::operator[](size_type idx) noexcept -> Lit& { return *((&m_firstLit) + idx); } inline auto Clause::operator[](size_type idx) const noexcept -> Lit const& { return *((&m_firstLit) + idx); } inline auto Clause::getLiterals() noexcept -> gsl::span<Lit> { return gsl::span<Lit>{&m_firstLit, (&m_firstLit) + m_size}; } inline auto Clause::getLiterals() const noexcept -> gsl::span<Lit const> { return gsl::span<Lit const>{&m_firstLit, (&m_firstLit) + m_size}; } inline auto Clause::size() const noexcept -> size_type { return m_size; } inline auto Clause::empty() const noexcept -> bool { return m_size == 0; } inline void Clause::setState(ClauseVerificationState state) noexcept { uint8_t rawState = static_cast<uint8_t>(state); m_flags = (m_flags & 0xFFFFFFFC) | rawState; } inline auto Clause::getState() const noexcept -> ClauseVerificationState { return static_cast<ClauseVerificationState>(m_flags & 3); } inline auto Clause::getAddIdx() const noexcept -> ProofSequenceIdx { return m_pointOfAdd; } inline Clause::Clause(size_type size, ClauseVerificationState initialState, ProofSequenceIdx addIdx) noexcept : m_size{size}, m_pointOfAdd{addIdx}, m_firstLit{Var{0}, false} { setState(initialState); } inline auto ClauseCollection::Ref::operator==(Ref rhs) const noexcept -> bool { return m_offset == rhs.m_offset; } inline auto ClauseCollection::Ref::operator!=(Ref rhs) const noexcept -> bool { return !(*this == rhs); } inline ClauseCollection::RefIterator::RefIterator(char const* m_allocatorMemory, std::size_t highWaterMark) noexcept : m_clausePtr{m_allocatorMemory}, m_distanceToEnd{highWaterMark}, m_currentRef{} { if (m_distanceToEnd == 0) { m_clausePtr = nullptr; } // Otherwise, the iterator is valid and currentRef is 0, referring to the first clause } inline ClauseCollection::RefIterator::RefIterator() noexcept : m_clausePtr{nullptr}, m_distanceToEnd{0}, m_currentRef{} { } inline auto ClauseCollection::RefIterator::operator*() const noexcept -> Ref const& { assert(m_clausePtr != nullptr && "Dereferencing a non-dereferencaable RefIterator"); return m_currentRef; } inline auto ClauseCollection::RefIterator::operator->() const noexcept -> Ref const* { assert(m_clausePtr != nullptr && "Dereferencing a non-dereferencaable RefIterator"); return &m_currentRef; } inline auto ClauseCollection::RefIterator::operator++(int) noexcept -> RefIterator { RefIterator old = *this; ++(*this); return old; } inline auto ClauseCollection::RefIterator::operator==(RefIterator const& rhs) const noexcept -> bool { return (this == &rhs) || (m_clausePtr == nullptr && rhs.m_clausePtr == nullptr) || (m_clausePtr == rhs.m_clausePtr && m_distanceToEnd == rhs.m_distanceToEnd && m_currentRef == rhs.m_currentRef); } inline auto ClauseCollection::RefIterator::operator!=(RefIterator const& rhs) const noexcept -> bool { return !(*this == rhs); } } namespace std { template <> struct hash<incmonk::verifier::Lit> { auto operator()(incmonk::verifier::Lit lit) const noexcept -> std::size_t { return std::hash<uint32_t>{}(lit.getRawValue()); } }; template <> struct hash<incmonk::verifier::Var> { auto operator()(incmonk::verifier::Var var) const noexcept -> std::size_t { return std::hash<uint32_t>{}(var.getRawValue()); } }; template <> struct hash<incmonk::verifier::ClauseCollection::Ref> { auto operator()(incmonk::verifier::ClauseCollection::Ref ref) const noexcept -> std::size_t { return std::hash<std::size_t>{}(ref.m_offset); } }; }
{ "alphanum_fraction": 0.712872593, "avg_line_length": 25.2733333333, "ext": "h", "hexsha": "8959ea394a7cb03afc8ec164cf9fd8bf6d4a2029", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fc87d8b408cd57a69f0c1bf3579ccbdfd60d7c13", "max_forks_repo_licenses": [ "X11", "MIT" ], "max_forks_repo_name": "fkutzner/IncrementalMonkey", "max_forks_repo_path": "lib/libincmonk/verifier/ClauseImpl.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "fc87d8b408cd57a69f0c1bf3579ccbdfd60d7c13", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11", "MIT" ], "max_issues_repo_name": "fkutzner/IncrementalMonkey", "max_issues_repo_path": "lib/libincmonk/verifier/ClauseImpl.h", "max_line_length": 100, "max_stars_count": 1, "max_stars_repo_head_hexsha": "fc87d8b408cd57a69f0c1bf3579ccbdfd60d7c13", "max_stars_repo_licenses": [ "X11", "MIT" ], "max_stars_repo_name": "fkutzner/IncrementalMonkey", "max_stars_repo_path": "lib/libincmonk/verifier/ClauseImpl.h", "max_stars_repo_stars_event_max_datetime": "2022-02-12T17:58:09.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-12T17:58:09.000Z", "num_tokens": 1917, "size": 7582 }
/*--- Flow*: A Verification Tool for Cyber-Physical Systems. Authors: Xin Chen, Sriram Sankaranarayanan, and Erika Abraham. Email: Xin Chen <chenxin415@gmail.com> if you have questions or comments. The code is released as is under the GNU General Public License (GPL). ---*/ #ifndef INCLUDE_H_ #define INCLUDE_H_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <cmath> #include <mpfr.h> #include <vector> #include <string> #include <list> #include <iostream> #include <cassert> #include <map> #include <time.h> #include <algorithm> #include <gsl/gsl_poly.h> #include <gsl/gsl_vector.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_linalg.h> #include <glpk.h> const int normal_precision = 53; const int high_precision = 256; #define MAX_REFINEMENT_STEPS 49 #define MAX_DYN_REF 49 #define MAX_WIDTH 1e-12 #define THRESHOLD_HIGH 1e-12 #define THRESHOLD_LOW 1e-20 #define STOP_RATIO 0.99 #define ABS_STOP_RATIO 0.99 #define PN 15 // the number of digits printed #define INVALID -1e10 #define UNBOUNDED 1e10 #define DC_THRESHOLD_SEARCH 1e-6 #define DC_THRESHOLD_IMPROV 0.9 #define ID_PRE 0 #define QR_PRE 1 #define UNIFORM 0 #define MULTI 1 #define LAMBDA_DOWN 0.5 #define LAMBDA_UP 1.1 #define NAME_SIZE 100 #define UNSAFE -1 #define SAFE 0 #define UNKNOWN 1 #define COMPLETED_UNSAFE 1 #define COMPLETED_SAFE 2 #define COMPLETED_UNKNOWN 3 #define UNCOMPLETED_SAFE 4 #define UNCOMPLETED_UNSAFE 5 #define UNCOMPLETED_UNKNOWN 6 #define PLOT_GNUPLOT 0 #define PLOT_MATLAB 1 #define PLOT_INTERVAL 0 #define PLOT_OCTAGON 1 #define PLOT_GRID 2 #define INTERVAL_AGGREG 0 #define PARA_AGGREG 1 #define PCA_AGGREG 2 #define MSG_SIZE 100 #define NUM_LENGTH 50 #define ONLY_PICARD 1 #define LOW_DEGREE 2 #define HIGH_DEGREE 3 #define NONPOLY_TAYLOR 4 #define LTI 5 #define LTV 6 #define ONLY_PICARD_SYMB 7 #define NONPOLY_TAYLOR_SYMB 8 #define POLY_DYN 1 #define NONPOLY_DYN 2 #define LTI_DYN 3 #define LTV_DYN 4 #define REFINEMENT_PREC 1e-5 #define RESET_COLOR "\033[0m" #define BLACK_COLOR "\033[30m" #define RED_COLOR "\033[31m" #define GREEN_COLOR "\033[32m" #define BLUE_COLOR "\033[34m" #define BOLD_FONT "\e[1m" const char str_pi_up[] = "3.14159265358979323846264338327950288419716939937511"; const char str_pi_lo[] = "3.14159265358979323846264338327950288419716939937510"; const char outputDir[] = "./outputs/"; const char imageDir[] = "./images/"; const char counterexampleDir[] = "./counterexamples/"; const char local_var_name[] = "local_var_"; const char str_prefix_taylor_picard[] = "taylor picard { "; const char str_prefix_taylor_remainder[] = "taylor remainder { "; const char str_prefix_taylor_polynomial[] = "taylor polynomial { "; const char str_prefix_center[] = "nonpolynomial center { "; const char str_prefix_combination_picard[] = "combination picard { "; const char str_prefix_combination_remainder[] = "combination remainder { "; const char str_prefix_combination_polynomial[] = "combination polynomial { "; const char str_prefix_univariate_polynomial[] = "univariate polynomial { "; const char str_prefix_multivariate_polynomial[] = "multivariate polynomial { "; const char str_prefix_expression[] = "expression { "; const char str_prefix_matrix[] = "matrix { "; const char str_suffix[] = " }"; const char str_counterexample_dumping_name_suffix[] = ".counterexample"; extern int lineNum; extern void parseODE(); #endif /* INCLUDE_H_ */
{ "alphanum_fraction": 0.7447346251, "avg_line_length": 23.4276315789, "ext": "h", "hexsha": "94e0e22513ffb64cc7c6fa280cecf11f7ba17174", "lang": "C", "max_forks_count": 12, "max_forks_repo_forks_event_max_datetime": "2021-10-05T04:16:44.000Z", "max_forks_repo_forks_event_min_datetime": "2018-02-05T15:13:05.000Z", "max_forks_repo_head_hexsha": "763e5817cca2b69f0e96560835a442434980b3a8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "souradeep-111/sherlock_2", "max_forks_repo_path": "flowstar-release/include.h", "max_issues_count": 4, "max_issues_repo_head_hexsha": "763e5817cca2b69f0e96560835a442434980b3a8", "max_issues_repo_issues_event_max_datetime": "2021-01-15T14:32:02.000Z", "max_issues_repo_issues_event_min_datetime": "2018-02-09T07:58:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "souradeep-111/sherlock_2", "max_issues_repo_path": "flowstar-release/include.h", "max_line_length": 80, "max_stars_count": 34, "max_stars_repo_head_hexsha": "bf34fb4713e5140b893c98382055fb963230d69d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "souradeep-111/sherlock", "max_stars_repo_path": "flowstar-release/include.h", "max_stars_repo_stars_event_max_datetime": "2022-03-08T19:21:00.000Z", "max_stars_repo_stars_event_min_datetime": "2018-02-17T14:18:57.000Z", "num_tokens": 1047, "size": 3561 }
#include "../EngineTest.h" #include <Catch2> #include <gsl/gsl_math.h> TEST_CASE("Lag-1 Autocorrelate Function Evaluation Tests", "[lag1]") { // SECTION("Empty Test"){ // requireIsEqual("lag1()", "Insufficient Number of Arguments for Function: lag1"); // } SECTION("`lag1` Test 1"){ requireIsEqual("lag1(3.95, 6.81, -3.05, -1.64, -3.5, 4.95, -8.23, 2.92, 6.06)", -0.2164409953); } SECTION("`autocorr` Test 2"){ requireIsEqual("autocorr(1.61, 7.86, -2.26, -5.62, 8.1, -4.55, 8.97)", -0.5295711223); } SECTION("`autocorr` Test 3"){ requireIsEqual("autocorr(-2.79, -2.1)", -0.5); } SECTION("`autocorr` Test 4"){ requireIsEqual("autocorr(7.27, -7.71, -6.63, -6.2, -0.98, 4.56)", 0.0020706076); } SECTION("`lag1` Test 5"){ requireIsEqual("lag1(8.81, -2.71)", -0.5); } SECTION("`lag1` Test 6"){ requireIsEqual("lag1(5.72, -3.33, 9.2, 2.92, -9.47, -8.05, -3.63)", 0.153525765); } SECTION("`autocorr` Test 7"){ requireIsEqual("autocorr(1.85, 6.89, -9.39, 5.94, -7.5)", -0.657389584); } SECTION("`autocorr` Test 8"){ requireIsEqual("autocorr(-5.14, -7.63, 5.89, 0.62, -1.38, 8.92, 7.13)", 0.1620685975); } SECTION("`autocorr` Test 9"){ requireIsEqual("autocorr(-3.61, 8.1, -9.53, -6.09, -1.66, 2.79, 7.55)", -0.0886150351); } SECTION("`lag1` Test 10"){ requireIsEqual("lag1(-0.76, 0.63)", -0.5); } }
{ "alphanum_fraction": 0.5434929198, "avg_line_length": 26.9636363636, "ext": "h", "hexsha": "8afdf5e341f202f5745eeddccd553670c3ea0de9", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "33cede17001e0a7038f99ea40dd6f9e433cf6454", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "antoniojkim/CalcPlusPlus", "max_forks_repo_path": "Tests/Tests/StatisticsTests/lag1Tests.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "33cede17001e0a7038f99ea40dd6f9e433cf6454", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "antoniojkim/CalcPlusPlus", "max_issues_repo_path": "Tests/Tests/StatisticsTests/lag1Tests.h", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "33cede17001e0a7038f99ea40dd6f9e433cf6454", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "antoniojkim/CalcPlusPlus", "max_stars_repo_path": "Tests/Tests/StatisticsTests/lag1Tests.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 616, "size": 1483 }
/* poly/gsl_poly.h * * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 Brian Gough * * 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 3 of the License, 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 __GSL_POLY_H__ #define __GSL_POLY_H__ #include <stdlib.h> #include <gsl/gsl_inline.h> #include <gsl/gsl_complex.h> #undef __BEGIN_DECLS #undef __END_DECLS #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } #else # define __BEGIN_DECLS /* empty */ # define __END_DECLS /* empty */ #endif __BEGIN_DECLS /* Evaluate polynomial * * c[0] + c[1] x + c[2] x^2 + ... + c[len-1] x^(len-1) * * exceptions: none */ /* real polynomial, real x */ INLINE_DECL double gsl_poly_eval(const double c[], const int len, const double x); /* real polynomial, complex x */ INLINE_DECL gsl_complex gsl_poly_complex_eval (const double c [], const int len, const gsl_complex z); /* complex polynomial, complex x */ INLINE_DECL gsl_complex gsl_complex_poly_complex_eval (const gsl_complex c [], const int len, const gsl_complex z); int gsl_poly_eval_derivs(const double c[], const size_t lenc, const double x, double res[], const size_t lenres); #ifdef HAVE_INLINE INLINE_FUN double gsl_poly_eval(const double c[], const int len, const double x) { int i; double ans = c[len-1]; for(i=len-1; i>0; i--) ans = c[i-1] + x * ans; return ans; } INLINE_FUN gsl_complex gsl_poly_complex_eval(const double c[], const int len, const gsl_complex z) { int i; gsl_complex ans; GSL_SET_COMPLEX (&ans, c[len-1], 0.0); for(i=len-1; i>0; i--) { /* The following three lines are equivalent to ans = gsl_complex_add_real (gsl_complex_mul (z, ans), c[i-1]); but faster */ double tmp = c[i-1] + GSL_REAL (z) * GSL_REAL (ans) - GSL_IMAG (z) * GSL_IMAG (ans); GSL_SET_IMAG (&ans, GSL_IMAG (z) * GSL_REAL (ans) + GSL_REAL (z) * GSL_IMAG (ans)); GSL_SET_REAL (&ans, tmp); } return ans; } INLINE_FUN gsl_complex gsl_complex_poly_complex_eval(const gsl_complex c[], const int len, const gsl_complex z) { int i; gsl_complex ans = c[len-1]; for(i=len-1; i>0; i--) { /* The following three lines are equivalent to ans = gsl_complex_add (c[i-1], gsl_complex_mul (x, ans)); but faster */ double tmp = GSL_REAL (c[i-1]) + GSL_REAL (z) * GSL_REAL (ans) - GSL_IMAG (z) * GSL_IMAG (ans); GSL_SET_IMAG (&ans, GSL_IMAG (c[i-1]) + GSL_IMAG (z) * GSL_REAL (ans) + GSL_REAL (z) * GSL_IMAG (ans)); GSL_SET_REAL (&ans, tmp); } return ans; } #endif /* HAVE_INLINE */ /* Work with divided-difference polynomials, Abramowitz & Stegun 25.2.26 */ int gsl_poly_dd_init (double dd[], const double x[], const double y[], size_t size); INLINE_DECL double gsl_poly_dd_eval (const double dd[], const double xa[], const size_t size, const double x); #ifdef HAVE_INLINE INLINE_FUN double gsl_poly_dd_eval(const double dd[], const double xa[], const size_t size, const double x) { size_t i; double y = dd[size - 1]; for (i = size - 1; i--;) y = dd[i] + (x - xa[i]) * y; return y; } #endif /* HAVE_INLINE */ int gsl_poly_dd_taylor (double c[], double xp, const double dd[], const double x[], size_t size, double w[]); /* Solve for real or complex roots of the standard quadratic equation, * returning the number of real roots. * * Roots are returned ordered. */ int gsl_poly_solve_quadratic (double a, double b, double c, double * x0, double * x1); int gsl_poly_complex_solve_quadratic (double a, double b, double c, gsl_complex * z0, gsl_complex * z1); /* Solve for real roots of the cubic equation * x^3 + a x^2 + b x + c = 0, returning the * number of real roots. * * Roots are returned ordered. */ int gsl_poly_solve_cubic (double a, double b, double c, double * x0, double * x1, double * x2); int gsl_poly_complex_solve_cubic (double a, double b, double c, gsl_complex * z0, gsl_complex * z1, gsl_complex * z2); /* Solve for the complex roots of a general real polynomial */ typedef struct { size_t nc ; double * matrix ; } gsl_poly_complex_workspace ; gsl_poly_complex_workspace * gsl_poly_complex_workspace_alloc (size_t n); void gsl_poly_complex_workspace_free (gsl_poly_complex_workspace * w); int gsl_poly_complex_solve (const double * a, size_t n, gsl_poly_complex_workspace * w, gsl_complex_packed_ptr z); __END_DECLS #endif /* __GSL_POLY_H__ */
{ "alphanum_fraction": 0.6661585366, "avg_line_length": 29.1555555556, "ext": "h", "hexsha": "fa40a69469f05bc8c2c635e3988cb12f1a58de2d", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-08-30T20:40:25.000Z", "max_forks_repo_forks_event_min_datetime": "2020-08-30T20:40:25.000Z", "max_forks_repo_head_hexsha": "2c2e7c85f8414cb0e654cb82e9686cce5e75c63a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ielomariala/Hex-Game", "max_forks_repo_path": "gsl-2.6/gsl/gsl_poly.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "2c2e7c85f8414cb0e654cb82e9686cce5e75c63a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ielomariala/Hex-Game", "max_issues_repo_path": "gsl-2.6/gsl/gsl_poly.h", "max_line_length": 115, "max_stars_count": null, "max_stars_repo_head_hexsha": "2c2e7c85f8414cb0e654cb82e9686cce5e75c63a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ielomariala/Hex-Game", "max_stars_repo_path": "gsl-2.6/gsl/gsl_poly.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1427, "size": 5248 }
//setzt constanten auf #define EXTERN_VARIABLES #include <stdio.h> #include <math.h> #include <gsl/gsl_sf_bessel.h> #include "global.h" #include "utility.h" #include "steppmethods.h" #include <gsl/gsl_cblas.h> #include <time.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <omp.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> void Set_Target_Length(double * TARGET_LENGTH, double volfrac, void (*Stepper_Method)(int N, double x[N/2] , double v[N/2], double a[N/2], double *t, void (*deriv) (double *y, double *ans, double t,int N)), void (*Poti_Handle) (double *y, double *ans, double t,int N)) { int FLAG = 1; *TARGET_LENGTH = 0.0; if (Stepper_Method == VVerlet_Step_deriv) { *TARGET_LENGTH = 0.0; printf(" No Targets\n"); FLAG = 0; } //if (Stepper_Method == VVerlet_Step_Target_Circle) //{ // *TARGET_LENGTH = LATTICE_SPACING * sqrt(volfrac/ M_PI); // printf(" Targets set to hard circles\n"); //} if (Stepper_Method == VVerlet_Step_hardsphere_reflect) { *TARGET_LENGTH = LATTICE_SPACING * sqrt(volfrac/ M_PI); printf(" Targets set to hard circles\n"); FLAG = 0; } if (Stepper_Method == VVerlet_Step_hardsphere_reflect_Kupf) { *TARGET_LENGTH = LATTICE_SPACING * sqrt(volfrac/ M_PI); printf(" Targets set to hard circles Kupferman \n"); FLAG = 0; } if (Stepper_Method == VVerlet_Step_hardsphere_reflect_all) { *TARGET_LENGTH = LATTICE_SPACING * sqrt(volfrac/ M_PI); printf(" Targets set to hard circles, reflect ALL particles\n"); FLAG = 0; } if (Stepper_Method == VVerlet_Step_deriv_Kupf) { *TARGET_LENGTH = 0.0; printf(" No Targets\n, Kupfermann bath"); FLAG = 0; } if (Stepper_Method == VVerlet_Step_deriv_Box) { //*TARGET_LENGTH = LATTICE_SPACING * sqrt(volfrac/ M_PI/5.0); //printf(" Targets set to soft Yukawa circles in 3 per pore corner\n"); *TARGET_LENGTH = 0; FLAG = 0; if (DIM > 1) { printf("wrong Dimension, please switch to 1d"); exit(1); } if (volfrac > 0.0) { printf("no need for volume fractions >0 \n"); exit(1); } printf("box set up with hard wall \n"); } if(FLAG) { printf("Kein bekannter Stepper in global, cannot set tarhet length!\n"); exit(1); } } void Constants(){ // call to setup the bathh parameters and give rudimentary output for the run int i; OUTPUT_FLAG = 1; printf ("OSSZI = %d DIM =%d ORDER =%d \n", OSSZI, DIM, ORDER); printf ("KBOLTZ = %e \nTIME_STEPS =%f \nTIME_END =%f \n", KBOLTZ, TIME_STEPS, TIME_END); for(i=0;i<OSSZI;i++){ coupling[i] = 0.0; } for(i=0;i<OSSZI;i++){ ommega[i] = 0.0; } for(i=0;i<OSSZI;i++){ massq[i] = 1.0; } for(i=0;i<ORDER;i++){ y[i] = 1.0; } printf("ALPHA = %1.2E GAMMA = %1.2E mass = %1.2E \n", ALPHA, GAMMA, mass); printf("NUMBER_TO_INF = %d \nTIME_ARRIVAL =%1.2E \n ", NUMBER_TO_INF, TIME_ARRIVAL); printf("Startbedingungen = "); printf("%s",LABEL); printf("\n"); if (!(OMMEGA_READ_BINARY)) { // random Number Preparation for Taus GSL genrator gsl_rng * r; const gsl_rng_type * T; gsl_rng_env_setup(); T = gsl_rng_taus2; r = gsl_rng_alloc (T); gsl_rng_set(r, time(NULL)); // Seed with time // Random number end // Ommega_Setup(r); gsl_rng_free (r); }else // read in from ommega.dat { FILE *fp; fp = fopen("ommega.dat", "r"); for (i=0;i<OSSZI;i++) { if (fscanf(fp, "%lf", &ommega[i]) != 1) { printf("ERROT READING ommega.dat"); break; } } fclose(fp); printf("read in ommega.dat\n"); } if(VIRTUAL_FLAG) printf("Virtuelles Teilchen benutzt, ohne Badrückkopplung"); Gamma_Setup(coupling); double ommega_max = ommega[cblas_idamax(OSSZI, ommega, 1)]; double coupling_max = coupling[cblas_idamax(OSSZI, coupling, 1)]; printf("MAX coupling = %1.2e\n",coupling_max); if(!(MAXSTEPSIZE_BINARY)) { MAXSTEPSIZE = (2*M_PI/ommega[cblas_idamax(OSSZI, ommega, 1)] * MAXSTEPSIZEMULT); printf("MAXSTEPSIZE = %1.2e set according to smallest period times %3.3e\n",MAXSTEPSIZE, MAXSTEPSIZEMULT); }else { MAXSTEPSIZE = (MAXSTEPSIZEMULT / (double) OSSZI); printf("MAXSTEPSIZE = %1.2e set according to OSSZInr times Stepsize dt = %3.3e\n",MAXSTEPSIZE, MAXSTEPSIZEMULT); } Sum_Method = SUMMATION_METHOD; Stepper_Method = STEPPER_METHOD; Poti_Handle = POTI_HANDLE; int m = ipow(NUMBER_TO_INF,DIM); int n = DIM; // Setze Gitter auf auf globale Matrix POSITIONS POSITIONS = (double **) malloc(m * sizeof(int *)); POSITIONS[0] = (double *) malloc(m* n * sizeof(int)); for (i=1; i<m; i++) POSITIONS[i] = POSITIONS[0] + n *i; vec_zero_i(lattice_position,DIM); printf("lattice allocated, current lattice cell set to zero\n"); TARGET_CONTACT = 0; OUTPUT_FLAG = 0; // subsequent setup calls should not display text printf("Running on %d threads, optimally DIM = %d\n", THREADS, DIM); // set masses for chosen type of coupling if( !(KUPF_BINARY) ) { for (int osi = 0; osi < OSSZI; osi ++) { massq[osi] = 1.0; } printf("Set all masses équal\n"); }else { for (int osi = 0; osi < OSSZI; osi ++) { massq[osi] = coupling[osi] / ommega[osi] / ommega[osi]; } printf("Set all masses according to k = m w^2l\n"); } // Setup masses of bath for simpsons rule, split ends, odd and even parts if (SIMPSON_BINARY) { for (int osi = 1; osi < OSSZI/2-1; osi ++) { massq[osi * 2] *= 2.0/3.0; massq[osi * 2 + 1] *= 4.0/3.0; } massq[0] *= 1.0/3.0;; massq[OSSZI-1] *= 1.0/3.0; if (KUPF_BINARY) { for (int osi = 0; osi < OSSZI; osi ++) { coupling[osi] = massq[osi] * ommega[osi] * ommega[osi]; } } } }
{ "alphanum_fraction": 0.6365235749, "avg_line_length": 27.0666666667, "ext": "c", "hexsha": "9e0b2f1b28b55dfb5f230c3f1c6a212176b09067", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8cacd50b7d307aeaa503b5a2f41cef4300f15a3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nowottnm/KAC_ZWANZIG_SIM", "max_forks_repo_path": "constants.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8cacd50b7d307aeaa503b5a2f41cef4300f15a3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nowottnm/KAC_ZWANZIG_SIM", "max_issues_repo_path": "constants.c", "max_line_length": 153, "max_stars_count": null, "max_stars_repo_head_hexsha": "b8cacd50b7d307aeaa503b5a2f41cef4300f15a3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nowottnm/KAC_ZWANZIG_SIM", "max_stars_repo_path": "constants.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2059, "size": 5684 }
#include <math.h> #include <stdlib.h> #include <stdio.h> #include <gsl/gsl_math.h> #include <gsl/gsl_integration.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_odeiv.h> #include "growthfactor.h" //Code to calculate the linear growth factor D, and linear growth rate, f. Where a linear perturbation delta grows as //delta(a') = delta(a)*(D(a')/D(a))^2 and f = dlnD/dlna //Note anyone using Komatsu's CRL library should note: growth_factor_crl = D *(1+z) and growth_rate_crl = f/(1+z) double D; double linear_f; double w0,wa; double omega_m,omega_lambda; #define LIMIT_SIZE 1000 int get_growthfactor(double a,double om, double w, double w2, double *gf) { w0 = w; wa = w2; omega_m = om; omega_lambda = 1.0 - omega_m; growth_de(a,gf); return 0; } // 2 parameter dark energy equation of state double w (double a) { return w0 + (1.0-a)*wa; } double w_int(double z, void *param) { return (1. + w(1./(z+1)) )/( 1. + z); } double Xde_int (double a,void *params ) { if (a == 0.) a = 1e-3; double Xde_int = w(a)/a; return Xde_int; } double Xde (double a) { gsl_integration_workspace * worksp = gsl_integration_workspace_alloc (LIMIT_SIZE); gsl_function F; F.function = &Xde_int; F.params =0; double integral,error; if (a == 0.) a = 1e-3; gsl_integration_qags (&F, a, 1, 1.0e-20, 1.0e-10, LIMIT_SIZE,worksp, &integral, &error); gsl_integration_workspace_free (worksp); return omega_m/(1.-omega_m)*exp(-3.*integral); } int func (double t, const double y[], double f[], void *params) { double mu = *(double *)params; f[0] = y[1]; f[1] = -( 3.5 - 1.5 * w(t)/( 1 + Xde(t) ) )*y[1]/t - 1.5 * ( 1 - w(t) )/( 1 + Xde(t))*(y[0]/t/t); return GSL_SUCCESS; } int jac (double t, const double y[], double *dfdy, double dfdt[], void *params) { double mu = *(double *)params; gsl_matrix_view dfdy_mat = gsl_matrix_view_array (dfdy, 2, 2); gsl_matrix * m = &dfdy_mat.matrix; gsl_matrix_set (m, 0, 0, 0.0); //dy1/dx1 gsl_matrix_set (m, 0, 1, 1.0); gsl_matrix_set (m, 1, 0, - 1.5 * ( 1 - w(t) )/( 1 + Xde(t))*(1./t/t)); gsl_matrix_set (m, 1, 1, -( 3.5 - 1.5 * w(t)/( 1 + Xde(t) ) )/t); dfdt[0] = 0.0; dfdt[1] = 0.0; return GSL_SUCCESS; } double growth_de (double a, double *gf) { const gsl_odeiv_step_type * T = gsl_odeiv_step_rk4; gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, 2); gsl_odeiv_control * c = gsl_odeiv_control_y_new (1e-6, 0.0); gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc (2); double mu = 10; gsl_odeiv_system sys = {func, jac, 2, &mu}; double t =1.e-3, t1 = a; double h = 1e-6; double y[2] = {1.,0.}; while (t < t1) { int status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t1, &h, y); if (status != GSL_SUCCESS) break; } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (s); // return y[0]*a; //D growth factor // return y[1]*a*a/(y[0]*a) +1.; // f = d ln D/ d ln a gf[0] = y[0]*a; gf[1] = y[1]*a*a/(y[0]*a) +1.; return y[0]*a; }
{ "alphanum_fraction": 0.6145833333, "avg_line_length": 24, "ext": "c", "hexsha": "ba43b19a0dd76b205c65886c96b7d9899733effd", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-06-11T15:29:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-11T15:29:43.000Z", "max_forks_repo_head_hexsha": "07e5d308c6a8641a369a3e0b8d13c4104988cd2b", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "ktanidis2/Modified_CosmoSIS_for_galaxy_number_count_angular_power_spectra", "max_forks_repo_path": "cosmosis-standard-library/structure/growth_factor/growthfactor.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "07e5d308c6a8641a369a3e0b8d13c4104988cd2b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "ktanidis2/Modified_CosmoSIS_for_galaxy_number_count_angular_power_spectra", "max_issues_repo_path": "cosmosis-standard-library/structure/growth_factor/growthfactor.c", "max_line_length": 117, "max_stars_count": 1, "max_stars_repo_head_hexsha": "07e5d308c6a8641a369a3e0b8d13c4104988cd2b", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "ktanidis2/Modified_CosmoSIS_for_galaxy_number_count_angular_power_spectra", "max_stars_repo_path": "cosmosis-standard-library/structure/growth_factor/growthfactor.c", "max_stars_repo_stars_event_max_datetime": "2021-09-15T10:10:26.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-15T10:10:26.000Z", "num_tokens": 1155, "size": 3072 }
#pragma once //#include <gsl/string_span> namespace Util { //static gsl::string_span<> toLower(gsl::string_span<> const&); }; // namespace util
{ "alphanum_fraction": 0.7103448276, "avg_line_length": 24.1666666667, "ext": "h", "hexsha": "6bb4743b08bdc06b784e3d6aff7d1830981dc1d8", "lang": "C", "max_forks_count": 233, "max_forks_repo_forks_event_max_datetime": "2022-03-28T23:12:33.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-11T03:03:00.000Z", "max_forks_repo_head_hexsha": "75dccc348ef7a136e916a8231f266c62fb71ca96", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "TimScriptov/MCPELauncher", "max_forks_repo_path": "jni/mcpe/util.h", "max_issues_count": 1334, "max_issues_repo_head_hexsha": "75dccc348ef7a136e916a8231f266c62fb71ca96", "max_issues_repo_issues_event_max_datetime": "2022-03-18T14:39:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-01T07:40:35.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "TimScriptov/MCPELauncher", "max_issues_repo_path": "jni/mcpe/util.h", "max_line_length": 64, "max_stars_count": 796, "max_stars_repo_head_hexsha": "146a78743f851728a803468083dbd2a68304f923", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ProtectorYT364/BlockLauncher", "max_stars_repo_path": "jni/mcpe/util.h", "max_stars_repo_stars_event_max_datetime": "2022-03-21T10:49:17.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-03T04:33:44.000Z", "num_tokens": 37, "size": 145 }
#ifndef LIC_METHOD_DEFINITION #define LIC_METHOD_DEFINITION #include <gsl/gsl> #include "Metadata.h" namespace lic { class MethodDefinition : Metadata { public: MethodDefinition(Assembly& assembly, MetadataTable table, size_t rid, gsl::byte* row); ~MethodDefinition(); const char* Name() const; const gsl::byte* Code() const; }; } #endif // !LIC_METHOD_DEFINITION
{ "alphanum_fraction": 0.7235142119, "avg_line_length": 16.125, "ext": "h", "hexsha": "f7fa2907dd7cc81d5681ce656d1d51895326c56f", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5ad4a7014673bb60b748390856e0c7cb11eaca09", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "roberthusak/lic", "max_forks_repo_path": "src/loader/MethodDefinition.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "5ad4a7014673bb60b748390856e0c7cb11eaca09", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "roberthusak/lic", "max_issues_repo_path": "src/loader/MethodDefinition.h", "max_line_length": 90, "max_stars_count": 1, "max_stars_repo_head_hexsha": "5ad4a7014673bb60b748390856e0c7cb11eaca09", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "roberthusak/lic", "max_stars_repo_path": "src/loader/MethodDefinition.h", "max_stars_repo_stars_event_max_datetime": "2017-05-18T11:44:16.000Z", "max_stars_repo_stars_event_min_datetime": "2017-05-18T11:44:16.000Z", "num_tokens": 90, "size": 387 }
#ifndef __GSL_MATRIX_H__ #define __GSL_MATRIX_H__ #if !defined( GSL_FUN ) # if !defined( GSL_DLL ) # define GSL_FUN extern # elif defined( BUILD_GSL_DLL ) # define GSL_FUN extern __declspec(dllexport) # else # define GSL_FUN extern __declspec(dllimport) # endif #endif #include <gsl/gsl_matrix_complex_long_double.h> #include <gsl/gsl_matrix_complex_double.h> #include <gsl/gsl_matrix_complex_float.h> #include <gsl/gsl_matrix_long_double.h> #include <gsl/gsl_matrix_double.h> #include <gsl/gsl_matrix_float.h> #include <gsl/gsl_matrix_ulong.h> #include <gsl/gsl_matrix_long.h> #include <gsl/gsl_matrix_uint.h> #include <gsl/gsl_matrix_int.h> #include <gsl/gsl_matrix_ushort.h> #include <gsl/gsl_matrix_short.h> #include <gsl/gsl_matrix_uchar.h> #include <gsl/gsl_matrix_char.h> #endif /* __GSL_MATRIX_H__ */
{ "alphanum_fraction": 0.7413394919, "avg_line_length": 24.0555555556, "ext": "h", "hexsha": "560f33138316d624eb3d54e51b55167c56a2d8ab", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-14T12:31:02.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-20T16:22:57.000Z", "max_forks_repo_head_hexsha": "099b66cb1285d19955e953f916ec6c12c68f2242", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "berkus/music-cs", "max_forks_repo_path": "deps/include/gsl/gsl_matrix.h", "max_issues_count": 1, "max_issues_repo_head_hexsha": "099b66cb1285d19955e953f916ec6c12c68f2242", "max_issues_repo_issues_event_max_datetime": "2021-01-13T16:28:48.000Z", "max_issues_repo_issues_event_min_datetime": "2021-01-11T01:08:01.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "berkus/music-cs", "max_issues_repo_path": "deps/include/gsl/gsl_matrix.h", "max_line_length": 49, "max_stars_count": 2, "max_stars_repo_head_hexsha": "099b66cb1285d19955e953f916ec6c12c68f2242", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "berkus/music-cs", "max_stars_repo_path": "deps/include/gsl/gsl_matrix.h", "max_stars_repo_stars_event_max_datetime": "2021-01-09T16:18:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-09T05:48:44.000Z", "num_tokens": 236, "size": 866 }
/* examples/C/ssmfe/shift_invert.c */ /* Laplacian on a rectangular grid by shift-invert via LDLT factorization */ #include "spral.h" #include <math.h> #include <stdlib.h> #include <stdio.h> #include <cblas.h> /* Headers that implements Laplacian and preconditioners and LDLT support */ #include "laplace2d.h" #include "ldltf.h" int main(void) { const int nx = 8; /* grid points along x */ const int ny = 8; /* grid points along y */ const int n = nx*ny; /* problem size */ const double sigma = 1.0; /* shift */ int ipiv[n]; /* LDLT pivot index */ double lambda[n]; /* eigenvalues */ double X[n][n]; /* eigenvectors */ double A[n][n]; /* matrix */ double LDLT[n][n]; /* factors */ double work[n][n]; /* work array for dsytrf */ struct spral_ssmfe_options options; /* eigensolver options */ struct spral_ssmfe_inform inform; /* information */ struct spral_ssmfe_rcid rci; /* reverse communication data */ void *keep; /* private data */ /* Initialize options to default values */ spral_ssmfe_default_options(&options); /* Set up then perform LDLT factorization of the shifted matrix */ set_laplacian_matrix(nx, ny, n, A); for(int j=0; j<n; j++) for(int i=0; i<n; i++) LDLT[j][i] = (i==j) ? A[j][i] - sigma : A[j][i]; cwrap_dsytrf('L', n, &LDLT[0][0], n, ipiv, &work[0][0], n*n); /* Main loop */ int left = num_neg_D(n, n, LDLT, ipiv); /* all evalues to left of sigma */ int right = 5; /* 5 evalues to right of sigma */ rci.job = 0; keep = NULL; while(true) { spral_ssmfe_standard_shift_double(&rci, sigma, left, right, n, lambda, n, &X[0][0], n, &keep, &options, &inform); switch( rci.job ) { case 1: cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, n, rci.nx, n, 1.0, &A[0][0], n, rci.x, n, 0.0, rci.y, n); break; case 2: // No preconditioning break; case 9: cblas_dcopy(n*rci.nx, rci.x, 1, rci.y, 1); cwrap_dsytrs('L', n, rci.nx, &LDLT[0][0], n, ipiv, rci.y, n); break; default: goto finished; } } finished: printf("Eigenvalues near %e (took %d iterations)\n", sigma, inform.iteration); for(int i=0; i<inform.left+inform.right; i++) printf(" lambda[%1d] = %13.7e\n", i, lambda[i]); spral_ssmfe_free_double(&keep, &inform); /* Success */ return 0; }
{ "alphanum_fraction": 0.5543562066, "avg_line_length": 35.5342465753, "ext": "c", "hexsha": "d22ec8174e038323ccfb641659de0ce3a5ac092a", "lang": "C", "max_forks_count": 19, "max_forks_repo_forks_event_max_datetime": "2022-02-28T14:58:37.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-30T20:52:47.000Z", "max_forks_repo_head_hexsha": "9bf003b2cc199928ec18c967ce0e009d98790898", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "mjacobse/spral", "max_forks_repo_path": "examples/C/ssmfe/shift_invert.c", "max_issues_count": 51, "max_issues_repo_head_hexsha": "9bf003b2cc199928ec18c967ce0e009d98790898", "max_issues_repo_issues_event_max_datetime": "2022-03-11T12:52:21.000Z", "max_issues_repo_issues_event_min_datetime": "2016-09-20T19:01:18.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "mjacobse/spral", "max_issues_repo_path": "examples/C/ssmfe/shift_invert.c", "max_line_length": 81, "max_stars_count": 76, "max_stars_repo_head_hexsha": "9bf003b2cc199928ec18c967ce0e009d98790898", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "mjacobse/spral", "max_stars_repo_path": "examples/C/ssmfe/shift_invert.c", "max_stars_repo_stars_event_max_datetime": "2022-03-14T00:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-03T13:58:37.000Z", "num_tokens": 792, "size": 2594 }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // ////////////////////////////////////////////////////////// // // // // // hybridMANTIS v1.0 // // // fastDETECT2 - C code // // // (optical photons transport) // // // // // ////////////////////////////////////////////////////////// // // // // // ****Disclaimer**** // This software and documentation (the "Software") were developed at the Food and Drug Administration (FDA) by employees of the Federal Government in // the course of their official duties. Pursuant to Title 17, Section 105 of the United States Code, this work is not subject to copyright protection // and is in the public domain. Permission is hereby granted, free of charge, to any person obtaining a copy of the Software, to deal in the Software // without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, or sell copies of the // Software or derivatives, and to permit persons to whom the Software is furnished to do so. FDA assumes no responsibility whatsoever for use by other // parties of the Software, its source code, documentation or compiled executables, and makes no guarantees, expressed or implied, about its quality, // reliability, or any other characteristic. Further, use of this code in no way implies endorsement by the FDA or confers any advantage in regulatory // decisions. Although this software can be redistributed and/or modified freely, we ask that any derivative works bear some notice that they are // derived from it, and any modified versions bear some notice that they have been modified. // // // Associated publication: Sharma Diksha, Badal Andreu and Badano Aldo, "hybridMANTIS: a CPU-GPU Monte Carlo method for modeling indirect x-ray detectors with // columnar scintillators". Physics in Medicine and Biology, 57(8), pp. 2357–2372 (2012) // // // File: hybridMANTIS_c_ver1_0.c // Author: Diksha Sharma (US Food and Drug Administration) // Email: diksha.sharma@fda.hhs.gov // Last updated: Apr 13, 2012 // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////// // // Header libraries // ///////////////////////////////////////// #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> ///////////////////////////////////////// // // Global variables // ///////////////////////////////////////// #define max_photon_per_EDE 900000 // maximum number of optical photons that can be generated per energy deposition event (EDE) #ifndef USING_CUDA #define mybufsize 2304000 // CPU buffer size: # of events sent to the CPU #endif ///////////////////////////////////////// // // Include kernel program // ///////////////////////////////////////// #include "kernel_cuda_c_ver1_0.cu" //////////////////////////////////////////////////////////////////////////// // MAIN PROGRAM // //////////////////////////////////////////////////////////////////////////// #ifndef USING_CUDA /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // cpuoptical(): Performs optical transport using CPU // Input arguments: gpusize // // gpusize - buffer size already processed in the GPU. CPU runs optical transport for rest of the buffer. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void cpuoptical_(int *gpusize) { // command line arguments float xdetector, ydetector, radius, height, n_C, n_IC, top_absfrac, bulk_abscoeff, beta, d_min, lbound_x, lbound_y, ubound_x, ubound_y, d_max, yield, sensorRefl; int pixelsize, num_primary, min_optphotons, max_optphotons, num_bins; float dcos[3]={0}; // directional cosines float normal[3]={0}; // normal to surface in case of TIR float pos[3] = {0}; // intersecting point coordinates float old_pos[3] = {0}; // source coordinates int nbytes = (optical_.myctropt - (*gpusize))*sizeof(struct start_info); struct start_info *structa; structa = (struct start_info*) malloc(nbytes); if( structa == NULL ) printf("\n Struct start_info array CANNOT BE ALLOCATED - %d !!", (optical_.myctropt-(*gpusize))); // get cpu time clock_t start, end; float num_sec; // get current time stamp to initialize seed input for RNG time_t seconds; seconds = time (NULL); struct timeval tv; gettimeofday(&tv,NULL); float rr=0.0f, theta=0.0f; float r=0.0f; // random number float norm=0.0f; int jj=0; int my_index=0; int penindex = 0; // equal to *gpusize int result_algo = 0; unsigned long long int *num_rebound; // initialize random number generator (RANECU) int seed_input = 271828182 ; // ranecu seed input int seed[2]; // GNU scientific library (gsl) variables const gsl_rng_type * Tgsl; gsl_rng * rgsl; double mu_gsl; // output image variables int xdim = 0; int ydim = 0; int indexi=0, indexj=0; // copy to local variables from PENELOPE buffers xdetector = inputargs_.detx; // x dimension of detector (in um). x in (0,xdetector) ydetector = inputargs_.dety; // y dimension of detector (in um). y in (0,ydetector) height = inputargs_.detheight; // height of column and thickness of detector (in um). z in range (-H/2, H/2) radius = inputargs_.detradius; // radius of column (in um). n_C = inputargs_.detnC; // refractive index of columns n_IC = inputargs_.detnIC; // refractive index of intercolumnar material top_absfrac = inputargs_.dettop; // column's top surface absorption fraction (0.0, 0.5, 0.98) bulk_abscoeff = inputargs_.detbulk; // column's bulk absorption coefficient (in um^-1) (0.001, 0.1 cm^-1) beta = inputargs_.detbeta; // roughness coefficient of column walls d_min = inputargs_.detdmin; // minimum distance a photon can travel when transmitted from a column d_max = inputargs_.detdmax; lbound_x = inputargs_.detlboundx; // x lower bound of region of interest of output image (in um) lbound_y = inputargs_.detlboundy; // y lower bound (in um) ubound_x = inputargs_.detuboundx; // x upper bound (in um) ubound_y = inputargs_.detuboundy; // y upper bound (in um) yield = inputargs_.detyield; // yield (/eV) pixelsize = inputargs_.detpixel; // 1 pixel = pixelsize microns (in um) sensorRefl = inputargs_.detsensorRefl; // Non-Ideal sensor reflectivity (%) num_primary = inputargs_.mynumhist; // total number of primaries to be simulated min_optphotons = inputargs_.minphotons; // minimum number of optical photons detected to be included in PHS max_optphotons = inputargs_.maxphotons; // maximum number of optical photons detected to be included in PHS num_bins = inputargs_.mynumbins; // number of bins for genrating PHS // create a generator chosen by the environment variable GSL_RNG_TYPE gsl_rng_env_setup(); Tgsl = gsl_rng_default; rgsl = gsl_rng_alloc (Tgsl); // dimensions of PRF image xdim = ceil((ubound_x - lbound_x)/pixelsize); ydim = ceil((ubound_y - lbound_y)/pixelsize); unsigned long long int myimage[xdim][ydim]; //initialize the output image 2D array for(indexi = 0; indexi < xdim; indexi++) { for(indexj = 0; indexj < ydim; indexj++) { myimage[indexi][indexj] = 0; } } // memory for storing histogram of # photons detected/primary int *h_num_detected_prim = 0; h_num_detected_prim = (int*)malloc(sizeof(int)*num_primary); for(indexj=0; indexj < num_primary; indexj++) h_num_detected_prim[indexj] = 0; // memory for storing histogram of # photons detected/primary int *h_histogram = 0; h_histogram = (int*)malloc(sizeof(int)*num_bins); for(indexj=0; indexj < num_bins; indexj++) h_histogram[indexj] = 0; penindex = *gpusize; for(my_index = 0; my_index < (optical_.myctropt-(*gpusize)); my_index++) // iterate over x-rays { // reset the global counters num_generated = 0; num_detect=0; num_abs_top=0; num_abs_bulk=0; num_lost=0; num_outofcol=0; num_theta1=0; photon_distance=0.0f; //re-initialize the output image 2D array for(indexi = 0; indexi < xdim; indexi++) for(indexj = 0; indexj < ydim; indexj++) myimage[indexi][indexj] = 0; // copying PENELOPE buffer into *structa // units in the penelope output file are in cm. Convert them to microns. structa[my_index].str_x = optical_.xbufopt[penindex+my_index] * 10000.0f; // x-coordinate of interaction event structa[my_index].str_y = optical_.ybufopt[penindex+my_index] * 10000.0f; // y-coordinate structa[my_index].str_z = optical_.zbufopt[penindex+my_index] * 10000.0f; // z-coordinate structa[my_index].str_E = optical_.debufopt[penindex+my_index]; // energy deposited structa[my_index].str_histnum = optical_.nbufopt[penindex+my_index]; // x-ray history // sample # optical photons based on light yield and energy deposited for this interaction event (using Poisson distribution) mu_gsl = (double)structa[my_index].str_E * yield; structa[my_index].str_N = gsl_ran_poisson(rgsl,mu_gsl); if(structa[my_index].str_N > max_photon_per_EDE) { printf("\n\n str_n exceeds max photons. program is exiting - %d !! \n\n",structa[my_index].str_N); exit(0); } num_rebound = (unsigned long long int*) malloc(structa[my_index].str_N*sizeof(unsigned long long int)); if(num_rebound == NULL) printf("\n Error allocating num_rebound memory !\n"); // start the clock start = clock(); // initialize the RANECU generator in a position far away from the previous history: seed_input = (int)(seconds/3600+tv.tv_usec); // seed input=seconds passed since 1970+current time in micro secs init_PRNG(my_index, 50000, seed_input, seed); // intialize RNG for(jj=0; jj<structa[my_index].str_N; jj++) num_rebound[jj] = 0; // reset the directional cosine and normal vectors dcos[0]=0.0f; dcos[1]=0.0f; dcos[2]=0.0f; normal[0]=0.0f; normal[1]=0.0f; normal[2]=0.0f; // re-initialize myimage for(indexi = 0; indexi < xdim; indexi++) for(indexj = 0; indexj < ydim; indexj++) myimage[indexi][indexj] = 0; // set starting location of photon pos[0] = structa[my_index].str_x; pos[1] = structa[my_index].str_y; pos[2] = structa[my_index].str_z; old_pos[0] = structa[my_index].str_x; old_pos[1] = structa[my_index].str_y; old_pos[2] = structa[my_index].str_z; // initializing the direction cosines for the first particle in each core r = (ranecu(seed) * 2.0f) - 1.0f; // random number between (-1,1) while(fabs(r) <= 0.01f) { r = (ranecu(seed) * 2.0f) - 1.0f; } dcos[2] = r; // random number between (-1,1) rr = sqrt(1.0f-r*r); theta=ranecu(seed)*twopipen; dcos[0]=rr*cos(theta); dcos[1]=rr*sin(theta); norm = sqrt(dcos[0]*dcos[0] + dcos[1]*dcos[1] + dcos[2]*dcos[2]); if ((norm < (1.0f - epsilon)) || (norm > (1.0f + epsilon))) // normalize { dcos[0] = dcos[0]/norm; dcos[1] = dcos[1]/norm; dcos[2] = dcos[2]/norm; } local_counter=0; // total number of photons terminated (either detected at sensor, absorbed at the top or in the bulk) [global variable] while(local_counter < structa[my_index].str_N) // until all the optical photons are not transported { absorbed = 0; detect = 0; bulk_abs = 0; // set starting location of photon pos[0] = structa[my_index].str_x; pos[1] = structa[my_index].str_y; pos[2] = structa[my_index].str_z; old_pos[0] = structa[my_index].str_x; old_pos[1] = structa[my_index].str_y; old_pos[2] = structa[my_index].str_z; num_generated++; result_algo = 0; while(result_algo == 0) { result_algo = algo(normal, old_pos, pos, dcos, num_rebound, seed, structa[my_index], &myimage[0][0], xdetector, ydetector, radius, height, n_C, n_IC, top_absfrac, bulk_abscoeff, beta, d_min, pixelsize, lbound_x, lbound_y, ubound_x, ubound_y, sensorRefl, d_max, ydim, h_num_detected_prim); } } // end the clock end = clock(); num_sec = (((float)end - start)/CLOCKS_PER_SEC); // type cast unsigned long long int to double double cast_num_generated; double cast_num_detect; double cast_num_abs_top; double cast_num_abs_bulk; double cast_num_lost; double cast_num_outofcol; double cast_num_theta1; double cast_gputime; cast_num_generated = (double)num_generated; cast_num_detect = (double)num_detect; cast_num_abs_top = (double)num_abs_top; cast_num_abs_bulk = (double)num_abs_bulk; cast_num_lost = (double)num_lost; cast_num_outofcol = (double)num_outofcol; cast_num_theta1 = (double)num_theta1; cast_gputime = (double)(num_sec*1000.0); // convert in millisecond // save to global counters optstats_.glgen = optstats_.glgen + cast_num_generated; optstats_.gldetect = optstats_.gldetect + cast_num_detect; optstats_.glabstop = optstats_.glabstop + cast_num_abs_top; optstats_.glabsbulk = optstats_.glabsbulk + cast_num_abs_bulk; optstats_.gllost = optstats_.gllost + cast_num_lost; optstats_.gloutofcol = optstats_.gloutofcol + cast_num_outofcol; optstats_.gltheta1 = optstats_.gltheta1 + cast_num_theta1; optstats_.glgputime = optstats_.glgputime + cast_gputime; // release resources free(num_rebound); } // my_index loop ends // make histogram of number of detected photons/primary for num_bins int binsize=0, newbin=0; int bincorr=0; binsize = floor((max_optphotons-min_optphotons)/num_bins); // calculate size of each bin. Assuming equally spaced bins. bincorr = floor(min_optphotons/binsize); // correction in bin number if min_optphotons > 0. for(indexi = 0; indexi < num_primary; indexi++) { newbin = floor(h_num_detected_prim[indexi]/binsize) - bincorr; // find bin # if(h_num_detected_prim[indexi] > 0) // store only non-zero bins { if(h_num_detected_prim[indexi] <= min_optphotons) // # detected < minimum photons given by user, add to the first bin h_histogram[0]++; else if(h_num_detected_prim[indexi] >= max_optphotons) // # detected > maximum photons given by user, then add to the last bin h_histogram[num_bins-1]++; else h_histogram[newbin]++; } } // add num_detected_primary to gldetprimary array in PENELOPE for(indexi = 0; indexi < num_bins; indexi++) outputdetprim_.gldetprimary[indexi] = outputdetprim_.gldetprimary[indexi] + h_histogram[indexi]; // release resources free(structa); free(h_num_detected_prim); free(h_histogram); return; } // C main() ends #endif
{ "alphanum_fraction": 0.6344327177, "avg_line_length": 40, "ext": "c", "hexsha": "ac96416066b0628989e79c15d6b4e52e59cb12b6", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8e2d374baaad27b3eae62fab34bea7675eb1ee4d", "max_forks_repo_licenses": [ "BSD-Source-Code" ], "max_forks_repo_name": "diamfda/hybridmantis", "max_forks_repo_path": "main/hybridMANTIS_c_ver1_0.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "8e2d374baaad27b3eae62fab34bea7675eb1ee4d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-Source-Code" ], "max_issues_repo_name": "diamfda/hybridmantis", "max_issues_repo_path": "main/hybridMANTIS_c_ver1_0.c", "max_line_length": 300, "max_stars_count": null, "max_stars_repo_head_hexsha": "8e2d374baaad27b3eae62fab34bea7675eb1ee4d", "max_stars_repo_licenses": [ "BSD-Source-Code" ], "max_stars_repo_name": "diamfda/hybridmantis", "max_stars_repo_path": "main/hybridMANTIS_c_ver1_0.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4368, "size": 15160 }
#pragma once #include <imageview/ContinuousImageView.h> #include <imageview/internal/ImageViewStorage.h> #include <imageview/internal/PixelRef.h> #include <gsl/span> #include <cstddef> namespace imageview { template <class PixelFormat, bool Mutable = false> class ImageView { public: static_assert(IsPixelFormat<PixelFormat>::value, "Not a PixelFormat."); using byte_type = std::conditional_t<Mutable, std::byte, const std::byte>; using value_type = typename PixelFormat::color_type; // TODO: consider using 'const value_type' instead of 'value_type' for immutable views. using reference = std::conditional_t<Mutable, detail::PixelRef<PixelFormat>, value_type>; // Construct an empty view. template <class Enable = std::enable_if_t<std::is_default_constructible_v<PixelFormat>>> constexpr ImageView() noexcept(noexcept(std::is_nothrow_default_constructible_v<PixelFormat>)) {} // Construct a view into an image. // \param height - height of the image. // \param width - width of the image. // \param stride - // \param data - bitmap data. constexpr ImageView(unsigned int height, unsigned int width, unsigned int stride, gsl::span<byte_type> data); // Construct a view into an image. // \param height - height of the image. // \param width - width of the image. // \param stride - // \param data - bitmap data. // \param pixel_format - PixelFormat instance to use. constexpr ImageView(unsigned int height, unsigned int width, unsigned int stride, gsl::span<byte_type> data, const PixelFormat& pixel_format); constexpr ImageView(unsigned int height, unsigned int width, unsigned int stride, gsl::span<byte_type> data, PixelFormat&& pixel_format); // Construct a read-only view from a mutable view. template <class Enable = std::enable_if_t<!Mutable>> constexpr ImageView(ImageView<PixelFormat, !Mutable> other); constexpr ImageView(ContinuousImageView<PixelFormat, Mutable> image); // Construct a read-only view from a mutable contiguous view. template <class Enable = std::enable_if_t<!Mutable>> constexpr ImageView(ContinuousImageView<PixelFormat, !Mutable> image); // Return the height of the image constexpr unsigned int height() const noexcept; constexpr unsigned int width() const noexcept; constexpr unsigned int stride() const noexcept; constexpr unsigned int area() const noexcept; // Returns true if the image has zero area, false otherwise. constexpr bool empty() const noexcept; // Returns the pixel format used by this image. constexpr const PixelFormat& pixelFormat() const noexcept; constexpr gsl::span<byte_type> data() const noexcept; constexpr reference operator()(unsigned int y, unsigned int x) const; constexpr ImageRowView<PixelFormat, Mutable> row(unsigned int y) const; private: detail::ImageViewStorage<PixelFormat, Mutable> storage_; unsigned int height_ = 0; unsigned int width_ = 0; unsigned int stride_ = 0; }; template <class PixelFormat, bool Mutable> constexpr ImageView<PixelFormat, Mutable>::ImageView(unsigned int height, unsigned int width, unsigned int stride, gsl::span<byte_type> data) : storage_(data.data()), height_(height), width_(width), stride_(stride) { Expects(width <= stride); const std::size_t expected_size = (height == 0) ? 0 : ((height - 1) * stride + width) * PixelFormat::kBytesPerPixel; Expects(data.size() == expected_size); } template <class PixelFormat, bool Mutable> constexpr ImageView<PixelFormat, Mutable>::ImageView(unsigned int height, unsigned int width, unsigned int stride, gsl::span<byte_type> data, const PixelFormat& pixel_format) : storage_(data.data(), pixel_format), height_(height), width_(width), stride_(stride) { Expects(width <= stride); const std::size_t expected_size = (height == 0) ? 0 : ((height - 1) * stride + width) * PixelFormat::kBytesPerPixel; Expects(data.size() == expected_size); } template <class PixelFormat, bool Mutable> constexpr ImageView<PixelFormat, Mutable>::ImageView(unsigned int height, unsigned int width, unsigned int stride, gsl::span<byte_type> data, PixelFormat&& pixel_format) : storage_(data.data(), std::move(pixel_format)), height_(height), width_(width), stride_(stride) { Expects(width <= stride); const std::size_t expected_size = (height == 0) ? 0 : ((height - 1) * stride + width) * PixelFormat::kBytesPerPixel; Expects(data.size() == expected_size); } template <class PixelFormat, bool Mutable> template <class Enable> constexpr ImageView<PixelFormat, Mutable>::ImageView(ImageView<PixelFormat, !Mutable> other) : ImageView(other.height(), other.width(), other.stride(), other.data(), other.pixelFormat()) {} template <class PixelFormat, bool Mutable> constexpr ImageView<PixelFormat, Mutable>::ImageView(ContinuousImageView<PixelFormat, Mutable> image) : ImageView(image.height(), image.width(), image.width(), image.data()) {} template <class PixelFormat, bool Mutable> template <class Enable> constexpr ImageView<PixelFormat, Mutable>::ImageView(ContinuousImageView<PixelFormat, !Mutable> image) : ImageView(ContinuousImageView<PixelFormat, Mutable>(image)) {} template <class PixelFormat, bool Mutable> constexpr unsigned int ImageView<PixelFormat, Mutable>::height() const noexcept { return height_; } template <class PixelFormat, bool Mutable> constexpr unsigned int ImageView<PixelFormat, Mutable>::width() const noexcept { return width_; } template <class PixelFormat, bool Mutable> constexpr unsigned int ImageView<PixelFormat, Mutable>::stride() const noexcept { return stride_; } template <class PixelFormat, bool Mutable> constexpr unsigned int ImageView<PixelFormat, Mutable>::area() const noexcept { return height_ * width_; } template <class PixelFormat, bool Mutable> constexpr bool ImageView<PixelFormat, Mutable>::empty() const noexcept { return height_ == 0 || width_ == 0; } template <class PixelFormat, bool Mutable> constexpr const PixelFormat& ImageView<PixelFormat, Mutable>::pixelFormat() const noexcept { return storage_.pixelFormat(); } template <class PixelFormat, bool Mutable> constexpr auto ImageView<PixelFormat, Mutable>::data() const noexcept -> gsl::span<byte_type> { const std::size_t data_size = (height_ == 0) ? 0 : ((height_ - 1) * stride_ + width_) * PixelFormat::kBytesPerPixel; return gsl::span<byte_type>(storage_.data(), data_size); } template <class PixelFormat, bool Mutable> constexpr auto ImageView<PixelFormat, Mutable>::operator()(unsigned int y, unsigned int x) const -> reference { Expects(y < height_); Expects(x < width_); const gsl::span<byte_type, PixelFormat::kBytesPerPixel> pixel_data( storage_.data() + (y * stride_ + x) * PixelFormat::kBytesPerPixel, PixelFormat::kBytesPerPixel); if constexpr (Mutable) { return detail::PixelRef<PixelFormat>(pixel_data, pixelFormat()); } else { return pixelFormat().read(pixel_data); } } template <class PixelFormat, bool Mutable> constexpr ImageRowView<PixelFormat, Mutable> ImageView<PixelFormat, Mutable>::row(unsigned int y) const { Expects(y < height_); const gsl::span<byte_type> row_data(storage_.data() + y * stride_ * PixelFormat::kBytesPerPixel, width_ * PixelFormat::kBytesPerPixel); return ImageRowView<PixelFormat>(row_data, width_, pixelFormat()); } } // namespace imageview
{ "alphanum_fraction": 0.722538004, "avg_line_length": 41.7955801105, "ext": "h", "hexsha": "2312b4906a30b4d9542528677611f642d8f48fbc", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "817e92ac1dcbffc7fb0ebb11afe4ee9836f37df0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alexanderbelous/imageview", "max_forks_repo_path": "include/imageview/ImageView.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "817e92ac1dcbffc7fb0ebb11afe4ee9836f37df0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "alexanderbelous/imageview", "max_issues_repo_path": "include/imageview/ImageView.h", "max_line_length": 118, "max_stars_count": null, "max_stars_repo_head_hexsha": "817e92ac1dcbffc7fb0ebb11afe4ee9836f37df0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alexanderbelous/imageview", "max_stars_repo_path": "include/imageview/ImageView.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1671, "size": 7565 }
/** * * @file core_ztstrf.c * * PLASMA core_blas kernel * PLASMA is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * * @version 2.6.0 * @author Hatem Ltaief * @author Mathieu Faverge * @author Jakub Kurzak * @date 2010-11-15 * @precisions normal z -> c d s * **/ #include "common.h" #include <cblas.h> #include <math.h> /***************************************************************************//** * * @ingroup CORE_PLASMA_Complex64_t * * CORE_ztstrf computes an LU factorization of a complex matrix formed * by an upper triangular NB-by-N tile U on top of a M-by-N tile A * using partial pivoting with row interchanges. * * This is the right-looking Level 2.5 BLAS version of the algorithm. * ******************************************************************************* * * @param[in] M * The number of rows of the tile A. M >= 0. * * @param[in] N * The number of columns of the tile A. N >= 0. * * @param[in] IB * The inner-blocking size. IB >= 0. * * @param[in] NB * * @param[in,out] U * On entry, the NB-by-N upper triangular tile. * On exit, the new factor U from the factorization * * @param[in] LDU * The leading dimension of the array U. LDU >= max(1,NB). * * @param[in,out] A * On entry, the M-by-N tile to be factored. * On exit, the factor L from the factorization * * @param[in] LDA * The leading dimension of the array A. LDA >= max(1,M). * * @param[in,out] L * On entry, the IB-by-N lower triangular tile. * On exit, the interchanged rows form the tile A in case of pivoting. * * @param[in] LDL * The leading dimension of the array L. LDL >= max(1,IB). * * @param[out] IPIV * The pivot indices; for 1 <= i <= min(M,N), row i of the * tile U was interchanged with row IPIV(i) of the tile A. * * @param[in,out] WORK * * @param[in] LDWORK * The leading dimension of the array WORK. * * @param[out] INFO * ******************************************************************************* * * @return * \retval PLASMA_SUCCESS successful exit * \retval <0 if INFO = -k, the k-th argument had an illegal value * \retval >0 if INFO = k, U(k,k) is exactly zero. The factorization * has been completed, but the factor U is exactly * singular, and division by zero will occur if it is used * to solve a system of equations. * ******************************************************************************/ #if defined(PLASMA_HAVE_WEAK) #pragma weak CORE_ztstrf = PCORE_ztstrf #define CORE_ztstrf PCORE_ztstrf #define CORE_zssssm PCORE_zssssm int CORE_zssssm(int M1, int N1, int M2, int N2, int K, int IB, PLASMA_Complex64_t *A1, int LDA1, PLASMA_Complex64_t *A2, int LDA2, const PLASMA_Complex64_t *L1, int LDL1, const PLASMA_Complex64_t *L2, int LDL2, const int *IPIV); #endif int CORE_ztstrf(int M, int N, int IB, int NB, PLASMA_Complex64_t *U, int LDU, PLASMA_Complex64_t *A, int LDA, PLASMA_Complex64_t *L, int LDL, int *IPIV, PLASMA_Complex64_t *WORK, int LDWORK, int *INFO) { static PLASMA_Complex64_t zzero = 0.0; static PLASMA_Complex64_t mzone =-1.0; PLASMA_Complex64_t alpha; int i, j, ii, sb; int im, ip; /* Check input arguments */ *INFO = 0; if (M < 0) { coreblas_error(1, "Illegal value of M"); return -1; } if (N < 0) { coreblas_error(2, "Illegal value of N"); return -2; } if (IB < 0) { coreblas_error(3, "Illegal value of IB"); return -3; } if ((LDU < max(1,NB)) && (NB > 0)) { coreblas_error(6, "Illegal value of LDU"); return -6; } if ((LDA < max(1,M)) && (M > 0)) { coreblas_error(8, "Illegal value of LDA"); return -8; } if ((LDL < max(1,IB)) && (IB > 0)) { coreblas_error(10, "Illegal value of LDL"); return -10; } /* Quick return */ if ((M == 0) || (N == 0) || (IB == 0)) return PLASMA_SUCCESS; /* Set L to 0 */ memset(L, 0, LDL*N*sizeof(PLASMA_Complex64_t)); ip = 0; for (ii = 0; ii < N; ii += IB) { sb = min(N-ii, IB); for (i = 0; i < sb; i++) { im = cblas_izamax(M, &A[LDA*(ii+i)], 1); IPIV[ip] = ii+i+1; if (cabs(A[LDA*(ii+i)+im]) > cabs(U[LDU*(ii+i)+ii+i])) { /* * Swap behind. */ cblas_zswap(i, &L[LDL*ii+i], LDL, &WORK[im], LDWORK ); /* * Swap ahead. */ cblas_zswap(sb-i, &U[LDU*(ii+i)+ii+i], LDU, &A[LDA*(ii+i)+im], LDA ); /* * Set IPIV. */ IPIV[ip] = NB + im + 1; for (j = 0; j < i; j++) { A[LDA*(ii+j)+im] = zzero; } } if ((*INFO == 0) && (cabs(A[LDA*(ii+i)+im]) == zzero) && (cabs(U[LDU*(ii+i)+ii+i]) == zzero)) { *INFO = ii+i+1; } alpha = ((PLASMA_Complex64_t)1. / U[LDU*(ii+i)+ii+i]); cblas_zscal(M, CBLAS_SADDR(alpha), &A[LDA*(ii+i)], 1); cblas_zcopy(M, &A[LDA*(ii+i)], 1, &WORK[LDWORK*i], 1); cblas_zgeru( CblasColMajor, M, sb-i-1, CBLAS_SADDR(mzone), &A[LDA*(ii+i)], 1, &U[LDU*(ii+i+1)+ii+i], LDU, &A[LDA*(ii+i+1)], LDA ); ip = ip+1; } /* * Apply the subpanel to the rest of the panel. */ if(ii+i < N) { for(j = ii; j < ii+sb; j++) { if (IPIV[j] <= NB) { IPIV[j] = IPIV[j] - ii; } } CORE_zssssm( NB, N-(ii+sb), M, N-(ii+sb), sb, sb, &U[LDU*(ii+sb)+ii], LDU, &A[LDA*(ii+sb)], LDA, &L[LDL*ii], LDL, WORK, LDWORK, &IPIV[ii]); for(j = ii; j < ii+sb; j++) { if (IPIV[j] <= NB) { IPIV[j] = IPIV[j] + ii; } } } } return PLASMA_SUCCESS; }
{ "alphanum_fraction": 0.4635344695, "avg_line_length": 30.1527777778, "ext": "c", "hexsha": "a92107caf89b9762931e6bdec04d5030f3781ae1", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bcc99c164a256bc7df7c936b9c43afd38c12aea2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "zhuangsc/Plasma-ompss1", "max_forks_repo_path": "core_blas/core_ztstrf.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "bcc99c164a256bc7df7c936b9c43afd38c12aea2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "zhuangsc/Plasma-ompss1", "max_issues_repo_path": "core_blas/core_ztstrf.c", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "bcc99c164a256bc7df7c936b9c43afd38c12aea2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "zhuangsc/Plasma-ompss1", "max_stars_repo_path": "core_blas/core_ztstrf.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1950, "size": 6513 }
/* Copyright [2017-2019] [IBM Corporation] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef COMANCHE_HSTORE_POOL_MANAGER_H #define COMANCHE_HSTORE_POOL_MANAGER_H #include <api/kvstore_itf.h> /* status_t */ #include "alloc_key.h" #include <common/logging.h> /* log_source */ #include <nupm/region_descriptor.h> #include <gsl/pointers> #include <sys/uio.h> #include <cstddef> #include <functional> #include <string> #include <system_error> struct pool_path; #pragma GCC diagnostic push // #pragma GCC diagnostic ignored "-Wunused-parameter" enum class pool_ec { pool_fail, pool_unsupported_mode, region_fail, region_fail_general_exception, region_fail_api_exception, }; struct pool_category : public std::error_category { const char* name() const noexcept override { return "pool_category"; } std::string message( int condition ) const noexcept override { switch ( condition ) { case int(pool_ec::pool_fail): return "default pool failure"; case int(pool_ec::pool_unsupported_mode): return "pool unsupported flags"; case int(pool_ec::region_fail): return "region-backed pool failure"; case int(pool_ec::region_fail_general_exception): return "region-backed pool failure (General_exception)"; case int(pool_ec::region_fail_api_exception): return "region-backed pool failure (API_exception)"; default: return "unknown pool failure"; } } }; namespace { pool_category pool_error_category; } struct pool_error : public std::error_condition { std::string _msg; public: pool_error(const std::string &msg_, pool_ec val_) : std::error_condition(int(val_), pool_error_category) , _msg(msg_) {} }; struct dax_manager; template <typename Pool> struct pool_manager : protected common::log_source { pool_manager(unsigned debug_level_) : common::log_source(debug_level_) {} virtual ~pool_manager() {} virtual void pool_create_check(const std::size_t size_) = 0; virtual void pool_close_check(const std::string &) = 0; virtual nupm::region_descriptor pool_get_regions(const Pool &) const = 0; /* * throws pool_error if create_region fails */ virtual auto pool_create_1( const pool_path &path_ , std::size_t size_ ) -> nupm::region_descriptor = 0; virtual auto pool_create_2( AK_FORMAL const nupm::region_descriptor & rac , component::IKVStore::flags_t flags , std::size_t expected_obj_count ) -> std::unique_ptr<Pool> = 0; virtual auto pool_open_1( const pool_path &path_ ) -> nupm::region_descriptor = 0; virtual auto pool_open_2( AK_FORMAL const nupm::region_descriptor & access_ , component::IKVStore::flags_t flags_ ) -> std::unique_ptr<Pool> = 0; virtual void pool_delete(const pool_path &path) = 0; virtual const std::unique_ptr<dax_manager> & get_dax_manager() const = 0; }; #pragma GCC diagnostic pop #endif
{ "alphanum_fraction": 0.7121559633, "avg_line_length": 26.4242424242, "ext": "h", "hexsha": "c837194d3db090e41f131f6af34cf76bfd62e182", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a6af06bc278993fb3ffe780f230d2396b2287c26", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "moshik1/mcas", "max_forks_repo_path": "src/components/store/hstore/src/pool_manager.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "a6af06bc278993fb3ffe780f230d2396b2287c26", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "moshik1/mcas", "max_issues_repo_path": "src/components/store/hstore/src/pool_manager.h", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "a6af06bc278993fb3ffe780f230d2396b2287c26", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "moshik1/mcas", "max_stars_repo_path": "src/components/store/hstore/src/pool_manager.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 839, "size": 3488 }
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <gsl/gsl_qrng.h> #include <gsl/gsl_histogram2d.h> #include <gsl/gsl_sf_laguerre.h> #include <courier.h> #include "data.h" static const char* localhost = "127.0.0.1"; extern void splineval_init(int* nx, double *x, double *fcn_1d); extern void spline_dump(int* nx); extern void throw_darts(const int* ndarts, const int *nx, double *x, double *y, int* hits); extern void classify(const int *nx, double *x, double *y, int* hits); void report(size_t ndarts, double* x, double* y, int* hits, Point* rowvec) { int i; } void explore(const int ndarts, size_t nreps, size_t nx, size_t ny, double xmin, double xmax, double ymin, double ymax) { double u, v; int i, j; const char* deps[] = {"Point"}; const gsl_rng_type * T = gsl_rng_default; gsl_rng * r = gsl_rng_alloc (T); gsl_histogram2d *h = gsl_histogram2d_alloc(nx,ny); gsl_histogram2d_pdf *p = gsl_histogram2d_pdf_alloc(nx,ny); gsl_histogram2d_set_ranges_uniform(h, xmin, xmax, ymin, ymax); gsl_histogram2d_shift(h, 100.0); double *x = malloc(sizeof(double)*ndarts), *y = malloc(sizeof(double)*ndarts); int *c = malloc(sizeof(int)*ndarts); Point *rowvec = malloc(sizeof(Point)*ndarts); int breakout = 0; for (j = 0; j < nreps; j++) { gsl_histogram2d_pdf_init(p,h); for (i = 0; i < ndarts; i++) { u = gsl_rng_uniform(r); v = gsl_rng_uniform(r); gsl_histogram2d_pdf_sample (p, u, v, &x[i], &y[i]); } classify(&ndarts,x,y,c); for (i = 0; i < ndarts; i++) { rowvec[i].x = x[i]; rowvec[i].y = y[i]; rowvec[i].category = c[i]; } courier_write_table("Point", rowvec, sizeof(Point), ndarts, 0); char* res = courier_request_analysis(localhost, "Update", deps, 1); { char* token = strtok(res, " "); while (token != NULL) { size_t idx = strtod(token, NULL) - 1; token = strtok(NULL, " "); double w = strtod(token, NULL); h->bin[idx] = 1;//fmax(0,10 / w); token = strtok(NULL, " "); } if (gsl_histogram2d_sum(h) <= nx*ny) { printf("Stopping due to exhausted histogram\n"); breakout = 1; } } courier_free_data(res); if (breakout) { printf("Iteration %d\n",j); break; } } FILE *hf = fopen("hist.tab", "w"); gsl_histogram2d_fprintf(hf,h,"%g","%g"); fclose(hf); free(rowvec); free(c); free(x); free(y); gsl_rng_free (r); gsl_histogram2d_pdf_free(p); gsl_histogram2d_free(h); } int main(int argc, char** argv) { int nx = 100; int i, j; double x[nx], fcn_1d[nx]; const gsl_rng_type * T; gsl_rng * r; gsl_rng_env_setup(); T = gsl_rng_default; r = gsl_rng_alloc (T); fcn_1d[0] = 0; x[0] = 0; for (i = 1; i < nx; i++) { x[i] = i + 1.0; double h = gsl_ran_levy_skew(r, 1, 1.0, 1.0); if (h < 1 && h > -1) { h = -5; } fcn_1d[i] = fmax(25,fmin(75,fcn_1d[i-1]+h)); } splineval_init(&nx,x,fcn_1d); explore(1000, 1000, 64, 64, 0, 100, 0, 100); spline_dump(&nx); gsl_rng_free (r); return 0; }
{ "alphanum_fraction": 0.5507913669, "avg_line_length": 29.9568965517, "ext": "c", "hexsha": "29d98e4b442f15e3307e8d9267afca090b466351", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3da4aa72cd85ad0779a341b3cabead390aa6927b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "sashalemon/spark-coupling", "max_forks_repo_path": "vegasoid/native/sim/main/src/main.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "3da4aa72cd85ad0779a341b3cabead390aa6927b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "sashalemon/spark-coupling", "max_issues_repo_path": "vegasoid/native/sim/main/src/main.c", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "3da4aa72cd85ad0779a341b3cabead390aa6927b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "sashalemon/spark-coupling", "max_stars_repo_path": "vegasoid/native/sim/main/src/main.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1078, "size": 3475 }
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_spline.h> #include <gsl/gsl_integration.h> #include <gsl/gsl_const_mksa.h> #include <gsl/gsl_roots.h> #include "ccl.h" // Global variable to hold the neutrino phase-space spline gsl_spline* nu_spline = NULL; // these are NOT adjustable // this phase space integral is only done once and the following is accurate // enough according to tests done by the devs /** * Absolute precision in neutrino root finding */ #define GSL_EPSABS_NU 1E-7 /** * Relative precision in neutrino root finding */ #define GSL_EPSREL_NU 1E-7 /** * Number of iterations for neutrino root finding */ #define GSL_N_ITERATION_NU 1000 /* ------- ROUTINE: nu_integrand ------ INPUTS: x: dimensionless momentum, *r: pointer to a dimensionless mass / temperature TASK: Integrand of phase-space massive neutrino integral */ static double nu_integrand(double x, void *r) { double rat = *((double*)(r)); double x2 = x*x; return sqrt(x2 + rat*rat) / (exp(x)+1.0) * x2; } /* ------- ROUTINE: ccl_calculate_nu_phasespace_spline ------ TASK: Get the spline of the result of the phase-space integral required for massive neutrinos. */ gsl_spline* calculate_nu_phasespace_spline(int *status) { int N = CCL_NU_MNUT_N; double *mnut = NULL; double *y = NULL; gsl_spline* spl = NULL; gsl_integration_cquad_workspace * workspace = NULL; int stat = 0, gslstatus; gsl_function F; mnut = ccl_linear_spacing(log(CCL_NU_MNUT_MIN), log(CCL_NU_MNUT_MAX), N); y = malloc(sizeof(double)*CCL_NU_MNUT_N); if ((y == NULL) || (mnut == NULL)) { // Not setting a status_message here because we can't easily pass a // cosmology to this function - message printed in ccl_error.c. *status = CCL_ERROR_NU_INT; } if (*status == 0) { workspace = gsl_integration_cquad_workspace_alloc(GSL_N_ITERATION_NU); if (workspace == NULL) *status = CCL_ERROR_NU_INT; } if (*status == 0) { F.function = &nu_integrand; for (int i=0; i < CCL_NU_MNUT_N; i++) { double mnut_ = exp(mnut[i]); F.params = &(mnut_); gslstatus = gsl_integration_cquad(&F, 0, 1000.0, GSL_EPSABS_NU, GSL_EPSREL_NU, workspace, &y[i], NULL, NULL); if (gslstatus != GSL_SUCCESS) { ccl_raise_gsl_warning(gslstatus, "ccl_neutrinos.c: calculate_nu_phasespace_spline():"); stat |= gslstatus; } } double renorm = 1./y[0]; for (int i=0; i < CCL_NU_MNUT_N; i++) y[i] *= renorm; if (stat) { *status = CCL_ERROR_NU_INT; } } if (*status == 0) { spl = gsl_spline_alloc(gsl_interp_akima, CCL_NU_MNUT_N); if (spl == NULL) *status = CCL_ERROR_NU_INT; } if (*status == 0) { stat |= gsl_spline_init(spl, mnut, y, CCL_NU_MNUT_N); if (stat) { ccl_raise_gsl_warning(gslstatus, "ccl_neutrinos.c: calculate_nu_phasespace_spline():"); *status = CCL_ERROR_NU_INT; } } // Check for errors in creating the spline if (stat || (*status)) { // Not setting a status_message here because we can't easily pass a // cosmology to this function - message printed in ccl_error.c. *status = CCL_ERROR_NU_INT; gsl_spline_free(spl); } gsl_integration_cquad_workspace_free(workspace); free(mnut); free(y); return spl; } /* ------- ROUTINE: ccl_nu_phasespace_intg ------ INPUTS: mnuOT: the dimensionless mass / temperature of a single massive neutrino TASK: Get the value of the phase space integral at mnuOT */ double nu_phasespace_intg(double mnuOT, int* status) { // Check if the global variable for the phasespace spline has been defined yet: if (nu_spline == NULL) nu_spline = calculate_nu_phasespace_spline(status); if (*status) { return NAN; } double integral_value = 0.; // First check the cases where we are in the limits. if (mnuOT < CCL_NU_MNUT_MIN) return 7./8.; else if (mnuOT > CCL_NU_MNUT_MAX) return 0.2776566337 * mnuOT; int gslstatus = gsl_spline_eval_e(nu_spline, log(mnuOT), NULL, &integral_value); if (gslstatus != GSL_SUCCESS) { ccl_raise_gsl_warning(gslstatus, "ccl_neutrinos.c: nu_phasespace_intg():"); *status |= gslstatus; } return integral_value * 7./8.; } /* -------- ROUTINE: Omeganuh2 --------- INPUTS: a: scale factor, Nnumass: number of massive neutrino species, mnu: total mass in eV of neutrinos, T_CMB: CMB temperature, status: pointer to status integer. TASK: Compute Omeganu * h^2 as a function of time. !! To all practical purposes, Neff is simply N_nu_mass !! */ double ccl_Omeganuh2 (double a, int N_nu_mass, double* mnu, double T_CMB, int* status) { double Tnu, a4, prefix_massless, mnuone, OmNuh2; double Tnu_eff, mnuOT, intval, prefix_massive; double total_mass; // To check if this is the massless or massive case. // First check if N_nu_mass is 0 if (N_nu_mass == 0) return 0.0; Tnu = T_CMB*pow(4./11.,1./3.); a4 = a*a*a*a; // Check if mnu=0. We assume that in the massless case mnu is a // pointer to a single element and that element is 0. This should in principle never be called. if (mnu[0] < 0.00017) { // Limit taken from Lesgourges et al. 2012 prefix_massless = NU_CONST * Tnu * Tnu * Tnu * Tnu; return N_nu_mass*prefix_massless*7./8./a4; } // And the remaining massive case. // Tnu_eff is used in the massive case because CLASS uses an effective // temperature of nonLCDM components to match to mnu / Omeganu =93.14eV. Tnu_eff = T_ncdm * T_CMB = 0.71611 * T_CMB Tnu_eff = Tnu * ccl_constants.TNCDM / (pow(4./11.,1./3.)); // Define the prefix using the effective temperature (to get mnu / Omega = 93.14 eV) for the massive case: prefix_massive = NU_CONST * Tnu_eff * Tnu_eff * Tnu_eff * Tnu_eff; OmNuh2 = 0.; // Initialize to 0 - we add to this for each massive neutrino species. for(int i=0; i < N_nu_mass; i++) { // Get mass over T (mass (eV) / ((kb eV/s/K) Tnu_eff (K)) // This returns the density normalized so that we get nuh2 at a=0 mnuOT = mnu[i] / (Tnu_eff/a) * (ccl_constants.EV_IN_J / (ccl_constants.KBOLTZ)); // Get the value of the phase-space integral intval = nu_phasespace_intg(mnuOT, status); OmNuh2 = intval*prefix_massive/a4 + OmNuh2; } return OmNuh2; } /* -------- ROUTINE: Omeganuh2_to_Mnu --------- INPUTS: OmNuh2: neutrino mass density today Omeganu * h^2, label: how you want to split up the masses, see ccl_neutrinos.h for options, T_CMB: CMB temperature, status: pointer to status integer. TASK: Given Omeganuh2 today, the method of splitting into masses, and the temperature of the CMB, output a pointer to the array of neutrino masses (may be length 1 if label asks for sum) */ double* ccl_nu_masses(double OmNuh2, ccl_neutrino_mass_splits mass_split, double T_CMB, int* status) { double sumnu; double *mnu = NULL; sumnu = 93.14 * OmNuh2; // Now split the sum up into three masses depending on the label given: if (mass_split == ccl_nu_normal) { mnu = malloc(3*sizeof(double)); if (mnu == NULL) { *status = CCL_ERROR_MEMORY; } if (*status == 0) { // See CCL note for how we get these expressions for the neutrino masses in // normal and inverted hierarchy. mnu[0] = ( 2./3.* sumnu - 1./6. * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_pos + 4. * sumnu*sumnu, 0.5) - 0.25 * ccl_constants.DELTAM12_sq / (2./3.* sumnu - 1./6. * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_pos + 4. * sumnu*sumnu, 0.5))); mnu[1] = ( 2./3.* sumnu - 1./6. * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_pos + 4. * sumnu*sumnu, 0.5) + 0.25 * ccl_constants.DELTAM12_sq / (2./3.* sumnu - 1./6. * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_pos + 4. * sumnu*sumnu, 0.5))); mnu[2] = ( -1./3. * sumnu + 1./3 * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_pos + 4. * sumnu*sumnu, 0.5)); if (mnu[0] < 0 || mnu[1] < 0 || mnu[2] < 0) { // The user has provided a sum that is below the physical limit. if (sumnu < 1e-14) { mnu[0] = 0.; mnu[1] = 0.; mnu[2] = 0.; } else { *status = CCL_ERROR_MNU_UNPHYSICAL; ccl_raise_warning( *status, "CCL_ERROR_MNU_UNPHYSICAL: Sum of neutrinos masses for this Omeganu " "value is incompatible with the requested mass hierarchy."); } } } } else if (mass_split == ccl_nu_inverted) { mnu = malloc(3*sizeof(double)); if (mnu == NULL) { *status = CCL_ERROR_MEMORY; } if (*status == 0) { mnu[0] = ( 2./3.* sumnu - 1./6. * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_neg + 4. * sumnu * sumnu, 0.5) - 0.25 * ccl_constants.DELTAM12_sq / (2./3.* sumnu - 1./6. * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_neg + 4. * sumnu * sumnu, 0.5))); mnu[1] = ( 2./3.* sumnu - 1./6. * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_neg + 4. * sumnu*sumnu, 0.5) + 0.25 * ccl_constants.DELTAM12_sq / (2./3.* sumnu - 1./6. * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_neg + 4. * sumnu*sumnu, 0.5))); mnu[2] = ( -1./3. * sumnu + 1./3 * pow(-6. * ccl_constants.DELTAM12_sq + 12. * ccl_constants.DELTAM13_sq_neg + 4. * sumnu*sumnu, 0.5)); if (mnu[0] < 0 || mnu[1] < 0 || mnu[2] < 0) { // The user has provided a sum that is below the physical limit. if (sumnu < 1e-14) { mnu[0] = 0.; mnu[1] = 0.; mnu[2] = 0.;; } else { *status = CCL_ERROR_MNU_UNPHYSICAL; ccl_raise_warning( *status, "CCL_ERROR_MNU_UNPHYSICAL: Sum of neutrinos masses for this Omeganu " "value is incompatible with the requested mass hierarchy."); } } } } else if (mass_split == ccl_nu_equal) { mnu = malloc(3*sizeof(double)); if (mnu == NULL) { *status = CCL_ERROR_MEMORY; } if (*status == 0) { mnu[0] = sumnu/3.; mnu[1] = sumnu/3.; mnu[2] = sumnu/3.; } } else if (mass_split == ccl_nu_sum) { mnu = malloc(sizeof(double)); if (mnu == NULL) { *status = CCL_ERROR_MEMORY; } if (*status == 0) { mnu[0] = sumnu; } } else { *status = CCL_ERROR_MNU_UNPHYSICAL; ccl_raise_warning( *status, "mass option = %d not yet supported!", mass_split); } return mnu; } #undef GSL_EPSABS_NU #undef GSL_EPSREL_NU #undef GSL_N_ITERATION_NU
{ "alphanum_fraction": 0.6266642349, "avg_line_length": 33.5351681957, "ext": "c", "hexsha": "15d0cd7534b6aebf0c05ec450a301da391e62190", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-02-10T07:35:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-10T07:35:07.000Z", "max_forks_repo_head_hexsha": "3a5f9dec72c6ce602ac8b11ceed0ee6c0460a926", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "benediktdiemer/CCL", "max_forks_repo_path": "src/ccl_neutrinos.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a5f9dec72c6ce602ac8b11ceed0ee6c0460a926", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "benediktdiemer/CCL", "max_issues_repo_path": "src/ccl_neutrinos.c", "max_line_length": 131, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a5f9dec72c6ce602ac8b11ceed0ee6c0460a926", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "benediktdiemer/CCL", "max_stars_repo_path": "src/ccl_neutrinos.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3582, "size": 10966 }
#include <stdio.h> #include <gsl/gsl_integration.h> #include "function.h" extern double f (double, void*); int main (void) { /* Claim memory needed for adaptive integration */ gsl_integration_workspace * w = gsl_integration_workspace_alloc (1000); /* Construct GSL function object to describe solution */ gsl_function F; F.function = &f; double alpha = 1.0; F.params = NULL; /* Parameters to control quadrature routine */ double a, b, tol_abs, tol_rel; int limit; a = 0.0; b = 3.0; tol_abs = 0; tol_rel = 1.0e-7; limit = 1000; // Test that the function is implemented properly //double test = GSL_FN_EVAL(&F,2); //printf("TEST RESULT: %.18f\n", test); /* Actual call to quadrature routine */ double result, error; gsl_integration_qag (&F, a, b, tol_abs, tol_rel, limit, GSL_INTEG_GAUSS15, w, &result, &error); double mathematica_result = 1.29646778572437307899; printf ("result = % .18f\n", result); printf ("mathematica result = % .18f\n", mathematica_result); printf ("estimated error = % .18f\n", error); printf ("error vs. mathematica = % .18f\n", fabs(result - mathematica_result)); printf ("# intervals = %d\n", (int) w->size); /* Return memory allocated for solver */ gsl_integration_workspace_free (w); return 0; }
{ "alphanum_fraction": 0.6400293255, "avg_line_length": 26.2307692308, "ext": "c", "hexsha": "b70d7a82c887bd8f8de56ed83fb1c924a0ce48c9", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "42825cdbc4532d9da6ebdba549b65fb1e36456a0", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "gnu-user/mcsc-6030-assignments", "max_forks_repo_path": "Assignment-03/question-2/main.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "42825cdbc4532d9da6ebdba549b65fb1e36456a0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "gnu-user/mcsc-6030-assignments", "max_issues_repo_path": "Assignment-03/question-2/main.c", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "42825cdbc4532d9da6ebdba549b65fb1e36456a0", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "gnu-user/mcsc-6030-assignments", "max_stars_repo_path": "Assignment-03/question-2/main.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 385, "size": 1364 }
/* rstat/test.c * * Copyright (C) 2015 Patrick Alken * * 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 3 of the License, 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. */ #include <config.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <gsl/gsl_math.h> #include <gsl/gsl_rstat.h> #include <gsl/gsl_sort.h> #include <gsl/gsl_statistics.h> #include <gsl/gsl_test.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <gsl/gsl_ieee_utils.h> double * random_data(const size_t n, gsl_rng *r) { size_t i; double *data = malloc(n * sizeof(double)); for (i = 0; i < n; ++i) data[i] = gsl_rng_uniform(r); return data; } void test_basic(const size_t n, const double data[], const double tol) { gsl_rstat_workspace *rstat_workspace_p = gsl_rstat_alloc(); const double expected_mean = gsl_stats_mean(data, 1, n); const double expected_var = gsl_stats_variance(data, 1, n); const double expected_sd = gsl_stats_sd(data, 1, n); const double expected_sd_mean = expected_sd / sqrt((double) n); const double expected_skew = gsl_stats_skew(data, 1, n); const double expected_kurtosis = gsl_stats_kurtosis(data, 1, n); double expected_rms = 0.0; double mean, var, sd, sd_mean, rms, skew, kurtosis; size_t i, num; int status; /* compute expected rms */ for (i = 0; i < n; ++i) expected_rms += data[i] * data[i]; expected_rms = sqrt(expected_rms / n); /* add data to rstat workspace */ for (i = 0; i < n; ++i) gsl_rstat_add(data[i], rstat_workspace_p); mean = gsl_rstat_mean(rstat_workspace_p); var = gsl_rstat_variance(rstat_workspace_p); sd = gsl_rstat_sd(rstat_workspace_p); sd_mean = gsl_rstat_sd_mean(rstat_workspace_p); rms = gsl_rstat_rms(rstat_workspace_p); skew = gsl_rstat_skew(rstat_workspace_p); kurtosis = gsl_rstat_kurtosis(rstat_workspace_p); num = gsl_rstat_n(rstat_workspace_p); gsl_test_int(num, n, "n n=%zu" , n); gsl_test_rel(mean, expected_mean, tol, "mean n=%zu", n); gsl_test_rel(var, expected_var, tol, "variance n=%zu", n); gsl_test_rel(sd, expected_sd, tol, "stddev n=%zu", n); gsl_test_rel(sd_mean, expected_sd_mean, tol, "stddev_mean n=%zu", n); gsl_test_rel(rms, expected_rms, tol, "rms n=%zu", n); gsl_test_rel(skew, expected_skew, tol, "skew n=%zu", n); gsl_test_rel(kurtosis, expected_kurtosis, tol, "kurtosis n=%zu", n); status = gsl_rstat_reset(rstat_workspace_p); gsl_test_int(status, GSL_SUCCESS, "rstat returned success"); num = gsl_rstat_n(rstat_workspace_p); gsl_test_int(num, 0, "n n=%zu" , n); gsl_rstat_free(rstat_workspace_p); } void test_quantile(const double p, const double data[], const size_t n, const double expected, const double tol, const char *desc) { gsl_rstat_quantile_workspace *w = gsl_rstat_quantile_alloc(p); double result; size_t i; for (i = 0; i < n; ++i) gsl_rstat_quantile_add(data[i], w); result = gsl_rstat_quantile_get(w); if (fabs(expected) < 1.0e-4) gsl_test_abs(result, expected, tol, "%s p=%g", desc, p); else gsl_test_rel(result, expected, tol, "%s p=%g", desc, p); gsl_rstat_quantile_free(w); } int main() { gsl_rng *r = gsl_rng_alloc(gsl_rng_default); const double tol1 = 1.0e-8; const double tol2 = 1.0e-3; gsl_ieee_env_setup(); { const size_t N = 2000000; double *data = random_data(N, r); double data2[] = { 4.0, 7.0, 13.0, 16.0, -5.0 }; size_t i; test_basic(2, data, tol1); test_basic(100, data, tol1); test_basic(1000, data, tol1); test_basic(10000, data, tol1); test_basic(50000, data, tol1); test_basic(80000, data, tol1); test_basic(1500000, data, tol1); test_basic(2000000, data, tol1); for (i = 0; i < 5; ++i) data2[i] += 1.0e9; test_basic(5, data2, tol1); free(data); } { /* dataset from Jain and Chlamtac paper */ const size_t n_jain = 20; const double data_jain[] = { 0.02, 0.15, 0.74, 3.39, 0.83, 22.37, 10.15, 15.43, 38.62, 15.92, 34.60, 10.28, 1.47, 0.40, 0.05, 11.39, 0.27, 0.42, 0.09, 11.37 }; double expected_jain = 4.44063435326; test_quantile(0.5, data_jain, n_jain, expected_jain, tol1, "jain"); } { size_t n = 1000000; double *data = malloc(n * sizeof(double)); double *sorted_data = malloc(n * sizeof(double)); gsl_rstat_workspace *rstat_workspace_p = gsl_rstat_alloc(); double p; size_t i; for (i = 0; i < n; ++i) { data[i] = gsl_ran_gaussian_tail(r, 1.3, 1.0); gsl_rstat_add(data[i], rstat_workspace_p); } memcpy(sorted_data, data, n * sizeof(double)); gsl_sort(sorted_data, 1, n); /* test quantile calculation */ for (p = 0.1; p <= 0.9; p += 0.1) { double expected = gsl_stats_quantile_from_sorted_data(sorted_data, 1, n, p); test_quantile(p, data, n, expected, tol2, "gauss"); } /* test mean, variance */ { const double expected_mean = gsl_stats_mean(data, 1, n); const double expected_var = gsl_stats_variance(data, 1, n); const double expected_sd = gsl_stats_sd(data, 1, n); const double expected_skew = gsl_stats_skew(data, 1, n); const double expected_kurtosis = gsl_stats_kurtosis(data, 1, n); const double expected_median = gsl_stats_quantile_from_sorted_data(sorted_data, 1, n, 0.5); const double mean = gsl_rstat_mean(rstat_workspace_p); const double var = gsl_rstat_variance(rstat_workspace_p); const double sd = gsl_rstat_sd(rstat_workspace_p); const double skew = gsl_rstat_skew(rstat_workspace_p); const double kurtosis = gsl_rstat_kurtosis(rstat_workspace_p); const double median = gsl_rstat_median(rstat_workspace_p); gsl_test_rel(mean, expected_mean, tol1, "mean"); gsl_test_rel(var, expected_var, tol1, "variance"); gsl_test_rel(sd, expected_sd, tol1, "stddev"); gsl_test_rel(skew, expected_skew, tol1, "skew"); gsl_test_rel(kurtosis, expected_kurtosis, tol1, "kurtosis"); gsl_test_abs(median, expected_median, tol2, "median"); } free(data); free(sorted_data); gsl_rstat_free(rstat_workspace_p); } gsl_rng_free(r); exit (gsl_test_summary()); }
{ "alphanum_fraction": 0.6638836908, "avg_line_length": 31.7214611872, "ext": "c", "hexsha": "23d7b416cd3ecd254aae2c412ae162c3b75c5462", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-14T12:31:02.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-20T16:22:57.000Z", "max_forks_repo_head_hexsha": "83fd1fc4cbd053a4f9b673d5cd5841823ddd4d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "karanbirsandhu/nu-sense", "max_forks_repo_path": "test/lib/gsl-2.6/rstat/test.c", "max_issues_count": 6, "max_issues_repo_head_hexsha": "2c2e7c85f8414cb0e654cb82e9686cce5e75c63a", "max_issues_repo_issues_event_max_datetime": "2019-12-22T00:00:16.000Z", "max_issues_repo_issues_event_min_datetime": "2019-12-16T17:41:24.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ielomariala/Hex-Game", "max_issues_repo_path": "gsl-2.6/rstat/test.c", "max_line_length": 97, "max_stars_count": 1, "max_stars_repo_head_hexsha": "2c2e7c85f8414cb0e654cb82e9686cce5e75c63a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ielomariala/Hex-Game", "max_stars_repo_path": "gsl-2.6/rstat/test.c", "max_stars_repo_stars_event_max_datetime": "2021-06-14T11:51:37.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-14T11:51:37.000Z", "num_tokens": 2129, "size": 6947 }
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <time.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <gsl/gsl_math.h> typedef struct parameters{ double Xo; double Ko; double SIGMA2_K; double SIGMA2_C; double R; double MU; double SIGMA2_MU; }PAR; /****** Function Prototypes ******/ /* Model */ double Nhat(double x, double Ko, double SIGMA2_K); double C(double x, double y, double SIGMA2_C); /* Jump moment equations */ double alpha1(double phi, void *params); double alpha1_prime(double phi, void *params); /* Useful functions */ double round( double x); // rounding /*Main function */ void canonical ( PAR parameters, double MAX_TIME, double ENSEMBLES, double Dt, double dt ); void ratescalc ( gsl_rng *rng, double X, double Y, void *params, double *prob, double *wait_time ); int func (double t, const double y[], double f[], void *params); void gslode(void *params, double MAX_TIME, FILE *theory); void euler(void *params, double MAX_TIME, FILE *theory);
{ "alphanum_fraction": 0.6879100281, "avg_line_length": 18.3965517241, "ext": "h", "hexsha": "367423d899e17e13f5c0a9e696b295959846e6fe", "lang": "C", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-09-15T07:21:19.000Z", "max_forks_repo_forks_event_min_datetime": "2015-11-09T18:14:25.000Z", "max_forks_repo_head_hexsha": "d646a22b258d92199845446d914c1d3866e7b43f", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "kbroman/fluctuationDomains", "max_forks_repo_path": "src/canonical.h", "max_issues_count": 1, "max_issues_repo_head_hexsha": "d646a22b258d92199845446d914c1d3866e7b43f", "max_issues_repo_issues_event_max_datetime": "2020-02-18T20:55:31.000Z", "max_issues_repo_issues_event_min_datetime": "2020-02-18T20:44:09.000Z", "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "kbroman/fluctuationDomains", "max_issues_repo_path": "src/canonical.h", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "d646a22b258d92199845446d914c1d3866e7b43f", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "kbroman/fluctuationDomains", "max_stars_repo_path": "src/canonical.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 283, "size": 1067 }
/* Copyright 2018 Los Alamos National Laboratory * Copyright 2009-2018 The University of Tennessee and The University * of Tennessee Research Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _TESTSCOMMON_H #define _TESTSCOMMON_H /* parsec things */ #include "parsec.h" /* system and io */ #include <stdlib.h> #include <stdio.h> #include <string.h> /* Plasma and math libs */ #include <math.h> //#include <cblas.h> //#include <lapacke.h> //#include <core_blas.h> #include "parsec/profiling.h" #include "parsec/parsec_internal.h" #include "parsec/utils/debug.h" //#include "dplasma.h" #ifdef __cplusplus extern "C" { #endif /* these are globals in common.c */ extern const char *PARSEC_SCHED_NAME[]; extern int unix_timestamp; extern char cwd[]; /* Update PASTE_CODE_PROGRESS_KERNEL below if you change this list */ enum iparam_t { IPARAM_RANK, /* Rank */ IPARAM_NNODES, /* Number of nodes */ IPARAM_NCORES, /* Number of cores */ IPARAM_NGPUS, /* Number of GPUs */ IPARAM_P, /* Rows in the process grid */ IPARAM_Q, /* Columns in the process grid */ IPARAM_M, /* Number of rows of the matrix */ IPARAM_N, /* Number of columns of the matrix */ IPARAM_K, /* RHS or K */ IPARAM_LDA, /* Leading dimension of A */ IPARAM_LDB, /* Leading dimension of B */ IPARAM_LDC, /* Leading dimension of C */ IPARAM_IB, /* Inner-blocking size */ IPARAM_NB, /* Number of columns in a tile */ IPARAM_MB, /* Number of rows in a tile */ IPARAM_SNB, /* Number of columns in a super-tile */ IPARAM_SMB, /* Number of rows in a super-tile */ IPARAM_HMB, /* Small MB for recursive hdags */ IPARAM_HNB, /* Small NB for recursive hdags */ IPARAM_CHECK, /* Checking activated or not */ IPARAM_VERBOSE, /* How much noise do we want? */ IPARAM_SCHEDULER, /* User-selected scheduler */ IPARAM_SIZEOF }; #define PARSEC_SCHEDULER_DEFAULT 0 #define PARSEC_SCHEDULER_LFQ 1 #define PARSEC_SCHEDULER_LTQ 2 #define PARSEC_SCHEDULER_AP 3 #define PARSEC_SCHEDULER_LHQ 4 #define PARSEC_SCHEDULER_GD 5 #define PARSEC_SCHEDULER_PBQ 6 #define PARSEC_SCHEDULER_IP 7 #define PARSEC_SCHEDULER_RND 8 void iparam_default_gemm(int* iparam); void iparam_default_ibnbmb(int* iparam, int ib, int nb, int mb); #define PASTE_CODE_IPARAM_LOCALS(iparam) \ rank = iparam[IPARAM_RANK]; \ nodes = iparam[IPARAM_NNODES]; \ cores = iparam[IPARAM_NCORES]; \ gpus = iparam[IPARAM_NGPUS]; \ P = iparam[IPARAM_P]; \ Q = iparam[IPARAM_Q]; \ M = iparam[IPARAM_M]; \ N = iparam[IPARAM_N]; \ K = iparam[IPARAM_K]; \ NRHS = K; \ LDA = max(M, iparam[IPARAM_LDA]); \ LDB = max(N, iparam[IPARAM_LDB]); \ LDC = max(K, iparam[IPARAM_LDC]); \ IB = iparam[IPARAM_IB]; \ MB = iparam[IPARAM_MB]; \ NB = iparam[IPARAM_NB]; \ SMB = iparam[IPARAM_SMB]; \ SNB = iparam[IPARAM_SNB]; \ HMB = iparam[IPARAM_HMB]; \ HNB = iparam[IPARAM_HNB]; \ MT = (M%MB==0) ? (M/MB) : (M/MB+1); \ NT = (N%NB==0) ? (N/NB) : (N/NB+1); \ KT = (K%MB==0) ? (K/MB) : (K/MB+1); \ check = iparam[IPARAM_CHECK]; \ loud = iparam[IPARAM_VERBOSE]; \ scheduler = iparam[IPARAM_SCHEDULER]; \ (void)rank;(void)nodes;(void)cores;(void)gpus;(void)P;(void)Q;(void)M;(void)N;(void)K;(void)NRHS; \ (void)LDA;(void)LDB;(void)LDC;(void)IB;(void)MB;(void)NB;(void)MT;(void)NT;(void)KT; \ (void)SMB;(void)SNB;(void)HMB;(void)HNB;(void)check;(void)loud; \ (void)scheduler; /******************************* * globals values *******************************/ #if defined(PARSEC_HAVE_MPI) extern MPI_Datatype SYNCHRO; #endif /* PARSEC_HAVE_MPI */ void print_usage(void); void print_arguments(int* iparam); parsec_context_t *setup_parsec(int argc, char* argv[], int *iparam); void cleanup_parsec(parsec_context_t* parsec, int *iparam); /** * No macro with the name max or min is acceptable as there is * no way to correctly define them without borderline effects. */ #undef max #undef min static inline int max(int a, int b) { return a > b ? a : b; } static inline int min(int a, int b) { return a < b ? a : b; } /* Paste code to allocate a matrix in desc if cond_init is true */ #define PASTE_CODE_ALLOCATE_MATRIX(DC, COND, TYPE, INIT_PARAMS) \ if(COND) { \ DC.mat = parsec_data_allocate((size_t)DC.super.nb_local_tiles * \ (size_t)DC.super.bsiz * \ (size_t)parsec_datadist_getsizeoftype(DC.super.mtype)); \ parsec_data_collection_set_key((parsec_data_collection_t*)&DC, #DC); \ } #ifdef __cplusplus } #endif #endif /* _TESTSCOMMON_H */
{ "alphanum_fraction": 0.5202968797, "avg_line_length": 41.7848101266, "ext": "h", "hexsha": "635de63bdd9d879f835dcbf8b4ac12c0d38244c2", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a5a7dd36e383f194302dd816cf29f7f21b1f28a5", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "nicog98/task-bench", "max_forks_repo_path": "parsec/common.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "a5a7dd36e383f194302dd816cf29f7f21b1f28a5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "nicog98/task-bench", "max_issues_repo_path": "parsec/common.h", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "a5a7dd36e383f194302dd816cf29f7f21b1f28a5", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "nicog98/task-bench", "max_stars_repo_path": "parsec/common.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1597, "size": 6602 }
/* * VGMTrans (c) 2002-2019 * Licensed under the zlib license, * refer to the included LICENSE.txt file */ #pragma once #include <cstdint> #include <vector> #include <map> #include <string> #include <cassert> #include <climits> #include <gsl-lite.hpp> class RawFile; constexpr auto PSF_TAG_SIG = "[TAG]"; constexpr auto PSF_TAG_SIG_LEN = 5; constexpr auto PSF_STRIP_BUF_SIZE = 4096; class PSFFile2 { public: PSFFile2(const RawFile &file); ~PSFFile2() = default; uint8_t version() const noexcept { return m_version; } const std::map<std::string, std::string> &tags() const noexcept { return m_tags; } const std::vector<char> &exe() const noexcept { return m_exe_data; } const std::vector<char> &reservedSection() const noexcept { return m_reserved_data; } template <typename T> T getExe(size_t ind) const { assert(ind + sizeof(T) < m_exe_data.size()); T value = 0; for (size_t i = 0; i < sizeof(T); i++) { value |= (m_exe_data[ind + i] << (i * CHAR_BIT)); } return value; } template <typename T> T getRes(size_t ind) const { assert(ind + sizeof(T) < m_reserved_data.size()); T value = 0; for (size_t i = 0; i < sizeof(T); i++) { value |= (m_reserved_data[ind + i] << (i * CHAR_BIT)); } return value; } private: uint8_t m_version; uint32_t m_exe_CRC; std::vector<char> m_exe_data; std::vector<char> m_reserved_data; std::map<std::string, std::string> m_tags; void parseTags(gsl::span<const char> data); };
{ "alphanum_fraction": 0.6182158453, "avg_line_length": 24.6615384615, "ext": "h", "hexsha": "1b8487530b417367b6be71ed111179991461f04e", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2017-10-19T16:40:12.000Z", "max_forks_repo_forks_event_min_datetime": "2017-10-19T16:40:12.000Z", "max_forks_repo_head_hexsha": "6d0780bdaaac29ffe118b9be2e2ad87401b426fe", "max_forks_repo_licenses": [ "Zlib" ], "max_forks_repo_name": "sykhro/vgmtrans-qt", "max_forks_repo_path": "src/main/components/PSFFile2.h", "max_issues_count": 6, "max_issues_repo_head_hexsha": "6d0780bdaaac29ffe118b9be2e2ad87401b426fe", "max_issues_repo_issues_event_max_datetime": "2021-09-10T15:26:24.000Z", "max_issues_repo_issues_event_min_datetime": "2017-10-19T16:47:19.000Z", "max_issues_repo_licenses": [ "Zlib" ], "max_issues_repo_name": "sykhro/vgmtrans-qt", "max_issues_repo_path": "src/main/components/PSFFile2.h", "max_line_length": 89, "max_stars_count": 18, "max_stars_repo_head_hexsha": "6d0780bdaaac29ffe118b9be2e2ad87401b426fe", "max_stars_repo_licenses": [ "Zlib" ], "max_stars_repo_name": "sykhro/vgmtrans-qt", "max_stars_repo_path": "src/main/components/PSFFile2.h", "max_stars_repo_stars_event_max_datetime": "2021-05-26T02:52:22.000Z", "max_stars_repo_stars_event_min_datetime": "2018-01-04T17:42:15.000Z", "num_tokens": 439, "size": 1603 }
/* ieee-utils/read.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough * * 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 3 of the License, 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. */ #include <config.h> #include <stdlib.h> #include <string.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_ieee_utils.h> static int lookup_string (const char * p, int * precision, int * rounding, int * exception_mask) ; int gsl_ieee_read_mode_string (const char * description, int * precision, int * rounding, int * exception_mask) { char * start ; char * end; char * p; int precision_count = 0 ; int rounding_count = 0 ; int exception_count = 0 ; start = (char *) malloc(strlen(description) + 1) ; if (start == 0) { GSL_ERROR ("no memory to parse mode string", GSL_ENOMEM) ; } strcpy (start, description) ; p = start ; *precision = 0 ; *rounding = 0 ; *exception_mask = 0 ; do { int status ; int new_precision, new_rounding, new_exception ; end = strchr (p,',') ; if (end) { *end = '\0' ; do { end++ ; /* skip over trailing whitespace */ } while (*end == ' ' || *end == ',') ; } new_precision = 0 ; new_rounding = 0 ; new_exception = 0 ; status = lookup_string (p, &new_precision, &new_rounding, &new_exception) ; if (status) GSL_ERROR ("unrecognized GSL_IEEE_MODE string.\nValid settings are:\n\n" " single-precision double-precision extended-precision\n" " round-to-nearest round-down round-up round-to-zero\n" " mask-invalid mask-denormalized mask-division-by-zero\n" " mask-overflow mask-underflow mask-all\n" " trap-common trap-inexact\n" "\n" "separated by commas. " "(e.g. GSL_IEEE_MODE=\"round-down,mask-underflow\")", GSL_EINVAL) ; if (new_precision) { *precision = new_precision ; precision_count ++ ; if (precision_count > 1) GSL_ERROR ("attempted to set IEEE precision twice", GSL_EINVAL) ; } if (new_rounding) { *rounding = new_rounding ; rounding_count ++ ; if (rounding_count > 1) GSL_ERROR ("attempted to set IEEE rounding mode twice", GSL_EINVAL) ; } if (new_exception) { *exception_mask |= new_exception ; exception_count ++ ; } p = end ; } while (end && *p != '\0') ; free(start) ; return GSL_SUCCESS ; } static int lookup_string (const char * p, int * precision, int * rounding, int * exception_mask) { if (strcmp(p,"single-precision") == 0) { *precision = GSL_IEEE_SINGLE_PRECISION ; } else if (strcmp(p,"double-precision") == 0) { *precision = GSL_IEEE_DOUBLE_PRECISION ; } else if (strcmp(p,"extended-precision") == 0) { *precision = GSL_IEEE_EXTENDED_PRECISION ; } else if (strcmp(p,"round-to-nearest") == 0) { *rounding = GSL_IEEE_ROUND_TO_NEAREST ; } else if (strcmp(p,"round-down") == 0) { *rounding = GSL_IEEE_ROUND_DOWN ; } else if (strcmp(p,"round-up") == 0) { *rounding = GSL_IEEE_ROUND_UP ; } else if (strcmp(p,"round-to-zero") == 0) { *rounding = GSL_IEEE_ROUND_TO_ZERO ; } else if (strcmp(p,"mask-all") == 0) { *exception_mask = GSL_IEEE_MASK_ALL ; } else if (strcmp(p,"mask-invalid") == 0) { *exception_mask = GSL_IEEE_MASK_INVALID ; } else if (strcmp(p,"mask-denormalized") == 0) { *exception_mask = GSL_IEEE_MASK_DENORMALIZED ; } else if (strcmp(p,"mask-division-by-zero") == 0) { *exception_mask = GSL_IEEE_MASK_DIVISION_BY_ZERO ; } else if (strcmp(p,"mask-overflow") == 0) { *exception_mask = GSL_IEEE_MASK_OVERFLOW ; } else if (strcmp(p,"mask-underflow") == 0) { *exception_mask = GSL_IEEE_MASK_UNDERFLOW ; } else if (strcmp(p,"trap-inexact") == 0) { *exception_mask = GSL_IEEE_TRAP_INEXACT ; } else if (strcmp(p,"trap-common") == 0) { return 0 ; } else { return 1 ; } return 0 ; }
{ "alphanum_fraction": 0.5791044776, "avg_line_length": 25.7692307692, "ext": "c", "hexsha": "1de26e84ab78d832cd0cfd95b9e5633d34f4b5ce", "lang": "C", "max_forks_count": 14, "max_forks_repo_forks_event_max_datetime": "2020-03-12T12:31:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T04:47:52.000Z", "max_forks_repo_head_hexsha": "0cb4635af7602f2a243a9b739e5ed757424ab2a7", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "skair39/structured", "max_forks_repo_path": "CMVS-PMVS/program/thirdParty/gsl-1.13/ieee-utils/read.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "0cb4635af7602f2a243a9b739e5ed757424ab2a7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "skair39/structured", "max_issues_repo_path": "CMVS-PMVS/program/thirdParty/gsl-1.13/ieee-utils/read.c", "max_line_length": 81, "max_stars_count": 14, "max_stars_repo_head_hexsha": "2ad5bfb9c9684b1c800e96732a9e2f1e844b856f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "ruslankuzmin/julia", "max_stars_repo_path": "oldjuila/juliakernel/ext_libraries/gsl/ieee-utils/read.c", "max_stars_repo_stars_event_max_datetime": "2021-06-10T11:31:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-12-18T18:09:25.000Z", "num_tokens": 1350, "size": 5025 }
/* fft/gsl_fft_complex.h * * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough * * 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 2 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __GSL_FFT_COMPLEX_H__ #define __GSL_FFT_COMPLEX_H__ #include <stddef.h> #include <gsl/gsl_math.h> #include <gsl/gsl_complex.h> #include <gsl/gsl_fft.h> #undef __BEGIN_DECLS #undef __END_DECLS #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } #else # define __BEGIN_DECLS /* empty */ # define __END_DECLS /* empty */ #endif __BEGIN_DECLS /* Power of 2 routines */ int gsl_fft_complex_radix2_forward (gsl_complex_packed_array data, const size_t stride, const size_t n); int gsl_fft_complex_radix2_backward (gsl_complex_packed_array data, const size_t stride, const size_t n); int gsl_fft_complex_radix2_inverse (gsl_complex_packed_array data, const size_t stride, const size_t n); int gsl_fft_complex_radix2_transform (gsl_complex_packed_array data, const size_t stride, const size_t n, const gsl_fft_direction sign); int gsl_fft_complex_radix2_dif_forward (gsl_complex_packed_array data, const size_t stride, const size_t n); int gsl_fft_complex_radix2_dif_backward (gsl_complex_packed_array data, const size_t stride, const size_t n); int gsl_fft_complex_radix2_dif_inverse (gsl_complex_packed_array data, const size_t stride, const size_t n); int gsl_fft_complex_radix2_dif_transform (gsl_complex_packed_array data, const size_t stride, const size_t n, const gsl_fft_direction sign); int gsl_fft_complex_bitreverse_order (gsl_complex_packed_array data, size_t stride, size_t n, size_t n_bits); /* Mixed Radix general-N routines */ typedef struct { size_t n; size_t nf; size_t factor[64]; gsl_complex *twiddle[64]; gsl_complex *trig; } gsl_fft_complex_wavetable; typedef struct { size_t n; double *scratch; } gsl_fft_complex_workspace; gsl_fft_complex_wavetable *gsl_fft_complex_wavetable_alloc (size_t n); void gsl_fft_complex_wavetable_free (gsl_fft_complex_wavetable * wavetable); gsl_fft_complex_workspace *gsl_fft_complex_workspace_alloc (size_t n); void gsl_fft_complex_workspace_free (gsl_fft_complex_workspace * workspace); int gsl_fft_complex_memcpy (gsl_fft_complex_wavetable * dest, gsl_fft_complex_wavetable * src); int gsl_fft_complex_forward (gsl_complex_packed_array data, const size_t stride, const size_t n, const gsl_fft_complex_wavetable * wavetable, gsl_fft_complex_workspace * work); int gsl_fft_complex_backward (gsl_complex_packed_array data, const size_t stride, const size_t n, const gsl_fft_complex_wavetable * wavetable, gsl_fft_complex_workspace * work); int gsl_fft_complex_inverse (gsl_complex_packed_array data, const size_t stride, const size_t n, const gsl_fft_complex_wavetable * wavetable, gsl_fft_complex_workspace * work); int gsl_fft_complex_transform (gsl_complex_packed_array data, const size_t stride, const size_t n, const gsl_fft_complex_wavetable * wavetable, gsl_fft_complex_workspace * work, const gsl_fft_direction sign); __END_DECLS #endif /* __GSL_FFT_COMPLEX_H__ */
{ "alphanum_fraction": 0.5920843278, "avg_line_length": 35.4084507042, "ext": "h", "hexsha": "d2f2b7adb87aca23a10c93f7c66f99e2636a8478", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_forks_event_min_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ICML14MoMCompare/spectral-learn", "max_forks_repo_path": "code/em/treba/gsl-1.0/fft/gsl_fft_complex.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ICML14MoMCompare/spectral-learn", "max_issues_repo_path": "code/em/treba/gsl-1.0/fft/gsl_fft_complex.h", "max_line_length": 76, "max_stars_count": 14, "max_stars_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ICML14MoMCompare/spectral-learn", "max_stars_repo_path": "code/em/treba/gsl-1.0/fft/gsl_fft_complex.h", "max_stars_repo_stars_event_max_datetime": "2021-06-10T11:31:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-12-18T18:09:25.000Z", "num_tokens": 981, "size": 5028 }
#ifndef _AVA_COMMON_SUPPORT_GEN_STAT_H_ #define _AVA_COMMON_SUPPORT_GEN_STAT_H_ #include <fmt/format.h> #include <stdint.h> #include <gsl/gsl> #include "common/extensions/cmd_batching.h" #include "common/support/io.h" #include "guestlib/guest_thread.h" #include "time_util.h" namespace ava { namespace support { inline void stats_end(const char *func_name, int64_t begin_ts) { auto end_ts = ava::GetMonotonicNanoTimestamp(); fmt::memory_buffer output; fmt::format_to(output, "GuestlibStat {}, {}\n", func_name, gsl::narrow_cast<int32_t>(end_ts - begin_ts)); ava::guest_write_stats(output.data(), output.size()); } } // namespace support } // namespace ava #endif // _AVA_COMMON_SUPPORT_GEN_STAT_H_
{ "alphanum_fraction": 0.7555865922, "avg_line_length": 25.5714285714, "ext": "h", "hexsha": "2f116aee19250670979381d1e75bdbaec8d37942", "lang": "C", "max_forks_count": 15, "max_forks_repo_forks_event_max_datetime": "2021-11-18T03:35:13.000Z", "max_forks_repo_forks_event_min_datetime": "2020-01-31T21:25:14.000Z", "max_forks_repo_head_hexsha": "a5905414c5234784fda3ca061d26f855f9fbd1d4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "photoszzt/ava", "max_forks_repo_path": "common/support/gen_stat.h", "max_issues_count": 81, "max_issues_repo_head_hexsha": "a5905414c5234784fda3ca061d26f855f9fbd1d4", "max_issues_repo_issues_event_max_datetime": "2021-07-14T12:22:47.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-16T02:47:04.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "photoszzt/ava", "max_issues_repo_path": "common/support/gen_stat.h", "max_line_length": 107, "max_stars_count": 24, "max_stars_repo_head_hexsha": "a5905414c5234784fda3ca061d26f855f9fbd1d4", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "photoszzt/ava", "max_stars_repo_path": "common/support/gen_stat.h", "max_stars_repo_stars_event_max_datetime": "2021-08-03T23:48:14.000Z", "max_stars_repo_stars_event_min_datetime": "2020-01-31T21:25:10.000Z", "num_tokens": 180, "size": 716 }
#pragma once #include <Strategic/Solver.h> #include <Sudoku/Board.h> #include <Sudoku/Location_Utilities.h> #include <Sudoku/Options.h> #include <gsl/gsl> #include <string> #include <iomanip> // setw(), setfill() #include <sstream> #include <utility> namespace Sudoku { // Solver-function declarations: template<int N> void test_solver_unique(Board<Options<elem_size<N>>, N>&); template<int N> void test_solver_exclusive(Board<Options<elem_size<N>>, N>&); template<int N> Board<Value, N> getResult(Board<Options<elem_size<N>>, N> const&) noexcept; //====--------------------------------------------------------------------====// class Console { struct delimiter { char space; char empty; std::string row_block; std::string col_block; std::string newl; std::string block_cross; }; const delimiter space{' ', ' ', "", "", "", ""}; const delimiter space2{' ', ' ', "", "", "\n", ""}; const delimiter display{' ', ' ', "-", "|", "\n", "o"}; // const delimiter csv; // const delimiter xml; public: Console() noexcept; explicit Console(delimiter); //~Console() = default; template<int N> std::stringstream print_row(const Board<int, N>&, gsl::index row_id) const; template<int N, int E> std::stringstream print_row(const Board<Options<E>, N>&, gsl::index row_id) const; template<int N> std::stringstream print_board(const Board<int, N>&) const; template<int N, int E> std::stringstream print_board(const Board<Options<E>, N>&) const; private: const delimiter d; // bool Format::find_option(const Board<std::set<int>>&,Location,int value); // format elem // format col-block section // format row-block = separator line }; //====--------------------------------------------------------------------====// // Member-functions: inline Console::Console() noexcept : d(display) { // empty constructor } inline Console::Console(delimiter del) : d(std::move(del)) { // empty constructor } namespace impl { [[nodiscard]] constexpr int pow(int const base, int exp) { if (exp == 0) { return 1; } return base * pow(base, --exp); } [[nodiscard]] constexpr int charsize(int value, int length) { constexpr int decimal{10}; if (value < pow(decimal, length)) { return length; } ++length; return charsize(value, length); } [[nodiscard]] constexpr int charsize(int value) { constexpr int decimal{10}; if (value < decimal) { return 1; } return charsize(value, 2); } } // namespace impl template<int N> std::stringstream Console::print_row(const Board<int, N>& input, gsl::index row_id) const { std::stringstream stream; constexpr int chars = impl::charsize(elem_size<N>) + 1; stream << d.col_block << std::setfill(d.space); for (gsl::index i = 0; i < elem_size<N>; ++i) { if (input[row_id][i] == 0) // no value { stream << std::setw(chars) << d.space; } else { stream << std::setw(chars) << input[row_id][i]; } if ((i + 1) % base_size<N> == 0) { stream << std::setw(2) << d.col_block; } } return stream; } template<int N> std::stringstream Console::print_board(const Board<int, N>& input) const { std::stringstream stream; std::stringstream temp; constexpr int chars = impl::charsize(elem_size<N>) + 1; // opening bar temp << d.block_cross; for (gsl::index j = 0; j < base_size<N>; ++j) { temp << std::setfill(d.row_block[0]) << std::setw(chars * base_size<N> + 2) << d.block_cross; } std::string bar; temp >> bar; stream << bar << '\n'; // loop rows for (gsl::index i = 0; i < elem_size<N>; ++i) { stream << print_row(input, i).str() << d.newl; if ((i + 1) % base_size<N> == 0) { stream << bar << '\n'; } } return stream; } template<int N, int E> std::stringstream Console::print_board(const Board<Options<E>, N>& input) const { static_assert(E == N * N); constexpr gsl::index block_size = elem_size<N> + base_size<N> + 2; constexpr gsl::index row_length = base_size<N> * block_size; /* 9 9 9 o-----------------------------------------o | 123 123 123 | 123 123 123 | 123 123 123 | | 456 456 456 | 456 456 456 | 456 456 456 | 9 | 789 789 | | 123 123 | ... o-----------------------------------------o | */ std::stringstream stream; std::stringstream n0; // horizontal block separator std::stringstream n4; // vertical element separator n0 << std::setfill(d.row_block[0]) << d.block_cross << std::setw(row_length) << d.block_cross << d.newl; n4 << std::setfill(' ') << std::setw(block_size) << d.col_block; stream << std::setfill(d.empty) << std::setw(base_size<N>); stream << '\n' << n0.str(); for (gsl::index row{0}; row < elem_size<N>; ++row) { stream << print_row(input, row).str(); if ((row + 1) % base_size<N> == 0) { stream << n0.str(); } else { stream << '|'; for (gsl::index index{}; index < base_size<N>; ++index) { stream << n4.str(); } stream << '\n'; } } return stream; } template<int N, int E> std::stringstream Console::print_row( const Board<Options<E>, N>& input, gsl::index row_id) const { std::stringstream stream; gsl::index X{1}; for (gsl::index k{0}; k < base_size<N>; ++k) { stream << d.col_block << d.space; for (gsl::index col{0}; col < elem_size<N>; ++col) { for (gsl::index i{X}; i < X + base_size<N>; ++i) { if (input[row_id][col].test(to_Value<N>(i))) { stream << i; } else { stream << d.empty; } } if ((col + 1) % base_size<N> == 0) { stream << std::setfill(d.space) << std::setw(2) << d.col_block << d.space; } else { stream << d.space; } } stream << d.newl; X += base_size<N>; } return stream; } //====--------------------------------------------------------------------====// // Solver function applications: template<int N> // NOLINTNEXTLINE(runtime/references) void test_solver_unique(Board<Options<elem_size<N>>, N>& board) { int found{1}; while (found > 0) { found = 0; for (gsl::index i = 0; i < elem_size<N>; ++i) { found += unique_in_section(board, board.row(i)); } for (gsl::index i = 0; i < elem_size<N>; ++i) { found += unique_in_section(board, board.col(i)); } for (gsl::index i = 0; i < elem_size<N>; ++i) { found += unique_in_section(board, board.block(i)); } } } template<int N> // NOLINTNEXTLINE(runtime/references) void test_solver_exclusive(Board<Options<elem_size<N>>, N>& board) { int found{1}; while (found > 0) { found = 0; for (gsl::index i = 0; i < elem_size<N>; ++i) { found += section_exclusive(board, board.row(i)); } for (gsl::index i = 0; i < elem_size<N>; ++i) { found += section_exclusive(board, board.col(i)); } for (gsl::index i = 0; i < elem_size<N>; ++i) { found += section_exclusive(board, board.block(i)); } } } template<int N> Board<Value, N> getResult(const Board<Options<elem_size<N>>, N>& options) noexcept { Board<Value, N> result{}; for (gsl::index i = 0; i < full_size<N>; ++i) { if (options[Location<N>(i)].is_answer()) { result[Location<N>(i)] = get_answer(options[Location<N>(i)]); } } return result; } } // namespace Sudoku
{ "alphanum_fraction": 0.5892606129, "avg_line_length": 21.9567901235, "ext": "h", "hexsha": "be0804f9e859bdfcc401dea2b95acdb72b309cbd", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-20T16:26:42.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-20T16:26:42.000Z", "max_forks_repo_head_hexsha": "05652d80fae2780f1327467225580e2c67dfa692", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Farwaykorse/fwkSudoku", "max_forks_repo_path": "Console/Console.h", "max_issues_count": 38, "max_issues_repo_head_hexsha": "05652d80fae2780f1327467225580e2c67dfa692", "max_issues_repo_issues_event_max_datetime": "2021-07-17T01:22:35.000Z", "max_issues_repo_issues_event_min_datetime": "2018-12-28T18:15:15.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Farwaykorse/fwkSudoku", "max_issues_repo_path": "Console/Console.h", "max_line_length": 80, "max_stars_count": 2, "max_stars_repo_head_hexsha": "05652d80fae2780f1327467225580e2c67dfa692", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Farwaykorse/fwkSudoku", "max_stars_repo_path": "Console/Console.h", "max_stars_repo_stars_event_max_datetime": "2019-08-18T19:26:28.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-17T18:27:16.000Z", "num_tokens": 2131, "size": 7114 }
#ifndef KABSCH_RMSD #define KABSCH_RMSD #include <valarray> #include <cblas.h> #include <lapacke.h> namespace kabsch { template <class M> double rmsd( const M P, const M Q) { double rmsd {0.0}; const unsigned int D {3}; const unsigned int size = P.size(); const unsigned int N = size / D; for(unsigned int i = 0; i < size; ++i) { rmsd += (P[i] - Q[i])*(P[i] - Q[i]); } return sqrt(rmsd/N); } template <class M> M centroid(M coordinates) { double x {0}; double y {0}; double z {0}; unsigned int size = coordinates.size(); unsigned int n_atoms = size / 3; unsigned int i = 0; while(i<size) { x += coordinates[i++]; y += coordinates[i++]; z += coordinates[i++]; } x /= n_atoms; y /= n_atoms; z /= n_atoms; return M {x, y, z}; } template <class Matrix> Matrix multiply(Matrix A, Matrix B, const int M, const int N, const int K) { double one = 1.0; Matrix C(M*N); cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, one, begin(A), K, begin(B), N, 1.0, begin(C), N); return C; } template <class Matrix> Matrix transpose_multiply(Matrix A, Matrix B, const int M, const int N, const int K) { double one = 1.0; Matrix C(M*N); cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans, M, N, K, one, begin(A), M, begin(B), N, one, begin(C), N); return C; } template <class Matrix> std::tuple<Matrix, Matrix, Matrix> matrix_svd(Matrix A, int rows, int cols) { // lapack_int LAPACKE_dgesvd( int matrix_layout, char jobu, char jobvt, // lapack_int m, lapack_int n, // double* a, lapack_int lda, // double* s, double* u, lapack_int ldu, // double* vt, lapack_int ldvt, // double* superb ); Matrix U(cols*rows); Matrix S(rows); Matrix VT(cols*rows); Matrix superb(cols*rows); int info; info = LAPACKE_dgesvd(LAPACK_ROW_MAJOR, 'A', 'A', rows, cols, begin(A), rows, begin(S), begin(U), rows, begin(VT), rows, begin(superb)); // TODO check if SVD is unconverged if(info > 0) { // Failed } return make_tuple(U, S, VT); } template <class M> double determinant3x3(M A) { // determinant of a square 3x3 matrix double det = A[0]*A[4]*A[8] +A[1]*A[5]*A[6] +A[2]*A[3]*A[7] -A[2]*A[4]*A[6] -A[1]*A[3]*A[8] -A[0]*A[5]*A[7]; return det; } template <class M, class T> M kabsch(M P, M Q, const T n_atoms) { // const unsigned int L = P.size(); // const unsigned int D = 3; M U; M V; M S; M C = transpose_multiply(P, Q, 3, 3, n_atoms); tie(U, S, V) = matrix_svd(C, 3, 3); // Getting the sign of the det(U)*(V) to decide whether we need to correct // our rotation matrix to ensure a right-handed coordinate system. if(determinant3x3(U)*determinant3x3(V) < 0.0) { // TODO More numpy'ish way to do this? U[std::slice( 2, 3, 3 )] = {-U[3*0+2], -U[3*1+2], -U[3*2+2]}; } M rotation = multiply(U, V, 3, 3, 3); return rotation; } template <class M, class T> M kabsch_rotate( const M P, const M Q, const T n_atoms) { M U = kabsch(P, Q, n_atoms); M product = multiply(P, U, n_atoms, 3, 3); return product; } template <class M, class T> double kabsch_rmsd( const M P, const M Q, const T n_atoms) { M P_rotated = kabsch_rotate(P, Q, n_atoms); return rmsd(P_rotated, Q); } } // namespace rmsd #endif
{ "alphanum_fraction": 0.5484832069, "avg_line_length": 18.46, "ext": "h", "hexsha": "00577eba7bb57904ac300e9aec8da16a71ee2d50", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-11-30T06:56:51.000Z", "max_forks_repo_forks_event_min_datetime": "2020-11-30T06:56:51.000Z", "max_forks_repo_head_hexsha": "8cd6adf6ca736ead1be745130efd6e3341e940df", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "kjappelbaum/rmsd", "max_forks_repo_path": "rmsd++/kabsch.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "8cd6adf6ca736ead1be745130efd6e3341e940df", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "kjappelbaum/rmsd", "max_issues_repo_path": "rmsd++/kabsch.h", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "8cd6adf6ca736ead1be745130efd6e3341e940df", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "kjappelbaum/rmsd", "max_stars_repo_path": "rmsd++/kabsch.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1183, "size": 3692 }
/* histogram/test.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough * * 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 2 of the License, 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. */ #include <config.h> #include <stdlib.h> #include <stdio.h> #include <gsl/gsl_histogram.h> #include <gsl/gsl_test.h> #include <gsl/gsl_ieee_utils.h> void test1d (void); void test2d (void); void test1d_resample (void); void test2d_resample (void); void test1d_trap (void); void test2d_trap (void); int main (void) { test1d(); test2d(); test1d_resample(); test2d_resample(); test1d_trap(); test2d_trap(); exit (gsl_test_summary ()); }
{ "alphanum_fraction": 0.7234548336, "avg_line_length": 27.4347826087, "ext": "c", "hexsha": "c170de8e13c9cb0a0d8e936ce406377db7ce9ff5", "lang": "C", "max_forks_count": 40, "max_forks_repo_forks_event_max_datetime": "2022-03-03T23:23:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-26T15:31:16.000Z", "max_forks_repo_head_hexsha": "d14edfb62795805c84a4280d67b50cca175b95af", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "manggoguy/parsec-modified", "max_forks_repo_path": "pkgs/libs/gsl/src/histogram/test.c", "max_issues_count": 12, "max_issues_repo_head_hexsha": "d14edfb62795805c84a4280d67b50cca175b95af", "max_issues_repo_issues_event_max_datetime": "2022-03-13T03:54:24.000Z", "max_issues_repo_issues_event_min_datetime": "2020-12-15T08:30:19.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "manggoguy/parsec-modified", "max_issues_repo_path": "pkgs/libs/gsl/src/histogram/test.c", "max_line_length": 81, "max_stars_count": 64, "max_stars_repo_head_hexsha": "d14edfb62795805c84a4280d67b50cca175b95af", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "manggoguy/parsec-modified", "max_stars_repo_path": "pkgs/libs/gsl/src/histogram/test.c", "max_stars_repo_stars_event_max_datetime": "2022-03-24T13:26:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-06T00:30:56.000Z", "num_tokens": 347, "size": 1262 }
#pragma once #include <gsl/span> #include "aas/aas_math.h" namespace aas { class Skeleton; struct SkelAnim; struct SkelBoneState; struct AnimPlayerStreamHeader { int field0; int field1; int field2; int8_t pad[3]; }; struct AnimPlayerStreamBone { DX::XMFLOAT4 prevScale; DX::XMFLOAT4 scale; DX::XMFLOAT4 prevRotation; DX::XMFLOAT4 rotation; DX::XMFLOAT4 prevTranslation; DX::XMFLOAT4 translation; int16_t scaleFrame; int16_t scaleNextFrame; int16_t rotationFrame; int16_t rotationNextFrame; int16_t translationFrame; int16_t translationNextFrame; int field6C; }; struct AnimPlayerStream { const Skeleton* skeleton; const SkelAnim* animation; int streamIdx; float scaleFactor; float translationFactor; float currentFrame; void* keyframePtr; int boneCount; AnimPlayerStreamBone bones[1]; //set according to skafile bone count AnimPlayerStream(AnimPlayerStream&) = delete; AnimPlayerStream(AnimPlayerStream&&) = delete; AnimPlayerStream& operator=(AnimPlayerStream&) = delete; AnimPlayerStream& operator=(AnimPlayerStream&&) = delete; void SetFrame(float frame); void Initialize(const SkelAnim *animation, int streamIdx); void GetBoneState(gsl::span<SkelBoneState> boneStateOut); float GetCurrentFrame() const; }; }
{ "alphanum_fraction": 0.7515337423, "avg_line_length": 21.0322580645, "ext": "h", "hexsha": "626bf6c15ef29e69167d7b5bf433c00baa2eb60e", "lang": "C", "max_forks_count": 25, "max_forks_repo_forks_event_max_datetime": "2021-11-15T23:14:51.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-04T21:19:53.000Z", "max_forks_repo_head_hexsha": "f0e552289822fea908f16daa379fa568b1bd286d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "edoipi/TemplePlus", "max_forks_repo_path": "Infrastructure/src/aas/aas_anim_player_stream.h", "max_issues_count": 457, "max_issues_repo_head_hexsha": "f0e552289822fea908f16daa379fa568b1bd286d", "max_issues_repo_issues_event_max_datetime": "2022-03-31T02:19:10.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-01T22:07:45.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "edoipi/TemplePlus", "max_issues_repo_path": "Infrastructure/src/aas/aas_anim_player_stream.h", "max_line_length": 70, "max_stars_count": 69, "max_stars_repo_head_hexsha": "f0e552289822fea908f16daa379fa568b1bd286d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "edoipi/TemplePlus", "max_stars_repo_path": "Infrastructure/src/aas/aas_anim_player_stream.h", "max_stars_repo_stars_event_max_datetime": "2022-02-15T06:13:04.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-05T14:09:25.000Z", "num_tokens": 362, "size": 1304 }
#ifndef POINTCLOUD_H_8O5EBVHZ #define POINTCLOUD_H_8O5EBVHZ #include <Eigen/Core> #include <algorithm> #include <gsl/gsl> #include <sens_loc/math/coordinate.h> #include <sens_loc/math/image.h> namespace sens_loc::math { /// A pointcloud is a set of camera coordinates. template <typename Real> using pointcloud = std::vector<camera_coord<Real>>; using pointcloud_t = pointcloud<float>; /// A set of pixel coordinates. template <typename Real> using imagepoints = std::vector<pixel_coord<Real>>; using imagepoints_t = imagepoints<float>; /// Calculate the point-wise euclidean distance between each point in \c c0 /// and \c c1. /// The result is a row-vector with the distance for point 'i' at position 'i'. /// \tparam one of \c pointcloud or \c imagepoints. /// \pre c0.size() == c1.size() => the same number of points /// \post each element in the result is non-negative. template <typename Points> std::vector<typename Points::value_type::real> pointwise_distance(const Points& c0, const Points& c1) noexcept { Expects(c0.size() == c1.size()); std::vector<typename Points::value_type::real> distances; if (c0.empty()) return distances; distances.reserve(c0.size()); for (std::size_t i = 0; i < c0.size(); ++i) distances.emplace_back((c0[i] - c1[i]).norm()); Ensures(distances.size() == c0.size()); Ensures(distances.size() == c1.size()); Ensures(*std::min_element(distances.begin(), distances.end()) >= 0.0F); return distances; } /// A pose is an affine transformation in 3 dimensions. Internally this is /// processed with homogeneous coordinates. /// \sa pointcloud_t using pose_t = Eigen::Matrix4f; /// Calculate the relative pose to get from \c from to \c to. /// /// Let \c O be the origin of a coordinate system, \c from and \c to are both /// absolute poses in this coordinate system. /// \c relative_pose calculates the relative pose to get from \c from to \c to. /// \pre both poses need to be valid /// \pre \c from must be invertable => pose is valid inline pose_t relative_pose(const pose_t& from, const pose_t& to) noexcept { return from.inverse() * to; } /// Translate and rotate all points in \c points with the transformation \c p. inline pointcloud_t operator*(const pose_t& p, const pointcloud_t& points) noexcept { pointcloud_t result; result.reserve(points.size()); for (const auto& pt : points) { Eigen::Vector4f tr = p * Eigen::Vector4f{pt.X(), pt.Y(), pt.Z(), 1.0F}; result.emplace_back(tr.x(), tr.y(), tr.z()); } return result; } } // namespace sens_loc::math #endif /* end of include guard: POINTCLOUD_H_8O5EBVHZ */
{ "alphanum_fraction": 0.6817675455, "avg_line_length": 33.6625, "ext": "h", "hexsha": "e2bc2e3eff484efa9a6de12d080e9aa43d630032", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5c8338276565d846c07673e83f94f6841006872b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "JonasToth/depth-conversions", "max_forks_repo_path": "src/include/sens_loc/math/pointcloud.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "5c8338276565d846c07673e83f94f6841006872b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "JonasToth/depth-conversions", "max_issues_repo_path": "src/include/sens_loc/math/pointcloud.h", "max_line_length": 79, "max_stars_count": 2, "max_stars_repo_head_hexsha": "5c8338276565d846c07673e83f94f6841006872b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "JonasToth/depth-conversions", "max_stars_repo_path": "src/include/sens_loc/math/pointcloud.h", "max_stars_repo_stars_event_max_datetime": "2022-03-14T09:14:35.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-30T07:09:49.000Z", "num_tokens": 697, "size": 2693 }
#ifndef config_e9763ac5_66db_439d_99b9_4c84c1b41e14_h #define config_e9763ac5_66db_439d_99b9_4c84c1b41e14_h #include <gslib\config.h> #ifdef __cplusplus #define __rathen_begin__ namespace gs { namespace rathen { #define __rathen_end__ }; }; #endif /* rathen source postfix & binary postfix */ #define rathen_spf _t(".rs") #define rathen_bpf _t(".rb") #endif
{ "alphanum_fraction": 0.7377892031, "avg_line_length": 22.8823529412, "ext": "h", "hexsha": "f10af7b559cdc2109807b981686a3c249b6991da", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-10-19T15:20:58.000Z", "max_forks_repo_forks_event_min_datetime": "2016-10-19T15:20:58.000Z", "max_forks_repo_head_hexsha": "1b165b7a812526c4b2a3179588df9a7c2ff602a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lymastee/gslib", "max_forks_repo_path": "include/rathen/config.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b165b7a812526c4b2a3179588df9a7c2ff602a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lymastee/gslib", "max_issues_repo_path": "include/rathen/config.h", "max_line_length": 62, "max_stars_count": 9, "max_stars_repo_head_hexsha": "1b165b7a812526c4b2a3179588df9a7c2ff602a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lymastee/gslib", "max_stars_repo_path": "include/rathen/config.h", "max_stars_repo_stars_event_max_datetime": "2022-02-11T09:44:51.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-18T09:40:09.000Z", "num_tokens": 133, "size": 389 }
/* ieee-utils/demo.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough * * 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 3 of the License, 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. */ #include <float.h> #include <stdio.h> #include <gsl/gsl_ieee_utils.h> int main () { int i ; double x = 10 ; float f = 1.0/3.0 ; double d = 1.0/3.0 ; double fd = f ; /* promote from float to double */ gsl_ieee_env_setup() ; printf(" float 1/3 = ") ; gsl_ieee_printf_float(&f) ; printf("\n") ; printf("promoted float = ") ; gsl_ieee_printf_double(&fd) ; printf("\n") ; printf(" double 1/3 = ") ; gsl_ieee_printf_double(&d) ; printf("\n") ; for (i=0;i<10;i++) { x = 0.5 *(x + 2.0/x) ; printf("%.18g ",x) ; gsl_ieee_printf_double(&x) ; printf("\n") ; } x = 10 * x * GSL_DBL_MAX ; printf("%.18g ",x) ; gsl_ieee_printf_double(&x) ; printf("\n") ; x = x / 0 ; ; printf("%.18g ",x) ; gsl_ieee_printf_double(&x) ; printf("\n") ; f = -1.0/3.0 ; while (f < 0) { f = f / 10 ; printf("%.18g ",f) ; gsl_ieee_printf_float(&f) ; printf("\n") ; } }
{ "alphanum_fraction": 0.6265822785, "avg_line_length": 27.15625, "ext": "c", "hexsha": "fe579a88239a61d84589d4f022b08e3991a7479a", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-14T12:31:02.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-20T16:22:57.000Z", "max_forks_repo_head_hexsha": "df1bbf6bea0b87b8c7c9a99dce213fdc249118f2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zzpwahaha/Chimera-Control-Trim", "max_forks_repo_path": "Chimera/3rd_Party/GSL_MSVC/ieee-utils/demo.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "df1bbf6bea0b87b8c7c9a99dce213fdc249118f2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "zzpwahaha/Chimera-Control-Trim", "max_issues_repo_path": "Chimera/3rd_Party/GSL_MSVC/ieee-utils/demo.c", "max_line_length": 81, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df1bbf6bea0b87b8c7c9a99dce213fdc249118f2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zzpwahaha/Chimera-Control-Trim", "max_stars_repo_path": "Chimera/3rd_Party/GSL_MSVC/ieee-utils/demo.c", "max_stars_repo_stars_event_max_datetime": "2021-06-14T11:51:37.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-14T11:51:37.000Z", "num_tokens": 550, "size": 1738 }
/* DomSelfAdaptFWD.c Forward-in-time simulation of an adaptive alleles with dominance and selfing, with linked neutral fragment. This is the BATCH version - to be used on cluster machine to produce many simulation replicates at once. Burn-in program: generates neutral background diversity for other simulations to use. See README for more information. Simulation uses routines found with the GNU Scientific Library (GSL) (http://www.gnu.org/software/gsl/) Since GSL is distributed under the GNU General Public License (http://www.gnu.org/copyleft/gpl.html), you must download it separately from this file. */ /* Preprocessor statements */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <stddef.h> #include <string.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <sys/stat.h> #include <sys/types.h> #define INITTS 1000 /* Function prototypes */ void Wait(); unsigned int bitswitch(unsigned int x); void generation_BI(unsigned int N, double self, double R, unsigned int *nums, unsigned int **neutin, unsigned int **neutout, unsigned int npoly, double *polypos, const gsl_rng *r); void rec_sort(double *index, unsigned int nrow); void addpoly(unsigned int N, unsigned int **neutin, double *polyloc, unsigned int *npoly, double theta, const gsl_rng *r); void reassign2(unsigned int **neutin, unsigned int **neutout, double *posin, double *posout, unsigned int npoly, unsigned int N, unsigned int aft); void popprint(unsigned int **neutin, double *posin, unsigned int npoly, unsigned int N, unsigned int ei, unsigned int suffix); void polyprint(unsigned int **neutin, double *posin, unsigned int npoly, unsigned int N); void ptrim(unsigned int size, unsigned int **neutin, unsigned int **neutout, double *posin, double *posout, unsigned int npoly, unsigned int *npolyT, double *avpi); unsigned int uniqueH(unsigned int **neutin, unsigned int npoly, unsigned int N); void Wait(){ printf("Press Enter to Continue"); while( getchar() != '\n' ); printf("\n"); } /* Bit-switching routine */ unsigned int bitswitch(unsigned int x){ unsigned int ret; switch(x) { case 0: ret = 1; break; case 1: ret = 0; break; default: /* If none of these cases chosen, exit with error message */ fprintf(stderr,"Error in bitswitch: input is not 0 or 1.\n"); exit(1); break; } return ret; } /* Sorting rec events after choosing them */ void rec_sort(double *index, unsigned int nrow){ unsigned int j, i; /* Sorting indices */ double temp0; /* For swapping */ for(j = 1; j < nrow; j++){ i = j; while( (i > 0) && ( *(index + (i - 1) ) > *(index + i) )){ /* Swapping entries */ temp0 = *(index + (i - 1)); *(index + (i - 1)) = *(index + (i)); *(index + (i)) = temp0; i--; } } } /* Reproduction routine */ void generation_BI(unsigned int N, double self, double R, unsigned int *nums, unsigned int **neutin, unsigned int **neutout, unsigned int npoly, double *polypos, const gsl_rng *r){ unsigned int i, j, k; /* Pop counter, neutral marker counter, rec event counter */ unsigned int isself = 0; /* Is this a selfing reproduction? */ unsigned int choose1 = 0; /* Chromosome to be selected */ unsigned int choose2 = 0; /* Chromosome to be selected (2nd with outcrossing) */ unsigned int wc1 = 0; /* Which chrom (parent 1) */ unsigned int wc2 = 0; /* Which chrom (parent 2) */ unsigned int index1 = 0; /* Index of chosen sample 1 */ unsigned int index2 = 0; /* Index of chosen sample 2 */ unsigned int nself = 0; /* Number of selfing events */ unsigned int selfix = 0; /* Selfing index */ unsigned int recix1 = 0; /* Rec index chr 1 */ unsigned int recix2 = 0; /* Rec index chr 2 */ unsigned int nrec1 = 0; /* Number rec events chr 1 */ unsigned int nrec2 = 0; /* Number rec events chr 2 */ /* First deciding number of selfing events; creating vector of events + choosing */ nself = gsl_ran_binomial(r, self, N); unsigned int *selfev = calloc(nself,sizeof(unsigned int)); gsl_ran_choose(r, selfev, nself, nums, N, sizeof(unsigned int)); for(i = 0; i < N; i++){ /* Regenerating population */ /* Choosing first parent, and relevant chromosomes */ /* ADJUSTED SO PURELY NEUTRAL SELECTION ONLY */ choose1 = gsl_rng_uniform_int(r,N); wc1 = gsl_ran_bernoulli(r,0.5); wc2 = gsl_ran_bernoulli(r,0.5); index1 = 2*choose1 + wc1; /* Copying over selected sites, first checking if selfing occurs */ isself = 0; if(nself != 0){ if(*(selfev + selfix) == i){ isself = 1; selfix++; } } if(isself == 1){ index2 = 2*choose1 + wc2; }else if(isself == 0){ choose2 = gsl_rng_uniform_int(r,N); index2 = 2*choose2 + wc2; } /* Now copying over neutral fragment, accounting for recombination */ if(R != 0){ /* Choosing number of recombination events on arms 1, 2 */ recix1 = 0; recix2 = 0; nrec1 = gsl_ran_poisson(r,R); nrec2 = gsl_ran_poisson(r,R); double *recev1 = calloc(nrec1 + 1,sizeof(double)); double *recev2 = calloc(nrec2 + 1,sizeof(double)); for(k = 0; k < nrec1; k++){ *(recev1 + k) = gsl_ran_flat(r,0,1); } for(k = 0; k < nrec2; k++){ *(recev2 + k) = gsl_ran_flat(r,0,1); } *(recev1 + nrec1) = 1.01; *(recev2 + nrec2) = 1.01; rec_sort(recev1,nrec1 + 1); rec_sort(recev2,nrec2 + 1); for(j = 0; j < npoly; j++){ if( (*(polypos + j)) >= *(recev1 + recix1)){ wc1 = bitswitch(wc1); index1 = 2*choose1 + wc1; recix1++; } if( (*(polypos + j)) >= *(recev2 + recix2)){ wc2 = bitswitch(wc2); if(isself == 1){ index2 = 2*choose1 + wc2; }else if(isself == 0){ index2 = 2*choose2 + wc2; } recix2++; } *((*(neutout + 2*i)) + j) = *((*(neutin + index1)) + j); *((*(neutout + 2*i + 1)) + j) = *((*(neutin + index2)) + j); } free(recev1); free(recev2); }else if (R == 0){ for(j = 0; j < npoly; j++){ *((*(neutout + 2*i)) + j) = *((*(neutin + index1)) + j); *((*(neutout + 2*i + 1)) + j) = *((*(neutin + index2)) + j); } } } free(selfev); } /* End of reproduction routine */ /* Adding neutral polymorphism routine */ void addpoly(unsigned int N, unsigned int **neutin, double *polyloc, unsigned int *npoly, double theta, const gsl_rng *r){ unsigned int i, j; int k; unsigned int newpoly = 0; /* Number of new polymorphisms added */ unsigned int pchr = 0; /* Chromosome of appearance */ unsigned int pfound = 0; /* Flag to denote if right index found */ double ploc = 0; /* Location of polymorphism */ /* FILE *ofp_poly; Pointer for polymorphisms output */ newpoly = gsl_ran_poisson(r,(0.5*theta)); /* printf("Add %d new polymorphisms\n",newpoly);*/ for(j = 0; j < newpoly; j++){ ploc = gsl_ran_flat(r,0.0,1.0); /* printf("ploc is %lf\n",ploc); */ pchr = gsl_rng_uniform_int(r,2*N); /* printf("pchr is %d\n",pchr);*/ /* Inserting new polymorphism */ if(*(npoly) == 0){ /* printf("zero entry here\n"); */ *(polyloc + 0) = ploc; for(i = 0; i < 2*N; i++){ *((*(neutin + i)) + 0) = 0; } *((*(neutin + pchr)) + 0) = 1; }else if(*(npoly) > 0){ /* printf("non-zero entry here\n"); */ pfound = 0; for(k = (*(npoly) - 1); k >= 0; k--){ /* printf("k is %d\n",k);*/ if(*(polyloc + k) > ploc){ /* printf("is here 1\n");*/ *(polyloc + k + 1) = *(polyloc + k); for(i = 0; i < 2*N; i++){ *((*(neutin + i)) + k + 1) = *((*(neutin + i)) + k); } }else if(*(polyloc + k) <= ploc){ /* printf("is here 2\n"); */ pfound = 1; *(polyloc + k + 1) = ploc; for(i = 0; i < 2*N; i++){ *((*(neutin + i)) + k + 1) = 0; } *((*(neutin + pchr)) + k + 1) = 1; break; } } if(pfound == 0){ /* In this case polymorphism is inserted at the start */ *(polyloc + 0) = ploc; for(i = 0; i < 2*N; i++){ *((*(neutin + i)) + 0) = 0; } *((*(neutin + pchr)) + 0) = 1; } } *(npoly) += 1; /* printf("n poly is %d\n",*(npoly)); */ if(*(npoly) == INITTS){ fprintf(stderr,"Too many neutral polymorphisms.\n"); exit(1); } } } /* Reassigning new population routine (after trimming) */ void reassign2(unsigned int **neutin, unsigned int **neutout, double *posin, double *posout, unsigned int npoly, unsigned int N, unsigned int aft){ unsigned int i, j; /* pop counter, poly counter */ for(i = 0; i < 2*N; i++){ for(j = 0; j < npoly; j++){ *((*(neutout + i)) + j) = *((*(neutin + i)) + j); if(i == 0 && aft == 1){ *(posout + j) = *(posin + j); } } } } /* End of reassignment routine */ /* Printing population state to file */ void popprint(unsigned int **neutin, double *posin, unsigned int npoly, unsigned int N, unsigned int ei, unsigned int suffix){ unsigned int i, j; /* pop counter, poly counter */ char Pout[32]; /* String to hold filename in (Mutations) */ FILE *ofp_poly = NULL; /* Pointer for data output */ /* Printing out polymorphism table */ sprintf(Pout,"Pop_%d.dat",ei + suffix); ofp_poly = fopen(Pout,"w"); for(j = 0; j < npoly; j++){ fprintf(ofp_poly,"%lf ",*(posin + j)); for(i = 0; i < 2*N; i++){ fprintf(ofp_poly,"%d ",*((*(neutin + i)) + j)); } fprintf(ofp_poly,"\n"); } fclose(ofp_poly); } /* End of population printing routine */ /* Printing polymorphism routines */ void polyprint(unsigned int **neutin, double *posin, unsigned int npoly, unsigned int N){ unsigned int i, j; /* pop counter, poly counter */ for(j = 0; j < npoly; j++){ printf("%lf ",*(posin + j)); for(i = 0; i < 2*N; i++){ printf("%d ",*((*(neutin + i)) + j)); } printf("\n"); } Wait(); } /* End of reassignment routine */ /* Cutting out non-polymorphic sites */ void ptrim(unsigned int size, unsigned int **neutin, unsigned int **neutout, double *posin, double *posout, unsigned int npoly, unsigned int *npolyT, double *avpi){ unsigned int i, j; unsigned int newp = 0; /* New number of polymorphisms */ unsigned int count = 0; /* Polymorphism count */ double cumpi = 0; /* Cumulative pi (diversity) */ /* printf("Trimming routine activated\n"); */ for(j = 0; j < npoly; j++){ count = 0; *(posout + newp) = *(posin + j); for(i = 0; i < size; i++){ *((*(neutout + i)) + newp) = *((*(neutin + i)) + j); count += *((*(neutin + i)) + j); } /* printf("For poly %d, count is %d\n",j,count);*/ if((count > 0) && (count < size)){ /* printf("Keeping poly %d at location %lf\n",j,*(posin + j)); */ newp++; cumpi += ((count*(size-count))/(1.0*size*size)); /* printf("Count is %d, freq is %lf, cumulative value is %lf\n",count,count/(1.0*size),cumpi); */ } /* if(count==size){ printf("A fixed neutral mutation here\n"); } */ } *npolyT = newp; *avpi = (cumpi/(1.0*newp)); } /* Count number of unique haplotypes */ unsigned int uniqueH(unsigned int **neutin, unsigned int npoly, unsigned int N){ unsigned int i, j, k; unsigned int unH = 0; /* Count of unique haplotypes */ unsigned int nomatch = 0; /* Marker to show if sites do not match */ unsigned int **UH = calloc(2*N,sizeof(unsigned int *)); for(i = 0; i < 2*N; i++){ UH[i] = calloc(npoly,sizeof(unsigned int)); } /* Assigning first unique haplotype */ for(j = 0; j < npoly; j++){ *((*(UH + 0)) + j) = *((*(neutin + 0)) + j); } unH++; /* Now testing other haplotypes */ for(i = 0; i < 2*N; i++){ nomatch = 0; for(k = 0; k < unH; k++){ for(j = 0; j < npoly; j++){ if(*((*(UH + k)) + j) != *((*(neutin + i)) + j)){ nomatch++; break; } } } if(nomatch == unH){ /* If haplotype does not match ANY unique ones, then add as new */ for(j = 0; j < npoly; j++){ *((*(UH + unH)) + j) = *((*(neutin + i)) + j); } unH++; } } for(i = 0; i < 2*N; i++){ free(UH[i]); } free(UH); return unH; } /* Main program */ int main(int argc, char *argv[]){ /* Declare variables here */ unsigned int a, i; /* Counters */ unsigned int N = 0; /* Population Size */ unsigned int npoly = 0; /* Number of neutral alleles */ unsigned int npolyT = 0; /* Number of neutral alleles (after cutting out fixed sites) */ unsigned int suffix = 0; /* Number of times to subsample from population */ unsigned int base = 0; /* Number of baseline forward-in-time simulations */ /* unsigned int n = 0; sprintf counter */ unsigned int ttot = 0; /* Total time of simulation */ /* unsigned int unH = 0; Number of unique haplotypes */ unsigned int tbi = 0; /* Burn-in time */ /* double npr = 0; Number of times to print out number of stats */ double self = 0; /* Selfing rate */ double Rin = 0; /* Recombination rate (input) */ double R = 0; /* Recombination rate (at a time) */ double theta = 0; /* Rate of neutral mutation */ double avpi = 0; char Sout[32]; /* String to hold filename in (Seed) */ FILE *ofp_sd; /* Pointer for seed output */ /* GSL random number definitions */ const gsl_rng_type * T; gsl_rng * r; /* Reading in data from command line */ if(argc != 7){ fprintf(stderr,"Not enough inputs (need: N self R theta basereps suffix).\n"); exit(1); } N = atoi(argv[1]); if(N <= 0){ fprintf(stderr,"Total Population size N is zero or negative, not allowed.\n"); exit(1); } self = strtod(argv[2],NULL); if(self < 0 || self > 1){ fprintf(stderr,"Selfing rate must lie between 0 and 1 (inclusive).\n"); exit(1); } Rin = strtod(argv[3],NULL); if(Rin < 0){ fprintf(stderr,"Recombination rate must be positive or zero.\n"); exit(1); } Rin /= 2.0*N; theta = strtod(argv[4],NULL); if(theta <= 0){ fprintf(stderr,"Mutation rate must be a positive value.\n"); exit(1); } base = atoi(argv[5]); if(base <= 0){ fprintf(stderr,"Number of baseline simulations must be greater than zero.\n"); exit(1); } suffix = atoi(argv[6]); if(argv[6] < 0){ fprintf(stderr,"File index must be greater than or equal to zero.\n"); exit(1); } /* create a generator chosen by the environment variable GSL_RNG_TYPE */ mkdir("SeedsPop/", 0777); gsl_rng_env_setup(); if (!getenv("GSL_RNG_SEED")) gsl_rng_default_seed = time(0); T = gsl_rng_default; r = gsl_rng_alloc(T); sprintf(Sout,"SeedsPop/Seed_%d.dat",suffix); ofp_sd = fopen(Sout,"w"); fprintf(ofp_sd,"%lu\n",gsl_rng_default_seed); fclose(ofp_sd); /* Vector of 0 to (N-1) for sampling random numbers */ unsigned int *nums = calloc(N,sizeof(unsigned int)); unsigned int *nums2 = calloc(2*N,sizeof(unsigned int)); for(a = 0; a < 2*N; a++){ *(nums2 + a) = a; if(a < N){ *(nums + a) = a; } } /* Executing simulation */ for(i = 0; i < base; i++){ /* printf("Starting run %d\n",i);*/ /* Setting up selection, neutral tables per individual */ double *polypos = calloc(INITTS,sizeof(double)); /* Position of neutral mutations */ double *polyposF = calloc(INITTS,sizeof(double)); /* Position of neutral mutations (final for polymorphism sampling) */ unsigned int **neutindvP = calloc(2*N,sizeof(unsigned int *)); /* Table of neutral markers per individual (parents) */ unsigned int **neutindvO = calloc(2*N,sizeof(unsigned int *)); /* Table of neutral markers per individual (offspring) */ unsigned int **neutindvF = calloc(2*N,sizeof(unsigned int *)); /* Table of neutral markers per individual (final for sampling) */ for(a = 0; a < 2*N; a++){ neutindvP[a] = calloc(INITTS,sizeof(unsigned int)); neutindvO[a] = calloc(INITTS,sizeof(unsigned int)); neutindvF[a] = calloc(INITTS,sizeof(unsigned int)); } npoly = 0; ttot = 0; R = Rin; tbi = 20*N; /* npr = 20.0; */ while(ttot < tbi){ /* int tick = (tbi)/(npr); if(ttot%tick == 0){ unH = uniqueH(neutindvP, npoly, N); printf("Time is %d; npoly is %d; av pi is %lf, unique haps are %d\n",ttot,npoly,avpi,unH); } */ /* Generating new population */ generation_BI(N,self,R,nums,neutindvP,neutindvO,npoly,polypos,r); /* Neutral Mutation phase */ addpoly(N, neutindvO, polypos, &npoly, theta, r); /* Reassigning matrices */ reassign2(neutindvO, neutindvP, polyposF, polypos, npoly, N, 0); ttot++; ptrim(2*N, neutindvP, neutindvF, polypos, polyposF, npoly, &npolyT, &avpi); npoly = npolyT; reassign2(neutindvF, neutindvP, polyposF, polypos, npoly, N, 1); /* printf("Number of unique haplotypes are %d\n",uniqueH(neutindvP, npoly, N)); polyprint(neutindvP, polypos, npoly, N); */ } /* printf("End of burn-in\n");*/ /* After burn-in, print out neutral mutants */ popprint(neutindvP, polypos, npoly, N, i, suffix); /* reassign2(neutindvP, neutindvA, polypos, polyposA, npoly, N); npolyA = npoly; */ for(a = 0; a < 2*N; a++){ free(neutindvF[a]); free(neutindvO[a]); free(neutindvP[a]); } free(neutindvF); free(neutindvO); free(neutindvP); free(polyposF); free(polypos); } free(nums2); free(nums); gsl_rng_free(r); return 0; } /* End of main program */ /* End of File */
{ "alphanum_fraction": 0.602883432, "avg_line_length": 30.2, "ext": "c", "hexsha": "7b998274e6f688acf475106c5547b883f99f3f75", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "73cde4d7936bb6645397f9931dade99a818e4c49", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MattHartfield/DomSelfAdapt", "max_forks_repo_path": "DomSelfAdaptFWD_BIRec.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "73cde4d7936bb6645397f9931dade99a818e4c49", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MattHartfield/DomSelfAdapt", "max_issues_repo_path": "DomSelfAdaptFWD_BIRec.c", "max_line_length": 180, "max_stars_count": null, "max_stars_repo_head_hexsha": "73cde4d7936bb6645397f9931dade99a818e4c49", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MattHartfield/DomSelfAdapt", "max_stars_repo_path": "DomSelfAdaptFWD_BIRec.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5672, "size": 17063 }
/* vector/gsl_vector_short.h * * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, Brian Gough * * 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 2 of the License, 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 __GSL_VECTOR_SHORT_H__ #define __GSL_VECTOR_SHORT_H__ #include <stdlib.h> #include <gsl/gsl_types.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_check_range.h> #include <gsl/gsl_block_short.h> #undef __BEGIN_DECLS #undef __END_DECLS #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } #else # define __BEGIN_DECLS /* empty */ # define __END_DECLS /* empty */ #endif __BEGIN_DECLS typedef struct { size_t size; size_t stride; short *data; gsl_block_short *block; int owner; } gsl_vector_short; typedef struct { gsl_vector_short vector; } _gsl_vector_short_view; typedef _gsl_vector_short_view gsl_vector_short_view; typedef struct { gsl_vector_short vector; } _gsl_vector_short_const_view; typedef const _gsl_vector_short_const_view gsl_vector_short_const_view; /* Allocation */ gsl_vector_short *gsl_vector_short_alloc (const size_t n); gsl_vector_short *gsl_vector_short_calloc (const size_t n); gsl_vector_short *gsl_vector_short_alloc_from_block (gsl_block_short * b, const size_t offset, const size_t n, const size_t stride); gsl_vector_short *gsl_vector_short_alloc_from_vector (gsl_vector_short * v, const size_t offset, const size_t n, const size_t stride); void gsl_vector_short_free (gsl_vector_short * v); /* Views */ _gsl_vector_short_view gsl_vector_short_view_array (short *v, size_t n); _gsl_vector_short_view gsl_vector_short_view_array_with_stride (short *base, size_t stride, size_t n); _gsl_vector_short_const_view gsl_vector_short_const_view_array (const short *v, size_t n); _gsl_vector_short_const_view gsl_vector_short_const_view_array_with_stride (const short *base, size_t stride, size_t n); _gsl_vector_short_view gsl_vector_short_subvector (gsl_vector_short *v, size_t i, size_t n); _gsl_vector_short_view gsl_vector_short_subvector_with_stride (gsl_vector_short *v, size_t i, size_t stride, size_t n); _gsl_vector_short_const_view gsl_vector_short_const_subvector (const gsl_vector_short *v, size_t i, size_t n); _gsl_vector_short_const_view gsl_vector_short_const_subvector_with_stride (const gsl_vector_short *v, size_t i, size_t stride, size_t n); /* Operations */ short gsl_vector_short_get (const gsl_vector_short * v, const size_t i); void gsl_vector_short_set (gsl_vector_short * v, const size_t i, short x); short *gsl_vector_short_ptr (gsl_vector_short * v, const size_t i); const short *gsl_vector_short_const_ptr (const gsl_vector_short * v, const size_t i); void gsl_vector_short_set_zero (gsl_vector_short * v); void gsl_vector_short_set_all (gsl_vector_short * v, short x); int gsl_vector_short_set_basis (gsl_vector_short * v, size_t i); int gsl_vector_short_fread (FILE * stream, gsl_vector_short * v); int gsl_vector_short_fwrite (FILE * stream, const gsl_vector_short * v); int gsl_vector_short_fscanf (FILE * stream, gsl_vector_short * v); int gsl_vector_short_fprintf (FILE * stream, const gsl_vector_short * v, const char *format); int gsl_vector_short_memcpy (gsl_vector_short * dest, const gsl_vector_short * src); int gsl_vector_short_reverse (gsl_vector_short * v); int gsl_vector_short_swap (gsl_vector_short * v, gsl_vector_short * w); int gsl_vector_short_swap_elements (gsl_vector_short * v, const size_t i, const size_t j); short gsl_vector_short_max (const gsl_vector_short * v); short gsl_vector_short_min (const gsl_vector_short * v); void gsl_vector_short_minmax (const gsl_vector_short * v, short * min_out, short * max_out); size_t gsl_vector_short_max_index (const gsl_vector_short * v); size_t gsl_vector_short_min_index (const gsl_vector_short * v); void gsl_vector_short_minmax_index (const gsl_vector_short * v, size_t * imin, size_t * imax); int gsl_vector_short_add (gsl_vector_short * a, const gsl_vector_short * b); int gsl_vector_short_sub (gsl_vector_short * a, const gsl_vector_short * b); int gsl_vector_short_mul (gsl_vector_short * a, const gsl_vector_short * b); int gsl_vector_short_div (gsl_vector_short * a, const gsl_vector_short * b); int gsl_vector_short_scale (gsl_vector_short * a, const double x); int gsl_vector_short_add_constant (gsl_vector_short * a, const double x); int gsl_vector_short_isnull (const gsl_vector_short * v); #ifdef HAVE_INLINE extern inline short gsl_vector_short_get (const gsl_vector_short * v, const size_t i) { #if GSL_RANGE_CHECK if (i >= v->size) { GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0); } #endif return v->data[i * v->stride]; } extern inline void gsl_vector_short_set (gsl_vector_short * v, const size_t i, short x) { #if GSL_RANGE_CHECK if (i >= v->size) { GSL_ERROR_VOID ("index out of range", GSL_EINVAL); } #endif v->data[i * v->stride] = x; } extern inline short * gsl_vector_short_ptr (gsl_vector_short * v, const size_t i) { #if GSL_RANGE_CHECK if (i >= v->size) { GSL_ERROR_NULL ("index out of range", GSL_EINVAL); } #endif return (short *) (v->data + i * v->stride); } extern inline const short * gsl_vector_short_const_ptr (const gsl_vector_short * v, const size_t i) { #if GSL_RANGE_CHECK if (i >= v->size) { GSL_ERROR_NULL ("index out of range", GSL_EINVAL); } #endif return (const short *) (v->data + i * v->stride); } #endif /* HAVE_INLINE */ __END_DECLS #endif /* __GSL_VECTOR_SHORT_H__ */
{ "alphanum_fraction": 0.6719943423, "avg_line_length": 31.1453744493, "ext": "h", "hexsha": "e73de3a78e7906a263672561468cc28a78ad68c3", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ad97da6f6bc94f91e72d75f37fa33ca949d9bb60", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrewkern/segSiteHMM", "max_forks_repo_path": "extern/include/gsl/gsl_vector_short.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "ad97da6f6bc94f91e72d75f37fa33ca949d9bb60", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrewkern/segSiteHMM", "max_issues_repo_path": "extern/include/gsl/gsl_vector_short.h", "max_line_length": 94, "max_stars_count": null, "max_stars_repo_head_hexsha": "ad97da6f6bc94f91e72d75f37fa33ca949d9bb60", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrewkern/segSiteHMM", "max_stars_repo_path": "extern/include/gsl/gsl_vector_short.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1651, "size": 7070 }
/* This file is part of the Astrometry.net suite. Copyright 2006-2008 Dustin Lang, Keir Mierle and Sam Roweis. The Astrometry.net suite 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, version 2. The Astrometry.net suite 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 the Astrometry.net suite ; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AN_GSL_UTILS_H #define AN_GSL_UTILS_H #include <gsl/gsl_matrix_double.h> #include <gsl/gsl_vector_double.h> void gslutils_use_error_system(); /** Solves a least-squares matrix equation A X_i = B_i For NB pairs of X_i, B_i. NOTE: THIS DESTROYS A! A: MxN matrix B: array of NB x length-M vectors X: must be an array big enough to hold NB vectors. (they will be length-N). resids: if non-NULL, must be an array big enough to hold NB vectors (they will be length-M). The result vectors are freshly allocated and should be freed with gsl_vector_free(). */ int gslutils_solve_leastsquares(gsl_matrix* A, gsl_vector** B, gsl_vector** X, gsl_vector** resids, int NB); /** Same as above, but using varargs. There must be exactly 3 * NB additional arguments, in the order: B0, &X0, &resid0, B1, &X1, &resid1, ... ie, the types must be repeating triples of: gsl_vector* b, gsl_vector** x, gsl_vector** resid */ int gslutils_solve_leastsquares_v(gsl_matrix* A, int NB, ...); // C = A B void gslutils_matrix_multiply(gsl_matrix* C, const gsl_matrix* A, const gsl_matrix* B); int gslutils_invert_3x3(const double* A, double* B); #endif
{ "alphanum_fraction": 0.7190123457, "avg_line_length": 30.223880597, "ext": "h", "hexsha": "11d60a031e3e828f3134f56ae11d0ac9c8b1bfe7", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "eafd0aea314c427da616e1707a49aaeaf5ea6991", "max_forks_repo_licenses": [ "OML" ], "max_forks_repo_name": "simonct/CoreAstro", "max_forks_repo_path": "External/astrometry.net/astrometry/include/gslutils.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "eafd0aea314c427da616e1707a49aaeaf5ea6991", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "OML" ], "max_issues_repo_name": "simonct/CoreAstro", "max_issues_repo_path": "External/astrometry.net/astrometry/include/gslutils.h", "max_line_length": 87, "max_stars_count": 3, "max_stars_repo_head_hexsha": "eafd0aea314c427da616e1707a49aaeaf5ea6991", "max_stars_repo_licenses": [ "OML" ], "max_stars_repo_name": "simonct/CoreAstro", "max_stars_repo_path": "External/astrometry.net/astrometry/include/gslutils.h", "max_stars_repo_stars_event_max_datetime": "2016-11-15T10:35:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-29T06:56:58.000Z", "num_tokens": 530, "size": 2025 }
#pragma once #define GLM_ENABLE_EXPERIMENTAL #include <glm/glm.hpp> #include <gsl/gsl> namespace Library { class Mesh; template <typename T> struct VertexDeclaration { static constexpr uint32_t VertexSize() { return gsl::narrow_cast<uint32_t>(sizeof(T)); } static constexpr uint32_t VertexBufferByteWidth(size_t vertexCount) { return gsl::narrow_cast<uint32_t>(sizeof(T) * vertexCount); } static void CreateVertexBuffer(const gsl::span<const T>& vertices, GLuint& vertexBuffer); }; struct VertexPosition final : public VertexDeclaration<VertexPosition> { glm::vec4 Position{ 0 }; VertexPosition() = default; VertexPosition(const glm::vec4& position) : Position(position) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPosition>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionColor final :public VertexDeclaration<VertexPositionColor> { glm::vec4 Position{ 0 }; glm::vec4 Color{ 0 }; VertexPositionColor() = default; VertexPositionColor(const glm::vec4& position, const glm::vec4& color) : Position(position), Color(color) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer, bool randomColor = false); static void CreateVertexBuffer(const gsl::span<const VertexPositionColor>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionTexture final : public VertexDeclaration<VertexPositionTexture> { glm::vec4 Position{ 0 }; glm::vec2 TextureCoordinates{ 0 }; VertexPositionTexture() = default; VertexPositionTexture(const glm::vec4& position, const glm::vec2& textureCoordinates) : Position(position), TextureCoordinates(textureCoordinates) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPositionTexture>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionNormal final : public VertexDeclaration<VertexPositionNormal> { glm::vec4 Position{ 0 }; glm::vec3 Normal{ 0 }; VertexPositionNormal() = default; VertexPositionNormal(const glm::vec4& position, const glm::vec3& normal) : Position(position), Normal(normal) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPositionNormal>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionTextureNormal final : public VertexDeclaration<VertexPositionTextureNormal> { glm::vec4 Position{ 0 }; glm::vec2 TextureCoordinates{ 0 }; glm::vec3 Normal{ 0 }; VertexPositionTextureNormal() = default; VertexPositionTextureNormal(const glm::vec4& position, const glm::vec2& textureCoordinates, const glm::vec3& normal) : Position(position), TextureCoordinates(textureCoordinates), Normal(normal) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPositionTextureNormal>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; struct VertexPositionTextureNormalTangentBinormal final : public VertexDeclaration<VertexPositionTextureNormalTangentBinormal> { glm::vec4 Position{ 0 }; glm::vec2 TextureCoordinates{ 0 }; glm::vec3 Normal{ 0 }; glm::vec3 Tangent{ 0 }; glm::vec3 Binormal{ 0 }; VertexPositionTextureNormalTangentBinormal() = default; VertexPositionTextureNormalTangentBinormal(const glm::vec4& position, const glm::vec2& textureCoordinates, const glm::vec3& normal, const glm::vec3& tangent, const glm::vec3& binormal) : Position(position), TextureCoordinates(textureCoordinates), Normal(normal), Tangent(tangent), Binormal(binormal) { } static void CreateVertexBuffer(const Library::Mesh& mesh, GLuint& vertexBuffer); static void CreateVertexBuffer(const gsl::span<const VertexPositionTextureNormalTangentBinormal>& vertices, GLuint& vertexBuffer) { VertexDeclaration::CreateVertexBuffer(vertices, vertexBuffer); } }; }
{ "alphanum_fraction": 0.7641594925, "avg_line_length": 35.5967741935, "ext": "h", "hexsha": "35c32a4f66e8d61c6a4e4c575d9a22aaca97b3f7", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "628e9aed116022175cc0c59c88ace7688309628c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DakkyDaWolf/OpenGL", "max_forks_repo_path": "source/Library.Shared/VertexDeclarations.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "628e9aed116022175cc0c59c88ace7688309628c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DakkyDaWolf/OpenGL", "max_issues_repo_path": "source/Library.Shared/VertexDeclarations.h", "max_line_length": 188, "max_stars_count": null, "max_stars_repo_head_hexsha": "628e9aed116022175cc0c59c88ace7688309628c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DakkyDaWolf/OpenGL", "max_stars_repo_path": "source/Library.Shared/VertexDeclarations.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1041, "size": 4414 }
#ifndef ConditionalTest_SERIAL_H #define ConditionalTest_SERIAL_H #include <ace/core/core.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_statistics_double.h> #include <gsl/gsl_randist.h> #include "conditionaltest.h" class ConditionalTest::Serial : public EAbstractAnalyticSerial { Q_OBJECT public: explicit Serial(ConditionalTest* parent); virtual std::unique_ptr<EAbstractAnalyticBlock> execute(const EAbstractAnalyticBlock* block) override final; // helper functions int test(CCMatrix::Pair& ccmPair, qint32 clusterIndex, qint32& testIndex, qint32 featureIndex, qint32 labelIndex, QVector<QVector<double>>& pValues, QVector<QVector<double>>& r2); int prepAnxData(QString testLabel, int dataIndex, TESTTYPE testType); bool isEmpty(QVector<QVector<double>>& matrix); int clusterInfo(CCMatrix::Pair& ccmPair, int clusterIndex, QString label, TESTTYPE testType); // Binomial Tests double binomial(); double testOne(); double testTwo(); // Hypergeometrix Test. double hypergeom(CCMatrix::Pair& ccmPair, int clusterIndex, QString test_label); // Regression Test void regression(QVector<QString> &amxInfo, CCMatrix::Pair& ccmPair, int clusterIndex, TESTTYPE testType, QVector<double>& results); double fTest(double chisq, gsl_matrix* X, gsl_vector* Y, gsl_matrix* cov, gsl_vector* C); private: /*! * Pointer to the serials objects parent KNNAnalytic. */ ConditionalTest* _base; /*! * Annotation matrix data for testing. */ QVector<QString> _amxData; /*! * Category count. */ qint32 _catCount {0}; /*! * Category count in cluster. */ qint32 _catInCluster {0}; /*! * Size of the cluster. */ qint32 _clusterSize {0}; }; #endif
{ "alphanum_fraction": 0.7041322314, "avg_line_length": 28.8095238095, "ext": "h", "hexsha": "013331bf9bbf32350255cda2b591060130c7c66a", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0f6565ce8e1102392382e4c716c128115b611f0c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mfayk/KINC", "max_forks_repo_path": "src/core/conditionaltest_serial.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "0f6565ce8e1102392382e4c716c128115b611f0c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mfayk/KINC", "max_issues_repo_path": "src/core/conditionaltest_serial.h", "max_line_length": 183, "max_stars_count": null, "max_stars_repo_head_hexsha": "0f6565ce8e1102392382e4c716c128115b611f0c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mfayk/KINC", "max_stars_repo_path": "src/core/conditionaltest_serial.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 454, "size": 1815 }
#pragma once #include <gsl/gsl> namespace aas { struct SkelBone; /** * Represents a sphere for cloth collision purposes. */ struct CollisionSphere { int boneId; float radius; Matrix3x4 worldMatrix; Matrix3x4 worldMatrixInverse; std::unique_ptr<CollisionSphere> next; }; /** * Represents a cylinder for cloth collision purposes. */ struct CollisionCylinder { int boneId; float radius; float height; Matrix3x4 worldMatrix; Matrix3x4 worldMatrixInverse; std::unique_ptr<CollisionCylinder> next; }; struct CollisionGeometry { std::unique_ptr<CollisionSphere> firstSphere; std::unique_ptr<CollisionCylinder> firstCylinder; }; /** * Extract the cloth collision information from a list of bones. * The information is parsed from the bone names. */ CollisionGeometry FindCollisionGeometry(gsl::span<SkelBone> bones); }
{ "alphanum_fraction": 0.7404844291, "avg_line_length": 19.2666666667, "ext": "h", "hexsha": "19977e88318555ffefcc94c0f24514ddec6d7447", "lang": "C", "max_forks_count": 25, "max_forks_repo_forks_event_max_datetime": "2021-11-15T23:14:51.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-04T21:19:53.000Z", "max_forks_repo_head_hexsha": "f0e552289822fea908f16daa379fa568b1bd286d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "edoipi/TemplePlus", "max_forks_repo_path": "Infrastructure/src/aas/aas_cloth_collision.h", "max_issues_count": 457, "max_issues_repo_head_hexsha": "f0e552289822fea908f16daa379fa568b1bd286d", "max_issues_repo_issues_event_max_datetime": "2022-03-31T02:19:10.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-01T22:07:45.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "edoipi/TemplePlus", "max_issues_repo_path": "Infrastructure/src/aas/aas_cloth_collision.h", "max_line_length": 68, "max_stars_count": 69, "max_stars_repo_head_hexsha": "f0e552289822fea908f16daa379fa568b1bd286d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "edoipi/TemplePlus", "max_stars_repo_path": "Infrastructure/src/aas/aas_cloth_collision.h", "max_stars_repo_stars_event_max_datetime": "2022-02-15T06:13:04.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-05T14:09:25.000Z", "num_tokens": 217, "size": 867 }
/* rng/ranf.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 James Theiler, Brian Gough * * 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 3 of the License, 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. */ #include <config.h> #include <math.h> #include <stdlib.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_sys.h> /* This is the CRAY RANF generator. The generator returns the upper 32 bits from each term of the sequence, x_{n+1} = (a x_n) mod m using 48-bit unsigned arithmetic, with a = 0x2875A2E7B175 and m = 2^48. The seed specifies the lower 32 bits of the initial value, x_1, with the lowest bit set (to prevent the seed taking an even value), and the upper 16 bits set to 0. There is a subtlety in the implementation of the seed. The initial state is put one step back by multiplying by the modular inverse of a mod m. This is done for compatibility with the original CRAY implementation. Note, you can only seed the generator with integers up to 2^32, while the CRAY uses wide integers which can cover all 2^48 states of the generator. The theoretical value of x_{10001} is 141091827447341. The period of this generator is 2^{46}. */ static inline void ranf_advance (void *vstate); static unsigned long int ranf_get (void *vstate); static double ranf_get_double (void *vstate); static void ranf_set (void *state, unsigned long int s); static const unsigned short int a0 = 0xB175 ; static const unsigned short int a1 = 0xA2E7 ; static const unsigned short int a2 = 0x2875 ; typedef struct { unsigned short int x0, x1, x2; } ranf_state_t; static inline void ranf_advance (void *vstate) { ranf_state_t *state = (ranf_state_t *) vstate; const unsigned long int x0 = (unsigned long int) state->x0 ; const unsigned long int x1 = (unsigned long int) state->x1 ; const unsigned long int x2 = (unsigned long int) state->x2 ; unsigned long int r ; r = a0 * x0 ; state->x0 = (r & 0xFFFF) ; r >>= 16 ; r += a0 * x1 + a1 * x0 ; state->x1 = (r & 0xFFFF) ; r >>= 16 ; r += a0 * x2 + a1 * x1 + a2 * x0 ; state->x2 = (r & 0xFFFF) ; } static unsigned long int ranf_get (void *vstate) { unsigned long int x1, x2; ranf_state_t *state = (ranf_state_t *) vstate; ranf_advance (state) ; x1 = (unsigned long int) state->x1; x2 = (unsigned long int) state->x2; return (x2 << 16) + x1; } static double ranf_get_double (void * vstate) { ranf_state_t *state = (ranf_state_t *) vstate; ranf_advance (state) ; return (ldexp((double) state->x2, -16) + ldexp((double) state->x1, -32) + ldexp((double) state->x0, -48)) ; } static void ranf_set (void *vstate, unsigned long int s) { ranf_state_t *state = (ranf_state_t *) vstate; unsigned short int x0, x1, x2 ; unsigned long int r ; unsigned long int b0 = 0xD6DD ; unsigned long int b1 = 0xB894 ; unsigned long int b2 = 0x5CEE ; if (s == 0) /* default seed */ { x0 = 0x9CD1 ; x1 = 0x53FC ; x2 = 0x9482 ; } else { x0 = (s | 1) & 0xFFFF ; x1 = s >> 16 & 0xFFFF ; x2 = 0 ; } r = b0 * x0 ; state->x0 = (r & 0xFFFF) ; r >>= 16 ; r += b0 * x1 + b1 * x0 ; state->x1 = (r & 0xFFFF) ; r >>= 16 ; r += b0 * x2 + b1 * x1 + b2 * x0 ; state->x2 = (r & 0xFFFF) ; return; } static const gsl_rng_type ranf_type = {"ranf", /* name */ 0xffffffffUL, /* RAND_MAX */ 0, /* RAND_MIN */ sizeof (ranf_state_t), &ranf_set, &ranf_get, &ranf_get_double }; const gsl_rng_type *gsl_rng_ranf = &ranf_type;
{ "alphanum_fraction": 0.6450929631, "avg_line_length": 26.0674846626, "ext": "c", "hexsha": "a35fdcac0870f6e350a1a32f874664575a2e7e90", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-14T12:31:02.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-20T16:22:57.000Z", "max_forks_repo_head_hexsha": "1b4ee4c146f526ea6e2f4f8607df7e9687204a9e", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "Brian-ning/HMNE", "max_forks_repo_path": "Source/BaselineMethods/MNE/C++/gsl-2.4/rng/ranf.c", "max_issues_count": 6, "max_issues_repo_head_hexsha": "1b4ee4c146f526ea6e2f4f8607df7e9687204a9e", "max_issues_repo_issues_event_max_datetime": "2019-12-22T00:00:16.000Z", "max_issues_repo_issues_event_min_datetime": "2019-12-16T17:41:24.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "Brian-ning/HMNE", "max_issues_repo_path": "Source/BaselineMethods/MNE/C++/gsl-2.4/rng/ranf.c", "max_line_length": 81, "max_stars_count": 14, "max_stars_repo_head_hexsha": "2c2e7c85f8414cb0e654cb82e9686cce5e75c63a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ielomariala/Hex-Game", "max_stars_repo_path": "gsl-2.6/rng/ranf.c", "max_stars_repo_stars_event_max_datetime": "2021-06-10T11:31:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-12-18T18:09:25.000Z", "num_tokens": 1348, "size": 4249 }
/** * \author Sylvain Marsat, University of Maryland - NASA GSFC * * \brief C header for the instrumental noise for LISA-type detectors. * * Formulas taken from Królak&al gr-qc/0401108 (c.f. section III). * */ #ifndef _LISANOISE_H #define _LISANOISE_H #define _XOPEN_SOURCE 500 #ifdef __GNUC__ #define UNUSED __attribute__ ((unused)) #else #define UNUSED #endif #include <stdio.h> #include <stdlib.h> #include <math.h> #include <complex.h> #include <time.h> #include <unistd.h> #include <getopt.h> #include <stdbool.h> #include <string.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_bspline.h> #include <gsl/gsl_blas.h> #include <gsl/gsl_min.h> #include <gsl/gsl_spline.h> #include <gsl/gsl_complex.h> #include "constants.h" #include "LISAgeometry.h" #if defined(__cplusplus) extern "C" { #elif 0 } /* so that editors will match preceding brace */ #endif /************************************************************************/ /****** Global variables storing min and max f for the noise PSD *******/ /* Defines bounds in frequency beyond which we don't trust the instrument model anymore - all waveforms will be cut to this range */ /* Here extended range - allows for instance to taper the FD signal for f>1Hz */ #define __LISASimFD_Noise_fLow 1.e-6 #define __LISASimFD_Noise_fHigh 5. /* Original, more conservative bounds */ //#define __LISASimFD_Noise_fLow 1.e-5 //#define __LISASimFD_Noise_fHigh 1. /**************************************************************/ /****** Prototypes: functions evaluating the noise PSD *******/ /* Function returning the relevant noise function, given a set of TDI observables and a channel */ ObjectFunction NoiseFunction(const LISAconstellation *variant, const TDItag tditag, const int nchan); /* Noise Sn for TDI observables - factors have been scaled out both in the response and the noise */ double SnXYZ(const LISAconstellation *variant, double f); double Snalphabetagamma(const LISAconstellation *variant, double f); double SnAXYZ(const LISAconstellation *variant, double f); double SnEXYZ(const LISAconstellation *variant, double f); double SnTXYZ(const LISAconstellation *variant, double f); double SnAalphabetagamma(const LISAconstellation *variant, double f); double SnEalphabetagamma(const LISAconstellation *variant, double f); double SnTalphabetagamma(const LISAconstellation *variant, double f); /* Noise functions for AET(XYZ) without rescaling */ double SnAXYZNoRescaling(const LISAconstellation *variant, double f); double SnEXYZNoRescaling(const LISAconstellation *variant, double f); double SnTXYZNoRescaling(const LISAconstellation *variant, double f); /* Function returning the relevant noise function, given a set of TDI observables and a channel */ /* double (*NoiseFunction(const TDItag tditag, const int chan))(double); */ /* The noise functions themselves */ /* double NoiseSnA(const double f); */ /* double NoiseSnE(const double f); */ /* double NoiseSnT(const double f); */ #if 0 { /* so that editors will match succeeding brace */ #elif defined(__cplusplus) } #endif #endif /* _LISANOISE_H */
{ "alphanum_fraction": 0.7208926261, "avg_line_length": 32.5473684211, "ext": "h", "hexsha": "45656cc55bf8e018f9de98acfd036bb305ece997", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2020-07-20T02:56:30.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-20T14:19:13.000Z", "max_forks_repo_head_hexsha": "4ffb02977d19786ab8c1a767cc495a799d9575ae", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "titodalcanton/flare", "max_forks_repo_path": "LISAsim/LISAnoise.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "4ffb02977d19786ab8c1a767cc495a799d9575ae", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "titodalcanton/flare", "max_issues_repo_path": "LISAsim/LISAnoise.h", "max_line_length": 132, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4ffb02977d19786ab8c1a767cc495a799d9575ae", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "titodalcanton/flare", "max_stars_repo_path": "LISAsim/LISAnoise.h", "max_stars_repo_stars_event_max_datetime": "2020-07-20T02:56:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-26T15:21:13.000Z", "num_tokens": 760, "size": 3092 }
#ifndef CONTROLLERS_IMAGEOPERATIONACTIONCONTROLLER_H #define CONTROLLERS_IMAGEOPERATIONACTIONCONTROLLER_H #include <QObject> #include "s3d/cv/image_operation/image_operation.h" #include <QAction> #include <gsl/gsl> class ImageOperationActionController : public QObject { Q_OBJECT public: ImageOperationActionController(gsl::not_null<QAction*> action, gsl::not_null<s3d::image_operation::ImageOperation*> imageOperation); virtual void onActionTriggered() = 0; signals: void imageOperationTriggered(); protected: QAction* m_action; s3d::image_operation::ImageOperation* m_imageOperation; }; #endif //CONTROLLERS_IMAGEOPERATIONACTIONCONTROLLER_H
{ "alphanum_fraction": 0.7750716332, "avg_line_length": 23.2666666667, "ext": "h", "hexsha": "4e067ba15197c51f9b43a224cda047756bc8bf5e", "lang": "C", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-18T16:22:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-13T21:51:09.000Z", "max_forks_repo_head_hexsha": "4ffad16f9b0973404b59eb1424cc45f68754fe12", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hugbed/OpenS3D", "max_forks_repo_path": "src/apps/S3DAnalyzer/controllers/imageoperationactioncontroller.h", "max_issues_count": 40, "max_issues_repo_head_hexsha": "4ffad16f9b0973404b59eb1424cc45f68754fe12", "max_issues_repo_issues_event_max_datetime": "2017-12-21T18:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-12T17:24:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hugbed/OpenS3D", "max_issues_repo_path": "src/apps/S3DAnalyzer/controllers/imageoperationactioncontroller.h", "max_line_length": 102, "max_stars_count": 8, "max_stars_repo_head_hexsha": "4ffad16f9b0973404b59eb1424cc45f68754fe12", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hugbed/OpenS3D", "max_stars_repo_path": "src/apps/S3DAnalyzer/controllers/imageoperationactioncontroller.h", "max_stars_repo_stars_event_max_datetime": "2020-04-20T03:23:15.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-16T16:38:15.000Z", "num_tokens": 159, "size": 698 }
/* movstat/gsl_movstat.h * * Copyright (C) 2018 Patrick Alken * * 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 3 of the License, 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 __GSL_MOVSTAT_H__ #define __GSL_MOVSTAT_H__ #if !defined( GSL_FUN ) # if !defined( GSL_DLL ) # define GSL_FUN extern # elif defined( BUILD_GSL_DLL ) # define GSL_FUN extern __declspec(dllexport) # else # define GSL_FUN extern __declspec(dllimport) # endif #endif #include <gsl/gsl_math.h> #include <gsl/gsl_vector.h> #undef __BEGIN_DECLS #undef __END_DECLS #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } #else # define __BEGIN_DECLS /* empty */ # define __END_DECLS /* empty */ #endif __BEGIN_DECLS typedef enum { GSL_MOVSTAT_END_PADZERO, GSL_MOVSTAT_END_PADVALUE, GSL_MOVSTAT_END_TRUNCATE } gsl_movstat_end_t; /* accumulator struct * size - return number of bytes needed for accumulator with maximum of n elements * init - initialize accumulator state * insert - insert a single sample into accumulator; if there are already n * samples in accumulator, oldest sample is overwritten * delete_oldest - delete oldest sample from accumulator * get - return accumulated value */ typedef struct { size_t (*size) (const size_t n); int (*init) (const size_t n, void * vstate); int (*insert) (const double x, void * vstate); int (*delete_oldest) (void * vstate); int (*get) (void * params, double * result, const void * vstate); } gsl_movstat_accum; typedef struct { double (* function) (const size_t n, double x[], void * params); void * params; } gsl_movstat_function; #define GSL_MOVSTAT_FN_EVAL(F,n,x) (*((F)->function))((n),(x),(F)->params) /* workspace for moving window statistics */ typedef struct { size_t H; /* number of previous samples in window */ size_t J; /* number of after samples in window */ size_t K; /* window size K = H + J + 1 */ double *work; /* workspace, size K */ void *state; /* state workspace for various accumulators */ size_t state_size; /* bytes allocated for 'state' */ } gsl_movstat_workspace; /* alloc.c */ GSL_FUN gsl_movstat_workspace *gsl_movstat_alloc(const size_t K); GSL_FUN gsl_movstat_workspace *gsl_movstat_alloc2(const size_t H, const size_t J); GSL_FUN gsl_movstat_workspace *gsl_movstat_alloc_with_size(const size_t accum_state_size, const size_t H, const size_t J); GSL_FUN void gsl_movstat_free(gsl_movstat_workspace * w); /* apply.c */ GSL_FUN int gsl_movstat_apply_accum(const gsl_movstat_end_t endtype, const gsl_vector * x, const gsl_movstat_accum * accum, void * accum_params, gsl_vector * y, gsl_vector * z, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_apply(const gsl_movstat_end_t endtype, const gsl_movstat_function * F, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w); /* fill.c */ GSL_FUN size_t gsl_movstat_fill(const gsl_movstat_end_t endtype, const gsl_vector * x, const size_t idx, const size_t H, const size_t J, double * window); GSL_FUN int gsl_movstat_mean(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_variance(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_sd(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_median(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_min(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_max(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_minmax(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y_min, gsl_vector * y_max, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_mad0(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * xmedian, gsl_vector * xmad, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_mad(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * xmedian, gsl_vector * xmad, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_qqr(const gsl_movstat_end_t endtype, const gsl_vector * x, const double q, gsl_vector * xqqr, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_Sn(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * xscale, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_Qn(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * xscale, gsl_movstat_workspace * w); GSL_FUN int gsl_movstat_sum(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w); /* accumulator variables */ GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_mad; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_max; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_mean; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_median; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_min; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_minmax; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_sd; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_Sn; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_sum; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_Qn; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_qqr; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_userfunc; GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_variance; __END_DECLS #endif /* __GSL_MOVSTAT_H__ */
{ "alphanum_fraction": 0.7247115241, "avg_line_length": 44.7852348993, "ext": "h", "hexsha": "d21ba936858917d7451fedd17b40dc879af819ec", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-14T12:31:02.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-20T16:22:57.000Z", "max_forks_repo_head_hexsha": "3baed1b5313e6c198d54a33c2c84357035d5146a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zzpwahaha/VimbaCamJILA", "max_forks_repo_path": "VimbaCam/ExternLib/GSL_MSVC/gsl/gsl_movstat.h", "max_issues_count": 1, "max_issues_repo_head_hexsha": "3baed1b5313e6c198d54a33c2c84357035d5146a", "max_issues_repo_issues_event_max_datetime": "2021-01-13T16:28:48.000Z", "max_issues_repo_issues_event_min_datetime": "2021-01-11T01:08:01.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "zzpwahaha/VimbaCamJILA", "max_issues_repo_path": "VimbaCam/ExternLib/GSL_MSVC/gsl/gsl_movstat.h", "max_line_length": 154, "max_stars_count": 2, "max_stars_repo_head_hexsha": "ef4d4539a537ab49329b77648aac893d2b4ad318", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "mgreter/astrometrylib", "max_stars_repo_path": "vendor/gsl/gsl/gsl_movstat.h", "max_stars_repo_stars_event_max_datetime": "2021-01-09T16:18:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-01-09T05:48:44.000Z", "num_tokens": 1666, "size": 6673 }
#include <pygsl/utils.h> #include <pygsl/error_helpers.h> #include <pygsl/block_helpers.h> #include <gsl/gsl_sf.h> #include <gsl/gsl_nan.h> #ifndef IMPORTALL static PyObject *module=NULL; #endif typedef int (array_p_evaluator_iid_ad)(int nmin, int nmax, double x, double * result_array); static PyObject* PyGSL_sf_array_evaluator_legendre_iid_ad(PyObject *self, PyObject *args, array_p_evaluator_iid_ad * eval) { PyArrayObject *result = NULL; int lmax=0, m=0, dimension = 0, ret; double x=0, *data=NULL; FUNC_MESS_BEGIN(); if (!PyArg_ParseTuple(args, "iid", &lmax, &m, &x)){ return NULL; } if(m < 0){ PyErr_SetString(PyExc_ValueError, "Nmin must be bigger than 0!"); return NULL; } if(lmax < m){ PyErr_SetString(PyExc_ValueError, "Nmax must be bigger or equal to nmin!"); } dimension = gsl_sf_legendre_array_size(lmax, m); result = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result == NULL) return NULL; data = (double *) result->data; ret = eval(lmax, m, x, data); if(PyGSL_ERROR_FLAG(ret) != GSL_SUCCESS) goto fail; FUNC_MESS_END(); return (PyObject *) result; fail: Py_XDECREF(result); return NULL; } static PyObject* PyGSL_sf_array_evaluator_iid_ad(PyObject *self, PyObject *args, array_p_evaluator_iid_ad * eval) { PyArrayObject *result = NULL; int nmin=0, nmax=0, dimension = 0, ret; double x=0, *data=NULL; FUNC_MESS_BEGIN(); if (!PyArg_ParseTuple(args, "iid", &nmin, &nmax, &x)){ return NULL; } if(nmin < 0){ PyErr_SetString(PyExc_ImportError, "Nmin must be bigger than 0!"); return NULL; } if(nmax < nmin){ PyErr_SetString(PyExc_ImportError, "Nmax must be bigger or equal to nmin!"); } dimension = nmax - nmin + 1; /* Goes form nmin to nmax, both included */ result = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result == NULL) return NULL; data = (double *) result->data; ret = eval(nmin, nmax, x, data); if(PyGSL_ERROR_FLAG(ret) != GSL_SUCCESS) goto fail; FUNC_MESS_END(); return (PyObject *) result; fail: Py_XDECREF(result); return NULL; } typedef int (array_p_evaluator_id_ad)(int nmax, double x, double * result_array); static PyObject* PyGSL_sf_array_evaluator_id_ad(PyObject *self, PyObject *args, array_p_evaluator_id_ad * eval) { PyArrayObject *result = NULL; int nmin=0, nmax=0, dimension = 0, ret; double x=0, *data=NULL; FUNC_MESS_BEGIN(); if (!PyArg_ParseTuple(args, "id", &nmax, &x)){ return NULL; } if(nmin < 0){ PyErr_SetString(PyExc_ImportError, "Nmin must be bigger than 0!"); return NULL; } dimension = nmax - nmin + 1; /* Goes form nmin to nmax, both included */ result = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result == NULL) return NULL; data = (double *) result->data; ret = eval(nmax, x, data); if(PyGSL_ERROR_FLAG(ret) != GSL_SUCCESS) goto fail; FUNC_MESS_END(); return (PyObject *) result; fail: Py_XDECREF(result); return NULL; } typedef int (array_p_evaluator_idd_ad)(int nmax, double x1, double x2, double * result_array); static PyObject* PyGSL_sf_array_evaluator_idd_ad(PyObject *self, PyObject *args, array_p_evaluator_idd_ad * eval) { PyArrayObject *result = NULL; int nmin=0, nmax=0, dimension = 0, ret; double x=0, x1=0, *data=NULL; FUNC_MESS_BEGIN(); if (!PyArg_ParseTuple(args, "idd", &nmax, &x, &x1)){ return NULL; } if(nmin < 0){ PyErr_SetString(PyExc_ImportError, "Nmin must be bigger than 0!"); return NULL; } dimension = nmax - nmin + 1; /* Goes form nmin to nmax, both included */ result = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result == NULL) return NULL; data = (double *) result->data; ret = eval(nmax, x, x1, data); if(PyGSL_ERROR_FLAG(ret) != GSL_SUCCESS) goto fail; FUNC_MESS_END(); return (PyObject *) result; fail: Py_XDECREF(result); return NULL; } typedef int (array_p_evaluator_did_ad)( double x1, int nmax, double x2, double * result_array); static PyObject* PyGSL_sf_array_evaluator_did_ad(PyObject *self, PyObject *args, array_p_evaluator_did_ad * eval) { PyArrayObject *result = NULL; int nmin=0, nmax=0, dimension = 0, ret; double x=0, x1=0, *data=NULL; FUNC_MESS_BEGIN(); if (!PyArg_ParseTuple(args, "did",&x, &nmax, &x1)){ return NULL; } dimension = nmax - nmin + 1; /* Goes form nmin to nmax, both included */ result = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result == NULL) return NULL; data = (double *) result->data; ret = eval(nmax, x, x1, data); if(PyGSL_ERROR_FLAG(ret) != GSL_SUCCESS) goto fail; FUNC_MESS_END(); return (PyObject *) result; fail: Py_XDECREF(result); return NULL; } typedef int (array_p_evaluator_didd_add)(double , int , double , double , double * array, double*); static PyObject* PyGSL_sf_array_evaluator_didd_add(PyObject *self, PyObject *args, array_p_evaluator_didd_add * eval) { PyArrayObject *result = NULL; int nmin=0, nmax=0, dimension = 0, ret; double x=0, x1=0, *data=NULL, l_min, exponent; FUNC_MESS_BEGIN(); if (!PyArg_ParseTuple(args, "didd", &l_min, &nmax, &x, &x1)){ return NULL; } if(nmin < 0){ PyErr_SetString(PyExc_ImportError, "Nmin must be bigger than 0!"); return NULL; } dimension = nmax - nmin + 1; /* Goes form nmin to nmax, both included */ result = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result == NULL) return NULL; data = (double *) result->data; ret = eval(l_min, nmax, x, x1, data, &exponent); FUNC_MESS_END(); if(PyGSL_ERROR_FLAG(ret) != GSL_SUCCESS) goto fail; return Py_BuildValue("Od",result,exponent); fail: Py_XDECREF(result); return NULL; } typedef int (array_p_evaluator_didd_addadd)(double , int , double , double , double * array1, double*, double *array2, double*); static PyObject* PyGSL_sf_array_evaluator_didd_addadd(PyObject *self, PyObject *args, array_p_evaluator_didd_addadd * eval) { PyArrayObject *result1 = NULL,*result2 = NULL; int nmin=0, nmax=0, dimension = 0, ret; double x=0, x1=0, *data1=NULL, *data2=NULL, l_min, exponent1,exponent2; FUNC_MESS_BEGIN(); if (!PyArg_ParseTuple(args, "didd", &l_min, &nmax, &x, &x1)){ return NULL; } if(nmin < 0){ PyErr_SetString(PyExc_ImportError, "Nmin must be bigger than 0!"); return NULL; } dimension = nmax - nmin + 1; /* Goes form nmin to nmax, both included */ result1 = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result1 == NULL) goto fail; result2 = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result2 == NULL) goto fail; data1 = (double *) result1->data; data2 = (double *) result2->data; ret = eval(l_min, nmax, x, x1, data1, &exponent1, data2, &exponent2); FUNC_MESS_END(); if(PyGSL_ERROR_FLAG(ret) != GSL_SUCCESS) goto fail; return Py_BuildValue("OdOd",result1,exponent1,result2,exponent2); fail: Py_XDECREF(result1); Py_XDECREF(result2); return NULL; } typedef int (array_p_evaluator_didd_adadadaddd)(double , int , double , double , double * a1, double * a2, double * a3, double * a4, double*, double*); static PyObject* PyGSL_sf_array_evaluator_didd_adadadaddd(PyObject *self, PyObject *args, array_p_evaluator_didd_adadadaddd * eval) { PyArrayObject *result1 = NULL,*result2 = NULL, *result3=NULL,*result4=NULL; int nmin=0, nmax=0, dimension = 0, ret; double x=0, x1=0, l_min, exponent1, exponent2; FUNC_MESS_BEGIN(); if (!PyArg_ParseTuple(args, "didd", &l_min, &nmax, &x, &x1)){ return NULL; } if(nmin < 0){ PyErr_SetString(PyExc_ImportError, "Nmin must be bigger than 0!"); return NULL; } dimension = nmax - nmin + 1; /* Goes form nmin to nmax, both included */ result1 = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result1 == NULL) goto fail; result2 = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result2 == NULL) goto fail; result3 = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result3 == NULL) goto fail; result4 = (PyArrayObject *) PyArray_FromDims(1, &dimension, PyArray_DOUBLE); if(result4 == NULL) goto fail; ret = eval(l_min, nmax, x, x1, (double *) result1->data, (double *)result2->data, (double *) result3->data, (double *)result4->data, &exponent1, &exponent2); FUNC_MESS_END(); if(PyGSL_ERROR_FLAG(ret) != GSL_SUCCESS) goto fail; return Py_BuildValue("OOOOdd",result1,result2,result3,result4,exponent1, exponent2); fail: Py_XDECREF(result1); Py_XDECREF(result2); Py_XDECREF(result3); Py_XDECREF(result4); return NULL; } #define SF_ARRAY(name, function) \ static PyObject* sf_ ## name (PyObject *self, PyObject *args) \ { \ PyObject * tmp; \ FUNC_MESS_BEGIN(); \ tmp = PyGSL_sf_array_evaluator_ ## function (self, args, gsl_sf_ ## name); \ if (tmp == NULL){ \ PyGSL_add_traceback(module, __FILE__, __FUNCTION__, __LINE__); \ } \ FUNC_MESS_END(); \ return tmp; \ } SF_ARRAY(bessel_Jn_array, iid_ad); SF_ARRAY(bessel_Yn_array, iid_ad); SF_ARRAY(bessel_In_array, iid_ad); SF_ARRAY(bessel_Kn_array, iid_ad); SF_ARRAY(bessel_Kn_scaled_array, iid_ad); SF_ARRAY(bessel_jl_array, id_ad); SF_ARRAY(bessel_jl_steed_array, id_ad); SF_ARRAY(bessel_yl_array, id_ad); SF_ARRAY(bessel_il_scaled_array, id_ad); SF_ARRAY(bessel_kl_scaled_array, id_ad); SF_ARRAY(gegenpoly_array, idd_ad); SF_ARRAY(legendre_H3d_array, idd_ad); SF_ARRAY(coulomb_wave_F_array, didd_add); SF_ARRAY(coulomb_wave_sphF_array, didd_add); SF_ARRAY(coulomb_wave_FG_array, didd_addadd); SF_ARRAY(coulomb_wave_FGp_array, didd_adadadaddd); SF_ARRAY(coulomb_CL_array, did_ad); SF_ARRAY(legendre_Pl_array, id_ad); SF_ARRAY(legendre_Plm_array, legendre_iid_ad); SF_ARRAY(legendre_sphPlm_array, legendre_iid_ad); static PyMethodDef sf_array_functions[] = { {"bessel_Jn_array", (PyCFunction) sf_bessel_Jn_array, METH_VARARGS, NULL}, {"bessel_Yn_array", (PyCFunction) sf_bessel_Yn_array, METH_VARARGS, NULL}, {"bessel_In_array", (PyCFunction) sf_bessel_In_array, METH_VARARGS, NULL}, {"bessel_Kn_array", (PyCFunction) sf_bessel_Kn_array, METH_VARARGS, NULL}, {"bessel_Kn_scaled_array", (PyCFunction) sf_bessel_Kn_scaled_array, METH_VARARGS, NULL}, {"bessel_jl_array", (PyCFunction) sf_bessel_jl_array, METH_VARARGS, NULL}, {"bessel_jl_steed_array", (PyCFunction) sf_bessel_jl_steed_array, METH_VARARGS, NULL}, {"bessel_yl_array", (PyCFunction) sf_bessel_yl_array, METH_VARARGS, NULL}, {"bessel_il_scaled_array", (PyCFunction) sf_bessel_il_scaled_array, METH_VARARGS, NULL}, {"bessel_kl_scaled_array", (PyCFunction) sf_bessel_kl_scaled_array, METH_VARARGS, NULL}, {"gegenpoly_array", (PyCFunction) sf_gegenpoly_array, METH_VARARGS, NULL}, {"legendre_H3d_array", (PyCFunction) sf_legendre_H3d_array, METH_VARARGS, NULL}, {"coulomb_wave_F_array", (PyCFunction) sf_coulomb_wave_F_array, METH_VARARGS, NULL}, {"coulomb_wave_sphF_array", (PyCFunction) sf_coulomb_wave_sphF_array, METH_VARARGS, NULL}, {"coulomb_wave_FG_array", (PyCFunction) sf_coulomb_wave_FG_array, METH_VARARGS, NULL}, {"coulomb_wave_FGp_array", (PyCFunction) sf_coulomb_wave_FGp_array, METH_VARARGS, NULL}, {"coulomb_CL_array", (PyCFunction) sf_coulomb_CL_array, METH_VARARGS, NULL}, {"legendre_Pl_array", (PyCFunction) sf_legendre_Pl_array, METH_VARARGS, NULL}, {"legendre_Plm_array", (PyCFunction) sf_legendre_Plm_array, METH_VARARGS, NULL}, {"legendre_sphPlm_array", (PyCFunction) sf_legendre_sphPlm_array, METH_VARARGS, NULL}, {NULL, NULL, 0} }; #ifndef IMPORTALL DL_EXPORT(void) initsfarray(void) { module = Py_InitModule("sfarray", sf_array_functions); import_array(); init_pygsl(); } #endif
{ "alphanum_fraction": 0.6426887689, "avg_line_length": 33.7205128205, "ext": "c", "hexsha": "b7957e17584d93809451cd703af6e94320307283", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-10-02T06:18:07.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-02T06:18:07.000Z", "max_forks_repo_head_hexsha": "457e7afb5cab424296dff95e1acf10ebf70d32a9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "juhnowski/FishingRod", "max_forks_repo_path": "production/pygsl-0.9.5/testing/src/sf/sf__arrays.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "457e7afb5cab424296dff95e1acf10ebf70d32a9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "juhnowski/FishingRod", "max_issues_repo_path": "production/pygsl-0.9.5/testing/src/sf/sf__arrays.c", "max_line_length": 133, "max_stars_count": null, "max_stars_repo_head_hexsha": "457e7afb5cab424296dff95e1acf10ebf70d32a9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "juhnowski/FishingRod", "max_stars_repo_path": "production/pygsl-0.9.5/testing/src/sf/sf__arrays.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3799, "size": 13151 }
/* dht/test_dht.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman * * 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 3 of the License, 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. */ /* Author: G. Jungman */ #include <config.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <gsl/gsl_ieee_utils.h> #include <gsl/gsl_test.h> #include <gsl/gsl_dht.h> /* Test exact small transform. */ int test_dht_exact(void) { int stat = 0; double f_in[3] = { 1.0, 2.0, 3.0 }; double f_out[3]; gsl_dht * t = gsl_dht_new(3, 1.0, 1.0); gsl_dht_apply(t, f_in, f_out); /* Check values. */ if(fabs( f_out[0]-( 0.375254649407520))/0.375254649407520 > 1.0e-14) stat++; if(fabs( f_out[1]-(-0.133507872695560))/0.133507872695560 > 1.0e-14) stat++; if(fabs( f_out[2]-( 0.044679925143840))/0.044679925143840 > 1.0e-14) stat++; /* Check inverse. * We have to adjust the normalization * so we can use the same precalculated transform. */ gsl_dht_apply(t, f_out, f_in); f_in[0] *= 13.323691936314223*13.323691936314223; /* jzero[1,4]^2 */ f_in[1] *= 13.323691936314223*13.323691936314223; f_in[2] *= 13.323691936314223*13.323691936314223; /* The loss of precision on the inverse * is a little surprising. However, this * thing is quite tricky since the band-limited * function represented by the samples {1,2,3} * need not be very nice. Like in any spectral * application, you really have to have some * a-priori knowledge of the underlying function. */ if(fabs( f_in[0]-1.0)/1.0 > 2.0e-05) stat++; if(fabs( f_in[1]-2.0)/2.0 > 2.0e-05) stat++; if(fabs( f_in[2]-3.0)/3.0 > 2.0e-05) stat++; gsl_dht_free(t); return stat; } /* Test the transform * Integrate[x J_0(a x) / (x^2 + 1), {x,0,Inf}] = K_0(a) */ int test_dht_simple(void) { int stat = 0; int n; double f_in[128]; double f_out[128]; gsl_dht * t = gsl_dht_new(128, 0.0, 100.0); for(n=0; n<128; n++) { const double x = gsl_dht_x_sample(t, n); f_in[n] = 1.0/(1.0+x*x); } gsl_dht_apply(t, f_in, f_out); /* This is a difficult transform to calculate this way, * since it does not satisfy the boundary condition and * it dies quite slowly. So it is not meaningful to * compare this to high accuracy. We only check * that it seems to be working. */ if(fabs( f_out[0]-4.00)/4.00 > 0.02) stat++; if(fabs( f_out[5]-1.84)/1.84 > 0.02) stat++; if(fabs(f_out[10]-1.27)/1.27 > 0.02) stat++; if(fabs(f_out[35]-0.352)/0.352 > 0.02) stat++; if(fabs(f_out[100]-0.0237)/0.0237 > 0.02) stat++; gsl_dht_free(t); return stat; } /* Test the transform * Integrate[ x exp(-x) J_1(a x), {x,0,Inf}] = a F(3/2, 2; 2; -a^2) */ int test_dht_exp1(void) { int stat = 0; int n; double f_in[128]; double f_out[128]; gsl_dht * t = gsl_dht_new(128, 1.0, 20.0); for(n=0; n<128; n++) { const double x = gsl_dht_x_sample(t, n); f_in[n] = exp(-x); } gsl_dht_apply(t, f_in, f_out); /* Spot check. * Note that the systematic errors in the calculation * are quite large, so it is meaningless to compare * to a high accuracy. */ if(fabs( f_out[0]-0.181)/0.181 > 0.02) stat++; if(fabs( f_out[5]-0.357)/0.357 > 0.02) stat++; if(fabs(f_out[10]-0.211)/0.211 > 0.02) stat++; if(fabs(f_out[35]-0.0289)/0.0289 > 0.02) stat++; if(fabs(f_out[100]-0.00221)/0.00211 > 0.02) stat++; gsl_dht_free(t); return stat; } /* Test the transform * Integrate[ x^2 (1-x^2) J_1(a x), {x,0,1}] = 2/a^2 J_3(a) */ int test_dht_poly1(void) { int stat = 0; int n; double f_in[128]; double f_out[128]; gsl_dht * t = gsl_dht_new(128, 1.0, 1.0); for(n=0; n<128; n++) { const double x = gsl_dht_x_sample(t, n); f_in[n] = x * (1.0 - x*x); } gsl_dht_apply(t, f_in, f_out); /* Spot check. This function satisfies the boundary condition, * so the accuracy should be ok. */ if(fabs( f_out[0]-0.057274214)/0.057274214 > 1.0e-07) stat++; if(fabs( f_out[5]-(-0.000190850))/0.000190850 > 1.0e-05) stat++; if(fabs(f_out[10]-0.000024342)/0.000024342 > 1.0e-04) stat++; if(fabs(f_out[35]-(-4.04e-07))/4.04e-07 > 1.0e-03) stat++; if(fabs(f_out[100]-1.0e-08)/1.0e-08 > 0.25) stat++; gsl_dht_free(t); return stat; } int main() { gsl_ieee_env_setup (); gsl_test( test_dht_exact(), "Small Exact DHT"); gsl_test( test_dht_simple(), "Simple DHT"); gsl_test( test_dht_exp1(), "Exp J1 DHT"); gsl_test( test_dht_poly1(), "Poly J1 DHT"); exit (gsl_test_summary()); }
{ "alphanum_fraction": 0.6355521056, "avg_line_length": 26.5618556701, "ext": "c", "hexsha": "03cdea47972a7247cbc77922c9c91f690f1fe3dd", "lang": "C", "max_forks_count": 224, "max_forks_repo_forks_event_max_datetime": "2022-03-30T00:57:48.000Z", "max_forks_repo_forks_event_min_datetime": "2015-11-12T21:17:03.000Z", "max_forks_repo_head_hexsha": "70dc728926a835ba049ddd3f4627ef08db7c95a0", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "utdsimmons/ohpc", "max_forks_repo_path": "tests/libs/gsl/tests/dht/test.c", "max_issues_count": 1096, "max_issues_repo_head_hexsha": "70dc728926a835ba049ddd3f4627ef08db7c95a0", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:48:41.000Z", "max_issues_repo_issues_event_min_datetime": "2015-11-12T09:08:22.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "utdsimmons/ohpc", "max_issues_repo_path": "tests/libs/gsl/tests/dht/test.c", "max_line_length": 81, "max_stars_count": 692, "max_stars_repo_head_hexsha": "70dc728926a835ba049ddd3f4627ef08db7c95a0", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "utdsimmons/ohpc", "max_stars_repo_path": "tests/libs/gsl/tests/dht/test.c", "max_stars_repo_stars_event_max_datetime": "2022-03-30T03:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-11-12T13:56:43.000Z", "num_tokens": 1896, "size": 5153 }
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <ccl.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_vector.h> //Structure containing info about a model parameter typedef struct { int index; double value; } LSS_param; //Structure defining one of the tracers being correlated //Note that each LSS tracer contains many redshift bins //(whereas a CCL_ClTracer corresponds to a single bin) typedef struct { int n_bins; //Number of redshift bins int *num_z; //Number of z-values for the n(z) of each bin (dims -> [nbins]) double **z_nz_arr; //z-values for the n(z) of each bin (dims -> [nbins,num_z]) double **n_nz_arr; //n(z) of each bin (dims -> [nbins,num_z]) int n_nodes_b; //Number of nodes defining b(z) double *z_bz_arr; //Redshift values for each node (dims -> [n_nodes_b]) LSS_param *b_bz_arr; //Bias values for each node (dims -> [n_nodes_b]) int interp_scheme_b; //Interpolation scheme for b(z) //Add similar stuff for magnification bias, 2nd-order bias etc., //Add similar stuff for photo-z uncertainties? //Flags describing theoretical calculation int flag_w_rsd; //Include RSDs? int flag_w_mag; //Include magnification? int non_linear_type; //Scheme for non-linearities? //Array of CCL_ClTracers for each redshift bin (stored here to avoid recomputation?) CCL_ClTracer *t; // (dims -> [n_bins]) } LSS_tracer_info; //Structure containing info needed to compute the LSS likelihood typedef struct { //Cosmological parameters LSS_param par_Oc; LSS_param par_Ob; LSS_param par_Ok; LSS_param par_h; LSS_param par_s8; LSS_param par_ns; LSS_param par_w0; LSS_param par_wa; //Tracers to correlate LSS_tracer_info *tr1; LSS_tracer_info *tr2; //Probably a lot of stuff missing here //... } LSS_likelihood_workspace; //Structure defining a set of power spectra typedef struct { //Number of bins for each tracer int nbin_1; int nbin_2; //Number of bandpowers for each cross-power spectrum int **n_bpw; // (dim -> [nbin_1,nbin_2]) //Effective ell for each bandpower double ***l_bpw; // (dim -> [nbin_1,nbin_2,n_bpw[nbin_1,nbin_2]]) //Effective C_ell for each bandpower gsl_vector *cl_bpw; // (flattened [nbin_1,nbin_2,n_bpw[nbin_1,nbin_2]]) //This will probably have to be more general, with a weight-per-ell //array for each bandpower (e.g. to account for pseudo-Cl binning). } LSS_2pt_Cell; //Something like the above should be defined for the precision matrix, //or it could be read directly into a 2D matrix ////////// // Functions defined in lss_cell_io.c // //Read power spectrum LSS_2pt_Cell *lss_read_cell(char *fname); //Write power spectrum void lss_write_cell(char *fname,LSS_2pt_Cell *cl); //Read precision matrix gsl_matrix *lss_read_precision(char *fname); //Write precision matrix void lss_write_precision(char *fname,gsl_matrix *prec,LSS_2pt_Cell *cl); //Destructor void lss_free_cell(LSS_2pt_Cell *cl); ////////// // Functions defined in lss_tracers.c // //Creates new tracer LSS_tracer_info *lss_tracer_new(int n_bins, int *num_z,double **z_nz_arr,double **n_nz_arr, int n_nodes_b,double *z_bz_arr,double *b_bz_arr, int flag_w_rsd,int flag_w_mag,int non_linear_type); //Destructor void lss_tracer_free(LSS_tracer_info *tr); ////////// // Functions defined in lss_cell_th.c // //Compute theory power spectrum (and return as gsl_vector) gsl_vector *lss_cell_theory(ccl_cosmology *cosmo,LSS_likelihood_workspace *w,LSS_2pt_Cell *cl); ////////// // Functions defined in lss_cell_like.c // //Computes likelihood for a set of cosmological and nuisance parameters (encoded in params) double lss_likelihood(int n_par,double *params,LSS_2pt_Cell *data,gsl_matrix *prec,LSS_likelihood_workspace *w); //Creates a new LSS_likelihood_workspace LSS_likelihood_workspace *lss_like_workspace_new(ccl_cosmology *cosmo,LSS_tracer_info *tr1,LSS_tracer_info *tr2); //Destructor void lss_like_workspace_free(LSS_likelihood_workspace *w);
{ "alphanum_fraction": 0.7417102967, "avg_line_length": 32.3467741935, "ext": "h", "hexsha": "f5b428ef12635459e3ad2b13f6f0c97faa448222", "lang": "C", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-03-25T08:38:31.000Z", "max_forks_repo_forks_event_min_datetime": "2018-02-13T19:13:13.000Z", "max_forks_repo_head_hexsha": "49f4654dbe08eacb377cdfb6e8f1131f1bbd0349", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "LSSTDESC/LSSLike", "max_forks_repo_path": "C_old/include/lss_common.h", "max_issues_count": 13, "max_issues_repo_head_hexsha": "49f4654dbe08eacb377cdfb6e8f1131f1bbd0349", "max_issues_repo_issues_event_max_datetime": "2019-09-23T18:09:32.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-07T03:40:06.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "LSSTDESC/LSSLike", "max_issues_repo_path": "C_old/include/lss_common.h", "max_line_length": 113, "max_stars_count": 1, "max_stars_repo_head_hexsha": "49f4654dbe08eacb377cdfb6e8f1131f1bbd0349", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "LSSTDESC/LSSLike", "max_stars_repo_path": "C_old/include/lss_common.h", "max_stars_repo_stars_event_max_datetime": "2019-06-04T20:57:17.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-04T20:57:17.000Z", "num_tokens": 1149, "size": 4011 }
//This file contains mostly untested code for computing splined //periodic flux tube configurations #include <stdio.h> #include <stdlib.h> #include <math.h> #include <builtin_types.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_odeiv2.h> #include "intT.h" //extern "C" //__device__ __host__ float interp(float rho2, float *rho2sp, float4 *coefs); int func (double t, const double y[], double f[], void *params) { double *p = (double *)params; double lambda2 = p[0]; double a = p[1]; f[0] = 2.0/lambda2*t*exp(-pow(sin(pi*t/a),2)/lambda2); return GSL_SUCCESS; } int jac(double t, const double y[], double *dfdy, double dfdt[], void *params) { double *p = (double *)params; double lambda2 = p[0]; double a = p[1]; gsl_matrix_view dfdy_mat = gsl_matrix_view_array(dfdy, 1, 1); gsl_matrix * m = &dfdy_mat.matrix; double der=0.0; gsl_matrix_set (m, 0, 0, der); dfdt[0] = 2.0/lambda2*exp(-pow(sin(pi*t/a),2)/lambda2)*(1.0- 2.0*pi/(a*lambda2)*t*sin(pi*t/a)*cos(pi/a*t)); return GSL_SUCCESS; } float4* flspline(double *fli, float *rho2, int N) //Computes the cubic spline coefficients for f_lambda(rho^2) //uses Burden and Faires algorithm 3.5 (Clamped Cubic Spline) //Step numbers refer to this textbook { int i; double* h; double* l; double* mu; double* z; double* alpha; float4* flscoefs; h=(double *)malloc(N*sizeof(*h)); l=(double *)malloc(N*sizeof(*l)); mu=(double *)malloc(N*sizeof(*mu)); z=(double *)malloc(N*sizeof(*z)); alpha = (double *)malloc(N*sizeof(*alpha)); flscoefs=(float4 *)malloc(N*sizeof(*flscoefs)); //Step 1 for(i=0;i<N;i++) { flscoefs[i].x = fli[i]; } for(i=0;i<N-1;i++) h[i]=rho2[i+1]-rho2[i]; //Step 2 alpha[0]=3.0*(fli[1]-fli[0])/h[0]; alpha[N-1]=-3.0*(fli[N-1]-fli[N-2])/h[N-2]; //Step 3 for(i=1;i<N-1;i++) { //printf("%d \n",i); alpha[i]=3.0/h[i]*(fli[i+1]-fli[i])-3.0/h[i-1]*(fli[i]-fli[i-1]); } //Step 4 - //Steps 4-7 solve a tridiagonal system using Crout factorization (Burden and Faires alg 6.7) l[0]=2.0*h[0]; mu[0]=0.5; z[0]=alpha[0]/l[0]; //Step 5 for(i=1;i<N-1;i++) { l[i]=2.0*(rho2[i+1]-rho2[i-1])-h[i-1]*mu[i-1]; mu[i]=h[i]/l[i]; z[i]=(alpha[i]-h[i-1]*z[i-1])/l[i]; } //Step 6 l[N-1]=h[N-2]*(2.0-mu[N-2]); z[N-1]=(alpha[N-1]-h[N-2]*z[N-2])/l[N-1]; flscoefs[N-1].z = z[N-1]; //Step 7 for(i=N-2;i>-1;i--) { flscoefs[i].z = z[i]-mu[i]*flscoefs[i+1].z; flscoefs[i].y = (fli[i+1]-fli[i])/h[i] - h[i]*(flscoefs[i+1].z+2.0*flscoefs[i].z)/3.0; flscoefs[i].w = (flscoefs[i+1].z-flscoefs[i].z)/(3.0*h[i]); } //Free allocated memory free(h);free(l);free(mu);free(z);free(alpha); //Step 8 return flscoefs; } float4* getspline(float* rho2, double lambda2, double a, int Npoints) { double params[2]; const gsl_odeiv2_step_type * T = gsl_odeiv2_step_rk8pd; float4 *coefs; gsl_odeiv2_step * s = gsl_odeiv2_step_alloc (T, 1); gsl_odeiv2_control * c = gsl_odeiv2_control_y_new (1e-9,1e-7); gsl_odeiv2_evolve * e = gsl_odeiv2_evolve_alloc (1); params[0] = lambda2; params[1] = a; gsl_odeiv2_system sys = {func, jac, 1, params}; double rho = 0.0; double rhof = 20.0; double h = rhof/((double)Npoints); double y[1] = { 0.00 }; double *flambda; int i=0; flambda=(double *)malloc(Npoints*sizeof(*flambda)); while (i<Npoints) { int status = gsl_odeiv2_evolve_apply_fixed_step (e, c, s, &sys, &rho, h, y); if(status == GSL_FAILURE) { printf("ERROR:GSL_FAILURE\n"); break; } else if (status != GSL_SUCCESS) break; rho2[i]=rho*rho; flambda[i]=y[0]; i+=1; //rho+=h; } gsl_odeiv2_evolve_free (e); gsl_odeiv2_control_free (c); gsl_odeiv2_step_free (s); coefs=flspline(flambda,rho2,Npoints); free(flambda); return coefs; } double getinterp(float rho2, float *rho2sp, float4 *coefs) { int j; int upperi=Nspline-1, loweri=0; float rho2diff=0.0; double flambda; //Discover which interval to look in using a binary search if(rho2<rho2sp[Nspline-1] && rho2>rho2sp[0]) // if(0) { while(upperi-loweri > 1) { if(rho2 >= rho2sp[(upperi+loweri)/2]) loweri=(upperi+loweri)/2; else upperi=(upperi+loweri)/2; } //interpolate using the jth interval j=loweri; rho2diff=rho2-rho2sp[j]; //rho2diff=0.0; flambda= coefs[j].x+rho2diff*(coefs[j].y+rho2diff*(coefs[j].z+rho2diff*coefs[j].w)); } else { j=0; rho2diff=0.0f; flambda=0.0f; } //*flambda= coefs[j].x+rho2diff*(coefs[j].y+rho2diff*(coefs[j].z+rho2diff*coefs[j].w)); //*fprime = coefs[j].y+rho2diff*(2.0f*coefs[j].z + rho2diff*(3.0f*coefs[j].w)); //*flambda=1.0f-exp(-1.0f*rho2); //*fprime=1.0f*exp(-1.0f*rho2); return flambda; } double testspline(float rho2, double lambda2, double a, int Npoints, float *rho2sp, float4 *flcoefs) { printf("testspline: rho2=%f\n",(double)rho2); double flodeiv, flspline; double params[2]; const gsl_odeiv2_step_type * T = gsl_odeiv2_step_rk8pd; float4 *coefs; gsl_odeiv2_step * s = gsl_odeiv2_step_alloc (T, 1); gsl_odeiv2_control * c = gsl_odeiv2_control_y_new (1e-9,1e-7); gsl_odeiv2_evolve * e = gsl_odeiv2_evolve_alloc (1); params[0] = lambda2; params[1] = a; gsl_odeiv2_system sys = {func, jac, 1, params}; double rho = 0.0; double rhof = sqrt(rho2); double h = rhof/((double)Npoints); double y[1] = { 0.00 }; double *flambda; int i=0; flambda=(double *)malloc(Npoints*sizeof(*flambda)); while(rho<rhof) { int status = gsl_odeiv2_evolve_apply (e, c, s, &sys, &rho, rhof, &h, y); if(status == GSL_FAILURE) { printf("ERROR:GSL_FAILURE\n"); } } flodeiv=y[0]; //rho+=h; flspline=(double)interp(rho2, rho2sp, flcoefs); return (flodeiv-flspline)/flodeiv; }
{ "alphanum_fraction": 0.5946657886, "avg_line_length": 24.3935742972, "ext": "c", "hexsha": "3aac996cdb49d6dce7e824144e1ee22447a26ed6", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "81cdf2bbb91e50cfe60e0ed81e6c93079a176cc8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "QEDan/Worldline-Flux-Tube-Lattice", "max_forks_repo_path": "periodic.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "81cdf2bbb91e50cfe60e0ed81e6c93079a176cc8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "QEDan/Worldline-Flux-Tube-Lattice", "max_issues_repo_path": "periodic.c", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "81cdf2bbb91e50cfe60e0ed81e6c93079a176cc8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "QEDan/Worldline-Flux-Tube-Lattice", "max_stars_repo_path": "periodic.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2297, "size": 6074 }
// https://www.gnu.org/software/gsl/doc/html/fft.html #include <stdio.h> #include <math.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_fft_real.h> #include <gsl/gsl_fft_halfcomplex.h> int main (void) { int i, n = 100; double data[n]; gsl_fft_real_wavetable * real; gsl_fft_halfcomplex_wavetable * hc; gsl_fft_real_workspace * work; for (i = 0; i < n; i++) { data[i] = 0.0; } for (i = n / 3; i < 2 * n / 3; i++) { data[i] = 1.0; } for (i = 0; i < n; i++) { printf ("%d: %e\n", i, data[i]); } printf ("\n"); work = gsl_fft_real_workspace_alloc (n); real = gsl_fft_real_wavetable_alloc (n); gsl_fft_real_transform (data, 1, n, real, work); gsl_fft_real_wavetable_free (real); for (i = 11; i < n; i++) { data[i] = 0; } hc = gsl_fft_halfcomplex_wavetable_alloc (n); gsl_fft_halfcomplex_inverse (data, 1, n, hc, work); gsl_fft_halfcomplex_wavetable_free (hc); for (i = 0; i < n; i++) { printf ("%d: %e\n", i, data[i]); } gsl_fft_real_workspace_free (work); return 0; }
{ "alphanum_fraction": 0.5555555556, "avg_line_length": 19.05, "ext": "c", "hexsha": "cee5beea50847d05637b28b6201889b350de1ee9", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fceabadef49ffe6ed25dfef38e3dc418f309e128", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "al2698/sp", "max_forks_repo_path": "07-lib/gsl/fft1.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "fceabadef49ffe6ed25dfef38e3dc418f309e128", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "al2698/sp", "max_issues_repo_path": "07-lib/gsl/fft1.c", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "fceabadef49ffe6ed25dfef38e3dc418f309e128", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "al2698/sp", "max_stars_repo_path": "07-lib/gsl/fft1.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 377, "size": 1143 }
#include "snd.h" #include "clm2xen.h" /* Snd defines its own exit and delay * * In Ruby, rand is kernel_rand. * * In Forth, Snd's exit is named snd-exit. */ /* -------- protect XEN vars from GC -------- */ #if HAVE_SCHEME int snd_protect(XEN obj) {return(s7_gc_protect(s7, obj));} void snd_unprotect_at(int loc) {s7_gc_unprotect_at(s7, loc);} XEN snd_protected_at(int loc) {return(s7_gc_protected_at(s7, loc));} #else static XEN gc_protection; static int gc_protection_size = 0; #define DEFAULT_GC_VALUE XEN_UNDEFINED static int gc_last_cleared = NOT_A_GC_LOC; static int gc_last_set = NOT_A_GC_LOC; int snd_protect(XEN obj) { int i, old_size; XEN tmp; if (gc_protection_size == 0) { gc_protection_size = 512; gc_protection = XEN_MAKE_VECTOR(gc_protection_size, DEFAULT_GC_VALUE); XEN_PROTECT_FROM_GC(gc_protection); XEN_VECTOR_SET(gc_protection, 0, obj); gc_last_set = 0; } else { if ((gc_last_cleared >= 0) && XEN_EQ_P(XEN_VECTOR_REF(gc_protection, gc_last_cleared), DEFAULT_GC_VALUE)) { /* we hit this branch about 2/3 of the time */ XEN_VECTOR_SET(gc_protection, gc_last_cleared, obj); gc_last_set = gc_last_cleared; gc_last_cleared = NOT_A_GC_LOC; return(gc_last_set); } for (i = gc_last_set; i < gc_protection_size; i++) if (XEN_EQ_P(XEN_VECTOR_REF(gc_protection, i), DEFAULT_GC_VALUE)) { XEN_VECTOR_SET(gc_protection, i, obj); gc_last_set = i; return(gc_last_set); } for (i = 0; i < gc_last_set; i++) if (XEN_EQ_P(XEN_VECTOR_REF(gc_protection, i), DEFAULT_GC_VALUE)) { /* here we average 3 checks before a hit, so this isn't as bad as it looks */ XEN_VECTOR_SET(gc_protection, i, obj); gc_last_set = i; return(gc_last_set); } tmp = gc_protection; old_size = gc_protection_size; gc_protection_size *= 2; gc_protection = XEN_MAKE_VECTOR(gc_protection_size, DEFAULT_GC_VALUE); XEN_PROTECT_FROM_GC(gc_protection); for (i = 0; i < old_size; i++) { XEN_VECTOR_SET(gc_protection, i, XEN_VECTOR_REF(tmp, i)); XEN_VECTOR_SET(tmp, i, DEFAULT_GC_VALUE); } XEN_VECTOR_SET(gc_protection, old_size, obj); /* in Ruby, I think we can unprotect it */ #if HAVE_RUBY || HAVE_FORTH XEN_UNPROTECT_FROM_GC(tmp); #endif gc_last_set = old_size; } return(gc_last_set); } void snd_unprotect_at(int loc) { if (loc >= 0) { XEN_VECTOR_SET(gc_protection, loc, DEFAULT_GC_VALUE); gc_last_cleared = loc; } } XEN snd_protected_at(int loc) { if (loc >= 0) return(XEN_VECTOR_REF(gc_protection, loc)); return(DEFAULT_GC_VALUE); } #endif /* -------- error handling -------- */ static char *last_file_loaded = NULL; #if HAVE_SCHEME static XEN g_snd_s7_error_handler(XEN args) { s7_pointer msg; msg = s7_car(args); XEN_ASSERT_TYPE(XEN_STRING_P(msg), msg, XEN_ONLY_ARG, "_snd_s7_error_handler_", "a string"); #if MUS_DEBUGGING fprintf(stderr, "error: %s\n", s7_object_to_c_string(s7, args)); #endif if (ss->xen_error_handler) (*(ss->xen_error_handler))(s7_string(msg), (void *)any_selected_sound()); /* not NULL! */ return(s7_f(s7)); } #endif void redirect_xen_error_to(void (*handler)(const char *msg, void *ufd), void *data) { ss->xen_error_handler = handler; ss->xen_error_data = data; #if HAVE_SCHEME if (handler == NULL) s7_eval_c_string(s7, "(set! (hook-functions *error-hook*) '())"); else s7_eval_c_string(s7, "(set! (hook-functions *error-hook*) (list \n\ (lambda (tag args) \n\ (_snd_s7_error_handler_ \n\ (string-append \n\ (if (string? args) \n\ args \n\ (if (pair? args) \n\ (apply format #f (car args) (cdr args)) \n\ \"\")) \n\ (if (and (*error-info* 2) \n\ (string? (*error-info* 4)) \n\ (number? (*error-info* 3))) \n\ (format #f \"~%~S[~D]: ~A~%\" \n\ (*error-info* 4) \n\ (*error-info* 3) \n\ (*error-info* 2)) \n\ \"\"))))))"); #endif } void redirect_snd_print_to(void (*handler)(const char *msg, void *ufd), void *data) { ss->snd_print_handler = handler; ss->snd_print_data = data; } void redirect_everything_to(void (*handler)(const char *msg, void *ufd), void *data) { redirect_snd_error_to(handler, data); redirect_xen_error_to(handler, data); redirect_snd_warning_to(handler, data); redirect_snd_print_to(handler, data); } void redirect_errors_to(void (*handler)(const char *msg, void *ufd), void *data) { redirect_snd_error_to(handler, data); redirect_xen_error_to(handler, data); redirect_snd_warning_to(handler, data); } static char *gl_print(XEN result); /* ---------------- RUBY error handler ---------------- */ #if HAVE_RUBY static XEN snd_format_if_needed(XEN args) { /* if car has formatting info, use next arg as arg list for it */ XEN format_args = XEN_EMPTY_LIST, cur_arg, result; int i, start = 0, num_args, format_info_len, err_size = 8192; bool got_tilde = false, was_formatted = false; char *format_info = NULL, *errmsg = NULL; num_args = XEN_LIST_LENGTH(args); if (num_args == 1) return(XEN_CAR(args)); format_info = mus_strdup(XEN_TO_C_STRING(XEN_CAR(args))); format_info_len = mus_strlen(format_info); if (XEN_LIST_P(XEN_CADR(args))) format_args = XEN_COPY_ARG(XEN_CADR(args)); /* protect Ruby case */ else format_args = XEN_CADR(args); errmsg = (char *)calloc(err_size, sizeof(char)); for (i = 0; i < format_info_len; i++) { if (format_info[i] == '~') { strncat(errmsg, (char *)(format_info + start), i - start); start = i + 2; got_tilde = true; } else { if (got_tilde) { was_formatted = true; got_tilde = false; switch (format_info[i]) { case '~': errmsg = mus_strcat(errmsg, "~", &err_size); break; case '%': errmsg = mus_strcat(errmsg, "\n", &err_size); break; case 'S': case 'A': if (XEN_NOT_NULL_P(format_args)) { cur_arg = XEN_CAR(format_args); format_args = XEN_CDR(format_args); if (XEN_VECTOR_P(cur_arg)) { char *vstr; vstr = gl_print(cur_arg); errmsg = mus_strcat(errmsg, vstr, &err_size); free(vstr); } else { char *temp = NULL; errmsg = mus_strcat(errmsg, temp = (char *)XEN_AS_STRING(cur_arg), &err_size); } } /* else ignore it */ break; default: start = i - 1; break; } } } } if (i > start) strncat(errmsg, (char *)(format_info + start), i - start); if (format_info) free(format_info); if (!was_formatted) { char *temp = NULL; errmsg = mus_strcat(errmsg, " ", &err_size); errmsg = mus_strcat(errmsg, temp = (char *)XEN_AS_STRING(XEN_CADR(args)), &err_size); } if (num_args > 2) { if ((!was_formatted) || (!(XEN_FALSE_P(XEN_CADDR(args))))) start = 2; else start = 3; for (i = start; i < num_args; i++) { char *temp = NULL; errmsg = mus_strcat(errmsg, " ", &err_size); errmsg = mus_strcat(errmsg, temp = (char *)XEN_AS_STRING(XEN_LIST_REF(args, i)), &err_size); } } result = C_TO_XEN_STRING(errmsg); free(errmsg); return(result); } void snd_rb_raise(XEN tag, XEN throw_args) { static char *msg = NULL; XEN err = rb_eStandardError, bt; bool need_comma = false; int size = 2048; if (strcmp(rb_id2name(tag), "Out_of_range") == 0) err = rb_eRangeError; else if (strcmp(rb_id2name(tag), "Wrong_type_arg") == 0) err = rb_eTypeError; if (msg) free(msg); msg = (char *)calloc(size, sizeof(char)); if ((XEN_LIST_P(throw_args)) && (XEN_LIST_LENGTH(throw_args) > 0)) { /* normally car is string name of calling func */ if (XEN_NOT_FALSE_P(XEN_CAR(throw_args))) { snprintf(msg, size, "%s: %s", XEN_AS_STRING(XEN_CAR(throw_args)), rb_id2name(tag)); need_comma = true; } if (XEN_LIST_LENGTH(throw_args) > 1) { /* here XEN_CADR can contain formatting info and XEN_CADDR is a list of args to fit in */ /* or it may be a list of info vars etc */ if (need_comma) msg = mus_strcat(msg, ": ", &size); /* new size, if realloc, reported through size arg */ if (XEN_STRING_P(XEN_CADR(throw_args))) msg = mus_strcat(msg, XEN_TO_C_STRING(snd_format_if_needed(XEN_CDR(throw_args))), &size); else msg = mus_strcat(msg, XEN_AS_STRING(XEN_CDR(throw_args)), &size); } } bt = rb_funcall(err, rb_intern("caller"), 0); if (XEN_VECTOR_P(bt) && XEN_VECTOR_LENGTH(bt) > 0) { int i; msg = mus_strcat(msg, "\n", &size); for (i = 0; i < XEN_VECTOR_LENGTH(bt); i++) { msg = mus_strcat(msg, XEN_TO_C_STRING(XEN_VECTOR_REF(bt, i)), &size); msg = mus_strcat(msg, "\n", &size); } } if (strcmp(rb_id2name(tag), "Snd_error") != 0) { if (!(run_snd_error_hook(msg))) { if (ss->xen_error_handler) { /* make sure it doesn't call itself recursively */ void (*old_xen_error_handler)(const char *msg, void *data); void *old_xen_error_data; old_xen_error_handler = ss->xen_error_handler; old_xen_error_data = ss->xen_error_data; ss->xen_error_handler = NULL; ss->xen_error_data = NULL; (*(old_xen_error_handler))(msg, old_xen_error_data); ss->xen_error_handler = old_xen_error_handler; ss->xen_error_data = old_xen_error_data; } } } rb_raise(err, msg); } #endif /* end HAVE_RUBY */ #if HAVE_EXTENSION_LANGUAGE XEN snd_catch_any(XEN_CATCH_BODY_TYPE body, void *body_data, const char *caller) { return((*body)(body_data)); } #else /* no extension language but user managed to try to evaluate something -- one way is to * activate the minibuffer (via click) and type an expression into it */ XEN snd_catch_any(XEN_CATCH_BODY_TYPE body, void *body_data, const char *caller) { snd_error("This version of Snd has no extension language, so there's no way for %s to evaluate anything", caller); return(XEN_FALSE); } #endif bool procedure_arity_ok(XEN proc, int args) { XEN arity; int rargs; arity = XEN_ARITY(proc); #if HAVE_RUBY rargs = XEN_TO_C_INT(arity); return(xen_rb_arity_ok(rargs, args)); #endif #if HAVE_FORTH rargs = XEN_TO_C_INT(arity); if (rargs != args) return(false); #endif #if HAVE_SCHEME { int oargs, restargs, gc_loc; gc_loc = s7_gc_protect(s7, arity); rargs = XEN_TO_C_INT(XEN_CAR(arity)); oargs = XEN_TO_C_INT(XEN_CADR(arity)); restargs = ((XEN_TRUE_P(XEN_CADDR(arity))) ? 1 : 0); s7_gc_unprotect_at(s7, gc_loc); if (rargs > args) return(false); if ((restargs == 0) && ((rargs + oargs) < args)) return(false); } #endif return(true); } char *procedure_ok(XEN proc, int args, const char *caller, const char *arg_name, int argn) { /* if string returned, needs to be freed */ /* 0 args is special => "thunk" meaning in this case that optional args are not ok (applies to as-one-edit and two menu callbacks) */ XEN arity; int rargs; if (!(XEN_PROCEDURE_P(proc))) { if (XEN_NOT_FALSE_P(proc)) /* #f as explicit arg to clear */ { char *temp = NULL, *str; str = mus_format("%s: %s (%s arg %d) is not a procedure!", temp = (char *)XEN_AS_STRING(proc), arg_name, caller, argn); #if HAVE_SCHEME if (temp) free(temp); #endif return(str); } } else { arity = XEN_ARITY(proc); #if HAVE_RUBY rargs = XEN_TO_C_INT(arity); if (!xen_rb_arity_ok(rargs, args)) return(mus_format("%s function (%s arg %d) should take %d args, not %d", arg_name, caller, argn, args, (rargs < 0) ? (-rargs) : rargs)); #endif #if HAVE_SCHEME { int oargs, restargs; int loc; loc = snd_protect(arity); rargs = XEN_TO_C_INT(XEN_CAR(arity)); oargs = XEN_TO_C_INT(XEN_CADR(arity)); restargs = ((XEN_TRUE_P(XEN_CADDR(arity))) ? 1 : 0); snd_unprotect_at(loc); if (rargs > args) return(mus_format("%s function (%s arg %d) should take %d argument%s, but instead requires %d", arg_name, caller, argn, args, (args != 1) ? "s" : "", rargs)); if ((restargs == 0) && ((rargs + oargs) < args)) return(mus_format("%s function (%s arg %d) should accept at least %d argument%s, but instead accepts only %d", arg_name, caller, argn, args, (args != 1) ? "s" : "", rargs + oargs)); if ((args == 0) && ((rargs != 0) || (oargs != 0) || (restargs != 0))) return(mus_format("%s function (%s arg %d) should take no args, not %d", arg_name, caller, argn, rargs + oargs + restargs)); } #endif #if HAVE_FORTH rargs = XEN_TO_C_INT(arity); if (rargs != args) return(mus_format("%s function (%s arg %d) should take %d args, not %d", arg_name, caller, argn, args, rargs)); #endif } return(NULL); } XEN snd_no_such_file_error(const char *caller, XEN filename) { XEN_ERROR(NO_SUCH_FILE, XEN_LIST_4(C_TO_XEN_STRING("no-such-file: ~A ~S: ~A"), C_TO_XEN_STRING(caller), filename, C_TO_XEN_STRING(snd_open_strerror()))); return(XEN_FALSE); } XEN snd_no_such_channel_error(const char *caller, XEN snd, XEN chn) { int index = NOT_A_SOUND; snd_info *sp; if (XEN_INTEGER_P(snd)) index = XEN_TO_C_INT(snd); else { if (XEN_SOUND_P(snd)) index = XEN_SOUND_TO_C_INT(snd); } if ((index >= 0) && (index < ss->max_sounds) && (snd_ok(ss->sounds[index]))) /* good grief... */ { sp = ss->sounds[index]; XEN_ERROR(NO_SUCH_CHANNEL, XEN_LIST_6(C_TO_XEN_STRING("no-such-channel: (~A: sound: ~A, chan: ~A) (~S, chans: ~A))"), C_TO_XEN_STRING(caller), snd, chn, C_TO_XEN_STRING(sp->short_filename), C_TO_XEN_INT(sp->nchans))); } XEN_ERROR(NO_SUCH_CHANNEL, XEN_LIST_4(C_TO_XEN_STRING("no-such-channel: (~A: sound: ~A, chan: ~A)"), C_TO_XEN_STRING(caller), snd, chn)); return(XEN_FALSE); } XEN snd_no_active_selection_error(const char *caller) { XEN_ERROR(XEN_ERROR_TYPE("no-active-selection"), XEN_LIST_2(C_TO_XEN_STRING("~A: no active selection"), C_TO_XEN_STRING(caller))); return(XEN_FALSE); } XEN snd_bad_arity_error(const char *caller, XEN errstr, XEN proc) { XEN_ERROR(XEN_ERROR_TYPE("bad-arity"), XEN_LIST_3(C_TO_XEN_STRING("~A,~A"), C_TO_XEN_STRING(caller), errstr)); return(XEN_FALSE); } /* -------- various evaluators (within our error handler) -------- */ XEN eval_str_wrapper(void *data) { return(XEN_EVAL_C_STRING((char *)data)); } #if (!HAVE_SCHEME) XEN eval_form_wrapper(void *data) { return(XEN_EVAL_FORM((XEN)data)); } #else XEN eval_form_wrapper(void *data) { return(XEN_FALSE); } #endif static XEN string_to_form_1(void *data) { return(C_STRING_TO_XEN_FORM((char *)data)); } XEN string_to_form(const char *str) { return(snd_catch_any(string_to_form_1, (void *)str, str)); /* catch needed else #< in input (or incomplete form) exits Snd! */ } static XEN eval_file_wrapper(void *data) { XEN error; last_file_loaded = (char *)data; error = XEN_LOAD_FILE((char *)data); /* error only meaningful in Ruby */ last_file_loaded = NULL; return(error); } static char *g_print_1(XEN obj) /* free return val */ { #if HAVE_SCHEME return(XEN_AS_STRING(obj)); #endif #if HAVE_FORTH || HAVE_RUBY return(mus_strdup(XEN_AS_STRING(obj))); #endif #if (!HAVE_EXTENSION_LANGUAGE) return(NULL); #endif } static char *gl_print(XEN result) { char *newbuf = NULL, *str = NULL; int i, ilen, savelen; #if HAVE_SCHEME /* expand \t first (neither gtk nor motif handles this automatically) * but... "#\\t" is the character t not a tab indication! * (object->string #\t) */ #define TAB_SPACES 4 int tabs = 0, len, j = 0; newbuf = g_print_1(result); len = mus_strlen(newbuf); for (i = 0; i < len - 1; i++) if (((i == 0) || (newbuf[i - 1] != '\\')) && (newbuf[i] == '\\') && (newbuf[i + 1] == 't')) tabs++; if (tabs == 0) return(newbuf); ilen = len + tabs * TAB_SPACES; str = (char *)calloc(ilen, sizeof(char)); for (i = 0; i < len - 1; i++) { if (((i == 0) || (newbuf[i - 1] != '\\')) && (newbuf[i] == '\\') && (newbuf[i + 1] == 't')) { int k; for (k = 0; k < TAB_SPACES; k++) str[j + k] = ' '; j += TAB_SPACES; i++; } else str[j++] = newbuf[i]; } str[j] = newbuf[len - 1]; free(newbuf); return(str); #endif /* specialize vectors which can be enormous in this context */ if ((!(XEN_VECTOR_P(result))) || ((int)(XEN_VECTOR_LENGTH(result)) <= print_length(ss))) return(g_print_1(result)); ilen = print_length(ss); newbuf = (char *)calloc(128, sizeof(char)); savelen = 128; #if HAVE_FORTH sprintf(newbuf, "#("); #endif #if HAVE_RUBY sprintf(newbuf, "["); #endif for (i = 0; i < ilen; i++) { str = g_print_1(XEN_VECTOR_REF(result, i)); if ((str) && (*str)) { if (i != 0) { #if HAVE_RUBY newbuf = mus_strcat(newbuf, ",", &savelen); #endif newbuf = mus_strcat(newbuf, " ", &savelen); } newbuf = mus_strcat(newbuf, str, &savelen); free(str); } } #if HAVE_FORTH newbuf = mus_strcat(newbuf, " ...)", &savelen); #endif #if HAVE_RUBY newbuf = mus_strcat(newbuf, " ...]", &savelen); #endif return(newbuf); } void snd_display_result(const char *str, const char *endstr) { if (ss->snd_print_handler) { /* make sure it doesn't call itself recursively */ void (*old_snd_print_handler)(const char *msg, void *data); void *old_snd_print_data; old_snd_print_handler = ss->snd_print_handler; old_snd_print_data = ss->snd_print_data; ss->snd_print_handler = NULL; ss->snd_print_data = NULL; (*(old_snd_print_handler))(str, old_snd_print_data); ss->snd_print_handler = old_snd_print_handler; ss->snd_print_data = old_snd_print_data; } else { if (endstr) listener_append(endstr); listener_append_and_prompt(str); } } void snd_report_result(XEN result, const char *buf) { char *str = NULL; str = gl_print(result); snd_display_result(str, buf); if (str) free(str); } void snd_report_listener_result(XEN form) { snd_report_result(form, "\n"); } static char *stdin_str = NULL; void clear_stdin(void) { if (stdin_str) free(stdin_str); stdin_str = NULL; } static char *stdin_check_for_full_expression(const char *newstr) { #if HAVE_SCHEME int end_of_text; #endif if (stdin_str) { char *str; str = stdin_str; stdin_str = (char *)calloc(mus_strlen(str) + mus_strlen(newstr) + 2, sizeof(char)); strcat(stdin_str, str); strcat(stdin_str, newstr); free(str); } else stdin_str = mus_strdup(newstr); #if HAVE_SCHEME end_of_text = check_balance(stdin_str, 0, mus_strlen(stdin_str), false); /* last-arg->not in listener */ if (end_of_text > 0) { if (end_of_text + 1 < mus_strlen(stdin_str)) stdin_str[end_of_text + 1] = 0; return(stdin_str); } return(NULL); #endif return(stdin_str); } static void string_to_stdout(const char *msg, void *ignored) { fprintf(stdout, "%s\n", msg); } void snd_eval_stdin_str(const char *buf) { /* we may get incomplete expressions here */ /* (Ilisp always sends a complete expression, but it may be broken into two or more pieces from read's point of view) */ char *str = NULL; if (mus_strlen(buf) == 0) return; str = stdin_check_for_full_expression(buf); if (str) { XEN result; int loc; redirect_everything_to(string_to_stdout, NULL); result = snd_catch_any(eval_str_wrapper, (void *)str, str); redirect_everything_to(NULL, NULL); loc = snd_protect(result); if (stdin_str) free(stdin_str); /* same as str here */ stdin_str = NULL; str = gl_print(result); string_to_stdout(str, NULL); if (str) free(str); snd_unprotect_at(loc); } } static void string_to_stderr_and_listener(const char *msg, void *ignore) { fprintf(stderr, "%s\n", msg); if (listener_exists()) /* the idea here is to save startup errors until we can post them */ { listener_append((char *)msg); listener_append("\n"); } else { if (ss->startup_errors) { char *temp; temp = ss->startup_errors; ss->startup_errors = mus_format("%s\n%s %s\n", ss->startup_errors, listener_prompt(ss), msg); free(temp); } else ss->startup_errors = mus_strdup(msg); /* initial prompt is already there */ } } static bool snd_load_init_file_1(const char *filename) { char *expr, *fullname; bool happy = false; fullname = mus_expand_filename(filename); if (mus_file_probe(fullname)) { happy = true; #if HAVE_SCHEME expr = mus_format("(load %s)", fullname); #endif #if HAVE_RUBY || HAVE_FORTH expr = mus_format("load(%s)", fullname); #endif snd_catch_any(eval_file_wrapper, (void *)fullname, expr); free(expr); } if (fullname) free(fullname); return(happy); } void snd_load_init_file(bool no_global, bool no_init) { /* look for ".snd" on the home directory; return true if an error occurred (to try to get that info to the user's attention) */ /* called only in snd-g|xmain.c at initialization time */ /* changed Oct-05 because the Scheme/Ruby/Forth choices are becoming a hassle -- * now save-options has its own file ~/.snd_prefs_ruby|forth|s7 which is loaded first, if present * then ~/.snd_ruby|forth|s7, if present * then ~/.snd for backwards compatibility * snd_options does not write ~/.snd anymore, but overwrites the .snd_prefs_* file * use set init files only change the ~/.snd choice * * there are parallel choices for the global configuration file: /etc/snd_ruby|forth|s7.conf */ #if HAVE_EXTENSION_LANGUAGE #if HAVE_RUBY #define SND_EXT_CONF "/etc/snd_ruby.conf" #define SND_PREFS "~/.snd_prefs_ruby" #define SND_INIT "~/.snd_ruby" #endif #if HAVE_FORTH #define SND_EXT_CONF "/etc/snd_forth.conf" #define SND_PREFS "~/.snd_prefs_forth" #define SND_INIT "~/.snd_forth" #endif #if HAVE_SCHEME #define SND_EXT_CONF "/etc/snd_s7.conf" #define SND_PREFS "~/.snd_prefs_s7" #define SND_INIT "~/.snd_s7" #endif #define SND_INIT_FILE_ENVIRONMENT_NAME "SND_INIT_FILE" #if (!HAVE_WINDOZE) #define INIT_FILE_NAME "~/.snd" #else #define INIT_FILE_NAME "snd-init" #endif #define SND_CONF "/etc/snd.conf" redirect_snd_print_to(string_to_stdout, NULL); redirect_errors_to(string_to_stderr_and_listener, NULL); /* check for global configuration files (/etc/snd*) */ if (!no_global) { snd_load_init_file_1(SND_EXT_CONF); snd_load_init_file_1(SND_CONF); } /* now load local init file(s) */ if (!no_init) { char *temp; snd_load_init_file_1(SND_PREFS); /* check for possible prefs dialog output */ snd_load_init_file_1(SND_INIT); temp = getenv(SND_INIT_FILE_ENVIRONMENT_NAME); if (temp) snd_load_init_file_1(temp); else snd_load_init_file_1(INIT_FILE_NAME); } redirect_everything_to(NULL, NULL); #endif } static char *find_source_file(const char *orig); void snd_load_file(const char *filename) { char *str = NULL, *str2 = NULL; str = mus_expand_filename(filename); if (!(mus_file_probe(str))) { char *temp; temp = find_source_file(str); free(str); str = temp; } if (!str) { snd_error("can't load %s: %s", filename, snd_open_strerror()); return; } str2 = mus_format("(load \"%s\")", filename); /* currently unused in Forth and Ruby */ snd_catch_any(eval_file_wrapper, (void *)str, str2); if (str) free(str); if (str2) free(str2); } static XEN g_snd_print(XEN msg) { #define H_snd_print "(" S_snd_print " str): display str in the listener window" char *str = NULL; if (XEN_STRING_P(msg)) str = mus_strdup(XEN_TO_C_STRING(msg)); else { if (XEN_CHAR_P(msg)) { str = (char *)calloc(2, sizeof(char)); str[0] = XEN_TO_C_CHAR(msg); } else str = gl_print(msg); } if (str) { listener_append(str); free(str); } /* used to check for event in Motif case, but that is very dangerous -- check for infinite loop C-c needs to be somewhere else */ return(msg); } static XEN print_hook; bool listener_print_p(const char *msg) { static int print_depth = 0; XEN res = XEN_FALSE; if ((msg) && (print_depth == 0) && (mus_strlen(msg) > 0) && (XEN_HOOKED(print_hook))) { print_depth++; res = run_or_hook(print_hook, XEN_LIST_1(C_TO_XEN_STRING(msg)), S_print_hook); print_depth--; } return(XEN_FALSE_P(res)); } void check_features_list(const char *features) { /* check for list of features, report any missing, exit (for compsnd) */ /* this can't be in snd.c because we haven't fully initialized the extension language and so on at that point */ if (!features) return; #if HAVE_SCHEME XEN_EVAL_C_STRING(mus_format("(for-each \ (lambda (f) \ (if (not (provided? f)) \ (display (format #f \"~%%no ~A!~%%~%%\" f)))) \ (list %s))", features)); #endif #if HAVE_RUBY /* provided? is defined in examp.rb */ XEN_EVAL_C_STRING(mus_format("[%s].each do |f|\n\ unless $LOADED_FEATURES.map do |ff| File.basename(ff) end.member?(f.to_s.tr(\"_\", \"-\"))\n\ $stderr.printf(\"~\\nno %%s!\\n\\n\", f.id2name)\n\ end\n\ end\n", features)); #endif #if HAVE_FORTH XEN_EVAL_C_STRING(mus_format("'( %s ) [each] dup \ provided? [if] \ drop \ [else] \ 1 >list \"\\nno %%s!\\n\\n\" swap format .stderr \ [then] \ [end-each]\n", features)); #endif snd_exit(0); } mus_float_t string_to_mus_float_t(const char *str, mus_float_t lo, const char *field_name) { #if HAVE_EXTENSION_LANGUAGE XEN res; mus_float_t f; res = snd_catch_any(eval_str_wrapper, (void *)str, "string->float"); if (XEN_NUMBER_P(res)) { f = XEN_TO_C_DOUBLE(res); if (f < lo) snd_error("%s: %.3f is invalid", field_name, f); else return(f); } else snd_error("%s is not a number", str); return(0.0); #else mus_float_t res = 0.0; if (str) { if (!(sscanf(str, "%f", &res))) snd_error("%s is not a number", str); else { if (res < lo) snd_error("%s: %.3f is invalid", field_name, res); } } return(res); #endif } int string_to_int(const char *str, int lo, const char *field_name) { #if HAVE_EXTENSION_LANGUAGE XEN res; res = snd_catch_any(eval_str_wrapper, (void *)str, "string->int"); if (XEN_NUMBER_P(res)) { int val; val = XEN_TO_C_INT(res); if (val < lo) snd_error("%s: %d is invalid", field_name, val); else return(val); } else snd_error("%s: %s is not a number", field_name, str); return(0); #else int res = 0; if (str) { if (!(sscanf(str, "%d", &res))) snd_error("%s: %s is not a number", field_name, str); else { if (res < lo) snd_error("%s: %d is invalid", field_name, res); } } return(res); #endif } mus_long_t string_to_mus_long_t(const char *str, mus_long_t lo, const char *field_name) { #if HAVE_EXTENSION_LANGUAGE XEN res; res = snd_catch_any(eval_str_wrapper, (void *)str, "string->mus_long_t"); if (XEN_NUMBER_P(res)) { mus_long_t val; val = XEN_TO_C_INT64_T(res); if (val < lo) snd_error("%s: " MUS_LD " is invalid", field_name, val); else return(val); } else snd_error("%s: %s is not a number", field_name, str); return(0); #else mus_long_t res = 0; if (str) { if (!(sscanf(str, MUS_LD , &res))) snd_error("%s: %s is not a number", field_name, str); else { if (res < lo) snd_error("%s: " MUS_LD " is invalid", field_name, res); } } return(res); #endif } XEN run_progn_hook(XEN hook, XEN args, const char *caller) { #if HAVE_SCHEME int gc_loc; #endif XEN result = XEN_FALSE; XEN procs = XEN_HOOK_PROCEDURES(hook); #if HAVE_SCHEME gc_loc = s7_gc_protect(s7, args); /* this gc protection is needed in s7 because the args are not s7 eval-assembled; * they are cons'd up in our C code, and applied here via s7_call, so between * s7_call's, they are not otherwise protected. In normal function calls, the * args are on the sc->args list in the evaluator, and therefore protected. */ #endif while (XEN_NOT_NULL_P(procs)) { result = XEN_APPLY(XEN_CAR(procs), args, caller); procs = XEN_CDR(procs); } #if HAVE_SCHEME s7_gc_unprotect_at(s7, gc_loc); #endif return(result); } XEN run_hook(XEN hook, XEN args, const char *caller) { #if HAVE_SCHEME int gc_loc; #endif XEN procs = XEN_HOOK_PROCEDURES(hook); #if HAVE_SCHEME gc_loc = s7_gc_protect(s7, args); #endif while (XEN_NOT_NULL_P(procs)) { if (!(XEN_EQ_P(args, XEN_EMPTY_LIST))) XEN_APPLY(XEN_CAR(procs), args, caller); else XEN_CALL_0(XEN_CAR(procs), caller); procs = XEN_CDR (procs); } #if HAVE_SCHEME s7_gc_unprotect_at(s7, gc_loc); #endif return(XEN_FALSE); } XEN run_or_hook(XEN hook, XEN args, const char *caller) { #if HAVE_SCHEME int gc_loc; #endif XEN result = XEN_FALSE; /* (or): #f */ XEN hook_result = XEN_FALSE; XEN procs = XEN_HOOK_PROCEDURES(hook); #if HAVE_SCHEME gc_loc = s7_gc_protect(s7, args); #endif while (XEN_NOT_NULL_P(procs)) { if (!(XEN_EQ_P(args, XEN_EMPTY_LIST))) result = XEN_APPLY(XEN_CAR(procs), args, caller); else result = XEN_CALL_0(XEN_CAR(procs), caller); if (XEN_NOT_FALSE_P(result)) hook_result = result; procs = XEN_CDR (procs); } #if HAVE_SCHEME s7_gc_unprotect_at(s7, gc_loc); #endif return(hook_result); } #if HAVE_SCHEME && HAVE_DLFCN_H #include <dlfcn.h> /* these are included because libtool's dlopen is incredibly stupid */ static XEN g_dlopen(XEN name) { #define H_dlopen "(dlopen lib) loads the dynamic library 'lib' and returns a handle for it (for dlinit and dlclose)" void *handle; const char *cname; XEN_ASSERT_TYPE(XEN_STRING_P(name), name, XEN_ONLY_ARG, "dlopen", "a string (filename)"); cname = XEN_TO_C_STRING(name); if (cname) { handle = dlopen(cname, RTLD_LAZY); if (handle == NULL) { char *longname; longname = mus_expand_filename(cname); handle = dlopen(longname, RTLD_LAZY); free(longname); if (handle == NULL) { char *err; err = (char *)dlerror(); if ((err) && (*err)) return(C_TO_XEN_STRING(err)); return(XEN_FALSE); } } return(XEN_WRAP_C_POINTER(handle)); } return(XEN_FALSE); } static XEN g_dlclose(XEN handle) { #define H_dlclose "(dlclose handle) may close the library referred to by 'handle'." XEN_ASSERT_TYPE(XEN_WRAPPED_C_POINTER_P(handle), handle, XEN_ONLY_ARG, "dlclose", "a library handle"); return(C_TO_XEN_INT(dlclose((void *)(XEN_UNWRAP_C_POINTER(handle))))); } static XEN g_dlerror(void) { #define H_dlerror "(dlerror) returns a string describing the last dlopen/dlinit/dlclose error" return(C_TO_XEN_STRING(dlerror())); } static XEN g_dlinit(XEN handle, XEN func) { #define H_dlinit "(dlinit handle func) calls 'func' from the library referred to by 'handle'." typedef void *(*snd_dl_func)(void); void *proc; XEN_ASSERT_TYPE(XEN_WRAPPED_C_POINTER_P(handle), handle, XEN_ARG_1, "dlinit", "a library handle"); XEN_ASSERT_TYPE(XEN_STRING_P(func), func, XEN_ARG_2, "dlinit", "a string (init func name)"); proc = dlsym((void *)(XEN_UNWRAP_C_POINTER(handle)), XEN_TO_C_STRING(func)); if (proc == NULL) return(C_TO_XEN_STRING(dlerror())); ((snd_dl_func)proc)(); return(XEN_TRUE); } #if 0 static XEN g_dlinit(XEN handle, XEN func) { /* 'man dlopen' suggests: double (*cosine)(double); *(void **) (&cosine) = dlsym(handle, "cos"); printf("%f\n", (*cosine)(2.0)); */ void (*proc)(void); /* typedef void *(*snd_dl_func)(void); */ /* void *proc; */ (*(void **)(&proc)) = dlsym((void *)(XEN_UNWRAP_C_POINTER(handle)), XEN_TO_C_STRING(func)); /* but this line triggers warnings from gcc */ if (proc == NULL) return(C_TO_XEN_STRING(dlerror())); /* ((snd_dl_func)proc)(); */ (*proc)(); return(XEN_TRUE); } #endif #endif static XEN g_little_endian(void) { #if MUS_LITTLE_ENDIAN return(XEN_TRUE); #else return(XEN_FALSE); #endif } static XEN g_snd_global_state(void) { return(XEN_WRAP_C_POINTER(ss)); } #if MUS_DEBUGGING static XEN g_snd_sound_pointer(XEN snd) { /* (XtCallCallbacks (cadr (sound-widgets 0)) XmNactivateCallback (snd-sound-pointer 0)) */ int s; s = XEN_TO_C_INT(snd); if ((s < ss->max_sounds) && (s >= 0) && (ss->sounds[s])) return(XEN_WRAP_C_POINTER(ss->sounds[s])); return(XEN_FALSE); } #endif #if (!HAVE_SCHEME) /* fmod is the same as modulo in s7: (do ((i 0 (+ i 1))) ((= i 100)) (let ((val1 (- (random 1.0) 2.0)) (val2 (- (random 1.0) 2.0))) (let ((f (fmod val1 val2)) (m (modulo val1 val2))) (if (> (abs (- f m)) 1e-9) (format *stderr* "~A ~A -> ~A ~A~%" val1 val2 f m))))) */ static XEN g_fmod(XEN a, XEN b) { double val, x, y; XEN_ASSERT_TYPE(XEN_NUMBER_P(a), a, XEN_ARG_1, "fmod", " a number"); XEN_ASSERT_TYPE(XEN_NUMBER_P(b), b, XEN_ARG_2, "fmod", " a number"); x = XEN_TO_C_DOUBLE(a); y = XEN_TO_C_DOUBLE(b); val = fmod(x, y); if (((y > 0.0) && (val < 0.0)) || ((y < 0.0) && (val > 0.0))) return(C_TO_XEN_DOUBLE(val + y)); return(C_TO_XEN_DOUBLE(val)); } #endif #if HAVE_SPECIAL_FUNCTIONS || HAVE_GSL #define S_bes_j0 "bes-j0" #define S_bes_j1 "bes-j1" #define S_bes_jn "bes-jn" #define S_bes_y0 "bes-y0" #define S_bes_y1 "bes-y1" #define S_bes_yn "bes-yn" #endif /* ---------------------------------------- use libm ---------------------------------------- */ #if HAVE_SCHEME && WITH_GMP && HAVE_SPECIAL_FUNCTIONS #include <gmp.h> #include <mpfr.h> #include <mpc.h> static XEN big_math_1(XEN x, int (*mpfr_math)(mpfr_ptr, mpfr_srcptr, mpfr_rnd_t)) { s7_pointer val; mpfr_t y; mpfr_init_set(y, *s7_big_real(x), GMP_RNDN); mpfr_math(y, y, GMP_RNDN); val = s7_make_big_real(s7, &y); mpfr_clear(y); return(val); } static XEN big_j0(XEN x) {return(big_math_1(x, mpfr_j0));} static XEN big_j1(XEN x) {return(big_math_1(x, mpfr_j1));} static XEN big_y0(XEN x) {return(big_math_1(x, mpfr_y0));} static XEN big_y1(XEN x) {return(big_math_1(x, mpfr_y1));} static XEN big_erf(XEN x) {return(big_math_1(x, mpfr_erf));} static XEN big_erfc(XEN x) {return(big_math_1(x, mpfr_erfc));} static XEN big_math_2(XEN n, XEN x, int (*mpfr_math)(mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t)) { s7_pointer val; mpfr_t y; mpfr_init_set(y, *s7_big_real(x), GMP_RNDN); mpfr_math(y, XEN_TO_C_INT(n), y, GMP_RNDN); val = s7_make_big_real(s7, &y); mpfr_clear(y); return(val); } static XEN big_jn(XEN n, XEN x) {return(big_math_2(n, x, mpfr_jn));} static XEN big_yn(XEN n, XEN x) {return(big_math_2(n, x, mpfr_yn));} /* bes-i0 from G&R 8.447, 8.451, A&S 9.6.12, 9.7.1, arprec bessel.cpp */ static XEN big_i0(XEN ux) { int k; mpfr_t sum, x, x1, x2, eps; mpfr_init_set_ui(sum, 0, GMP_RNDN); mpfr_init_set(x, *s7_big_real(ux), GMP_RNDN); mpfr_init_set_ui(sum, 1, GMP_RNDN); mpfr_init_set_ui(x1, 1, GMP_RNDN); mpfr_init_set_ui(eps, 2, GMP_RNDN); mpfr_pow_si(eps, eps, -mpfr_get_default_prec(), GMP_RNDN); mpfr_init_set_ui(x2, mpfr_get_default_prec(), GMP_RNDN); mpfr_div_ui(x2, x2, 2, GMP_RNDN); if (mpfr_cmpabs(x, x2) < 0) { mpfr_mul(x, x, x, GMP_RNDN); /* x = ux^2 */ for (k = 1; k < 10000; k++) { mpfr_set_ui(x2, k, GMP_RNDN); /* x2 = k */ mpfr_mul(x2, x2, x2, GMP_RNDN); /* x2 = k^2 */ mpfr_div(x1, x1, x2, GMP_RNDN); /* x1 = x1/x2 */ mpfr_mul(x1, x1, x, GMP_RNDN); /* x1 = x1*x */ mpfr_div_ui(x1, x1, 4, GMP_RNDN); /* x1 = x1/4 */ if (mpfr_cmp(x1, eps) < 0) break; mpfr_add(sum, sum, x1, GMP_RNDN); /* sum += x1 */ } /* takes usually ca 10 to 40 iterations */ } else { mpfr_t den, num; mpfr_init(den); mpfr_init(num); mpfr_abs(x, x, GMP_RNDN); for (k = 1; k < 10000; k++) { mpfr_set(x2, x1, GMP_RNDN); mpfr_set_ui(den, k, GMP_RNDN); mpfr_mul_ui(den, den, 8, GMP_RNDN); mpfr_mul(den, den, x, GMP_RNDN); mpfr_set_ui(num, k, GMP_RNDN); mpfr_mul_ui(num, num, 2, GMP_RNDN); mpfr_sub_ui(num, num, 1, GMP_RNDN); mpfr_mul(num, num, num, GMP_RNDN); mpfr_div(num, num, den, GMP_RNDN); mpfr_mul(x1, x1, num, GMP_RNDN); mpfr_add(sum, sum, x1, GMP_RNDN); if (mpfr_cmp(x1, eps) < 0) { mpfr_const_pi(x2, GMP_RNDN); mpfr_mul_ui(x2, x2, 2, GMP_RNDN); mpfr_mul(x2, x2, x, GMP_RNDN); mpfr_sqrt(x2, x2, GMP_RNDN); /* sqrt(2*pi*x) */ mpfr_div(sum, sum, x2, GMP_RNDN); mpfr_exp(x1, x, GMP_RNDN); mpfr_mul(sum, sum, x1, GMP_RNDN); /* sum * e^x / sqrt(2*pi*x) */ break; } if (mpfr_cmp(x1, x2) > 0) { fprintf(stderr, "bes-i0 has screwed up"); break; } } mpfr_clear(den); mpfr_clear(num); } mpfr_clear(x1); mpfr_clear(x2); mpfr_clear(x); mpfr_clear(eps); return(s7_make_big_real(s7, &sum)); } /* fft * (define hi (make-vector 8)) * (define ho (make-vector 8)) * (do ((i 0 (+ i 1))) ((= i 8)) (vector-set! hi i (bignum "0.0")) (vector-set! ho i (bignum "0.0"))) * (vector-set! ho 1 (bignum "-1.0")) * (vector-set! ho 1 (bignum "-1.0")) * (bignum-fft hi ho 8) * * this is tricky -- perhaps a bad idea. vector elements are changed in place which means * they better be unique! and there are no checks that each element actually is a bignum * which means we'll segfault if a normal real leaks through. * * bignum_fft is say 200 times slower than the same size fftw call, and takes more space than * I can account for: 2^20 29 secs ~.5 Gb, 2^24 11 mins ~5Gb. I think there should be * the vector element (8), the mpfr_t space (16 or 32), the s7_cell (28 or 32), and the value pointer (8), * and the heap pointer loc (8) so 2^24 should be (* 2 (expt 2 24) (+ 8 8 8 8 32 32)) = 3 Gb, not 5. 2^25 25 min 10.6? * I think the extra is in the free space in the heap -- it can be adding 1/4 of the total. */ static s7_pointer bignum_fft(s7_scheme *sc, s7_pointer args) { #define H_bignum_fft "(bignum-fft rl im n (sign 1)) performs a multiprecision fft on the vectors of bigfloats rl and im" int n, sign = 1; s7_pointer *rl, *im; int m, j, mh, ldm, lg, i, i2, j2, imh; mpfr_t ur, ui, u, vr, vi, angle, c, s, temp; #define big_rl(n) (*(s7_big_real(rl[n]))) #define big_im(n) (*(s7_big_real(im[n]))) n = s7_integer(s7_list_ref(sc, args, 2)); if (s7_list_length(sc, args) > 3) sign = s7_integer(s7_list_ref(sc, args, 3)); rl = s7_vector_elements(s7_list_ref(sc, args, 0)); im = s7_vector_elements(s7_list_ref(sc, args, 1)); /* scramble(rl, im, n); */ { int i, m, j; s7_pointer vr, vi; j = 0; for (i = 0; i < n; i++) { if (j > i) { vr = rl[j]; vi = im[j]; rl[j] = rl[i]; im[j] = im[i]; rl[i] = vr; im[i] = vi; } m = n >> 1; while ((m >= 2) && (j >= m)) { j -= m; m = m >> 1; } j += m; } } imh = (int)(log(n + 1) / log(2.0)); m = 2; ldm = 1; mh = n >> 1; mpfr_init(angle); /* angle = (M_PI * sign) */ mpfr_const_pi(angle, GMP_RNDN); if (sign == -1) mpfr_neg(angle, angle, GMP_RNDN); mpfr_init(c); mpfr_init(s); mpfr_init(ur); mpfr_init(ui); mpfr_init(u); mpfr_init(vr); mpfr_init(vi); mpfr_init(temp); for (lg = 0; lg < imh; lg++) { mpfr_cos(c, angle, GMP_RNDN); /* c = cos(angle) */ mpfr_sin(s, angle, GMP_RNDN); /* s = sin(angle) */ mpfr_set_ui(ur, 1, GMP_RNDN); /* ur = 1.0 */ mpfr_set_ui(ui, 0, GMP_RNDN); /* ui = 0.0 */ for (i2 = 0; i2 < ldm; i2++) { i = i2; j = i2 + ldm; for (j2 = 0; j2 < mh; j2++) { mpfr_set(temp, big_im(j), GMP_RNDN); /* vr = ur * rl[j] - ui * im[j] */ mpfr_mul(temp, temp, ui, GMP_RNDN); mpfr_set(vr, big_rl(j), GMP_RNDN); mpfr_mul(vr, vr, ur, GMP_RNDN); mpfr_sub(vr, vr, temp, GMP_RNDN); mpfr_set(temp, big_rl(j), GMP_RNDN); /* vi = ur * im[j] + ui * rl[j] */ mpfr_mul(temp, temp, ui, GMP_RNDN); mpfr_set(vi, big_im(j), GMP_RNDN); mpfr_mul(vi, vi, ur, GMP_RNDN); mpfr_add(vi, vi, temp, GMP_RNDN); mpfr_set(big_rl(j), big_rl(i), GMP_RNDN); /* rl[j] = rl[i] - vr */ mpfr_sub(big_rl(j), big_rl(j), vr, GMP_RNDN); mpfr_set(big_im(j), big_im(i), GMP_RNDN); /* im[j] = im[i] - vi */ mpfr_sub(big_im(j), big_im(j), vi, GMP_RNDN); mpfr_add(big_rl(i), big_rl(i), vr, GMP_RNDN); /* rl[i] += vr */ mpfr_add(big_im(i), big_im(i), vi, GMP_RNDN); /* im[i] += vi */ i += m; j += m; } mpfr_set(u, ur, GMP_RNDN); /* u = ur */ mpfr_set(temp, ui, GMP_RNDN); /* ur = (ur * c) - (ui * s) */ mpfr_mul(temp, temp, s, GMP_RNDN); mpfr_mul(ur, ur, c, GMP_RNDN); mpfr_sub(ur, ur, temp, GMP_RNDN); mpfr_set(temp, u, GMP_RNDN); /* ui = (ui * c) + (u * s) */ mpfr_mul(temp, temp, s, GMP_RNDN); mpfr_mul(ui, ui, c, GMP_RNDN); mpfr_add(ui, ui, temp, GMP_RNDN); } mh >>= 1; ldm = m; mpfr_div_ui(angle, angle, 2, GMP_RNDN); /* angle *= 0.5 */ m <<= 1; } return(s7_f(sc)); } #endif #if HAVE_SPECIAL_FUNCTIONS && (!HAVE_GSL) static XEN g_j0(XEN x) { #define H_j0 "(" S_bes_j0 " x): returns the regular cylindrical bessel function value J0(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_j0, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_j0(x)); #endif return(C_TO_XEN_DOUBLE(j0(XEN_TO_C_DOUBLE(x)))); } static XEN g_j1(XEN x) { #define H_j1 "(" S_bes_j1 " x): returns the regular cylindrical bessel function value J1(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_j1, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_j1(x)); #endif return(C_TO_XEN_DOUBLE(j1(XEN_TO_C_DOUBLE(x)))); } static XEN g_jn(XEN order, XEN x) { #define H_jn "(" S_bes_jn " n x): returns the regular cylindrical bessel function value Jn(x)" XEN_ASSERT_TYPE(XEN_INTEGER_P(order), x, XEN_ARG_1, S_bes_jn, " an int"); XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ARG_2, S_bes_jn, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_jn(order, x)); #endif return(C_TO_XEN_DOUBLE(jn(XEN_TO_C_INT(order), XEN_TO_C_DOUBLE(x)))); } static XEN g_y0(XEN x) { #define H_y0 "(" S_bes_y0 " x): returns the irregular cylindrical bessel function value Y0(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_y0, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_y0(x)); #endif return(C_TO_XEN_DOUBLE(y0(XEN_TO_C_DOUBLE(x)))); } static XEN g_y1(XEN x) { #define H_y1 "(" S_bes_y1 " x): returns the irregular cylindrical bessel function value Y1(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_y1, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_y1(x)); #endif return(C_TO_XEN_DOUBLE(y1(XEN_TO_C_DOUBLE(x)))); } static XEN g_yn(XEN order, XEN x) { #define H_yn "(" S_bes_yn " n x): returns the irregular cylindrical bessel function value Yn(x)" XEN_ASSERT_TYPE(XEN_INTEGER_P(order), x, XEN_ARG_1, S_bes_yn, " an int"); XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ARG_2, S_bes_yn, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_yn(order, x)); #endif return(C_TO_XEN_DOUBLE(yn(XEN_TO_C_INT(order), XEN_TO_C_DOUBLE(x)))); } static XEN g_erf(XEN x) { #define H_erf "(erf x): returns the error function erf(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, "erf", " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_erf(x)); #endif return(C_TO_XEN_DOUBLE(erf(XEN_TO_C_DOUBLE(x)))); } static XEN g_erfc(XEN x) { #define H_erfc "(erfc x): returns the complementary error function erfc(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, "erfc", " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_erfc(x)); #endif return(C_TO_XEN_DOUBLE(erfc(XEN_TO_C_DOUBLE(x)))); } static XEN g_lgamma(XEN x) { #define H_lgamma "(lgamma x): returns the log of the gamma function at x" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, "lgamma", " a number"); return(C_TO_XEN_DOUBLE(lgamma(XEN_TO_C_DOUBLE(x)))); } #endif #define S_bes_i0 "bes-i0" static XEN g_i0(XEN x) { #define H_i0 "(" S_bes_i0 " x): returns the modified cylindrical bessel function value I0(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_i0, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_i0(x)); #endif return(C_TO_XEN_DOUBLE(mus_bessi0(XEN_TO_C_DOUBLE(x)))); /* uses GSL if possible */ } /* ---------------------------------------- use GSL ---------------------------------------- */ #if HAVE_GSL /* include all the bessel functions, etc */ #include <gsl/gsl_sf_bessel.h> static XEN g_j0(XEN x) { #define H_j0 "(" S_bes_j0 " x): returns the regular cylindrical bessel function value J0(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_j0, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_j0(x)); #endif return(C_TO_XEN_DOUBLE(gsl_sf_bessel_J0(XEN_TO_C_DOUBLE(x)))); } static XEN g_j1(XEN x) { #define H_j1 "(" S_bes_j1 " x): returns the regular cylindrical bessel function value J1(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_j1, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_j1(x)); #endif return(C_TO_XEN_DOUBLE(gsl_sf_bessel_J1(XEN_TO_C_DOUBLE(x)))); } static XEN g_jn(XEN order, XEN x) { #define H_jn "(" S_bes_jn " n x): returns the regular cylindrical bessel function value Jn(x)" XEN_ASSERT_TYPE(XEN_INTEGER_P(order), x, XEN_ARG_1, S_bes_jn, " an int"); XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ARG_2, S_bes_jn, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_jn(order, x)); #endif return(C_TO_XEN_DOUBLE(gsl_sf_bessel_Jn(XEN_TO_C_INT(order), XEN_TO_C_DOUBLE(x)))); } static XEN g_y0(XEN x) { #define H_y0 "(" S_bes_y0 " x): returns the irregular cylindrical bessel function value Y0(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_y0, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_y0(x)); #endif return(C_TO_XEN_DOUBLE(gsl_sf_bessel_Y0(XEN_TO_C_DOUBLE(x)))); } static XEN g_y1(XEN x) { #define H_y1 "(" S_bes_y1 " x): returns the irregular cylindrical bessel function value Y1(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_y1, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_y1(x)); #endif return(C_TO_XEN_DOUBLE(gsl_sf_bessel_Y1(XEN_TO_C_DOUBLE(x)))); } static XEN g_yn(XEN order, XEN x) { #define H_yn "(" S_bes_yn " n x): returns the irregular cylindrical bessel function value Yn(x)" XEN_ASSERT_TYPE(XEN_INTEGER_P(order), x, XEN_ARG_1, S_bes_yn, " an int"); XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ARG_2, S_bes_yn, " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_yn(order, x)); #endif return(C_TO_XEN_DOUBLE(gsl_sf_bessel_Yn(XEN_TO_C_INT(order), XEN_TO_C_DOUBLE(x)))); } #define S_bes_i1 "bes-i1" #define S_bes_in "bes-in" #define S_bes_k0 "bes-k0" #define S_bes_k1 "bes-k1" #define S_bes_kn "bes-kn" static XEN g_i1(XEN x) { #define H_i1 "(" S_bes_i1 " x): returns the regular cylindrical bessel function value I1(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_i1, " a number"); return(C_TO_XEN_DOUBLE(gsl_sf_bessel_I1(XEN_TO_C_DOUBLE(x)))); } static XEN g_in(XEN order, XEN x) { #define H_in "(" S_bes_in " n x): returns the regular cylindrical bessel function value In(x)" XEN_ASSERT_TYPE(XEN_INTEGER_P(order), x, XEN_ARG_1, S_bes_in, " an int"); XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ARG_2, S_bes_in, " a number"); return(C_TO_XEN_DOUBLE(gsl_sf_bessel_In(XEN_TO_C_INT(order), XEN_TO_C_DOUBLE(x)))); } static XEN g_k0(XEN x) { #define H_k0 "(" S_bes_k0 " x): returns the irregular cylindrical bessel function value K0(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_k0, " a number"); return(C_TO_XEN_DOUBLE(gsl_sf_bessel_K0(XEN_TO_C_DOUBLE(x)))); } static XEN g_k1(XEN x) { #define H_k1 "(" S_bes_k1 " x): returns the irregular cylindrical bessel function value K1(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, S_bes_k1, " a number"); return(C_TO_XEN_DOUBLE(gsl_sf_bessel_K1(XEN_TO_C_DOUBLE(x)))); } static XEN g_kn(XEN order, XEN x) { #define H_kn "(" S_bes_kn " n x): returns the irregular cylindrical bessel function value Kn(x)" XEN_ASSERT_TYPE(XEN_INTEGER_P(order), x, XEN_ARG_1, S_bes_kn, " an int"); XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ARG_2, S_bes_kn, " a number"); return(C_TO_XEN_DOUBLE(gsl_sf_bessel_Kn(XEN_TO_C_INT(order), XEN_TO_C_DOUBLE(x)))); } #include <gsl/gsl_sf_erf.h> static XEN g_erf(XEN x) { #define H_erf "(erf x): returns the error function erf(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, "erf", " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_erf(x)); #endif return(C_TO_XEN_DOUBLE(gsl_sf_erf(XEN_TO_C_DOUBLE(x)))); } static XEN g_erfc(XEN x) { #define H_erfc "(erfc x): returns the complementary error function value erfc(x)" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, "erfc", " a number"); #if HAVE_SCHEME && WITH_GMP if ((s7_is_bignum(x)) && (s7_is_real(x)) && (!(s7_is_rational(x)))) return(big_erfc(x)); #endif return(C_TO_XEN_DOUBLE(gsl_sf_erfc(XEN_TO_C_DOUBLE(x)))); } #include <gsl/gsl_sf_gamma.h> static XEN g_lgamma(XEN x) { #define H_lgamma "(lgamma x): returns the log of the gamma function at x" XEN_ASSERT_TYPE(XEN_NUMBER_P(x), x, XEN_ONLY_ARG, "lgamma", " a number"); return(C_TO_XEN_DOUBLE(gsl_sf_lngamma(XEN_TO_C_DOUBLE(x)))); } #include <gsl/gsl_sf_ellint.h> static XEN g_gsl_ellipk(XEN k) { double f; #define H_gsl_ellipk "(gsl-ellipk k): returns the complete elliptic integral k" XEN_ASSERT_TYPE(XEN_NUMBER_P(k), k, XEN_ONLY_ARG, "gsl-ellipk", "a number"); f = XEN_TO_C_DOUBLE(k); XEN_ASSERT_TYPE(f >= 0.0, k, XEN_ONLY_ARG, "gsl-ellipk", "a non-negative number"); return(C_TO_XEN_DOUBLE(gsl_sf_ellint_Kcomp(sqrt(XEN_TO_C_DOUBLE(k)), GSL_PREC_APPROX))); } #include <gsl/gsl_sf_elljac.h> static XEN g_gsl_ellipj(XEN u, XEN m) { #define H_gsl_ellipj "(gsl-ellipj u m): returns the Jacobian elliptic functions sn, cn, and dn of u and m" double sn = 0.0, cn = 0.0, dn = 0.0; XEN_ASSERT_TYPE(XEN_NUMBER_P(u), u, XEN_ARG_1, "gsl-ellipj", "a number"); XEN_ASSERT_TYPE(XEN_NUMBER_P(m), m, XEN_ARG_2, "gsl-ellipj", "a number"); gsl_sf_elljac_e(XEN_TO_C_DOUBLE(u), XEN_TO_C_DOUBLE(m), &sn, &cn, &dn); return(XEN_LIST_3(C_TO_XEN_DOUBLE(sn), C_TO_XEN_DOUBLE(cn), C_TO_XEN_DOUBLE(dn))); } #if MUS_DEBUGGING && HAVE_SCHEME /* use gsl gegenbauer to check our function */ #include <gsl/gsl_sf_gegenbauer.h> static XEN g_gsl_gegenbauer(XEN n, XEN lambda, XEN x) { gsl_sf_result val; gsl_sf_gegenpoly_n_e(XEN_TO_C_INT(n), XEN_TO_C_DOUBLE(lambda), XEN_TO_C_DOUBLE(x), &val); return(C_TO_XEN_DOUBLE(val.val)); } #ifdef XEN_ARGIFY_1 XEN_NARGIFY_3(g_gsl_gegenbauer_w, g_gsl_gegenbauer) #else #define g_gsl_gegenbauer_w g_gsl_gegenbauer #endif #endif #include <gsl/gsl_dht.h> static XEN g_gsl_dht(XEN size, XEN data, XEN nu, XEN xmax) { #define H_gsl_dht "(gsl-dht size data nu xmax): Hankel transform of data (a vct)" int n; XEN_ASSERT_TYPE(XEN_INTEGER_P(size), size, XEN_ARG_1, "gsl-dht", "an integer"); XEN_ASSERT_TYPE(MUS_VCT_P(data), data, XEN_ARG_2, "gsl-dht", "a vct"); XEN_ASSERT_TYPE(XEN_NUMBER_P(nu), nu, XEN_ARG_3, "gsl-dht", "a number"); XEN_ASSERT_TYPE(XEN_NUMBER_P(xmax), xmax, XEN_ARG_4, "gsl-dht", "a number"); n = XEN_TO_C_INT(size); if (n <= 0) XEN_OUT_OF_RANGE_ERROR("gsl-dht", XEN_ARG_1, size, "must be > 0"); else { double *indata, *outdata; int i; vct *v; gsl_dht *t = gsl_dht_new(n, XEN_TO_C_DOUBLE(nu), XEN_TO_C_DOUBLE(xmax)); indata = (double *)calloc(n, sizeof(double)); outdata = (double *)calloc(n, sizeof(double)); v = XEN_TO_VCT(data); for (i = 0; i < n; i++) indata[i] = v->data[i]; gsl_dht_apply(t, indata, outdata); for (i = 0; i < n; i++) v->data[i] = outdata[i]; gsl_dht_free(t); free(indata); free(outdata); } return(data); } #if HAVE_GSL_EIGEN_NONSYMMV_WORKSPACE /* eignevector/values, from gsl/doc/examples/eigen_nonsymm.c */ #include <gsl/gsl_math.h> #include <gsl/gsl_eigen.h> static XEN g_gsl_eigenvectors(XEN matrix) { double *data; mus_any *u1; mus_float_t *vals; int i, j, len; XEN values = XEN_FALSE, vectors = XEN_FALSE; XEN_ASSERT_TYPE(mus_xen_p(matrix), matrix, XEN_ONLY_ARG, "gsl-eigenvectors", "a mixer (matrix)"); u1 = XEN_TO_MUS_ANY(matrix); if (!mus_mixer_p(u1)) return(XEN_FALSE); vals = mus_data(u1); len = mus_length(u1); data = (double *)calloc(len * len, sizeof(double)); for (i = 0; i < len; i++) for (j = 0; j < len; j++) data[i * len + j] = mus_mixer_ref(u1, i, j); { gsl_matrix_view m = gsl_matrix_view_array(data, len, len); gsl_vector_complex *eval = gsl_vector_complex_alloc(len); gsl_matrix_complex *evec = gsl_matrix_complex_alloc(len, len); gsl_eigen_nonsymmv_workspace *w = gsl_eigen_nonsymmv_alloc(len); gsl_eigen_nonsymmv(&m.matrix, eval, evec, w); gsl_eigen_nonsymmv_free(w); gsl_eigen_nonsymmv_sort(eval, evec, GSL_EIGEN_SORT_ABS_DESC); { int values_loc, vectors_loc; values = XEN_MAKE_VECTOR(len, XEN_ZERO); values_loc = snd_protect(values); vectors = XEN_MAKE_VECTOR(len, XEN_FALSE); vectors_loc = snd_protect(vectors); for (i = 0; i < len; i++) { XEN vect; gsl_complex eval_i = gsl_vector_complex_get(eval, i); gsl_vector_complex_view evec_i = gsl_matrix_complex_column(evec, i); XEN_VECTOR_SET(values, i, C_TO_XEN_DOUBLE(GSL_REAL(eval_i))); vect = XEN_MAKE_VECTOR(len, XEN_ZERO); XEN_VECTOR_SET(vectors, i, vect); for (j = 0; j < len; j++) { gsl_complex z = gsl_vector_complex_get(&evec_i.vector, j); XEN_VECTOR_SET(vect, j, C_TO_XEN_DOUBLE(GSL_REAL(z))); } } snd_unprotect_at(values_loc); snd_unprotect_at(vectors_loc); } gsl_vector_complex_free(eval); gsl_matrix_complex_free(evec); } free(data); return(XEN_LIST_2(values, vectors)); } #endif #if HAVE_COMPLEX_TRIG && XEN_HAVE_COMPLEX_NUMBERS #include <gsl/gsl_poly.h> #include <complex.h> static XEN g_gsl_roots(XEN poly) { #define H_gsl_roots "(gsl-roots poly): roots of poly" int i, n, loc; double *p; double complex *z; gsl_poly_complex_workspace *w; XEN result; XEN_ASSERT_TYPE(XEN_VECTOR_P(poly), poly, XEN_ONLY_ARG, "gsl-roots", "a vector"); n = XEN_VECTOR_LENGTH(poly); w = gsl_poly_complex_workspace_alloc(n); z = (double complex *)calloc(n, sizeof(double complex)); p = (double *)calloc(n, sizeof(double)); for (i = 0; i < n; i++) p[i] = XEN_TO_C_DOUBLE(XEN_VECTOR_REF(poly, i)); gsl_poly_complex_solve(p, n, w, (gsl_complex_packed_ptr)z); gsl_poly_complex_workspace_free (w); result = XEN_MAKE_VECTOR(n - 1, XEN_ZERO); loc = snd_protect(result); for (i = 0; i < n - 1; i++) if (__imag__(z[i]) != 0.0) XEN_VECTOR_SET(result, i, C_TO_XEN_COMPLEX(z[i])); else XEN_VECTOR_SET(result, i, C_TO_XEN_DOUBLE(__real__(z[i]))); free(z); free(p); snd_unprotect_at(loc); return(result); } #endif #endif /* -------- source file extensions list -------- */ static char **source_file_extensions = NULL; static int source_file_extensions_size = 0; static int source_file_extensions_end = 0; static int default_source_file_extensions = 0; static void add_source_file_extension(const char *ext) { int i; for (i = 0; i < source_file_extensions_end; i++) if (mus_strcmp(ext, source_file_extensions[i])) return; if (source_file_extensions_end == source_file_extensions_size) { source_file_extensions_size += 8; if (source_file_extensions == NULL) source_file_extensions = (char **)calloc(source_file_extensions_size, sizeof(char *)); else source_file_extensions = (char **)realloc(source_file_extensions, source_file_extensions_size * sizeof(char *)); } source_file_extensions[source_file_extensions_end] = mus_strdup(ext); source_file_extensions_end++; } bool source_file_p(const char *name) { int i, dot_loc = -1, len; if (!name) return(false); if (source_file_extensions) { len = strlen(name); for (i = 0; i < len; i++) if (name[i] == '.') dot_loc = i; /* dot_loc is last dot in the name */ if ((dot_loc > 0) && (dot_loc < len - 1)) { const char *ext; ext = (const char *)(name + dot_loc + 1); for (i = 0; i < source_file_extensions_end; i++) if (mus_strcmp(ext, source_file_extensions[i])) return(true); } } return(false); } void save_added_source_file_extensions(FILE *fd) { int i; if (source_file_extensions_end > default_source_file_extensions) for (i = default_source_file_extensions; i < source_file_extensions_end; i++) { #if HAVE_SCHEME fprintf(fd, "(%s \"%s\")\n", S_add_source_file_extension, source_file_extensions[i]); #endif #if HAVE_RUBY fprintf(fd, "%s(\"%s\")\n", TO_PROC_NAME(S_add_source_file_extension), source_file_extensions[i]); #endif #if HAVE_FORTH fprintf(fd, "\"%s\" %s drop\n", source_file_extensions[i], S_add_source_file_extension); #endif } } static XEN g_add_source_file_extension(XEN ext) { #define H_add_source_file_extension "(" S_add_source_file_extension " ext): add the file extension 'ext' to the list of source file extensions" XEN_ASSERT_TYPE(XEN_STRING_P(ext), ext, XEN_ONLY_ARG, S_add_source_file_extension, "a string"); add_source_file_extension(XEN_TO_C_STRING(ext)); return(ext); } static char *find_source_file(const char *orig) { int i; char *str; for (i = 0; i < source_file_extensions_end; i++) { str = mus_format("%s.%s", orig, source_file_extensions[i]); if (mus_file_probe(str)) return(str); free(str); } return(NULL); } #if HAVE_SCHEME static s7_pointer g_char_position(s7_scheme *sc, s7_pointer args) { #define H_char_position "(char-position char str (start 0)) returns the position of the first occurrence of char in str, or #f" const char *porig, *p; char c; int start = 0; if (!s7_is_character(s7_car(args))) return(s7_wrong_type_arg_error(sc, "char-position", 1, s7_car(args), "a character")); if (!s7_is_string(s7_car(s7_cdr(args)))) return(s7_wrong_type_arg_error(sc, "char-position", 2, s7_car(s7_cdr(args)), "a string")); if (s7_is_pair(s7_cdr(s7_cdr(args)))) { s7_pointer arg; arg = s7_car(s7_cdr(s7_cdr(args))); if (!s7_is_integer(arg)) return(s7_wrong_type_arg_error(sc, "char-position", 3, arg, "an integer")); start = s7_integer(arg); if (start < 0) return(s7_wrong_type_arg_error(sc, "char-position", 3, arg, "a non-negative integer")); } c = s7_character(s7_car(args)); porig = s7_string(s7_car(s7_cdr(args))); if ((!porig) || (start >= mus_strlen(porig))) return(s7_f(sc)); for (p = (const char *)(porig + start); (*p); p++) if ((*p) == c) return(s7_make_integer(sc, p - porig)); return(s7_f(sc)); } static s7_pointer g_string_position_1(s7_scheme *sc, s7_pointer args, bool ci, const char *name) { const char *s1, *s2, *p1, *p2; int start = 0; if (!s7_is_string(s7_car(args))) return(s7_wrong_type_arg_error(sc, name, 1, s7_car(args), "a string")); if (!s7_is_string(s7_car(s7_cdr(args)))) return(s7_wrong_type_arg_error(sc, name, 2, s7_car(s7_cdr(args)), "a string")); if (s7_is_pair(s7_cdr(s7_cdr(args)))) { s7_pointer arg; arg = s7_car(s7_cdr(s7_cdr(args))); if (!s7_is_integer(arg)) return(s7_wrong_type_arg_error(sc, name, 3, arg, "an integer")); start = s7_integer(arg); if (start < 0) return(s7_wrong_type_arg_error(sc, name, 3, arg, "a non-negative integer")); } s1 = s7_string(s7_car(args)); s2 = s7_string(s7_car(s7_cdr(args))); if (start >= mus_strlen(s2)) return(s7_f(sc)); if (!ci) { for (p2 = (const char *)(s2 + start); (*p2); p2++) { const char *ptemp; for (p1 = s1, ptemp = p2; (*p1) && (*ptemp) && ((*p1) == (*ptemp)); p1++, ptemp++); if (!(*p1)) return(s7_make_integer(sc, p2 - s2)); } } else { for (p2 = (const char *)(s2 + start); (*p2); p2++) { const char *ptemp; for (p1 = s1, ptemp = p2; (*p1) && (*ptemp) && (toupper((int)(*p1)) == toupper((int)(*ptemp))); p1++, ptemp++); if (!(*p1)) return(s7_make_integer(sc, p2 - s2)); } } return(s7_f(sc)); } static s7_pointer g_string_position(s7_scheme *sc, s7_pointer args) { #define H_string_position "(string-position str1 str2 (start 0)) returns the starting position of str1 in str2 or #f" return(g_string_position_1(sc, args, false, "string-position")); } static s7_pointer g_string_ci_position(s7_scheme *sc, s7_pointer args) { #define H_string_ci_position "(string-ci-position str1 str2 (start 0)) returns the starting position of str1 in str2 ignoring case, or #f" return(g_string_position_1(sc, args, true, "string-ci-position")); } static s7_pointer g_string_vector_position(s7_scheme *sc, s7_pointer args) { #define H_string_vector_position "(string-vector-position str vect (start 0)) returns the position of the first occurrence of str in vect starting from start, or #f" const char *s1; s7_pointer *strs; int i, len, start = 0; if (!s7_is_string(s7_car(args))) return(s7_wrong_type_arg_error(sc, "string-vector-position", 1, s7_car(args), "a string")); if (!s7_is_vector(s7_car(s7_cdr(args)))) return(s7_wrong_type_arg_error(sc, "string-vector-position", 2, s7_car(s7_cdr(args)), "a vector")); if (s7_is_pair(s7_cdr(s7_cdr(args)))) { s7_pointer arg; arg = s7_car(s7_cdr(s7_cdr(args))); if (!s7_is_integer(arg)) return(s7_wrong_type_arg_error(sc, "string-vector-position", 3, arg, "an integer")); start = s7_integer(arg); if (start < 0) return(s7_wrong_type_arg_error(sc, "string-vector-position", 3, arg, "a non-negative integer")); } s1 = s7_string(s7_car(args)); strs = s7_vector_elements(s7_car(s7_cdr(args))); len = s7_vector_length(s7_car(s7_cdr(args))); for (i = start; i < len; i++) if ((s7_is_string(strs[i])) && (mus_strcmp(s1, s7_string(strs[i])))) return(s7_make_integer(sc, i)); return(s7_f(sc)); } static s7_pointer g_string_list_position_1(s7_scheme *sc, s7_pointer args, bool ci, const char *name) { const char *s1; s7_pointer p; int i, start = 0; if (!s7_is_string(s7_car(args))) return(s7_wrong_type_arg_error(sc, name, 1, s7_car(args), "a string")); p = s7_car(s7_cdr(args)); if (p == s7_nil(sc)) return(s7_f(sc)); if (!s7_is_pair(p)) return(s7_wrong_type_arg_error(sc, name, 2, p, "a list")); if (s7_is_pair(s7_cdr(s7_cdr(args)))) { s7_pointer arg; arg = s7_car(s7_cdr(s7_cdr(args))); if (!s7_is_integer(arg)) return(s7_wrong_type_arg_error(sc, "string-list-position", 3, arg, "an integer")); start = s7_integer(arg); if (start < 0) return(s7_wrong_type_arg_error(sc, "string-list-position", 3, arg, "a non-negative integer")); } s1 = s7_string(s7_car(args)); if (!ci) { for (i = 0; s7_is_pair(p); p = s7_cdr(p), i++) if ((i >= start) && (s7_is_string(s7_car(p))) && (mus_strcmp(s1, s7_string(s7_car(p))))) return(s7_make_integer(sc, i)); } else { for (i = 0; s7_is_pair(p); p = s7_cdr(p), i++) if ((i >= start) && (s7_is_string(s7_car(p))) && (strcasecmp(s1, s7_string(s7_car(p))) == 0)) return(s7_make_integer(sc, i)); } return(s7_f(sc)); } static s7_pointer g_string_list_position(s7_scheme *sc, s7_pointer args) { #define H_string_list_position "(string-list-position str lst (start 0)) returns the position of the first occurrence of str in lst starting from start, or #f" return(g_string_list_position_1(sc, args, false, "string-list-position")); } static s7_pointer g_string_ci_list_position(s7_scheme *sc, s7_pointer args) { #define H_string_ci_list_position "(string-ci-list-position str lst (start 0)) returns the position of the first occurrence of str in lst starting from start, or #f" return(g_string_list_position_1(sc, args, true, "string-ci-list-position")); } /* list-in-vector|list, vector-in-list|vector, cobj-in-vector|list obj-in-cobj * string-ci-in-vector? hash-table cases? * most of this could be done via for-each */ #endif #ifdef XEN_ARGIFY_1 #if HAVE_SCHEME && HAVE_DLFCN_H XEN_NARGIFY_1(g_dlopen_w, g_dlopen) XEN_NARGIFY_1(g_dlclose_w, g_dlclose) XEN_NARGIFY_0(g_dlerror_w, g_dlerror) XEN_NARGIFY_2(g_dlinit_w, g_dlinit) #endif #if HAVE_SCHEME XEN_VARGIFY(g_snd_s7_error_handler_w, g_snd_s7_error_handler); #endif XEN_NARGIFY_1(g_snd_print_w, g_snd_print) XEN_NARGIFY_0(g_little_endian_w, g_little_endian) XEN_NARGIFY_0(g_snd_global_state_w, g_snd_global_state) XEN_NARGIFY_1(g_add_source_file_extension_w, g_add_source_file_extension) #if MUS_DEBUGGING XEN_NARGIFY_1(g_snd_sound_pointer_w, g_snd_sound_pointer) #endif #if (!HAVE_SCHEME) XEN_NARGIFY_2(g_fmod_w, g_fmod) #endif #if HAVE_SPECIAL_FUNCTIONS || HAVE_GSL XEN_NARGIFY_1(g_j0_w, g_j0) XEN_NARGIFY_1(g_j1_w, g_j1) XEN_NARGIFY_2(g_jn_w, g_jn) XEN_NARGIFY_1(g_y0_w, g_y0) XEN_NARGIFY_1(g_y1_w, g_y1) XEN_NARGIFY_2(g_yn_w, g_yn) XEN_NARGIFY_1(g_erf_w, g_erf) XEN_NARGIFY_1(g_erfc_w, g_erfc) XEN_NARGIFY_1(g_lgamma_w, g_lgamma) #endif XEN_NARGIFY_1(g_i0_w, g_i0) #if HAVE_GSL XEN_NARGIFY_1(g_i1_w, g_i1) XEN_NARGIFY_2(g_in_w, g_in) XEN_NARGIFY_1(g_k0_w, g_k0) XEN_NARGIFY_1(g_k1_w, g_k1) XEN_NARGIFY_2(g_kn_w, g_kn) XEN_NARGIFY_1(g_gsl_ellipk_w, g_gsl_ellipk) XEN_NARGIFY_2(g_gsl_ellipj_w, g_gsl_ellipj) XEN_NARGIFY_4(g_gsl_dht_w, g_gsl_dht) #if HAVE_GSL_EIGEN_NONSYMMV_WORKSPACE XEN_NARGIFY_1(g_gsl_eigenvectors_w, g_gsl_eigenvectors) #endif #if HAVE_COMPLEX_TRIG && XEN_HAVE_COMPLEX_NUMBERS XEN_NARGIFY_1(g_gsl_roots_w, g_gsl_roots) #endif #endif #else /* not argify */ #if HAVE_SCHEME && HAVE_DLFCN_H #define g_dlopen_w g_dlopen #define g_dlclose_w g_dlclose #define g_dlerror_w g_dlerror #define g_dlinit_w g_dlinit #endif #if HAVE_SCHEME #define g_snd_s7_error_handler_w g_snd_s7_error_handler #endif #define g_snd_print_w g_snd_print #define g_little_endian_w g_little_endian #define g_snd_global_state_w g_snd_global_state #define g_add_source_file_extension_w g_add_source_file_extension #if MUS_DEBUGGING #define g_snd_sound_pointer_w g_snd_sound_pointer #endif #if (!HAVE_SCHEME) #define g_fmod_w g_fmod #endif #if HAVE_SPECIAL_FUNCTIONS || HAVE_GSL #define g_j0_w g_j0 #define g_j1_w g_j1 #define g_jn_w g_jn #define g_y0_w g_y0 #define g_y1_w g_y1 #define g_yn_w g_yn #define g_erf_w g_erf #define g_erfc_w g_erfc #define g_lgamma_w g_lgamma #endif #define g_i0_w g_i0 #if HAVE_GSL #define g_i1_w g_i1 #define g_in_w g_in #define g_k0_w g_k0 #define g_k1_w g_k1 #define g_kn_w g_kn #define g_gsl_ellipk_w g_gsl_ellipk #define g_gsl_ellipj_w g_gsl_ellipj #define g_gsl_dht_w g_gsl_dht #if HAVE_GSL_EIGEN_NONSYMMV_WORKSPACE #define g_gsl_eigenvectors_w g_gsl_eigenvectors #endif #if HAVE_COMPLEX_TRIG && XEN_HAVE_COMPLEX_NUMBERS #define g_gsl_roots_w g_gsl_roots #endif #endif #endif #if HAVE_STATIC_XM #if USE_MOTIF void Init_libxm(void); #else void Init_libxg(void); #endif #endif #if HAVE_GL && (!JUST_GL) void Init_libgl(void); #endif static char *legalize_path(const char *in_str) { int inlen; char *out_str; int inpos, outpos = 0; inlen = mus_strlen(in_str); out_str = (char *)calloc(inlen * 2, sizeof(char)); for (inpos = 0; inpos < inlen; inpos++) { if (in_str[inpos] == '\\') out_str[outpos++] = '\\'; out_str[outpos++] = in_str[inpos]; } return(out_str); } #if HAVE_GL static XEN g_snd_glx_context(void) { return(XEN_LIST_2(C_STRING_TO_XEN_SYMBOL("GLXContext"), XEN_WRAP_C_POINTER(ss->cx))); } #ifdef XEN_ARGIFY_1 XEN_NARGIFY_0(g_snd_glx_context_w, g_snd_glx_context) #else #define g_snd_glx_context_w g_snd_glx_context #endif #endif /* -------------------------------------------------------------------------------- */ void g_xen_initialize(void) { add_source_file_extension(XEN_FILE_EXTENSION); #if HAVE_SCHEME add_source_file_extension("cl"); add_source_file_extension("lisp"); add_source_file_extension("init"); /* for slib */ #endif #if HAVE_FORTH add_source_file_extension("fth"); add_source_file_extension("fsm"); #endif add_source_file_extension("marks"); /* from save-marks */ default_source_file_extensions = source_file_extensions_end; XEN_DEFINE_PROCEDURE("snd-global-state", g_snd_global_state_w, 0, 0, 0, "internal testing function"); XEN_DEFINE_PROCEDURE(S_add_source_file_extension, g_add_source_file_extension_w, 1, 0, 0, H_add_source_file_extension); ss->snd_open_file_hook = XEN_DEFINE_SIMPLE_HOOK(1); ss->snd_selection_hook = XEN_DEFINE_SIMPLE_HOOK(1); XEN_PROTECT_FROM_GC(ss->snd_open_file_hook); XEN_PROTECT_FROM_GC(ss->snd_selection_hook); ss->effects_hook = XEN_DEFINE_HOOK(S_effects_hook, 0, "called when something changes that the effects dialogs care about"); #if MUS_DEBUGGING XEN_DEFINE_PROCEDURE("snd-sound-pointer", g_snd_sound_pointer_w, 1, 0, 0, "internal testing function"); #endif Init_sndlib(); #if HAVE_FORTH fth_add_loaded_files("sndlib.so"); #endif #if (!HAVE_SCHEME) gc_protection = XEN_FALSE; #endif XEN_DEFINE_SAFE_PROCEDURE(S_snd_print, g_snd_print_w, 1, 0, 0, H_snd_print); XEN_DEFINE_SAFE_PROCEDURE("little-endian?", g_little_endian_w, 0, 0, 0, "return " PROC_TRUE " if host is little endian"); #if HAVE_SCHEME XEN_EVAL_C_STRING("(define fmod modulo)"); #else XEN_DEFINE_PROCEDURE("fmod", g_fmod_w, 2, 0, 0, "C's fmod"); #endif #if HAVE_SPECIAL_FUNCTIONS || HAVE_GSL XEN_DEFINE_SAFE_PROCEDURE(S_bes_j0, g_j0_w, 1, 0, 0, H_j0); XEN_DEFINE_SAFE_PROCEDURE(S_bes_j1, g_j1_w, 1, 0, 0, H_j1); XEN_DEFINE_SAFE_PROCEDURE(S_bes_jn, g_jn_w, 2, 0, 0, H_jn); XEN_DEFINE_SAFE_PROCEDURE(S_bes_y0, g_y0_w, 1, 0, 0, H_y0); XEN_DEFINE_SAFE_PROCEDURE(S_bes_y1, g_y1_w, 1, 0, 0, H_y1); XEN_DEFINE_SAFE_PROCEDURE(S_bes_yn, g_yn_w, 2, 0, 0, H_yn); XEN_DEFINE_SAFE_PROCEDURE("erf", g_erf_w, 1, 0, 0, H_erf); XEN_DEFINE_SAFE_PROCEDURE("erfc", g_erfc_w, 1, 0, 0, H_erfc); XEN_DEFINE_SAFE_PROCEDURE("lgamma", g_lgamma_w, 1, 0, 0, H_lgamma); #endif XEN_DEFINE_PROCEDURE(S_bes_i0, g_i0_w, 1, 0, 0, H_i0); #if HAVE_GSL XEN_DEFINE_SAFE_PROCEDURE(S_bes_i1, g_i1_w, 1, 0, 0, H_i1); XEN_DEFINE_SAFE_PROCEDURE(S_bes_in, g_in_w, 2, 0, 0, H_in); XEN_DEFINE_SAFE_PROCEDURE(S_bes_k0, g_k0_w, 1, 0, 0, H_k0); XEN_DEFINE_SAFE_PROCEDURE(S_bes_k1, g_k1_w, 1, 0, 0, H_k1); XEN_DEFINE_SAFE_PROCEDURE(S_bes_kn, g_kn_w, 2, 0, 0, H_kn); XEN_DEFINE_PROCEDURE("gsl-ellipk", g_gsl_ellipk_w, 1, 0, 0, H_gsl_ellipk); XEN_DEFINE_PROCEDURE("gsl-ellipj", g_gsl_ellipj_w, 2, 0, 0, H_gsl_ellipj); XEN_DEFINE_PROCEDURE("gsl-dht", g_gsl_dht_w, 4, 0, 0, H_gsl_dht); #if HAVE_GSL_EIGEN_NONSYMMV_WORKSPACE XEN_DEFINE_PROCEDURE("gsl-eigenvectors", g_gsl_eigenvectors_w, 1, 0, 0, "returns eigenvalues and eigenvectors"); #endif #if MUS_DEBUGGING && HAVE_SCHEME XEN_DEFINE_PROCEDURE("gsl-gegenbauer", g_gsl_gegenbauer_w, 3, 0, 0, "internal test func"); #endif #if HAVE_COMPLEX_TRIG && XEN_HAVE_COMPLEX_NUMBERS XEN_DEFINE_PROCEDURE("gsl-roots", g_gsl_roots_w, 1, 0, 0, H_gsl_roots); #endif #endif #if HAVE_SCHEME && WITH_GMP s7_define_function(s7, "bignum-fft", bignum_fft, 3, 1, false, H_bignum_fft); #endif #if HAVE_SCHEME s7_define_safe_function(s7, "char-position", g_char_position, 2, 1, false, H_char_position); s7_define_safe_function(s7, "string-position", g_string_position, 2, 1, false, H_string_position); s7_define_safe_function(s7, "string-ci-position", g_string_ci_position, 2, 1, false, H_string_ci_position); s7_define_safe_function(s7, "string-vector-position", g_string_vector_position, 2, 1, false, H_string_vector_position); s7_define_safe_function(s7, "string-list-position", g_string_list_position, 2, 1, false, H_string_list_position); s7_define_safe_function(s7, "string-ci-list-position", g_string_ci_list_position, 2, 1, false, H_string_ci_list_position); #define H_print_hook S_print_hook " (text): called each time some Snd-generated response (text) is about to be appended to the listener. \ If it returns some non-" PROC_FALSE " result, Snd assumes you've sent the text out yourself, as well as any needed prompt. \n\ (add-hook! " S_print_hook "\n\ (lambda (msg) \n\ (" S_snd_print "\n\ (format #f \"~A~%[~A]~%~A\" \n\ msg \n\ (strftime \"%d-%b %H:%M %Z\" \n\ (localtime (current-time))) \n\ (" S_listener_prompt ")))))" #endif #if HAVE_RUBY #define H_print_hook S_print_hook " (text): called each time some Snd-generated response (text) is about to be appended to the listener. \ If it returns some non-false result, Snd assumes you've sent the text out yourself, as well as any needed prompt. \n\ $print_hook.add-hook!(\"localtime\") do |msg|\n\ $stdout.print msg\n\ false\n\ end" #endif #if HAVE_FORTH #define H_print_hook S_print_hook " (text): called each time some Snd-generated response (text) is about to be appended to the listener. \ If it returns some non-#f result, Snd assumes you've sent the text out yourself, as well as any needed prompt. \n\ " S_print_hook " lambda: <{ msg }>\n\ \"%s\n[%s]\n%s\" '( msg date " S_listener_prompt " ) format " S_snd_print "\n\ ; add-hook!" #endif print_hook = XEN_DEFINE_HOOK(S_print_hook, 1, H_print_hook); /* arg = text */ g_init_base(); g_init_utils(); g_init_marks(); g_init_regions(); g_init_selection(); g_init_mix(); g_init_chn(); g_init_kbd(); g_init_sig(); g_init_print(); g_init_errors(); g_init_fft(); g_init_edits(); g_init_listener(); g_init_help(); g_init_menu(); g_init_main(); g_init_snd(); g_init_dac(); /* needs to follow snd and mix */ g_init_file(); g_init_data(); g_init_env(); g_init_find(); #if (!USE_NO_GUI) g_init_gxcolormaps(); g_init_gxfile(); g_init_gxdraw(); g_init_gxenv(); g_init_gxmenu(); g_init_axis(); g_init_gxlistener(); g_init_gxchn(); g_init_draw(); g_init_gxdrop(); g_init_gxregion(); g_init_gxsnd(); g_init_gxfind(); #endif #if (!WITH_SHARED_SNDLIB) mus_init_run(); /* this needs to be called after Snd's run-optimizable functions are defined (sampler_p for example) */ #endif #if HAVE_SCHEME && HAVE_DLFCN_H XEN_DEFINE_PROCEDURE("dlopen", g_dlopen_w, 1, 0 ,0, H_dlopen); XEN_DEFINE_PROCEDURE("dlclose", g_dlclose_w, 1, 0 ,0, H_dlclose); XEN_DEFINE_PROCEDURE("dlerror", g_dlerror_w, 0, 0 ,0, H_dlerror); XEN_DEFINE_PROCEDURE("dlinit", g_dlinit_w, 2, 0 ,0, H_dlinit); #endif #if HAVE_LADSPA && HAVE_EXTENSION_LANGUAGE && HAVE_DLFCN_H && HAVE_DIRENT_H g_ladspa_to_snd(); #endif #ifdef SCRIPTS_DIR XEN_ADD_TO_LOAD_PATH((char *)SCRIPTS_DIR); #endif { char *pwd, *legal_pwd; pwd = mus_getcwd(); legal_pwd = legalize_path(pwd); XEN_ADD_TO_LOAD_PATH(legal_pwd); free(pwd); free(legal_pwd); } #if HAVE_SCHEME XEN_DEFINE_PROCEDURE("_snd_s7_error_handler_", g_snd_s7_error_handler_w, 0, 0, 1, "internal error redirection for snd/s7"); XEN_EVAL_C_STRING("(define redo-edit redo)"); /* consistency with Ruby */ XEN_EVAL_C_STRING("(define undo-edit undo)"); XEN_EVAL_C_STRING("(define (procedure-name proc) (if (procedure? proc) (format #f \"~A\" proc) #f))"); /* needed in snd-test.scm and hooks.scm */ XEN_EVAL_C_STRING("\ (define* (apropos name port)\ (define (substring? subs s)\ (let* ((start 0)\ (ls (string-length s))\ (lu (string-length subs))\ (limit (- ls lu)))\ (let loop ((i start))\ (cond ((> i limit) #f)\ ((do ((j i (+ j 1))\ (k 0 (+ k 1)))\ ((or (= k lu)\ (not (char=? (string-ref subs k) (string-ref s j))))\ (= k lu))) i)\ (else (loop (+ i 1)))))))\ (define (apropos-1 e)\ (for-each\ (lambda (binding)\ (if (and (pair? binding)\ (substring? name (symbol->string (car binding))))\ (let ((str (format #f \"~%~A: ~A\" \ (car binding) \ (if (procedure? (cdr binding))\ (procedure-documentation (cdr binding))\ (cdr binding)))))\ (if (not port)\ (snd-print str)\ (display str port)))))\ e))\ (if (or (not (string? name))\ (= (length name) 0))\ (error 'wrong-type-arg \"apropos argument should be a non-nil string\")\ (begin \ (if (not (eq? (current-environment) (global-environment)))\ (for-each apropos-1 (environment->list (current-environment)))) \ (apropos-1 (global-environment)))))"); XEN_EVAL_C_STRING("\ (define break-ok #f)\ (define break-exit #f) ; a kludge to get 2 funcs to share a local variable\n\ (define break-enter #f)\ \ (let ((saved-listener-prompt (listener-prompt)))\ (set! break-exit (lambda ()\ (reset-hook! read-hook)\ (set! (listener-prompt) saved-listener-prompt)\ #f))\ (set! break-enter (lambda ()\ (set! saved-listener-prompt (listener-prompt)))))\ \ (define-macro (break)\ `(let ((__break__ (current-environment)))\ (break-enter)\ (set! (listener-prompt) (format #f \"~A>\" (if (defined? __func__) __func__ 'break)))\ (call/cc\ (lambda (return)\ (set! break-ok return) ; save current program loc so (break-ok) continues from the break\n\ (add-hook! read-hook ; anything typed in the listener is evaluated in the environment of the break call\n\ (lambda (str)\ (eval-string str __break__)))\ (error 'snd-top-level))) ; jump back to the top level\n\ (break-exit))) ; we get here if break-ok is called\n\ "); #endif #if HAVE_SCHEME && USE_GTK && (!HAVE_GTK_ADJUSTMENT_GET_UPPER) /* Gtk 3 is removing direct struct accesses (which they should have done years ago), so we need compatibility functions: */ XEN_EVAL_C_STRING("(define (gtk_widget_get_window w) (.window w))"); XEN_EVAL_C_STRING("(define (gtk_font_selection_dialog_get_ok_button w) (.ok_button w))"); XEN_EVAL_C_STRING("(define (gtk_font_selection_dialog_get_apply_button w) (.apply_button w))"); XEN_EVAL_C_STRING("(define (gtk_font_selection_dialog_get_cancel_button w) (.cancel_button w))"); XEN_EVAL_C_STRING("(define (gtk_color_selection_dialog_get_color_selection w) (.colorsel w))"); XEN_EVAL_C_STRING("(define (gtk_dialog_get_action_area w) (.action_area w))"); XEN_EVAL_C_STRING("(define (gtk_dialog_get_content_area w) (.vbox w))"); /* also gtk_adjustment fields, but I think they are not in use in Snd's gtk code */ #endif #if HAVE_FORTH XEN_EVAL_C_STRING("<'> redo alias redo-edit"); /* consistency with Ruby */ XEN_EVAL_C_STRING("<'> undo alias undo-edit"); XEN_EVAL_C_STRING(": clm-print ( fmt :optional args -- ) fth-format snd-print drop ;"); #endif #if HAVE_RUBY XEN_EVAL_C_STRING("def clm_print(str, *args)\n\ snd_print format(str, *args)\n\ end"); #endif #if HAVE_SCHEME XEN_EVAL_C_STRING("(define (clm-print . args) \"(clm-print . args) applies format to args and prints the result via snd-print\" \ (snd-print (apply format #f args)))"); #endif #if HAVE_GL XEN_DEFINE_PROCEDURE("snd-glx-context", g_snd_glx_context_w, 0, 0, 0, "OpenGL GLXContext"); #endif #if HAVE_STATIC_XM #if USE_MOTIF Init_libxm(); #if HAVE_FORTH fth_add_loaded_files("libxm.so"); #endif #else Init_libxg(); #if HAVE_FORTH fth_add_loaded_files("libxg.so"); #endif #endif #endif #if (HAVE_GL) && (!JUST_GL) Init_libgl(); #endif #if MUS_DEBUGGING XEN_YES_WE_HAVE("snd-debug"); #endif #if HAVE_ALSA XEN_YES_WE_HAVE("alsa"); #endif #if HAVE_OSS XEN_YES_WE_HAVE("oss"); #endif #if MUS_ESD XEN_YES_WE_HAVE("esd"); #endif #if MUS_PULSEAUDIO XEN_YES_WE_HAVE("pulse-audio"); #endif #if MUS_JACK XEN_YES_WE_HAVE("jack"); #endif #if HAVE_GSL XEN_YES_WE_HAVE("gsl"); #endif #if USE_MOTIF XEN_YES_WE_HAVE("snd-motif"); #endif #if USE_GTK XEN_YES_WE_HAVE("snd-gtk"); #if HAVE_GTK_3 XEN_YES_WE_HAVE("gtk3"); #else XEN_YES_WE_HAVE("gtk2"); #endif #endif #if USE_NO_GUI XEN_YES_WE_HAVE("snd-nogui"); #endif #if HAVE_FORTH XEN_YES_WE_HAVE("snd-forth"); #endif #if HAVE_SCHEME XEN_YES_WE_HAVE("snd-s7"); #endif #if HAVE_RUBY XEN_YES_WE_HAVE("snd-ruby"); /* we need to set up the search path so that load and require will work as in the program irb */ #ifdef RUBY_SEARCH_PATH { /* this code stolen from ruby.c */ char *str, *buf; int i, j = 0, len; str = (char *)(RUBY_SEARCH_PATH); len = mus_strlen(str); buf = (char *)calloc(len + 1, sizeof(char)); for (i = 0; i < len; i++) if (str[i] == ':') { buf[j] = 0; if (j > 0) { XEN_ADD_TO_LOAD_PATH(buf); } j = 0; } else buf[j++] = str[i]; if (j > 0) { buf[j] = 0; XEN_ADD_TO_LOAD_PATH(buf); } free(buf); } #endif #endif XEN_YES_WE_HAVE("snd"); XEN_YES_WE_HAVE("snd" SND_MAJOR_VERSION); XEN_YES_WE_HAVE("snd-" SND_MAJOR_VERSION "." SND_MINOR_VERSION); }
{ "alphanum_fraction": 0.6401757705, "avg_line_length": 27.6603834904, "ext": "c", "hexsha": "f7ba880841f2fb61c224fa0f875c16170137ec17", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b633660e5945a6a6b095cd9aa3178deab56b354f", "max_forks_repo_licenses": [ "Ruby" ], "max_forks_repo_name": "OS2World/MM-SOUND-Snd", "max_forks_repo_path": "sources/snd-xen.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "b633660e5945a6a6b095cd9aa3178deab56b354f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Ruby" ], "max_issues_repo_name": "OS2World/MM-SOUND-Snd", "max_issues_repo_path": "sources/snd-xen.c", "max_line_length": 167, "max_stars_count": 1, "max_stars_repo_head_hexsha": "b633660e5945a6a6b095cd9aa3178deab56b354f", "max_stars_repo_licenses": [ "Ruby" ], "max_stars_repo_name": "OS2World/MM-SOUND-Snd", "max_stars_repo_path": "sources/snd-xen.c", "max_stars_repo_stars_event_max_datetime": "2018-08-27T17:57:08.000Z", "max_stars_repo_stars_event_min_datetime": "2018-08-27T17:57:08.000Z", "num_tokens": 26738, "size": 85111 }
/****************************************************************************** * Copyright (C) 2016-2019, Cris Cecka. All rights reserved. * Copyright (C) 2016-2019, NVIDIA CORPORATION. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the NVIDIA CORPORATION nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ #pragma once #include <blam/detail/config.h> #if !defined(__MKL_CBLAS_H__) #include <cblas.h> using CBLAS_LAYOUT = CBLAS_ORDER; #endif namespace blam { inline CBLAS_LAYOUT cblas_type(Layout order) { switch (order) { case Layout::ColMajor: return CblasColMajor; case Layout::RowMajor: return CblasRowMajor; default: assert(false && "Invalid Layout Parameter"); return CblasColMajor; } } inline CBLAS_TRANSPOSE cblas_type(Op trans) { switch (trans) { case Op::NoTrans: return CblasNoTrans; case Op::Trans: return CblasTrans; case Op::ConjTrans: return CblasConjTrans; default: assert(false && "Invalid Op Parameter"); return CblasNoTrans; } } inline CBLAS_UPLO cblas_type(Uplo uplo) { switch (uplo) { case Uplo::Upper: return CblasUpper; case Uplo::Lower: return CblasLower; default: assert(false && "Invalid Uplo Parameter"); return CblasUpper; } } inline CBLAS_SIDE cblas_type(Side side) { switch (side) { case Side::Left: return CblasLeft; case Side::Right: return CblasRight; default: assert(false && "Invalid Side Parameter"); return CblasLeft; } } inline CBLAS_DIAG cblas_type(Diag diag) { switch (diag) { case Diag::Unit: return CblasUnit; case Diag::NonUnit: return CblasNonUnit; default: assert(false && "Invalid Diag Parameter"); return CblasUnit; } } } // end namespace blam
{ "alphanum_fraction": 0.6844854071, "avg_line_length": 31.6019417476, "ext": "h", "hexsha": "a341738addc2e116f6c900445375aa9f07ae434d", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-07-31T07:50:20.000Z", "max_forks_repo_forks_event_min_datetime": "2018-08-04T04:38:59.000Z", "max_forks_repo_head_hexsha": "4198e8a22aa7650cc97a1b6d96b30bdcac8ce232", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "ccecka/BLAM", "max_forks_repo_path": "blam/system/cblas/config.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "4198e8a22aa7650cc97a1b6d96b30bdcac8ce232", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "ccecka/BLAM", "max_issues_repo_path": "blam/system/cblas/config.h", "max_line_length": 82, "max_stars_count": 5, "max_stars_repo_head_hexsha": "4198e8a22aa7650cc97a1b6d96b30bdcac8ce232", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "ccecka/BLAM", "max_stars_repo_path": "blam/system/cblas/config.h", "max_stars_repo_stars_event_max_datetime": "2021-08-19T04:51:47.000Z", "max_stars_repo_stars_event_min_datetime": "2017-02-09T20:48:51.000Z", "num_tokens": 743, "size": 3255 }
/* FacSexCoalescent.c The facultative sex coalescent program, ported to C Run the program without parameters to obtain a helpfile outlining basic instructions. Further information is available in the README file, and the manual. (see http://github.com/MattHartfield/FacSexCoalescent for more info.) Simulation uses routines found with the GNU Scientific Library (GSL) (http://www.gnu.org/software/gsl/) Since GSL is distributed under the GNU General Public License (http://www.gnu.org/copyleft/gpl.html), you must download it separately from this file. */ /* Preprocessor statements */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <stddef.h> #include <string.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <gsl/gsl_sf_lambert.h> #include <sys/stat.h> #include <sys/types.h> #define INITBR 10 #define HUGEVAL 1000000 #define WARNQ 0.05 /* Function prototypes */ unsigned int isanyUI(unsigned int *vin, unsigned int size_t, unsigned int match); unsigned int isanyD(double *vin, unsigned int size_t, double match, unsigned int offset); unsigned int isallUI(unsigned int *vin, unsigned int size_t, unsigned int match, unsigned int offset); unsigned int isallI(int *vin, unsigned int size_t, int match, unsigned int offset); unsigned int isallD(double *vin, unsigned int size_t, double match); double powDUI(double *Va, unsigned int *Vb, unsigned int size_t); unsigned int sumUI(unsigned int *Vin, unsigned int size_t); double sumT_D(double **Tin, unsigned int nrow, unsigned int ncol); unsigned int isanylessD_2D(double **Tin, unsigned int nrow, unsigned int ncol, double match); void vcopyUI(unsigned int *Vout, unsigned int *Vin, unsigned int size_t); void vcopyI(int *Vout, int *Vin, unsigned int size_t); void vcopyUI_I(int *Vout, unsigned int *Vin, unsigned int size_t); void vcopyD(double *Vout, double *Vin, unsigned int size_t); void rowsumD(double **Tin, unsigned int nrow, unsigned int ncol, double *Vout); unsigned int matchUI(unsigned int *Vin, unsigned int size_t, unsigned int match); void smultI_UI(int *Vout, unsigned int *Vin, unsigned int size_t, int scale); void vsum_UI_I(unsigned int *Vbase, int *Vadd, unsigned int size_t); void sselect_UI(unsigned int **Tin, unsigned int *Vout, unsigned int nrow, unsigned int matchcol, unsigned int datcol, unsigned int match, unsigned int dcol, unsigned int deme); void sselect_UIV(unsigned int **Tin, unsigned int *Vout, unsigned int nrow, unsigned int matchcol, unsigned int datcol, unsigned int *match, unsigned int mlength, unsigned int mlength2, unsigned int dcol, unsigned int deme); double sumrep(unsigned int n); double sumrepsq(unsigned int n); unsigned int maxUI(unsigned int *vin, unsigned int size_t); unsigned int minUI(unsigned int *vin, unsigned int size_t, unsigned int offset); int minI(int *vin, unsigned int size_t, unsigned int offset); unsigned int first_neI(int *vin, unsigned int size_t, int target, unsigned int offset); unsigned int first_neUI(unsigned int *vin, unsigned int size_t, unsigned int target, unsigned int offset); unsigned int last_neI(int *vin, unsigned int size_t, int target, unsigned int offset); unsigned int last_neUI(unsigned int *vin, unsigned int size_t, unsigned int target, unsigned int offset); unsigned int trig(unsigned int x); double KQ(double Q); double singGC(unsigned int y, unsigned int k, double geemi, double geeme, double Qmi, double Qme, double sexC); double pairGC(unsigned int x, unsigned int k, double geemi, double Qmi); double P23(unsigned int y, unsigned int k, unsigned int Na); double P4(unsigned int x, unsigned int k, unsigned int Na); double P56(unsigned int y, unsigned int Na); double P7(unsigned int x, unsigned int k, unsigned int Na); double P8(unsigned int x, unsigned int y, unsigned int k, unsigned int Na); double P9(unsigned int x, unsigned int y, unsigned int k, double geemi, double geeme, double Qmi, double Qme, double sexC, unsigned int nsites); double P10(unsigned int x, unsigned int y, unsigned int k, double mee); double P11(unsigned int y, unsigned int k, double sexC, double rec, double mrec, unsigned int lrec, unsigned int nlrec, unsigned int nlrec2); double P12(unsigned int x, unsigned int k, double geemi, double Qmi, unsigned int nsites); double P13(unsigned int x, unsigned int k, double mrec, unsigned int lrec, unsigned int nlrecx); double invs1(double Si, double Qin); double invt1(double Ti, double Qin); double invs2(double Si, double Qin); double invt2(double Ti, double Si, double Qin); void probset2(unsigned int N, double gmi, double gme, double *sexC, double rec, double mrec, double Qmi, double Qme, unsigned int lrec, unsigned int *nlrec, unsigned int *nlrec2, unsigned int *nlrecx, double mig, unsigned int *Nwith, unsigned int *Nbet, unsigned int *kin, unsigned int sw, double **pr); void rate_change(unsigned int N, unsigned int pST,double pLH, double pHL, double *sexH, double *sexL, unsigned int switch1, double *sexCN, double *sexCNInv, double *tts, unsigned int *npST,const gsl_rng *r); void stchange2(unsigned int ev, unsigned int deme, unsigned int *kin, int *WCH, int *BCH); void sexconv(unsigned int **Tin, unsigned int *rsex, unsigned int nsum, unsigned int Ntot, unsigned int Nid, unsigned int ex); unsigned int coalesce(unsigned int **indvs, int **GType, double **CTms , int **TAnc, unsigned int **nlri, unsigned int **nlrix, double Ttot, unsigned int *Nwith, unsigned int *Nbet, unsigned int deme, unsigned int *rsex, unsigned int *nsex, unsigned int ex, unsigned int drec, unsigned int e2, unsigned int **breaks, unsigned int nsites, unsigned int *nbreaks, unsigned int NMax, unsigned int Itot, double gmi, double gme, double Qmi, double Qme, unsigned int *gcalt, double *sexC, int *WCHex, int *BCHex, const gsl_rng *r, unsigned int ei); void cchange(unsigned int **indvs, int **GType, double **CTms, int **TAnc, unsigned int **breaks, unsigned int *csamp, unsigned int *par, unsigned int lsamp, unsigned int Ntot, unsigned int cst, unsigned int *cend, double Ttot, unsigned int isall); unsigned int ccheck(unsigned int **indvs, int **GType, unsigned int **breaks, unsigned int nsites, unsigned int Ntot, unsigned int nbreaks); void excoal(unsigned int **indvs, int **GType, unsigned int *par, unsigned int nbreaks, unsigned int npar, unsigned int Ntot, int *WCHex, int *BCHex, unsigned int deme); unsigned int coalcalc(unsigned int **breaks, unsigned int nsites, unsigned int nbreaks, unsigned int start); void sexsamp(unsigned int **indvs, unsigned int *rsex, unsigned int *nsex, unsigned int *Nwith, unsigned int Ntot, const gsl_rng *r); void indv_sort(unsigned int **indvs, unsigned int nrow); void indv_sortD(double **Tin, unsigned int nrow, unsigned int ncol, unsigned int tcol); void Wait(); void TestTabs(unsigned int **indvs, int **GType, double **CTms, int **TAnc, unsigned int **breaks, unsigned int **nlri, unsigned int **nlrix, unsigned int NMax, unsigned int Itot, unsigned int Nbet, unsigned int Nwith, unsigned int nbreaks); char * treemaker(double **TFin, double thetain, unsigned int mind2, unsigned int maxd2, double mind, double maxd, unsigned int Itot, unsigned int run, double gmi, double gme, unsigned int ismsp, unsigned int *nmutT, unsigned int prtrees, unsigned int ismut, double pburst, unsigned int mburst, double bdist, const gsl_rng *r); void reccal(unsigned int **indvs, int **GType, unsigned int **breaks, unsigned int **nlri, unsigned int *Nbet, unsigned int *Nwith, unsigned int *rsex, unsigned int esex, unsigned int *lnrec, unsigned int nbreaks, unsigned int NMax, unsigned int sw, unsigned int run); void reccalx(unsigned int **indvs, int **GType, unsigned int **breaks, unsigned int **nlrix, unsigned int *Nbet, unsigned int *Nwith, unsigned int *rsex, unsigned int esex, unsigned int *lnrec, unsigned int nbreaks, unsigned int NMax, unsigned int sw, unsigned int run); void proberr(unsigned int est, double **pr, unsigned int *NW, unsigned int *NB, unsigned int *esx); void proberr2(double **pr, unsigned int *NW, unsigned int *NB); void proberr3(double **pr, unsigned int *NW, unsigned int *NB); void printCT(double **CTms, unsigned int **breaks, unsigned int nbreaks, unsigned int nsites, unsigned int Itot, unsigned int run); void manyr(); void usage(); void inputtest(unsigned int argno, unsigned int argmax, char *args[]); /* Global variable declaration */ double rec = 0; /* Per-site recombination rate */ unsigned int nsites = 1; /* Number of sites (for recombination) */ unsigned int d = 1; /* Number of demes */ /* Function to replicate the 'any' func in R (unsigned int) */ unsigned int isanyUI(unsigned int *vin, unsigned int size_t, unsigned int match){ unsigned int i; unsigned int res = 0; for(i = 0; i < size_t; i++){ if(*(vin + i) == match){ res = 1; } } return res; } /* Function to replicate the 'any' func in R (double) */ unsigned int isanyD(double *vin, unsigned int size_t, double match, unsigned int offset){ unsigned int i; unsigned int res = 0; for(i = offset; i < size_t; i++){ if(*(vin + i) == match){ res = 1; } } return res; } /* Function to replicate the 'all' func in R (unsigned int) */ unsigned int isallUI(unsigned int *vin, unsigned int size_t, unsigned int match, unsigned int offset){ unsigned int i; unsigned int res = 1; for(i = offset; i < size_t; i++){ if(*(vin + i) != match){ res = 0; } } return res; } /* Function to replicate the 'all' func in R (normal int) */ unsigned int isallI(int *vin, unsigned int size_t, int match, unsigned int offset){ unsigned int i; unsigned int res = 1; for(i = offset; i < size_t; i++){ if(*(vin + i) != match){ res = 0; } } return res; } /* Function to replicate the 'all' func in R (double) */ unsigned int isallD(double *vin, unsigned int size_t, double match){ unsigned int i; unsigned int res = 1; for(i = 0; i < size_t; i++){ if(*(vin + i) != match){ res = 0; } } return res; } /* Dot product of two vectors (double X UI) */ double powDUI(double *Va, unsigned int *Vb, unsigned int size_t){ unsigned int i; double res = 1; for(i = 0; i < size_t; i++){ res *= pow((*(Va + i)),(*(Vb + i))); } return res; } /* Summing vector (UI) */ unsigned int sumUI(unsigned int *Vin, unsigned int size_t){ unsigned int i; unsigned int res = 0; for(i = 0; i < size_t; i++){ res += *(Vin + i); } return res; } /* Summing entire table (double) */ double sumT_D(double **Tin, unsigned int nrow, unsigned int ncol){ unsigned int i, j; double res = 0; for(i = 0; i < nrow; i++){ for(j = 0; j < ncol; j++){ res += (*((*(Tin + i)) + j)); } } return res; } /* Is any entry of table less than input? */ unsigned int isanylessD_2D(double **Tin, unsigned int nrow, unsigned int ncol, double match){ unsigned int i, j; double res = 0; for(i = 0; i < nrow; i++){ for(j = 0; j < ncol; j++){ if(*((*(Tin + i)) + j) < match){ res = 1; } } } return res; } /* Copying vectors (UI) */ void vcopyUI(unsigned int *Vout, unsigned int *Vin, unsigned int size_t){ unsigned int x; for(x = 0; x < d; x++){ *(Vout + x) = *(Vin + x); } } /* Copying vectors (Int) */ void vcopyI(int *Vout, int *Vin, unsigned int size_t){ unsigned int x; for(x = 0; x < d; x++){ *(Vout + x) = *(Vin + x); } } /* Copying vectors (UInt -> Int) */ void vcopyUI_I(int *Vout, unsigned int *Vin, unsigned int size_t){ unsigned int x; for(x = 0; x < d; x++){ *(Vout + x) = *(Vin + x); } } /* Copying vectors (double) */ void vcopyD(double *Vout, double *Vin, unsigned int size_t){ unsigned int x; for(x = 0; x < d; x++){ *(Vout + x) = *(Vin + x); } } /* Calculating rowsums (double) */ void rowsumD(double **Tin, unsigned int nrow, unsigned int ncol, double *Vout){ unsigned int i, j; for(i = 0; i < nrow; i++){ *(Vout + i) = 0; for(j = 0; j < ncol; j++){ *(Vout + i) += *((*(Tin + i)) + j); } } } /* Replicating 'match' R function (UI) */ unsigned int matchUI(unsigned int *Vin, unsigned int size_t, unsigned int match){ unsigned int i; unsigned int res = 0; for(i = 0; i < size_t; i++){ if(*(Vin + i) == match){ res = i; } } return res; } /* Multiplying vector by a scalar (Int) */ void smultI_UI(int *Vout, unsigned int *Vin, unsigned int size_t, int scale){ unsigned int i; for(i = 0; i < size_t; i++){ *(Vout + i) = (scale)*(*(Vin + i)); } } /* Summing two vector (UI + Int) */ void vsum_UI_I(unsigned int *Vbase, int *Vadd, unsigned int size_t){ unsigned int i; for(i = 0; i < size_t; i++){ *(Vbase + i) += *(Vadd + i); } } /* Choosing UNIQUE elements from array that match certain pattern (UI) */ void sselect_UI(unsigned int **Tin, unsigned int *Vout, unsigned int nrow, unsigned int matchcol, unsigned int datcol, unsigned int match, unsigned int dcol, unsigned int deme){ unsigned int j, x = 0; unsigned int count = 0; unsigned int ny = 1; /* 'Not yet' - is element already present? */ for(j = 0; j < nrow; j++){ if((*((*(Tin + j)) + matchcol) == match) && (*((*(Tin + j)) + dcol) == deme) ){ /* Only add if not yet present */ ny = 1; for(x = 0; x < count; x++){ if( *(Vout + x) == *((*(Tin + j)) + datcol)){ ny = 0; } } if(ny == 1){ *(Vout + count) = *((*(Tin + j)) + datcol); count++; } } } } /* Choosing elements from array that match certain vector (UI) */ void sselect_UIV(unsigned int **Tin, unsigned int *Vout, unsigned int nrow, unsigned int matchcol, unsigned int datcol, unsigned int *match, unsigned int mlength, unsigned int mlength2, unsigned int dcol, unsigned int deme){ unsigned int j = 0; unsigned int count = 0; unsigned int count2 = 0; while(count < mlength && count2 < mlength2){ for(j = 0; j < nrow; j++){ if((*((*(Tin + j)) + matchcol) == (*(match + count2))) && (*((*(Tin + j)) + dcol) == deme) ){ *(Vout + 2*count) = *((*(Tin + j)) + datcol); *(Vout + 2*count+1) = *((*(Tin + j + 1)) + datcol); count++; count2++; break; }else if((*((*(Tin + j)) + matchcol) == *(match + count2)) && (*((*(Tin + j)) + dcol) != deme) ){ count2++; break; } } } } /* Sum of 1/i */ double sumrep(unsigned int n){ unsigned int count = 0; unsigned int i; for(i = 1; i < n; i++){ count += 1/(1.0*i); } return(count); } /* Sum of 1/i^2 */ double sumrepsq(unsigned int n){ unsigned int count = 0; unsigned int i; for(i = 1; i < n; i++){ count += 1/(1.0*i*i); } return(count); } /* Finding max of samples (UI) */ unsigned int maxUI(unsigned int *vin, unsigned int size_t){ unsigned int ret = 0; unsigned int i = 0; for(i = 0; i < size_t; i++){ if(*(vin + i) > ret){ ret = *(vin + i); } } return ret; } /* Finding min of samples (UI) */ unsigned int minUI(unsigned int *vin, unsigned int size_t, unsigned int offset){ unsigned int ret = 0; unsigned int i = 0; for(i = 0; i < size_t; i++){ if(*(vin + i + offset) < ret){ ret = *(vin + i + offset); } } return ret; } /* Finding min of samples (I) */ int minI(int *vin, unsigned int size_t, unsigned int offset){ int ret = 0; unsigned int i = 0; for(i = 0; i < size_t; i++){ if(*(vin + i + offset) < ret){ ret = *(vin + i + offset); } } return ret; } /* First element not of type (I) */ unsigned int first_neI(int *vin, unsigned int size_t, int target, unsigned int offset){ int ret = 0; unsigned int i = 0; for(i = offset; i < size_t; i++){ if(*(vin + i) != target){ ret = i; break; } } return ret; } /* First element not of type (UI) */ unsigned int first_neUI(unsigned int *vin, unsigned int size_t, unsigned int target, unsigned int offset){ unsigned int ret = 0; unsigned int i = 0; for(i = offset; i < size_t; i++){ if(*(vin + i) != target){ ret = i; break; } } return ret; } /* Last element not of type (I) */ unsigned int last_neI(int *vin, unsigned int size_t, int target, unsigned int offset){ int ret = 0; unsigned int i = 0; for(i = offset; i < size_t; i++){ if(*(vin + i) != target){ ret = i; } } return ret; } /* Last element not of type (UI) */ unsigned int last_neUI(unsigned int *vin, unsigned int size_t, unsigned int target, unsigned int offset){ unsigned int ret = 0; unsigned int i = 0; for(i = offset; i < size_t; i++){ if(*(vin + i) != target){ ret = i; } } return ret; } /* 'Triangle function' calculation */ unsigned int trig(unsigned int x){ return (x*(x-1))/2.0; } /* 'K' function, for GC calculations */ double KQ(double Q){ return 1.0 - ((1.0 - exp(-Q))/(1.0*Q)); } /* Partial GC prob calculations. For calculating overall GC prob, and subprobs of different events */ double singGC(unsigned int y, unsigned int k, double geemi, double geeme, double Qmi, double Qme, double sexC){ return y*(geemi*(2.0-KQ(Qmi)) + sexC*geeme*(2.0-KQ(Qme))) + 2*k*(geemi*(2.0-KQ(Qmi)) + geeme*(2.0-KQ(Qme))); } double pairGC(unsigned int x, unsigned int k, double geemi, double Qmi){ return 2.0*geemi*(2.0-KQ(Qmi))*(x-k); } /* Functions of each transition probability calculation */ double P23(unsigned int y, unsigned int k, unsigned int Na){ /* One of the paired samples is recreated: (x,y) -> (x-k+1, y + 2(k-1)). OR A unique samples coalesces with another (either pre-existing or new): (x,y) -> (x-k, y + 2k - 1) */ return (k*y)/(1.0*Na) + trig(2.0*k)/(2.0*Na); } double P4(unsigned int x, unsigned int k, unsigned int Na){ /* A paired sample coaleses with new unique sample: (x,y) -> (x-k,y + 2k -1) */ return ((x-k)*2.0*k)/(1.0*Na); } double P56(unsigned int y, unsigned int Na){ /* Two pre-existing unique samples re-create a paired sample: (x,y) -> (x - k + 1, y + 2(k-1)). OR Two pre-existing unique samples coalesce: (x,y) -> (x - k, y + 2k-1) */ return trig(y)/(2.0*Na); } double P7(unsigned int x, unsigned int k, unsigned int Na){ /* Two remaining paired samples doubly coalesce asexually: (x,y) -> (x-k-1,y+2k) */ unsigned int diff = 0; diff = x-k; return trig(diff)/(1.0*Na); } double P8(unsigned int x, unsigned int y, unsigned int k, unsigned int Na){ /* One of the x - k remaining paired samples can coalesce with a unique sample: (x,y) -> (x-k,y+2k-1) */ unsigned int diff = 0; diff = x-k; return (diff*y)/(1.0*Na); } double P9(unsigned int x, unsigned int y, unsigned int k, double geemi, double geeme, double Qmi, double Qme, double sexC, unsigned int nsites){ /* 'Disruptive' gene conversion event (I.e. where at least one bp is in sampled material) */ double outs = 0; if(nsites == 1){ outs = 0; }else if(nsites > 1){ outs = pairGC(x, k, geemi, Qmi) + singGC(y, k, geemi, geeme, Qmi, Qme, sexC); } return outs; } double P10(unsigned int x, unsigned int y, unsigned int k, double mee){ /* A sample migrates to another deme */ return mee*(x + y + k); } double P11(unsigned int y, unsigned int k, double sexC, double rec, double mrec, unsigned int lrec, unsigned int nlrec, unsigned int nlrec2){ /* One of the single samples splits by recombination, creates two new single samples: (x,y) -> (x-k,y+2k+1) */ return ((sexC*rec + mrec)*((lrec - 1)*(y) - nlrec) + (rec + mrec)*((lrec - 1)*(2*k) - nlrec2)); } double P12(unsigned int x, unsigned int k, double geemi, double Qmi, unsigned int nsites){ /* Complete gene conversion, coalesces paired sample into single sample */ double outs = 0; if(nsites == 1){ outs = geemi*(x-k); }else if(nsites > 1){ outs = (2*geemi*(x-k)*(exp(-Qmi)/(1.0*Qmi))); } return outs; } double P13(unsigned int x, unsigned int k, double mrec, unsigned int lrec, unsigned int nlrecx){ /* Mitotic recombination acting on paired sample. Does not change sample partition, instead alters genealogy along samples */ return ((mrec)*((lrec - 1)*((x-k)) - nlrecx)); } double invs1(double Si, double Qin){ /* Inversion of start point, if starting but not ending in tract */ return log(1 + (exp(Qin)-1)*Si)/(1.0*Qin); } double invt1(double Ti, double Qin){ /* Inversion of end point, if starting outside but ending in tract */ return (Qin - log(exp(Qin) + Ti - exp(Qin)*Ti))/(1.0*Qin); } double invs2(double Si, double Qin){ /* Inversion of start point, double GC event (2 bps) */ return exp(-Qin)*(-1.0 + Si + exp(Qin)*(Si*(Qin - 1.0) - gsl_sf_lambert_W0((-1.0)*exp(-Qin + Si*(Qin - 1.0) + exp(-Qin)*(Si-1.0)))))/(1.0*Qin); } double invt2(double Ti, double Si, double Qin){ /* Inversion of endpoint for double GC event (2 bps) */ return Si - (log(1.0 - Ti*(1.0 - exp(-Qin*(1.0 - Si)))))/(1.0*Qin); } /* Calculate probability change vectors each time OVER EACH DEME */ void probset2(unsigned int N, double gmi, double gme, double *sexC, double rec, double mrec, double Qmi, double Qme, unsigned int lrec, unsigned int *nlrec, unsigned int *nlrec2, unsigned int *nlrecx, double mig, unsigned int *Nwith, unsigned int *Nbet, unsigned int *kin, unsigned int sw, double **pr){ unsigned int x; /* Deme counter */ unsigned int ksum = 0; /* Total number of segregating events */ /* First calculate number of splits... */ for(x = 0; x < d; x++){ ksum += *(kin + x); } /* Calculate each transition probability, per deme */ for(x = 0; x < d; x++){ *((*(pr + 4)) + x) = P56(*(Nbet + x),N); *((*(pr + 5)) + x) = P56(*(Nbet + x),N); *((*(pr + 6)) + x) = P7(*(Nwith + x),*(kin + x),N); *((*(pr + 7)) + x) = P8(*(Nwith + x),*(Nbet + x),*(kin + x),N); *((*(pr + 8)) + x) = P9(*(Nwith + x),*(Nbet + x),*(kin + x),gmi,gme,Qmi,Qme,*(sexC + x),nsites); *((*(pr + 9)) + x) = P10(*(Nwith + x),*(Nbet + x),*(kin + x),mig); *((*(pr + 10)) + x) = P11(*(Nbet + x),*(kin + x),*(sexC + x),rec,mrec,lrec,*(nlrec + x),*(nlrec2 + x)); *((*(pr + 11)) + x) = P12(*(Nwith + x),*(kin + x),gmi,Qmi,nsites); *((*(pr + 12)) + x) = P13(*(Nwith + x),*(kin + x),mrec,lrec,*(nlrecx + x)); /* Only activate the first three events if need to consider segregation via sex (fourth is 'split pairs remain split') */ if(sw == 1){ if(ksum != 1){ *((*(pr + 1)) + x) = P23(*(Nbet + x),*(kin + x),N); }else if(ksum == 1){ *((*(pr + 1)) + x) = 0; } *((*(pr + 2)) + x) = P23(*(Nbet + x),*(kin + x),N); *((*(pr + 3)) + x) = P4(*(Nwith + x),*(kin + x),N); /* Last entry is simply 1-(sum all other probs) */ if(x == 0){ *((*(pr + 0)) + x) = (1-sumT_D(pr,13,d)); } }else if(sw == 0){ *((*(pr + 1)) + x) = 0; *((*(pr + 2)) + x) = 0; *((*(pr + 3)) + x) = 0; *((*(pr + 0)) + x) = 0; } } } /* End of 'probset2' function */ /* Function to change rates of sex given a state change */ void rate_change(unsigned int N, unsigned int pST,double pLH, double pHL, double *sexH, double *sexL, unsigned int switch1, double *sexCN, double *sexCNInv, double *tts, unsigned int *npST, const gsl_rng *r){ unsigned int x = 0; /* Deme counter */ /* Setting up transition time (tts, or 'time to switch') */ if(pST == 0){ for(x = 0; x < d; x++){ *(sexCN + x) = *(sexL + x); *(sexCNInv + x) = 1.0 - (*(sexL + x)); } *tts = gsl_ran_geometric(r,pLH)/(2.0*N*d); *npST = 1; }else if(pST == 1){ for(x = 0; x < d; x++){ *(sexCN + x) = *(sexH + x); *(sexCNInv + x) = 1.0 - (*(sexH + x)); } *tts = gsl_ran_geometric(r,pHL)/(2.0*N*d); *npST = 0; }else if(pST == 2){ /* If stepwise change, alter depending on whether already switched or not */ *npST = pST; if(switch1 == 0){ for(x = 0; x < d; x++){ *(sexCN + x) = *(sexL + x); *(sexCNInv + x) = 1.0 - (*(sexL + x)); } *tts = pLH; }else if(switch1 == 1){ for(x = 0; x < d; x++){ *(sexCN + x) = *(sexH + x); *(sexCNInv + x) = 1.0 - (*(sexH + x)); } *tts = (1.0/0.0); } }else if(pST == 3){ /* If constant, no time to sex switch */ for(x = 0; x < d; x++){ *(sexCN + x) = *(sexL + x); *(sexCNInv + x) = 1.0 - (*(sexL + x)); } *tts = (1.0/0.0); *npST = pST; } } /* End of 'rate_change' function */ /* Function to determine how to change state numbers following an event, taking into account events over all demes*/ void stchange2(unsigned int ev, unsigned int deme, unsigned int *kin, int *WCH, int *BCH){ int *oo3 = calloc(2,sizeof(int)); /* Extra change in pop due to event */ int *negk = calloc(d,sizeof(int)); /* Negative of k */ int *dblek = calloc(d,sizeof(int)); /* Double k */ /* Rescaling k */ smultI_UI(negk, kin, d, (-1)); smultI_UI(dblek, kin, d, 2); /* Baseline sex events */ vcopyI(WCH, negk, d); vcopyI(BCH, dblek, d); /* Now deciding extra events depending on deme and event */ switch(ev) { case 0: *(oo3 + 0) = 0; *(oo3 + 1) = 0; break; case 1: *(oo3 + 0) = 1; *(oo3 + 1) = -2; break; case 2: *(oo3 + 0) = 0; *(oo3 + 1) = -1; break; case 3: *(oo3 + 0) = 0; *(oo3 + 1) = -1; break; case 4: *(oo3 + 0) = 1; *(oo3 + 1) = -2; break; case 5: *(oo3 + 0) = 0; *(oo3 + 1) = -1; break; case 6: *(oo3 + 0) = -1; *(oo3 + 1) = 0; break; case 7: *(oo3 + 0) = 0; *(oo3 + 1) = -1; break; case 8: *(oo3 + 0) = 0; *(oo3 + 1) = 0; break; case 9: *(oo3 + 0) = 0; *(oo3 + 1) = 0; break; case 10: *(oo3 + 0) = 1; *(oo3 + 1) = -1; break; case 11: *(oo3 + 0) = -1; *(oo3 + 1) = 1; break; case 12: *(oo3 + 0) = 0; *(oo3 + 1) = 0; break; default: /* If none of these cases chosen, exit with error message */ fprintf(stderr,"Error: Non-standard coalescent case selected ('stchange2').\n"); exit(1); break; } *(WCH + deme) += *(oo3 + 0); *(BCH + deme) += *(oo3 + 1); free(dblek); free(negk); free(oo3); } /* End of 'stchange' function */ /* For converting WH to BH */ void sexconv(unsigned int **Tin, unsigned int *rsex, unsigned int nsum, unsigned int Ntot, unsigned int Nid, unsigned int ex){ unsigned int j; unsigned int count = 0; unsigned int npc = 0; while(count < nsum){ for(j = 0; j < Ntot; j++){ if( *((*(Tin + j)) + 1) == *(rsex + count) ){ *((*(Tin + j)) + 2) = 1; *((*(Tin + j + 1)) + 2) = 1; /* Since other paired sample also split */ if(ex == 8 || ex == 10){ *((*(Tin + j + 1)) + 1) = Nid + npc; /* Placing sample in *same* individual with rec or GC */ npc++; } count++; break; } } } } /* Function to change status of samples following event change */ unsigned int coalesce(unsigned int **indvs, int **GType, double **CTms , int **TAnc, unsigned int **nlri, unsigned int **nlrix, double Ttot, unsigned int *Nwith, unsigned int *Nbet, unsigned int deme, unsigned int *rsex, unsigned int *nsex, unsigned int ex, unsigned int drec, unsigned int e2, unsigned int **breaks, unsigned int nsites, unsigned int *nbreaks, unsigned int NMax, unsigned int Itot, double gmi, double gme, double Qmi, double Qme, unsigned int *gcalt, double *sexC, int *WCHex, int *BCHex, const gsl_rng *r, unsigned int ei){ unsigned int NWtot = 2*sumUI(Nwith,d); unsigned int NBtot = sumUI(Nbet,d); unsigned int Ntot = NWtot + NBtot; unsigned int Nindv = sumUI(Nwith,d) + sumUI(Nbet,d); unsigned int NindvW = sumUI(Nwith,d); unsigned int nsum = sumUI(nsex,d); unsigned int j = 0; unsigned int a = 0; int x = 0; unsigned int count = 0; /* For converting WH to BH samples */ unsigned int done = 0; /* For sampling right individual */ unsigned int rands = 0; /* Sample split by rec (event 10) */ unsigned int rands2 = 0; /* Sample that does not split fully (event 1; also used in event 8) */ unsigned int rands3 = 0; /* Other chromosome arm during mitotic rec event (event 12) */ unsigned int nos = 0; /* Sub-sample that does not split fully (event 1) */ unsigned int bhc = 0; /* Single sample that repairs (ev 1) or migrates (ev 9); */ unsigned int csamp = 0; /* Sample that coalesces */ unsigned int par = 0; /* Parental sample in coalescence */ unsigned int par2 = 0; /* Parental sample of paired coalescence (ev 2) */ unsigned int WHsel = 0; /* WH sample involved in event (ev 7) */ unsigned int isWH = 0; /* Is the sample from WH? (ev 7) */ unsigned int parNo = 0; /* Parent where coalescent occurs (event 6) */ unsigned int rsite = 0; /* Position of recombination breakpoint (event 10) */ unsigned int isyetbp = 0; /* Is breakpoint already present? (event 10) */ unsigned int isyetbp2 = 0; /* Is 2nd breakpoint already present? (event 8) */ unsigned int maxtr = 0; /* Max site in bp table before breakpoint (event 10) */ unsigned int mintr = 0; /* Start of GC event (event 8) */ unsigned int gt = 0; /* GC acting on single or paired sample? (event 8) */ int gcst = 0; /* GC start point (event 8) */ int gcend = 0; /* GC end point (event 8) */ unsigned int gcsamp = 0; /* Index of GC'ed sample (event 8) */ unsigned int gcsamp2 = 0; /* Index of GC'ed sample if paired sample involved (event 8) */ double NWd = 0; /* Weighted WH sample chosen (event 8) */ double NTd = 0; /* Total GC prob (ev 8) */ double gcMI = 0; /* Probability that single samp GC event is mitotic (event 8) */ double Qin = 0; /* Q value used in subsequent calcs (event 8) */ double gcst2 = 0; /* Initial start site for GC (event 8) */ double gcend2 = 0; /* Initial end site for GC (event 8) */ double p1bp = 0; /* Prob 1 breakpoint (event 8) */ unsigned int gcst3 = 0; unsigned int gcS = 0; /* Type of GC evening on unpaired samples (event 8) */ unsigned int mindr = 0; /* Done choosing min tract point? (event 8) */ unsigned int proceed = 0; /* Proceed with gene conversion? (event 8) */ unsigned int maxck = 0; /* Check if end of bp correctly chosen (event 8) */ unsigned int iscoal = 0; /* Check if paired GC event leads to coalescence (event 8) */ unsigned int rpar = 0; /* Indv number of recombined sample (event 10) */ unsigned int gcbp = 0; /* Type of GC event (1 or 2 breakpoints; event 8) */ unsigned int achange = 0; /* Note whether to run extra coal check */ unsigned int length = 0; /* Length of sampled chrom (event 10) */ unsigned int start = 0; /* Start of sampled chrom (event 10) */ unsigned int ctype = 0; /* Coalesced type if mitotic rec creates non-ancestral tract (event 12) */ int tempGT = 0; /* Temporary storage of genotype entry during mitotic recombination (event 12) */ /* Then further actions based on other event */ switch(ex) { case 0: /* Event 0: 2k new samples created from paired samples. Nothing else to be done */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); break; case 1: /* Event 1: One of the paired samples is recreated, no coalescence */ /* First choose sample that does not split fully */ while(done == 0){ gsl_ran_choose(r,&rands2,1,rsex,nsum,sizeof(unsigned int)); /* Then checking it is in the same deme as the action */ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 1) == rands2 ){ if(*((*(indvs + j)) + 3) == deme){ done = 1; } } } } /* Then setting BH samples */ nos = gsl_ran_bernoulli(r,0.5); /* Only sample that splits fully */ while(count < nsum){ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 1) == *(rsex + count) ){ if(*(rsex + count) != rands2){ *((*(indvs + j)) + 2) = 1; *((*(indvs + j + 1)) + 2) = 1; *((*(indvs + j + 1)) + 1) = (Nindv + count); count++; }else if(*(rsex + count) == rands2){ *((*(indvs + j + nos)) + 2) = 1; *((*(indvs + j + nos)) + 1) = (Nindv + count); count++; } break; } } } /* Now; out of all single samples, choose one to rebind with the single sample */ unsigned int *singsamps = calloc((*(Nbet + deme) + 2*(*(nsex + deme)) - 1),sizeof(unsigned int)); /* For storing BH samples */ sselect_UI(indvs, singsamps, Ntot, 2, 0, 1, 3, deme); gsl_ran_choose(r,&bhc,1,singsamps,(*(Nbet + deme) + 2*(*(nsex + deme)) - 1),sizeof(unsigned int)); for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 0) == bhc ){ *((*(indvs + j)) + 2) = 0; *((*(indvs + j)) + 1) = rands2; /* Ensuring paired samples have same parents*/ break; } } free(singsamps); break; case 2: /* Event 2: One of the unique samples coaleses with another unique one (either pre-existing or new) */ done = 0; sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); unsigned int *singsamps2 = calloc((*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(unsigned int)); /* For storing BH samples */ sselect_UI(indvs, singsamps2, Ntot, 2, 0, 1, 3, deme); while(done == 0){ gsl_ran_choose(r,&csamp,1,singsamps2,(*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(unsigned int)); /* One sample involved in coalescence (csamp) */ par = csamp; while(par == csamp){ /* Ensuring par != csamp */ gsl_ran_choose(r,&par,1,singsamps2,(*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(unsigned int)); /* Other sample involved in coalescence (par) */ } /* Now checking that at least one of the two is from sample split by sex */ for(j = 0; j < Ntot; j++){ if( (*((*(indvs + j)) + 0) == csamp) || (*((*(indvs + j)) + 0) == par) ){ for(a = 0; a < nsum; a++){ if( (*((*(indvs + j)) + 1)) == *(rsex + a)){ done = 1; break; } } } } } /* Now updating coalescent times */ cchange(indvs, GType, CTms, TAnc, breaks, &csamp, &par, 1, Ntot, 0, nbreaks, Ttot, 1); /* Check if tracts have coalesced */ achange = ccheck(indvs,GType,breaks,nsites,Ntot,*nbreaks); if(achange == 1){ excoal(indvs, GType, &par, *nbreaks, 1, Ntot, WCHex, BCHex, deme); } free(singsamps2); break; case 3: /* Event 3: A paired sample coaleses with new unique sample */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); unsigned int *singsamps3N = calloc(2*(*(nsex + deme)),sizeof(unsigned int)); /* For storing new BH samples */ unsigned int *singsamps3B = calloc( 2*((*(Nwith + deme) - (*(nsex + deme)))) ,sizeof(unsigned int)); /* For storing WH samples */ unsigned int *twosamps = calloc(2,sizeof(unsigned int)); /* Two samples in coalescence */ /* Creating vector of new unique samples created */ sselect_UIV(indvs, singsamps3N, Ntot, 1, 0, rsex, 2*(*(nsex + deme)), nsum, 3, deme); /* Creating vector of existing paired samples */ sselect_UI(indvs, singsamps3B, Ntot, 2, 0, 0, 3, deme); gsl_ran_choose(r,&twosamps[0],1,singsamps3N,(2*(*(nsex + deme))),sizeof(unsigned int)); /* Unique sample involved in coalescence */ gsl_ran_choose(r,&twosamps[1],1,singsamps3B,(2*((*(Nwith + deme) - (*(nsex + deme))))),sizeof(unsigned int)); /* Paired sample involved in coalescence */ gsl_ran_choose(r,&csamp,1,twosamps,2,sizeof(unsigned int)); /* One sample involved in coalescence (csamp) */ par = csamp; while(par == csamp){ /* Ensuring par != csamp */ gsl_ran_choose(r,&par,1,twosamps,2,sizeof(unsigned int)); /* Other sample involved in coalescence (par) */ } /* Correction if parential sample is unique sample */ unsigned int pcorr = 0; for(j = 0; j < Ntot; j++){ if( (*((*(indvs + j)) + 0) == par) && (*((*(indvs + j)) + 2) == 1) ){ pcorr = 1; par2 = j; (*((*(indvs + j)) + 2) = 0); break; } } if(pcorr == 1){ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == csamp){ *((*(indvs + par2)) + 1) = *((*(indvs + j)) + 1); break; } } } /* Now updating coalescent times */ cchange(indvs, GType, CTms, TAnc, breaks, &csamp, &par, 1, Ntot, 0, nbreaks, Ttot, 1); /* Check if tracts have coalesced */ achange = ccheck(indvs,GType,breaks,nsites,Ntot,*nbreaks); if(achange == 1){ excoal(indvs, GType, &par, *nbreaks, 1, Ntot, WCHex, BCHex, deme); } free(twosamps); free(singsamps3B); free(singsamps3N); break; case 4: /* Event 4: Two pre-existing unique samples re-create paired sample. */ done = 0; unsigned int *singsamps4 = calloc(*(Nbet + deme),sizeof(unsigned int)); /* For storing BH samples */ unsigned int *twosing = calloc(2,sizeof(unsigned int)); sselect_UI(indvs, singsamps4, Ntot, 2, 0, 1, 3, deme); /* Two sample involved in pairing */ gsl_ran_choose(r,twosing,2,singsamps4,*(Nbet + deme),sizeof(unsigned int)); gsl_ran_shuffle(r, twosing, 2, sizeof(unsigned int)); /* Now going through (twice!) and updating ancestry */ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == *(twosing + 0)){ par2 = j; *((*(indvs + j)) + 2) = 0; break; } } for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == *(twosing + 1)){ *((*(indvs + j)) + 2) = 0; *((*(indvs + j)) + 1) = *((*(indvs + par2)) + 1); break; } } /* THEN convert WH to BH samples */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); free(twosing); free(singsamps4); break; case 5: /* Event 5: Two pre-existing unique samples coalesce */ csamp = 0; unsigned int *singsamps5 = calloc(*(Nbet + deme),sizeof(unsigned int)); /* For storing BH samples */ sselect_UI(indvs, singsamps5, Ntot, 2, 0, 1, 3, deme); gsl_ran_choose(r,&csamp,1,singsamps5,(*(Nbet + deme)),sizeof(unsigned int)); /* One sample involved in coalescence (csamp) */ par = csamp; while(par == csamp){ /* Ensuring par != csamp */ gsl_ran_choose(r,&par,1,singsamps5,(*(Nbet + deme)),sizeof(unsigned int)); /* Other sample involved in coalescence (par) */ } /* Now updating coalescent times */ cchange(indvs, GType, CTms, TAnc, breaks, &csamp, &par, 1, Ntot, 0, nbreaks, Ttot, 1); /* Check if tracts have coalesced */ achange = ccheck(indvs,GType,breaks,nsites,Ntot,*nbreaks); if(achange == 1){ excoal(indvs, GType, &par, *nbreaks, 1, Ntot, WCHex, BCHex, deme); } /* THEN convert WH to BH samples */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); free(singsamps5); break; case 6: /* Event 6: Two remaining paired samples doubly coalesce asexually. */ /* Converting WH to BH samples */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); unsigned int *parsamps6 = calloc((*(Nwith + deme) - *(nsex + deme)),sizeof(unsigned int)); /* For storing WH indvs */ unsigned int *twopars6 = calloc(2,sizeof(unsigned int)); unsigned int *lhs = calloc(2,sizeof(unsigned int)); unsigned int *rhs = calloc(2,sizeof(unsigned int)); unsigned int *csamp2 = calloc(2,sizeof(unsigned int)); unsigned int *parT = calloc(2,sizeof(unsigned int)); sselect_UI(indvs, parsamps6, Ntot, 2, 1, 0, 3, deme); /* Two parents involved in coalescence */ gsl_ran_choose(r,twopars6,2,parsamps6,(*(Nwith + deme) - *(nsex + deme)),sizeof(unsigned int)); gsl_ran_shuffle(r,twopars6, 2, sizeof(unsigned int)); /* Finding parents and partitioning samples (twice) */ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 1) == *(twopars6 + 0)){ *(lhs + 0) = *((*(indvs + j)) + 0); *(rhs + 0) = *((*(indvs + j + 1)) + 0); break; } } for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 1) == *(twopars6 + 1)){ *(lhs + 1) = *((*(indvs + j)) + 0); *(rhs + 1) = *((*(indvs + j + 1)) + 0); break; } } /* Now assigning coalesced and parental samples respectively */ gsl_ran_choose(r,&csamp2[0],1,lhs,2,sizeof(unsigned int)); parT[0] = csamp2[0]; while(parT[0] == csamp2[0]){ gsl_ran_choose(r,&parT[0],1,lhs,2,sizeof(unsigned int)); } gsl_ran_choose(r,&csamp2[1],1,rhs,2,sizeof(unsigned int)); parT[1] = csamp2[1]; while(parT[1] == csamp2[1]){ gsl_ran_choose(r,&parT[1],1,rhs,2,sizeof(unsigned int)); } /* Now updating coalescent times */ cchange(indvs, GType, CTms, TAnc, breaks, csamp2, parT, 2, Ntot, 0, nbreaks, Ttot, 1); /* Check if tracts have coalesced */ achange = ccheck(indvs,GType,breaks,nsites,Ntot,*nbreaks); /* Making sure parent samples are in same individual */ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == parT[0]){ parNo = *((*(indvs + j)) + 1); break; } } for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == parT[1]){ *((*(indvs + j)) + 1) = parNo; break; } } if(achange == 1){ excoal(indvs, GType, parT, *nbreaks, 2, Ntot, WCHex, BCHex, deme); } free(parT); free(csamp2); free(rhs); free(lhs); free(twopars6); free(parsamps6); break; case 7: /* Event 7: One of the x - k remaining paired samples coalesces with a unique sample */ /* Converting WH to BH samples (idea being that I later check if chosen BH originated from WH - discard if so) */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); /* For storing WH indvs */ unsigned int *parsamps7 = calloc((*(Nwith + deme) - *(nsex + deme)),sizeof(unsigned int)); unsigned int *singsamps7 = calloc((*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(unsigned int)); /* For storing BH samples */ unsigned int *twosamps7 = calloc(2,sizeof(unsigned int)); sselect_UI(indvs, parsamps7, Ntot, 2, 1, 0, 3, deme); sselect_UI(indvs, singsamps7, Ntot, 2, 0, 1, 3, deme); /* A paired sample involved in coalescence */ gsl_ran_choose(r,&WHsel,1,parsamps7,(*(Nwith + deme) - *(nsex + deme)),sizeof(unsigned int)); nos = gsl_ran_bernoulli(r,0.5); /* Which side involved in event */ /* Finding sample */ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 1) == WHsel){ *(twosamps7 + 0) = *((*(indvs + j + nos)) + 0); break; } } /* Choosing BH sample */ while(done == 0){ gsl_ran_choose(r,&twosamps7[1],1,singsamps7,(*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(unsigned int)); /* Checking that it didn't originate from WH */ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == *(twosamps7 + 1)){ /* ACTIONS */ isWH = 1; for(a = 0; a < nsum; a++){ if( *((*(indvs + j)) + 1) == *(rsex + a)){ isWH = 0; } } if(isWH == 1){ done = 1; } break; } } } /* Choosing csamp, par */ gsl_ran_choose(r,&csamp,1,twosamps7,2,sizeof(unsigned int)); /* One sample involved in coalescence (csamp) */ par = csamp; while(par == csamp){ /* Ensuring par != csamp */ gsl_ran_choose(r,&par,1,twosamps7,2,sizeof(unsigned int)); /* Other sample involved in coalescence (par) */ } /* Correction if parental sample is BH */ if(par == *(twosamps7 + 1)){ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == par){ *((*(indvs + j)) + 2) = 0; *((*(indvs + j)) + 1) = WHsel; /* Same parent as WH sample */ break; } } } /* Now updating coalescent times */ cchange(indvs, GType, CTms, TAnc, breaks, &csamp, &par, 1, Ntot, 0, nbreaks, Ttot, 1); /* Check if tracts have coalesced */ achange = ccheck(indvs,GType,breaks,nsites,Ntot,*nbreaks); if(achange == 1){ excoal(indvs, GType, &par, *nbreaks, 1, Ntot, WCHex, BCHex, deme); } free(twosamps7); free(singsamps7); free(parsamps7); break; case 8: /* Event 8: (Partial) Gene conversion */ /* Converting WH to BH samples */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); /* First, is it a paired or single sample that is affected? */ NWd = pairGC(*(Nwith + deme), *(nsex + deme), gmi, Qmi); NTd = NWd + singGC(*(Nbet + deme), *(nsex + deme), gmi, gme, Qmi, Qme, *(sexC + deme)); gt = gsl_ran_bernoulli(r,(NWd/(1.0*NTd))); if(gt == 0){ /* Acts on single sample */ unsigned int *singsamps8 = calloc((*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(unsigned int)); /* Obtaining list of samples to choose from */ sselect_UI(indvs, singsamps8, Ntot, 2, 0, 1, 3, deme); /* Sample that undergoes GC */ gsl_ran_choose(r,&rands,1,singsamps8,(*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(unsigned int)); for(j = 0; j < NMax; j++){ if( *((*(GType + j)) + 0) == rands){ gcsamp = j; break; } } /* Then choosing type of event */ gcMI = ((gmi*(2.0-KQ(Qmi))*((*(Nbet + deme)) + 2*(*(nsex + deme))))/(1.0*singGC(*(Nbet + deme), *(nsex + deme), gmi, gme, Qmi, Qme, *(sexC + deme)))); gcS = gsl_ran_bernoulli(r,gcMI); if(gcS == 0){ Qin = Qme; }else if(gcS == 1){ Qin = Qmi; } free(singsamps8); }else if(gt == 1){ /* Acts on paired sample */ Qin = Qmi; unsigned int *parsamps8 = calloc((*(Nwith + deme) - *(nsex + deme)),sizeof(unsigned int)); /* Obtaining list of samples to choose from */ sselect_UI(indvs, parsamps8, Ntot, 2, 1, 0, 3, deme); /* Sample that undergoes GC */ gsl_ran_choose(r,&rands,1,parsamps8,(*(Nwith + deme) - *(nsex + deme)),sizeof(unsigned int)); rands2 = gsl_ran_bernoulli(r,0.5); for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 1) == rands){ gcsamp = *((*(indvs + j + rands2)) + 0); gcsamp2 = *((*(indvs + j + (rands2 + 1)%2)) + 0); break; } } free(parsamps8); } /* Now determining type of GC event. */ /* Does there exist one or two breakpoints? */ if(nsites == 2){ gcbp = 1; }else if(nsites > 2){ p1bp = 2.0*((1-KQ(Qin))/(1.0*(2.0-KQ(Qin)))); gcbp = gsl_ran_bernoulli(r,p1bp); } if(gcbp == 0){ /* Two breakpoints */ gcst = 0; gcend = nsites; while(gcst == 0 || gcst >= (nsites-1)){ gcst2 = gsl_ran_flat(r, 0, 1); gcst = (unsigned int)(invs2(gcst2,Qin)*nsites); } while(gcend == 0 || gcend == nsites || gcend == gcst){ gcend2 = gsl_ran_flat(r, 0, 1); gcend = (unsigned int)(invt2(gcend2, (gcst/(1.0*nsites)), Qin)*nsites); } }else if(gcbp == 1){ /* One breakpoint */ gcst3 = gsl_ran_bernoulli(r,0.5); if(gcst3 == 0){ /* Starts outside, ends in */ gcst = 0; gcend = 0; while(gcend == 0 || gcend == nsites){ gcend2 = gsl_ran_flat(r, 0, 1); gcend = (unsigned int)(invt1(gcend2,Qin)*nsites); } }else if(gcst3 == 1){ /* Starts inside, ends out */ gcend = nsites; gcst = 0; while(gcst == 0 || gcst == nsites){ gcst2 = gsl_ran_flat(r, 0, 1); gcst = (unsigned int)(invs1(gcst2,Qin)*nsites); } } } /* Finding block number associated with start point */ mindr = 0; for(x = 0; x < *nbreaks; x++){ if( *((*(breaks + 0)) + x) == gcst){ isyetbp = 1; } if( *((*(breaks + 0)) + x) > gcst){ mintr = (x-1); mindr = 1; break; } } if(mindr == 0){ /* GC start past end of current breakpoints, so need to force it */ mintr = ((*nbreaks)-1); } /* Inserting new, start BP if needed */ if((isyetbp != 1) && (*((*(GType + gcsamp)) + mintr + 1) != (-1))){ (*nbreaks)++; for(x = *nbreaks-2; x >= (int)(mintr+1); x--){ *((*(breaks + 0)) + x + 1) = *((*(breaks + 0)) + x); *((*(breaks + 1)) + x + 1) = *((*(breaks + 1)) + x); } *((*(breaks + 0)) + mintr + 1) = gcst; *((*(breaks + 1)) + mintr + 1) = 0; /* Adding new site to genotype; coalescent time; ancestry table */ for(j = 0; j < NMax; j++){ for(x = (*nbreaks-1); x > (int)(mintr); x--){ *((*(GType + j)) + x + 1) = *((*(GType + j)) + x); if(j < Itot){ *((*(CTms + j)) + x + 1) = *((*(CTms + j)) + x); *((*(TAnc + j)) + x + 1) = *((*(TAnc + j)) + x); } } } mintr++; } /* Finding block number associated with end point */ maxck = 0; for(x = 0; x < *nbreaks; x++){ if( *((*(breaks + 0)) + x) == gcend){ isyetbp2 = 1; } if( *((*(breaks + 0)) + x) > gcend){ maxtr = (x-1); maxck = 1; break; } } if(maxck == 0 && (gcend != nsites) && (gcend != 0)){ /* If endpoint not found amongst existing bps, must be at end */ maxtr = ((*nbreaks)-1); }else if(maxck == 0 && (gcend == nsites)){ maxtr = (*nbreaks); isyetbp2 = 1; } /* Inserting new, end BP if needed */ if((isyetbp2 != 1) && (*((*(GType + gcsamp)) + maxtr + 1) != (-1))){ (*nbreaks)++; for(x = *nbreaks-2; x >= (int)(maxtr + 1); x--){ *((*(breaks + 0)) + x + 1) = *((*(breaks + 0)) + x); *((*(breaks + 1)) + x + 1) = *((*(breaks + 1)) + x); } *((*(breaks + 0)) + maxtr + 1) = gcend; *((*(breaks + 1)) + maxtr + 1) = 0; /* Adding new site to genotype; coalescent time; ancestry table */ for(j = 0; j < NMax; j++){ for(x = (*nbreaks-1); x > (int)(maxtr); x--){ *((*(GType + j)) + x + 1) = *((*(GType + j)) + x); if(j < Itot){ *((*(CTms + j)) + x + 1) = *((*(CTms + j)) + x); *((*(TAnc + j)) + x + 1) = *((*(TAnc + j)) + x); } } } maxtr++; } /* ONLY PROCEED (in single-sample case) IF NOT ALL SITES EMPTY */ if(gt == 0 && (isallI((*(GType + gcsamp)), (maxtr + 1), (-1), (mintr + 1)) != 1) && ((isallI((*(GType + gcsamp)), (mintr + 1), (-1), 1) != 1) || (isallI((*(GType + gcsamp)), (*nbreaks + 1), (-1), (maxtr + 1)) != 1))){ proceed = 1; } if(proceed == 1){ *gcalt = 1; /* First, checking parent number of existing sample, setting as paired */ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 0) == gcsamp){ rpar = *((*(indvs + j)) + 1); *((*(indvs + j)) + 2) = 0; break; } } /* Adding new sample to indv table */ *((*(indvs + NMax)) + 0) = NMax; *((*(indvs + NMax)) + 1) = rpar; *((*(indvs + NMax)) + 2) = 0; *((*(indvs + NMax)) + 3) = deme; /* Now creating the new sample genotype; updating all other tables */ for(x = (maxtr); x > (int)(mintr); x--){ *((*(GType + NMax)) + x) = *((*(GType + gcsamp)) + x); *((*(GType + gcsamp)) + x) = (-1); } for(x = (*nbreaks); x > (int)(maxtr); x--){ *((*(GType + NMax)) + x) = (-1); } for(x = (mintr); x > (int)0; x--){ *((*(GType + NMax)) + x) = (-1); } *((*(GType + NMax)) + 0) = NMax; } /* With paired GC, we have part coalescence instead */ if(gt == 1){ csamp = gcsamp; par = gcsamp2; if( ( (isallI((*(GType + gcsamp)), (mintr+1), (-1), 1) == 1) ) && ( (isallI((*(GType + gcsamp)), (*nbreaks+1), (-1), (maxtr+1)) == 1) ) ){ iscoal = 1; } if(iscoal == 1){ *gcalt = 2; /* Making sure remaining sample becomes BH */ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 0) == gcsamp2){ *((*(indvs + j)) + 2) = 1; break; } } } /* Now updating coalescent times */ cchange(indvs, GType, CTms, TAnc, breaks, &csamp, &par, 1, Ntot, mintr, &maxtr, Ttot, iscoal); /* Check if tracts have coalesced */ achange = ccheck(indvs,GType,breaks,nsites,Ntot,*nbreaks); if(achange == 1){ excoal(indvs, GType, &par, *nbreaks, 1, Ntot, WCHex, BCHex, deme); } } break; case 9: /* Event 9: Migration of a sample */ /* Converting WH to BH samples */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); if(e2 == 0){ /* WH sample migrates */ /* For storing WH indvs */ unsigned int *parsamps9 = calloc((*(Nwith + deme) + 1),sizeof(unsigned int)); /* Obtaining list of samples to choose from */ sselect_UI(indvs, parsamps9, Ntot, 2, 1, 0, 3, deme); /* Sample that migrates */ gsl_ran_choose(r,&bhc,1,parsamps9,(*(Nwith + deme) + 1),sizeof(unsigned int)); for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 1) == bhc){ *((*(indvs + j)) + 3) = drec; *((*(indvs + j + 1)) + 3) = drec; /* Altering deme accordingly */ break; } } free(parsamps9); }else if(e2 == 1){ /* BH sample migrates */ /* For storing BH samples */ unsigned int *singsamps9 = calloc((*(Nbet + deme) + 1),sizeof(unsigned int)); /* Obtaining list of samples to choose from */ sselect_UI(indvs, singsamps9, Ntot, 2, 0, 1, 3, deme); /* Sample that migrates */ gsl_ran_choose(r,&bhc,1,singsamps9,(*(Nbet + deme) + 1),sizeof(unsigned int)); for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == bhc){ *((*(indvs + j)) + 3) = drec; /* Altering deme accordingly */ break; } } free(singsamps9); } break; case 10: /* Event 10: Recombination - splitting a sample to create a new one */ /* Converting WH to BH samples */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); /* For storing BH weights */ double *weights10 = calloc((*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(double)); double *singsamps10 = calloc((*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(double)); double *startp = calloc((*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(double)); /* Obtaining weights of each sample */ count = 0; while(count < (*(Nbet + deme) + 2*(*(nsex + deme)))){ for(j = 0; j < (NBtot + 2*nsum); j++){ if( *((*(nlri + j)) + 3) == deme){ *(weights10 + count) = *((*(nlri + j)) + 2); *(startp + count) = *((*(nlri + j)) + 1); *(singsamps10 + count) = *((*(nlri + j)) + 0); count++; } } } /* For storing BH samples */ unsigned int *singsamps10a = calloc((*(Nbet + deme) + 2*(*(nsex + deme))),sizeof(unsigned int)); /* Choosing single sample to be split in recombination */ gsl_ran_multinomial(r,(*(Nbet + deme) + 2*(*(nsex + deme))),1,weights10,singsamps10a); /* Matching choice to sample */ for(j = 0; j < (*(Nbet + deme) + 2*(*(nsex + deme))); j++){ if(*(singsamps10a + j) == 1){ rands = *(singsamps10 + j); length = *(weights10 + j); start = *(startp + j); break; } } free(singsamps10a); rsite = gsl_rng_uniform_int(r,length) + (start + 1); if(*nbreaks == 1){ isyetbp = 0; /* isbpend = 1; */ maxtr = 1; }else if(*nbreaks > 1){ /* First, check if (1) rsite is already in existing table of breakpoints; and (2) if so, breakpoint included at end of existing table */ isyetbp = 0; maxtr = 0; for(x = 0; x < *nbreaks; x++){ if( *((*(breaks + 0)) + x) == rsite){ isyetbp = 1; } if( *((*(breaks + 0)) + x) <= rsite){ maxtr = (x+1); } } } /* Adding new site and re-ordering tracts in other tables */ if((isyetbp != 1) && (*((*(GType + rands)) + maxtr) != (-1)) ){ (*nbreaks)++; for(x = *nbreaks-2; x >= (int)(maxtr-1); x--){ *((*(breaks + 0)) + x + 1) = *((*(breaks + 0)) + x); *((*(breaks + 1)) + x + 1) = *((*(breaks + 1)) + x); } *((*(breaks + 0)) + maxtr) = rsite; *((*(breaks + 1)) + maxtr) = *((*(breaks + 1)) + maxtr - 1); /* Adding new site to genotype; coalescent time; ancestry table */ for(j = 0; j < NMax; j++){ for(x = (*nbreaks-1); x >= (int)(maxtr); x--){ *((*(GType + j)) + x + 1) = *((*(GType + j)) + x); if(j < Itot){ *((*(CTms + j)) + x + 1) = *((*(CTms + j)) + x); *((*(TAnc + j)) + x + 1) = *((*(TAnc + j)) + x); } } } }else if((isyetbp == 1) || (*((*(GType + rands)) + maxtr) == (-1) )){ maxtr--; } /* First, checking parent number of existing sample, setting as paired */ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 0) == rands){ rpar = *((*(indvs + j)) + 1); *((*(indvs + j)) + 2) = 0; break; } } /* Adding new sample to indv table */ *((*(indvs + NMax)) + 0) = NMax; *((*(indvs + NMax)) + 1) = rpar; *((*(indvs + NMax)) + 2) = 0; *((*(indvs + NMax)) + 3) = deme; /* Now creating the new sample genotype */ for(j = 0; j < NMax; j++){ if( *((*(GType + j)) + 0) == rands ){ for(x = (*nbreaks); x > (int)maxtr; x--){ *((*(GType + NMax)) + x) = *((*(GType + j)) + x); *((*(GType + j)) + x) = (-1); } break; } } for(x = maxtr; x > (int)0; x--){ *((*(GType + NMax)) + x) = (-1); } *((*(GType + NMax)) + 0) = NMax; free(startp); free(singsamps10); free(weights10); break; case 11: /* Converting WH to BH samples */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); /* For storing WH indvs */ unsigned int *parsamps11 = calloc((*(Nwith + deme) - *(nsex + deme)),sizeof(unsigned int)); sselect_UI(indvs, parsamps11, Ntot, 2, 1, 0, 3, deme); /* A paired sample involved in coalescence */ gsl_ran_choose(r,&WHsel,1,parsamps11,(*(Nwith + deme) - *(nsex + deme)),sizeof(unsigned int)); nos = gsl_ran_bernoulli(r,0.5); /* Which side involved in event */ /* Finding sample */ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 1) == WHsel){ csamp = *((*(indvs + j + nos)) + 0); par = *((*(indvs + j + (nos+1)%2)) + 0); *((*(indvs + j + (nos+1)%2)) + 2) = 1; /* Setting 'par' as BH */ break; } } /* Now updating coalescent times */ cchange(indvs, GType, CTms, TAnc, breaks, &csamp, &par, 1, Ntot, 0, nbreaks, Ttot, 1); /* Check if tracts have coalesced */ achange = ccheck(indvs,GType,breaks,nsites,Ntot,*nbreaks); if(achange == 1){ excoal(indvs, GType, &par, *nbreaks, 1, Ntot, WCHex, BCHex, deme); } free(parsamps11); break; case 12: /* Event 12: Mitotic Recombination - exchanging coalescent histories within paired samples */ /* Converting WH to BH samples */ sexconv(indvs, rsex, nsum, Ntot, Nindv, ex); /* For storing WH weights */ double *weights12 = calloc((*(Nwith + deme) - *(nsex + deme)),sizeof(double)); double *parsamps12 = calloc((*(Nwith + deme) - *(nsex + deme)),sizeof(double)); double *startp12 = calloc((*(Nwith + deme) - *(nsex + deme)),sizeof(double)); /* Obtaining weights of each sample */ count = 0; while(count < (*(Nwith + deme) - *(nsex + deme))){ for(j = 0; j < (NindvW - nsum); j++){ if( *((*(nlrix + j)) + 3) == deme){ *(weights12 + count) = *((*(nlrix + j)) + 2); *(startp12 + count) = *((*(nlrix + j)) + 1); *(parsamps12 + count) = *((*(nlrix + j)) + 0); count++; } } } /* For storing BH samples */ unsigned int *parsamps12a = calloc(((*(Nwith + deme) - *(nsex + deme))),sizeof(unsigned int)); /* Choosing single sample to be split in recombination */ gsl_ran_multinomial(r,(*(Nwith + deme) - *(nsex + deme)),1,weights12,parsamps12a); /* Matching choice to sample */ for(j = 0; j < ((*(Nwith + deme) - *(nsex + deme))); j++){ if(*(parsamps12a + j) == 1){ rands = *(parsamps12 + j); length = *(weights12 + j); start = *(startp12 + j); break; } } free(parsamps12a); /* Then finding haplotypes associated with pair */ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 1) == rands){ rands2 = *((*(indvs + j)) + 0); rands3 = *((*(indvs + j + 1)) + 0); break; } } rsite = gsl_rng_uniform_int(r,length) + (start + 1); /* printf("Indv %d has bp at %d\n",rands,rsite); */ if(*nbreaks == 1){ isyetbp = 0; maxtr = 1; }else if(*nbreaks > 1){ /* First, check if (1) rsite is already in existing table of breakpoints; and (2) if so, breakpoint included at end of existing table */ isyetbp = 0; maxtr = 0; for(x = 0; x < *nbreaks; x++){ if( *((*(breaks + 0)) + x) == rsite){ isyetbp = 1; } if( *((*(breaks + 0)) + x) <= rsite){ maxtr = (x+1); } } } /* Adding new site and re-ordering tracts in other tables */ /* (Note also check ancestral state of other arm; if ancestral then should create a new breakpoint) */ if((isyetbp != 1) && ((*((*(GType + rands2)) + maxtr) != (-1)) || (*((*(GType + rands3)) + maxtr) != (-1))) ){ (*nbreaks)++; for(x = *nbreaks-2; x >= (int)(maxtr-1); x--){ *((*(breaks + 0)) + x + 1) = *((*(breaks + 0)) + x); *((*(breaks + 1)) + x + 1) = *((*(breaks + 1)) + x); } *((*(breaks + 0)) + maxtr) = rsite; *((*(breaks + 1)) + maxtr) = *((*(breaks + 1)) + maxtr - 1); /* Adding new site to genotype; coalescent time; ancestry table */ for(j = 0; j < NMax; j++){ for(x = (*nbreaks-1); x >= (int)(maxtr); x--){ *((*(GType + j)) + x + 1) = *((*(GType + j)) + x); if(j < Itot){ *((*(CTms + j)) + x + 1) = *((*(CTms + j)) + x); *((*(TAnc + j)) + x + 1) = *((*(TAnc + j)) + x); } } } }else if((isyetbp == 1) || ((*((*(GType + rands2)) + maxtr) == (-1) ) && (*((*(GType + rands3)) + maxtr) == (-1) ))){ maxtr--; } /* Now creating the new sample genotype, by swapping genealogies */ for(x = (*nbreaks); x > (int)maxtr; x--){ tempGT = *((*(GType + rands3)) + x); *((*(GType + rands3)) + x) = *((*(GType + rands2)) + x); *((*(GType + rands2)) + x) = tempGT; } /* Final check: if one GT only contains non-ancestral material, turn into BH sample */ if( ( (isallI((*(GType + rands2)), (*nbreaks+1), (-1), 1) == 1) ) || ( (isallI((*(GType + rands3)), (*nbreaks+1), (-1), 1) == 1) ) ){ if(isallI((*(GType + rands2)), (*nbreaks+1), (-1), 1) == 1){ ctype = rands2; /* ntype = rands3; */ }else if(isallI((*(GType + rands3)), (*nbreaks+1), (-1), 1) == 1){ ctype = rands3; /* ntype = rands2; */ } achange = 1; excoal(indvs, GType, &ctype, *nbreaks, 1, Ntot, WCHex, BCHex, deme); /* for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 0) == ctype){ *((*(indvs + j)) + 1) = HUGEVAL; *((*(indvs + j)) + 2) = 2; break; } } */ } free(startp12); free(parsamps12); free(weights12); break; default: /* If none of these cases chosen, exit with error message */ fprintf(stderr,"Error: Non-standard coalescent case selected ('coalesce').\n"); exit(1); break; } return(achange); } /* End of coalescent routine */ /* Updating information following coalescent event */ void cchange(unsigned int **indvs, int **GType, double **CTms, int **TAnc, unsigned int **breaks, unsigned int *csamp, unsigned int *par, unsigned int lsamp, unsigned int Ntot, unsigned int cst, unsigned int *cend, double Ttot, unsigned int isall){ unsigned int j, i, x; unsigned int crow = 0; int tempval = 0; for(i = 0; i < lsamp; i++){ /* Finding crow, prow */ for(j = 0; j < Ntot; j++){ if(*((*(indvs + j)) + 0) == *(csamp + i)){ crow = j; break; } } /* 'csamp' coalesces if ALL parts coalesce (so it's removed from the simulation) */ if(isall == 1){ *((*(indvs + crow)) + 1) = HUGEVAL; *((*(indvs + crow)) + 2) = 2; } for(x = cst; x < (*cend); x++){ /* Updating coalescent time and parental sample */ tempval = -1; if( (*((*(GType + (*(csamp + i)))) + (x+1))) != (-1) && (*((*(GType + (*(par + i)))) + (x+1))) != (-1) ){ tempval = *((*(GType + (*(csamp + i)))) + (x+1)); *((*(CTms + (tempval))) + (x+1)) = Ttot; *((*(TAnc + (tempval))) + (x+1)) = (*((*(GType + (*(par + i)))) + (x+1))); } /* Updating genotype table */ if( (*((*(GType + (*(csamp + i)))) + (x+1))) != (-1) && (*((*(GType + (*(par + i)))) + (x+1))) == (-1)){ (*((*(GType + (*(par + i)))) + (x+1))) = (*((*(GType + (*(csamp + i)))) + (x+1))); } /* If coal event was via GC, then making coal'ed sample non-ancestral */ if(isall == 0 && (*((*(GType + (*(csamp + i)))) + (x+1))) != (-1)){ (*((*(GType + (*(csamp + i)))) + (x+1))) = (-1); } } } } /* End of 'cchange' function */ /* After coalescence, check if tracts have coalesced and make non-ancestral if need be */ unsigned int ccheck(unsigned int **indvs, int **GType, unsigned int **breaks, unsigned int nsites, unsigned int Ntot, unsigned int nbreaks){ unsigned int j, x; /* counters */ unsigned int achange = 0; /* Has there been 'a change'? */ unsigned int gcount = 0; /* count of extant tracts present */ unsigned int ridx = 0; /* Index of sample */ int isfst = -1; /* Is first indv that carries coal'ed material? */ /* Checking if tract has completely coalesced */ for(x = 0; x < nbreaks; x++){ isfst = (-1); if( *((*(breaks + 1)) + x) != 1 ){ /* If not yet coalesced... */ gcount = 0; for(j = 0; j < Ntot; j++){ if( (*((*(indvs + j)) + 2) != 2 ) ){ ridx = *((*(indvs + j)) + 0); if( (*((*(GType + ridx)) + (x + 1)) != (-1))){ gcount++; if( isfst == (-1) ){ isfst = ridx; } } } } /* If only one individual exists which carries that tract, then it has coalesced */ /* Setting last ancestral piece to non-ancestral to reflect this */ if(gcount == 1){ *((*(breaks + 1)) + x) = 1; *((*(GType + isfst)) + (x + 1)) = (-1); achange = 1; } } } return(achange); } /* End of 'ccheck' function */ /* Check if extra samples are removed, as all extant material coalesces */ void excoal(unsigned int **indvs, int **GType, unsigned int *par, unsigned int nbreaks, unsigned int npar, unsigned int Ntot, int *WCHex, int *BCHex, unsigned int deme){ unsigned int i, j; unsigned int prow = 0; unsigned int prent = 0; for(i = 0; i < npar; i++){ if( isallI(*(GType + (*(par + i))), nbreaks + 1, (-1), 1) == 1 ) { for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 0) == *(par + i) ){ prow = j; break; } } if(*((*(indvs + prow)) + 2) == 1){ *(BCHex + deme) -= 1; }else if(*((*(indvs + prow)) + 2) == 0){ prent = *((*(indvs + prow)) + 1); for(j = 0; j < Ntot; j++){ if( (*((*(indvs + j)) + 1) == prent) && (*((*(indvs + j)) + 0) != *(par + i) ) ){ *((*(indvs + j)) + 2) = 1; break; } } *(WCHex + deme) -= 1; *(BCHex + deme) += 1; } *((*(indvs + prow)) + 1) = HUGEVAL; *((*(indvs + prow)) + 2) = 2; } } } /* Routine to calculate length of coalesced tracts */ unsigned int coalcalc(unsigned int **breaks, unsigned int nsites, unsigned int nbreaks, unsigned int start){ /* Calculating length of coalesced samples: deducting 1 to account for edge effects; adding on breakpoints lying between two coalesced samples */ unsigned int x; unsigned int val1, val2; unsigned int lcoal = 0; for(x = start; x < (nbreaks - 1); x++){ val1 = 0; val2 = 0; if(*((*(breaks + 1)) + x) == 1){ val1 = *((*(breaks + 0)) + x); val2 = *((*(breaks + 0)) + x + 1); lcoal += (val2 - val1 - 1); if(*((*(breaks + 1)) + x + 1) == 1){ lcoal++; } } } val1 = 0; val2 = 0; if(*((*(breaks + 1)) + (nbreaks - 1)) == 1){ val1 = *((*(breaks + 0)) + (nbreaks - 1)); val2 = nsites; lcoal += (val2 - val1 - 1); } return(lcoal); } /* End of coalcalc function */ /* Function to choose which samples split by sex */ void sexsamp(unsigned int **indvs, unsigned int *rsex, unsigned int *nsex, unsigned int *Nwith, unsigned int Ntot, const gsl_rng *r){ unsigned int count = 0; unsigned int x, a; for(x = 0; x < d; x++){ if(*(Nwith + x) != 0 && *(nsex + x) != 0){ /* Avoiding errors if no WH in deme */ unsigned int *WHsamp = calloc(*(Nwith + x),sizeof(unsigned int)); unsigned int *WHchosen = calloc(*(nsex + x),sizeof(unsigned int)); /* Obtaining WH in that deme */ sselect_UI(indvs, WHsamp, Ntot, 2, 1, 0, 3, x); /* Sampling those to be split */ gsl_ran_choose(r,WHchosen,(*(nsex + x)),WHsamp,(*(Nwith + x)),sizeof(unsigned int)); gsl_ran_shuffle(r, WHchosen, (*(nsex + x)), sizeof(unsigned int)); /* Assigning samples to 'rsex' */ for(a = 0; a < *(nsex + x); a++){ *(rsex + (count + a)) = *(WHchosen + a); } count += *(nsex + x); free(WHchosen); free(WHsamp); } } } /* Insertion-sort rows by individual no., to ensure paired samples are together after an action */ void indv_sort(unsigned int **indvs, unsigned int nrow){ unsigned int j, i; /* Sorting indices */ unsigned int temp0, temp1, temp2, temp3; /* For swapping */ unsigned int count = 0; unsigned int icount = 0; for(j = 1; j < nrow; j++){ i = j; while( (i > 0) && ( *((*(indvs + (i - 1) )) + 1) > *((*(indvs + i)) + 1) )){ /* Swapping entries */ temp0 = *((*(indvs + (i - 1) )) + 0); temp1 = *((*(indvs + (i - 1) )) + 1); temp2 = *((*(indvs + (i - 1) )) + 2); temp3 = *((*(indvs + (i - 1) )) + 3); *((*(indvs + (i-1) )) + 0) = *((*(indvs + (i) )) + 0); *((*(indvs + (i-1) )) + 1) = *((*(indvs + (i) )) + 1); *((*(indvs + (i-1) )) + 2) = *((*(indvs + (i) )) + 2); *((*(indvs + (i-1) )) + 3) = *((*(indvs + (i) )) + 3); *((*(indvs + (i) )) + 0) = temp0; *((*(indvs + (i) )) + 1) = temp1; *((*(indvs + (i) )) + 2) = temp2; *((*(indvs + (i) )) + 3) = temp3; i--; } } /* Then renumbering indvs */ while(count < nrow){ if(*((*(indvs + count)) + 2) == 1){ *((*(indvs + count)) + 1) = icount; icount++; count++; }else if(*((*(indvs + count)) + 2) == 0){ *((*(indvs + count)) + 1) = icount; *((*(indvs + count + 1)) + 1) = icount; count++; count++; icount++; }else if(*((*(indvs + count)) + 2) == 2){ count++; } } } /* Insertion-sort for double-type tables */ void indv_sortD(double **Tin, unsigned int nrow, unsigned int ncol, unsigned int tcol){ unsigned int j, i, k; /* Sorting indices */ double *tempcol = calloc(ncol,sizeof(double)); /* temp entries for swapping */ for(j = 1; j < nrow; j++){ i = j; while( (i > 0) && ( *((*(Tin + (i - 1) )) + tcol) > *((*(Tin + i)) + tcol) )){ /* Swapping entries */ for(k = 0; k < ncol; k++){ *(tempcol + k) = *((*(Tin + (i - 1) )) + k); *((*(Tin + (i - 1) )) + k) = *((*(Tin + (i) )) + k); *((*(Tin + (i) )) + k) = *(tempcol + k); } i--; } } free(tempcol); } void Wait(){ printf("Press Enter to Continue"); while( getchar() != '\n' ); printf("\n"); } void TestTabs(unsigned int **indvs, int **GType, double **CTms, int **TAnc, unsigned int **breaks, unsigned int **nlri, unsigned int **nlrix, unsigned int NMax, unsigned int Itot, unsigned int Nbet, unsigned int Nwith, unsigned int nbreaks){ unsigned int j, x; printf("INDV TABLE\n"); for(j = 0; j < NMax; j++){ for(x = 0; x < 4; x++){ printf("%d ",*((*(indvs + j)) + x)); } printf("\n"); } printf("\n"); printf("GTYPE TABLE\n"); for(j = 0; j < NMax; j++){ for(x = 0; x <= nbreaks; x++){ printf("%d ",*((*(GType + j)) + x)); } printf("\n"); } printf("\n"); /* printf("CTMS TABLE\n"); for(j = 0; j < Itot; j++){ for(x = 0; x <= nbreaks; x++){ printf("%lf ",*((*(CTms + j)) + x)); } printf("\n"); } printf("\n"); printf("TANC TABLE\n"); for(j = 0; j < Itot; j++){ for(x = 0; x <= nbreaks; x++){ printf("%d ",*((*(TAnc + j)) + x)); } printf("\n"); } printf("\n"); printf("NLRI TABLE\n"); for(j = 0; j < Nbet; j++){ for(x = 0; x < 4; x++){ printf("%d ",*((*(nlri + j)) + x)); } printf("\n"); } printf("\n"); */ printf("NLRIX TABLE\n"); for(j = 0; j < Nwith; j++){ for(x = 0; x < 4; x++){ printf("%d ",*((*(nlrix + j)) + x)); } printf("\n"); } printf("\n"); printf("BREAKS TABLE\n"); for(j = 0; j < 2; j++){ for(x = 0; x < nbreaks; x++){ printf("%d ",*((*(breaks + j)) + x)); } printf("\n"); } printf("\n"); Wait(); /* exit(1); */ } /* Function to reconstruct genealogy and to add mutation to branches */ char * treemaker(double **TFin, double thetain, unsigned int mind2, unsigned int maxd2, double mind, double maxd, unsigned int Itot, unsigned int run, double gmi, double gme, unsigned int ismsp, unsigned int *nmutT, unsigned int prtrees, unsigned int ismut, double pburst, unsigned int mburst, double bdist, const gsl_rng *r){ unsigned int i, j, k, a; unsigned int lct = Itot; unsigned int lct2 = lct-1; unsigned int nc = 0; /* {N}umber of {c}lades in current reconstruction */ double birthtime = 0; /* Coalescent time */ double cbst = 0; /* Centre of burst event */ unsigned int child1 = 0; /* Coalesced sample */ unsigned int parent1 = 0; /* Parental sample */ unsigned int csum = 0; /* How many of each have been sampled, to decide action*/ unsigned int ischild = 0; /* Is it a child sample? */ unsigned int rmut1 = 0; /* Mutations along first branch */ unsigned int rmut2 = 0; /* Mutations along second branch */ unsigned int cc = 0; /* Child clade */ unsigned int pc = 0; /* Parental clade */ unsigned int exsamps = 0; /* Extra samples */ unsigned int cs = 0; /* 'Clade' samps */ unsigned int minc = 0; /* Min, max clade (for resorting) */ unsigned int maxc = 0; unsigned int ccM = 0; unsigned int brk = 0; /* Breakpoint where tract starts */ unsigned int clen = 4096; /* Space allocated to clades array */ unsigned int nmut = 0; /* Number of mutants added */ unsigned int newr = 0; /* New rows in table if need to expand */ unsigned int isbst = 0; /* Are next mutants clustered ? */ unsigned int bsze = 0; /* Burst counter */ unsigned int isrb = 0; /* Checking if burst distance lies in actual distance */ static const char lbr[] = "("; static const char rbr[] = ")"; static const char com[] = ","; static const char cln[] = ":"; static const char scln[] = ";"; static const char lsq[] = "["; static const char rsq[] = "]"; static const char spa[] = " "; char p1char[10]; char c1char[10]; char btchar1[16]; char btchar2[16]; char brkchar[16]; char Mout[32]; /* String to hold filename in (Mutations) */ FILE *ofp_mut = NULL; /* Pointer for data output */ /* Defining necessary tables */ double *Cheight = calloc(lct,sizeof(double)); /* Current 'height' (time) of each clade */ char **clades = calloc(lct, sizeof(char *)); /* Vector of possible clades */ unsigned int **samps = calloc(lct,sizeof(unsigned int *)); /* Table of samples present in each clade (row = each clade) */ for(j = 0; j < lct; j++){ clades[j] = calloc((clen+1),sizeof(char)); samps[j] = calloc(lct,sizeof(unsigned int)); for(k = 0; k < lct; k++){ *((*(samps + j)) + k) = Itot; } } /* Allocating space for mutation table */ unsigned int MTRows = 30; double **MTab = calloc(MTRows,sizeof(double *)); /* Mutation table */ for(j = 0; j < MTRows; j++){ MTab[j] = calloc((Itot+1),sizeof(double)); } for(i = 0; i < lct2; i++){ birthtime = *((*(TFin + i)) + 1); child1 = *((*(TFin + i)) + 0); parent1 = *((*(TFin + i)) + 2); ischild = 0; csum = 0; if(i == 0){ *((*(samps + 0)) + 0) = parent1; *((*(samps + 0)) + 1) = child1; *(Cheight + 0) = birthtime; /* Converting values to strings */ sprintf(p1char, "%d", parent1); sprintf(c1char, "%d", child1); sprintf(btchar1,"%0.5lf",birthtime); strcpy(*(clades + 0),lbr); strcat(*(clades + 0),p1char); strcat(*(clades + 0),cln); strcat(*(clades + 0),btchar1); strcat(*(clades + 0),com); strcat(*(clades + 0),c1char); strcat(*(clades + 0),cln); strcat(*(clades + 0),btchar1); strcat(*(clades + 0),rbr); /* Assigning mutations */ rmut1 = gsl_ran_poisson(r,(0.5*thetain*birthtime)); rmut2 = gsl_ran_poisson(r,(0.5*thetain*birthtime)); if(rmut1 != 0){ isbst = 0; bsze = 0; if((nmut + rmut1) > MTRows){ newr = MTRows; while(newr < (nmut + rmut1)){ newr = 2*newr; } MTab = (double **)realloc(MTab, newr*sizeof(double *)); for(j = 0; j < MTRows; j++){ MTab[j] = (double *)realloc( *(MTab + j) ,(Itot+1)*sizeof(double)); } for(j = MTRows; j < newr; j++){ MTab[j] = (double *)calloc((Itot + 1),sizeof(double)); } MTRows = newr; } for(a = 0; a < rmut1; a++){ /* Indicating location of mutants */ if(bsze == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, mind, maxd); isbst = gsl_ran_bernoulli(r,pburst); if(isbst == 1){ bsze = mburst; cbst = *((*(MTab + (nmut+a))) + 0); } }else if(bsze > 0){ isrb = 0; while(isrb == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, cbst-bdist, cbst+bdist); if( (mind < *((*(MTab + (nmut+a))) + 0)) && (*((*(MTab + (nmut+a))) + 0) < maxd) ){ isrb = 1; } } bsze--; } *((*(MTab + (nmut+a))) + (parent1+1)) = 1; } nmut += rmut1; } if(rmut2 != 0){ isbst = 0; bsze = 0; if((nmut + rmut2) > MTRows){ newr = MTRows; while(newr < (nmut + rmut2)){ newr = 2*newr; } MTab = (double **)realloc(MTab, newr*sizeof(double *)); for(j = 0; j < MTRows; j++){ MTab[j] = (double *)realloc( *(MTab + j) ,(Itot+1)*sizeof(double)); } for(j = MTRows; j < newr; j++){ MTab[j] = (double *)calloc((Itot + 1),sizeof(double)); } MTRows = newr; } for(a = 0; a < rmut2; a++){ /* Indicating location of mutants */ if(bsze == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, mind, maxd); isbst = gsl_ran_bernoulli(r,pburst); if(isbst == 1){ bsze = mburst; cbst = *((*(MTab + (nmut+a))) + 0); } }else if(bsze > 0){ isrb = 0; while(isrb == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, cbst-bdist, cbst+bdist); if( (mind < *((*(MTab + (nmut+a))) + 0)) && (*((*(MTab + (nmut+a))) + 0) < maxd) ){ isrb = 1; } } bsze--; } *((*(MTab + (nmut+a))) + (child1+1)) = 1; } nmut += rmut2; } }else if(i > 0){ /* There can be three cases: Merge clades if child already listed; Add to clade if child new but parent already listed; Create new clade otherwise. Testing how many of the pair have already been sampled, to decide tree reconstruction */ cc = Itot; pc = Itot; csum = 0; for(j = 0; j < lct; j++){ if( *((*(samps + j)) + 0) == Itot ){ break; } for(k = 0; k < lct; k++){ if( *((*(samps + j)) + k) == child1 ){ cc = j; csum++; } if( *((*(samps + j)) + k) == parent1 ){ pc = j; csum++; } if( *((*(samps + j)) + k) == Itot ){ break; } } } if(csum==0){ /* Create a new clade */ nc++; *((*(samps + nc)) + 0) = parent1; *((*(samps + nc)) + 1) = child1; *(Cheight + nc) = birthtime; /* Converting values to strings */ sprintf(p1char, "%d", parent1); sprintf(c1char, "%d", child1); sprintf(btchar1,"%0.5lf",birthtime); strcpy(*(clades + nc),lbr); strcat(*(clades + nc),p1char); strcat(*(clades + nc),cln); strcat(*(clades + nc),btchar1); strcat(*(clades + nc),com); strcat(*(clades + nc),c1char); strcat(*(clades + nc),cln); strcat(*(clades + nc),btchar1); strcat(*(clades + nc),rbr); /* Assigning mutations */ rmut1 = gsl_ran_poisson(r,(0.5*thetain*birthtime)); rmut2 = gsl_ran_poisson(r,(0.5*thetain*birthtime)); if(rmut1 != 0){ isbst = 0; bsze = 0; if((nmut + rmut1) > MTRows){ newr = MTRows; while(newr < (nmut + rmut1)){ newr = 2*newr; } MTab = (double **)realloc(MTab, newr*sizeof(double *)); for(j = 0; j < MTRows; j++){ MTab[j] = (double *)realloc( *(MTab + j) ,(Itot+1)*sizeof(double)); } for(j = MTRows; j < newr; j++){ MTab[j] = (double *)calloc((Itot + 1),sizeof(double)); } MTRows = newr; } for(a = 0; a < rmut1; a++){ /* Indicating location of mutants */ if(bsze == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, mind, maxd); isbst = gsl_ran_bernoulli(r,pburst); if(isbst == 1){ bsze = mburst; cbst = *((*(MTab + (nmut+a))) + 0); } }else if(bsze > 0){ isrb = 0; while(isrb == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, cbst-bdist, cbst+bdist); if( (mind < *((*(MTab + (nmut+a))) + 0)) && (*((*(MTab + (nmut+a))) + 0) < maxd) ){ isrb = 1; } } bsze--; } *((*(MTab + (nmut+a))) + (parent1+1)) = 1; } nmut += rmut1; } if(rmut2 != 0){ isbst = 0; bsze = 0; if((nmut + rmut2) > MTRows){ newr = MTRows; while(newr < (nmut + rmut2)){ newr = 2*newr; } MTab = (double **)realloc(MTab, newr*sizeof(double *)); for(j = 0; j < MTRows; j++){ MTab[j] = (double *)realloc( *(MTab + j) ,(Itot+1)*sizeof(double)); } for(j = MTRows; j < newr; j++){ MTab[j] = (double *)calloc((Itot + 1),sizeof(double)); } MTRows = newr; } for(a = 0; a < rmut2; a++){ /* Indicating location of mutants */ if(bsze == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, mind, maxd); isbst = gsl_ran_bernoulli(r,pburst); if(isbst == 1){ bsze = mburst; cbst = *((*(MTab + (nmut+a))) + 0); } }else if(bsze > 0){ isrb = 0; while(isrb == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, cbst-bdist, cbst+bdist); if( (mind < *((*(MTab + (nmut+a))) + 0)) && (*((*(MTab + (nmut+a))) + 0) < maxd) ){ isrb = 1; } } bsze--; } *((*(MTab + (nmut+a))) + (child1+1)) = 1; } nmut += rmut2; } }else if(csum == 1){ /* Add to existing clade */ /* Choosing row (and therefore clade) containing existing parent (or child) */ if(pc==Itot){ ischild = 1; pc = cc; } /* Converting values to strings */ sprintf(c1char, "%d", child1); sprintf(p1char, "%d", parent1); sprintf(btchar1,"%0.5lf",birthtime); sprintf(btchar2,"%0.5lf",(birthtime - (*(Cheight+pc)))); char *tc = malloc( (strlen((*(clades + pc))) + 40) * sizeof(char) ); if( tc == NULL ) { fprintf(stderr, "Error - unable to allocate required memory\n"); } if(ischild == 0){ /* Concatenating new clade */ strcpy(tc,lbr); strcat(tc,c1char); strcat(tc,cln); strcat(tc,btchar1); strcat(tc,com); strcat(tc,(*(clades + pc))); strcat(tc,cln); strcat(tc,btchar2); strcat(tc,rbr); for(k = 0; k < lct; k++){ if( *((*(samps + pc)) + k) == Itot ){ *((*(samps + pc)) + k) = child1; break; } } exsamps = child1; }else if(ischild==1){ strcpy(tc,lbr); strcat(tc,p1char); strcat(tc,cln); strcat(tc,btchar1); strcat(tc,com); strcat(tc,(*(clades + pc))); strcat(tc,cln); strcat(tc,btchar2); strcat(tc,rbr); for(k = 0; k < lct; k++){ if( *((*(samps + pc)) + k) == Itot ){ *((*(samps + pc)) + k) = parent1; break; } } exsamps = parent1; } /* Assigning mutations */ rmut1 = gsl_ran_poisson(r,(0.5*thetain*(birthtime - (*(Cheight+pc))))); rmut2 = gsl_ran_poisson(r,(0.5*thetain*birthtime)); if(rmut1 != 0){ isbst = 0; bsze = 0; if((nmut + rmut1) > MTRows){ newr = MTRows; while(newr < (nmut + rmut1)){ newr = 2*newr; } MTab = (double **)realloc(MTab, newr*sizeof(double *)); for(j = 0; j < MTRows; j++){ MTab[j] = (double *)realloc( *(MTab + j) ,(Itot+1)*sizeof(double)); } for(j = MTRows; j < newr; j++){ MTab[j] = (double *)calloc((Itot + 1),sizeof(double)); } MTRows = newr; } for(a = 0; a < rmut1; a++){ /* Indicating location of mutants */ if(bsze == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, mind, maxd); isbst = gsl_ran_bernoulli(r,pburst); if(isbst == 1){ bsze = mburst; cbst = *((*(MTab + (nmut+a))) + 0); } }else if(bsze > 0){ isrb = 0; while(isrb == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, cbst-bdist, cbst+bdist); if( (mind < *((*(MTab + (nmut+a))) + 0)) && (*((*(MTab + (nmut+a))) + 0) < maxd) ){ isrb = 1; } } bsze--; } for(k = 0; k < lct; k++){ if( (*((*(samps + pc)) + k) != Itot) && (*((*(samps + pc)) + k) != exsamps) ){ cs = *((*(samps + pc)) + k); *((*(MTab + (nmut+a))) + (cs + 1)) = 1; } } } nmut += rmut1; } if(rmut2 != 0){ isbst = 0; bsze = 0; if((nmut + rmut2) > MTRows){ newr = MTRows; while(newr < (nmut + rmut2)){ newr = 2*newr; } MTab = (double **)realloc(MTab, newr*sizeof(double *)); for(j = 0; j < MTRows; j++){ MTab[j] = (double *)realloc( *(MTab + j) ,(Itot+1)*sizeof(double)); } for(j = MTRows; j < newr; j++){ MTab[j] = (double *)calloc((Itot + 1),sizeof(double)); } MTRows = newr; } for(a = 0; a < rmut2; a++){ /* Indicating location of mutants */ if(bsze == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, mind, maxd); isbst = gsl_ran_bernoulli(r,pburst); if(isbst == 1){ bsze = mburst; cbst = *((*(MTab + (nmut+a))) + 0); } }else if(bsze > 0){ isrb = 0; while(isrb == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, cbst-bdist, cbst+bdist); if( (mind < *((*(MTab + (nmut+a))) + 0)) && (*((*(MTab + (nmut+a))) + 0) < maxd) ){ isrb = 1; } } bsze--; } *((*(MTab + (nmut+a))) + (exsamps + 1)) = 1; } nmut += rmut2; } memset((*(clades + pc)),'\0',(clen+1)); if(strlen(tc) > clen){ while(strlen(tc) > clen){ clen = 2*clen; } for(j = 0; j < lct; j++){ clades[j] = realloc((*(clades + j)), (clen+1) * sizeof(char) ); } } strcpy((*(clades + pc)),tc); *(Cheight + pc) = birthtime; free(tc); }else if((csum == 2) && (nc > 0)){ /* Add to existing clade */ /* Converting values to strings */ sprintf(c1char, "%d", child1); sprintf(p1char, "%d", parent1); sprintf(btchar1,"%0.5lf",(birthtime - (*(Cheight + pc)))); sprintf(btchar2,"%0.5lf",(birthtime - (*(Cheight + cc)))); /* memset(tc,'\0',sizeof(tc)); */ char *tc2 = malloc((strlen((*(clades + pc))) + strlen((*(clades + cc))) + 40) * sizeof(char)); if( tc2 == NULL ) { fprintf(stderr, "Error - unable to allocate required memory\n"); } strcpy(tc2,lbr); strcat(tc2,(*(clades + pc))); strcat(tc2,cln); strcat(tc2,btchar1); strcat(tc2,com); strcat(tc2,(*(clades + cc))); strcat(tc2,cln); strcat(tc2,btchar2); strcat(tc2,rbr); /* Assigning mutations */ rmut1 = gsl_ran_poisson(r,(0.5*thetain*(birthtime - (*(Cheight+pc))))); rmut2 = gsl_ran_poisson(r,(0.5*thetain*(birthtime - (*(Cheight+cc))))); if(rmut1 != 0){ isbst = 0; bsze = 0; if((nmut + rmut1) > MTRows){ newr = MTRows; while(newr < (nmut + rmut1)){ newr = 2*newr; } MTab = (double **)realloc(MTab, newr*sizeof(double *)); for(j = 0; j < MTRows; j++){ MTab[j] = (double *)realloc( *(MTab + j) ,(Itot+1)*sizeof(double)); } for(j = MTRows; j < newr; j++){ MTab[j] = (double *)calloc((Itot + 1),sizeof(double)); } MTRows = newr; } for(a = 0; a < rmut1; a++){ /* Indicating location of mutants */ if(bsze == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, mind, maxd); isbst = gsl_ran_bernoulli(r,pburst); if(isbst == 1){ bsze = mburst; cbst = *((*(MTab + (nmut+a))) + 0); } }else if(bsze > 0){ isrb = 0; while(isrb == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, cbst-bdist, cbst+bdist); if( (mind < *((*(MTab + (nmut+a))) + 0)) && (*((*(MTab + (nmut+a))) + 0) < maxd) ){ isrb = 1; } } bsze--; } for(k = 0; k < lct; k++){ if( *((*(samps + pc)) + k) != Itot ){ cs = *((*(samps + pc)) + k); *((*(MTab + (nmut+a))) + (cs + 1)) = 1; } } } nmut += rmut1; } if(rmut2 != 0){ isbst = 0; bsze = 0; if((nmut + rmut2) > MTRows){ newr = MTRows; while(newr < (nmut + rmut2)){ newr = 2*newr; } MTab = (double **)realloc(MTab, newr*sizeof(double *)); for(j = 0; j < MTRows; j++){ MTab[j] = (double *)realloc( *(MTab + j) ,(Itot+1)*sizeof(double)); } for(j = MTRows; j < newr; j++){ MTab[j] = (double *)calloc((Itot + 1),sizeof(double)); } MTRows = newr; } for(a = 0; a < rmut2; a++){ /* Indicating location of mutants */ if(bsze == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, mind, maxd); isbst = gsl_ran_bernoulli(r,pburst); if(isbst == 1){ bsze = mburst; cbst = *((*(MTab + (nmut+a))) + 0); } }else if(bsze > 0){ isrb = 0; while(isrb == 0){ *((*(MTab + (nmut+a))) + 0) = gsl_ran_flat(r, cbst-bdist, cbst+bdist); if( (mind < *((*(MTab + (nmut+a))) + 0)) && (*((*(MTab + (nmut+a))) + 0) < maxd) ){ isrb = 1; } } bsze--; } for(k = 0; k < lct; k++){ if( *((*(samps + cc)) + k) != Itot ){ cs = *((*(samps + cc)) + k); *((*(MTab + (nmut+a))) + (cs + 1)) = 1.0; } } } nmut += rmut2; } /* Deleting old clade data */ if(cc < pc){ minc = cc; maxc = pc; }else if (cc > pc){ minc = pc; maxc = cc; } if(strlen(tc2) > clen){ while(strlen(tc2) > clen){ clen = 2*clen; } for(j = 0; j < lct; j++){ clades[j] = realloc((*(clades + j)), (clen+1) * sizeof(char) ); } } memset((*(clades + minc)),'\0',(clen+1)); memset((*(clades + maxc)),'\0',(clen+1)); strcpy((*(clades + minc)),tc2); *(Cheight + minc) = birthtime; *(Cheight + maxc) = 0; free(tc2); for(k = 0; k < lct; k++){ if(*((*(samps + minc)) + k) == Itot){ ccM = k; break; } } for(k = 0; k < lct; k++){ if(*((*(samps + maxc)) + k) == Itot){ break; } *((*(samps + minc)) + (k + ccM)) = *((*(samps + maxc)) + k); /* *((*(samps + maxc)) + k) = Itot; */ } /* Now to reorder (to prevent overflow/going out of array length) */ /* Then re-writing over original arrays */ for(j = maxc; j < nc; j++){ for(k = 0; k < lct; k++){ *((*(samps + j)) + k) = *((*(samps + j + 1)) + k); } memset((*(clades + j)),'\0',(clen+1)); strcpy((*(clades + j)),(*(clades + j + 1))); *(Cheight + j) = *(Cheight + j + 1); } for(k = 0; k < lct; k++){ *((*(samps + nc)) + k) = Itot; } memset((*(clades + nc)),'\0',(clen+1)); *(Cheight + nc) = 0; nc--; } } } /* Printing out Mutations to file */ indv_sortD(MTab,nmut,(Itot+1),0); if(thetain > 0){ sprintf(Mout,"Mutations/Muts_%d.dat",run); if(mind != 0){ ofp_mut = fopen(Mout,"a"); }else if(mind == 0){ ofp_mut = fopen(Mout,"w"); } for(j = 0; j < nmut; j++){ fprintf(ofp_mut,"%lf ",*((*(MTab + j)) + 0)); for(a = 1; a < (Itot + 1); a++){ fprintf(ofp_mut,"%d ",(unsigned int)(*((*(MTab + j)) + a))); } fprintf(ofp_mut,"\n"); } fclose(ofp_mut); } *nmutT += nmut; strcat((*(clades + 0)),scln); char *str = malloc(clen * sizeof(char)); if(str == NULL) { fprintf(stderr, "Error - unable to allocate required memory (str1) \n"); } char *str2 = malloc(clen * sizeof(char)); if(str2 == NULL) { fprintf(stderr, "Error - unable to allocate required memory (str2) \n"); } if( (rec == 0 && gmi == 0 && gme == 0) || nsites == 1){ strcpy(str,(*(clades + 0))); strcpy(str2,(*(clades + 0))); }else if((rec > 0 || gmi > 0 || gme > 0) && nsites > 1){ brk = (maxd2 - mind2); sprintf(brkchar, "%d", brk); strcpy(str,lsq); strcpy(str2,lsq); strcat(str,brkchar); strcat(str2,brkchar); strcat(str,rsq); strcat(str2,rsq); strcat(str,spa); strcat(str,(*(clades + 0))); strcat(str2,(*(clades + 0))); } if(ismsp == 1){ if(prtrees == 1){ printf("%s\n",str2); } /* If last tree, then print out mutation table */ if(maxd == 1 && ismut == 1){ /* If last tree and using MS-style printout, read in data and print to screen */ double **MTabF = calloc(*nmutT,sizeof(double *)); /* Mutation table */ for(j = 0; j < *nmutT; j++){ MTabF[j] = calloc((Itot+1),sizeof(double)); } /* Reading in table */ sprintf(Mout,"Mutations/Muts_%d.dat",run); ofp_mut = fopen(Mout,"r"); for(j = 0; j < *nmutT; j++){ for(a = 0; a < (Itot + 1); a++){ fscanf(ofp_mut,"%lf", &(MTabF[j][a]) ); } } fclose(ofp_mut); /* Print off sites and positions */ printf("segsites: %d\n",*nmutT); printf("positions: "); for(j = 0; j < *nmutT; j++){ printf("%.4lf ",*((*(MTabF + j)) + 0)); } printf("\n"); /* Now printing off mutation tables */ for(a = 1; a < (Itot + 1); a++){ for(j = 0; j < *nmutT; j++){ printf("%d",(unsigned int)(*((*(MTabF + j)) + a))); } printf("\n"); } /* Then free tables */ for(j = 0; j < *nmutT; j++){ free(MTabF[j]); } free(MTabF); } } free(str2); for(j = 0; j < MTRows; j++){ free(MTab[j]); } for(j = 0; j < lct; j++){ free(samps[j]); free(clades[j]); } free(MTab); free(samps); free(clades); free(Cheight); return(str); free(str); } /* End of treemaker routine */ /* Reccal: calculating effective recombination rate over potential sites */ void reccal(unsigned int **indvs, int **GType, unsigned int **breaks, unsigned int **nlri, unsigned int *Nbet, unsigned int *Nwith, unsigned int *rsex, unsigned int esex, unsigned int *lnrec, unsigned int nbreaks, unsigned int NMax, unsigned int sw, unsigned int run){ unsigned int j, i; unsigned int count = 0; unsigned int count2 = 0; unsigned int vl = 0; unsigned int mintr = 0; unsigned int maxtr = 0; unsigned int Ntot = sumUI(Nbet,d) + 2*sumUI(Nwith,d); unsigned int is0l = 0; unsigned int is0r = 0; unsigned int ridx = 0; unsigned int brec = 0; /* Accounted breakpoints */ unsigned int intot = 0; unsigned int count3 = 0; if(sw == 1){ count3 = sumUI(Nbet,d); } if(sw == 0){ vl = sumUI(Nbet,d); }else if(sw == 1){ vl = 2*esex; } unsigned int *BHi = calloc(vl,sizeof(unsigned int)); unsigned int *BHid = calloc(vl,sizeof(unsigned int)); /* Vector of samples */ count = 0; count2 = 0; if(sw == 0){ while(count < vl){ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 2) == 1){ *(BHi + count) = *((*(indvs + j)) + 0); *(BHid + count) = *((*(indvs + j)) + 3); count++; } } } }else if(sw == 1){ while(count < vl){ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 1) == *(rsex + count2)){ *(BHi + count) = *((*(indvs + j)) + 0); *(BHid + count) = *((*(indvs + j)) + 3); *(BHi + count + 1) = *((*(indvs + j + 1)) + 0); *(BHid + count + 1) = *((*(indvs + j + 1)) + 3); count++; count++; count2++; break; } } } } for(i = 0; i < d; i++){ *(lnrec + i) = 0; } if(vl > 0){ for(i = 0; i < vl; i++){ mintr = 0; maxtr = 0; is0l = 0; is0r = 0; ridx = 0; brec = 0; intot = 0; *((*(nlri + count3 + i)) + 0) = (*(BHi + i)); *((*(nlri + count3 + i)) + 1) = 0; /* Determining case to run */ for(j = 0; j < NMax; j++){ if( *((*(GType + j)) + 0) == *(BHi + i) ){ ridx = j; if( *((*(GType + j)) + 1) == -1 ){ is0l = 1; } if( *((*(GType + j)) + nbreaks) == -1 ){ is0r = 1; } break; } } if( is0l == 1 ){ mintr = first_neI(*(GType + ridx), nbreaks + 1, (-1), 1); mintr--; /* So concordant with 'breaks' table */ *((*(nlri + count3 + i)) + 1) = *((*(breaks + 0)) + mintr); brec = *((*(breaks + 0)) + mintr); *(lnrec + (*(BHid + i))) += brec; intot = brec; } brec = 0; if( is0r == 1 ){ maxtr = last_neI(*(GType + ridx), nbreaks+1, (-1), 1); maxtr--; /* So concordant with 'breaks' table */ brec = nsites - *((*(breaks + 0)) + maxtr + 1); *(lnrec + (*(BHid + i))) += brec; intot += brec; } *((*(nlri + count3 + i)) + 2) = (nsites - 1 - intot); *((*(nlri + count3 + i)) + 3) = (*(BHid + i)); } } free(BHid); free(BHi); } /* ReccalX: calculating effective recombination rate over potential sites FOR PAIRED SAMPLES (for mitotic recombination) */ void reccalx(unsigned int **indvs, int **GType, unsigned int **breaks, unsigned int **nlrix, unsigned int *Nbet, unsigned int *Nwith, unsigned int *rsex, unsigned int esex, unsigned int *lnrec, unsigned int nbreaks, unsigned int NMax, unsigned int sw, unsigned int run){ unsigned int j, i; unsigned int count = 0; unsigned int vl = 0; unsigned int mintr1 = 0; unsigned int mintr2 = 0; unsigned int mintr = 0; unsigned int maxtr1 = 0; unsigned int maxtr2 = 0; unsigned int maxtr = 0; unsigned int Ntot = sumUI(Nbet,d) + 2*sumUI(Nwith,d); unsigned int is0l = 0; unsigned int is0r = 0; unsigned int ridx1 = 0; unsigned int ridx2 = 0; unsigned int brec = 0; /* Accounted breakpoints */ unsigned int intot = 0; if(sw == 0){ vl = sumUI(Nwith,d); }else if(sw == 1){ vl = (sumUI(Nwith,d) - esex); } unsigned int *WHi = calloc(vl,sizeof(unsigned int)); unsigned int *WHid = calloc(vl,sizeof(unsigned int)); for(j = 0; j < vl; j++){ *(WHi + j) = Ntot; *(WHid + j) = Ntot; } /* Vector of samples */ if(sw == 0){ while(count < vl){ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 2) == 0 && (isanyUI(WHi, vl, *((*(indvs + j)) + 1)) == 0) ){ *(WHi + count) = *((*(indvs + j)) + 1); *(WHid + count) = *((*(indvs + j)) + 3); count++; } } } }else if(sw == 1){ while(count < vl){ for(j = 0; j < Ntot; j++){ if( (*((*(indvs + j)) + 2) == 0) && (isanyUI(WHi, vl, *((*(indvs + j)) + 1)) == 0) && (isanyUI(rsex, esex, *((*(indvs + j)) + 1) ) == 0) ){ *(WHi + count) = *((*(indvs + j)) + 1); *(WHid + count) = *((*(indvs + j)) + 3); count++; } } } } for(i = 0; i < d; i++){ *(lnrec + i) = 0; } if(vl > 0){ for(i = 0; i < vl; i++){ mintr = 0; maxtr = 0; is0l = 0; is0r = 0; ridx1 = 0; ridx2 = 0; brec = 0; intot = 0; *((*(nlrix + i)) + 0) = (*(WHi + i)); *((*(nlrix + i)) + 1) = 0; /* Determining case to run */ for(j = 0; j < Ntot; j++){ if( *((*(indvs + j)) + 1) == *(WHi + i) ){ ridx1 = *((*(indvs + j)) + 0); ridx2 = *((*(indvs + j + 1)) + 0); if( (*((*(GType + ridx1)) + 1) == -1) && (*((*(GType + ridx2)) + 1) == -1) ){ is0l = 1; } if( (*((*(GType + ridx1)) + nbreaks) == -1) && (*((*(GType + ridx2)) + nbreaks) == -1) ){ is0r = 1; } break; } } if( is0l == 1 ){ mintr1 = first_neI(*(GType + ridx1), nbreaks + 1, (-1), 1); mintr2 = first_neI(*(GType + ridx2), nbreaks + 1, (-1), 1); if(mintr1 < mintr2){ mintr = mintr1; }else if(mintr1 >= mintr2){ mintr = mintr2; } mintr--; /* So concordant with 'breaks' table */ *((*(nlrix + i)) + 1) = *((*(breaks + 0)) + mintr); brec = *((*(breaks + 0)) + mintr); *(lnrec + (*(WHid + i))) += brec; intot = brec; } brec = 0; if( is0r == 1 ){ maxtr1 = last_neI(*(GType + ridx1), nbreaks + 1, (-1), 1); maxtr2 = last_neI(*(GType + ridx2), nbreaks + 1, (-1), 1); if(maxtr1 > maxtr2){ maxtr = maxtr1; }else if(maxtr1 <= maxtr2){ maxtr = maxtr2; } maxtr--; /* So concordant with 'breaks' table */ brec = nsites - *((*(breaks + 0)) + maxtr + 1); *(lnrec + (*(WHid + i))) += brec; intot += brec; } *((*(nlrix + i)) + 2) = (nsites - 1 - intot); *((*(nlrix + i)) + 3) = (*(WHid + i)); } } free(WHid); free(WHi); } void proberr(unsigned int est, double **pr, unsigned int *NW, unsigned int *NB, unsigned int *esx){ unsigned int j, x; fprintf(stderr,"A negative probability exists, you need to double-check your algebra (or probability inputs) - esex %d.\n",est); fprintf(stderr,"This likely arises due to having excessively high recombination or gene conversion rates - please check.\n"); fprintf(stderr,"\n"); fprintf(stderr,"For error reporting, the number of paired and unpaired samples per deme are:\n"); if(est == 0){ for(x = 0; x < d; x++){ fprintf(stderr,"%d %d\n",*(NW + x), *(NB + x)); } }else if(est == 1){ for(x = 0; x < d; x++){ fprintf(stderr,"%d %d (%d)\n",*(NW + x), *(NB + x), *(esx + x)); } } fprintf(stderr,"\n"); fprintf(stderr,"The final probability calculations per deme are:\n"); for(j = 0; j < 13; j++){ fprintf(stderr,"Event %d: ",j); for(x = 0; x < d; x++){ fprintf(stderr,"%0.10lf ",(*((*(pr + j)) + x))); } fprintf(stderr,"\n"); } fprintf(stderr,"\n"); exit(1); } void proberr2(double **pr, unsigned int *NW, unsigned int *NB){ unsigned int j, x; fprintf(stderr,"Summed probabilities exceed one, you need to double-check your algebra (or probability inputs).\n"); fprintf(stderr,"This likely arises due to having excessively high recombination or gene conversion rates - please check.\n"); fprintf(stderr,"\n"); fprintf(stderr,"For error reporting, the number of paired and unpaired samples per deme are:\n"); for(x = 0; x < d; x++){ fprintf(stderr,"%d %d\n",*(NW + x), *(NB + x)); } fprintf(stderr,"\n"); fprintf(stderr,"The final probability calculations per deme are:\n"); for(j = 0; j < 13; j++){ fprintf(stderr,"Event %d: ",j); for(x = 0; x < d; x++){ fprintf(stderr,"%0.10lf ",(*((*(pr + j)) + x))); } fprintf(stderr,"\n"); } fprintf(stderr,"\n"); exit(1); } void proberr3(double **pr, unsigned int *NW, unsigned int *NB){ unsigned int j, x; fprintf(stderr,"Summed probabilites are zero or negative, you need to double-check your algebra (or probability inputs).\n"); fprintf(stderr,"\n"); fprintf(stderr,"For error reporting, the number of paired and unpaired samples per deme are:\n"); for(x = 0; x < d; x++){ fprintf(stderr,"%d %d\n",*(NW + x), *(NB + x)); } fprintf(stderr,"\n"); fprintf(stderr,"The final probability calculations per deme are:\n"); for(j = 0; j < 13; j++){ fprintf(stderr,"Event %d: ",j); for(x = 0; x < d; x++){ fprintf(stderr,"%0.10lf ",(*((*(pr + j)) + x))); } fprintf(stderr,"\n"); } fprintf(stderr,"\n"); exit(1); } /* Function to print coalescent times of individual loci */ void printCT(double **CTms, unsigned int **breaks, unsigned int nbreaks, unsigned int nsites, unsigned int Itot, unsigned int run){ unsigned int j, x; char Cout[32]; /* String to hold filename in */ FILE *ofp_ctm = NULL; /* Pointer for data output */ sprintf(Cout,"CoalTimes/CTimes_%d.dat",run); ofp_ctm = fopen(Cout,"w"); for(x = 0; x < nbreaks; x++){ fprintf(ofp_ctm,"%d ",*((*(breaks + 0)) + x)); } fprintf(ofp_ctm,"\n"); for(j = 0; j < Itot; j++){ for(x = 1; x <= nbreaks; x++){ fprintf(ofp_ctm,"%lf ",*((*(CTms + j)) + x)); } fprintf(ofp_ctm,"\n"); } fclose(ofp_ctm); } void manyr(){ fprintf(stderr,"Too many recombinants (exceeds HUGEVAL), exiting program.\n"); fprintf(stderr,"This is likely due to having excessively large recombination\n"); fprintf(stderr,"or gene conversion rates.\n"); exit(1); } void usage(){ fprintf(stderr,"\n"); fprintf(stderr,"Command: FacSexCoalescent <Population Size> <Paired Samples> <Single Samples> <Frequency of Sex> <Reps> <Other parameters>\n"); fprintf(stderr,"\n"); fprintf(stderr,"'Other parameters' include:\n"); fprintf(stderr," -t: [4N(mu)] defines neutral mutation rate\n"); fprintf(stderr," -T: prints out individuals trees to file\n"); fprintf(stderr," (Note that one of -t or -T MUST be used)\n"); fprintf(stderr," -P: prints out data to screen using MS-style format\n"); fprintf(stderr," -D: 'Debug mode'; prints table of coalescent times to file.\n"); fprintf(stderr," -r: [2Nc(L-1) L] to specify MEIOTIC crossover recombination (rate 2Nc(L-1) and number of sites L)\n"); fprintf(stderr," -x: [2N(cA)(L-1)] to specify MITOTIC crossover recombination\n"); fprintf(stderr," -c: [2N(gS)(L-1) lambda_S] specifies rate and mean length of MEIOTIC gene conversion\n"); fprintf(stderr," -m: [2Ng(L-1) lambda] specifies rate and mean length of MITOTIC gene conversion\n"); fprintf(stderr," (For -x, -c, -m: need to first use -r to specify number of sites L, even if 2Nc(L-1) = 0)\n"); fprintf(stderr," -I: d [Paired_j Single_j]...[2Nm] for defining island model.\n"); fprintf(stderr," d is number of demes: [Paired_j Single_j] are d pairs of samples per deme;\n"); fprintf(stderr," 2Nm is net migration rate between demes.\n"); fprintf(stderr," -H: [Type of heterogeneity] [pLH pHL] [SexL_j SexH_j] for heterogeneity in frequencies of sex.\n"); fprintf(stderr," Type of heterogeneity is 0 for constant switching; 1 for stepwise change; 2 for no temporal change (only spatial change).\n"); fprintf(stderr," If type = 0; pLH pHL is probability of switching from low-sex to high-sex state (and vice versa).\n"); fprintf(stderr," If type = 1; pLH is time (units of 2N generations) when switch occurs.\n"); fprintf(stderr," If type = 2; these are not used so should be set to zero.\n"); fprintf(stderr," [SexL_j SexH_j] are d pairs of low-sex, high-sex frequencies in deme j (if type = 0).\n"); fprintf(stderr," OR they are d pairs of initial-frequency, changed-frequency of sex (if type = 1).\n"); fprintf(stderr," Only SexL_j is defined if just spatial heterogeneity is present (if type = 2).\n"); fprintf(stderr," Note that with -H, one must first specify -I to specify subdivision (even if only one population).\n"); fprintf(stderr,"\n"); fprintf(stderr,"See documentation for further details.\n"); fprintf(stderr,"\n"); exit(1); } void inputtest(unsigned int argno, unsigned int argmax, char *args[]){ if( argno >= argmax || args[argno][0] == '-' ){ fprintf(stderr,"Incorrect command line setup.\n"); usage(); } } /* Main program */ int main(int argc, char *argv[]){ unsigned int x, i, j, z; /* Assignment counter, rep counter, indv counter, argument counter */ unsigned int pST = 0; /* State of reproduction heterogeneity */ unsigned int npST = 0; /* State of reproduction heterogeneity */ unsigned int Ntot = 0; /* Total number of samples at time */ unsigned int IwithT = 0; /* Total within individual samples */ unsigned int IbetT = 0; /* Total between individual samples */ unsigned int IwithT2 = 0; /* Sum for checking structured population case */ unsigned int IbetT2 = 0; /* Sum for checking structured population case */ unsigned int IwithC = 0; /* Cumulative Iwith sum */ unsigned int IbetC = 0; /* Cumulative Ibet sum */ unsigned int esex = 0; /* Total sex events (segregation of paired samples) */ unsigned int CsexS = 0; /* Switch once sex samples chosen */ unsigned int done = 0; /* Is simulation complete? */ unsigned int nbreaks = 0; /* Number of non-rec tracts */ unsigned int event = 0; /* What event happens? */ unsigned int deme = 0; /* Which deme does event happen in? */ unsigned int drec = 0; /* Receiving deme for migration event */ unsigned int e2 = 0; /* Outcome of mig sampling, type of deme that migrates */ unsigned int count = 0; /* For creating ancestry table */ unsigned int exr = INITBR; /* Extra rows */ unsigned int exc = INITBR; /* Extra columns */ unsigned int NMax = 0; /* Max samples present (for correct table searching!) */ unsigned int Itot = 0; /* Number of initial samples */ unsigned int Nreps = 0; /* Number of simulation replicates */ unsigned int pSTIN = 2; /* Determine type of heterogeneity (0 = fluctuating sex, 1 = stepwise change, 2 = constant sex) */ unsigned int N = 0; /* Population Size */ unsigned int gcalt = 0; /* How to alter number samples following GC event */ unsigned int argx = 6; /* Extra command line inputs, for parameter definitions */ unsigned int prtrees = 0; /* Print out trees to file */ unsigned int isrec = 0; /* Has rec been defined? */ unsigned int ismig = 0; /* Has population structure been defined? */ unsigned int isburst = 0; /* Has a burst of mutations been defined? */ unsigned int ismsp = 0; /* Use MS-style printout? */ unsigned int nmutT = 0; /* Total mutants (for printout) */ unsigned int mind2 = 0; unsigned int maxd2 = 0; unsigned int ismut = 0; /* Mutation defined? */ unsigned int mburst = 0; /* Max burst size */ unsigned int isexp = 0; /* Assume exponential growth/decay? */ unsigned int achange = 0; /* Has there been a coal event? If so then extra checks needed */ unsigned int iscmp = 0; /* Switch to denote whether to print off table of coalescent times */ double bsex = 0; /* Baseline rate of sex (for initial inputting) */ double pLH = 0; /* Prob of low-sex to high-sex transition, OR time of transition if stepwise change */ double pHL = 0; /* Prob of high-sex to low-sex transition */ double Ttot = 0; /* Time in past, initiate at zero */ double NextT = 0; /* Next time, after drawing event */ double tls = 0; /* 'Time since Last Switch' or tls */ double tts = 0; /* 'Time to switch' */ double nosex = 0; /* Probability of no sexual reproduction over all demes */ double psum = 0; /* Sum of transition probs (first go) */ double tjump = 0; /* Time until next event */ double mind = 0; /* Min tract dist */ double maxd = 0; /* Max tract dist */ double gmi = 0; /* MITOTIC gene conversion probability */ double gme = 0; /* MEIOTIC gene conversion probability */ double theta = 0; /* Scaled mutation rate, 4Nmu */ double mig = 0; /* Migration rate between demes */ double mrec = 0; /* MITOTIC recombination (crossover) rate 2N(cA) */ double lambdami = 0; /* Average length of MITOTIC GC event */ double lambdame = 0; /* Average length of MEIOTIC GC event */ double bigQmi = 1/(1.0*0); /* Relative length of lambdami (for GC prob calculations) */ double bigQme = 1/(1.0*0); /* Relative length of lambdame (for GC prob calculations) */ double pburst = 0; /* Probability that subsequent mutations will cluster */ double bdist = 0; /* Max distance if mutations cluster */ double alpha = 0; /* Population growth/shrink parameter */ char Tout[32]; /* String to hold filename in (Trees) */ FILE *ofp_tr = NULL; /* Pointer for tree output */ FILE *ofp_sd; /* Pointer for seed output */ /* GSL random number definitions */ const gsl_rng_type * T; gsl_rng * r; /* Reading in data from command line */ if(argc < 6){ fprintf(stderr,"At least 6 inputs are needed.\n"); usage(); } N = atoi(argv[1]); if(N <= 0){ fprintf(stderr,"Total Population size N is zero or negative, not allowed.\n"); usage(); } IwithT = atoi(argv[2]); IbetT = atoi(argv[3]); Itot = 2*IwithT + IbetT; if(Itot <= 1){ fprintf(stderr,"More than one sample must be initially present to execute the simulation.\n"); usage(); } bsex = strtod(argv[4],NULL); if( bsex <= 0 || bsex > 1){ fprintf(stderr,"Baseline rate of sexual reproduction has to lie between 0 and 1.\n"); usage(); } /* Number of samples/reps to take */ Nreps = atoi(argv[5]); if(Nreps <= 0){ fprintf(stderr,"Must set positive number of repetitions.\n"); usage(); } /* Initial state of two samples; Iwith = No. of within host Ibet = No. of between host So total number of initial samples in a deme = 2*Iwith + Ibet THEN sexL[i], sexH[i] = low-sex, high-sex rate in each deme */ unsigned int *Iwith = calloc(1,sizeof(unsigned int)); /* Within-individual samples */ unsigned int *Ibet = calloc(1,sizeof(unsigned int)); /* Between-individual samples */ unsigned int *Nwith = calloc(1,sizeof(unsigned int)); /* To be used in individual rep */ unsigned int *Nbet = calloc(1,sizeof(unsigned int)); /* To be used in individual rep */ unsigned int *zeros = calloc(1,sizeof(unsigned int)); /* Placeholder array of zeros */ unsigned int *demes = calloc(1,sizeof(unsigned int)); /* Indices of demes (for sampling) */ double *sexL = calloc(1,sizeof(double)); /* Low-sex rates */ double *sexH = calloc(1,sizeof(double)); /* High-sex rates */ *(Iwith + 0) = IwithT; *(Ibet + 0) = IbetT; *(sexL + 0) = bsex; *(sexH + 0) = 0; *(zeros + 0) = 0; *(demes + 0) = 0; /* Now moving onto case-by-case parameter setting */ /* Based on routine as used in ms (Hudson 2002, Bioinformatics) */ if(argc > 6){ while(argx < argc){ if(argv[argx][0] != '-'){ fprintf(stderr,"Further arguments should be of form -C, for C a defined character.\n"); usage(); } switch ( argv[argx][1] ){ case 't': /* Defining Mutation Rate (theta) */ ismut = 1; argx++; inputtest(argx, argc, argv); theta = strtod(argv[argx],NULL); if(theta <= 0){ fprintf(stderr,"Mutation rate must be a positive value.\n"); usage(); } argx++; break; case 'r': /* Defining recombination (cross over) */ isrec = 1; argx++; inputtest(argx, argc, argv); rec = strtod(argv[argx],NULL); if(rec < 0){ fprintf(stderr,"Must define a positive recombination rate.\n"); usage(); } argx++; inputtest(argx, argc, argv); nsites = atoi(argv[argx]); if(nsites < 2 && rec > 0){ fprintf(stderr,"Must define at least two sites with recombination.\n"); usage(); } argx++; break; case 'x': /* Defining MITOTIC recombination (cross over) */ if(isrec == 0){ fprintf(stderr,"Have to define number of sites first (using -r) before defining mitotic crossover rates.\n"); usage(); } argx++; inputtest(argx, argc, argv); mrec = strtod(argv[argx],NULL); if(mrec < 0){ fprintf(stderr,"Must define a positive mitotic recombination rate.\n"); usage(); } if(nsites < 2 && mrec > 0){ fprintf(stderr,"Must define at least two sites with mitotic recombination.\n"); usage(); } argx++; break; case 'T': /* Print trees? */ prtrees = 1; argx++; break; case 'c': /* MEIOTIC gene conversion */ if(isrec == 0){ fprintf(stderr,"Have to define number of sites first (using -r) before defining conversion rates.\n"); usage(); } argx++; inputtest(argx, argc, argv); gme = strtod(argv[argx],NULL); if(gme < 0){ fprintf(stderr,"Must define a positive meiotic gene conversion rate.\n"); usage(); } if(nsites < 2 && gme > 0){ fprintf(stderr,"Must define at least two sites with meiotic gene conversion.\n"); usage(); } argx++; inputtest(argx, argc, argv); lambdame = strtod(argv[argx],NULL); if(lambdame < 1){ fprintf(stderr,"With meiotic gene conversion, average length (lambda) has to be at least 1.\n"); usage(); } bigQme = (nsites-1)/(1.0*lambdame); if((bigQme < WARNQ) && (nsites > 1)){ fprintf(stderr,"WARNING: Simulation assumes that lambda ~ nsites.\n"); fprintf(stderr,"Too large a lambda might produce inaccurate coalescent times.\n"); } argx++; break; case 'm': /* MITOTIC gene conversion */ if(isrec == 0){ fprintf(stderr,"Have to define number of sites first (using -r) before defining conversion rates.\n"); usage(); } argx++; inputtest(argx, argc, argv); gmi = strtod(argv[argx],NULL); if(gmi < 0){ fprintf(stderr,"Must define a positive mitotic gene conversion rate.\n"); usage(); } argx++; inputtest(argx, argc, argv); lambdami = strtod(argv[argx],NULL); if(lambdami < 1 && nsites > 1){ fprintf(stderr,"With mitotic gene conversion, average length (lambda) has to be at least 1 with multiple sites.\n"); usage(); } bigQmi = (nsites-1)/(1.0*lambdami); if((bigQmi < WARNQ) && (nsites > 1)){ fprintf(stderr,"WARNING: Simulation assumes that lambda ~ nsites.\n"); fprintf(stderr,"Too large a lambda might produce inaccurate coalescent times.\n"); } argx++; break; case 'I': /* Population subdivision (Island model) */ ismig = 1; argx++; inputtest(argx, argc, argv); d = atoi(argv[argx]); if(d <= 0){ fprintf(stderr,"Number of demes has to be a positive integer.\n"); usage(); } if(N%d != 0){ fprintf(stderr,"Population size must be a multiple of deme number.\n"); usage(); } N = (unsigned int)(N/(d*1.0)); /* Scaling NT to a demetic size, for more consistent use in calculations */ if(d > 1){ /* Assigning per-deme samples */ Iwith = (unsigned int *)realloc(Iwith,d*sizeof(unsigned int)); Ibet = (unsigned int *)realloc(Ibet,d*sizeof(unsigned int)); Nwith = (unsigned int *)realloc(Nwith,d*sizeof(unsigned int)); Nbet = (unsigned int *)realloc(Nbet,d*sizeof(unsigned int)); zeros = (unsigned int *)realloc(zeros,d*sizeof(unsigned int)); demes = (unsigned int *)realloc(demes,d*sizeof(unsigned int)); sexL = (double *)realloc(sexL,d*sizeof(double)); sexH = (double *)realloc(sexH,d*sizeof(double)); for(x = 0; x < d; x++){ argx++; inputtest(argx, argc, argv); *(Iwith + x) = atoi(argv[argx]); argx++; inputtest(argx, argc, argv); *(Ibet + x) = atoi(argv[argx]); *(sexL + x) = bsex; *(sexH + x) = 0; *(zeros + x) = 0; *(demes + x) = x; IwithT2 += (*(Iwith + x)); IbetT2 += (*(Ibet + x)); } if( IwithT2 != IwithT ){ fprintf(stderr,"Sum of paired per-deme samples should equal total samples.\n"); usage(); } if( IbetT2 != IbetT ){ fprintf(stderr,"Sum of unpaired per-deme samples should equal total samples.\n"); usage(); } }else if(d == 1){ argx += 2; } argx++; inputtest(argx, argc, argv); mig = strtod(argv[argx],NULL); mig = mig/(2.0*N*d); if(mig < 0){ fprintf(stderr,"Migration rate must be a positive (or zero) value.\n"); usage(); } if((d > 1) && (mig == 0)){ fprintf(stderr,"Migration rate cannot be zero with multiple demes.\n"); usage(); } argx++; break; case 'H': if(ismig == 0){ fprintf(stderr,"Have to define number of demes first (using -I) before defining heterogeneity.\n"); usage(); } /* Defining type of heterogeneity */ argx++; inputtest(argx, argc, argv); pSTIN = atoi(argv[argx]); argx++; inputtest(argx, argc, argv); pLH = strtod(argv[argx],NULL); argx++; inputtest(argx, argc, argv); pHL = strtod(argv[argx],NULL); if(pSTIN != 0 && pSTIN != 1 && pSTIN != 2){ fprintf(stderr,"pSTIN has to equal 0, 1 or 2.\n"); usage(); } if(pSTIN != 1){ if(pHL < 0 || pHL > 1 || pLH < 0 || pLH > 1){ fprintf(stderr,"Sex transition probabilities have to lie between 0 and 1 (if there is no stepwise change in sex).\n"); usage(); } } if( (pHL == 0 || pLH == 0 ) && pSTIN == 0){ fprintf(stderr,"Sex transition probabilities have to lie between 0 and 1 with fluctuating sex.\n"); usage(); } for(x = 0; x < d; x++){ argx++; inputtest(argx, argc, argv); *(sexL + x) = strtod(argv[argx],NULL); argx++; inputtest(argx, argc, argv); *(sexH + x) = strtod(argv[argx],NULL); if( *(sexL + x) < 0 || *(sexL + x) > 1 || *(sexH + x) < 0 || *(sexH + x) > 1){ fprintf(stderr,"Rate of sexual reproduction has to lie between 0 and 1.\n"); usage(); } if( *(sexH + x) == 0 && pSTIN == 0){ fprintf(stderr,"With temporally heterogeneous sex, high rate cannot be zero.\n"); usage(); } if((*(sexL + x) > *(sexH + x)) && pSTIN == 0){ fprintf(stderr,"All low-sex values must be less than or equal to high-sex values. Please re-check.\n"); usage(); } } argx++; break; case 'P': ismsp = 1; argx++; break; case 'D': iscmp = 1; argx++; break; case 'b': if(isrec == 0){ fprintf(stderr,"Have to define number of breakpoints first (using -r) before defining burst of mutations.\n"); usage(); } if(ismut == 0){ fprintf(stderr,"Need to define a mutation rate first.\n"); usage(); } isburst = 1; argx++; inputtest(argx, argc, argv); pburst = strtod(argv[argx],NULL); argx++; inputtest(argx, argc, argv); mburst = atoi(argv[argx]); argx++; inputtest(argx, argc, argv); bdist = strtod(argv[argx],NULL); if( (pburst < 0) || (pburst > 1) ){ fprintf(stderr,"Burst probability has to lie between 0 and 1.\n"); usage(); } if(mburst == 0){ fprintf(stderr,"Max burst size has to be greater than zero.\n"); usage(); } if(bdist == 0){ fprintf(stderr,"Burst distance has to be greater than zero.\n"); usage(); } argx++; break; case 'G': isexp = 1; argx++; inputtest(argx, argc, argv); alpha = strtod(argv[argx],NULL); if(alpha <= 0){ fprintf(stderr,"Growth rate has to be a positive, non-zero value.\n"); usage(); } argx++; break; default: /* If none of these cases chosen, exit with error message */ fprintf(stderr,"Error: Non-standard input given.\n"); usage(); break; } } } if(ismut == 0 && prtrees == 0){ fprintf(stderr,"Error: Have to define a mutation rate or print out trees.\n"); usage(); } if(isrec == 1){ rec = rec/(2.0*(nsites-1)*N*d); mrec = mrec/(2.0*(nsites-1)*N*d); gme = ((gme)/(2.0*N*d)); gmi = ((gmi)/(2.0*N*d)); } if(isburst == 1){ bdist = bdist/(1.0*nsites); } if(d == 1){ mig = 0; /* Set migration to zero if only one deme, as a precaution */ } if(rec == 0 && mrec == 0 && gmi == 0 && gme == 0 && isburst == 0){ nsites = 1; /* Set number of sites to 1 if no recombination OR gc, as a precaution */ } if(nsites == 1){ rec = 0; mrec = 0; } /* Arrays definition and memory assignment */ unsigned int *nlrec = calloc(d,sizeof(unsigned int)); /* Non-recombinable samples 1 */ unsigned int *nlrec2 = calloc(d,sizeof(unsigned int)); /* Non-recombinable samples 2 */ unsigned int *nlrecx = calloc(d,sizeof(unsigned int)); /* Non-recombinable samples FOR PARIED SAMPLES */ unsigned int *evsex = calloc(d,sizeof(unsigned int)); /* Number of sex events per deme */ unsigned int *csex = calloc(2,sizeof(unsigned int)); /* Does sex occur or not? */ unsigned int *draw = calloc(13,sizeof(unsigned int)); /* Event that happens */ unsigned int *draw2 = calloc(d,sizeof(unsigned int)); /* Deme in which event happens */ unsigned int *draw3 = calloc(2,sizeof(unsigned int)); /* Which type of sample migrates */ double *Nsamps = calloc(2,sizeof(double)); /* Within and between-indv samples in deme */ int *WCH = calloc(d,sizeof(int)); /* How within-indv samples change */ int *BCH = calloc(d,sizeof(int)); /* How between-indv samples change */ int *WCHex = calloc(d,sizeof(int)); /* Extra calc if null values formed */ int *BCHex = calloc(d,sizeof(int)); /* Extra calc if null values formed */ double *sexC = calloc(d,sizeof(double)); /* Current rates of sex per deme */ double *sexCInv = calloc(d,sizeof(double)); /* Inverse of current rates of sex (1-sexC) */ double *psex = calloc(2,sizeof(double)); /* Individual probabilities if individuals undergo sex or not */ double *pr_rsums = calloc(13,sizeof(double)); /* Rowsums of probs (for event choosing) */ double **pr = calloc(13,sizeof(double *)); /* Probability matrix per deme */ for (j = 0; j < 13; j++){ /* Assigning space for each population within each deme */ pr[j] = calloc(d,sizeof(double)); } /* create a generator chosen by the environment variable GSL_RNG_TYPE */ gsl_rng_env_setup(); if (!getenv("GSL_RNG_SEED")) gsl_rng_default_seed = time(0); T = gsl_rng_default; r = gsl_rng_alloc(T); ofp_sd = fopen("Seed.dat","w"); fprintf(ofp_sd,"%lu\n",gsl_rng_default_seed); fclose(ofp_sd); if(ismsp == 1){ for(z = 0; z < argc; z++){ printf("%s ",argv[z]); } printf("\n"); printf("%lu\n",gsl_rng_default_seed); } /* Creating necessary directories */ if((rec > 0 || mrec > 0 || gmi > 0 || gme > 0) && (nsites != 1) && (prtrees == 1)){ mkdir("Trees/", 0777); } if(ismut == 1){ mkdir("Mutations/", 0777); } if(iscmp == 1){ mkdir("CoalTimes/", 0777); } /* Running the simulation Nreps times */ for(i = 0; i < Nreps; i++){ /* printf("Starting Run %d\n",i); */ nmutT = 0; /* Setting up type of sex heterogeneity */ if(pSTIN == 0){ pST = gsl_ran_bernoulli(r,pLH/(pLH+pHL)); /* Randomly assigning initial low-sex or high-sex state */ }else if(pSTIN == 1){ pST = 2; }else if(pSTIN == 2){ pST = 3; } Ttot = 0; Ntot = Itot; NMax = Itot; exr = INITBR; exc = INITBR; for(x = 0; x < d; x++){ *(Nwith + x) = *(Iwith + x); /* Resetting number of within-host samples */ *(Nbet + x) = *(Ibet + x); /* Resetting number of between-host samples */ *(nlrec + x) = 0; /* Genome not affected by recombination */ *(nlrec2 + x) = 0; /* Genome not affected by recombination */ *(nlrecx + x) = 0; /* Genome not affected by recombination (paired samples) */ } /* Setting up temporal heterogeneity */ rate_change(N,pST,pLH,pHL,sexH,sexL,0,sexC,sexCInv,&tts,&npST,r); pST = npST; tls = 0; /* Setting up summary table of individual samples */ /* ASSIGNING MEMORY FROM SCRATCH HERE, SINCE TABLES WILL BE MODIFIED FOR EACH SIM */ unsigned int **indvs = calloc(Itot+exr,sizeof(unsigned int *)); /* Table of individual samples */ int **GType = calloc(Itot+exr,sizeof(int *)); /* Table of sample genotypes */ double **CTms = calloc(Itot+exr,sizeof(double *)); /* Coalescent times per sample */ int **TAnc = calloc(Itot+exr,sizeof(int *)); /* Table of ancestors for each sample */ unsigned int **breaks = calloc(2,sizeof(unsigned int *)); /* Table of breakpoints created in the simulation */ double **TFin = calloc((Itot-1),sizeof(double *)); /* Final ancestry table, for tree reconstruction */ unsigned int **nlri = calloc(Itot+exr,sizeof(unsigned int *)); /* Per-unpaired-sample valid bp table (for weighted sampling) */ unsigned int **nlrix = calloc(Itot+exr,sizeof(unsigned int *)); /* Per-paired-sample valid bp table (for weighted sampling) */ for(j = 0; j < (Itot+exr); j++){ /* Assigning space for each genome sample */ indvs[j] = calloc(4,sizeof(unsigned int)); GType[j] = calloc(exc+1,sizeof(int)); nlri[j] = calloc(4,sizeof(unsigned int)); nlrix[j] = calloc(4,sizeof(unsigned int)); if(j < Itot){ CTms[j] = calloc(exc+1,sizeof(double)); TAnc[j] = calloc(exc+1,sizeof(int)); if(j < (Itot - 1)){ TFin[j] = calloc(3,sizeof(double)); } } } breaks[0] = calloc(exc,sizeof(unsigned int)); breaks[1] = calloc(exc,sizeof(unsigned int)); nbreaks = 1; IwithC = 0; IbetC = 0; for(j = 0; j < Itot; j++){ *((*(indvs + j)) + 0) = j; *((*(GType + j)) + 0) = j; *((*(GType + j)) + 1) = j; *((*(CTms + j)) + 0) = j; *((*(CTms + j)) + 1) = -1; *((*(TAnc + j)) + 0) = j; /* Entry of "-1" equivalent to NA in old code, i.e. it is not ancestral, reflects extant tracts */ *((*(TAnc + j)) + 1) = (-1); } if(IwithT != 0){ for(j = 0; j < IwithT; j++){ *((*(indvs + 2*j)) + 1) = j; *((*(indvs + (2*j+1))) + 1) = j; *((*(indvs + 2*j)) + 2) = 0; *((*(indvs + (2*j+1))) + 2) = 0; *((*(nlrix + j)) + 0) = j; *((*(nlrix + j)) + 1) = 0; *((*(nlrix + j)) + 2) = (nsites-1); } for(x = 0; x < d; x++){ for(j = IwithC; j < (IwithC + *(Iwith + x)); j++){ *((*(indvs + 2*j)) + 3) = x; *((*(indvs + (2*j+1))) + 3) = x; *((*(nlrix + j)) + 3) = x; } IwithC += *(Iwith + x); } } if(IbetT != 0){ for(j = 0; j < IbetT; j++){ *((*(indvs + (2*IwithT + j))) + 1) = IwithT + j; *((*(indvs + (2*IwithT + j))) + 2) = 1; *((*(nlri + j)) + 0) = j; *((*(nlri + j)) + 1) = 0; *((*(nlri + j)) + 2) = (nsites-1); } for(x = 0; x < d; x++){ for(j = IbetC; j < (IbetC + *(Ibet + x)); j++){ *((*(indvs + (2*IwithT + j))) + 3) = x; *((*(nlri + j)) + 3) = x; } IbetC += *(Ibet + x); } } done = 0; while(done != 1){ /* Setting up vector of state-change probabilities *without sex* */ probset2(N, gmi, gme, sexC, rec, mrec, bigQmi, bigQme, nsites, nlrec, zeros, nlrecx, mig, Nwith, Nbet, zeros, 0, pr); nosex = powDUI(sexCInv,Nwith,d); /* Probability of no segregation via sex, accounting for within-deme variation */ psum = (1-nosex) + nosex*(sumT_D(pr,13,d)); /* Sum of all event probabilities, for drawing random time */ /* Intermediate error checking */ if(psum > 1){ proberr2(pr,Nwith,Nbet); } if((psum <= 0) && (isallD(sexC,d,0) != 1)){ proberr3(pr,Nwith,Nbet); } if(isanylessD_2D(pr,13,d,0) == 1){ proberr(0,pr,Nwith,Nbet,evsex); } /* Drawing time to next event, SCALED TO 2NT GENERATIONS */ if(psum == 1){ tjump = 1.0/(2.0*N*d); }else if(psum == 0){ tjump = (1.0/0.0); }else{ tjump = (gsl_ran_geometric(r,psum))/(2.0*N*d); } NextT = (Ttot + tjump); /* Outcomes depends on what's next: an event or change in rates of sex */ if(NextT > (tls + tts)){ /* If next event happens after a switch, change rates of sex */ tls = (tls + tts); /* 'Time since Last Switch' or tls */ Ttot = tls; rate_change(N,pST,pLH,pHL,sexH,sexL,1,sexC,sexCInv,&tts,&npST,r); pST = npST; }else if (NextT <= (tls + tts)){ /* If next event happens before a switch, draw an action */ Ttot = NextT; /* Determines if sex occurs; if so, which samples are chosen */ /* (deme-independent Binomial draws) */ esex = 0; CsexS = 0; vcopyUI(evsex,zeros,d); *(psex + 0) = nosex*(sumT_D(pr,13,d)); *(psex + 1) = 1-nosex; gsl_ran_multinomial(r,2,1,psex,csex); if(*(csex + 1) == 1){ /* Working out number of sex events IF it does occur */ while(CsexS == 0){ for(x = 0; x < d; x++){ *(evsex + x) = gsl_ran_binomial(r,*(sexC + x),*(Nwith + x)); esex += *(evsex + x); } if(esex > 0){ CsexS = 1; } } } unsigned int *rsex = calloc(esex,sizeof(unsigned int)); /* Now redrawing probabilities with changed configuration */ if(esex >= 1){ /* New in ARG simulation: already determining which samples have split (so can calculate recombination prob accurately) */ /* First, choosing samples to split by sex */ sexsamp(indvs, rsex, evsex, Nwith, Ntot, r); /* Then calculating relevant breakpoints in each new sample */ /* (And recalculate for paired samples) */ reccal(indvs, GType, breaks, nlri, Nbet, Nwith, rsex, esex, nlrec2, nbreaks, NMax, 1, i); reccalx(indvs, GType, breaks, nlrix, Nbet, Nwith, rsex, esex, nlrecx, nbreaks, NMax, 1, i); /* Then recalculating probability of events */ probset2(N, gmi, gme, sexC, rec, mrec, bigQmi, bigQme, nsites, nlrec, nlrec2, nlrecx, mig, Nwith, Nbet, evsex, 1, pr); if(isanylessD_2D(pr,13,d,0) == 1){ proberr(1, pr, Nwith, Nbet, evsex); } } /* Given event happens, what is that event? Weighted average based on above probabilities. Then drawing deme of event. */ rowsumD(pr,13,d,pr_rsums); gsl_ran_multinomial(r,13,1,pr_rsums,draw); event = matchUI(draw,13,1); gsl_ran_multinomial(r,d,1,(*(pr + event)),draw2); deme = matchUI(draw2,d,1); /* printf("Event is %d\n",event);*/ if(event == 9){ /* Choosing demes to swap NOW if there is a migration */ stchange2(event,deme,evsex,WCH,BCH); vsum_UI_I(Nwith, WCH, d); vsum_UI_I(Nbet, BCH, d); Ntot = 2*(sumUI(Nwith,d)) + sumUI(Nbet,d); *(Nsamps + 0) = *(Nwith + deme); *(Nsamps + 1) = *(Nbet + deme); drec = deme; while(drec == deme){ gsl_ran_choose(r,&drec,1,demes,d,sizeof(unsigned int)); } gsl_ran_multinomial(r,2,1,Nsamps,draw3); e2 = matchUI(draw3,2,1); if(e2 == 0){ /* Paired sample migrates */ (*(Nwith + deme))--; (*(Nwith + drec))++; }else if(e2 == 1){ /* Single sample migrates */ (*(Nbet + deme))--; (*(Nbet + drec))++; } } /* Change ancestry accordingly */ gcalt = 0; achange = coalesce(indvs, GType, CTms, TAnc, nlri, nlrix, Ttot, Nwith, Nbet, deme, rsex, evsex, event, drec, e2, breaks, nsites, &nbreaks, NMax, Itot, gmi, gme, bigQmi, bigQme, &gcalt, sexC, WCHex, BCHex, r, i); /* Based on outcome, altering (non-mig) states accordingly */ if(event != 9){ /* Since already done for state = 9 above... */ stchange2(event,deme,evsex,WCH,BCH); vsum_UI_I(Nwith, WCH, d); vsum_UI_I(Nbet, BCH, d); Ntot = 2*(sumUI(Nwith,d)) + sumUI(Nbet,d); *(Nsamps + 0) = *(Nwith + deme); *(Nsamps + 1) = *(Nbet + deme); if(gcalt != 0){ if(gcalt == 1){ /* GC led to new BH sample being produced */ (*(Nwith + deme))++; (*(Nsamps + 0))++; (*(Nbet + deme))--; (*(Nsamps + 1))--; Ntot++; NMax++; if(NMax > HUGEVAL){ manyr(); } } if(gcalt == 2){ /* GC led to WH sample coalescing */ (*(Nbet + deme))++; (*(Nsamps + 1))++; (*(Nwith + deme))--; (*(Nsamps + 0))--; Ntot--; } } if(achange == 1){ vsum_UI_I(Nwith, WCHex, d); vsum_UI_I(Nbet, BCHex, d); vcopyUI_I(WCHex, zeros, d); vcopyUI_I(BCHex, zeros, d); Ntot = 2*(sumUI(Nwith,d)) + sumUI(Nbet,d); *(Nsamps + 0) = *(Nwith + deme); *(Nsamps + 1) = *(Nbet + deme); achange = 0; } } if(event == 10){ NMax++; if(NMax > HUGEVAL){ manyr(); } } /* Sorting table afterwards to ensure paired samples are together */ indv_sort(indvs, NMax); /* Updating baseline recombinable material depending on number single samples */ if(isallUI(*(breaks+1),nbreaks,1,0) == 0){ reccal(indvs, GType, breaks, nlri, Nbet, Nwith, rsex, esex, nlrec, nbreaks, NMax, 0, i); reccalx(indvs, GType, breaks, nlrix, Nbet, Nwith, rsex, esex, nlrecx, nbreaks, NMax, 0, i); for(x = 0; x < d; x++){ *(nlrec2 + x) = 0; } } free(rsex); /* Can be discarded once used to change ancestry */ /* Checking if need to expand tables */ if(NMax == (exr+Itot-1)){ exr += INITBR; indvs = (unsigned int **)realloc(indvs,(Itot+exr)*sizeof(unsigned int *)); GType = (int **)realloc(GType, (Itot+exr)*sizeof(int *)); nlri = (unsigned int **)realloc(nlri,(Itot+exr)*sizeof(unsigned int *)); nlrix = (unsigned int **)realloc(nlrix,(Itot+exr)*sizeof(unsigned int *)); for(j = 0; j < (Itot+exr-INITBR); j++){ indvs[j] = (unsigned int *)realloc(*(indvs + j),4*sizeof(unsigned int)); GType[j] = (int *)realloc( *(GType + j) ,(exc + 1)*sizeof(int)); nlri[j] = (unsigned int *)realloc(*(nlri + j),4*sizeof(unsigned int)); nlrix[j] = (unsigned int *)realloc(*(nlrix + j),4*sizeof(unsigned int)); } for(j = (Itot+exr-INITBR); j < (Itot+exr); j++){ indvs[j] = (unsigned int *)calloc(4,sizeof(unsigned int)); GType[j] = (int *)calloc((exc + 1),sizeof(int)); nlri[j] = (unsigned int *)calloc(4,sizeof(unsigned int)); nlrix[j] = (unsigned int *)calloc(4,sizeof(unsigned int)); } } if(nbreaks >= exc-1){ exc += INITBR; for(j = 0; j < (Itot+exr); j++){ GType[j] = (int *)realloc( *(GType + j) ,(exc + 1)*sizeof(int)); if(j < Itot){ CTms[j] = (double *)realloc( *(CTms + j) ,(exc + 1)*sizeof(double)); TAnc[j] = (int *)realloc( *(TAnc + j) ,(exc + 1)*sizeof(int)); } } breaks[0] = (unsigned int *)realloc(*(breaks + 0),exc*sizeof(unsigned int)); breaks[1] = (unsigned int *)realloc(*(breaks + 1),exc*sizeof(unsigned int)); } /* Testing if all sites coalesced or not */ done = isallUI(*(breaks + 1),nbreaks,1,0); } } if(ismsp == 1){ printf("\n"); printf("// \n"); } if(iscmp == 1){ /* Print off table of coalescent times if requested */ printCT(CTms, breaks, nbreaks, nsites, Itot, i); } for(x = 1; x <= nbreaks; x++){ /* Creating ancestry table */ count = 0; for(j = 0; j < Itot; j++){ if((*((*(CTms + j)) + x)) != (-1.0)){ *((*(TFin + count)) + 0) = *((*(CTms + j)) + 0); if(isexp == 0){ *((*(TFin + count)) + 1) = *((*(CTms + j)) + x); }else if(isexp == 1){ *((*(TFin + count)) + 1) = (1/(1.0*alpha))*log(1 + alpha*(*((*(CTms + j)) + x))); } *((*(TFin + count)) + 2) = *((*(TAnc + j)) + x); count++; } } indv_sortD(TFin,(Itot-1),3,1); /* Using ancestry table to build tree and mutation table */ if(x < nbreaks){ maxd2 = (*((*(breaks + 0)) + x)); maxd = maxd2/(1.0*nsites); mind2 = (*((*(breaks + 0)) + (x-1))); mind = mind2/(1.0*nsites); }else if(x == nbreaks){ maxd2 = nsites; maxd = 1; mind2 = *((*(breaks + 0)) + (x-1)); mind = (mind2)/(1.0*nsites); } char *ret_tree = treemaker(TFin, theta*(maxd-mind), mind2, maxd2 ,mind, maxd, Itot, i, gmi, gme, ismsp, &nmutT, prtrees, ismut, pburst, mburst, bdist, r); if(prtrees == 1){ if((rec == 0 && gmi == 0 && gme == 0) || (nsites == 1) ){ if(i == 0){ ofp_tr = fopen("Trees.dat","w"); }else if(i > 0){ ofp_tr = fopen("Trees.dat","a+"); } fprintf(ofp_tr,"%s\n",ret_tree); }else if((rec > 0 || gmi > 0 || gme > 0) && (nsites != 1)){ sprintf(Tout,"Trees/Trees_%d.dat",i); if(x == 1){ ofp_tr = fopen(Tout,"w"); }else if(x > 1){ ofp_tr = fopen(Tout,"a+"); } fprintf(ofp_tr,"%s\n",ret_tree); } fclose(ofp_tr); } free(ret_tree); } /* Freeing memory at end of particular run */ free(breaks[1]); free(breaks[0]); for(j = 0; j < (Itot + exr); j++){ if(j < Itot){ free(TAnc[j]); free(CTms[j]); if(j < (Itot - 1)){ free(TFin[j]); } } free(nlrix[j]); free(nlri[j]); free(GType[j]); free(indvs[j]); } free(nlrix); free(nlri); free(TFin); free(breaks); free(TAnc); free(CTms); free(GType); free(indvs); } /* Freeing memory and wrapping up */ gsl_rng_free(r); for(x = 0; x < 13; x++){ free(pr[x]); } free(pr); free(pr_rsums); free(psex); free(sexCInv); free(sexC); free(nlrecx); free(nlrec2); free(nlrec); free(sexH); free(sexL); free(BCHex); free(WCHex); free(BCH); free(WCH); free(Nsamps); free(draw3); free(draw2); free(draw); free(csex); free(evsex); free(demes); free(zeros); free(Nbet); free(Nwith); free(Ibet); free(Iwith); return 0; } /* End of main program */ /* End of File */
{ "alphanum_fraction": 0.5496680213, "avg_line_length": 33.2148288973, "ext": "c", "hexsha": "11b6ebd68f683a3a63116afbe3a1a9a9c29b3ab9", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7895d6acb20310af9ad02f548a2d29ee2817b721", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MattHartfield/FacSexCoalescent", "max_forks_repo_path": "FacSexCoalescent.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "7895d6acb20310af9ad02f548a2d29ee2817b721", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MattHartfield/FacSexCoalescent", "max_issues_repo_path": "FacSexCoalescent.c", "max_line_length": 541, "max_stars_count": 3, "max_stars_repo_head_hexsha": "7895d6acb20310af9ad02f548a2d29ee2817b721", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MattHartfield/FacSexCoalescent", "max_stars_repo_path": "FacSexCoalescent.c", "max_stars_repo_stars_event_max_datetime": "2018-10-04T15:53:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T20:23:12.000Z", "num_tokens": 48489, "size": 139768 }
/** * * @file qwrapper_dlange.c * * PLASMA core_blas quark wrapper * PLASMA is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * * @version 2.6.0 * @author Julien Langou * @author Henricus Bouwmeester * @author Mathieu Faverge * @date 2010-11-15 * @generated d Tue Jan 7 11:44:56 2014 * **/ #include <lapacke.h> #include "common.h" /***************************************************************************//** * **/ void QUARK_CORE_dlange(Quark *quark, Quark_Task_Flags *task_flags, int norm, int M, int N, const double *A, int LDA, int szeA, int szeW, double *result) { szeW = max(1, szeW); DAG_CORE_LANGE; QUARK_Insert_Task(quark, CORE_dlange_quark, task_flags, sizeof(PLASMA_enum), &norm, VALUE, sizeof(int), &M, VALUE, sizeof(int), &N, VALUE, sizeof(double)*szeA, A, INPUT, sizeof(int), &LDA, VALUE, sizeof(double)*szeW, NULL, SCRATCH, sizeof(double), result, OUTPUT, 0); } /***************************************************************************//** * **/ void QUARK_CORE_dlange_f1(Quark *quark, Quark_Task_Flags *task_flags, PLASMA_enum norm, int M, int N, const double *A, int LDA, int szeA, int szeW, double *result, double *fake, int szeF) { szeW = max(1, szeW); DAG_CORE_LANGE; if ( result == fake ) { QUARK_Insert_Task(quark, CORE_dlange_quark, task_flags, sizeof(PLASMA_enum), &norm, VALUE, sizeof(int), &M, VALUE, sizeof(int), &N, VALUE, sizeof(double)*szeA, A, INPUT, sizeof(int), &LDA, VALUE, sizeof(double)*szeW, NULL, SCRATCH, sizeof(double), result, OUTPUT | GATHERV, 0); } else { QUARK_Insert_Task(quark, CORE_dlange_f1_quark, task_flags, sizeof(PLASMA_enum), &norm, VALUE, sizeof(int), &M, VALUE, sizeof(int), &N, VALUE, sizeof(double)*szeA, A, INPUT, sizeof(int), &LDA, VALUE, sizeof(double)*szeW, NULL, SCRATCH, sizeof(double), result, OUTPUT, sizeof(double)*szeF, fake, OUTPUT | GATHERV, 0); } } /***************************************************************************//** * **/ #if defined(PLASMA_HAVE_WEAK) #pragma weak CORE_dlange_quark = PCORE_dlange_quark #define CORE_dlange_quark PCORE_dlange_quark #endif void CORE_dlange_quark(Quark *quark) { double *normA; int norm; int M; int N; double *A; int LDA; double *work; quark_unpack_args_7(quark, norm, M, N, A, LDA, work, normA); *normA = LAPACKE_dlange_work( LAPACK_COL_MAJOR, lapack_const(norm), M, N, A, LDA, work); } /***************************************************************************//** * **/ #if defined(PLASMA_HAVE_WEAK) #pragma weak CORE_dlange_f1_quark = PCORE_dlange_f1_quark #define CORE_dlange_f1_quark PCORE_dlange_f1_quark #endif void CORE_dlange_f1_quark(Quark *quark) { double *normA; int norm; int M; int N; double *A; int LDA; double *work; double *fake; quark_unpack_args_8(quark, norm, M, N, A, LDA, work, normA, fake); *normA = LAPACKE_dlange_work( LAPACK_COL_MAJOR, lapack_const(norm), M, N, A, LDA, work); }
{ "alphanum_fraction": 0.4636610002, "avg_line_length": 32.2142857143, "ext": "c", "hexsha": "6f1b0e2f01a4428b3809174aab982ed4f066df8d", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bcc99c164a256bc7df7c936b9c43afd38c12aea2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "zhuangsc/Plasma-ompss1", "max_forks_repo_path": "core_blas-qwrapper/qwrapper_dlange.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "bcc99c164a256bc7df7c936b9c43afd38c12aea2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "zhuangsc/Plasma-ompss1", "max_issues_repo_path": "core_blas-qwrapper/qwrapper_dlange.c", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "bcc99c164a256bc7df7c936b9c43afd38c12aea2", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "zhuangsc/Plasma-ompss1", "max_stars_repo_path": "core_blas-qwrapper/qwrapper_dlange.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1009, "size": 4059 }
/* specfunc/hyperg_U.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman * * 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 2 of the License, 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. */ /* Author: G. Jungman */ #include <config.h> #include <gsl/gsl_math.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_sf_exp.h> #include <gsl/gsl_sf_gamma.h> #include <gsl/gsl_sf_bessel.h> #include <gsl/gsl_sf_laguerre.h> #include <gsl/gsl_sf_pow_int.h> #include <gsl/gsl_sf_hyperg.h> #include "error.h" #include "hyperg.h" #define INT_THRESHOLD (1000.0*GSL_DBL_EPSILON) #define SERIES_EVAL_OK(a,b,x) ((fabs(a) < 5 && b < 5 && x < 2.0) || (fabs(a) < 10 && b < 10 && x < 1.0)) #define ASYMP_EVAL_OK(a,b,x) (GSL_MAX_DBL(fabs(a),1.0)*GSL_MAX_DBL(fabs(1.0+a-b),1.0) < 0.99*fabs(x)) /* Log[U(a,2a,x)] * [Abramowitz+stegun, 13.6.21] * Assumes x > 0, a > 1/2. */ static int hyperg_lnU_beq2a(const double a, const double x, gsl_sf_result * result) { const double lx = log(x); const double nu = a - 0.5; const double lnpre = 0.5*(x - M_LNPI) - nu*lx; gsl_sf_result lnK; gsl_sf_bessel_lnKnu_e(nu, 0.5*x, &lnK); result->val = lnpre + lnK.val; result->err = 2.0 * GSL_DBL_EPSILON * (fabs(0.5*x) + 0.5*M_LNPI + fabs(nu*lx)); result->err += lnK.err; result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val); return GSL_SUCCESS; } /* Evaluate u_{N+1}/u_N by Steed's continued fraction method. * * u_N := Gamma[a+N]/Gamma[a] U(a + N, b, x) * * u_{N+1}/u_N = (a+N) U(a+N+1,b,x)/U(a+N,b,x) */ static int hyperg_U_CF1(const double a, const double b, const int N, const double x, double * result, int * count) { const double RECUR_BIG = GSL_SQRT_DBL_MAX; const int maxiter = 20000; int n = 1; double Anm2 = 1.0; double Bnm2 = 0.0; double Anm1 = 0.0; double Bnm1 = 1.0; double a1 = -(a + N); double b1 = (b - 2.0*a - x - 2.0*(N+1)); double An = b1*Anm1 + a1*Anm2; double Bn = b1*Bnm1 + a1*Bnm2; double an, bn; double fn = An/Bn; while(n < maxiter) { double old_fn; double del; n++; Anm2 = Anm1; Bnm2 = Bnm1; Anm1 = An; Bnm1 = Bn; an = -(a + N + n - b)*(a + N + n - 1.0); bn = (b - 2.0*a - x - 2.0*(N+n)); An = bn*Anm1 + an*Anm2; Bn = bn*Bnm1 + an*Bnm2; if(fabs(An) > RECUR_BIG || fabs(Bn) > RECUR_BIG) { An /= RECUR_BIG; Bn /= RECUR_BIG; Anm1 /= RECUR_BIG; Bnm1 /= RECUR_BIG; Anm2 /= RECUR_BIG; Bnm2 /= RECUR_BIG; } old_fn = fn; fn = An/Bn; del = old_fn/fn; if(fabs(del - 1.0) < 10.0*GSL_DBL_EPSILON) break; } *result = fn; *count = n; if(n == maxiter) GSL_ERROR ("error", GSL_EMAXITER); else return GSL_SUCCESS; } /* Large x asymptotic for x^a U(a,b,x) * Based on SLATEC D9CHU() [W. Fullerton] * * Uses a rational approximation due to Luke. * See [Luke, Algorithms for the Computation of Special Functions, p. 252] * [Luke, Utilitas Math. (1977)] * * z^a U(a,b,z) ~ 2F0(a,1+a-b,-1/z) * * This assumes that a is not a negative integer and * that 1+a-b is not a negative integer. If one of them * is, then the 2F0 actually terminates, the above * relation is an equality, and the sum should be * evaluated directly [see below]. */ static int d9chu(const double a, const double b, const double x, gsl_sf_result * result) { const double EPS = 8.0 * GSL_DBL_EPSILON; /* EPS = 4.0D0*D1MACH(4) */ const int maxiter = 500; double aa[4], bb[4]; int i; double bp = 1.0 + a - b; double ab = a*bp; double ct2 = 2.0 * (x - ab); double sab = a + bp; double ct3 = sab + 1.0 + ab; double anbn = ct3 + sab + 3.0; double ct1 = 1.0 + 2.0*x/anbn; bb[0] = 1.0; aa[0] = 1.0; bb[1] = 1.0 + 2.0*x/ct3; aa[1] = 1.0 + ct2/ct3; bb[2] = 1.0 + 6.0*ct1*x/ct3; aa[2] = 1.0 + 6.0*ab/anbn + 3.0*ct1*ct2/ct3; for(i=4; i<maxiter; i++) { int j; double c2; double d1z; double g1, g2, g3; double x2i1 = 2*i - 3; ct1 = x2i1/(x2i1-2.0); anbn += x2i1 + sab; ct2 = (x2i1 - 1.0)/anbn; c2 = x2i1*ct2 - 1.0; d1z = 2.0*x2i1*x/anbn; ct3 = sab*ct2; g1 = d1z + ct1*(c2+ct3); g2 = d1z - c2; g3 = ct1*(1.0 - ct3 - 2.0*ct2); bb[3] = g1*bb[2] + g2*bb[1] + g3*bb[0]; aa[3] = g1*aa[2] + g2*aa[1] + g3*aa[0]; if(fabs(aa[3]*bb[0]-aa[0]*bb[3]) < EPS*fabs(bb[3]*bb[0])) break; for(j=0; j<3; j++) { aa[j] = aa[j+1]; bb[j] = bb[j+1]; } } result->val = aa[3]/bb[3]; result->err = 8.0 * GSL_DBL_EPSILON * fabs(result->val); if(i == maxiter) { GSL_ERROR ("error", GSL_EMAXITER); } else { return GSL_SUCCESS; } } /* Evaluate asymptotic for z^a U(a,b,z) ~ 2F0(a,1+a-b,-1/z) * We check for termination of the 2F0 as a special case. * Assumes x > 0. * Also assumes a,b are not too large compared to x. */ static int hyperg_zaU_asymp(const double a, const double b, const double x, gsl_sf_result *result) { const double ap = a; const double bp = 1.0 + a - b; const double rintap = floor(ap + 0.5); const double rintbp = floor(bp + 0.5); const int ap_neg_int = ( ap < 0.0 && fabs(ap - rintap) < INT_THRESHOLD ); const int bp_neg_int = ( bp < 0.0 && fabs(bp - rintbp) < INT_THRESHOLD ); if(ap_neg_int || bp_neg_int) { /* Evaluate 2F0 polynomial. */ double mxi = -1.0/x; double nmax = -(int)(GSL_MIN(ap,bp) - 0.1); double tn = 1.0; double sum = 1.0; double n = 1.0; double sum_err = 0.0; while(n <= nmax) { double apn = (ap+n-1.0); double bpn = (bp+n-1.0); tn *= ((apn/n)*mxi)*bpn; sum += tn; sum_err += 2.0 * GSL_DBL_EPSILON * fabs(tn); n += 1.0; } result->val = sum; result->err = sum_err; result->err += 2.0 * GSL_DBL_EPSILON * (fabs(nmax)+1.0) * fabs(sum); return GSL_SUCCESS; } else { return d9chu(a,b,x,result); } } /* Evaluate finite sum which appears below. */ static int hyperg_U_finite_sum(int N, double a, double b, double x, double xeps, gsl_sf_result * result) { int i; double sum_val; double sum_err; if(N <= 0) { double t_val = 1.0; double t_err = 0.0; gsl_sf_result poch; int stat_poch; sum_val = 1.0; sum_err = 0.0; for(i=1; i<= -N; i++) { const double xi1 = i - 1; const double mult = (a+xi1)*x/((b+xi1)*(xi1+1.0)); t_val *= mult; t_err += fabs(mult) * t_err + fabs(t_val) * 8.0 * 2.0 * GSL_DBL_EPSILON; sum_val += t_val; sum_err += t_err; } stat_poch = gsl_sf_poch_e(1.0+a-b, -a, &poch); result->val = sum_val * poch.val; result->err = fabs(sum_val) * poch.err + sum_err * fabs(poch.val); result->err += fabs(poch.val) * (fabs(N) + 2.0) * GSL_DBL_EPSILON * fabs(sum_val); result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val); result->err *= 2.0; /* FIXME: fudge factor... why is the error estimate too small? */ return stat_poch; } else { const int M = N - 2; if(M < 0) { result->val = 0.0; result->err = 0.0; return GSL_SUCCESS; } else { gsl_sf_result gbm1; gsl_sf_result gamr; int stat_gbm1; int stat_gamr; double t_val = 1.0; double t_err = 0.0; sum_val = 1.0; sum_err = 0.0; for(i=1; i<=M; i++) { const double mult = (a-b+i)*x/((1.0-b+i)*i); t_val *= mult; t_err += t_err * fabs(mult) + fabs(t_val) * 8.0 * 2.0 * GSL_DBL_EPSILON; sum_val += t_val; sum_err += t_err; } stat_gbm1 = gsl_sf_gamma_e(b-1.0, &gbm1); stat_gamr = gsl_sf_gammainv_e(a, &gamr); if(stat_gbm1 == GSL_SUCCESS) { gsl_sf_result powx1N; int stat_p = gsl_sf_pow_int_e(x, 1-N, &powx1N); double pe_val = powx1N.val * xeps; double pe_err = powx1N.err * fabs(xeps) + 2.0 * GSL_DBL_EPSILON * fabs(pe_val); double coeff_val = gbm1.val * gamr.val * pe_val; double coeff_err = gbm1.err * fabs(gamr.val * pe_val) + gamr.err * fabs(gbm1.val * pe_val) + fabs(gbm1.val * gamr.val) * pe_err + 2.0 * GSL_DBL_EPSILON * fabs(coeff_val); result->val = sum_val * coeff_val; result->err = fabs(sum_val) * coeff_err + sum_err * fabs(coeff_val); result->err += 2.0 * GSL_DBL_EPSILON * (M+2.0) * fabs(result->val); result->err *= 2.0; /* FIXME: fudge factor... why is the error estimate too small? */ return stat_p; } else { result->val = 0.0; result->err = 0.0; return stat_gbm1; } } } } /* Based on SLATEC DCHU() [W. Fullerton] * Assumes x > 0. * This is just a series summation method, and * it is not good for large a. * * I patched up the window for 1+a-b near zero. [GJ] */ static int hyperg_U_series(const double a, const double b, const double x, gsl_sf_result * result) { const double EPS = 2.0 * GSL_DBL_EPSILON; /* EPS = D1MACH(3) */ const double SQRT_EPS = M_SQRT2 * GSL_SQRT_DBL_EPSILON; if(fabs(1.0 + a - b) < SQRT_EPS) { /* Original Comment: ALGORITHM IS BAD WHEN 1+A-B IS NEAR ZERO FOR SMALL X */ /* We can however do the following: * U(a,b,x) = U(a,a+1,x) when 1+a-b=0 * and U(a,a+1,x) = x^(-a). */ double lnr = -a * log(x); int stat_e = gsl_sf_exp_e(lnr, result); result->err += 2.0 * SQRT_EPS * fabs(result->val); return stat_e; } else { double aintb = ( b < 0.0 ? ceil(b-0.5) : floor(b+0.5) ); double beps = b - aintb; int N = aintb; double lnx = log(x); double xeps = exp(-beps*lnx); /* Evaluate finite sum. */ gsl_sf_result sum; int stat_sum = hyperg_U_finite_sum(N, a, b, x, xeps, &sum); /* Evaluate infinite sum. */ int istrt = ( N < 1 ? 1-N : 0 ); double xi = istrt; gsl_sf_result gamr; gsl_sf_result powx; int stat_gamr = gsl_sf_gammainv_e(1.0+a-b, &gamr); int stat_powx = gsl_sf_pow_int_e(x, istrt, &powx); double sarg = beps*M_PI; double sfact = ( sarg != 0.0 ? sarg/sin(sarg) : 1.0 ); double factor_val = sfact * ( GSL_IS_ODD(N) ? -1.0 : 1.0 ) * gamr.val * powx.val; double factor_err = fabs(gamr.val) * powx.err + fabs(powx.val) * gamr.err + 2.0 * GSL_DBL_EPSILON * fabs(factor_val); gsl_sf_result pochai; gsl_sf_result gamri1; gsl_sf_result gamrni; int stat_pochai = gsl_sf_poch_e(a, xi, &pochai); int stat_gamri1 = gsl_sf_gammainv_e(xi + 1.0, &gamri1); int stat_gamrni = gsl_sf_gammainv_e(aintb + xi, &gamrni); int stat_gam123 = GSL_ERROR_SELECT_3(stat_gamr, stat_gamri1, stat_gamrni); int stat_gamall = GSL_ERROR_SELECT_4(stat_sum, stat_gam123, stat_pochai, stat_powx); gsl_sf_result pochaxibeps; gsl_sf_result gamrxi1beps; int stat_pochaxibeps = gsl_sf_poch_e(a, xi-beps, &pochaxibeps); int stat_gamrxi1beps = gsl_sf_gammainv_e(xi + 1.0 - beps, &gamrxi1beps); int stat_all = GSL_ERROR_SELECT_3(stat_gamall, stat_pochaxibeps, stat_gamrxi1beps); double b0_val = factor_val * pochaxibeps.val * gamrni.val * gamrxi1beps.val; double b0_err = fabs(factor_val * pochaxibeps.val * gamrni.val) * gamrxi1beps.err + fabs(factor_val * pochaxibeps.val * gamrxi1beps.val) * gamrni.err + fabs(factor_val * gamrni.val * gamrxi1beps.val) * pochaxibeps.err + fabs(pochaxibeps.val * gamrni.val * gamrxi1beps.val) * factor_err + 2.0 * GSL_DBL_EPSILON * fabs(b0_val); if(fabs(xeps-1.0) < 0.5) { /* C X**(-BEPS) IS CLOSE TO 1.0D0, SO WE MUST BE C CAREFUL IN EVALUATING THE DIFFERENCES. */ int i; gsl_sf_result pch1ai; gsl_sf_result pch1i; gsl_sf_result poch1bxibeps; int stat_pch1ai = gsl_sf_pochrel_e(a + xi, -beps, &pch1ai); int stat_pch1i = gsl_sf_pochrel_e(xi + 1.0 - beps, beps, &pch1i); int stat_poch1bxibeps = gsl_sf_pochrel_e(b+xi, -beps, &poch1bxibeps); double c0_t1_val = beps*pch1ai.val*pch1i.val; double c0_t1_err = fabs(beps) * fabs(pch1ai.val) * pch1i.err + fabs(beps) * fabs(pch1i.val) * pch1ai.err + 2.0 * GSL_DBL_EPSILON * fabs(c0_t1_val); double c0_t2_val = -poch1bxibeps.val + pch1ai.val - pch1i.val + c0_t1_val; double c0_t2_err = poch1bxibeps.err + pch1ai.err + pch1i.err + c0_t1_err + 2.0 * GSL_DBL_EPSILON * fabs(c0_t2_val); double c0_val = factor_val * pochai.val * gamrni.val * gamri1.val * c0_t2_val; double c0_err = fabs(factor_val * pochai.val * gamrni.val * gamri1.val) * c0_t2_err + fabs(factor_val * pochai.val * gamrni.val * c0_t2_val) * gamri1.err + fabs(factor_val * pochai.val * gamri1.val * c0_t2_val) * gamrni.err + fabs(factor_val * gamrni.val * gamri1.val * c0_t2_val) * pochai.err + fabs(pochai.val * gamrni.val * gamri1.val * c0_t2_val) * factor_err + 2.0 * GSL_DBL_EPSILON * fabs(c0_val); /* C XEPS1 = (1.0 - X**(-BEPS))/BEPS = (X**(-BEPS) - 1.0)/(-BEPS) */ gsl_sf_result dexprl; int stat_dexprl = gsl_sf_exprel_e(-beps*lnx, &dexprl); double xeps1_val = lnx * dexprl.val; double xeps1_err = 2.0 * GSL_DBL_EPSILON * (1.0 + fabs(beps*lnx)) * fabs(dexprl.val) + fabs(lnx) * dexprl.err + 2.0 * GSL_DBL_EPSILON * fabs(xeps1_val); double dchu_val = sum.val + c0_val + xeps1_val*b0_val; double dchu_err = sum.err + c0_err + fabs(xeps1_val)*b0_err + xeps1_err * fabs(b0_val) + fabs(b0_val*lnx)*dexprl.err + 2.0 * GSL_DBL_EPSILON * (fabs(sum.val) + fabs(c0_val) + fabs(xeps1_val*b0_val)); double xn = N; double t_val; double t_err; stat_all = GSL_ERROR_SELECT_5(stat_all, stat_dexprl, stat_poch1bxibeps, stat_pch1i, stat_pch1ai); for(i=1; i<2000; i++) { const double xi = istrt + i; const double xi1 = istrt + i - 1; const double tmp = (a-1.0)*(xn+2.0*xi-1.0) + xi*(xi-beps); const double b0_multiplier = (a+xi1-beps)*x/((xn+xi1)*(xi-beps)); const double c0_multiplier_1 = (a+xi1)*x/((b+xi1)*xi); const double c0_multiplier_2 = tmp / (xi*(b+xi1)*(a+xi1-beps)); b0_val *= b0_multiplier; b0_err += fabs(b0_multiplier) * b0_err + fabs(b0_val) * 8.0 * 2.0 * GSL_DBL_EPSILON; c0_val = c0_multiplier_1 * c0_val - c0_multiplier_2 * b0_val; c0_err = fabs(c0_multiplier_1) * c0_err + fabs(c0_multiplier_2) * b0_err + fabs(c0_val) * 8.0 * 2.0 * GSL_DBL_EPSILON + fabs(b0_val * c0_multiplier_2) * 16.0 * 2.0 * GSL_DBL_EPSILON; t_val = c0_val + xeps1_val*b0_val; t_err = c0_err + fabs(xeps1_val)*b0_err; t_err += fabs(b0_val*lnx) * dexprl.err; t_err += fabs(b0_val)*xeps1_err; dchu_val += t_val; dchu_err += t_err; if(fabs(t_val) < EPS*fabs(dchu_val)) break; } result->val = dchu_val; result->err = 2.0 * dchu_err; result->err += 2.0 * fabs(t_val); result->err += 4.0 * GSL_DBL_EPSILON * (i+2.0) * fabs(dchu_val); result->err *= 2.0; /* FIXME: fudge factor */ if(i >= 2000) { GSL_ERROR ("error", GSL_EMAXITER); } else { return stat_all; } } else { /* C X**(-BEPS) IS VERY DIFFERENT FROM 1.0, SO THE C STRAIGHTFORWARD FORMULATION IS STABLE. */ int i; double dchu_val; double dchu_err; double t_val; double t_err; gsl_sf_result dgamrbxi; int stat_dgamrbxi = gsl_sf_gammainv_e(b+xi, &dgamrbxi); double a0_val = factor_val * pochai.val * dgamrbxi.val * gamri1.val / beps; double a0_err = fabs(factor_val * pochai.val * dgamrbxi.val / beps) * gamri1.err + fabs(factor_val * pochai.val * gamri1.val / beps) * dgamrbxi.err + fabs(factor_val * dgamrbxi.val * gamri1.val / beps) * pochai.err + fabs(pochai.val * dgamrbxi.val * gamri1.val / beps) * factor_err + 2.0 * GSL_DBL_EPSILON * fabs(a0_val); stat_all = GSL_ERROR_SELECT_2(stat_all, stat_dgamrbxi); b0_val = xeps * b0_val / beps; b0_err = fabs(xeps / beps) * b0_err + 4.0 * GSL_DBL_EPSILON * fabs(b0_val); dchu_val = sum.val + a0_val - b0_val; dchu_err = sum.err + a0_err + b0_err + 2.0 * GSL_DBL_EPSILON * (fabs(sum.val) + fabs(a0_val) + fabs(b0_val)); for(i=1; i<2000; i++) { double xi = istrt + i; double xi1 = istrt + i - 1; double a0_multiplier = (a+xi1)*x/((b+xi1)*xi); double b0_multiplier = (a+xi1-beps)*x/((aintb+xi1)*(xi-beps)); a0_val *= a0_multiplier; a0_err += fabs(a0_multiplier) * a0_err; b0_val *= b0_multiplier; b0_err += fabs(b0_multiplier) * b0_err; t_val = a0_val - b0_val; t_err = a0_err + b0_err; dchu_val += t_val; dchu_err += t_err; if(fabs(t_val) < EPS*fabs(dchu_val)) break; } result->val = dchu_val; result->err = 2.0 * dchu_err; result->err += 2.0 * fabs(t_val); result->err += 4.0 * GSL_DBL_EPSILON * (i+2.0) * fabs(dchu_val); result->err *= 2.0; /* FIXME: fudge factor */ if(i >= 2000) { GSL_ERROR ("error", GSL_EMAXITER); } else { return stat_all; } } } } /* Assumes b > 0 and x > 0. */ static int hyperg_U_small_ab(const double a, const double b, const double x, gsl_sf_result * result) { if(a == -1.0) { /* U(-1,c+1,x) = Laguerre[c,0,x] = -b + x */ result->val = -b + x; result->err = 2.0 * GSL_DBL_EPSILON * (fabs(b) + fabs(x)); result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val); return GSL_SUCCESS; } else if(a == 0.0) { /* U(0,c+1,x) = Laguerre[c,0,x] = 1 */ result->val = 1.0; result->err = 0.0; return GSL_SUCCESS; } else if(ASYMP_EVAL_OK(a,b,x)) { double p = pow(x, -a); gsl_sf_result asymp; int stat_asymp = hyperg_zaU_asymp(a, b, x, &asymp); result->val = asymp.val * p; result->err = asymp.err * p; result->err += fabs(asymp.val) * GSL_DBL_EPSILON * fabs(a) * p; result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val); return stat_asymp; } else { return hyperg_U_series(a, b, x, result); } } /* Assumes b > 0 and x > 0. */ static int hyperg_U_small_a_bgt0(const double a, const double b, const double x, gsl_sf_result * result, double * ln_multiplier ) { if(a == 0.0) { result->val = 1.0; result->err = 1.0; *ln_multiplier = 0.0; return GSL_SUCCESS; } else if( (b > 5000.0 && x < 0.90 * fabs(b)) || (b > 500.0 && x < 0.50 * fabs(b)) ) { int stat = gsl_sf_hyperg_U_large_b_e(a, b, x, result, ln_multiplier); if(stat == GSL_EOVRFLW) return GSL_SUCCESS; else return stat; } else if(b > 15.0) { /* Recurse up from b near 1. */ double eps = b - floor(b); double b0 = 1.0 + eps; gsl_sf_result r_Ubm1; gsl_sf_result r_Ub; int stat_0 = hyperg_U_small_ab(a, b0, x, &r_Ubm1); int stat_1 = hyperg_U_small_ab(a, b0+1.0, x, &r_Ub); double Ubm1 = r_Ubm1.val; double Ub = r_Ub.val; double Ubp1; double bp; for(bp = b0+1.0; bp<b-0.1; bp += 1.0) { Ubp1 = ((1.0+a-bp)*Ubm1 + (bp+x-1.0)*Ub)/x; Ubm1 = Ub; Ub = Ubp1; } result->val = Ub; result->err = (fabs(r_Ubm1.err/r_Ubm1.val) + fabs(r_Ub.err/r_Ub.val)) * fabs(Ub); result->err += 2.0 * GSL_DBL_EPSILON * (fabs(b-b0)+1.0) * fabs(Ub); *ln_multiplier = 0.0; return GSL_ERROR_SELECT_2(stat_0, stat_1); } else { *ln_multiplier = 0.0; return hyperg_U_small_ab(a, b, x, result); } } /* We use this to keep track of large * dynamic ranges in the recursions. * This can be important because sometimes * we want to calculate a very large and * a very small number and the answer is * the product, of order 1. This happens, * for instance, when we apply a Kummer * transform to make b positive and * both x and b are large. */ #define RESCALE_2(u0,u1,factor,count) \ do { \ double au0 = fabs(u0); \ if(au0 > factor) { \ u0 /= factor; \ u1 /= factor; \ count++; \ } \ else if(au0 < 1.0/factor) { \ u0 *= factor; \ u1 *= factor; \ count--; \ } \ } while (0) /* Specialization to b >= 1, for integer parameters. * Assumes x > 0. */ static int hyperg_U_int_bge1(const int a, const int b, const double x, gsl_sf_result_e10 * result) { if(a == 0) { result->val = 1.0; result->err = 0.0; result->e10 = 0; return GSL_SUCCESS; } else if(a == -1) { result->val = -b + x; result->err = 2.0 * GSL_DBL_EPSILON * (fabs(b) + fabs(x)); result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val); result->e10 = 0; return GSL_SUCCESS; } else if(b == a + 1) { /* U(a,a+1,x) = x^(-a) */ return gsl_sf_exp_e10_e(-a*log(x), result); } else if(ASYMP_EVAL_OK(a,b,x)) { const double ln_pre_val = -a*log(x); const double ln_pre_err = 2.0 * GSL_DBL_EPSILON * fabs(ln_pre_val); gsl_sf_result asymp; int stat_asymp = hyperg_zaU_asymp(a, b, x, &asymp); int stat_e = gsl_sf_exp_mult_err_e10_e(ln_pre_val, ln_pre_err, asymp.val, asymp.err, result); return GSL_ERROR_SELECT_2(stat_e, stat_asymp); } else if(SERIES_EVAL_OK(a,b,x)) { gsl_sf_result ser; const int stat_ser = hyperg_U_series(a, b, x, &ser); result->val = ser.val; result->err = ser.err; result->e10 = 0; return stat_ser; } else if(a < 0) { /* Recurse backward from a = -1,0. */ int scale_count = 0; const double scale_factor = GSL_SQRT_DBL_MAX; gsl_sf_result lnm; gsl_sf_result y; double lnscale; double Uap1 = 1.0; /* U(0,b,x) */ double Ua = -b + x; /* U(-1,b,x) */ double Uam1; int ap; for(ap=-1; ap>a; ap--) { Uam1 = ap*(b-ap-1.0)*Uap1 + (x+2.0*ap-b)*Ua; Uap1 = Ua; Ua = Uam1; RESCALE_2(Ua,Uap1,scale_factor,scale_count); } lnscale = log(scale_factor); lnm.val = scale_count*lnscale; lnm.err = 2.0 * GSL_DBL_EPSILON * fabs(lnm.val); y.val = Ua; y.err = 4.0 * GSL_DBL_EPSILON * (fabs(a)+1.0) * fabs(Ua); return gsl_sf_exp_mult_err_e10_e(lnm.val, lnm.err, y.val, y.err, result); } else if(b >= 2.0*a + x) { /* Recurse forward from a = 0,1. */ int scale_count = 0; const double scale_factor = GSL_SQRT_DBL_MAX; gsl_sf_result r_Ua; gsl_sf_result lnm; gsl_sf_result y; double lnscale; double lm; int stat_1 = hyperg_U_small_a_bgt0(1.0, b, x, &r_Ua, &lm); /* U(1,b,x) */ int stat_e; double Uam1 = 1.0; /* U(0,b,x) */ double Ua = r_Ua.val; double Uap1; int ap; Uam1 *= exp(-lm); for(ap=1; ap<a; ap++) { Uap1 = -(Uam1 + (b-2.0*ap-x)*Ua)/(ap*(1.0+ap-b)); Uam1 = Ua; Ua = Uap1; RESCALE_2(Ua,Uam1,scale_factor,scale_count); } lnscale = log(scale_factor); lnm.val = lm + scale_count * lnscale; lnm.err = 2.0 * GSL_DBL_EPSILON * (fabs(lm) + fabs(scale_count*lnscale)); y.val = Ua; y.err = fabs(r_Ua.err/r_Ua.val) * fabs(Ua); y.err += 2.0 * GSL_DBL_EPSILON * (fabs(a) + 1.0) * fabs(Ua); stat_e = gsl_sf_exp_mult_err_e10_e(lnm.val, lnm.err, y.val, y.err, result); return GSL_ERROR_SELECT_2(stat_e, stat_1); } else { if(b <= x) { /* Recurse backward either to the b=a+1 line * or to a=0, whichever we hit. */ const double scale_factor = GSL_SQRT_DBL_MAX; int scale_count = 0; int stat_CF1; double ru; int CF1_count; int a_target; double lnU_target; double Ua; double Uap1; double Uam1; int ap; if(b < a + 1) { a_target = b-1; lnU_target = -a_target*log(x); } else { a_target = 0; lnU_target = 0.0; } stat_CF1 = hyperg_U_CF1(a, b, 0, x, &ru, &CF1_count); Ua = 1.0; Uap1 = ru/a * Ua; for(ap=a; ap>a_target; ap--) { Uam1 = -((b-2.0*ap-x)*Ua + ap*(1.0+ap-b)*Uap1); Uap1 = Ua; Ua = Uam1; RESCALE_2(Ua,Uap1,scale_factor,scale_count); } if(Ua == 0.0) { result->val = 0.0; result->err = 0.0; result->e10 = 0; GSL_ERROR ("error", GSL_EZERODIV); } else { double lnscl = -scale_count*log(scale_factor); double lnpre_val = lnU_target + lnscl; double lnpre_err = 2.0 * GSL_DBL_EPSILON * (fabs(lnU_target) + fabs(lnscl)); double oUa_err = 2.0 * (fabs(a_target-a) + CF1_count + 1.0) * GSL_DBL_EPSILON * fabs(1.0/Ua); int stat_e = gsl_sf_exp_mult_err_e10_e(lnpre_val, lnpre_err, 1.0/Ua, oUa_err, result); return GSL_ERROR_SELECT_2(stat_e, stat_CF1); } } else { /* Recurse backward to near the b=2a+x line, then * determine normalization by either direct evaluation * or by a forward recursion. The direct evaluation * is needed when x is small (which is precisely * when it is easy to do). */ const double scale_factor = GSL_SQRT_DBL_MAX; int scale_count_for = 0; int scale_count_bck = 0; int a0 = 1; int a1 = a0 + ceil(0.5*(b-x) - a0); double Ua1_bck_val; double Ua1_bck_err; double Ua1_for_val; double Ua1_for_err; int stat_for; int stat_bck; gsl_sf_result lm_for; { /* Recurse back to determine U(a1,b), sans normalization. */ double ru; int CF1_count; int stat_CF1 = hyperg_U_CF1(a, b, 0, x, &ru, &CF1_count); double Ua = 1.0; double Uap1 = ru/a * Ua; double Uam1; int ap; for(ap=a; ap>a1; ap--) { Uam1 = -((b-2.0*ap-x)*Ua + ap*(1.0+ap-b)*Uap1); Uap1 = Ua; Ua = Uam1; RESCALE_2(Ua,Uap1,scale_factor,scale_count_bck); } Ua1_bck_val = Ua; Ua1_bck_err = 2.0 * GSL_DBL_EPSILON * (fabs(a1-a)+CF1_count+1.0) * fabs(Ua); stat_bck = stat_CF1; } if(b == 2*a1 && a1 > 1) { /* This can happen when x is small, which is * precisely when we need to be careful with * this evaluation. */ hyperg_lnU_beq2a((double)a1, x, &lm_for); Ua1_for_val = 1.0; Ua1_for_err = 0.0; stat_for = GSL_SUCCESS; } else if(b == 2*a1 - 1 && a1 > 1) { /* Similar to the above. Happens when x is small. * Use * U(a,2a-1) = (x U(a,2a) - U(a-1,2(a-1))) / (2a - 2) */ gsl_sf_result lnU00, lnU12; gsl_sf_result U00, U12; hyperg_lnU_beq2a(a1-1.0, x, &lnU00); hyperg_lnU_beq2a(a1, x, &lnU12); if(lnU00.val > lnU12.val) { lm_for.val = lnU00.val; lm_for.err = lnU00.err; U00.val = 1.0; U00.err = 0.0; gsl_sf_exp_err_e(lnU12.val - lm_for.val, lnU12.err + lm_for.err, &U12); } else { lm_for.val = lnU12.val; lm_for.err = lnU12.err; U12.val = 1.0; U12.err = 0.0; gsl_sf_exp_err_e(lnU00.val - lm_for.val, lnU00.err + lm_for.err, &U00); } Ua1_for_val = (x * U12.val - U00.val) / (2.0*a1 - 2.0); Ua1_for_err = (fabs(x)*U12.err + U00.err) / fabs(2.0*a1 - 2.0); Ua1_for_err += 2.0 * GSL_DBL_EPSILON * fabs(Ua1_for_val); stat_for = GSL_SUCCESS; } else { /* Recurse forward to determine U(a1,b) with * absolute normalization. */ gsl_sf_result r_Ua; double Uam1 = 1.0; /* U(a0-1,b,x) = U(0,b,x) */ double Ua; double Uap1; int ap; double lm_for_local; stat_for = hyperg_U_small_a_bgt0(a0, b, x, &r_Ua, &lm_for_local); /* U(1,b,x) */ Ua = r_Ua.val; Uam1 *= exp(-lm_for_local); lm_for.val = lm_for_local; lm_for.err = 0.0; for(ap=a0; ap<a1; ap++) { Uap1 = -(Uam1 + (b-2.0*ap-x)*Ua)/(ap*(1.0+ap-b)); Uam1 = Ua; Ua = Uap1; RESCALE_2(Ua,Uam1,scale_factor,scale_count_for); } Ua1_for_val = Ua; Ua1_for_err = fabs(Ua) * fabs(r_Ua.err/r_Ua.val); Ua1_for_err += 2.0 * GSL_DBL_EPSILON * (fabs(a1-a0)+1.0) * fabs(Ua1_for_val); } /* Now do the matching to produce the final result. */ if(Ua1_bck_val == 0.0) { result->val = 0.0; result->err = 0.0; result->e10 = 0; GSL_ERROR ("error", GSL_EZERODIV); } else if(Ua1_for_val == 0.0) { /* Should never happen. */ UNDERFLOW_ERROR_E10(result); } else { double lns = (scale_count_for - scale_count_bck)*log(scale_factor); double ln_for_val = log(fabs(Ua1_for_val)); double ln_for_err = GSL_DBL_EPSILON + fabs(Ua1_for_err/Ua1_for_val); double ln_bck_val = log(fabs(Ua1_bck_val)); double ln_bck_err = GSL_DBL_EPSILON + fabs(Ua1_bck_err/Ua1_bck_val); double lnr_val = lm_for.val + ln_for_val - ln_bck_val + lns; double lnr_err = lm_for.err + ln_for_err + ln_bck_err + 2.0 * GSL_DBL_EPSILON * (fabs(lm_for.val) + fabs(ln_for_val) + fabs(ln_bck_val) + fabs(lns)); double sgn = GSL_SIGN(Ua1_for_val) * GSL_SIGN(Ua1_bck_val); int stat_e = gsl_sf_exp_err_e10_e(lnr_val, lnr_err, result); result->val *= sgn; return GSL_ERROR_SELECT_3(stat_e, stat_bck, stat_for); } } } } /* Handle b >= 1 for generic a,b values. */ static int hyperg_U_bge1(const double a, const double b, const double x, gsl_sf_result_e10 * result) { const double rinta = floor(a+0.5); const int a_neg_integer = (a < 0.0 && fabs(a - rinta) < INT_THRESHOLD); if(a == 0.0) { result->val = 1.0; result->err = 0.0; result->e10 = 0; return GSL_SUCCESS; } else if(a_neg_integer && fabs(rinta) < INT_MAX) { /* U(-n,b,x) = (-1)^n n! Laguerre[n,b-1,x] */ const int n = -(int)rinta; const double sgn = (GSL_IS_ODD(n) ? -1.0 : 1.0); gsl_sf_result lnfact; gsl_sf_result L; const int stat_L = gsl_sf_laguerre_n_e(n, b-1.0, x, &L); gsl_sf_lnfact_e(n, &lnfact); { const int stat_e = gsl_sf_exp_mult_err_e10_e(lnfact.val, lnfact.err, sgn*L.val, L.err, result); return GSL_ERROR_SELECT_2(stat_e, stat_L); } } else if(ASYMP_EVAL_OK(a,b,x)) { const double ln_pre_val = -a*log(x); const double ln_pre_err = 2.0 * GSL_DBL_EPSILON * fabs(ln_pre_val); gsl_sf_result asymp; int stat_asymp = hyperg_zaU_asymp(a, b, x, &asymp); int stat_e = gsl_sf_exp_mult_err_e10_e(ln_pre_val, ln_pre_err, asymp.val, asymp.err, result); return GSL_ERROR_SELECT_2(stat_e, stat_asymp); } else if(fabs(a) <= 1.0) { gsl_sf_result rU; double ln_multiplier; int stat_U = hyperg_U_small_a_bgt0(a, b, x, &rU, &ln_multiplier); int stat_e = gsl_sf_exp_mult_err_e10_e(ln_multiplier, 2.0*GSL_DBL_EPSILON*fabs(ln_multiplier), rU.val, rU.err, result); return GSL_ERROR_SELECT_2(stat_U, stat_e); } else if(SERIES_EVAL_OK(a,b,x)) { gsl_sf_result ser; const int stat_ser = hyperg_U_series(a, b, x, &ser); result->val = ser.val; result->err = ser.err; result->e10 = 0; return stat_ser; } else if(a < 0.0) { /* Recurse backward on a and then upward on b. */ const double scale_factor = GSL_SQRT_DBL_MAX; const double a0 = a - floor(a) - 1.0; const double b0 = b - floor(b) + 1.0; int scale_count = 0; double lm_0, lm_1; double lm_max; gsl_sf_result r_Uap1; gsl_sf_result r_Ua; int stat_0 = hyperg_U_small_a_bgt0(a0+1.0, b0, x, &r_Uap1, &lm_0); int stat_1 = hyperg_U_small_a_bgt0(a0, b0, x, &r_Ua, &lm_1); int stat_e; double Uap1 = r_Uap1.val; double Ua = r_Ua.val; double Uam1; double ap; lm_max = GSL_MAX(lm_0, lm_1); Uap1 *= exp(lm_0-lm_max); Ua *= exp(lm_1-lm_max); /* Downward recursion on a. */ for(ap=a0; ap>a+0.1; ap -= 1.0) { Uam1 = ap*(b0-ap-1.0)*Uap1 + (x+2.0*ap-b0)*Ua; Uap1 = Ua; Ua = Uam1; RESCALE_2(Ua,Uap1,scale_factor,scale_count); } if(b < 2.0) { /* b == b0, so no recursion necessary */ const double lnscale = log(scale_factor); gsl_sf_result lnm; gsl_sf_result y; lnm.val = lm_max + scale_count * lnscale; lnm.err = 2.0 * GSL_DBL_EPSILON * (fabs(lm_max) + scale_count * fabs(lnscale)); y.val = Ua; y.err = fabs(r_Uap1.err/r_Uap1.val) * fabs(Ua); y.err += fabs(r_Ua.err/r_Ua.val) * fabs(Ua); y.err += 2.0 * GSL_DBL_EPSILON * (fabs(a-a0) + 1.0) * fabs(Ua); y.err *= fabs(lm_0-lm_max) + 1.0; y.err *= fabs(lm_1-lm_max) + 1.0; stat_e = gsl_sf_exp_mult_err_e10_e(lnm.val, lnm.err, y.val, y.err, result); } else { /* Upward recursion on b. */ const double err_mult = fabs(b-b0) + fabs(a-a0) + 1.0; const double lnscale = log(scale_factor); gsl_sf_result lnm; gsl_sf_result y; double Ubm1 = Ua; /* U(a,b0) */ double Ub = (a*(b0-a-1.0)*Uap1 + (a+x)*Ua)/x; /* U(a,b0+1) */ double Ubp1; double bp; for(bp=b0+1.0; bp<b-0.1; bp += 1.0) { Ubp1 = ((1.0+a-bp)*Ubm1 + (bp+x-1.0)*Ub)/x; Ubm1 = Ub; Ub = Ubp1; RESCALE_2(Ub,Ubm1,scale_factor,scale_count); } lnm.val = lm_max + scale_count * lnscale; lnm.err = 2.0 * GSL_DBL_EPSILON * (fabs(lm_max) + fabs(scale_count * lnscale)); y.val = Ub; y.err = 2.0 * err_mult * fabs(r_Uap1.err/r_Uap1.val) * fabs(Ub); y.err += 2.0 * err_mult * fabs(r_Ua.err/r_Ua.val) * fabs(Ub); y.err += 2.0 * GSL_DBL_EPSILON * err_mult * fabs(Ub); y.err *= fabs(lm_0-lm_max) + 1.0; y.err *= fabs(lm_1-lm_max) + 1.0; stat_e = gsl_sf_exp_mult_err_e10_e(lnm.val, lnm.err, y.val, y.err, result); } return GSL_ERROR_SELECT_3(stat_e, stat_0, stat_1); } else if(b >= 2*a + x) { /* Recurse forward from a near zero. * Note that we cannot cross the singularity at * the line b=a+1, because the only way we could * be in that little wedge is if a < 1. But we * have already dealt with the small a case. */ int scale_count = 0; const double a0 = a - floor(a); const double scale_factor = GSL_SQRT_DBL_MAX; double lnscale; double lm_0, lm_1, lm_max; gsl_sf_result r_Uam1; gsl_sf_result r_Ua; int stat_0 = hyperg_U_small_a_bgt0(a0-1.0, b, x, &r_Uam1, &lm_0); int stat_1 = hyperg_U_small_a_bgt0(a0, b, x, &r_Ua, &lm_1); int stat_e; gsl_sf_result lnm; gsl_sf_result y; double Uam1 = r_Uam1.val; double Ua = r_Ua.val; double Uap1; double ap; lm_max = GSL_MAX(lm_0, lm_1); Uam1 *= exp(lm_0-lm_max); Ua *= exp(lm_1-lm_max); for(ap=a0; ap<a-0.1; ap += 1.0) { Uap1 = -(Uam1 + (b-2.0*ap-x)*Ua)/(ap*(1.0+ap-b)); Uam1 = Ua; Ua = Uap1; RESCALE_2(Ua,Uam1,scale_factor,scale_count); } lnscale = log(scale_factor); lnm.val = lm_max + scale_count * lnscale; lnm.err = 2.0 * GSL_DBL_EPSILON * (fabs(lm_max) + fabs(scale_count * lnscale)); y.val = Ua; y.err = fabs(r_Uam1.err/r_Uam1.val) * fabs(Ua); y.err += fabs(r_Ua.err/r_Ua.val) * fabs(Ua); y.err += 2.0 * GSL_DBL_EPSILON * (fabs(a-a0) + 1.0) * fabs(Ua); y.err *= fabs(lm_0-lm_max) + 1.0; y.err *= fabs(lm_1-lm_max) + 1.0; stat_e = gsl_sf_exp_mult_err_e10_e(lnm.val, lnm.err, y.val, y.err, result); return GSL_ERROR_SELECT_3(stat_e, stat_0, stat_1); } else { if(b <= x) { /* Recurse backward to a near zero. */ const double a0 = a - floor(a); const double scale_factor = GSL_SQRT_DBL_MAX; int scale_count = 0; gsl_sf_result lnm; gsl_sf_result y; double lnscale; double lm_0; double Uap1; double Ua; double Uam1; gsl_sf_result U0; double ap; double ru; double r; int CF1_count; int stat_CF1 = hyperg_U_CF1(a, b, 0, x, &ru, &CF1_count); int stat_U0; int stat_e; r = ru/a; Ua = GSL_SQRT_DBL_MIN; Uap1 = r * Ua; for(ap=a; ap>a0+0.1; ap -= 1.0) { Uam1 = -((b-2.0*ap-x)*Ua + ap*(1.0+ap-b)*Uap1); Uap1 = Ua; Ua = Uam1; RESCALE_2(Ua,Uap1,scale_factor,scale_count); } stat_U0 = hyperg_U_small_a_bgt0(a0, b, x, &U0, &lm_0); lnscale = log(scale_factor); lnm.val = lm_0 - scale_count * lnscale; lnm.err = 2.0 * GSL_DBL_EPSILON * (fabs(lm_0) + fabs(scale_count * lnscale)); y.val = GSL_SQRT_DBL_MIN*(U0.val/Ua); y.err = GSL_SQRT_DBL_MIN*(U0.err/fabs(Ua)); y.err += 2.0 * GSL_DBL_EPSILON * (fabs(a0-a) + CF1_count + 1.0) * fabs(y.val); stat_e = gsl_sf_exp_mult_err_e10_e(lnm.val, lnm.err, y.val, y.err, result); return GSL_ERROR_SELECT_3(stat_e, stat_U0, stat_CF1); } else { /* Recurse backward to near the b=2a+x line, then * forward from a near zero to get the normalization. */ int scale_count_for = 0; int scale_count_bck = 0; const double scale_factor = GSL_SQRT_DBL_MAX; const double eps = a - floor(a); const double a0 = ( eps == 0.0 ? 1.0 : eps ); const double a1 = a0 + ceil(0.5*(b-x) - a0); gsl_sf_result lnm; gsl_sf_result y; double lm_for; double lnscale; double Ua1_bck; double Ua1_for; int stat_for; int stat_bck; int stat_e; int CF1_count; { /* Recurse back to determine U(a1,b), sans normalization. */ double Uap1; double Ua; double Uam1; double ap; double ru; double r; int stat_CF1 = hyperg_U_CF1(a, b, 0, x, &ru, &CF1_count); r = ru/a; Ua = GSL_SQRT_DBL_MIN; Uap1 = r * Ua; for(ap=a; ap>a1+0.1; ap -= 1.0) { Uam1 = -((b-2.0*ap-x)*Ua + ap*(1.0+ap-b)*Uap1); Uap1 = Ua; Ua = Uam1; RESCALE_2(Ua,Uap1,scale_factor,scale_count_bck); } Ua1_bck = Ua; stat_bck = stat_CF1; } { /* Recurse forward to determine U(a1,b) with * absolute normalization. */ gsl_sf_result r_Uam1; gsl_sf_result r_Ua; double lm_0, lm_1; int stat_0 = hyperg_U_small_a_bgt0(a0-1.0, b, x, &r_Uam1, &lm_0); int stat_1 = hyperg_U_small_a_bgt0(a0, b, x, &r_Ua, &lm_1); double Uam1 = r_Uam1.val; double Ua = r_Ua.val; double Uap1; double ap; lm_for = GSL_MAX(lm_0, lm_1); Uam1 *= exp(lm_0 - lm_for); Ua *= exp(lm_1 - lm_for); for(ap=a0; ap<a1-0.1; ap += 1.0) { Uap1 = -(Uam1 + (b-2.0*ap-x)*Ua)/(ap*(1.0+ap-b)); Uam1 = Ua; Ua = Uap1; RESCALE_2(Ua,Uam1,scale_factor,scale_count_for); } Ua1_for = Ua; stat_for = GSL_ERROR_SELECT_2(stat_0, stat_1); } lnscale = log(scale_factor); lnm.val = lm_for + (scale_count_for - scale_count_bck)*lnscale; lnm.err = 2.0 * GSL_DBL_EPSILON * (fabs(lm_for) + fabs(scale_count_for - scale_count_bck)*fabs(lnscale)); y.val = GSL_SQRT_DBL_MIN*Ua1_for/Ua1_bck; y.err = 2.0 * GSL_DBL_EPSILON * (fabs(a-a0) + CF1_count + 1.0) * fabs(y.val); stat_e = gsl_sf_exp_mult_err_e10_e(lnm.val, lnm.err, y.val, y.err, result); return GSL_ERROR_SELECT_3(stat_e, stat_bck, stat_for); } } } /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/ int gsl_sf_hyperg_U_int_e10_e(const int a, const int b, const double x, gsl_sf_result_e10 * result) { /* CHECK_POINTER(result) */ if(x <= 0.0) { DOMAIN_ERROR_E10(result); } else { if(b >= 1) { return hyperg_U_int_bge1(a, b, x, result); } else { /* Use the reflection formula * U(a,b,x) = x^(1-b) U(1+a-b,2-b,x) */ gsl_sf_result_e10 U; double ln_x = log(x); int ap = 1 + a - b; int bp = 2 - b; int stat_e; int stat_U = hyperg_U_int_bge1(ap, bp, x, &U); double ln_pre_val = (1.0-b)*ln_x; double ln_pre_err = 2.0 * GSL_DBL_EPSILON * (fabs(b)+1.0) * fabs(ln_x); ln_pre_err += 2.0 * GSL_DBL_EPSILON * fabs(1.0-b); /* error in log(x) */ stat_e = gsl_sf_exp_mult_err_e10_e(ln_pre_val + U.e10*M_LN10, ln_pre_err, U.val, U.err, result); return GSL_ERROR_SELECT_2(stat_e, stat_U); } } } int gsl_sf_hyperg_U_e10_e(const double a, const double b, const double x, gsl_sf_result_e10 * result) { const double rinta = floor(a + 0.5); const double rintb = floor(b + 0.5); const int a_integer = ( fabs(a - rinta) < INT_THRESHOLD ); const int b_integer = ( fabs(b - rintb) < INT_THRESHOLD ); /* CHECK_POINTER(result) */ if(x <= 0.0) { DOMAIN_ERROR_E10(result); } else if(a == 0.0) { result->val = 1.0; result->err = 0.0; result->e10 = 0; return GSL_SUCCESS; } else if(a_integer && b_integer) { return gsl_sf_hyperg_U_int_e10_e(rinta, rintb, x, result); } else { if(b >= 1.0) { /* Use b >= 1 function. */ return hyperg_U_bge1(a, b, x, result); } else { /* Use the reflection formula * U(a,b,x) = x^(1-b) U(1+a-b,2-b,x) */ const double lnx = log(x); const double ln_pre_val = (1.0-b)*lnx; const double ln_pre_err = fabs(lnx) * 2.0 * GSL_DBL_EPSILON * (1.0 + fabs(b)); const double ap = 1.0 + a - b; const double bp = 2.0 - b; gsl_sf_result_e10 U; int stat_U = hyperg_U_bge1(ap, bp, x, &U); int stat_e = gsl_sf_exp_mult_err_e10_e(ln_pre_val + U.e10*M_LN10, ln_pre_err, U.val, U.err, result); return GSL_ERROR_SELECT_2(stat_e, stat_U); } } } int gsl_sf_hyperg_U_int_e(const int a, const int b, const double x, gsl_sf_result * result) { gsl_sf_result_e10 re; int stat_U = gsl_sf_hyperg_U_int_e10_e(a, b, x, &re); int stat_c = gsl_sf_result_smash_e(&re, result); return GSL_ERROR_SELECT_2(stat_c, stat_U); } int gsl_sf_hyperg_U_e(const double a, const double b, const double x, gsl_sf_result * result) { gsl_sf_result_e10 re; int stat_U = gsl_sf_hyperg_U_e10_e(a, b, x, &re); int stat_c = gsl_sf_result_smash_e(&re, result); return GSL_ERROR_SELECT_2(stat_c, stat_U); } /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/ #include "eval.h" double gsl_sf_hyperg_U_int(const int a, const int b, const double x) { EVAL_RESULT(gsl_sf_hyperg_U_int_e(a, b, x, &result)); } double gsl_sf_hyperg_U(const double a, const double b, const double x) { EVAL_RESULT(gsl_sf_hyperg_U_e(a, b, x, &result)); }
{ "alphanum_fraction": 0.5611035468, "avg_line_length": 31.841506752, "ext": "c", "hexsha": "9b28835d6f1f9d9a934aef71530b0b4a0c7bcbf0", "lang": "C", "max_forks_count": 40, "max_forks_repo_forks_event_max_datetime": "2022-03-03T23:23:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-26T15:31:16.000Z", "max_forks_repo_head_hexsha": "d14edfb62795805c84a4280d67b50cca175b95af", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "manggoguy/parsec-modified", "max_forks_repo_path": "pkgs/libs/gsl/src/specfunc/hyperg_U.c", "max_issues_count": 12, "max_issues_repo_head_hexsha": "d14edfb62795805c84a4280d67b50cca175b95af", "max_issues_repo_issues_event_max_datetime": "2022-03-13T03:54:24.000Z", "max_issues_repo_issues_event_min_datetime": "2020-12-15T08:30:19.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "manggoguy/parsec-modified", "max_issues_repo_path": "pkgs/libs/gsl/src/specfunc/hyperg_U.c", "max_line_length": 123, "max_stars_count": 64, "max_stars_repo_head_hexsha": "d14edfb62795805c84a4280d67b50cca175b95af", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "manggoguy/parsec-modified", "max_stars_repo_path": "pkgs/libs/gsl/src/specfunc/hyperg_U.c", "max_stars_repo_stars_event_max_datetime": "2022-03-24T13:26:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-06T00:30:56.000Z", "num_tokens": 15660, "size": 44801 }
#ifndef MODULE_WASM_LINEAR_MEMORY_H #define MODULE_WASM_LINEAR_MEMORY_H #include <array> #include <vector> #include <algorithm> #include "wasm_base.h" #include "wasm_value.h" #include <stdexcept> #include <iostream> #include <cstring> #include <gsl/span> #include "utilities/endianness.h" namespace wasm { struct WasmLinearMemory { static constexpr const std::size_t page_size = 65536; using page_type = alignas(page_size) char[page_size]; private: using vector_type = wasm::SimpleVector<page_type>; public: using wasm_external_kind_type = parse::Memory; using page_iterator = page_type*; using const_page_iterator = const page_type*; using page_pointer = page_type*; using const_page_pointer = const page_type*; using page_reference = page_type&; using const_page_reference = const page_type&; using page_span = gsl::span<const page_type>; using const_page_span = gsl::span<const page_type>; using value_type = char; using iterator = value_type*; using const_iterator = const value_type*; using pointer = value_type*; using const_pointer = const value_type*; using reference = value_type&; using const_reference = const value_type&; using raw_span = gsl::span<const value_type>; using const_raw_span = gsl::span<const value_type>; using size_type = vector_type::size_type; using difference_type = vector_type::difference_type; WasmLinearMemory(const parse::Memory& def, const parse::DataSegment& seg); friend const_page_span pages(const WasmLinearMemory& self) { return const_page_span(self.memory_.data(), self.memory_.size()); } friend page_span pages(WasmLinearMemory& self) { return page_span(self.memory_.data(), self.memory_.size()); } friend const_raw_span data(const WasmLinearMemory& self) { return raw_span( static_cast<const_pointer>(self.vec_.data()), page_size * self.vec_.size() ); } friend raw_span data(WasmLinearMemory& self) { return raw_span( static_cast<pointer>(self.vec_.data()), page_size * self.vec_.size() ); } friend wasm_sint32_t grow_memory(WasmLinearMemory& self, wasm_uint32_t delta) { wasm_uint32_t prev = static_cast<wasm_uint32_t>(pages(self).size()); assert(prev == pages(self).size()); if(delta > 0u) { std::size_t new_size = self.vec_.size() + delta; if(new_size > maximum_) return -1; try { self.resize(self.vec_.size() + delta); } catch(std::bad_alloc& e) { return -1; } } return reinterpret_cast<const wasm_sint32_t&>(prev); } friend bool matches(const WasmLinearMemory& self, const parse::Memory& tp) { return self.memory_.size() >= tp.size() and ( self.maximum_ == tp.maximum.value_or(std::numeric_limits<std::size_t>::max()) ); } private: void resize(std::size_t n) { assert(n <= maximum_); using std::swap; vector_type tmp(n); swap(memory_, tmp); std::memcpy(v.data(), tmp.data(), tmp.size() * sizeof(tmp.front())); std::memset(v.data() + tmp.size(), 0, v.size() - tmp.size()); } vector_type memory_; const std::size_t maximum_ = std::numeric_limits<std::size_t>::max(); }; LanguageType index_type(const WasmLinearMemory& self) { return } WasmLinearMemory::size_type current_memory(const WasmLinearMemory& self) { return pages(self).size(); } WasmLinearMemory::size_type page_count(const WasmLinearMemory& self) { return current_memory(self); } WasmLinearMemory::size_type size(const WasmLinearMemory& self) { return data(self).size(); } WasmLinearMemory::WasmLinearMemory(const parse::Memory& def): memory_(def.initial), maximum_(def.maximum.value_or(std::numeric_limits<std::size_t>::max()) { auto bytes = data(*this); std::fill(bytes.begin(), bytes.end(), 0); } gsl::span<const char> compute_effective_address( const WasmLinearMemory& self, wasm_uint32_t base, wasm_uint32_t offset, std::size_t size ) { auto mem = data(self); if(mem.size() <= base) throw std::out_of_range("Base address is too large while computing linear memory effective address."); std::size_t effective_address = base; effective_address += offset; if(mem.size() <= effective_address) throw std::out_of_range("Computed effective address is too large for linear memory."); if(std::size_t remaining = mem.size() - effective_address; remaining < sizeof(Type)) throw std::out_of_range("Linear memory access partially acesses out-of-bounds memory."); return mem.subspan(effective_address, size); } gsl::span<char> compute_effective_address( WasmLinearMemory& self, wasm_uint32_t base, wasm_uint32_t offset, std::size_t size ) { auto addr = compute_effective_address(std::as_const(self), base, offset, size); const char* data = addr.data(); auto size = addr.data(); return gsl::span<char>(const_cast<char*>(data), size); } template <class Type> Type load_little_endian(const WasmLinearMemory& self, wasm_uint32_t base, wasm_uint32_t offset) { static_assert(std::is_trivially_copyable_v<Type>); static_assert(std::is_arithmetic_v<Type>); Type result; auto addr = compute_effective_address(self, base, offset, sizeof(Type)); assert(addr.size() == sizeof(result)); std::memcpy(&result, addr.data(), sizeof(result)); if(not system_is_little_endian()) { static_assert(std::is_same_v<decltype(byte_swap(value)), decltype(value)>); result = byte_swap(result); } return result; } template <class Type, class PassedType> void store_little_endian(const WasmLinearMemory& self, wasm_uint32_t base, wasm_uint32_t offset, PassedType value) { static_assert(std::is_trivially_copyable_v<Type>); static_assert(std::is_arithmetic_v<Type>); static_assert(std::is_same_v<Type, PassedType>); auto pos = compute_effective_address(self, base, offset, sizeof(Type)); assert(addr.size() == sizeof(value)); if(not system_is_little_endian()) { static_assert(std::is_same_v<decltype(byte_swap(value)), decltype(value)>); value = byte_swap(value); } std::memcpy(pos, &value, sizeof(value)); } } /* namespace wasm */ #endif /* MODULE_WASM_LINEAR_MEMORY_H */
{ "alphanum_fraction": 0.737548214, "avg_line_length": 28.806763285, "ext": "h", "hexsha": "7068e89421d640073e02d6df6636071f801710b6", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "8a56c1706e2723ece36e3642bae9e36792dbd7b2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tvanslyke/wasm-cpp", "max_forks_repo_path": "include/module/WasmLinearMemory.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "8a56c1706e2723ece36e3642bae9e36792dbd7b2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tvanslyke/wasm-cpp", "max_issues_repo_path": "include/module/WasmLinearMemory.h", "max_line_length": 114, "max_stars_count": null, "max_stars_repo_head_hexsha": "8a56c1706e2723ece36e3642bae9e36792dbd7b2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tvanslyke/wasm-cpp", "max_stars_repo_path": "include/module/WasmLinearMemory.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1481, "size": 5963 }
// Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #ifndef _HEBench_ClearText_LogReg_H_7e5fa8c2415240ea93eff148ed73539b #define _HEBench_ClearText_LogReg_H_7e5fa8c2415240ea93eff148ed73539b #include <gsl/gsl> #include "hebench/api_bridge/cpp/hebench.hpp" #include "clear_benchmark.h" template <class T> class LogReg_Benchmark : public ClearTextBenchmark { private: HEBERROR_DECLARE_CLASS_NAME(LogReg_Benchmark) public: LogReg_Benchmark(hebench::cpp::BaseEngine &engine, const hebench::APIBridge::BenchmarkDescriptor &bench_desc, const hebench::APIBridge::WorkloadParams &bench_params); ~LogReg_Benchmark() override; hebench::APIBridge::Handle encode(const hebench::APIBridge::DataPackCollection *p_parameters) override; void decode(hebench::APIBridge::Handle encoded_data, hebench::APIBridge::DataPackCollection *p_native) override; hebench::APIBridge::Handle load(const hebench::APIBridge::Handle *p_local_data, std::uint64_t count) override; void store(hebench::APIBridge::Handle remote_data, hebench::APIBridge::Handle *p_local_data, std::uint64_t count) override; hebench::APIBridge::Handle operate(hebench::APIBridge::Handle h_remote_packed, const hebench::APIBridge::ParameterIndexer *p_param_indexers) override; protected: std::uint64_t m_vector_size; hebench::APIBridge::Workload m_workload; private: static void logReg(gsl::span<T> &result, const gsl::span<const T> &V0, const gsl::span<const T> &V1, const gsl::span<const T> &V2, std::size_t element_count, hebench::APIBridge::Workload workload); }; #include "inl/bench_logreg.inl" #endif // defined _HEBench_ClearText_LogReg_H_7e5fa8c2415240ea93eff148ed73539b
{ "alphanum_fraction": 0.7326839827, "avg_line_length": 37.7142857143, "ext": "h", "hexsha": "d29be83e22918c4aa092565f8c906dd771646646", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-05T18:01:48.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-05T18:01:48.000Z", "max_forks_repo_head_hexsha": "83e4398d9271f3e077bb4dfc0a8fb04ce36e23f6", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "hebench/backend-cpu-cleartext", "max_forks_repo_path": "benchmarks/Vector/LogisticRegression/include/bench_logreg.h", "max_issues_count": 2, "max_issues_repo_head_hexsha": "83e4398d9271f3e077bb4dfc0a8fb04ce36e23f6", "max_issues_repo_issues_event_max_datetime": "2021-12-16T23:37:53.000Z", "max_issues_repo_issues_event_min_datetime": "2021-12-06T19:37:42.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "hebench/backend-cpu-cleartext", "max_issues_repo_path": "benchmarks/Vector/LogisticRegression/include/bench_logreg.h", "max_line_length": 116, "max_stars_count": 1, "max_stars_repo_head_hexsha": "83e4398d9271f3e077bb4dfc0a8fb04ce36e23f6", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "hebench/backend-cpu-cleartext", "max_stars_repo_path": "benchmarks/Vector/LogisticRegression/include/bench_logreg.h", "max_stars_repo_stars_event_max_datetime": "2022-02-28T17:57:32.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-28T17:57:32.000Z", "num_tokens": 491, "size": 1848 }
#include <math.h> #include <stdlib.h> #if !defined(__APPLE__) #include <malloc.h> #endif #include <stdio.h> #include <assert.h> #include <time.h> #include <string.h> #include <fftw3.h> #include <gsl/gsl_interp2d.h> #include <gsl/gsl_spline2d.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_sf_erf.h> #include <gsl/gsl_integration.h> #include <gsl/gsl_spline.h> #include <gsl/gsl_sf_gamma.h> #include <gsl/gsl_sf_legendre.h> #include <gsl/gsl_sf_bessel.h> #include <gsl/gsl_linalg.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_eigen.h> #include <gsl/gsl_sf_expint.h> #include <gsl/gsl_deriv.h> #include "../../../cosmolike_core/theory/basics.c" #include "tinker_emulator.h" #include "tinker_emulator.c" int main(){ //Test kernel double x0[7] = {0.0043*pow(0.7,2), 0.286*pow(0.7,2), -1, 1, 3.0, 70, 3.0}; double x1[7] = {0.0043*pow(0.7,2), 0.286*pow(0.7,2), -1, 1, 3.0, 70, 5.0}; printf("kernel : %e \n", kernel(x0, x1, emu_tinker_bias_log_lambda[0], tinkerEmuParam.tinker_bias_ncosmo)); //Test bias emulator double emu_tinker_bias_param[6]; predict_tinker_bias_parameters(0.0043*pow(0.7,2), 0.286*pow(0.7,2), -1, 1, 3.0, 70, 3.0, 0.3, emu_tinker_bias_param); double bias_ref[6] = {4.432419358797392, 0.32058653615384625, 1.3586846172228393, 1.347376928846154, 0.728081326923077, -1.0947315110189246}; printf("bias result:\n"); printf("item c ref\n"); for(int i=0; i<tinkerEmuParam.tinker_bias_nparam_redshift; ++i) printf("%d, %e, %e\n", i,emu_tinker_bias_param[i], bias_ref[i]); printf("####################\n"); //Test hmf emulator double emu_tinker_hmf_param[4]; double hmf_ref[4] = { 2.5198116919192444, 0.8454997909106351, 0.5441108055593771, 1.3001900391246013}; predict_tinker_hmf_parameters(0.0043*pow(0.7,2), 0.286*pow(0.7,2), -1, 1, 3.0, 70, 3.0, 0.3, emu_tinker_hmf_param); printf("hmf result:\n"); printf("item c ref\n"); for(int i=0; i<tinkerEmuParam.tinker_hmf_nparam_redshift; ++i) printf("%d, %e, %e\n", i,emu_tinker_hmf_param[i], hmf_ref[i]); printf("####################\n"); }
{ "alphanum_fraction": 0.6823929961, "avg_line_length": 36.0701754386, "ext": "c", "hexsha": "92d820251496f0af95553b0b752fa350aca422f1", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e70ae310bedda2850eba8ea01fc04abcb87cb337", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tmcclintock/TinkerEmulator", "max_forks_repo_path": "src/test.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "e70ae310bedda2850eba8ea01fc04abcb87cb337", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tmcclintock/TinkerEmulator", "max_issues_repo_path": "src/test.c", "max_line_length": 144, "max_stars_count": null, "max_stars_repo_head_hexsha": "e70ae310bedda2850eba8ea01fc04abcb87cb337", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tmcclintock/TinkerEmulator", "max_stars_repo_path": "src/test.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 799, "size": 2056 }
/* Copyright (c) 2014, Giuseppe Argentieri <giuseppe.argentieri@ts.infn.it> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ /* * * * Filename: total_current.c * * Description: Total current ( AC + DC ) * * Version: 1.0 * Created: 26/06/2014 14:59:12 * Revision: none * License: BSD * * Author: Giuseppe Argentieri (ga), giuseppe.argentieri@ts.infn.it * Organization: Università degli Studi di Trieste * * */ #include "funcs.h" #include <gsl/gsl_vector.h> /* * FUNCTION * Name: tot_current * Description: * */ double tot_current ( const gsl_vector* rho, void* params ) { struct f_params* pars = (struct f_params*) params ; double Omega = pars->Omega ; double o_1 = pars->omega_1 ; double D = sqrt(o_1*o_1 - Omega*Omega) ; double curr = -((VECTOR(rho, 2)*D + VECTOR(rho, 3)*Omega)/o_1) ; return (curr) ; } /* ----- end of function tot_current ----- */
{ "alphanum_fraction": 0.6977363515, "avg_line_length": 35.203125, "ext": "c", "hexsha": "f70ccf7c94d56a6b5173babbd5509b63937ae49c", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "54132a3c7dd0e83e27375f6c5f6ec154065a9695", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "j-silver/quantum_dots", "max_forks_repo_path": "total_current.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "54132a3c7dd0e83e27375f6c5f6ec154065a9695", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "j-silver/quantum_dots", "max_issues_repo_path": "total_current.c", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "54132a3c7dd0e83e27375f6c5f6ec154065a9695", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "j-silver/quantum_dots", "max_stars_repo_path": "total_current.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 554, "size": 2253 }
#include <stdio.h> #include <stdarg.h> #include <string.h> #include <math.h> #include <gbpLib.h> #include <gbpRNG.h> #include <gbpMCMC.h> #include <gsl/gsl_linalg.h> #include <gsl/gsl_fit.h> #include <gsl/gsl_interp.h> void generate_MCMC_proposition(MCMC_info *MCMC, int flag_chain_init) { // Set the parameters for first trial parameters for the proposition switch(flag_chain_init) { case GBP_TRUE: memcpy(MCMC->P_new, MCMC->P_init, (size_t)MCMC->n_P * sizeof(double)); memcpy(MCMC->P_last, MCMC->P_init, (size_t)MCMC->n_P * sizeof(double)); memcpy(MCMC->P_chain, MCMC->P_init, (size_t)MCMC->n_P * sizeof(double)); MCMC->flag_init_chain = GBP_FALSE; MCMC->n_success = 0; MCMC->n_fail = 0; MCMC->n_propositions = 0; break; case GBP_FALSE: generate_MCMC_parameters(MCMC); break; } // Keep generating new parameter sets until the mapping function is satisfied while(MCMC->map_P_to_M(MCMC->P_new, MCMC, MCMC->M_new)) { MCMC->n_map_calls++; MCMC->first_map_call = GBP_FALSE; generate_MCMC_parameters(MCMC); } MCMC->first_map_call = GBP_FALSE; MCMC->n_map_calls++; // Produce likelihood for this proposition MCMC->compute_MCMC_ln_likelihood( MCMC, MCMC->M_new, MCMC->P_new, MCMC->ln_likelihood_DS, MCMC->n_DoF_DS, &(MCMC->ln_likelihood_new), &(MCMC->n_DoF)); if(!SID_CHECK_BITFIELD_SWITCH(MCMC->mode, MCMC_MODE_PARALLEL)) { SID_Bcast(MCMC->ln_likelihood_DS, MCMC->n_DS, SID_DOUBLE, SID_MASTER_RANK, MCMC->comm); SID_Bcast(MCMC->n_DoF_DS, MCMC->n_DS, SID_INT, SID_MASTER_RANK, MCMC->comm); SID_Bcast(&(MCMC->ln_likelihood_new), 1, SID_DOUBLE, SID_MASTER_RANK, MCMC->comm); SID_Bcast(&(MCMC->n_DoF), 1, SID_INT, SID_MASTER_RANK, MCMC->comm); } MCMC->first_likelihood_call = GBP_FALSE; if(flag_chain_init) { MCMC->ln_likelihood_chain = MCMC->ln_likelihood_new; MCMC->ln_likelihood_best = MCMC->ln_likelihood_new; memcpy(MCMC->P_best, MCMC->P_new, (size_t)MCMC->n_P * sizeof(double)); MCMC->ln_Pr_chain = 0.; MCMC->ln_Pr_new = 0.; } // Keep track of the best proposition else if(MCMC->ln_likelihood_new > MCMC->ln_likelihood_best) { MCMC->ln_likelihood_best = MCMC->ln_likelihood_new; memcpy(MCMC->P_best, MCMC->P_new, (size_t)MCMC->n_P * sizeof(double)); } }
{ "alphanum_fraction": 0.6518784972, "avg_line_length": 40.3548387097, "ext": "c", "hexsha": "1774b21bf59603d47f16d6a7cc633b3b4b59d302", "lang": "C", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-01T08:14:24.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-23T00:50:40.000Z", "max_forks_repo_head_hexsha": "5157d2e377edbd4806258d1c16b329373186d43a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "gbpoole/gbpCode", "max_forks_repo_path": "src/gbpMath/gbpMCMC/generate_MCMC_proposition.c", "max_issues_count": 2, "max_issues_repo_head_hexsha": "5157d2e377edbd4806258d1c16b329373186d43a", "max_issues_repo_issues_event_max_datetime": "2019-06-18T00:40:46.000Z", "max_issues_repo_issues_event_min_datetime": "2017-07-30T11:10:49.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "gbpoole/gbpCode", "max_issues_repo_path": "src/gbpMath/gbpMCMC/generate_MCMC_proposition.c", "max_line_length": 124, "max_stars_count": 1, "max_stars_repo_head_hexsha": "5157d2e377edbd4806258d1c16b329373186d43a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "gbpoole/gbpCode", "max_stars_repo_path": "src/gbpMath/gbpMCMC/generate_MCMC_proposition.c", "max_stars_repo_stars_event_max_datetime": "2015-10-20T11:39:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-10-20T11:39:53.000Z", "num_tokens": 790, "size": 2502 }
/* least_square_solver.c written by Eunseok Lee function: obtain the least-square solution of a linear equation system v1: Feb 2, 2018 */ #include <stdio.h> #include <stdlib.h> #include <math.h> //#include <cem.h> #include <gsl/gsl_linalg.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_vector.h> void least_square_solver(double *matA, int n_row, int n_col, double *y, double *sol_x) { int i, j, k, tmp; double sum; gsl_matrix * A = gsl_matrix_alloc (n_row,n_col); gsl_matrix * V = gsl_matrix_alloc (n_col,n_col); gsl_vector * S = gsl_vector_alloc (n_col); gsl_vector * work = gsl_vector_alloc (n_col); // gsl_matrix * U = gsl_matrix_alloc (n_row-1,n_col_ids); gsl_vector * b = gsl_vector_alloc (n_row); gsl_vector * x = gsl_vector_alloc (n_col); // need to copy matA to A, y to b! for (i=0;i<n_row;i++) { for (j=0; j<n_col; j++) { gsl_matrix_set (A, i, j, *(matA+i*n_col+j)); } gsl_vector_set (b, i, y[i]); } gsl_linalg_SV_decomp(A, V, S, work); // on output, A is replaced by U! gsl_linalg_SV_solve (A, V, S, b, x); // So, A should be used instead of U, here. for (i=0;i<n_col;i++) { sol_x[i] = gsl_vector_get(x,i); } gsl_matrix_free(A); gsl_matrix_free(V); gsl_vector_free(S); gsl_vector_free(work); gsl_vector_free(b); gsl_vector_free(x); }
{ "alphanum_fraction": 0.6194503171, "avg_line_length": 27.2884615385, "ext": "c", "hexsha": "d9aa6bc9d9836308b3f3239965dd4aa20c4513b9", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "17c2ddb309f02e1203411b0bc2ff23bc4d1177ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "eunseok-lee/spin_atom_ce", "max_forks_repo_path": "src_findcluster/least_square_solver.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "17c2ddb309f02e1203411b0bc2ff23bc4d1177ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "eunseok-lee/spin_atom_ce", "max_issues_repo_path": "src_findcluster/least_square_solver.c", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "17c2ddb309f02e1203411b0bc2ff23bc4d1177ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "eunseok-lee/spin_atom_ce", "max_stars_repo_path": "src_findcluster/least_square_solver.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 431, "size": 1419 }
#ifndef CONVOLUTION_H #define CONVOLUTION_H #include <cstddef> #include <cstring> #include <iostream> extern "C" { #include <cblas.h> } using namespace std; template<typename T> constexpr T relu(T x) { return (x > 0) ? x : 0; } template<typename T> void mul_mat(T *A, double *B, double *C, size_t m, size_t k, size_t n) { for(size_t r = 0; r < m; r++) { for(size_t c = 0; c < n; c++) { double x = 0.0; for(size_t z = 0; z < k; z++) { x += A[r * k + z] * B[z * n + c]; } C[r * n + c] = x; } } } template<size_t in_maps, size_t in_height, size_t in_width, size_t conv_height, size_t conv_width, size_t vert_stride, size_t horiz_stride, size_t out_maps> struct ConvolutionLayer { static constexpr size_t conv_size = conv_height * conv_width; static constexpr size_t in_map_size = in_height * in_width; static constexpr size_t inputs_no = in_maps * in_height * in_width; static constexpr size_t parameters_no = out_maps * (conv_width * conv_height * in_maps + 1); static constexpr size_t bias_idx = conv_width * conv_height * in_maps; static constexpr size_t out_height = (in_height - conv_height) / vert_stride +1; static constexpr size_t out_width = (in_width - conv_width) / horiz_stride + 1; static constexpr size_t out_map_size = out_height * out_width; static constexpr size_t internal_no = out_maps * out_height * out_width; static constexpr size_t outputs_no = out_maps * out_height * out_width; static constexpr size_t p_idx(size_t out_map, size_t in_map, size_t conv_r, size_t conv_c) { return out_map * (in_maps * conv_height * conv_width + 1) + in_map * (conv_height * conv_width) + conv_r * conv_width + conv_c; } static void forward(double* inputs, double * parameters, double* outputs) { for (size_t j = 0; j < out_maps; j++) { double *pj = &(parameters[j*(conv_height * conv_width * in_maps + 1)]); for (size_t out_r = 0; out_r < out_height; out_r++) { for (size_t out_c = 0; out_c < out_width; out_c++) { const size_t out_idx = j * (out_map_size) + out_r * out_width + out_c; double a = 0; for (size_t i = 0; i < in_maps; i++) { const size_t i_idx = i * conv_size; const size_t i2_idx = i * in_map_size; for (size_t conv_r = 0; conv_r < conv_height; conv_r++) { for (size_t conv_c = 0; conv_c < conv_width; conv_c++) { size_t p2_idx = i_idx + conv_r * conv_width + conv_c; size_t in_idx = i2_idx + (out_r * vert_stride + conv_r) * in_width + out_c * horiz_stride + conv_c; a += pj[p2_idx] * inputs[in_idx]; } } } a += pj[bias_idx]; outputs[out_idx] = relu(a); } } } } }; template<size_t in_maps, size_t in_height, size_t in_width, size_t conv_height, size_t conv_width, size_t vert_stride, size_t horiz_stride, size_t out_maps> struct ConvolutionLayer2 { static constexpr size_t in_map_size = in_height * in_width; static constexpr size_t inputs_no = in_maps * in_map_size; static constexpr size_t out_height = (in_height - conv_height) / vert_stride +1; static constexpr size_t out_width = (in_width - conv_width) / horiz_stride + 1; static constexpr size_t out_map_size = out_height * out_width; static constexpr size_t internal_no = out_maps * out_map_size; static constexpr size_t outputs_no = out_maps * out_map_size; static constexpr size_t conv_size = conv_height * conv_width; static constexpr size_t parameters_no = out_maps * (in_maps * conv_size + 1); static constexpr size_t p_idx(size_t out_map, size_t in_map, size_t conv_r, size_t conv_c) { return out_map * (in_maps * conv_height * conv_width + 1) + in_map * (conv_height * conv_width) + conv_r * conv_width + conv_c; } static void forward(double* inputs, double *parameters, double* outputs) { double* _in = (double*) malloc(sizeof(double) * in_maps * conv_size * out_map_size); for (size_t out_r = 0; out_r < out_height; out_r++) { for (size_t out_c = 0; out_c < out_width; out_c++) { for (size_t i = 0; i < in_maps; i++) { for (size_t conv_r = 0; conv_r < conv_height; conv_r++) { for (size_t conv_c = 0; conv_c < conv_width; conv_c++) { size_t in_idx = i * in_map_size + (out_r * vert_stride + conv_r) * in_width + out_c * horiz_stride + conv_c; size_t row_idx = i * conv_size + conv_r * conv_width + conv_c; size_t _in_idx = row_idx * out_map_size + out_r * out_width + out_c; _in[_in_idx] = inputs[in_idx]; } } } } } for (size_t j = 0; j < out_maps;j++) { double bias = parameters[(j+1) * (in_maps * conv_size + 1) - 1]; for (size_t i = 0; i < out_map_size; i++) { outputs[j * out_map_size + i] = bias; } } cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, out_maps, out_map_size, in_maps * conv_size, 1.0, parameters, in_maps * conv_size + 1, _in, out_map_size, 1.0, outputs, out_map_size); for(size_t j = 0; j < out_maps * out_map_size; j++) { outputs[j] = relu(outputs[j]); } } }; #endif
{ "alphanum_fraction": 0.6187580615, "avg_line_length": 37.1712328767, "ext": "h", "hexsha": "97029be348e73492f62bd8481fca8316a2fd4e0f", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0a2599b83e2eddf4b703e9c06acbb067d430117b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tudor-berariu/cc-hacks", "max_forks_repo_path": "convolution/src/convolution.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "0a2599b83e2eddf4b703e9c06acbb067d430117b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tudor-berariu/cc-hacks", "max_issues_repo_path": "convolution/src/convolution.h", "max_line_length": 101, "max_stars_count": null, "max_stars_repo_head_hexsha": "0a2599b83e2eddf4b703e9c06acbb067d430117b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tudor-berariu/cc-hacks", "max_stars_repo_path": "convolution/src/convolution.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1519, "size": 5427 }
#ifndef DERIVATIVES_H_5CHQ89V7 #define DERIVATIVES_H_5CHQ89V7 #include <gsl/gsl> #include <tuple> #include <type_traits> namespace sens_loc::math { /// Calculate the first derivate with the central differential quotient. /// \tparam Real precision of the calculation /// \param y__1 \f$y_{i-1}\f$ /// \param y_1 \f$y_{i+1}\f$ /// \param dx \f$2. * dx\f$ /// \returns first derivative at this point of order \f$\mathcal{O}(dx^2)\f$ template <typename Real> inline Real first_derivative_central(Real y__1, Real y_1, Real dx) noexcept { static_assert(std::is_floating_point_v<Real>); Expects(dx > Real(0.)); // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) return (y_1 - y__1) / (Real(2.) * dx); } /// Calculate the second derivate with the central differential quotient. /// \tparam Real precision of the calculation /// \param y__1 \f$y_{i-1}\f$ /// \param y_0 \f$y_{i}\f$ /// \param y_1 \f$y_{i+1}\f$ /// \param dx \f$dx\f$ /// \returns second derivative at this point of order \f$\mathcal{O}(dx^2)\f$ template <typename Real> inline Real second_derivative_central(Real y__1, Real y_0, Real y_1, Real dx) noexcept { static_assert(std::is_floating_point_v<Real>); Expects(dx > Real(0.)); // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) return (y_1 + y__1 - Real(2.) * y_0) / (dx * dx); } /// Calculate the derivatives for a surface patch. /// /// Index convention: /// \f$d\_\_1 == d_{-1}\f$ /// \f$d\_\_0 == d_{0}\f$ /// \f$d\_1 == d_{1}\f$ /// /// Angle convention: /// \f$\varphi\f$ -> u direction /// \f$\theta\f$ -> v direction /// /// \tparam Real precision of the calculation /// \param d__1__1,d__1__0,d__1_1 neighbours "above" central pixel /// \param d__0__1,d__0__0,d__0_1 same row as the central pixel /// \param d_1__1,d_1__0,d_1_1 row "after" the central pixel /// \param d_phi angle between rays in x direction \f$(u - 1, u + 1)\f$ /// \param d_theta angle between rays in y direction \f$(v - 1, v + 1)\f$ /// \param d_phi_theta angle between rays in diagonal direction /// \f$(u - 1, v + 1)\f$ /// \returns partial derivatives \f$(f_u, f_v, f_uu, f_vv, f_uv)\f$ /// \pre the depth values shuold be positive, as they encode depth values /// \pre \p / d_phi, \p d_theta, \p d_phi_theta are all positive angles // clang-format off template <typename Real = float> inline std::tuple<Real, Real, Real, Real, Real> derivatives(Real d__1__1, Real d__1__0, Real d__1_1, Real d__0__1, Real d__0__0, Real d__0_1, Real d_1__1, Real d_1__0, Real d_1_1, Real d_phi, Real d_theta, Real d_phi_theta) noexcept { static_assert(std::is_floating_point_v<Real>); Expects(d_phi > 0.); Expects(d_theta > 0.); Expects(d_phi_theta > 0.); (void)d__1__1; (void)d__1_1; (void)d_1__1; (void)d_1_1; // clang-format on const Real f_u = math::first_derivative_central(d__0__1, d__0_1, d_phi); const Real f_v = math::first_derivative_central(d__1__0, d_1__0, d_theta); const Real f_uu = math::second_derivative_central(d__0__1, d__0__0, d__0_1, d_phi); const Real f_vv = math::second_derivative_central(d__1__0, d__0__0, d_1__0, d_theta); const Real f_uv = math::second_derivative_central(d__1__0, d__0__0, d_1__0, d_phi_theta); return std::make_tuple(f_u, f_v, f_uu, f_vv, f_uv); }; // clang-format on } // namespace sens_loc::math #endif /* end of include guard: DERIVATIVES_H_5CHQ89V7 */
{ "alphanum_fraction": 0.6766917293, "avg_line_length": 35.2857142857, "ext": "h", "hexsha": "1df168888a06557143f36074a538a3f354f6a9df", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5c8338276565d846c07673e83f94f6841006872b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "JonasToth/depth-conversions", "max_forks_repo_path": "src/include/sens_loc/math/derivatives.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "5c8338276565d846c07673e83f94f6841006872b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "JonasToth/depth-conversions", "max_issues_repo_path": "src/include/sens_loc/math/derivatives.h", "max_line_length": 79, "max_stars_count": 2, "max_stars_repo_head_hexsha": "5c8338276565d846c07673e83f94f6841006872b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "JonasToth/depth-conversions", "max_stars_repo_path": "src/include/sens_loc/math/derivatives.h", "max_stars_repo_stars_event_max_datetime": "2022-03-14T09:14:35.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-30T07:09:49.000Z", "num_tokens": 1172, "size": 3458 }
#include <slepcmfn.h> #include "cs.h" #include <gsl/gsl_rng.h> //for use in programs like im_clam typedef struct clam_lik_params{ int snpNumber, maxSampleSize,nstates,n1,n2,nParams; gsl_vector *sampleSizeVector,*rates, *stateVec, *resVec ; gsl_vector *paramVector,*paramCIUpper,*paramCILower, *mlParams; //For straight MLE the paramVector takes the form [N2,NA,m1,m2,t] gsl_matrix *log_afs, *transMat,*expAFS, *expAFS2, *invMatGSL, *invMatGSLA, *obsData; afsStateSpace *stateSpace ,*reducedStateSpace; gsl_rng *rng; struct site *data; double *cs_work,*new,*topA,*resultTmp,**invMat,*b,*res, *st, *top; int *dim1, *dim2, *moveA, *move, *dim1A, *dim2A; //these pointers ease the construction of sparse matrices int nnz, nnzA; double maxLik; int *map, *reverseMap; //these provide mapping of between state spaces of two phases int optimized; int rank; int Na,fEvals; double *expoArray; double meanTreeLength; cs_di *spMat, *eye, *eyeAnc, *triplet, *tmpMat, *tmpMat2; Vec x_0, x, u,bP, u2, bP2, v, y, v_seq, *x2, ancStateVec, ancResVec; Vec xInv,bInv; Mat ident,C, C2, C_transpose, D, D_copy, F, denseIdent, denseMat1, denseMat2, denseMat3; VecScatter ctx; MFN mfn; PetscInt iStart,iEnd; /* linear solver context */ PC pc; /* preconditioner context */ }clam_lik_params;
{ "alphanum_fraction": 0.6988217968, "avg_line_length": 37.7222222222, "ext": "h", "hexsha": "5c1bb533023d75f66fd9ba878be99b7ebc5d65a3", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e1643d7489106d5e040329bd0b7db75d80ce21d6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kern-lab/im_clam", "max_forks_repo_path": "im_clam.h", "max_issues_count": 3, "max_issues_repo_head_hexsha": "e55ad3d0114f2e1491989fb6a00a37f8e2e4cfec", "max_issues_repo_issues_event_max_datetime": "2018-04-08T17:04:32.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-17T09:15:17.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dortegadelv/IMaDNA", "max_issues_repo_path": "im_clam.h", "max_line_length": 107, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e55ad3d0114f2e1491989fb6a00a37f8e2e4cfec", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dortegadelv/IMaDNA", "max_stars_repo_path": "im_clam.h", "max_stars_repo_stars_event_max_datetime": "2020-04-17T17:22:14.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-22T13:06:07.000Z", "num_tokens": 448, "size": 1358 }
#ifndef ALLVARS_H #define ALLVARS_H #include <stdio.h> #include <gsl/gsl_rng.h> #include "core_simulation.h" #define ABORT(sigterm) \ do { \ printf("Error in file: %s\tfunc: %s\tline: %i\n", __FILE__, __FUNCTION__, __LINE__); \ myexit(sigterm); \ } while(0) #define STEPS 10 // Number of integration intervals between two snapshots #define MAXGALFAC 1 #define ALLOCPARAMETER 10.0 #define MAX_NODE_NAME_LEN 50 #define ABSOLUTEMAXSNAPS 1000 #define GRAVITY 6.672e-8 #define SOLAR_MASS 1.989e33 #define SOLAR_LUM 3.826e33 #define RAD_CONST 7.565e-15 #define AVOGADRO 6.0222e23 #define BOLTZMANN 1.3806e-16 #define GAS_CONST 8.31425e7 #define C 2.9979e10 #define PLANCK 6.6262e-27 #define CM_PER_MPC 3.085678e24 #define PROTONMASS 1.6726e-24 #define HUBBLE 3.2407789e-18 /* in h/sec */ #define SEC_PER_MEGAYEAR 3.155e13 #define SEC_PER_YEAR 3.155e7 // This structure contains the properties that are output struct GALAXY_OUTPUT { int SnapNum; int Type; long long GalaxyIndex; long long CentralGalaxyIndex; int SAGEHaloIndex; int SAGETreeIndex; long long SimulationHaloIndex; int mergeType; //0=none; 1=minor merger; 2=major merger; 3=disk instability; 4=disrupt to ICS int mergeIntoID; int mergeIntoSnapNum; float dT; // (sub)halo properties float Pos[3]; float Vel[3]; float Spin[3]; int Len; float Mvir; float CentralMvir; float Rvir; float Vvir; float Vmax; float VelDisp; // baryonic reservoirs float ColdGas; float StellarMass; float BulgeMass; float HotGas; float EjectedMass; float BlackHoleMass; float ICS; // metals float MetalsColdGas; float MetalsStellarMass; float MetalsBulgeMass; float MetalsHotGas; float MetalsEjectedMass; float MetalsICS; // to calculate magnitudes float SfrDisk; float SfrBulge; float SfrDiskZ; float SfrBulgeZ; // misc float DiskScaleRadius; float Cooling; float Heating; float QuasarModeBHaccretionMass; float TimeOfLastMajorMerger; float TimeOfLastMinorMerger; float OutflowRate; // infall properties float infallMvir; float infallVvir; float infallVmax; }; // This structure contains the properties used within the code struct GALAXY { int SnapNum; int Type; int GalaxyNr; int CentralGal; int HaloNr; long long MostBoundID; int mergeType; //0=none; 1=minor merger; 2=major merger; 3=disk instability; 4=disrupt to ICS int mergeIntoID; int mergeIntoSnapNum; float dT; // (sub)halo properties float Pos[3]; float Vel[3]; int Len; float Mvir; float deltaMvir; float CentralMvir; float Rvir; float Vvir; float Vmax; // baryonic reservoirs float ColdGas; float StellarMass; float BulgeMass; float HotGas; float EjectedMass; float BlackHoleMass; float ICS; // metals float MetalsColdGas; float MetalsStellarMass; float MetalsBulgeMass; float MetalsHotGas; float MetalsEjectedMass; float MetalsICS; // to calculate magnitudes float SfrDisk[STEPS]; float SfrBulge[STEPS]; float SfrDiskColdGas[STEPS]; float SfrDiskColdGasMetals[STEPS]; float SfrBulgeColdGas[STEPS]; float SfrBulgeColdGasMetals[STEPS]; // misc float DiskScaleRadius; float MergTime; double Cooling; double Heating; float r_heat; float QuasarModeBHaccretionMass; float TimeOfLastMajorMerger; float TimeOfLastMinorMerger; float OutflowRate; float TotalSatelliteBaryons; // infall properties float infallMvir; float infallVvir; float infallVmax; } *Gal, *HaloGal; // auxiliary halo data struct halo_aux_data { int DoneFlag; int HaloFlag; int NGalaxies; int FirstGalaxy; } *HaloAux; extern int FirstFile; // first and last file for processing extern int LastFile; extern int Ntrees; // number of trees in current file extern int NumGals; // Total number of galaxies stored for current tree extern int MaxGals; // Maximum number of galaxies allowed for current tree extern int FoF_MaxGals; extern int GalaxyCounter; // unique galaxy ID for main progenitor line in tree extern int LastSnapShotNr; extern char OutputDir[512]; extern char FileNameGalaxies[512]; extern char TreeName[512]; extern char SimulationDir[512]; extern char FileWithSnapList[512]; extern int TotHalos; extern int TotGalaxies[ABSOLUTEMAXSNAPS]; extern int *TreeNgals[ABSOLUTEMAXSNAPS]; extern int *FirstHaloInSnap; extern int *TreeNHalos; extern int *TreeFirstHalo; #ifdef MPI extern int ThisTask, NTask, nodeNameLen; extern char *ThisNode; #endif extern double Omega; extern double OmegaLambda; extern double PartMass; extern double Hubble_h; extern double EnergySNcode, EnergySN; extern double EtaSNcode, EtaSN; // recipe flags extern int ReionizationOn; extern int SupernovaRecipeOn; extern int DiskInstabilityOn; extern int AGNrecipeOn; extern int SFprescription; // recipe parameters extern double RecycleFraction; extern double Yield; extern double FracZleaveDisk; extern double ReIncorporationFactor; extern double ThreshMajorMerger; extern double BaryonFrac; extern double SfrEfficiency; extern double FeedbackReheatingEpsilon; extern double FeedbackEjectionEfficiency; extern double RadioModeEfficiency; extern double QuasarModeEfficiency; extern double BlackHoleGrowthRate; extern double Reionization_z0; extern double Reionization_zr; extern double ThresholdSatDisruption; extern double UnitLength_in_cm, UnitTime_in_s, UnitVelocity_in_cm_per_s, UnitMass_in_g, RhoCrit, UnitPressure_in_cgs, UnitDensity_in_cgs, UnitCoolingRate_in_cgs, UnitEnergy_in_cgs, UnitTime_in_Megayears, G, Hubble, a0, ar; extern int ListOutputSnaps[ABSOLUTEMAXSNAPS]; extern double ZZ[ABSOLUTEMAXSNAPS]; extern double AA[ABSOLUTEMAXSNAPS]; extern double *Age; extern int MAXSNAPS; extern int NOUT; extern int Snaplistlen; extern gsl_rng *random_generator; extern int TreeID; extern int FileNum; #endif // #ifndef ALLVARS_H
{ "alphanum_fraction": 0.7185409366, "avg_line_length": 22.183745583, "ext": "h", "hexsha": "5c89e8ddff8d697078b74667fedf3805b218e2dc", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6c6ff3b0a50108523a7666041bd1e8815126e7de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jacobseiler/SAGE", "max_forks_repo_path": "code/core_allvars.h", "max_issues_count": 2, "max_issues_repo_head_hexsha": "6c6ff3b0a50108523a7666041bd1e8815126e7de", "max_issues_repo_issues_event_max_datetime": "2019-02-11T02:43:11.000Z", "max_issues_repo_issues_event_min_datetime": "2018-05-24T09:57:10.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jacobseiler/SAGE", "max_issues_repo_path": "code/core_allvars.h", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "6c6ff3b0a50108523a7666041bd1e8815126e7de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jacobseiler/SAGE", "max_stars_repo_path": "code/core_allvars.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1863, "size": 6278 }
#include <petsc.h> #include <petscts2.h> #if PETSC_VERSION_LE(3,3,0) #define TSRegister(s,f) TSRegister(s,0,0,f) #endif typedef struct { PetscReal Omega; /* frequency */ PetscReal Xi; /* damping */ } UserParams; #undef __FUNCT__ #define __FUNCT__ "Residual1" PetscErrorCode Residual1(TS ts,PetscReal t,Vec X,Vec A,Vec R,void *ctx) { UserParams *user = (UserParams *)ctx; PetscReal Omega = user->Omega; PetscScalar *x,*a,*r; PetscErrorCode ierr; PetscFunctionBegin; ierr = VecGetArray(X,&x);CHKERRQ(ierr); ierr = VecGetArray(A,&a);CHKERRQ(ierr); ierr = VecGetArray(R,&r);CHKERRQ(ierr); r[0] = a[0] + (Omega*Omega)*x[0]; ierr = VecRestoreArray(X,&x);CHKERRQ(ierr); ierr = VecRestoreArray(A,&a);CHKERRQ(ierr); ierr = VecRestoreArray(R,&r);CHKERRQ(ierr); ierr = VecAssemblyBegin(R);CHKERRQ(ierr); ierr = VecAssemblyEnd (R);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Tangent1" PetscErrorCode Tangent1(TS ts,PetscReal t,Vec X,Vec A,PetscReal shiftA,Mat J,Mat P,void *ctx) { UserParams *user = (UserParams *)ctx; PetscReal Omega = user->Omega; PetscReal T = 0; PetscErrorCode ierr; PetscFunctionBegin; T = shiftA + (Omega*Omega); ierr = MatSetValue(P,0,0,T,INSERT_VALUES);CHKERRQ(ierr); ierr = MatAssemblyBegin(P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd (P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); if (J != P) { ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); } PetscFunctionReturn(0); } #if PETSC_VERSION_LT(3,5,0) PetscErrorCode Tangent1_Legacy(TS ts,PetscReal t,Vec U,Vec V,PetscReal shift,Mat *J,Mat *P,MatStructure *m,void *ctx) {*m = SAME_NONZERO_PATTERN; return Tangent1(ts,t,U,V,shift,*J,*P,ctx);} #define Tangent1 Tangent1_Legacy #endif #undef __FUNCT__ #define __FUNCT__ "Residual2" PetscErrorCode Residual2(TS ts,PetscReal t,Vec X,Vec V,Vec A,Vec R,void *ctx) { UserParams *user = (UserParams *)ctx; PetscReal Omega = user->Omega, Xi = user->Xi; PetscScalar *x,*v,*a,*r; PetscErrorCode ierr; PetscFunctionBegin; ierr = VecGetArray(X,&x);CHKERRQ(ierr); ierr = VecGetArray(V,&v);CHKERRQ(ierr); ierr = VecGetArray(A,&a);CHKERRQ(ierr); ierr = VecGetArray(R,&r);CHKERRQ(ierr); r[0] = a[0] + (2*Xi*Omega)*v[0] + (Omega*Omega)*x[0]; ierr = VecRestoreArray(X,&x);CHKERRQ(ierr); ierr = VecRestoreArray(V,&v);CHKERRQ(ierr); ierr = VecRestoreArray(A,&a);CHKERRQ(ierr); ierr = VecRestoreArray(R,&r);CHKERRQ(ierr); ierr = VecAssemblyBegin(R);CHKERRQ(ierr); ierr = VecAssemblyEnd (R);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Tangent2" PetscErrorCode Tangent2(TS ts,PetscReal t,Vec X,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat J,Mat P,void *ctx) { UserParams *user = (UserParams *)ctx; PetscReal Omega = user->Omega, Xi = user->Xi; PetscReal T = 0; PetscErrorCode ierr; PetscFunctionBegin; T = shiftA + shiftV * (2*Xi*Omega) + (Omega*Omega); ierr = MatSetValue(P,0,0,T,INSERT_VALUES);CHKERRQ(ierr); ierr = MatAssemblyBegin(P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd (P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); if (J != P) { ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Monitor" PetscErrorCode Monitor(TS ts,PetscInt i,PetscReal t,Vec U,void *ctx) { const char *filename = (const char *)ctx; static FILE *fp = 0; Vec X,V; const PetscScalar *x,*v; TSConvergedReason reason; PetscErrorCode ierr; PetscFunctionBegin; if (i<0) PetscFunctionReturn(0); /*XXX temporary petsc-dev fix */ if (!fp) {ierr = PetscFOpen(PETSC_COMM_SELF,filename,"w",&fp);CHKERRQ(ierr);} ierr = TSGetSolution2(ts,&X,&V);CHKERRQ(ierr); ierr = VecGetArrayRead(X,&x);CHKERRQ(ierr); ierr = VecGetArrayRead(V,&v);CHKERRQ(ierr); ierr = PetscFPrintf(PETSC_COMM_SELF,fp,"%g %g %g\n",(double)t,(double)x[0],(double)v[0]);CHKERRQ(ierr); ierr = VecRestoreArrayRead(X,&x);CHKERRQ(ierr); ierr = VecRestoreArrayRead(V,&v);CHKERRQ(ierr); ierr = TSGetConvergedReason(ts,&reason); CHKERRQ(ierr); if (reason) {ierr = PetscFClose(PETSC_COMM_SELF,fp);CHKERRQ(ierr); fp=0;} PetscFunctionReturn(0); } EXTERN_C_BEGIN PetscErrorCode TSCreate_Alpha2(TS); EXTERN_C_END #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc, char *argv[]) { TS ts; Vec R; Mat J; Vec X,V; PetscScalar *x,*v; UserParams user; PetscBool out; char output[PETSC_MAX_PATH_LEN] = {0}; PetscErrorCode ierr; ierr = PetscInitialize(&argc,&argv,0,0);CHKERRQ(ierr); ierr = TSRegister(TSALPHA2,TSCreate_Alpha2);CHKERRQ(ierr); user.Omega = 1.0; user.Xi = 0.0; ierr = PetscOptionsBegin(PETSC_COMM_SELF,"","Oscillator Options","TS");CHKERRQ(ierr); ierr = PetscOptionsReal("-frequency","Frequency",__FILE__,user.Omega,&user.Omega,NULL);CHKERRQ(ierr); ierr = PetscOptionsReal("-damping", "Damping", __FILE__,user.Xi, &user.Xi, NULL);CHKERRQ(ierr); ierr = PetscOptionsString("-output","Output",__FILE__,output,output,sizeof(output),&out);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); if (out && !output[0]) {ierr = PetscStrcpy(output,"Oscillator.out");CHKERRQ(ierr);} ierr = TSCreate(PETSC_COMM_SELF,&ts);CHKERRQ(ierr); ierr = TSSetType(ts,TSALPHA2);CHKERRQ(ierr); ierr = TSSetDuration(ts,PETSC_MAX_INT,2*M_PI * 5);CHKERRQ(ierr); ierr = TSSetTimeStep(ts,0.01);CHKERRQ(ierr); ierr = VecCreateSeq(PETSC_COMM_SELF,1,&R);CHKERRQ(ierr); ierr = VecSetUp(R);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,1,1,NULL,&J);CHKERRQ(ierr); ierr = MatSetUp(J);CHKERRQ(ierr); if (user.Xi <= 0.0) { ierr = TSSetIFunction(ts,R,Residual1,&user);CHKERRQ(ierr); ierr = TSSetIJacobian(ts,J,J,Tangent1,&user);CHKERRQ(ierr); } else { ierr = TSSetIFunction2(ts,R,Residual2,&user);CHKERRQ(ierr); ierr = TSSetIJacobian2(ts,J,J,Tangent2,&user);CHKERRQ(ierr); } ierr = VecDestroy(&R);CHKERRQ(ierr); ierr = MatDestroy(&J);CHKERRQ(ierr); if (output[0]) { ierr = TSMonitorSet(ts,Monitor,output,NULL);CHKERRQ(ierr); } ierr = VecCreateSeq(PETSC_COMM_SELF,1,&X);CHKERRQ(ierr); ierr = VecCreateSeq(PETSC_COMM_SELF,1,&V);CHKERRQ(ierr); ierr = VecGetArray(X,&x);CHKERRQ(ierr); ierr = VecGetArray(V,&v);CHKERRQ(ierr); x[0] = 1.0; v[0] = 0.0; ierr = VecRestoreArray(X,&x);CHKERRQ(ierr); ierr = VecRestoreArray(V,&v);CHKERRQ(ierr); ierr = TSSetSolution2(ts,X,V);CHKERRQ(ierr); ierr = TSSetFromOptions(ts);CHKERRQ(ierr); ierr = TSSolve2(ts,X,V);CHKERRQ(ierr); ierr = VecDestroy(&X);CHKERRQ(ierr); ierr = VecDestroy(&V);CHKERRQ(ierr); ierr = TSDestroy(&ts);CHKERRQ(ierr); ierr = PetscFinalize();CHKERRQ(ierr); return 0; }
{ "alphanum_fraction": 0.6930078012, "avg_line_length": 31.8986175115, "ext": "c", "hexsha": "a37418b5ab8e3987408e175105fb548521a9547a", "lang": "C", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2021-06-14T10:40:40.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-08T12:55:17.000Z", "max_forks_repo_head_hexsha": "ce8c07de8511000ee6f1cbfd3fb90fda9cb31954", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "otherlab/petiga", "max_forks_repo_path": "test/Oscillator.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "ce8c07de8511000ee6f1cbfd3fb90fda9cb31954", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "otherlab/petiga", "max_issues_repo_path": "test/Oscillator.c", "max_line_length": 117, "max_stars_count": 4, "max_stars_repo_head_hexsha": "ce8c07de8511000ee6f1cbfd3fb90fda9cb31954", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "otherlab/petiga", "max_stars_repo_path": "test/Oscillator.c", "max_stars_repo_stars_event_max_datetime": "2021-06-14T10:40:32.000Z", "max_stars_repo_stars_event_min_datetime": "2017-08-31T21:20:27.000Z", "num_tokens": 2185, "size": 6922 }
/* * Copyright (c) 2016-2021 lymastee, All rights reserved. * Contact: lymastee@hotmail.com * * This file is part of the gslib project. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #pragma once #ifndef treeop_00fc8cde_c6b6_464d_b51d_71eaad31b9ef_h #define treeop_00fc8cde_c6b6_464d_b51d_71eaad31b9ef_h #include <gslib/tree.h> __gslib_begin__ /* * The original tree was created from top to bottom, to implement the new operation it might be needed * to create the tree from bottom to top. * These classes were designed to achieve that. * Caution: * You'd better NOT include me in headers. * You'd better use def_tr$ macros in a function scope. * with argumented def_tr$ versions, IE. like def_tr$_v1, def_tr$_v2, and so on... * the tree should NOT be a copy wrapper one. */ template<class _tree> class treeop_helper { public: typedef _tree tree; typedef typename _tree::value value; typedef typename _tree::wrapper wrapper; typedef typename _tree::alloc alloc; typedef typename _tree::const_iterator const_iterator; typedef typename _tree::iterator iterator; typedef typename wrapper::children children; }; template<class _tree> class treeop_set { public: typedef treeop_helper<_tree> helper; typedef typename helper::tree tree; typedef typename helper::value value; typedef typename helper::wrapper wrapper; typedef typename helper::alloc alloc; typedef typename helper::const_iterator const_iterator; typedef typename helper::iterator iterator; typedef typename helper::children children; typedef children opset; public: opset _opset; public: treeop_set() {} treeop_set(wrapper* w) { _opset.init(w); } treeop_set(treeop_set& rhs) { _opset.swap(rhs.dump()); } bool empty() const { return _opset.empty(); } bool unary() const { return _opset.size() == 1; } opset& dump() { return _opset; } treeop_set& operator+ (treeop_set& rhs) { return connect(rhs); } void acquire(treeop_set& ops) { assert(unary()); wrapper* m = _opset.front(); assert(m); m->acquire_children(ops.dump()); } treeop_set& sub(treeop_set& ops) { acquire(ops); return *this; } treeop_set& connect(treeop_set& ops) { _opset.connect(ops.dump()); return *this; } wrapper* detach() { assert(unary()); wrapper* w = _opset.front(); _opset.reset(); return w; } }; template<class _tree> class treeop { public: typedef treeop_helper<_tree> helper; typedef typename helper::tree tree; typedef typename helper::value value; typedef typename helper::wrapper wrapper; typedef typename helper::alloc alloc; typedef typename helper::const_iterator const_iterator; typedef typename helper::iterator iterator; typedef typename helper::children children; typedef treeop_set<_tree> tropset; typedef children opset; public: treeop(_tree& tr) { _tr = &tr; } void create(tropset& ops) { _tr->set_root(ops.detach()); } protected: _tree* _tr; }; /* * Usage: * For example, * 1.if we wanted to create a tree in the following structure, * { a = 1, b = "hello"; } * { a = 2, b = "bingo"; } * { a = 3, b = "bravo"; } * { a = 6, b = "amigo"; } * and the node was for: struct node { int a; string b; }; * We could write it like, * typedef tree<node, _treenode_wrapper<node> > mytree; * def_tr$(node1, mytree, ([&](){ a = 1, b = "hello"; })); * def_tr$(node2, mytree, ([&](){ a = 2, b = "bingo"; })); * def_tr$(node3, mytree, ([&](){ a = 3, b = "bravo"; })); * def_tr$(node4, mytree, ([&](){ a = 6, b = "amigo"; })); * tr$(node1).sub( * tr$(node2).sub( * tr$(node3) * ) * + tr$(node4) * ); * 2.if your compiler doesn't support c++0x style of lambda, * you may modify the def_tr$ micro a little bit, like assignments; * then you could temporally write it like: * typedef tree<node, _treenode_wrapper<node> > mytree; * def_tr$(node1, mytree, (a = 1, b = "hello";)); * it works, just maybe unsafe. */ #define def_tr$(name, treeop, prototype, assignments) \ struct tag##name \ { \ typedef treeop::wrapper wrapper; \ typedef treeop::value value; \ typedef treeop::alloc alloc; \ typedef treeop::tropset tropset; \ struct constructor: \ public prototype \ { \ constructor() { (assignments)(); } \ }; \ tropset create() \ { \ wrapper* w = alloc::born(); \ w->born<constructor>(); \ return tropset(w); \ } \ } name; #define def_tr$_v1(name, treeop, prototype, arg1, assignments) \ struct tag##name \ { \ typedef treeop::wrapper wrapper; \ typedef treeop::value value; \ typedef treeop::alloc alloc; \ typedef treeop::tropset tropset; \ typedef decltype(arg1) type1; \ type1& ref_arg1; \ tag##name(type1& arg1): ref_arg1(arg1) {} \ struct constructor: \ public prototype \ { \ constructor(type1& arg1) { (assignments)(arg1); } \ }; \ tropset create() \ { \ wrapper* w = alloc::born(); \ w->born<constructor>(ref_arg1); \ return tropset(w); \ } \ } name(arg1); #define def_tr$_v2(name, treeop, prototype, arg1, arg2, assignments) \ struct tag##name \ { \ typedef treeop::wrapper wrapper; \ typedef treeop::value value; \ typedef treeop::alloc alloc; \ typedef treeop::tropset tropset; \ typedef decltype(arg1) type1; \ typedef decltype(arg2) type2; \ type1& ref_arg1; \ type2& ref_arg2; \ tag##name(type1& arg1, type2& arg2): ref_arg1(arg1), ref_arg2(arg2) {} \ struct constructor: \ public prototype \ { \ constructor(type1& arg1, type2& arg2) { (assignments)(arg1, arg2); } \ }; \ tropset create() \ { \ wrapper* w = alloc::born(); \ w->born<constructor>(ref_arg1, ref_arg2); \ return tropset(w); \ } \ } name(arg1, arg2); #define def_tr$_v3(name, treeop, prototype, arg1, arg2, arg3, assignments) \ struct tag##name \ { \ typedef treeop::wrapper wrapper; \ typedef treeop::value value; \ typedef treeop::alloc alloc; \ typedef treeop::tropset tropset; \ typedef decltype(arg1) type1; \ typedef decltype(arg2) type2; \ typedef decltype(arg3) type3; \ type1& ref_arg1; \ type2& ref_arg2; \ type3& ref_arg3; \ tag##name(type1& arg1, type2& arg2, type3& arg3): ref_arg1(arg1), ref_arg2(arg2), ref_arg3(arg3) {} \ struct constructor: \ public prototype \ { \ constructor(type1& arg1, type2& arg2, type3& arg3) { (assignments)(arg1, arg2, arg3); } \ }; \ tropset create() \ { \ wrapper* w = alloc::born(); \ w->born<constructor>(ref_arg1, ref_arg2, ref_arg3); \ return tropset(w); \ } \ } name(arg1, arg2, arg3); #define tr$(name) (name.create()) __gslib_end__ #endif
{ "alphanum_fraction": 0.6193393393, "avg_line_length": 31.7748091603, "ext": "h", "hexsha": "6fb0709b80a56944efd226af8299f1354c5fddb8", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-10-19T15:20:58.000Z", "max_forks_repo_forks_event_min_datetime": "2016-10-19T15:20:58.000Z", "max_forks_repo_head_hexsha": "1b165b7a812526c4b2a3179588df9a7c2ff602a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lymastee/gslib", "max_forks_repo_path": "include/gslib/treeop.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b165b7a812526c4b2a3179588df9a7c2ff602a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lymastee/gslib", "max_issues_repo_path": "include/gslib/treeop.h", "max_line_length": 106, "max_stars_count": 9, "max_stars_repo_head_hexsha": "1b165b7a812526c4b2a3179588df9a7c2ff602a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lymastee/gslib", "max_stars_repo_path": "include/gslib/treeop.h", "max_stars_repo_stars_event_max_datetime": "2022-02-11T09:44:51.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-18T09:40:09.000Z", "num_tokens": 2213, "size": 8325 }
#pragma once #ifndef _NOGSL #include <gsl/gsl_vector.h> #endif class MaxOptimizationWrapper { public: virtual gsl_vector* getMinState() = 0; virtual double getObjectiveVal() = 0; virtual bool maximize(Interface* inputs, const gsl_vector* initState, const gsl_vector* initDir, const set<int>& assertConstraints, int minimizeNode, float beta, int level, int id) = 0; };
{ "alphanum_fraction": 0.764075067, "avg_line_length": 28.6923076923, "ext": "h", "hexsha": "ddbe2d61b1a9805b9f34d6cf128784311e3208a7", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2020-12-06T01:45:04.000Z", "max_forks_repo_forks_event_min_datetime": "2020-12-04T20:47:51.000Z", "max_forks_repo_head_hexsha": "6ecbb6f724149d50d290997fef5e2e1e92ab3d9e", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "natebragg/sketch-backend", "max_forks_repo_path": "src/SketchSolver/NumericalSynthesis/Optimizers/MaxOptimizationWrapper.h", "max_issues_count": 1, "max_issues_repo_head_hexsha": "6ecbb6f724149d50d290997fef5e2e1e92ab3d9e", "max_issues_repo_issues_event_max_datetime": "2022-03-04T04:02:09.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-01T16:53:05.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "natebragg/sketch-backend", "max_issues_repo_path": "src/SketchSolver/NumericalSynthesis/Optimizers/MaxOptimizationWrapper.h", "max_line_length": 186, "max_stars_count": 17, "max_stars_repo_head_hexsha": "6ecbb6f724149d50d290997fef5e2e1e92ab3d9e", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "natebragg/sketch-backend", "max_stars_repo_path": "src/SketchSolver/NumericalSynthesis/Optimizers/MaxOptimizationWrapper.h", "max_stars_repo_stars_event_max_datetime": "2022-03-31T00:28:40.000Z", "max_stars_repo_stars_event_min_datetime": "2020-08-20T14:54:11.000Z", "num_tokens": 96, "size": 373 }
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <limits.h> #include <omp.h> #include <stdbool.h> #include <getopt.h> #include <math.h> #include <mpi.h> #include "parmt_config.h" #ifdef PARMT_USE_INTEL #include <ippcore.h> #include <mkl.h> #include <mkl_cblas.h> #else #include <cblas.h> #endif #include "compearth.h" #include "parmt_mtsearch.h" #include "parmt_postProcess.h" #include "parmt_utils.h" #include "iscl/array/array.h" #include "iscl/memory/memory.h" #define PROGRAM_NAME "parmt" static int parseArguments(int argc, char *argv[], const int nprocs, int *npInObsGroups, int *npInLocGroups, int *npInMTGroups, char iniFile[PATH_MAX]); static void printUsage(void); int parmt_freeData(struct parmtData_struct *data); int parmt_freeLocalMTs(struct localMT_struct *mts); /*! * */ int main(int argc, char *argv[]) { char iniFile[PATH_MAX]; double *betas, *h, *kappas, *gammas, *M0s, *sigmas, *thetas, *u, *v; double *deps, *luneMPDF, *phi, t0, t1, du, dv, dh, dk, ds; int64_t ngridSearch; double hLower, hUpper, uLower, uUpper, vLower, vUpper, xnorm; int *lags, i, ierr, iobs, myid, npInLocGroups, nmt, npInMTGroups, npInObsGroups, nprocs, provided; int ix, iy, k; MPI_Comm mtComm, locComm, obsComm; bool linMTComm, linLocComm, linObsComm; const int master = 0; const int ldm = 8; struct parmtGeneralParms_struct parms; struct parmtData_struct data; struct parmtMtSearchParms_struct mtsearch; struct localMT_struct mtloc; //------------------------------------------------------------------------// // // initialize MPI, ISCL, and handle threading issues MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided); MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); iscl_init(); #ifdef PARMT_USE_INTEL //omp_set_num_threads(2); mkl_set_num_threads(1); ippSetNumThreads(1); #endif // initialize phi = NULL; M0s = NULL; betas = NULL; gammas = NULL; sigmas = NULL; kappas = NULL; thetas = NULL; h = NULL; u = NULL; v = NULL; lags = NULL; memset(&parms, 0, sizeof(struct parmtGeneralParms_struct)); memset(&data, 0, sizeof(struct parmtData_struct)); memset(&mtsearch, 0, sizeof(struct parmtMtSearchParms_struct)); memset(&mtloc, 0, sizeof(struct localMT_struct)); if (myid == master) { ierr = parseArguments(argc, argv, nprocs, &npInObsGroups, &npInLocGroups, &npInMTGroups, iniFile); if (ierr != 0){goto INIT_ERROR;} // read the ini file printf("%s: Parsing ini file %s...\n", PROGRAM_NAME, iniFile); ierr = 0; ierr += parmt_utils_readGeneralParms(iniFile, &parms); strcpy(parms.programName, PROGRAM_NAME); parms.programID = PARMT_ID; ierr += parmt_utils_readMtSearch(iniFile, &mtsearch); if (ierr != 0) { printf("%s: Error reading ini file\n", PROGRAM_NAME); goto INIT_ERROR; } printf("%s: Process management:\n", PROGRAM_NAME); printf(" Number of processes in observation groups %d\n", npInObsGroups); printf(" Number of processes in location groups %d\n", npInLocGroups); printf(" Number of processes in moment tensor groups %d\n", npInMTGroups); // npInObsGroups = 1; // npInLocGroups = 1; // npInMTGroups = nprocs; printf("verify greens fns are correct\n"); /* double pAxis[3], nAxis[3], tAxis[3], beta, gamma, u,v; u= 3.0*M_PI/8.0; v=-1.0/9.0; compearth_u2beta(1, 10, 2, &u, 1.e-10, &beta); compearth_v2gamma(1, &v, &gamma); postprocess_tt2tnp(beta, gamma, 4.0*M_PI/5.0, -M_PI/2.0, 0.723, pAxis, nAxis, tAxis); int nxp = 51; double *xw1 = memory_calloc64f(nxp*nxp); double *yw1 = memory_calloc64f(nxp*nxp); int8_t *pn1 = (int8_t *) calloc(nxp*nxp, sizeof(int8_t)); const double xc = 1.5; const double yc = 1.5; const double rad = 1.0; // Compute the corresponding moment tensor double M0loc = 1.0/sqrt(2.0), Muse[6], lamUse[9], Uuse[9]; double gammaDeg = gamma*180.0/M_PI; double deltaDeg = (M_PI_2 - beta)*180.0/M_PI; double kappaDeg = (4.0*M_PI/5.0)*180.0/M_PI; double sigmaDeg = (-M_PI_2)*180.0/M_PI; double thetaDeg = 0.723*180.0/M_PI; compearth_tt2cmt(gammaDeg, deltaDeg, M0loc, kappaDeg, thetaDeg, sigmaDeg, Muse, lamUse, Uuse); printf("mt = [%f,%f,%f,%f,%f,%f]\n", Muse[0], Muse[1], Muse[2], Muse[3], Muse[4], Muse[5]); printf("drawing\n"); for (int i=0; i<10000; i++) { postprocess_tnp2beachballPolarity(nxp, xc, yc, rad, pAxis, nAxis, tAxis, xw1, yw1, pn1); } FILE *fwork = fopen("depmag/beachball.txt", "w"); for (int iy=0; iy<nxp; iy++) { for (int ix=0; ix<nxp; ix++) { int k = iy*nxp + ix; fprintf(fwork, "%e %e %d\n", xw1[k], yw1[k], pn1[k]); } fprintf(fwork, "\n"); } fclose(fwork); memory_free64f(&xw1); memory_free64f(&yw1); free(pn1); printf("back\n"); //getchar(); */ } INIT_ERROR:; MPI_Bcast(&ierr, 1, MPI_INT, master, MPI_COMM_WORLD); if (ierr != 0){goto FINISH;} MPI_Bcast(&npInObsGroups, 1, MPI_INT, master, MPI_COMM_WORLD); MPI_Bcast(&npInLocGroups, 1, MPI_INT, master, MPI_COMM_WORLD); MPI_Bcast(&npInMTGroups, 1, MPI_INT, master, MPI_COMM_WORLD); // split the communicators ierr = parmt_splitComm(MPI_COMM_WORLD, npInObsGroups, npInLocGroups, npInMTGroups, &linObsComm, &obsComm, &linLocComm, &locComm, &linMTComm, &mtComm); if (ierr != 0) { printf("%s: Fatal error splitting communicators - have a nice day\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } // load the observations and greens functions then broadcast if (myid == master) { printf("%s: Loading data...\n", PROGRAM_NAME); memset(&data, 0, sizeof(struct parmtData_struct)); ierr = utils_dataArchive_readAllWaveforms(parms.dataFile, &data); data.est = (struct sacData_struct *) calloc((size_t) data.nobs, sizeof(struct sacData_struct)); ngridSearch = (int64_t) (mtsearch.nm*mtsearch.nb*mtsearch.ng) *(int64_t) (mtsearch.nk*mtsearch.ns*mtsearch.nt) *(int64_t) data.nlocs; if (ngridSearch > INT_MAX) { printf("%s: Error - grid search too big - integer overflow", PROGRAM_NAME); ierr = 1; } } MPI_Bcast(&ierr, 1, MPI_INT, master, MPI_COMM_WORLD); if (ierr != 0){goto FINISH;} // Send the inputs to everyone if (myid == master) { printf("%s: Broadcasting parameters...\n", PROGRAM_NAME); } ierr = parmt_broadcast_mtSearchParms(&mtsearch, master, MPI_COMM_WORLD); if (ierr != 0) { printf("%s: Fatal error broadcasting parameters\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } ierr = parmt_broadcast_generalParms(&parms, master, MPI_COMM_WORLD); if (ierr != 0) { printf("%s: Fatal error broadcasting general parameters\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } // Send the waveforms to everyone ierr = parmt_broadcast_data(&data, master, MPI_COMM_WORLD); if (ierr != 0) { printf("%s: Fatal error broadcasting waveforms\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } // Discretize the moment tensor space in (u, v, h) space if (myid == master) { printf("%s: Discretizing MT space...\n", PROGRAM_NAME); } // Discretize the moment tensor space in (u, v, h) space ierr = parmt_discretizeCells64f( mtsearch.nb, mtsearch.betaLower, mtsearch.betaUpper, mtsearch.ng, mtsearch.gammaLower, mtsearch.gammaUpper, mtsearch.nk, mtsearch.kappaLower, mtsearch.kappaUpper, mtsearch.ns, mtsearch.sigmaLower, mtsearch.sigmaUpper, mtsearch.nt, mtsearch.thetaLower, mtsearch.thetaUpper, mtsearch.nm, mtsearch.m0Lower, mtsearch.m0Upper, mtsearch.luseLog, &betas, &gammas, &kappas, &sigmas, &thetas, &M0s); if (ierr != 0) { printf("%s: Error discretizing MT space\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } /* compearth_beta2u(1, &mtsearch.betaLower, &uLower); compearth_beta2u(1, &mtsearch.betaUpper, &uUpper); compearth_gamma2v(1, &mtsearch.gammaLower, &vLower); compearth_gamma2v(1, &mtsearch.gammaUpper, &vUpper); compearth_theta2h(1, &mtsearch.thetaLower, &hLower); compearth_theta2h(1, &mtsearch.thetaUpper, &hUpper); du = (uUpper - uLower)/(double) mtsearch.nb; dv = (vUpper - vLower)/(double) mtsearch.ng; dh =-(hUpper - hLower)/(double) mtsearch.nt; dk = (mtsearch.kappaUpper - mtsearch.kappaLower)/(double) mtsearch.nk; ds = (mtsearch.sigmaUpper - mtsearch.sigmaLower)/(double) mtsearch.ns; //if (myid == master){printf("%f %f %f\n", du, dv, dh);} u = array_linspace64f(uLower+du/2, uUpper-du/2, mtsearch.nb, &ierr); v = array_linspace64f(vLower+dv/2, vUpper-dv/2, mtsearch.ng, &ierr); h = array_linspace64f(hLower-dh/2, hUpper+dh/2, mtsearch.nt, &ierr); betas = memory_calloc64f(mtsearch.nb); gammas = memory_calloc64f(mtsearch.ng); thetas = memory_calloc64f(mtsearch.nt); compearth_u2beta(mtsearch.nb, 20, 2, u, 1.e-6, betas); compearth_v2gamma(mtsearch.ng, v, gammas); compearth_h2theta(mtsearch.nt, h, thetas); M0s = array_linspace64f(mtsearch.m0Lower, mtsearch.m0Upper, mtsearch.nm, &ierr); kappas = array_linspace64f(mtsearch.kappaLower+dk/2, mtsearch.kappaUpper-dk/2, mtsearch.nk, &ierr); sigmas = array_linspace64f(mtsearch.sigmaLower+ds/2, mtsearch.sigmaUpper-ds/2, mtsearch.ns, &ierr); */ //if (myid != master){for (int i=0; i<mtsearch.nb; i++){printf("%f %f\n", u[i],betas[i]);}} // avoid an annoying warning for (i=0; i<mtsearch.ns; i++) { if (fabs(sigmas[i]) < 1.e-7){sigmas[i] = 1.e-7;} } nmt = mtsearch.ng*mtsearch.nb*mtsearch.nk *mtsearch.ns*mtsearch.nt*mtsearch.nm; if (myid == master) { printf("%s: Discretizing moment tensor...\n", PROGRAM_NAME); } t0 = MPI_Wtime(); ierr = parmt_discretizeMT64f_MPI(mtComm, mtsearch.ng, gammas, mtsearch.nb, betas, mtsearch.nm, M0s, mtsearch.nk, kappas, mtsearch.nt, thetas, mtsearch.ns, sigmas, ldm, &mtloc); if (ierr != 0) { printf("%s: Error discretizing moment tensor on process %d\n", PROGRAM_NAME, myid); MPI_Abort(MPI_COMM_WORLD, 30); } MPI_Barrier(MPI_COMM_WORLD); t1 = MPI_Wtime(); if (myid == master) { printf("%s: Discretization time %6.2f (seconds)\n", PROGRAM_NAME, t1 - t0); } // Initialize the output file t0 = MPI_Wtime(); if (myid == master) { printf("%s: Initializing output file...\n", PROGRAM_NAME); deps = memory_calloc64f(data.nlocs); for (i=0; i<data.nlocs; i++) { deps[i] = data.sacGxx[i].header.evdp; } ierr = parmt_io_createObjfnArchive64f(//parms.resultsDir, parms.projnm, //parms.resultsFileSuffix, PROGRAM_NAME, parms.parmtArchive, data.nobs, data.nlocs, deps, mtsearch.nm, M0s, mtsearch.nb, betas, mtsearch.ng, gammas, mtsearch.nk, kappas, mtsearch.ns, sigmas, mtsearch.nt, thetas); memory_free64f(&deps); } MPI_Barrier(MPI_COMM_WORLD); // Compute the objective functions t0 = MPI_Wtime(); phi = NULL; lags = NULL; /* nlags = 0; double lagTime; bool ldefault, lwantLags; int iobs = 0; int nlags = 0; phi = NULL; lags = NULL; nlags = 0; if (parms.lwantLags) { //lagTime = data.data[iobs].header.user0; //if (lagTime < 0.0){lagTime = parms.defaultMaxLagTime;} lagTime = parmt_utils_getLagTime(data.data[iobs], parms.defaultMaxLagTime, &ldefault); nlags = (int) (lagTime/data.data[iobs].header.delta + 0.5); } lags = NULL; lwantLags = false; if (nlags > 0){lwantLags = true;} */ if (myid == master) { phi = memory_calloc64f(data.nlocs*mtloc.nmtAll); } else { phi = memory_calloc64f(1); } // Perform the grid search MPI_Wtime(); ierr = parmt_obsSearch64f(MPI_COMM_WORLD, obsComm, locComm, linObsComm, linLocComm, parms, data, mtloc, phi); if (ierr != 0) { printf("%s: Error calling obsSearch64f\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } MPI_Barrier(MPI_COMM_WORLD); if (myid == master) { MPI_Wtime(); printf("%s: Objective function computation time: %f\n", PROGRAM_NAME, MPI_Wtime() - t0); } if (ierr != 0) { printf("%s: Error calling locSearchXC64f\n", PROGRAM_NAME); MPI_Abort(MPI_COMM_WORLD, 30); } if (myid == master) { printf("%s: Writing results...\n", PROGRAM_NAME); ierr = parmt_io_writeObjectiveFunction64f( //parms.resultsDir, parms.projnm, parms.resultsFileSuffix, parms.parmtArchive, nmt, phi); if (ierr != 0) { printf("%s: Error writing objective function\n", PROGRAM_NAME); goto FINISH; } int jloc, jm, jb, jg, jk, js, jt; int imtopt = array_argmax64f(data.nlocs*mtloc.nmtAll, phi, &ierr); marginal_getOptimum(data.nlocs, mtsearch.nm, mtsearch.nb, mtsearch.ng, mtsearch.nk, mtsearch.ns, mtsearch.nt, phi, &jloc, &jm, &jb, &jg, &jk, &js, &jt); printf("%d %f %f %f %f %f %f\n", jloc, gammas[jg]*180.0/M_PI, 90.0-betas[jb]*180.0/M_PI, 1.0, kappas[jk]*180.0/M_PI, thetas[jt]*180.0/M_PI, sigmas[js]*180.0/M_PI); double Muse[6], Mned[6], lam[3], U[9]; printf("phi opt: %d %e\n", imtopt, phi[imtopt]); printf("%d %d %d %d %d %d %d\n", jloc, jg, jb, jm, jk, jt, js); double gammaOpt = gammas[jg]*180.0/M_PI; double deltaOpt = 90.0-betas[jb]*180.0/M_PI; double kappaOpt = kappas[jk]*180.0/M_PI; double thetaOpt = thetas[jt]*180.0/M_PI; double sigmaOpt = sigmas[js]*180.0/M_PI; compearth_TT2CMT(1, &gammaOpt, &deltaOpt, &M0s[jm], &kappaOpt, &thetaOpt, &sigmaOpt, Muse, lam, U); /* compearth_tt2cmt(gammas[jg]*180.0/M_PI, 90.0-betas[jb]*180.0/M_PI, M0s[jm], kappas[jk]*180.0/M_PI, thetas[jt]*180.0/M_PI, sigmas[js]*180.0/M_PI, Muse, lam, U); */ parmt_discretizeMT64f(1, &gammas[jg], 1, &betas[jb], 1, &M0s[jm], 1, &kappas[jk], 1, &thetas[jt], 1, &sigmas[js], 6, 1, Mned); //printf("%e %e %e\n", phi[0], phi[1000], phi[500000]); printf("mtUSE =[%f,%f,%f,%f,%f,%f]\n", Muse[0], Muse[1], Muse[2], Muse[3], Muse[4], Muse[5]); printf("mtNED =[%f,%f,%f,%f,%f,%f]\n", Mned[0], Mned[1], Mned[2], Mned[3], Mned[4], Mned[5]); } FINISH:; if (linObsComm){MPI_Comm_free(&obsComm);} if (linLocComm){MPI_Comm_free(&locComm);} if (linMTComm){MPI_Comm_free(&mtComm);} memory_free64f(&M0s); memory_free64f(&h); memory_free64f(&u); memory_free64f(&v); memory_free64f(&betas); memory_free64f(&gammas); memory_free64f(&kappas); memory_free64f(&sigmas); memory_free64f(&thetas); memory_free64f(&phi); memory_free32i(&lags); parmt_freeData(&data); parmt_freeLocalMTs(&mtloc); iscl_finalize(); MPI_Finalize(); return EXIT_SUCCESS; } static int parseArguments(int argc, char *argv[], const int nprocs, int *npInObsGroups, int *npInLocGroups, int *npInMTGroups, char iniFile[PATH_MAX]) { bool linFile; int prod; linFile = false; *npInObsGroups = 1; *npInLocGroups = 1; *npInMTGroups = 1; memset(iniFile, 0, PATH_MAX*sizeof(char)); while (true) { static struct option longOptions[] = { {"help", no_argument, 0, '?'}, {"help", no_argument, 0, 'h'}, {"ini_file", required_argument, 0, 'i'}, {"obsGroupSize", required_argument, 0, 'w'}, {"mtGroupSize", required_argument, 0, 'm'}, {"locGroupSize", required_argument, 0, 'l'}, {0, 0, 0, 0} }; int c, optionIndex; c = getopt_long(argc, argv, "?hi:w:m:l:", longOptions, &optionIndex); if (c ==-1){break;} if (c == 'i') { strcpy(iniFile, (const char *) optarg); linFile = true; } else if (c == 'w' && nprocs > 1) { *npInObsGroups = atoi(optarg); } else if (c == 'l' && nprocs > 1) { *npInLocGroups = atoi(optarg); } else if (c == 'm' && nprocs > 1) { *npInMTGroups = atoi(optarg); } else if (c == 'h' || c == '?') { printUsage(); return -2; } else { printf("%s: Unknown options: %s\n", PROGRAM_NAME, argv[optionIndex]); } } if (!linFile) { printf("%s: Error must specify ini file\n\n", PROGRAM_NAME); printUsage(); return -1; } prod = (*npInObsGroups)*(*npInLocGroups)*(*npInMTGroups); if (prod != nprocs) { if (prod != 1) { printf("%s: Invalid process layout - defaulting to (%d,%d,%d)\n", PROGRAM_NAME, 1, 1, nprocs); } *npInObsGroups = 1; *npInLocGroups = 1; *npInMTGroups = nprocs; } return 0; } static void printUsage(void) { printf("Usage:\n parmt -i input_file\n\n"); printf("Required arguments:\n"); printf(" -i input_file specifies the initialization file\n"); printf("\n"); printf("Optional arguments:\n"); printf(" -m number of processes in moment-tensor groups\n"); printf(" -w number of processes in waveform (observation) groups\n"); printf(" -l number of processes in location groups\n"); printf(" -h displays this message\n"); printf(" Note if m*w*l must equal the number of processes\n"); printf(" If they are not set the program will set -m=nprocs\n"); return; } int parmt_freeData(struct parmtData_struct *data) { int i; if (data->nobs > 0 && data->nlocs > 0 && data->sacGxx != NULL && data->sacGyy != NULL && data->sacGzz != NULL && data->sacGxy != NULL && data->sacGxz != NULL && data->sacGyz != NULL) { for (i=0; i<data->nobs*data->nlocs; i++) { sacio_freeData(&data->sacGxx[i]); sacio_freeData(&data->sacGyy[i]); sacio_freeData(&data->sacGzz[i]); sacio_freeData(&data->sacGxy[i]); sacio_freeData(&data->sacGxz[i]); sacio_freeData(&data->sacGyz[i]); } free(data->sacGxx); free(data->sacGyy); free(data->sacGzz); free(data->sacGxy); free(data->sacGxz); free(data->sacGyz); } if (data->nobs > 0 && data->data != NULL) { for (i=0; i<data->nobs; i++) { sacio_freeData(&data->data[i]); } free(data->data); } if (data->nobs > 0 && data->est != NULL) { free(data->est); } memset(data, 0, sizeof(struct parmtData_struct)); return 0; } int parmt_freeLocalMTs(struct localMT_struct *mtloc) { memory_free64f(&mtloc->mts); //memory_free32i(&mtloc->l2g); // TODO remove memory_free32i(&mtloc->offset); memset(mtloc, 0, sizeof(struct localMT_struct)); return 0; }
{ "alphanum_fraction": 0.5298635583, "avg_line_length": 35.9902439024, "ext": "c", "hexsha": "9ffc3011409bcef4f6ab9c01318d7d99c5d0f706", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2b4097df02ef5e56407d40e821d5c7155c2e4416", "max_forks_repo_licenses": [ "Intel" ], "max_forks_repo_name": "bakerb845/parmt", "max_forks_repo_path": "src/parmt.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "2b4097df02ef5e56407d40e821d5c7155c2e4416", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Intel" ], "max_issues_repo_name": "bakerb845/parmt", "max_issues_repo_path": "src/parmt.c", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "2b4097df02ef5e56407d40e821d5c7155c2e4416", "max_stars_repo_licenses": [ "Intel" ], "max_stars_repo_name": "bakerb845/parmt", "max_stars_repo_path": "src/parmt.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 6248, "size": 22134 }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.36 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGPYTHON #define SWIG_PYTHON_DIRECTOR_NO_VTABLE /* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable * declarations/attributes, and other compiler dependent labels. * ----------------------------------------------------------------------------- */ /* template workaround for compilers that cannot correctly implement the C++ standard */ #ifndef SWIGTEMPLATEDISAMBIGUATOR # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) # define SWIGTEMPLATEDISAMBIGUATOR template # elif defined(__HP_aCC) /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ # define SWIGTEMPLATEDISAMBIGUATOR template # else # define SWIGTEMPLATEDISAMBIGUATOR # endif #endif /* inline attribute */ #ifndef SWIGINLINE # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline # else # define SWIGINLINE # endif #endif /* attribute recognised by some compilers to avoid 'unused' warnings */ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) # define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ # endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else # define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif /* internal SWIG method */ #ifndef SWIGINTERN # define SWIGINTERN static SWIGUNUSED #endif /* internal inline SWIG method */ #ifndef SWIGINTERNINLINE # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE #endif /* exporting methods */ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) # ifndef GCC_HASCLASSVISIBILITY # define GCC_HASCLASSVISIBILITY # endif #endif #ifndef SWIGEXPORT # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define SWIGEXPORT # else # define SWIGEXPORT __declspec(dllexport) # endif # else # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) # define SWIGEXPORT __attribute__ ((visibility("default"))) # else # define SWIGEXPORT # endif # endif #endif /* calling conventions for Windows */ #ifndef SWIGSTDCALL # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL # endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) # define _CRT_SECURE_NO_DEPRECATE #endif /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) # define _SCL_SECURE_NO_DEPRECATE #endif /* Python.h has to appear first */ #include <Python.h> /* ----------------------------------------------------------------------------- * swigrun.swg * * This file contains generic CAPI SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE # define SWIG_QUOTE_STRING(x) #x # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else # define SWIG_TYPE_TABLE_NAME #endif /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the swig runtime code. In 99.9% of the cases, swig just needs to declare them as 'static'. But only do this if is strictly necessary, ie, if you have problems with your compiler or so. */ #ifndef SWIGRUNTIME # define SWIGRUNTIME SWIGINTERN #endif #ifndef SWIGRUNTIMEINLINE # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE #endif /* Generic buffer size */ #ifndef SWIG_BUFFER_SIZE # define SWIG_BUFFER_SIZE 1024 #endif /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 /* Flags/methods for returning states. The swig conversion methods, as ConvertPtr, return and integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. In old swig versions, you usually write code as: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code } else { //fail code } Now you can be more explicit as: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { // success code } else { // fail code } that seems to be the same, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); if (SWIG_IsOK(res)) { // success code if (SWIG_IsNewObj(res) { ... delete *ptr; } else { ... } } else { // fail code } I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that requires also to SWIG_ConvertPtr to return new result values, as int SWIG_ConvertPtr(obj, ptr,...) { if (<obj is ok>) { if (<need new object>) { *ptr = <ptr to new allocated object>; return SWIG_NEWOBJ; } else { *ptr = <ptr to old object>; return SWIG_OLDOBJ; } } else { return SWIG_BADOBJ; } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the swig errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this int food(double) int fooi(int); and you call food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) /* The NewMask denotes the object was created (using new/malloc) */ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) /* The TmpMask is for in/out typemaps that use temporal objects */ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) /* Simple returning values */ #define SWIG_BADOBJ (SWIG_ERROR) #define SWIG_OLDOBJ (SWIG_OK) #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) /* Check, add and del mask methods */ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank # define SWIG_TypeRank unsigned long # endif # ifndef SWIG_MAXCASTRANK /* Default cast allowed */ # define SWIG_MAXCASTRANK (2) # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ # define SWIG_AddCast # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif #include <string.h> #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ struct swig_cast_info *cast; /* linked list of types that can cast into this type */ void *clientdata; /* language specific type data */ int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { swig_type_info *type; /* pointer to type that is equivalent to this type */ swig_converter_func converter; /* function to cast the void pointers */ struct swig_cast_info *next; /* pointer to next cast in linked list */ struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ size_t size; /* Number of types in this module */ struct swig_module_info *next; /* Pointer to next element in circularly linked list */ swig_type_info **type_initial; /* Array of initially generated type structures */ swig_cast_info **cast_initial; /* Array of initially generated casting structures */ void *clientdata; /* Language specific module data */ } swig_module_info; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class<int>" == "Class<int >", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; } return (int)((l1 - f1) - (l2 - f2)); } /* Check type equivalence in a name list like <name1>|<name2>|... Return 0 if not equal, 1 if equal */ SWIGRUNTIME int SWIG_TypeEquiv(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; if (*ne) ++ne; } return equiv; } /* Check type equivalence in a name list like <name1>|<name2>|... Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int SWIG_TypeCompare(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; if (*ne) ++ne; } return equiv; } /* think of this as a c++ template<> or a scheme macro */ #define SWIG_TypeCheck_Template(comparison, ty) \ if (ty) { \ swig_cast_info *iter = ty->cast; \ while (iter) { \ if (comparison) { \ if (iter == ty->cast) return iter; \ /* Move iter to the top of the linked list */ \ iter->prev->next = iter->next; \ if (iter->next) \ iter->next->prev = iter->prev; \ iter->next = ty->cast; \ iter->prev = 0; \ if (ty->cast) ty->cast->prev = iter; \ ty->cast = iter; \ return iter; \ } \ iter = iter->next; \ } \ } \ return 0 /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); } /* Same as previous function, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { SWIG_TypeCheck_Template(iter->type == from, into); } /* Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ SWIGRUNTIMEINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ SWIGRUNTIME const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (!type) return NULL; if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Set the clientdata field for a type */ SWIGRUNTIME void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } } cast = cast->next; } } SWIGRUNTIME void SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { register size_t l = 0; register size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ register size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { register int compare = strcmp(name, iname); if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { r = i - 1; } else { break; } } else if (compare > 0) { l = i + 1; } } else { break; /* should never happen */ } } while (l <= r); } iter = iter->next; } while (iter != end); return 0; } /* Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); if (ret) { return ret; } else { /* STEP 2: If the type hasn't been found, do a complete search of the str field (the human readable name) */ swig_module_info *iter = start; do { register size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; } iter = iter->next; } while (iter != end); } /* neither found a match */ return 0; } /* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; register const unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { register unsigned char *u = (unsigned char *) ptr; register const unsigned char *eu = u + sz; for (; u != eu; ++u) { register char d = *(c++); register unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return (char *) 0; *u = uu; } return c; } /* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } SWIGRUNTIME const char * SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { *ptr = (void *) 0; return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sizeof(void *)); } SWIGRUNTIME char * SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { char *r = buff; size_t lname = (name ? strlen(name) : 0); if ((2*sz + 2 + lname) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); if (lname) { strncpy(r,name,lname+1); } else { *r = 0; } return buff; } SWIGRUNTIME const char * SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { if (*c != '_') { if (strcmp(c,"NULL") == 0) { memset(ptr,0,sz); return name; } else { return 0; } } return SWIG_UnpackData(++c,ptr,sz); } #ifdef __cplusplus } #endif /* Errors in SWIG */ #define SWIG_UnknownError -1 #define SWIG_IOError -2 #define SWIG_RuntimeError -3 #define SWIG_IndexError -4 #define SWIG_TypeError -5 #define SWIG_DivisionByZero -6 #define SWIG_OverflowError -7 #define SWIG_SyntaxError -8 #define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 #define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # define PyOS_snprintf _snprintf # else # define PyOS_snprintf snprintf # endif #endif /* A crude PyString_FromFormat implementation for old Pythons */ #if PY_VERSION_HEX < 0x02020000 #ifndef SWIG_PYBUFFER_SIZE # define SWIG_PYBUFFER_SIZE 1024 #endif static PyObject * PyString_FromFormat(const char *fmt, ...) { va_list ap; char buf[SWIG_PYBUFFER_SIZE * 2]; int res; va_start(ap, fmt); res = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); } #endif /* Add PyObject_Del for old Pythons */ #if PY_VERSION_HEX < 0x01060000 # define PyObject_Del(op) PyMem_DEL((op)) #endif #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif /* A crude PyExc_StopIteration exception for old Pythons */ #if PY_VERSION_HEX < 0x02020000 # ifndef PyExc_StopIteration # define PyExc_StopIteration PyExc_RuntimeError # endif # ifndef PyObject_GenericGetAttr # define PyObject_GenericGetAttr 0 # endif #endif /* Py_NotImplemented is defined in 2.1 and up. */ #if PY_VERSION_HEX < 0x02010000 # ifndef Py_NotImplemented # define Py_NotImplemented PyExc_RuntimeError # endif #endif /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 # ifndef PyString_AsStringAndSize # define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} # endif #endif /* PySequence_Size for old Pythons */ #if PY_VERSION_HEX < 0x02000000 # ifndef PySequence_Size # define PySequence_Size PySequence_Length # endif #endif /* PyBool_FromLong for old Pythons */ #if PY_VERSION_HEX < 0x02030000 static PyObject *PyBool_FromLong(long ok) { PyObject *result = ok ? Py_True : Py_False; Py_INCREF(result); return result; } #endif /* Py_ssize_t for old Pythons */ /* This code is as recommended by: */ /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) typedef int Py_ssize_t; # define PY_SSIZE_T_MAX INT_MAX # define PY_SSIZE_T_MIN INT_MIN #endif /* ----------------------------------------------------------------------------- * error manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIME PyObject* SWIG_Python_ErrorType(int code) { PyObject* type = 0; switch(code) { case SWIG_MemoryError: type = PyExc_MemoryError; break; case SWIG_IOError: type = PyExc_IOError; break; case SWIG_RuntimeError: type = PyExc_RuntimeError; break; case SWIG_IndexError: type = PyExc_IndexError; break; case SWIG_TypeError: type = PyExc_TypeError; break; case SWIG_DivisionByZero: type = PyExc_ZeroDivisionError; break; case SWIG_OverflowError: type = PyExc_OverflowError; break; case SWIG_SyntaxError: type = PyExc_SyntaxError; break; case SWIG_ValueError: type = PyExc_ValueError; break; case SWIG_SystemError: type = PyExc_SystemError; break; case SWIG_AttributeError: type = PyExc_AttributeError; break; default: type = PyExc_RuntimeError; } return type; } SWIGRUNTIME void SWIG_Python_AddErrorMsg(const char* mesg) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } #if defined(SWIG_PYTHON_NO_THREADS) # if defined(SWIG_PYTHON_THREADS) # undef SWIG_PYTHON_THREADS # endif #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) # if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ # define SWIG_PYTHON_USE_GIL # endif # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() # endif # ifdef __cplusplus /* C++ code */ class SWIG_Python_Thread_Block { bool status; PyGILState_STATE state; public: void end() { if (status) { PyGILState_Release(state); status = false;} } SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} ~SWIG_Python_Thread_Block() { end(); } }; class SWIG_Python_Thread_Allow { bool status; PyThreadState *save; public: void end() { if (status) { PyEval_RestoreThread(save); status = false; }} SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} ~SWIG_Python_Thread_Allow() { end(); } }; # define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block # define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() # define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow # define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() # else /* C code */ # define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() # define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() # define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) # endif # else /* Old thread way, not implemented, user must provide it */ # if !defined(SWIG_PYTHON_INITIALIZE_THREADS) # define SWIG_PYTHON_INITIALIZE_THREADS # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_END_BLOCK) # define SWIG_PYTHON_THREAD_END_BLOCK # endif # if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # endif # if !defined(SWIG_PYTHON_THREAD_END_ALLOW) # define SWIG_PYTHON_THREAD_END_ALLOW # endif # endif #else /* No thread support */ # define SWIG_PYTHON_INITIALIZE_THREADS # define SWIG_PYTHON_THREAD_BEGIN_BLOCK # define SWIG_PYTHON_THREAD_END_BLOCK # define SWIG_PYTHON_THREAD_BEGIN_ALLOW # define SWIG_PYTHON_THREAD_END_ALLOW #endif /* ----------------------------------------------------------------------------- * Python API portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #if 0 } /* cc-mode */ #endif #endif /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; #ifdef __cplusplus #if 0 { /* cc-mode */ #endif } #endif /* ----------------------------------------------------------------------------- * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * ----------------------------------------------------------------------------- */ /* Common SWIG API */ /* for raw pointers */ #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) #define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* for class or struct pointers */ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) /* for C or C++ function pointers */ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) /* for C++ member pointers, ie, member methods */ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) /* Runtime API */ #define SWIG_GetModule(clientdata) SWIG_Python_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) PySwigClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Runtime API implementation */ /* Error manipulation */ SWIGINTERN void SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetObject(errtype, obj); Py_DECREF(obj); SWIG_PYTHON_THREAD_END_BLOCK; } SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(errtype, (char *) msg); SWIG_PYTHON_THREAD_END_BLOCK; } #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) /* Set a constant value */ SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { PyDict_SetItemString(d, (char*) name, obj); Py_DECREF(obj); } /* Append a value to the result obj */ SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { #if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyList_Check(result)) { PyObject *o2 = result; result = PyList_New(1); PyList_SetItem(result, 0, o2); } PyList_Append(result,obj); Py_DECREF(obj); } return result; #else PyObject* o2; PyObject* o3; if (!result) { result = obj; } else if (result == Py_None) { Py_DECREF(result); result = obj; } else { if (!PyTuple_Check(result)) { o2 = result; result = PyTuple_New(1); PyTuple_SET_ITEM(result, 0, o2); } o3 = PyTuple_New(1); PyTuple_SET_ITEM(o3, 0, obj); o2 = result; result = PySequence_Concat(o2, o3); Py_DECREF(o2); Py_DECREF(o3); } return result; #endif } /* Unpack the argument tuple */ SWIGINTERN int SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { if (!min && !max) { return 1; } else { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", name, (min == max ? "" : "at least "), (int)min); return 0; } } if (!PyTuple_Check(args)) { PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { register Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); return 0; } else if (l > max) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { register int i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } for (; l < max; ++l) { objs[l] = 0; } return i + 1; } } } /* A functor is a function object with one single object argument */ #if PY_VERSION_HEX >= 0x02020000 #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); #else #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); #endif /* Helper for static pointer initialization for both C and C++ code, for example static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); */ #ifdef __cplusplus #define SWIG_STATIC_POINTER(var) var #else #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var #endif /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Flags for new pointer objects */ #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) #ifdef __cplusplus extern "C" { #if 0 } /* cc-mode */ #endif #endif /* How to access Py_None */ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # ifndef SWIG_PYTHON_NO_BUILD_NONE # ifndef SWIG_PYTHON_BUILD_NONE # define SWIG_PYTHON_BUILD_NONE # endif # endif #endif #ifdef SWIG_PYTHON_BUILD_NONE # ifdef Py_None # undef Py_None # define Py_None SWIG_Py_None() # endif SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { PyObject *none = Py_BuildValue((char*)""); Py_DECREF(none); return none; } SWIGRUNTIME PyObject * SWIG_Py_None(void) { static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); return none; } #endif /* The python void return value */ SWIGRUNTIMEINLINE PyObject * SWIG_Py_Void(void) { PyObject *none = Py_None; Py_INCREF(none); return none; } /* PySwigClientData */ typedef struct { PyObject *klass; PyObject *newraw; PyObject *newargs; PyObject *destroy; int delargs; int implicitconv; } PySwigClientData; SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { PySwigClientData *data = (PySwigClientData *)ty->clientdata; return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; PyObject *klass = data ? data->klass : 0; return (klass ? klass : PyExc_RuntimeError); } SWIGRUNTIME PySwigClientData * PySwigClientData_New(PyObject* obj) { if (!obj) { return 0; } else { PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); /* the klass element */ data->klass = obj; Py_INCREF(data->klass); /* the newraw method and newargs arguments used to create a new raw instance */ if (PyClass_Check(obj)) { data->newraw = 0; data->newargs = obj; Py_INCREF(obj); } else { #if (PY_VERSION_HEX < 0x02020000) data->newraw = 0; #else data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); #endif if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); PyTuple_SetItem(data->newargs, 0, obj); } else { data->newargs = obj; } Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; } if (data->destroy) { int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); #ifdef METH_O data->delargs = !(flags & (METH_O)); #else data->delargs = 0; #endif } else { data->delargs = 0; } data->implicitconv = 0; return data; } } SWIGRUNTIME void PySwigClientData_Del(PySwigClientData* data) { Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); } /* =============== PySwigObject =====================*/ typedef struct { PyObject_HEAD void *ptr; swig_type_info *ty; int own; PyObject *next; } PySwigObject; SWIGRUNTIME PyObject * PySwigObject_long(PySwigObject *v) { return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * PySwigObject_format(const char* fmt, PySwigObject *v) { PyObject *res = NULL; PyObject *args = PyTuple_New(1); if (args) { if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { PyObject *ofmt = PyString_FromString(fmt); if (ofmt) { res = PyString_Format(ofmt,args); Py_DECREF(ofmt); } Py_DECREF(args); } } return res; } SWIGRUNTIME PyObject * PySwigObject_oct(PySwigObject *v) { return PySwigObject_format("%o",v); } SWIGRUNTIME PyObject * PySwigObject_hex(PySwigObject *v) { return PySwigObject_format("%x",v); } SWIGRUNTIME PyObject * #ifdef METH_NOARGS PySwigObject_repr(PySwigObject *v) #else PySwigObject_repr(PySwigObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = PySwigObject_hex(v); PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex)); Py_DECREF(hex); if (v->next) { #ifdef METH_NOARGS PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); #else PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); #endif PyString_ConcatAndDel(&repr,nrep); } return repr; } SWIGRUNTIME int PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { #ifdef METH_NOARGS PyObject *repr = PySwigObject_repr(v); #else PyObject *repr = PySwigObject_repr(v, NULL); #endif if (repr) { fputs(PyString_AsString(repr), fp); Py_DECREF(repr); return 0; } else { return 1; } } SWIGRUNTIME PyObject * PySwigObject_str(PySwigObject *v) { char result[SWIG_BUFFER_SIZE]; return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? PyString_FromString(result) : 0; } SWIGRUNTIME int PySwigObject_compare(PySwigObject *v, PySwigObject *w) { void *i = v->ptr; void *j = w->ptr; return (i < j) ? -1 : ((i > j) ? 1 : 0); } SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); SWIGRUNTIME PyTypeObject* PySwigObject_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); return type; } SWIGRUNTIMEINLINE int PySwigObject_Check(PyObject *op) { return ((op)->ob_type == PySwigObject_type()) || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); } SWIGRUNTIME PyObject * PySwigObject_New(void *ptr, swig_type_info *ty, int own); SWIGRUNTIME void PySwigObject_dealloc(PyObject *v) { PySwigObject *sobj = (PySwigObject *) v; PyObject *next = sobj->next; if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { /* we need to create a temporal object to carry the destroy operation */ PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); } else { PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); PyObject *mself = PyCFunction_GET_SELF(destroy); res = ((*meth)(mself, v)); } Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) else { const char *name = SWIG_TypePrettyName(ty); printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } #endif } Py_XDECREF(next); PyObject_DEL(v); } SWIGRUNTIME PyObject* PySwigObject_append(PyObject* v, PyObject* next) { PySwigObject *sobj = (PySwigObject *) v; #ifndef METH_O PyObject *tmp = 0; if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; next = tmp; #endif if (!PySwigObject_Check(next)) { return NULL; } sobj->next = next; Py_INCREF(next); return SWIG_Py_Void(); } SWIGRUNTIME PyObject* #ifdef METH_NOARGS PySwigObject_next(PyObject* v) #else PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { PySwigObject *sobj = (PySwigObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; } else { return SWIG_Py_Void(); } } SWIGINTERN PyObject* #ifdef METH_NOARGS PySwigObject_disown(PyObject *v) #else PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { PySwigObject *sobj = (PySwigObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* #ifdef METH_NOARGS PySwigObject_acquire(PyObject *v) #else PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { PySwigObject *sobj = (PySwigObject *)v; sobj->own = SWIG_POINTER_OWN; return SWIG_Py_Void(); } SWIGINTERN PyObject* PySwigObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) #else if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) #endif { return NULL; } else { PySwigObject *sobj = (PySwigObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { PySwigObject_acquire(v); } else { PySwigObject_disown(v); } #else if (PyObject_IsTrue(val)) { PySwigObject_acquire(v,args); } else { PySwigObject_disown(v,args); } #endif } return obj; } } #ifdef METH_O static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif #if PY_VERSION_HEX < 0x02020000 SWIGINTERN PyObject * PySwigObject_getattr(PySwigObject *sobj,char *name) { return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); } #endif SWIGRUNTIME PyTypeObject* _PySwigObject_type(void) { static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; static PyNumberMethods PySwigObject_as_number = { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ (binaryfunc)0, /*nb_divide*/ (binaryfunc)0, /*nb_remainder*/ (binaryfunc)0, /*nb_divmod*/ (ternaryfunc)0,/*nb_power*/ (unaryfunc)0, /*nb_negative*/ (unaryfunc)0, /*nb_positive*/ (unaryfunc)0, /*nb_absolute*/ (inquiry)0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ (coercion)0, /*nb_coerce*/ (unaryfunc)PySwigObject_long, /*nb_int*/ (unaryfunc)PySwigObject_long, /*nb_long*/ (unaryfunc)0, /*nb_float*/ (unaryfunc)PySwigObject_oct, /*nb_oct*/ (unaryfunc)PySwigObject_hex, /*nb_hex*/ #if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; static PyTypeObject pyswigobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ (char *)"PySwigObject", /* tp_name */ sizeof(PySwigObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)PySwigObject_dealloc, /* tp_dealloc */ (printfunc)PySwigObject_print, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)PySwigObject_getattr, /* tp_getattr */ #else (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ (cmpfunc)PySwigObject_compare, /* tp_compare */ (reprfunc)PySwigObject_repr, /* tp_repr */ &PySwigObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)PySwigObject_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; pyswigobject_type = tmp; pyswigobject_type.ob_type = &PyType_Type; type_init = 1; } return &pyswigobject_type; } SWIGRUNTIME PyObject * PySwigObject_New(void *ptr, swig_type_info *ty, int own) { PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); if (sobj) { sobj->ptr = ptr; sobj->ty = ty; sobj->own = own; sobj->next = 0; } return (PyObject *)sobj; } /* ----------------------------------------------------------------------------- * Implements a simple Swig Packed type, and use it instead of string * ----------------------------------------------------------------------------- */ typedef struct { PyObject_HEAD void *pack; swig_type_info *ty; size_t size; } PySwigPacked; SWIGRUNTIME int PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char result[SWIG_BUFFER_SIZE]; fputs("<Swig Packed ", fp); if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { fputs("at ", fp); fputs(result, fp); } fputs(v->ty->name,fp); fputs(">", fp); return 0; } SWIGRUNTIME PyObject * PySwigPacked_repr(PySwigPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); } else { return PyString_FromFormat("<Swig Packed %s>", v->ty->name); } } SWIGRUNTIME PyObject * PySwigPacked_str(PySwigPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ return PyString_FromFormat("%s%s", result, v->ty->name); } else { return PyString_FromString(v->ty->name); } } SWIGRUNTIME int PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) { size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); SWIGRUNTIME PyTypeObject* PySwigPacked_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); return type; } SWIGRUNTIMEINLINE int PySwigPacked_Check(PyObject *op) { return ((op)->ob_type == _PySwigPacked_type()) || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); } SWIGRUNTIME void PySwigPacked_dealloc(PyObject *v) { if (PySwigPacked_Check(v)) { PySwigPacked *sobj = (PySwigPacked *) v; free(sobj->pack); } PyObject_DEL(v); } SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void) { static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; static PyTypeObject pyswigpacked_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ (char *)"PySwigPacked", /* tp_name */ sizeof(PySwigPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)PySwigPacked_dealloc, /* tp_dealloc */ (printfunc)PySwigPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ (cmpfunc)PySwigPacked_compare, /* tp_compare */ (reprfunc)PySwigPacked_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ (reprfunc)PySwigPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ swigpacked_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; pyswigpacked_type = tmp; pyswigpacked_type.ob_type = &PyType_Type; type_init = 1; } return &pyswigpacked_type; } SWIGRUNTIME PyObject * PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) { PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); if (sobj) { void *pack = malloc(size); if (pack) { memcpy(pack, ptr, size); sobj->pack = pack; sobj->ty = ty; sobj->size = size; } else { PyObject_DEL((PyObject *) sobj); sobj = 0; } } return (PyObject *) sobj; } SWIGRUNTIME swig_type_info * PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { if (PySwigPacked_Check(obj)) { PySwigPacked *sobj = (PySwigPacked *)obj; if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { return PyString_FromString("this"); } SWIGRUNTIME PyObject * SWIG_This(void) { static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); return swig_this; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ SWIGRUNTIME PySwigObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { if (PySwigObject_Check(pyobj)) { return (PySwigObject *) pyobj; } else { PyObject *obj = 0; #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { PyObject **dictptr = _PyObject_GetDictPtr(pyobj); if (dictptr != NULL) { PyObject *dict = *dictptr; obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; } else { #ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; } #endif obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } } } #else obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { Py_DECREF(obj); } else { if (PyErr_Occurred()) PyErr_Clear(); return 0; } #endif if (obj && !PySwigObject_Check(obj)) { /* a PyObject is called 'this', try to get the 'real this' PySwigObject from it */ return SWIG_Python_GetSwigThis(obj); } return (PySwigObject *)obj; } } /* Acquire a pointer value */ SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { if (own == SWIG_POINTER_OWN) { PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; sobj->own = own; return oldown; } } return 0; } /* Convert a pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { if (!obj) return SWIG_ERROR; if (obj == Py_None) { if (ptr) *ptr = 0; return SWIG_OK; } else { PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); if (own) *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { swig_type_info *to = sobj->ty; if (to == ty) { /* no type cast needed */ if (ptr) *ptr = vptr; break; } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) { sobj = (PySwigObject *)sobj->next; } else { if (ptr) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { assert(own); if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } } break; } } } else { if (ptr) *ptr = vptr; break; } } if (sobj) { if (own) *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } return SWIG_OK; } else { int res = SWIG_ERROR; if (flags & SWIG_POINTER_IMPLICIT_CONV) { PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; if (klass) { PyObject *impconv; data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ impconv = SWIG_Python_CallFunctor(klass, obj); data->implicitconv = 0; if (PyErr_Occurred()) { PyErr_Clear(); impconv = 0; } if (impconv) { PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); if (iobj) { void *vptr; res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); if (SWIG_IsOK(res)) { if (ptr) { *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; res = SWIG_AddCast(res); res = SWIG_AddNewMask(res); } else { res = SWIG_AddCast(res); } } } Py_DECREF(impconv); } } } } return res; } } } /* Convert a function ptr value */ SWIGRUNTIME int SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { if (!PyCFunction_Check(obj)) { return SWIG_ConvertPtr(obj, ptr, ty, 0); } else { void *vptr = 0; /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; if (desc) { desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; if (!desc) return SWIG_ERROR; } if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); if (tc) { int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */ } else { return SWIG_ERROR; } } else { *ptr = vptr; } return SWIG_OK; } } /* Convert a packed value value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { /* check type cast? */ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) return SWIG_ERROR; } } return SWIG_OK; } /* ----------------------------------------------------------------------------- * Create a new pointer object * ----------------------------------------------------------------------------- */ /* Create a new instance object, whitout calling __init__, and set the 'this' attribute. */ SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) { #if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { inst = PyObject_Call(newraw, data->newargs, NULL); if (inst) { #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { PyObject *dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; PyDict_SetItem(dict, SWIG_This(), swig_this); } } #else PyObject *key = SWIG_This(); PyObject_SetAttr(inst, key, swig_this); #endif } } else { PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); } return inst; #else #if (PY_VERSION_HEX >= 0x02010000) PyObject *inst; PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); return (PyObject *) inst; #else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) { return NULL; } inst->in_class = (PyClassObject *)data->newargs; Py_INCREF(inst->in_class); inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { Py_DECREF(inst); return NULL; } #ifdef Py_TPFLAGS_HAVE_WEAKREFS inst->in_weakreflist = NULL; #endif #ifdef Py_TPFLAGS_GC PyObject_GC_Init(inst); #endif PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); return (PyObject *) inst; #endif #endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; if (dict == NULL) { dict = PyDict_New(); *dictptr = dict; } PyDict_SetItem(dict, SWIG_This(), swig_this); return; } #endif dict = PyObject_GetAttrString(inst, (char*)"__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { return NULL; } else { PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { PySwigObject_append((PyObject*) sthis, obj[1]); } else { SWIG_Python_SetSwigThis(obj[0], obj[1]); } return SWIG_Py_Void(); } } /* Create a new pointer object */ SWIGRUNTIME PyObject * SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { if (!ptr) { return SWIG_Py_Void(); } else { int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; PyObject *robj = PySwigObject_New(ptr, type, own); PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); if (inst) { Py_DECREF(robj); robj = inst; } } return robj; } } /* Create a new packed object */ SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* * Get type list * -----------------------------------------------------------------------------*/ #ifdef SWIG_LINK_RUNTIME void *SWIG_ReturnGlobalTypeList(void *); #endif SWIGRUNTIME swig_module_info * SWIG_Python_GetModule(void) { static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; } #endif } return (swig_module_info *) type_pointer; } #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ SWIGINTERN int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return SWIG_ERROR; } if (PyDict_SetItemString(dict, name, o)) return SWIG_ERROR; Py_DECREF(o); return SWIG_OK; } #endif SWIGRUNTIME void SWIG_Python_DestroyModule(void *vptr) { swig_module_info *swig_module = (swig_module_info *) vptr; swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { PySwigClientData *data = (PySwigClientData *) ty->clientdata; if (data) PySwigClientData_Del(data); } } Py_DECREF(SWIG_This()); } SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } } /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); return cache; } SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); PyObject *key = PyString_FromString(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); } else { swig_module_info *swig_module = SWIG_Python_GetModule(); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { obj = PyCObject_FromVoidPtr(descriptor, NULL); PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } } Py_DECREF(key); return descriptor; } /* For backward compatibility only */ #define SWIG_POINTER_EXCEPTION 0 #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) SWIGRUNTIME int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); } else { PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); } Py_DECREF(old_str); } return 1; } else { return 0; } } SWIGRUNTIME int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } SWIGRUNTIMEINLINE const char * PySwigObject_GetDesc(PyObject *self) { PySwigObject *v = (PySwigObject *)self; swig_type_info *ty = v ? v->ty : 0; return ty ? ty->str : (char*)""; } SWIGRUNTIME void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { #if defined(SWIG_COBJECT_TYPES) if (obj && PySwigObject_Check(obj)) { const char *otype = (const char *) PySwigObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", type, otype); return; } } else #endif { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? PyString_AsString(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_XDECREF(str); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } /* Convert a pointer value, signal an exception on a type mismatch */ SWIGRUNTIME void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); if (flags & SWIG_POINTER_EXCEPTION) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } } return result; } #ifdef __cplusplus #if 0 { /* cc-mode */ #endif } #endif #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_FILE swig_types[0] #define SWIGTYPE_p_char swig_types[1] #define SWIGTYPE_p_double swig_types[2] #define SWIGTYPE_p_gsl_cheb_series swig_types[3] #define SWIGTYPE_p_gsl_function swig_types[4] #define SWIGTYPE_p_gsl_function_fdf swig_types[5] #define SWIGTYPE_p_gsl_integration_qawo_table swig_types[6] #define SWIGTYPE_p_gsl_integration_qaws_table swig_types[7] #define SWIGTYPE_p_gsl_integration_workspace swig_types[8] #define SWIGTYPE_p_gsl_matrix swig_types[9] #define SWIGTYPE_p_gsl_min_fminimizer swig_types[10] #define SWIGTYPE_p_gsl_min_fminimizer_type swig_types[11] #define SWIGTYPE_p_gsl_monte_function swig_types[12] #define SWIGTYPE_p_gsl_monte_miser_state swig_types[13] #define SWIGTYPE_p_gsl_monte_plain_state swig_types[14] #define SWIGTYPE_p_gsl_monte_vegas_state swig_types[15] #define SWIGTYPE_p_gsl_multifit_fdfsolver swig_types[16] #define SWIGTYPE_p_gsl_multifit_fdfsolver_type swig_types[17] #define SWIGTYPE_p_gsl_multifit_fsolver swig_types[18] #define SWIGTYPE_p_gsl_multifit_fsolver_type swig_types[19] #define SWIGTYPE_p_gsl_multifit_function swig_types[20] #define SWIGTYPE_p_gsl_multifit_function_fdf swig_types[21] #define SWIGTYPE_p_gsl_multifit_linear_workspace swig_types[22] #define SWIGTYPE_p_gsl_multimin_fdfminimizer swig_types[23] #define SWIGTYPE_p_gsl_multimin_fdfminimizer_type swig_types[24] #define SWIGTYPE_p_gsl_multimin_fminimizer swig_types[25] #define SWIGTYPE_p_gsl_multimin_fminimizer_type swig_types[26] #define SWIGTYPE_p_gsl_multimin_function swig_types[27] #define SWIGTYPE_p_gsl_multimin_function_fdf swig_types[28] #define SWIGTYPE_p_gsl_multiroot_fdfsolver swig_types[29] #define SWIGTYPE_p_gsl_multiroot_fdfsolver_type swig_types[30] #define SWIGTYPE_p_gsl_multiroot_fsolver swig_types[31] #define SWIGTYPE_p_gsl_multiroot_fsolver_type swig_types[32] #define SWIGTYPE_p_gsl_multiroot_function swig_types[33] #define SWIGTYPE_p_gsl_multiroot_function_fdf swig_types[34] #define SWIGTYPE_p_gsl_odeiv_control swig_types[35] #define SWIGTYPE_p_gsl_odeiv_control_type swig_types[36] #define SWIGTYPE_p_gsl_odeiv_evolve swig_types[37] #define SWIGTYPE_p_gsl_odeiv_step swig_types[38] #define SWIGTYPE_p_gsl_odeiv_step_type swig_types[39] #define SWIGTYPE_p_gsl_rng swig_types[40] #define SWIGTYPE_p_gsl_root_fdfsolver swig_types[41] #define SWIGTYPE_p_gsl_root_fdfsolver_type swig_types[42] #define SWIGTYPE_p_gsl_root_fsolver swig_types[43] #define SWIGTYPE_p_gsl_root_fsolver_type swig_types[44] #define SWIGTYPE_p_gsl_vector swig_types[45] #define SWIGTYPE_p_unsigned_int swig_types[46] static swig_type_info *swig_types[48]; static swig_module_info swig_module = {swig_types, 47, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) /* -------- TYPES TABLE (END) -------- */ #if (PY_VERSION_HEX <= 0x02000000) # if !defined(SWIG_PYTHON_CLASSIC) # error "This python version requires swig to be run with the '-classic' option" # endif #endif /*----------------------------------------------- @(target):= __callback.so ------------------------------------------------*/ #define SWIG_init init__callback #define SWIG_name "__callback" #define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION #define SWIG_as_voidptr(a) (void *)((const void *)(a)) #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) #include <gsl/gsl_math.h> #include <gsl/gsl_errno.h> #include <assert.h> #include <float.h> #include <setjmp.h> #include <pygsl/utils.h> #include <pygsl/function_helpers.h> #define PyGSL_gsl_function_GET_PARAMS(sys) \ (sys)->params #define PyGSL_gsl_function_fdf_GET_PARAMS(sys) \ (sys)->params #include <pygsl/utils.h> #include <pygsl/error_helpers.h> typedef int gsl_error_flag; typedef int gsl_error_flag_drop; PyObject *pygsl_module_for_error_treatment = NULL; #include <pygsl/utils.h> #include <pygsl/block_helpers.h> #include <typemaps/block_conversion_functions.h> #include <string.h> #include <assert.h> #include <pygsl/error_helpers.h> #include "function_helpers.c" #include "chars.c" gsl_function * gsl_function_init(gsl_function * STORE) { return STORE; /* Do Not need to do anything here. All done in the typemaps */ } gsl_function_fdf * gsl_function_init_fdf(gsl_function_fdf * STORE) { return STORE; /* Do Not need to do anything here. All done in the typemaps */ } void gsl_function_free(gsl_function * FREE) { /* Do Not need to do anything here. All done in the typemaps */ } void gsl_function_free_fdf(gsl_function_fdf * FREE) { /* Do Not need to do anything here. All done in the typemaps */ } #include <gsl/gsl_monte.h> #include <gsl/gsl_monte_plain.h> #include <gsl/gsl_monte_miser.h> #include <gsl/gsl_monte_vegas.h> #include <pygsl/block_helpers.h> #include <gsl/gsl_interp.h> #include <gsl/gsl_spline.h> #include <stdio.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_rng.h> #include <pygsl/rng.h> #include <pygsl/rng_helpers.h> /* * Normally Microsofts (R) Visual C (TM) Compiler is used to compile python * on windows. * When I used MinGW to compile I could not convert Python File Objects to * C File Structs (The function PyFile_AsFile generated a core). Therefore * I raise a python exception if someone tries to use this Code when it was * compiled with MinGW. Do you know a better solution? Perhaps how to get it * work? */ #ifdef __MINGW32__ #define HANDLE_MINGW() \ do { \ PyGSL_add_traceback(NULL, __FILE__, __FUNCTION__, __LINE__); \ PyErr_SetString(PyExc_TypeError, "This Module was compiled using MinGW32. " \ "Conversion of python files to C files is not supported.");\ goto fail; \ } while(0) #else #define HANDLE_MINGW() #endif #define PyGSL_gsl_monte_function_GET_PARAMS(sys) \ (sys)->params; gsl_monte_function * gsl_monte_function_init(gsl_monte_function * STORE) { FUNC_MESS("BEGIN"); assert(STORE); FUNC_MESS("END"); return STORE; } void gsl_monte_function_free(gsl_monte_function * FREE) { ; } SWIGINTERN int SWIG_AsVal_double (PyObject *obj, double *val) { int res = SWIG_TypeError; if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; } else if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; double d = PyFloat_AsDouble(obj); if (!PyErr_Occurred()) { if (val) *val = d; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); } else { PyErr_Clear(); } } } #endif return res; } #include <float.h> #include <math.h> SWIGINTERNINLINE int SWIG_CanCastAsInteger(double *d, double min, double max) { double x = *d; if ((min <= x && x <= max)) { double fx = floor(x); double cx = ceil(x); double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ if ((errno == EDOM) || (errno == ERANGE)) { errno = 0; } else { double summ, reps, diff; if (rd < x) { diff = x - rd; } else if (rd > x) { diff = rd - x; } else { return 1; } summ = rd + x; reps = diff/summ; if (reps < 8*DBL_EPSILON) { *d = rd; return 1; } } } return 0; } SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { long v = PyInt_AsLong(obj); if (v >= 0) { if (val) *val = v; return SWIG_OK; } else { return SWIG_OverflowError; } } else if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { if (val) *val = (unsigned long)(d); return res; } } } #endif return SWIG_TypeError; } SWIGINTERNINLINE int SWIG_AsVal_size_t (PyObject * obj, size_t *val) { unsigned long v; int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); if (SWIG_IsOK(res) && val) *val = (size_t)(v); return res; } #define SWIG_From_double PyFloat_FromDouble size_t pygsl_monte_miser_get_min_calls(gsl_monte_miser_state * s){ return s->min_calls; } size_t pygsl_monte_miser_get_min_calls_per_bisection(gsl_monte_miser_state * s){ return s->min_calls_per_bisection; } double pygsl_monte_miser_get_dither(gsl_monte_miser_state * s){ return s->dither; } double pygsl_monte_miser_get_estimate_frac(gsl_monte_miser_state * s){ return s->estimate_frac; } double pygsl_monte_miser_get_alpha(gsl_monte_miser_state * s){ return s->alpha; } void pygsl_monte_miser_set_min_calls(gsl_monte_miser_state * s, int NONNEGATIVE){ s->min_calls = (size_t) NONNEGATIVE; } void pygsl_monte_miser_set_min_calls_per_bisection(gsl_monte_miser_state * s, int NONNEGATIVE){ s->min_calls_per_bisection = (size_t) NONNEGATIVE; } void pygsl_monte_miser_set_dither(gsl_monte_miser_state * s, double d){ s->dither = d; } void pygsl_monte_miser_set_estimate_frac(gsl_monte_miser_state * s, double e){ s->estimate_frac = e; } void pygsl_monte_miser_set_alpha(gsl_monte_miser_state * s, double alpha){ s->alpha = alpha; } #define SWIG_From_long PyInt_FromLong SWIGINTERNINLINE PyObject* SWIG_From_unsigned_SS_long (unsigned long value) { return (value > LONG_MAX) ? PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); } SWIGINTERNINLINE PyObject * SWIG_From_size_t (size_t value) { return SWIG_From_unsigned_SS_long ((unsigned long)(value)); } #include <limits.h> #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) # define LLONG_MAX __LONG_LONG_MAX__ # define LLONG_MIN (-LLONG_MAX - 1LL) # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) # endif #endif SWIGINTERN int SWIG_AsVal_long (PyObject *obj, long* val) { if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; } else if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); } } #ifdef SWIG_PYTHON_CAST_MODE { int dispatch = 0; long v = PyInt_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_AddCast(SWIG_OK); } else { PyErr_Clear(); } if (!dispatch) { double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { if (val) *val = (long)(d); return res; } } } #endif return SWIG_TypeError; } SWIGINTERN int SWIG_AsVal_int (PyObject * obj, int *val) { long v; int res = SWIG_AsVal_long (obj, &v); if (SWIG_IsOK(res)) { if ((v < INT_MIN || v > INT_MAX)) { return SWIG_OverflowError; } else { if (val) *val = (int)(v); } } return res; } SWIGINTERNINLINE PyObject * SWIG_From_int (int value) { return SWIG_From_long (value); } double pygsl_monte_vegas_get_result(gsl_monte_vegas_state *s){return s->result ;} double pygsl_monte_vegas_get_sigma(gsl_monte_vegas_state *s){return s->sigma ;} double pygsl_monte_vegas_get_chisq(gsl_monte_vegas_state *s){return s->chisq ;} double pygsl_monte_vegas_get_alpha(gsl_monte_vegas_state *s){return s->alpha ;} size_t pygsl_monte_vegas_get_iterations(gsl_monte_vegas_state *s){return s->iterations;} int pygsl_monte_vegas_get_stage(gsl_monte_vegas_state *s){return s->stage ;} int pygsl_monte_vegas_get_mode(gsl_monte_vegas_state *s){return s->mode ;} int pygsl_monte_vegas_get_verbose(gsl_monte_vegas_state *s){return s->verbose ;} FILE * pygsl_monte_vegas_get_ostream(gsl_monte_vegas_state *s){return s->ostream ;} void pygsl_monte_vegas_set_result(gsl_monte_vegas_state *s , double v){ s->result = v;} void pygsl_monte_vegas_set_sigma(gsl_monte_vegas_state *s , double v){ s->sigma = v;} void pygsl_monte_vegas_set_chisq(gsl_monte_vegas_state *s , double v){ s->chisq = v;} void pygsl_monte_vegas_set_alpha(gsl_monte_vegas_state *s , double v){ s->alpha = v;} void pygsl_monte_vegas_set_iterations(gsl_monte_vegas_state *s, int NONNEGATIVE){ s->iterations = (size_t) NONNEGATIVE;} void pygsl_monte_vegas_set_stage(gsl_monte_vegas_state *s , int NONNEGATIVE){ s->stage = NONNEGATIVE;} void pygsl_monte_vegas_set_mode(gsl_monte_vegas_state *s , int v){ s->mode = v;} void pygsl_monte_vegas_set_verbose(gsl_monte_vegas_state *s , int v){ s->verbose = v;} void pygsl_monte_vegas_set_ostream(gsl_monte_vegas_state *s , FILE * v){ s->ostream = v;} #include <gsl/gsl_types.h> #include <gsl/gsl_roots.h> #define PyGSL_gsl_root_fsolver_GET_PARAMS(sys) \ (sys)->function->params #define PyGSL_gsl_root_fdfsolver_GET_PARAMS(sys) \ (sys)->fdf->params SWIGINTERN swig_type_info* SWIG_pchar_descriptor(void) { static int init = 0; static swig_type_info* info = 0; if (!init) { info = SWIG_TypeQuery("_p_char"); init = 1; } return info; } SWIGINTERNINLINE PyObject * SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { if (size > INT_MAX) { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); return pchar_descriptor ? SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); } else { return PyString_FromStringAndSize(carray, (int)(size)); } } else { return SWIG_Py_Void(); } } SWIGINTERNINLINE PyObject * SWIG_FromCharPtr(const char *cptr) { return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); } #include <gsl/gsl_min.h> #define PyGSL_gsl_min_fminimizer_GET_PARAMS(sys) \ (sys)->function->params #include <gsl/gsl_multiroots.h> gsl_multiroot_function * gsl_multiroot_function_init(gsl_multiroot_function * STORE) { return STORE; /* Do Not need to do anything here. All done in the typemaps */ } gsl_multiroot_function_fdf * gsl_multiroot_function_init_fdf(gsl_multiroot_function_fdf * STORE) { return STORE; /* Do Not need to do anything here. All done in the typemaps */ } typedef gsl_vector gsl_multiroot_solver_data; gsl_multiroot_solver_data * gsl_multiroot_function_getf(gsl_multiroot_fsolver * s) { return s->f; } gsl_multiroot_solver_data * gsl_multiroot_function_fdf_getf(gsl_multiroot_fdfsolver * s) { return s->f; } gsl_multiroot_solver_data * gsl_multiroot_function_getx(gsl_multiroot_fsolver * s) { return s->x; } gsl_multiroot_solver_data * gsl_multiroot_function_fdf_getx(gsl_multiroot_fdfsolver * s) { return s->x; } void gsl_multiroot_function_free(gsl_multiroot_function * FREE) { /* Do Not need to do anything here. All done in the typemaps */ } void gsl_multiroot_function_free_fdf(gsl_multiroot_function_fdf * FREE) { /* Do Not need to do anything here. All done in the typemaps */ } #include <gsl/gsl_multimin.h> #define PyGSL_gsl_multimin_fminimizer_GET_PARAMS(sys) \ (sys)->f->params; #define PyGSL_gsl_multimin_fdfminimizer_GET_PARAMS(sys) \ (sys)->fdf->params; #define PyGSL_gsl_multimin_function_GET_PARAMS(sys) \ (sys)->params #define PyGSL_gsl_multimin_function_fdf_GET_PARAMS(sys) \ (sys)->params typedef gsl_vector gsl_multimin_solver_data; gsl_multimin_function * gsl_multimin_function_init(gsl_multimin_function * STORE) { return STORE; } gsl_multimin_function_fdf * gsl_multimin_function_init_fdf(gsl_multimin_function_fdf * STORE) { return STORE; /* Do Not need to do anything here. All done in the typemaps */ } void gsl_multimin_function_free(gsl_multimin_function * FREE) { ; } void gsl_multimin_function_free_fdf(gsl_multimin_function_fdf * FREE) { /* Do Not need to do anything here. All done in the typemaps */ ; } double gsl_multimin_fminimizer_f(gsl_multimin_fminimizer * s) { return s->fval; } double gsl_multimin_fdfminimizer_f(gsl_multimin_fdfminimizer * s) { return s->f; } /* * Try to find what level of GSL I am running. If less than zero, * give a NULL. The overlying wrapper must check for NULL and raise * an approbriate error message. */ #include <pygsl/pygsl_features.h> #ifdef _PYGSL_GSL_HAS_FMINIMIZER_NMSIMPLEX extern const gsl_multimin_fminimizer_type *gsl_multimin_fminimizer_nmsimplex; #else gsl_multimin_fminimizer_type *gsl_multimin_fminimizer_nmsimplex = NULL; #endif #include <gsl/gsl_multifit_nlin.h> #include "pygsl_multifit.ic" typedef gsl_vector gsl_multifit_solver_vector; typedef gsl_matrix gsl_multifit_solver_matrix; gsl_multifit_function * gsl_multifit_function_init(gsl_multifit_function * STORE) { return STORE; /* Do Not need to do anything here. All done in the typemaps */ } gsl_multifit_function_fdf * gsl_multifit_function_init_fdf(gsl_multifit_function_fdf * STORE) { return STORE; /* Do Not need to do anything here. All done in the typemaps */ } gsl_multifit_solver_vector * gsl_multifit_fsolver_getdx(gsl_multifit_fsolver * s) { return s->dx; } gsl_multifit_solver_vector * gsl_multifit_fsolver_getx(gsl_multifit_fsolver * s) { return s->x; } gsl_multifit_solver_vector * gsl_multifit_fsolver_getf(gsl_multifit_fsolver * s) { return s->f; } gsl_multifit_solver_vector * gsl_multifit_fdfsolver_getdx(gsl_multifit_fdfsolver * s) { return s->dx; } gsl_multifit_solver_vector * gsl_multifit_fdfsolver_getx(gsl_multifit_fdfsolver * s) { return s->x; } gsl_multifit_solver_vector * gsl_multifit_fdfsolver_getf(gsl_multifit_fdfsolver * s) { return s->f; } gsl_multifit_solver_matrix * gsl_multifit_fdfsolver_getJ(gsl_multifit_fdfsolver * s) { return s->J; } void gsl_multifit_function_free(gsl_multifit_function * FREE) { /* Do Not need to do anything here. All done in the typemaps */ } void gsl_multifit_function_free_fdf(gsl_multifit_function_fdf * FREE) { /* Do Not need to do anything here. All done in the typemaps */ } #include <gsl/gsl_integration.h> size_t gsl_integration_workspace_get_size(gsl_integration_workspace * w) { return w->size; } SWIGINTERNINLINE PyObject * SWIG_From_unsigned_SS_int (unsigned int value) { return SWIG_From_unsigned_SS_long (value); } #include <gsl/gsl_chebyshev.h> PyObject * pygsl_cheb_get_coefficients(gsl_cheb_series * s){ gsl_vector_view v; v = gsl_vector_view_array(s->c, s->order); return (PyObject *) PyGSL_copy_gslvector_to_pyarray(&v.vector); } int pygsl_cheb_set_coefficients(gsl_cheb_series * s, gsl_vector *coef){ size_t i, v_size; v_size = coef->size; if(v_size != s->order){ PyGSL_ERROR("The number of coefficients does not match the specified order.", GSL_EBADLEN); return GSL_EBADLEN; } for (i=0; i<v_size; i++){ s->c[i] = gsl_vector_get(coef, i); } return GSL_SUCCESS; } double pygsl_cheb_get_a(gsl_cheb_series *s){ return s->a; } double pygsl_cheb_get_b(gsl_cheb_series *s){ return s->b; } void pygsl_cheb_set_a(gsl_cheb_series *s, double a){ s->a = a; } void pygsl_cheb_set_b(gsl_cheb_series *s, double b){ s->b = b; } size_t pygsl_cheb_get_order_sp(gsl_cheb_series *s){ return s->order_sp; } void pygsl_cheb_set_order_sp(gsl_cheb_series *s, size_t sp){ s->order_sp = sp; } double pygsl_cheb_get_f(gsl_cheb_series *s){ return *(s->f); } void pygsl_cheb_set_f(gsl_cheb_series *s, double f){ *(s->f) = f; } #include <gsl/gsl_odeiv.h> #include <stdlib.h> #include <assert.h> /* Some functions needed hand coded wrapper. These are in here. */ #include <odeiv.ic> #include <gsl/gsl_multifit.h> #include <gsl/gsl_fit.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_vector.h> #ifdef __cplusplus extern "C" { #endif SWIGINTERN PyObject *_wrap_gsl_function_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_function *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_function_init",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_function (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_function *)gsl_function_init(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_function, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_function_init_fdf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function_fdf *arg1 = (gsl_function_fdf *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_function_fdf *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_function_init_fdf",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_function_fdf (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_function_fdf *)gsl_function_init_fdf(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_function_fdf, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_function_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_function *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_function_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_function_free" "', argument " "1"" of type '" "gsl_function *""'"); } arg1 = (gsl_function *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_function_free(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_function_free_fdf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function_fdf *arg1 = (gsl_function_fdf *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_function_fdf *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_function_free_fdf",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function_fdf, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_function_free_fdf" "', argument " "1"" of type '" "gsl_function_fdf *""'"); } arg1 = (gsl_function_fdf *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_function_free_fdf(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_function_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_function *arg1 = (gsl_monte_function *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_monte_function *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_function_init",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_monte_function (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_monte_function *)gsl_monte_function_init(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_monte_function, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_function_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_function *arg1 = (gsl_monte_function *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_monte_function *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_function_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_function_free" "', argument " "1"" of type '" "gsl_monte_function *""'"); } arg1 = (gsl_monte_function *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_monte_function_free(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_plain_integrate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_function *arg1 = (gsl_monte_function *) 0 ; double *arg2 ; double *arg3 ; size_t arg4 ; size_t arg5 ; gsl_rng *arg6 = (gsl_rng *) 0 ; gsl_monte_plain_state *arg7 = (gsl_monte_plain_state *) 0 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; size_t val5 ; int ecode5 = 0 ; void *argp7 = 0 ; int res7 = 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "xl",(char *) "calls",(char *) "r",(char *) "state", NULL }; gsl_error_flag_drop result; gsl_monte_function * volatile _solver1 = NULL; PyArrayObject *_PyVector_12 = NULL; PyArrayObject *_PyVector_22 = NULL; arg8 = &temp8; arg9 = &temp9; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_monte_plain_integrate",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_plain_integrate" "', argument " "1"" of type '" "gsl_monte_function const *""'"); } arg1 = (gsl_monte_function *)(argp1); { int mysize = 0; if(!PySequence_Check(obj1)){ PyErr_SetString(PyExc_TypeError, "Expected a sequence of two arrays!"); goto fail; } if(PySequence_Size(obj1) != 2){ PyErr_SetString(PyExc_TypeError, "Expected a sequence of two arrays! Number of sequence arguments did not match!"); goto fail; } _PyVector_12 = PyGSL_vector_check(PySequence_GetItem(obj1, 0), -1, PyGSL_DARRAY_CINPUT(2), NULL, NULL); if (_PyVector_12 == NULL) goto fail; mysize = _PyVector_12->dimensions[0]; _PyVector_22 = PyGSL_vector_check(PySequence_GetItem(obj1, 1), mysize, PyGSL_DARRAY_CINPUT(2+1), NULL, NULL); if (_PyVector_22 == NULL) goto fail; arg2 = (double *)(_PyVector_12->data); arg3 = (double *)(_PyVector_22->data); arg4 = (size_t) mysize; } ecode5 = SWIG_AsVal_size_t(obj2, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_monte_plain_integrate" "', argument " "5"" of type '" "size_t""'"); } arg5 = (size_t)(val5); { arg6= (gsl_rng*) PyGSL_gsl_rng_from_pyobject(obj3); if(arg6 == NULL) goto fail; } res7 = SWIG_ConvertPtr(obj4, &argp7,SWIGTYPE_p_gsl_monte_plain_state, 0 | 0 ); if (!SWIG_IsOK(res7)) { SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "gsl_monte_plain_integrate" "', argument " "7"" of type '" "gsl_monte_plain_state *""'"); } arg7 = (gsl_monte_plain_state *)(argp7); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } { ; } result = gsl_monte_plain_integrate((gsl_monte_function const *)arg1,(double const (*))arg2,(double const (*))arg3,arg4,arg5,arg6,arg7,arg8,arg9); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector_12); Py_XDECREF(_PyVector_22); } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector_12); Py_XDECREF(_PyVector_22); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_plain_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "dim", NULL }; gsl_monte_plain_state *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_plain_alloc",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_size_t(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_monte_plain_alloc" "', argument " "1"" of type '" "size_t""'"); } arg1 = (size_t)(val1); result = (gsl_monte_plain_state *)gsl_monte_plain_alloc(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_monte_plain_state, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_plain_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_plain_state *arg1 = (gsl_monte_plain_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "state", NULL }; gsl_error_flag_drop result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_plain_init",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_plain_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_plain_init" "', argument " "1"" of type '" "gsl_monte_plain_state *""'"); } arg1 = (gsl_monte_plain_state *)(argp1); result = gsl_monte_plain_init(arg1); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_plain_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_plain_state *arg1 = (gsl_monte_plain_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "state", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_plain_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_plain_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_plain_free" "', argument " "1"" of type '" "gsl_monte_plain_state *""'"); } arg1 = (gsl_monte_plain_state *)(argp1); gsl_monte_plain_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_get_min_calls(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; size_t result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_miser_get_min_calls",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_get_min_calls" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); result = (size_t)pygsl_monte_miser_get_min_calls(arg1); resultobj = SWIG_From_size_t((size_t)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_get_min_calls_per_bisection(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; size_t result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_miser_get_min_calls_per_bisection",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_get_min_calls_per_bisection" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); result = (size_t)pygsl_monte_miser_get_min_calls_per_bisection(arg1); resultobj = SWIG_From_size_t((size_t)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_get_dither(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_miser_get_dither",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_get_dither" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); result = (double)pygsl_monte_miser_get_dither(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_get_estimate_frac(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_miser_get_estimate_frac",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_get_estimate_frac" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); result = (double)pygsl_monte_miser_get_estimate_frac(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_get_alpha(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_miser_get_alpha",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_get_alpha" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); result = (double)pygsl_monte_miser_get_alpha(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_set_min_calls(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "NONNEGATIVE", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_miser_set_min_calls",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_set_min_calls" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_miser_set_min_calls" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); { if (arg2 < 0) { SWIG_exception(SWIG_ValueError,"Expected a non-negative value."); } } pygsl_monte_miser_set_min_calls(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_set_min_calls_per_bisection(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "NONNEGATIVE", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_miser_set_min_calls_per_bisection",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_set_min_calls_per_bisection" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_miser_set_min_calls_per_bisection" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); { if (arg2 < 0) { SWIG_exception(SWIG_ValueError,"Expected a non-negative value."); } } pygsl_monte_miser_set_min_calls_per_bisection(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_set_dither(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "d", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_miser_set_dither",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_set_dither" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_miser_set_dither" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_monte_miser_set_dither(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_set_estimate_frac(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "e", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_miser_set_estimate_frac",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_set_estimate_frac" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_miser_set_estimate_frac" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_monte_miser_set_estimate_frac(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_miser_set_alpha(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "alpha", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_miser_set_alpha",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_miser_set_alpha" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_miser_set_alpha" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_monte_miser_set_alpha(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_miser_integrate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_function *arg1 = (gsl_monte_function *) 0 ; double *arg2 ; double *arg3 ; size_t arg4 ; size_t arg5 ; gsl_rng *arg6 = (gsl_rng *) 0 ; gsl_monte_miser_state *arg7 = (gsl_monte_miser_state *) 0 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; size_t val5 ; int ecode5 = 0 ; void *argp7 = 0 ; int res7 = 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "xl",(char *) "calls",(char *) "r",(char *) "state", NULL }; gsl_error_flag_drop result; gsl_monte_function * volatile _solver1 = NULL; PyArrayObject *_PyVector_12 = NULL; PyArrayObject *_PyVector_22 = NULL; arg8 = &temp8; arg9 = &temp9; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_monte_miser_integrate",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_miser_integrate" "', argument " "1"" of type '" "gsl_monte_function *""'"); } arg1 = (gsl_monte_function *)(argp1); { int mysize = 0; if(!PySequence_Check(obj1)){ PyErr_SetString(PyExc_TypeError, "Expected a sequence of two arrays!"); goto fail; } if(PySequence_Size(obj1) != 2){ PyErr_SetString(PyExc_TypeError, "Expected a sequence of two arrays! Number of sequence arguments did not match!"); goto fail; } _PyVector_12 = PyGSL_vector_check(PySequence_GetItem(obj1, 0), -1, PyGSL_DARRAY_CINPUT(2), NULL, NULL); if (_PyVector_12 == NULL) goto fail; mysize = _PyVector_12->dimensions[0]; _PyVector_22 = PyGSL_vector_check(PySequence_GetItem(obj1, 1), mysize, PyGSL_DARRAY_CINPUT(2+1), NULL, NULL); if (_PyVector_22 == NULL) goto fail; arg2 = (double *)(_PyVector_12->data); arg3 = (double *)(_PyVector_22->data); arg4 = (size_t) mysize; } ecode5 = SWIG_AsVal_size_t(obj2, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_monte_miser_integrate" "', argument " "5"" of type '" "size_t""'"); } arg5 = (size_t)(val5); { arg6= (gsl_rng*) PyGSL_gsl_rng_from_pyobject(obj3); if(arg6 == NULL) goto fail; } res7 = SWIG_ConvertPtr(obj4, &argp7,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res7)) { SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "gsl_monte_miser_integrate" "', argument " "7"" of type '" "gsl_monte_miser_state *""'"); } arg7 = (gsl_monte_miser_state *)(argp7); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } { ; } result = gsl_monte_miser_integrate(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector_12); Py_XDECREF(_PyVector_22); } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector_12); Py_XDECREF(_PyVector_22); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_miser_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "dim", NULL }; gsl_monte_miser_state *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_miser_alloc",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_size_t(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_monte_miser_alloc" "', argument " "1"" of type '" "size_t""'"); } arg1 = (size_t)(val1); result = (gsl_monte_miser_state *)gsl_monte_miser_alloc(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_miser_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "state", NULL }; gsl_error_flag_drop result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_miser_init",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_miser_init" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); result = gsl_monte_miser_init(arg1); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_miser_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_miser_state *arg1 = (gsl_monte_miser_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "state", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_miser_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_miser_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_miser_free" "', argument " "1"" of type '" "gsl_monte_miser_state *""'"); } arg1 = (gsl_monte_miser_state *)(argp1); gsl_monte_miser_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_result(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_result",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_result" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (double)pygsl_monte_vegas_get_result(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_sigma(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_sigma",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_sigma" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (double)pygsl_monte_vegas_get_sigma(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_chisq(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_chisq",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_chisq" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (double)pygsl_monte_vegas_get_chisq(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_alpha(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_alpha",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_alpha" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (double)pygsl_monte_vegas_get_alpha(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_iterations(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; size_t result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_iterations",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_iterations" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (size_t)pygsl_monte_vegas_get_iterations(arg1); resultobj = SWIG_From_size_t((size_t)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_stage(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_stage",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_stage" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (int)pygsl_monte_vegas_get_stage(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_mode(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_mode",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_mode" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (int)pygsl_monte_vegas_get_mode(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_verbose(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_verbose",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_verbose" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (int)pygsl_monte_vegas_get_verbose(arg1); resultobj = SWIG_From_int((int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_get_ostream(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; FILE *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_monte_vegas_get_ostream",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_get_ostream" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = (FILE *)pygsl_monte_vegas_get_ostream(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_FILE, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_result(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "v", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_result",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_result" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_vegas_set_result" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_monte_vegas_set_result(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_sigma(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "v", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_sigma",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_sigma" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_vegas_set_sigma" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_monte_vegas_set_sigma(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_chisq(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "v", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_chisq",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_chisq" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_vegas_set_chisq" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_monte_vegas_set_chisq(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_alpha(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "v", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_alpha",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_alpha" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_vegas_set_alpha" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_monte_vegas_set_alpha(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_iterations(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "NONNEGATIVE", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_iterations",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_iterations" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_vegas_set_iterations" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); { if (arg2 < 0) { SWIG_exception(SWIG_ValueError,"Expected a non-negative value."); } } pygsl_monte_vegas_set_iterations(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_stage(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "NONNEGATIVE", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_stage",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_stage" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_vegas_set_stage" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); { if (arg2 < 0) { SWIG_exception(SWIG_ValueError,"Expected a non-negative value."); } } pygsl_monte_vegas_set_stage(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_mode(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "v", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_mode",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_mode" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_vegas_set_mode" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); pygsl_monte_vegas_set_mode(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_verbose(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; int arg2 ; void *argp1 = 0 ; int res1 = 0 ; int val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "v", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_verbose",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_verbose" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); ecode2 = SWIG_AsVal_int(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_monte_vegas_set_verbose" "', argument " "2"" of type '" "int""'"); } arg2 = (int)(val2); pygsl_monte_vegas_set_verbose(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_monte_vegas_set_ostream(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; FILE *arg2 = (FILE *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "v", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_monte_vegas_set_ostream",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_monte_vegas_set_ostream" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); { FUNC_MESS_BEGIN(); HANDLE_MINGW(); if (!PyFile_Check(obj1)) { PyErr_SetString(PyExc_TypeError, "Need a file!"); PyGSL_add_traceback(NULL, "typemaps/file_typemaps.i", __FUNCTION__, 33); goto fail; } FUNC_MESS("Convert Python File to C File"); arg2 = PyFile_AsFile(obj1); DEBUG_MESS(2, "Using file at %p with filedes %d", (void *) arg2, fileno(arg2)); assert(arg2 != NULL); } pygsl_monte_vegas_set_ostream(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_vegas_integrate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_function *arg1 = (gsl_monte_function *) 0 ; double *arg2 ; double *arg3 ; size_t arg4 ; size_t arg5 ; gsl_rng *arg6 = (gsl_rng *) 0 ; gsl_monte_vegas_state *arg7 = (gsl_monte_vegas_state *) 0 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; size_t val5 ; int ecode5 = 0 ; void *argp7 = 0 ; int res7 = 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "xl",(char *) "calls",(char *) "r",(char *) "state", NULL }; gsl_error_flag_drop result; gsl_monte_function * volatile _solver1 = NULL; PyArrayObject *_PyVector_12 = NULL; PyArrayObject *_PyVector_22 = NULL; arg8 = &temp8; arg9 = &temp9; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_monte_vegas_integrate",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_vegas_integrate" "', argument " "1"" of type '" "gsl_monte_function *""'"); } arg1 = (gsl_monte_function *)(argp1); { int mysize = 0; if(!PySequence_Check(obj1)){ PyErr_SetString(PyExc_TypeError, "Expected a sequence of two arrays!"); goto fail; } if(PySequence_Size(obj1) != 2){ PyErr_SetString(PyExc_TypeError, "Expected a sequence of two arrays! Number of sequence arguments did not match!"); goto fail; } _PyVector_12 = PyGSL_vector_check(PySequence_GetItem(obj1, 0), -1, PyGSL_DARRAY_CINPUT(2), NULL, NULL); if (_PyVector_12 == NULL) goto fail; mysize = _PyVector_12->dimensions[0]; _PyVector_22 = PyGSL_vector_check(PySequence_GetItem(obj1, 1), mysize, PyGSL_DARRAY_CINPUT(2+1), NULL, NULL); if (_PyVector_22 == NULL) goto fail; arg2 = (double *)(_PyVector_12->data); arg3 = (double *)(_PyVector_22->data); arg4 = (size_t) mysize; } ecode5 = SWIG_AsVal_size_t(obj2, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_monte_vegas_integrate" "', argument " "5"" of type '" "size_t""'"); } arg5 = (size_t)(val5); { arg6= (gsl_rng*) PyGSL_gsl_rng_from_pyobject(obj3); if(arg6 == NULL) goto fail; } res7 = SWIG_ConvertPtr(obj4, &argp7,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res7)) { SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "gsl_monte_vegas_integrate" "', argument " "7"" of type '" "gsl_monte_vegas_state *""'"); } arg7 = (gsl_monte_vegas_state *)(argp7); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } { ; } result = gsl_monte_vegas_integrate(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector_12); Py_XDECREF(_PyVector_22); } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_monte_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector_12); Py_XDECREF(_PyVector_22); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_vegas_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "dim", NULL }; gsl_monte_vegas_state *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_vegas_alloc",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_size_t(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_monte_vegas_alloc" "', argument " "1"" of type '" "size_t""'"); } arg1 = (size_t)(val1); result = (gsl_monte_vegas_state *)gsl_monte_vegas_alloc(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_vegas_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "state", NULL }; gsl_error_flag_drop result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_vegas_init",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_vegas_init" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); result = gsl_monte_vegas_init(arg1); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_monte_vegas_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_monte_vegas_state *arg1 = (gsl_monte_vegas_state *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "state", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_monte_vegas_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_monte_vegas_state, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_monte_vegas_free" "', argument " "1"" of type '" "gsl_monte_vegas_state *""'"); } arg1 = (gsl_monte_vegas_state *)(argp1); gsl_monte_vegas_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN int Swig_var_gsl_root_fsolver_bisection_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_root_fsolver_bisection is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_root_fsolver_bisection_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_root_fsolver_bisection), SWIGTYPE_p_gsl_root_fsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_root_fsolver_brent_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_root_fsolver_brent is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_root_fsolver_brent_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_root_fsolver_brent), SWIGTYPE_p_gsl_root_fsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_root_fsolver_falsepos_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_root_fsolver_falsepos is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_root_fsolver_falsepos_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_root_fsolver_falsepos), SWIGTYPE_p_gsl_root_fsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_root_fdfsolver_newton_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_root_fdfsolver_newton is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_root_fdfsolver_newton_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_root_fdfsolver_newton), SWIGTYPE_p_gsl_root_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_root_fdfsolver_secant_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_root_fdfsolver_secant is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_root_fdfsolver_secant_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_root_fdfsolver_secant), SWIGTYPE_p_gsl_root_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_root_fdfsolver_steffenson_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_root_fdfsolver_steffenson is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_root_fdfsolver_steffenson_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_root_fdfsolver_steffenson), SWIGTYPE_p_gsl_root_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN PyObject *_wrap_gsl_root_fsolver_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fsolver_type *arg1 = (gsl_root_fsolver_type *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "T", NULL }; gsl_root_fsolver *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fsolver_alloc",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fsolver_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fsolver_alloc" "', argument " "1"" of type '" "gsl_root_fsolver_type const *""'"); } arg1 = (gsl_root_fsolver_type *)(argp1); result = (gsl_root_fsolver *)gsl_root_fsolver_alloc((gsl_root_fsolver_type const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_root_fsolver, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fsolver_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fsolver *arg1 = (gsl_root_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fsolver_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fsolver_free" "', argument " "1"" of type '" "gsl_root_fsolver *""'"); } arg1 = (gsl_root_fsolver *)(argp1); gsl_root_fsolver_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fdfsolver_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fdfsolver_type *arg1 = (gsl_root_fdfsolver_type *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "T", NULL }; gsl_root_fdfsolver *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fdfsolver_alloc",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fdfsolver_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fdfsolver_alloc" "', argument " "1"" of type '" "gsl_root_fdfsolver_type const *""'"); } arg1 = (gsl_root_fdfsolver_type *)(argp1); result = (gsl_root_fdfsolver *)gsl_root_fdfsolver_alloc((gsl_root_fdfsolver_type const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_root_fdfsolver, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fdfsolver_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fdfsolver *arg1 = (gsl_root_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fdfsolver_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fdfsolver_free" "', argument " "1"" of type '" "gsl_root_fdfsolver *""'"); } arg1 = (gsl_root_fdfsolver *)(argp1); gsl_root_fdfsolver_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fsolver_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fsolver *arg1 = (gsl_root_fsolver *) 0 ; gsl_function *arg2 = (gsl_function *) 0 ; double arg3 ; double arg4 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "s",(char *) "BUFFER",(char *) "X_LOWER",(char *) "X_UPPER", NULL }; int result; gsl_function * volatile _solver2 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_root_fsolver_set",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fsolver_set" "', argument " "1"" of type '" "gsl_root_fsolver *""'"); } arg1 = (gsl_root_fsolver *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_root_fsolver_set" "', argument " "2"" of type '" "gsl_function *""'"); } arg2 = (gsl_function *)(argp2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_root_fsolver_set" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_root_fsolver_set" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg2); _solver2 = arg2; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_root_fsolver_set(arg1,arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fdfsolver_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fdfsolver *arg1 = (gsl_root_fdfsolver *) 0 ; gsl_function_fdf *arg2 = (gsl_function_fdf *) 0 ; double arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; double val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "s",(char *) "BUFFER",(char *) "ROOT", NULL }; int result; gsl_function_fdf * volatile _solver2 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_root_fdfsolver_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fdfsolver_set" "', argument " "1"" of type '" "gsl_root_fdfsolver *""'"); } arg1 = (gsl_root_fdfsolver *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_function_fdf, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_root_fdfsolver_set" "', argument " "2"" of type '" "gsl_function_fdf *""'"); } arg2 = (gsl_function_fdf *)(argp2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_root_fdfsolver_set" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); { int flag; callback_function_params_fdf * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg2); _solver2 = arg2; p = (callback_function_params_fdf *) PyGSL_gsl_function_fdf_GET_PARAMS(_solver2); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); /* Set jump buffer */ p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_root_fdfsolver_set(arg1,arg2,arg3); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params_fdf * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_function_fdf_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params_fdf * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_function_fdf_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fsolver_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fsolver *arg1 = (gsl_root_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fsolver_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fsolver_name" "', argument " "1"" of type '" "gsl_root_fsolver const *""'"); } arg1 = (gsl_root_fsolver *)(argp1); result = (char *)gsl_root_fsolver_name((gsl_root_fsolver const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fdfsolver_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fdfsolver *arg1 = (gsl_root_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fdfsolver_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fdfsolver_name" "', argument " "1"" of type '" "gsl_root_fdfsolver const *""'"); } arg1 = (gsl_root_fdfsolver *)(argp1); result = (char *)gsl_root_fdfsolver_name((gsl_root_fdfsolver const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fsolver_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fsolver *arg1 = (gsl_root_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "BUFFER", NULL }; int result; gsl_root_fsolver * volatile _solver1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fsolver_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fsolver_iterate" "', argument " "1"" of type '" "gsl_root_fsolver *""'"); } arg1 = (gsl_root_fsolver *)(argp1); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_root_fsolver_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_root_fsolver_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_root_fsolver_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_root_fsolver_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fdfsolver_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fdfsolver *arg1 = (gsl_root_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "BUFFER", NULL }; int result; gsl_root_fdfsolver * volatile _solver1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fdfsolver_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fdfsolver_iterate" "', argument " "1"" of type '" "gsl_root_fdfsolver *""'"); } arg1 = (gsl_root_fdfsolver *)(argp1); { int flag; callback_function_params_fdf * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params_fdf *) PyGSL_gsl_root_fdfsolver_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); /* Set jump buffer */ p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_root_fdfsolver_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params_fdf * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_root_fdfsolver_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params_fdf * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_root_fdfsolver_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fsolver_root(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fsolver *arg1 = (gsl_root_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fsolver_root",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fsolver_root" "', argument " "1"" of type '" "gsl_root_fsolver const *""'"); } arg1 = (gsl_root_fsolver *)(argp1); result = (double)gsl_root_fsolver_root((gsl_root_fsolver const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fdfsolver_root(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fdfsolver *arg1 = (gsl_root_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fdfsolver_root",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fdfsolver_root" "', argument " "1"" of type '" "gsl_root_fdfsolver const *""'"); } arg1 = (gsl_root_fdfsolver *)(argp1); result = (double)gsl_root_fdfsolver_root((gsl_root_fdfsolver const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fsolver_x_lower(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fsolver *arg1 = (gsl_root_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fsolver_x_lower",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fsolver_x_lower" "', argument " "1"" of type '" "gsl_root_fsolver const *""'"); } arg1 = (gsl_root_fsolver *)(argp1); result = (double)gsl_root_fsolver_x_lower((gsl_root_fsolver const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_fsolver_x_upper(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_root_fsolver *arg1 = (gsl_root_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_root_fsolver_x_upper",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_root_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_root_fsolver_x_upper" "', argument " "1"" of type '" "gsl_root_fsolver const *""'"); } arg1 = (gsl_root_fsolver *)(argp1); result = (double)gsl_root_fsolver_x_upper((gsl_root_fsolver const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_test_interval(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double arg3 ; double arg4 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "X_LOWER",(char *) "X_UPPER",(char *) "EPSABS",(char *) "EPSREL", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_root_test_interval",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_root_test_interval" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_root_test_interval" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_root_test_interval" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_root_test_interval" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); result = (int)gsl_root_test_interval(arg1,arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_test_delta(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double arg3 ; double arg4 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "X1",(char *) "X0",(char *) "EPSREL",(char *) "EPSABS", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_root_test_delta",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_root_test_delta" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_root_test_delta" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_root_test_delta" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_root_test_delta" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); result = (int)gsl_root_test_delta(arg1,arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_root_test_residual(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "F",(char *) "EPSABS", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_root_test_residual",kwnames,&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_root_test_residual" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_root_test_residual" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (int)gsl_root_test_residual(arg1,arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN int Swig_var_gsl_min_fminimizer_goldensection_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_min_fminimizer_goldensection is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_min_fminimizer_goldensection_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_min_fminimizer_goldensection), SWIGTYPE_p_gsl_min_fminimizer_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_min_fminimizer_brent_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_min_fminimizer_brent is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_min_fminimizer_brent_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_min_fminimizer_brent), SWIGTYPE_p_gsl_min_fminimizer_type, 0 ); return pyobj; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer_type *arg1 = (gsl_min_fminimizer_type *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "T", NULL }; gsl_min_fminimizer *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_min_fminimizer_alloc",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_alloc" "', argument " "1"" of type '" "gsl_min_fminimizer_type const *""'"); } arg1 = (gsl_min_fminimizer_type *)(argp1); result = (gsl_min_fminimizer *)gsl_min_fminimizer_alloc((gsl_min_fminimizer_type const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer *arg1 = (gsl_min_fminimizer *) 0 ; gsl_function *arg2 = (gsl_function *) 0 ; double arg3 ; double arg4 ; double arg5 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "s",(char *) "BUFFER",(char *) "X_MINIMUM",(char *) "X_LOWER",(char *) "X_UPPER", NULL }; int result; gsl_function * volatile _solver2 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_min_fminimizer_set",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_set" "', argument " "1"" of type '" "gsl_min_fminimizer *""'"); } arg1 = (gsl_min_fminimizer *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_min_fminimizer_set" "', argument " "2"" of type '" "gsl_function *""'"); } arg2 = (gsl_function *)(argp2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_min_fminimizer_set" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_min_fminimizer_set" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_min_fminimizer_set" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg2); _solver2 = arg2; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_min_fminimizer_set(arg1,arg2,arg3,arg4,arg5); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_set_with_values(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer *arg1 = (gsl_min_fminimizer *) 0 ; gsl_function *arg2 = (gsl_function *) 0 ; double arg3 ; double arg4 ; double arg5 ; double arg6 ; double arg7 ; double arg8 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; double val6 ; int ecode6 = 0 ; double val7 ; int ecode7 = 0 ; double val8 ; int ecode8 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; PyObject * obj6 = 0 ; PyObject * obj7 = 0 ; char * kwnames[] = { (char *) "s",(char *) "BUFFER",(char *) "X_MINIMUM",(char *) "F_MINIMUM",(char *) "X_LOWER",(char *) "F_LOWER",(char *) "X_UPPER",(char *) "F_UPPER", NULL }; int result; gsl_function * volatile _solver2 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOOO:gsl_min_fminimizer_set_with_values",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_set_with_values" "', argument " "1"" of type '" "gsl_min_fminimizer *""'"); } arg1 = (gsl_min_fminimizer *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_min_fminimizer_set_with_values" "', argument " "2"" of type '" "gsl_function *""'"); } arg2 = (gsl_function *)(argp2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_min_fminimizer_set_with_values" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_min_fminimizer_set_with_values" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_min_fminimizer_set_with_values" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); ecode6 = SWIG_AsVal_double(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "gsl_min_fminimizer_set_with_values" "', argument " "6"" of type '" "double""'"); } arg6 = (double)(val6); ecode7 = SWIG_AsVal_double(obj6, &val7); if (!SWIG_IsOK(ecode7)) { SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "gsl_min_fminimizer_set_with_values" "', argument " "7"" of type '" "double""'"); } arg7 = (double)(val7); ecode8 = SWIG_AsVal_double(obj7, &val8); if (!SWIG_IsOK(ecode8)) { SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "gsl_min_fminimizer_set_with_values" "', argument " "8"" of type '" "double""'"); } arg8 = (double)(val8); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg2); _solver2 = arg2; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_min_fminimizer_set_with_values(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer *arg1 = (gsl_min_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_min_fminimizer_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_free" "', argument " "1"" of type '" "gsl_min_fminimizer *""'"); } arg1 = (gsl_min_fminimizer *)(argp1); gsl_min_fminimizer_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer *arg1 = (gsl_min_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_min_fminimizer_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_name" "', argument " "1"" of type '" "gsl_min_fminimizer const *""'"); } arg1 = (gsl_min_fminimizer *)(argp1); result = (char *)gsl_min_fminimizer_name((gsl_min_fminimizer const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer *arg1 = (gsl_min_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "BUFFER", NULL }; int result; gsl_min_fminimizer * volatile _solver1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_min_fminimizer_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_iterate" "', argument " "1"" of type '" "gsl_min_fminimizer *""'"); } arg1 = (gsl_min_fminimizer *)(argp1); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_min_fminimizer_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_min_fminimizer_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_min_fminimizer_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_min_fminimizer_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_minimum(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer *arg1 = (gsl_min_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_min_fminimizer_minimum",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_minimum" "', argument " "1"" of type '" "gsl_min_fminimizer const *""'"); } arg1 = (gsl_min_fminimizer *)(argp1); result = (double)gsl_min_fminimizer_minimum((gsl_min_fminimizer const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_x_upper(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer *arg1 = (gsl_min_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_min_fminimizer_x_upper",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_x_upper" "', argument " "1"" of type '" "gsl_min_fminimizer const *""'"); } arg1 = (gsl_min_fminimizer *)(argp1); result = (double)gsl_min_fminimizer_x_upper((gsl_min_fminimizer const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_fminimizer_x_lower(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_min_fminimizer *arg1 = (gsl_min_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "S", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_min_fminimizer_x_lower",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_min_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_min_fminimizer_x_lower" "', argument " "1"" of type '" "gsl_min_fminimizer const *""'"); } arg1 = (gsl_min_fminimizer *)(argp1); result = (double)gsl_min_fminimizer_x_lower((gsl_min_fminimizer const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_min_test_interval(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double arg3 ; double arg4 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "X_LOWER",(char *) "X_UPPER",(char *) "EPSABS",(char *) "EPSREL", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_min_test_interval",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_min_test_interval" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_min_test_interval" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_min_test_interval" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_min_test_interval" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); result = (int)gsl_min_test_interval(arg1,arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_function_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_function *arg1 = (gsl_multiroot_function *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_multiroot_function *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_function_init",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_multiroot_function (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_multiroot_function *)gsl_multiroot_function_init(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multiroot_function, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_function_init_fdf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_function_fdf *arg1 = (gsl_multiroot_function_fdf *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_multiroot_function_fdf *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_function_init_fdf",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_multiroot_function_fdf (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_multiroot_function_fdf *)gsl_multiroot_function_init_fdf(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multiroot_function_fdf, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_function_getf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fsolver *arg1 = (gsl_multiroot_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multiroot_solver_data *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_function_getf",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_function_getf" "', argument " "1"" of type '" "gsl_multiroot_fsolver *""'"); } arg1 = (gsl_multiroot_fsolver *)(argp1); result = (gsl_multiroot_solver_data *)gsl_multiroot_function_getf(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_function_fdf_getf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fdfsolver *arg1 = (gsl_multiroot_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multiroot_solver_data *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_function_fdf_getf",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_function_fdf_getf" "', argument " "1"" of type '" "gsl_multiroot_fdfsolver *""'"); } arg1 = (gsl_multiroot_fdfsolver *)(argp1); result = (gsl_multiroot_solver_data *)gsl_multiroot_function_fdf_getf(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_function_getx(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fsolver *arg1 = (gsl_multiroot_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multiroot_solver_data *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_function_getx",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_function_getx" "', argument " "1"" of type '" "gsl_multiroot_fsolver *""'"); } arg1 = (gsl_multiroot_fsolver *)(argp1); result = (gsl_multiroot_solver_data *)gsl_multiroot_function_getx(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_function_fdf_getx(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fdfsolver *arg1 = (gsl_multiroot_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multiroot_solver_data *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_function_fdf_getx",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_function_fdf_getx" "', argument " "1"" of type '" "gsl_multiroot_fdfsolver *""'"); } arg1 = (gsl_multiroot_fdfsolver *)(argp1); result = (gsl_multiroot_solver_data *)gsl_multiroot_function_fdf_getx(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_function_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_function *arg1 = (gsl_multiroot_function *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_multiroot_function *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_function_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_function_free" "', argument " "1"" of type '" "gsl_multiroot_function *""'"); } arg1 = (gsl_multiroot_function *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_multiroot_function_free(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_function_free_fdf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_function_fdf *arg1 = (gsl_multiroot_function_fdf *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_multiroot_function_fdf *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_function_free_fdf",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_function_fdf, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_function_free_fdf" "', argument " "1"" of type '" "gsl_multiroot_function_fdf *""'"); } arg1 = (gsl_multiroot_function_fdf *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_multiroot_function_free_fdf(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fsolver_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fsolver_type *arg1 = (gsl_multiroot_fsolver_type *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "T",(char *) "n", NULL }; gsl_multiroot_fsolver *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multiroot_fsolver_alloc",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fsolver_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fsolver_alloc" "', argument " "1"" of type '" "gsl_multiroot_fsolver_type const *""'"); } arg1 = (gsl_multiroot_fsolver_type *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multiroot_fsolver_alloc" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); result = (gsl_multiroot_fsolver *)gsl_multiroot_fsolver_alloc((gsl_multiroot_fsolver_type const *)arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multiroot_fsolver, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fsolver_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fsolver *arg1 = (gsl_multiroot_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_fsolver_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fsolver_free" "', argument " "1"" of type '" "gsl_multiroot_fsolver *""'"); } arg1 = (gsl_multiroot_fsolver *)(argp1); gsl_multiroot_fsolver_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fsolver_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fsolver *arg1 = (gsl_multiroot_fsolver *) 0 ; gsl_multiroot_function *arg2 = (gsl_multiroot_function *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "s",(char *) "f",(char *) "IN", NULL }; int result; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multiroot_fsolver_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fsolver_set" "', argument " "1"" of type '" "gsl_multiroot_fsolver *""'"); } arg1 = (gsl_multiroot_fsolver *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_multiroot_function, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_multiroot_fsolver_set" "', argument " "2"" of type '" "gsl_multiroot_function *""'"); } arg2 = (gsl_multiroot_function *)(argp2); { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj2, arg3, _PyVector3, _vector3, PyGSL_INPUT_ARRAY, gsl_vector, 3, &stride) != GSL_SUCCESS){ goto fail; } } result = (int)gsl_multiroot_fsolver_set(arg1,arg2,arg3); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fsolver_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fsolver *arg1 = (gsl_multiroot_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_fsolver_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fsolver_iterate" "', argument " "1"" of type '" "gsl_multiroot_fsolver *""'"); } arg1 = (gsl_multiroot_fsolver *)(argp1); result = (int)gsl_multiroot_fsolver_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fsolver_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fsolver *arg1 = (gsl_multiroot_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_fsolver_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fsolver_name" "', argument " "1"" of type '" "gsl_multiroot_fsolver const *""'"); } arg1 = (gsl_multiroot_fsolver *)(argp1); result = (char *)gsl_multiroot_fsolver_name((gsl_multiroot_fsolver const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fsolver_root(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fsolver *arg1 = (gsl_multiroot_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_fsolver_root",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fsolver_root" "', argument " "1"" of type '" "gsl_multiroot_fsolver const *""'"); } arg1 = (gsl_multiroot_fsolver *)(argp1); result = (gsl_vector *)gsl_multiroot_fsolver_root((gsl_multiroot_fsolver const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_vector, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fdfsolver_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fdfsolver_type *arg1 = (gsl_multiroot_fdfsolver_type *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "T",(char *) "n", NULL }; gsl_multiroot_fdfsolver *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multiroot_fdfsolver_alloc",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fdfsolver_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fdfsolver_alloc" "', argument " "1"" of type '" "gsl_multiroot_fdfsolver_type const *""'"); } arg1 = (gsl_multiroot_fdfsolver_type *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multiroot_fdfsolver_alloc" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); result = (gsl_multiroot_fdfsolver *)gsl_multiroot_fdfsolver_alloc((gsl_multiroot_fdfsolver_type const *)arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multiroot_fdfsolver, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fdfsolver_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fdfsolver *arg1 = (gsl_multiroot_fdfsolver *) 0 ; gsl_multiroot_function_fdf *arg2 = (gsl_multiroot_function_fdf *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "s",(char *) "fdf",(char *) "IN", NULL }; int result; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multiroot_fdfsolver_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fdfsolver_set" "', argument " "1"" of type '" "gsl_multiroot_fdfsolver *""'"); } arg1 = (gsl_multiroot_fdfsolver *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_multiroot_function_fdf, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_multiroot_fdfsolver_set" "', argument " "2"" of type '" "gsl_multiroot_function_fdf *""'"); } arg2 = (gsl_multiroot_function_fdf *)(argp2); { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj2, arg3, _PyVector3, _vector3, PyGSL_INPUT_ARRAY, gsl_vector, 3, &stride) != GSL_SUCCESS){ goto fail; } } result = (int)gsl_multiroot_fdfsolver_set(arg1,arg2,arg3); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fdfsolver_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fdfsolver *arg1 = (gsl_multiroot_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_fdfsolver_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fdfsolver_iterate" "', argument " "1"" of type '" "gsl_multiroot_fdfsolver *""'"); } arg1 = (gsl_multiroot_fdfsolver *)(argp1); result = (int)gsl_multiroot_fdfsolver_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fdfsolver_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fdfsolver *arg1 = (gsl_multiroot_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_fdfsolver_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fdfsolver_free" "', argument " "1"" of type '" "gsl_multiroot_fdfsolver *""'"); } arg1 = (gsl_multiroot_fdfsolver *)(argp1); gsl_multiroot_fdfsolver_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fdfsolver_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fdfsolver *arg1 = (gsl_multiroot_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_fdfsolver_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fdfsolver_name" "', argument " "1"" of type '" "gsl_multiroot_fdfsolver const *""'"); } arg1 = (gsl_multiroot_fdfsolver *)(argp1); result = (char *)gsl_multiroot_fdfsolver_name((gsl_multiroot_fdfsolver const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_fdfsolver_root(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multiroot_fdfsolver *arg1 = (gsl_multiroot_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multiroot_fdfsolver_root",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multiroot_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multiroot_fdfsolver_root" "', argument " "1"" of type '" "gsl_multiroot_fdfsolver const *""'"); } arg1 = (gsl_multiroot_fdfsolver *)(argp1); result = (gsl_vector *)gsl_multiroot_fdfsolver_root((gsl_multiroot_fdfsolver const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_vector, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_test_delta(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_vector *arg1 = (gsl_vector *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; double arg3 ; double arg4 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "IN",(char *) "epsabs",(char *) "epsrel", NULL }; int result; PyArrayObject * volatile _PyVector1 = NULL; TYPE_VIEW_gsl_vector _vector1; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_multiroot_test_delta",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj0, arg1, _PyVector1, _vector1, PyGSL_INPUT_ARRAY, gsl_vector, 1, &stride) != GSL_SUCCESS){ goto fail; } } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_multiroot_test_delta" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_multiroot_test_delta" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); result = (int)gsl_multiroot_test_delta((gsl_vector const *)arg1,(gsl_vector const *)arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multiroot_test_residual(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_vector *arg1 = (gsl_vector *) 0 ; double arg2 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "epsabs", NULL }; int result; PyArrayObject * volatile _PyVector1 = NULL; TYPE_VIEW_gsl_vector _vector1; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multiroot_test_residual",kwnames,&obj0,&obj1)) SWIG_fail; { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj0, arg1, _PyVector1, _vector1, PyGSL_INPUT_ARRAY, gsl_vector, 1, &stride) != GSL_SUCCESS){ goto fail; } } ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multiroot_test_residual" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (int)gsl_multiroot_test_residual((gsl_vector const *)arg1,arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN int Swig_var_gsl_multiroot_fsolver_dnewton_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multiroot_fsolver_dnewton is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multiroot_fsolver_dnewton_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multiroot_fsolver_dnewton), SWIGTYPE_p_gsl_multiroot_fsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multiroot_fsolver_broyden_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multiroot_fsolver_broyden is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multiroot_fsolver_broyden_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multiroot_fsolver_broyden), SWIGTYPE_p_gsl_multiroot_fsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multiroot_fsolver_hybrid_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multiroot_fsolver_hybrid is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multiroot_fsolver_hybrid_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multiroot_fsolver_hybrid), SWIGTYPE_p_gsl_multiroot_fsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multiroot_fsolver_hybrids_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multiroot_fsolver_hybrids is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multiroot_fsolver_hybrids_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multiroot_fsolver_hybrids), SWIGTYPE_p_gsl_multiroot_fsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multiroot_fdfsolver_newton_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multiroot_fdfsolver_newton is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multiroot_fdfsolver_newton_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multiroot_fdfsolver_newton), SWIGTYPE_p_gsl_multiroot_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multiroot_fdfsolver_gnewton_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multiroot_fdfsolver_gnewton is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multiroot_fdfsolver_gnewton_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multiroot_fdfsolver_gnewton), SWIGTYPE_p_gsl_multiroot_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multiroot_fdfsolver_hybridj_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multiroot_fdfsolver_hybridj is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multiroot_fdfsolver_hybridj_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multiroot_fdfsolver_hybridj), SWIGTYPE_p_gsl_multiroot_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multiroot_fdfsolver_hybridsj_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multiroot_fdfsolver_hybridsj is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multiroot_fdfsolver_hybridsj_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multiroot_fdfsolver_hybridsj), SWIGTYPE_p_gsl_multiroot_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN PyObject *_wrap_gsl_multimin_function_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_function *arg1 = (gsl_multimin_function *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_multimin_function *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_function_init",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_multimin_function (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_multimin_function *)gsl_multimin_function_init(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multimin_function, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_function_init_fdf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_function_fdf *arg1 = (gsl_multimin_function_fdf *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_multimin_function_fdf *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_function_init_fdf",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_multimin_function_fdf (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_multimin_function_fdf *)gsl_multimin_function_init_fdf(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multimin_function_fdf, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_function_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_function *arg1 = (gsl_multimin_function *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_multimin_function *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_function_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_function_free" "', argument " "1"" of type '" "gsl_multimin_function *""'"); } arg1 = (gsl_multimin_function *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_multimin_function_free(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_function_free_fdf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_function_fdf *arg1 = (gsl_multimin_function_fdf *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_multimin_function_fdf *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_function_free_fdf",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_function_fdf, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_function_free_fdf" "', argument " "1"" of type '" "gsl_multimin_function_fdf *""'"); } arg1 = (gsl_multimin_function_fdf *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_multimin_function_free_fdf(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_f(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer *arg1 = (gsl_multimin_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fminimizer_f",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_f" "', argument " "1"" of type '" "gsl_multimin_fminimizer *""'"); } arg1 = (gsl_multimin_fminimizer *)(argp1); result = (double)gsl_multimin_fminimizer_f(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer_type *arg1 = (gsl_multimin_fminimizer_type *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "T",(char *) "n", NULL }; gsl_multimin_fminimizer *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multimin_fminimizer_alloc",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_alloc" "', argument " "1"" of type '" "gsl_multimin_fminimizer_type const *""'"); } arg1 = (gsl_multimin_fminimizer_type *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multimin_fminimizer_alloc" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); result = (gsl_multimin_fminimizer *)gsl_multimin_fminimizer_alloc((gsl_multimin_fminimizer_type const *)arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer *arg1 = (gsl_multimin_fminimizer *) 0 ; gsl_multimin_function *arg2 = (gsl_multimin_function *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; gsl_vector *arg4 = (gsl_vector *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "s",(char *) "BUFFER",(char *) "IN",(char *) "IN", NULL }; int result; gsl_multimin_function * volatile _solver2 = NULL; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; PyArrayObject * volatile _PyVector4 = NULL; TYPE_VIEW_gsl_vector _vector4; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_multimin_fminimizer_set",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_set" "', argument " "1"" of type '" "gsl_multimin_fminimizer *""'"); } arg1 = (gsl_multimin_fminimizer *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_multimin_function, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_multimin_fminimizer_set" "', argument " "2"" of type '" "gsl_multimin_function *""'"); } arg2 = (gsl_multimin_function *)(argp2); { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj2, arg3, _PyVector3, _vector3, PyGSL_INPUT_ARRAY, gsl_vector, 3, &stride) != GSL_SUCCESS){ goto fail; } } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj3, arg4, _PyVector4, _vector4, PyGSL_INPUT_ARRAY, gsl_vector, 4, &stride) != GSL_SUCCESS){ goto fail; } } { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg2); _solver2 = arg2; p = (callback_function_params *) PyGSL_gsl_multimin_function_GET_PARAMS(_solver2); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_multimin_fminimizer_set(arg1,arg2,(gsl_vector const *)arg3,(gsl_vector const *)arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_multimin_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector4); _PyVector4 = NULL; FUNC_MESS_END(); } return resultobj; fail: { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_multimin_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector4); _PyVector4 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer *arg1 = (gsl_multimin_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fminimizer_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_free" "', argument " "1"" of type '" "gsl_multimin_fminimizer *""'"); } arg1 = (gsl_multimin_fminimizer *)(argp1); gsl_multimin_fminimizer_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer *arg1 = (gsl_multimin_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fminimizer_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_name" "', argument " "1"" of type '" "gsl_multimin_fminimizer const *""'"); } arg1 = (gsl_multimin_fminimizer *)(argp1); result = (char *)gsl_multimin_fminimizer_name((gsl_multimin_fminimizer const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer *arg1 = (gsl_multimin_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fminimizer_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_iterate" "', argument " "1"" of type '" "gsl_multimin_fminimizer *""'"); } arg1 = (gsl_multimin_fminimizer *)(argp1); result = (int)gsl_multimin_fminimizer_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_x(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer *arg1 = (gsl_multimin_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multimin_solver_data *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fminimizer_x",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_x" "', argument " "1"" of type '" "gsl_multimin_fminimizer const *""'"); } arg1 = (gsl_multimin_fminimizer *)(argp1); result = (gsl_multimin_solver_data *)gsl_multimin_fminimizer_x((gsl_multimin_fminimizer const *)arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_minimum(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer *arg1 = (gsl_multimin_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fminimizer_minimum",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_minimum" "', argument " "1"" of type '" "gsl_multimin_fminimizer const *""'"); } arg1 = (gsl_multimin_fminimizer *)(argp1); result = (double)gsl_multimin_fminimizer_minimum((gsl_multimin_fminimizer const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fminimizer_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fminimizer *arg1 = (gsl_multimin_fminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fminimizer_size",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fminimizer_size" "', argument " "1"" of type '" "gsl_multimin_fminimizer const *""'"); } arg1 = (gsl_multimin_fminimizer *)(argp1); result = (double)gsl_multimin_fminimizer_size((gsl_multimin_fminimizer const *)arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer_type *arg1 = (gsl_multimin_fdfminimizer_type *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "T",(char *) "n", NULL }; gsl_multimin_fdfminimizer *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multimin_fdfminimizer_alloc",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_alloc" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer_type const *""'"); } arg1 = (gsl_multimin_fdfminimizer_type *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multimin_fdfminimizer_alloc" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); result = (gsl_multimin_fdfminimizer *)gsl_multimin_fdfminimizer_alloc((gsl_multimin_fdfminimizer_type const *)arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; gsl_multimin_function_fdf *arg2 = (gsl_multimin_function_fdf *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; double arg4 ; double arg5 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "s",(char *) "BUFFER",(char *) "IN",(char *) "step_size",(char *) "tol", NULL }; int result; gsl_multimin_function_fdf * volatile _solver2 = NULL; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_multimin_fdfminimizer_set",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_set" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_multimin_function_fdf, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_multimin_fdfminimizer_set" "', argument " "2"" of type '" "gsl_multimin_function_fdf *""'"); } arg2 = (gsl_multimin_function_fdf *)(argp2); { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj2, arg3, _PyVector3, _vector3, PyGSL_INPUT_ARRAY, gsl_vector, 3, &stride) != GSL_SUCCESS){ goto fail; } } ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_multimin_fdfminimizer_set" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_multimin_fdfminimizer_set" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); { int flag; callback_function_params_fdf * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg2); _solver2 = arg2; p = (callback_function_params_fdf *) PyGSL_gsl_multimin_function_fdf_GET_PARAMS(_solver2); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); /* Set jump buffer */ p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_multimin_fdfminimizer_set(arg1,arg2,(gsl_vector const *)arg3,arg4,arg5); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params_fdf * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_multimin_function_fdf_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return resultobj; fail: { callback_function_params_fdf * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_multimin_function_fdf_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_free" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); gsl_multimin_fdfminimizer_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_name" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer const *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); result = (char *)gsl_multimin_fdfminimizer_name((gsl_multimin_fdfminimizer const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "BUFFER", NULL }; int result; gsl_multimin_fdfminimizer * volatile _solver1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_iterate" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); { int flag; callback_function_params_fdf * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params_fdf *) PyGSL_gsl_multimin_fdfminimizer_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); /* Set jump buffer */ p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_multimin_fdfminimizer_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params_fdf * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_multimin_fdfminimizer_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params_fdf * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_multimin_fdfminimizer_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_restart(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "BUFFER", NULL }; int result; gsl_multimin_fdfminimizer * volatile _solver1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_restart",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_restart" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); { int flag; callback_function_params_fdf * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params_fdf *) PyGSL_gsl_multimin_fdfminimizer_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); /* Set jump buffer */ p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_multimin_fdfminimizer_restart(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params_fdf * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_multimin_fdfminimizer_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params_fdf * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params_fdf *) PyGSL_gsl_multimin_fdfminimizer_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_test_gradient(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_vector *arg1 = (gsl_vector *) 0 ; double arg2 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "epsabs", NULL }; int result; PyArrayObject * volatile _PyVector1 = NULL; TYPE_VIEW_gsl_vector _vector1; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multimin_test_gradient",kwnames,&obj0,&obj1)) SWIG_fail; { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj0, arg1, _PyVector1, _vector1, PyGSL_INPUT_ARRAY, gsl_vector, 1, &stride) != GSL_SUCCESS){ goto fail; } } ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multimin_test_gradient" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (int)gsl_multimin_test_gradient((gsl_vector const *)arg1,arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_test_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "size",(char *) "epsabs", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multimin_test_size",kwnames,&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_multimin_test_size" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multimin_test_size" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (int)gsl_multimin_test_size(arg1,arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_f(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_f",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_f" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); result = (double)gsl_multimin_fdfminimizer_f(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_x(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multimin_solver_data *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_x",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_x" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); result = (gsl_multimin_solver_data *)gsl_multimin_fdfminimizer_x(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_dx(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multimin_solver_data *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_dx",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_dx" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); result = (gsl_multimin_solver_data *)gsl_multimin_fdfminimizer_dx(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_gradient(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multimin_solver_data *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_gradient",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_gradient" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); result = (gsl_multimin_solver_data *)gsl_multimin_fdfminimizer_gradient(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multimin_fdfminimizer_minimum(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multimin_fdfminimizer *arg1 = (gsl_multimin_fdfminimizer *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multimin_fdfminimizer_minimum",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multimin_fdfminimizer, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multimin_fdfminimizer_minimum" "', argument " "1"" of type '" "gsl_multimin_fdfminimizer *""'"); } arg1 = (gsl_multimin_fdfminimizer *)(argp1); result = (double)gsl_multimin_fdfminimizer_minimum(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN int Swig_var_gsl_multimin_fdfminimizer_steepest_descent_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multimin_fdfminimizer_steepest_descent is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multimin_fdfminimizer_steepest_descent_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multimin_fdfminimizer_steepest_descent), SWIGTYPE_p_gsl_multimin_fdfminimizer_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multimin_fdfminimizer_conjugate_pr_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multimin_fdfminimizer_conjugate_pr is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multimin_fdfminimizer_conjugate_pr_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multimin_fdfminimizer_conjugate_pr), SWIGTYPE_p_gsl_multimin_fdfminimizer_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multimin_fdfminimizer_conjugate_fr_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multimin_fdfminimizer_conjugate_fr is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multimin_fdfminimizer_conjugate_fr_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multimin_fdfminimizer_conjugate_fr), SWIGTYPE_p_gsl_multimin_fdfminimizer_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multimin_fdfminimizer_vector_bfgs_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multimin_fdfminimizer_vector_bfgs is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multimin_fdfminimizer_vector_bfgs_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multimin_fdfminimizer_vector_bfgs), SWIGTYPE_p_gsl_multimin_fdfminimizer_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multimin_fminimizer_nmsimplex_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multimin_fminimizer_nmsimplex is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multimin_fminimizer_nmsimplex_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multimin_fminimizer_nmsimplex), SWIGTYPE_p_gsl_multimin_fminimizer_type, 0 ); return pyobj; } SWIGINTERN PyObject *_wrap_gsl_multifit_function_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_function *arg1 = (gsl_multifit_function *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_multifit_function *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_function_init",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_multifit_function (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_multifit_function *)gsl_multifit_function_init(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multifit_function, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_function_init_fdf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_function_fdf *arg1 = (gsl_multifit_function_fdf *) 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "STORE", NULL }; gsl_multifit_function_fdf *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_function_init_fdf",kwnames,&obj0)) SWIG_fail; { FUNC_MESS("gsl_function STORE BEGIN"); arg1 = PyGSL_convert_to_gsl_multifit_function_fdf (obj0); FUNC_MESS("gsl_function STORE END"); if(arg1==NULL) goto fail; } result = (gsl_multifit_function_fdf *)gsl_multifit_function_init_fdf(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multifit_function_fdf, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_getdx(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver *arg1 = (gsl_multifit_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multifit_solver_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fsolver_getdx",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_getdx" "', argument " "1"" of type '" "gsl_multifit_fsolver *""'"); } arg1 = (gsl_multifit_fsolver *)(argp1); result = (gsl_multifit_solver_vector *)gsl_multifit_fsolver_getdx(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_getx(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver *arg1 = (gsl_multifit_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multifit_solver_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fsolver_getx",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_getx" "', argument " "1"" of type '" "gsl_multifit_fsolver *""'"); } arg1 = (gsl_multifit_fsolver *)(argp1); result = (gsl_multifit_solver_vector *)gsl_multifit_fsolver_getx(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_getf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver *arg1 = (gsl_multifit_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multifit_solver_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fsolver_getf",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_getf" "', argument " "1"" of type '" "gsl_multifit_fsolver *""'"); } arg1 = (gsl_multifit_fsolver *)(argp1); result = (gsl_multifit_solver_vector *)gsl_multifit_fsolver_getf(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_getdx(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multifit_solver_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fdfsolver_getdx",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_getdx" "', argument " "1"" of type '" "gsl_multifit_fdfsolver *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); result = (gsl_multifit_solver_vector *)gsl_multifit_fdfsolver_getdx(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_getx(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multifit_solver_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fdfsolver_getx",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_getx" "', argument " "1"" of type '" "gsl_multifit_fdfsolver *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); result = (gsl_multifit_solver_vector *)gsl_multifit_fdfsolver_getx(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_getf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multifit_solver_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fdfsolver_getf",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_getf" "', argument " "1"" of type '" "gsl_multifit_fdfsolver *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); result = (gsl_multifit_solver_vector *)gsl_multifit_fdfsolver_getf(arg1); { PyArrayObject *a_array; a_array = PyGSL_copy_gslvector_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_getJ(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_multifit_solver_matrix *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fdfsolver_getJ",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_getJ" "', argument " "1"" of type '" "gsl_multifit_fdfsolver *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); result = (gsl_multifit_solver_matrix *)gsl_multifit_fdfsolver_getJ(arg1); { PyArrayObject *a_array = NULL; a_array = PyGSL_copy_gslmatrix_to_pyarray(result); resultobj = (PyObject *) a_array; } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_function_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_function *arg1 = (gsl_multifit_function *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_multifit_function *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_function_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_function_free" "', argument " "1"" of type '" "gsl_multifit_function *""'"); } arg1 = (gsl_multifit_function *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_multifit_function_free(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_function_free_fdf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_function_fdf *arg1 = (gsl_multifit_function_fdf *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "FREE", NULL }; gsl_multifit_function_fdf *_function1 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_function_free_fdf",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_function_fdf, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_function_free_fdf" "', argument " "1"" of type '" "gsl_multifit_function_fdf *""'"); } arg1 = (gsl_multifit_function_fdf *)(argp1); { DEBUG_MESS(2, "gsl_function STORE IN ptr @ %p", arg1); if(arg1==NULL) goto fail; _function1 = arg1; } gsl_multifit_function_free_fdf(arg1); resultobj = SWIG_Py_Void(); { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return resultobj; fail: { DEBUG_MESS(2, "gsl_function freeing %p", _function1); if(_function1){ assert(arg1 == _function1); PyGSL_params_free((callback_function_params *) arg1->params); free(arg1); } _function1 = NULL; DEBUG_MESS(2, "gsl_function freed %p", _function1); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver_type *arg1 = (gsl_multifit_fsolver_type *) 0 ; size_t arg2 ; size_t arg3 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; size_t val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "T",(char *) "n",(char *) "p", NULL }; gsl_multifit_fsolver *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multifit_fsolver_alloc",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_alloc" "', argument " "1"" of type '" "gsl_multifit_fsolver_type const *""'"); } arg1 = (gsl_multifit_fsolver_type *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multifit_fsolver_alloc" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); ecode3 = SWIG_AsVal_size_t(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_multifit_fsolver_alloc" "', argument " "3"" of type '" "size_t""'"); } arg3 = (size_t)(val3); result = (gsl_multifit_fsolver *)gsl_multifit_fsolver_alloc((gsl_multifit_fsolver_type const *)arg1,arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver *arg1 = (gsl_multifit_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fsolver_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_free" "', argument " "1"" of type '" "gsl_multifit_fsolver *""'"); } arg1 = (gsl_multifit_fsolver *)(argp1); gsl_multifit_fsolver_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver *arg1 = (gsl_multifit_fsolver *) 0 ; gsl_multifit_function *arg2 = (gsl_multifit_function *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "s",(char *) "f",(char *) "IN", NULL }; int result; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multifit_fsolver_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_set" "', argument " "1"" of type '" "gsl_multifit_fsolver *""'"); } arg1 = (gsl_multifit_fsolver *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_multifit_function, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_multifit_fsolver_set" "', argument " "2"" of type '" "gsl_multifit_function *""'"); } arg2 = (gsl_multifit_function *)(argp2); { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj2, arg3, _PyVector3, _vector3, PyGSL_INPUT_ARRAY, gsl_vector, 3, &stride) != GSL_SUCCESS){ goto fail; } } result = (int)gsl_multifit_fsolver_set(arg1,arg2,arg3); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver *arg1 = (gsl_multifit_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fsolver_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_iterate" "', argument " "1"" of type '" "gsl_multifit_fsolver *""'"); } arg1 = (gsl_multifit_fsolver *)(argp1); result = (int)gsl_multifit_fsolver_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver *arg1 = (gsl_multifit_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fsolver_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_name" "', argument " "1"" of type '" "gsl_multifit_fsolver const *""'"); } arg1 = (gsl_multifit_fsolver *)(argp1); result = (char *)gsl_multifit_fsolver_name((gsl_multifit_fsolver const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fsolver_position(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fsolver *arg1 = (gsl_multifit_fsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fsolver_position",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fsolver_position" "', argument " "1"" of type '" "gsl_multifit_fsolver const *""'"); } arg1 = (gsl_multifit_fsolver *)(argp1); result = (gsl_vector *)gsl_multifit_fsolver_position((gsl_multifit_fsolver const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_vector, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver_type *arg1 = (gsl_multifit_fdfsolver_type *) 0 ; size_t arg2 ; size_t arg3 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; size_t val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "T",(char *) "n",(char *) "p", NULL }; gsl_multifit_fdfsolver *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multifit_fdfsolver_alloc",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_alloc" "', argument " "1"" of type '" "gsl_multifit_fdfsolver_type const *""'"); } arg1 = (gsl_multifit_fdfsolver_type *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multifit_fdfsolver_alloc" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); ecode3 = SWIG_AsVal_size_t(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_multifit_fdfsolver_alloc" "', argument " "3"" of type '" "size_t""'"); } arg3 = (size_t)(val3); result = (gsl_multifit_fdfsolver *)gsl_multifit_fdfsolver_alloc((gsl_multifit_fdfsolver_type const *)arg1,arg2,arg3); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; gsl_multifit_function_fdf *arg2 = (gsl_multifit_function_fdf *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "s",(char *) "fdf",(char *) "IN", NULL }; int result; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multifit_fdfsolver_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_set" "', argument " "1"" of type '" "gsl_multifit_fdfsolver *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_multifit_function_fdf, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_multifit_fdfsolver_set" "', argument " "2"" of type '" "gsl_multifit_function_fdf *""'"); } arg2 = (gsl_multifit_function_fdf *)(argp2); { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj2, arg3, _PyVector3, _vector3, PyGSL_INPUT_ARRAY, gsl_vector, 3, &stride) != GSL_SUCCESS){ goto fail; } } result = (int)gsl_multifit_fdfsolver_set(arg1,arg2,arg3); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_iterate(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fdfsolver_iterate",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_iterate" "', argument " "1"" of type '" "gsl_multifit_fdfsolver *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); result = (int)gsl_multifit_fdfsolver_iterate(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fdfsolver_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_free" "', argument " "1"" of type '" "gsl_multifit_fdfsolver *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); gsl_multifit_fdfsolver_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fdfsolver_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_name" "', argument " "1"" of type '" "gsl_multifit_fdfsolver const *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); result = (char *)gsl_multifit_fdfsolver_name((gsl_multifit_fdfsolver const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_fdfsolver_position(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_fdfsolver *arg1 = (gsl_multifit_fdfsolver *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; gsl_vector *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_fdfsolver_position",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_fdfsolver, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_fdfsolver_position" "', argument " "1"" of type '" "gsl_multifit_fdfsolver const *""'"); } arg1 = (gsl_multifit_fdfsolver *)(argp1); result = (gsl_vector *)gsl_multifit_fdfsolver_position((gsl_multifit_fdfsolver const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_vector, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_test_delta(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_vector *arg1 = (gsl_vector *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; double arg3 ; double arg4 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "IN",(char *) "epsabs",(char *) "epsrel", NULL }; int result; PyArrayObject * volatile _PyVector1 = NULL; TYPE_VIEW_gsl_vector _vector1; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_multifit_test_delta",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj0, arg1, _PyVector1, _vector1, PyGSL_INPUT_ARRAY, gsl_vector, 1, &stride) != GSL_SUCCESS){ goto fail; } } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_multifit_test_delta" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_multifit_test_delta" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); result = (int)gsl_multifit_test_delta((gsl_vector const *)arg1,(gsl_vector const *)arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_test_gradient(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_vector *arg1 = (gsl_vector *) 0 ; double arg2 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "epsabs", NULL }; int result; PyArrayObject * volatile _PyVector1 = NULL; TYPE_VIEW_gsl_vector _vector1; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multifit_test_gradient",kwnames,&obj0,&obj1)) SWIG_fail; { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj0, arg1, _PyVector1, _vector1, PyGSL_INPUT_ARRAY, gsl_vector, 1, &stride) != GSL_SUCCESS){ goto fail; } } ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multifit_test_gradient" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (int)gsl_multifit_test_gradient((gsl_vector const *)arg1,arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN int Swig_var_gsl_multifit_fdfsolver_lmder_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multifit_fdfsolver_lmder is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multifit_fdfsolver_lmder_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multifit_fdfsolver_lmder), SWIGTYPE_p_gsl_multifit_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_multifit_fdfsolver_lmsder_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_multifit_fdfsolver_lmsder is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_multifit_fdfsolver_lmsder_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_multifit_fdfsolver_lmsder), SWIGTYPE_p_gsl_multifit_fdfsolver_type, 0 ); return pyobj; } SWIGINTERN PyObject *_wrap_gsl_integration_workspace_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "n", NULL }; gsl_integration_workspace *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_integration_workspace_alloc",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_size_t(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_integration_workspace_alloc" "', argument " "1"" of type '" "size_t""'"); } arg1 = (size_t)(val1); result = (gsl_integration_workspace *)gsl_integration_workspace_alloc(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_workspace_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_integration_workspace *arg1 = (gsl_integration_workspace *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "w", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_integration_workspace_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_workspace_free" "', argument " "1"" of type '" "gsl_integration_workspace *""'"); } arg1 = (gsl_integration_workspace *)(argp1); gsl_integration_workspace_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_workspace_get_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_integration_workspace *arg1 = (gsl_integration_workspace *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "w", NULL }; size_t result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_integration_workspace_get_size",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_workspace_get_size" "', argument " "1"" of type '" "gsl_integration_workspace *""'"); } arg1 = (gsl_integration_workspace *)(argp1); result = (size_t)gsl_integration_workspace_get_size(arg1); resultobj = SWIG_From_size_t((size_t)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qaws_table_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; int arg3 ; int arg4 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; int val3 ; int ecode3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "alpha",(char *) "beta",(char *) "mu",(char *) "nu", NULL }; gsl_integration_qaws_table *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_integration_qaws_table_alloc",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_integration_qaws_table_alloc" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qaws_table_alloc" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qaws_table_alloc" "', argument " "3"" of type '" "int""'"); } arg3 = (int)(val3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qaws_table_alloc" "', argument " "4"" of type '" "int""'"); } arg4 = (int)(val4); result = (gsl_integration_qaws_table *)gsl_integration_qaws_table_alloc(arg1,arg2,arg3,arg4); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_integration_qaws_table, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qaws_table_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_integration_qaws_table *arg1 = (gsl_integration_qaws_table *) 0 ; double arg2 ; double arg3 ; int arg4 ; int arg5 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; int val4 ; int ecode4 = 0 ; int val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "t",(char *) "alpha",(char *) "beta",(char *) "mu",(char *) "nu", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_integration_qaws_table_set",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_integration_qaws_table, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qaws_table_set" "', argument " "1"" of type '" "gsl_integration_qaws_table *""'"); } arg1 = (gsl_integration_qaws_table *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qaws_table_set" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qaws_table_set" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qaws_table_set" "', argument " "4"" of type '" "int""'"); } arg4 = (int)(val4); ecode5 = SWIG_AsVal_int(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qaws_table_set" "', argument " "5"" of type '" "int""'"); } arg5 = (int)(val5); result = (int)gsl_integration_qaws_table_set(arg1,arg2,arg3,arg4,arg5); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qaws_table_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_integration_qaws_table *arg1 = (gsl_integration_qaws_table *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "t", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_integration_qaws_table_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_integration_qaws_table, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qaws_table_free" "', argument " "1"" of type '" "gsl_integration_qaws_table *""'"); } arg1 = (gsl_integration_qaws_table *)(argp1); gsl_integration_qaws_table_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qawo_table_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; enum gsl_integration_qawo_enum arg3 ; size_t arg4 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; int val3 ; int ecode3 = 0 ; size_t val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "omega",(char *) "L",(char *) "sine",(char *) "n", NULL }; gsl_integration_qawo_table *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_integration_qawo_table_alloc",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_integration_qawo_table_alloc" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qawo_table_alloc" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_int(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qawo_table_alloc" "', argument " "3"" of type '" "enum gsl_integration_qawo_enum""'"); } arg3 = (enum gsl_integration_qawo_enum)(val3); ecode4 = SWIG_AsVal_size_t(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qawo_table_alloc" "', argument " "4"" of type '" "size_t""'"); } arg4 = (size_t)(val4); result = (gsl_integration_qawo_table *)gsl_integration_qawo_table_alloc(arg1,arg2,arg3,arg4); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_integration_qawo_table, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qawo_table_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_integration_qawo_table *arg1 = (gsl_integration_qawo_table *) 0 ; double arg2 ; double arg3 ; enum gsl_integration_qawo_enum arg4 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; int val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "t",(char *) "omega",(char *) "L",(char *) "sine", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_integration_qawo_table_set",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_integration_qawo_table, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qawo_table_set" "', argument " "1"" of type '" "gsl_integration_qawo_table *""'"); } arg1 = (gsl_integration_qawo_table *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qawo_table_set" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qawo_table_set" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_int(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qawo_table_set" "', argument " "4"" of type '" "enum gsl_integration_qawo_enum""'"); } arg4 = (enum gsl_integration_qawo_enum)(val4); result = (int)gsl_integration_qawo_table_set(arg1,arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qawo_table_set_length(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_integration_qawo_table *arg1 = (gsl_integration_qawo_table *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "t",(char *) "L", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_integration_qawo_table_set_length",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_integration_qawo_table, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qawo_table_set_length" "', argument " "1"" of type '" "gsl_integration_qawo_table *""'"); } arg1 = (gsl_integration_qawo_table *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qawo_table_set_length" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (int)gsl_integration_qawo_table_set_length(arg1,arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qawo_table_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_integration_qawo_table *arg1 = (gsl_integration_qawo_table *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "t", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_integration_qawo_table_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_integration_qawo_table, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qawo_table_free" "', argument " "1"" of type '" "gsl_integration_qawo_table *""'"); } arg1 = (gsl_integration_qawo_table *)(argp1); gsl_integration_qawo_table_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qng(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; double arg4 ; double arg5 ; double *arg6 = (double *) 0 ; double *arg7 = (double *) 0 ; size_t *arg8 = (size_t *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; double temp6 ; int res6 = SWIG_TMPOBJ ; double temp7 ; int res7 = SWIG_TMPOBJ ; size_t temp8 ; int res8 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "a",(char *) "b",(char *) "epsabs",(char *) "epsrel", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg6 = &temp6; arg7 = &temp7; arg8 = &temp8; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_integration_qng",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qng" "', argument " "1"" of type '" "gsl_function const *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qng" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qng" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qng" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qng" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qng((gsl_function const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res6)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg6))); } else { int new_flags = SWIG_IsNewObj(res6) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg6), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res7)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg7))); } else { int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_int((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_unsigned_int, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qag(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; double arg4 ; double arg5 ; size_t arg6 ; int arg7 ; gsl_integration_workspace *arg8 = (gsl_integration_workspace *) 0 ; double *arg9 = (double *) 0 ; double *arg10 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; size_t val6 ; int ecode6 = 0 ; int val7 ; int ecode7 = 0 ; void *argp8 = 0 ; int res8 = 0 ; double temp9 ; int res9 = SWIG_TMPOBJ ; double temp10 ; int res10 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; PyObject * obj6 = 0 ; PyObject * obj7 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "a",(char *) "b",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "key",(char *) "workspace", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg9 = &temp9; arg10 = &temp10; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOOO:gsl_integration_qag",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qag" "', argument " "1"" of type '" "gsl_function const *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qag" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qag" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qag" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qag" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); ecode6 = SWIG_AsVal_size_t(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "gsl_integration_qag" "', argument " "6"" of type '" "size_t""'"); } arg6 = (size_t)(val6); ecode7 = SWIG_AsVal_int(obj6, &val7); if (!SWIG_IsOK(ecode7)) { SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "gsl_integration_qag" "', argument " "7"" of type '" "int""'"); } arg7 = (int)(val7); res8 = SWIG_ConvertPtr(obj7, &argp8,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res8)) { SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "gsl_integration_qag" "', argument " "8"" of type '" "gsl_integration_workspace *""'"); } arg8 = (gsl_integration_workspace *)(argp8); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qag((gsl_function const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res10)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg10))); } else { int new_flags = SWIG_IsNewObj(res10) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg10), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qagi(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; size_t arg4 ; gsl_integration_workspace *arg5 = (gsl_integration_workspace *) 0 ; double *arg6 = (double *) 0 ; double *arg7 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; size_t val4 ; int ecode4 = 0 ; void *argp5 = 0 ; int res5 = 0 ; double temp6 ; int res6 = SWIG_TMPOBJ ; double temp7 ; int res7 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "workspace", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg6 = &temp6; arg7 = &temp7; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_integration_qagi",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qagi" "', argument " "1"" of type '" "gsl_function *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qagi" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qagi" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_size_t(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qagi" "', argument " "4"" of type '" "size_t""'"); } arg4 = (size_t)(val4); res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "gsl_integration_qagi" "', argument " "5"" of type '" "gsl_integration_workspace *""'"); } arg5 = (gsl_integration_workspace *)(argp5); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qagi(arg1,arg2,arg3,arg4,arg5,arg6,arg7); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res6)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg6))); } else { int new_flags = SWIG_IsNewObj(res6) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg6), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res7)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg7))); } else { int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qagiu(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; double arg4 ; size_t arg5 ; gsl_integration_workspace *arg6 = (gsl_integration_workspace *) 0 ; double *arg7 = (double *) 0 ; double *arg8 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; size_t val5 ; int ecode5 = 0 ; void *argp6 = 0 ; int res6 = 0 ; double temp7 ; int res7 = SWIG_TMPOBJ ; double temp8 ; int res8 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "a",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "workspace", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg7 = &temp7; arg8 = &temp8; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOO:gsl_integration_qagiu",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qagiu" "', argument " "1"" of type '" "gsl_function *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qagiu" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qagiu" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qagiu" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_size_t(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qagiu" "', argument " "5"" of type '" "size_t""'"); } arg5 = (size_t)(val5); res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res6)) { SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "gsl_integration_qagiu" "', argument " "6"" of type '" "gsl_integration_workspace *""'"); } arg6 = (gsl_integration_workspace *)(argp6); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qagiu(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res7)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg7))); } else { int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qagil(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; double arg4 ; size_t arg5 ; gsl_integration_workspace *arg6 = (gsl_integration_workspace *) 0 ; double *arg7 = (double *) 0 ; double *arg8 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; size_t val5 ; int ecode5 = 0 ; void *argp6 = 0 ; int res6 = 0 ; double temp7 ; int res7 = SWIG_TMPOBJ ; double temp8 ; int res8 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "b",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "workspace", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg7 = &temp7; arg8 = &temp8; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOO:gsl_integration_qagil",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qagil" "', argument " "1"" of type '" "gsl_function *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qagil" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qagil" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qagil" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_size_t(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qagil" "', argument " "5"" of type '" "size_t""'"); } arg5 = (size_t)(val5); res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res6)) { SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "gsl_integration_qagil" "', argument " "6"" of type '" "gsl_integration_workspace *""'"); } arg6 = (gsl_integration_workspace *)(argp6); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qagil(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res7)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg7))); } else { int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qags(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; double arg4 ; double arg5 ; size_t arg6 ; gsl_integration_workspace *arg7 = (gsl_integration_workspace *) 0 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; size_t val6 ; int ecode6 = 0 ; void *argp7 = 0 ; int res7 = 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; PyObject * obj6 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "a",(char *) "b",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "workspace", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg8 = &temp8; arg9 = &temp9; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOO:gsl_integration_qags",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qags" "', argument " "1"" of type '" "gsl_function const *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qags" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qags" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qags" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qags" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); ecode6 = SWIG_AsVal_size_t(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "gsl_integration_qags" "', argument " "6"" of type '" "size_t""'"); } arg6 = (size_t)(val6); res7 = SWIG_ConvertPtr(obj6, &argp7,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res7)) { SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "gsl_integration_qags" "', argument " "7"" of type '" "gsl_integration_workspace *""'"); } arg7 = (gsl_integration_workspace *)(argp7); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qags((gsl_function const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qagp(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double *arg2 = (double *) 0 ; size_t arg3 ; double arg4 ; double arg5 ; size_t arg6 ; gsl_integration_workspace *arg7 = (gsl_integration_workspace *) 0 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; size_t val6 ; int ecode6 = 0 ; void *argp7 = 0 ; int res7 = 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "pts",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "workspace", NULL }; int result; gsl_function * volatile _solver1 = NULL; PyArrayObject * volatile _PyVector2 = NULL; arg8 = &temp8; arg9 = &temp9; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOO:gsl_integration_qagp",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qagp" "', argument " "1"" of type '" "gsl_function const *""'"); } arg1 = (gsl_function *)(argp1); _PyVector2 = PyGSL_vector_check(obj1, -1, PyGSL_DARRAY_CINPUT(2), NULL, NULL); if (_PyVector2 == NULL) goto fail; arg2 = (double*)(_PyVector2->data); arg3 = _PyVector2->dimensions[0]; ecode4 = SWIG_AsVal_double(obj2, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qagp" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj3, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qagp" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); ecode6 = SWIG_AsVal_size_t(obj4, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "gsl_integration_qagp" "', argument " "6"" of type '" "size_t""'"); } arg6 = (size_t)(val6); res7 = SWIG_ConvertPtr(obj5, &argp7,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res7)) { SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "gsl_integration_qagp" "', argument " "7"" of type '" "gsl_integration_workspace *""'"); } arg7 = (gsl_integration_workspace *)(argp7); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qagp((gsl_function const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector2); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qawc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; double arg4 ; double arg5 ; double arg6 ; size_t arg7 ; gsl_integration_workspace *arg8 = (gsl_integration_workspace *) 0 ; double *arg9 = (double *) 0 ; double *arg10 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; double val6 ; int ecode6 = 0 ; size_t val7 ; int ecode7 = 0 ; void *argp8 = 0 ; int res8 = 0 ; double temp9 ; int res9 = SWIG_TMPOBJ ; double temp10 ; int res10 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; PyObject * obj6 = 0 ; PyObject * obj7 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "a",(char *) "b",(char *) "c",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "workspace", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg9 = &temp9; arg10 = &temp10; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOOO:gsl_integration_qawc",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qawc" "', argument " "1"" of type '" "gsl_function *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qawc" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qawc" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qawc" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qawc" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); ecode6 = SWIG_AsVal_double(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "gsl_integration_qawc" "', argument " "6"" of type '" "double""'"); } arg6 = (double)(val6); ecode7 = SWIG_AsVal_size_t(obj6, &val7); if (!SWIG_IsOK(ecode7)) { SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "gsl_integration_qawc" "', argument " "7"" of type '" "size_t""'"); } arg7 = (size_t)(val7); res8 = SWIG_ConvertPtr(obj7, &argp8,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res8)) { SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "gsl_integration_qawc" "', argument " "8"" of type '" "gsl_integration_workspace *""'"); } arg8 = (gsl_integration_workspace *)(argp8); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qawc(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res10)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg10))); } else { int new_flags = SWIG_IsNewObj(res10) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg10), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qaws(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; gsl_integration_qaws_table *arg4 = (gsl_integration_qaws_table *) 0 ; double arg5 ; double arg6 ; size_t arg7 ; gsl_integration_workspace *arg8 = (gsl_integration_workspace *) 0 ; double *arg9 = (double *) 0 ; double *arg10 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; void *argp4 = 0 ; int res4 = 0 ; double val5 ; int ecode5 = 0 ; double val6 ; int ecode6 = 0 ; size_t val7 ; int ecode7 = 0 ; void *argp8 = 0 ; int res8 = 0 ; double temp9 ; int res9 = SWIG_TMPOBJ ; double temp10 ; int res10 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; PyObject * obj6 = 0 ; PyObject * obj7 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "a",(char *) "b",(char *) "t",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "workspace", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg9 = &temp9; arg10 = &temp10; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOOO:gsl_integration_qaws",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qaws" "', argument " "1"" of type '" "gsl_function *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qaws" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qaws" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_gsl_integration_qaws_table, 0 | 0 ); if (!SWIG_IsOK(res4)) { SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "gsl_integration_qaws" "', argument " "4"" of type '" "gsl_integration_qaws_table *""'"); } arg4 = (gsl_integration_qaws_table *)(argp4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qaws" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); ecode6 = SWIG_AsVal_double(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "gsl_integration_qaws" "', argument " "6"" of type '" "double""'"); } arg6 = (double)(val6); ecode7 = SWIG_AsVal_size_t(obj6, &val7); if (!SWIG_IsOK(ecode7)) { SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "gsl_integration_qaws" "', argument " "7"" of type '" "size_t""'"); } arg7 = (size_t)(val7); res8 = SWIG_ConvertPtr(obj7, &argp8,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res8)) { SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "gsl_integration_qaws" "', argument " "8"" of type '" "gsl_integration_workspace *""'"); } arg8 = (gsl_integration_workspace *)(argp8); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qaws(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res10)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg10))); } else { int new_flags = SWIG_IsNewObj(res10) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg10), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qawo(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; double arg4 ; size_t arg5 ; gsl_integration_workspace *arg6 = (gsl_integration_workspace *) 0 ; gsl_integration_qawo_table *arg7 = (gsl_integration_qawo_table *) 0 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; size_t val5 ; int ecode5 = 0 ; void *argp6 = 0 ; int res6 = 0 ; void *argp7 = 0 ; int res7 = 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; PyObject * obj6 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "a",(char *) "epsabs",(char *) "epsrel",(char *) "limit",(char *) "workspace",(char *) "wf", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg8 = &temp8; arg9 = &temp9; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOO:gsl_integration_qawo",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qawo" "', argument " "1"" of type '" "gsl_function *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qawo" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qawo" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qawo" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_size_t(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_integration_qawo" "', argument " "5"" of type '" "size_t""'"); } arg5 = (size_t)(val5); res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res6)) { SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "gsl_integration_qawo" "', argument " "6"" of type '" "gsl_integration_workspace *""'"); } arg6 = (gsl_integration_workspace *)(argp6); res7 = SWIG_ConvertPtr(obj6, &argp7,SWIGTYPE_p_gsl_integration_qawo_table, 0 | 0 ); if (!SWIG_IsOK(res7)) { SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "gsl_integration_qawo" "', argument " "7"" of type '" "gsl_integration_qawo_table *""'"); } arg7 = (gsl_integration_qawo_table *)(argp7); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qawo(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_integration_qawf(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_function *arg1 = (gsl_function *) 0 ; double arg2 ; double arg3 ; size_t arg4 ; gsl_integration_workspace *arg5 = (gsl_integration_workspace *) 0 ; gsl_integration_workspace *arg6 = (gsl_integration_workspace *) 0 ; gsl_integration_qawo_table *arg7 = (gsl_integration_qawo_table *) 0 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; size_t val4 ; int ecode4 = 0 ; void *argp5 = 0 ; int res5 = 0 ; void *argp6 = 0 ; int res6 = 0 ; void *argp7 = 0 ; int res7 = 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; PyObject * obj6 = 0 ; char * kwnames[] = { (char *) "BUFFER",(char *) "a",(char *) "epsabs",(char *) "limit",(char *) "workspace",(char *) "cycle_workspace",(char *) "wf", NULL }; int result; gsl_function * volatile _solver1 = NULL; arg8 = &temp8; arg9 = &temp9; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOO:gsl_integration_qawf",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_integration_qawf" "', argument " "1"" of type '" "gsl_function *""'"); } arg1 = (gsl_function *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_integration_qawf" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_integration_qawf" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_size_t(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_integration_qawf" "', argument " "4"" of type '" "size_t""'"); } arg4 = (size_t)(val4); res5 = SWIG_ConvertPtr(obj4, &argp5,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res5)) { SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "gsl_integration_qawf" "', argument " "5"" of type '" "gsl_integration_workspace *""'"); } arg5 = (gsl_integration_workspace *)(argp5); res6 = SWIG_ConvertPtr(obj5, &argp6,SWIGTYPE_p_gsl_integration_workspace, 0 | 0 ); if (!SWIG_IsOK(res6)) { SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "gsl_integration_qawf" "', argument " "6"" of type '" "gsl_integration_workspace *""'"); } arg6 = (gsl_integration_workspace *)(argp6); res7 = SWIG_ConvertPtr(obj6, &argp7,SWIGTYPE_p_gsl_integration_qawo_table, 0 | 0 ); if (!SWIG_IsOK(res7)) { SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "gsl_integration_qawf" "', argument " "7"" of type '" "gsl_integration_qawo_table *""'"); } arg7 = (gsl_integration_qawo_table *)(argp7); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg1); _solver1 = arg1; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_integration_qawf(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver1){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver1); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "order", NULL }; gsl_cheb_series *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_cheb_alloc",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_size_t(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_cheb_alloc" "', argument " "1"" of type '" "size_t""'"); } arg1 = (size_t)(val1); result = (gsl_cheb_series *)gsl_cheb_alloc(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "cs", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_cheb_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_cheb_free" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); gsl_cheb_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; gsl_function *arg2 = (gsl_function *) 0 ; double arg3 ; double arg4 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "cs",(char *) "BUFFER",(char *) "a",(char *) "b", NULL }; int result; gsl_function * volatile _solver2 = NULL; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_cheb_init",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_cheb_init" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_function, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_cheb_init" "', argument " "2"" of type '" "gsl_function const *""'"); } arg2 = (gsl_function *)(argp2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_cheb_init" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_cheb_init" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); { int flag; callback_function_params * p; FUNC_MESS("\t\t Setting jump buffer"); assert(arg2); _solver2 = arg2; p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if((flag=setjmp(p->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); p->buffer_is_set = 1; } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); p->buffer_is_set = 0; goto fail; } FUNC_MESS("\t\t END Setting jump buffer"); } result = (int)gsl_cheb_init(arg1,(gsl_function const *)arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return resultobj; fail: { callback_function_params * p; if(_solver2){ FUNC_MESS("\t\t Looking for pointer params"); p = (callback_function_params *) PyGSL_gsl_function_GET_PARAMS(_solver2); if(p){ FUNC_MESS("\t\t Setting buffer_is_set = 0"); p->buffer_is_set = 0; } } } return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_eval(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "cs",(char *) "x", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_cheb_eval",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_cheb_eval" "', argument " "1"" of type '" "gsl_cheb_series const *""'"); } arg1 = (gsl_cheb_series *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_cheb_eval" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (double)gsl_cheb_eval((gsl_cheb_series const *)arg1,arg2); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_eval_err(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; double arg2 ; double *arg3 = (double *) 0 ; double *arg4 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double temp3 ; int res3 = SWIG_TMPOBJ ; double temp4 ; int res4 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "cs",(char *) "x", NULL }; int result; arg3 = &temp3; arg4 = &temp4; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_cheb_eval_err",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_cheb_eval_err" "', argument " "1"" of type '" "gsl_cheb_series const *""'"); } arg1 = (gsl_cheb_series *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_cheb_eval_err" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (int)gsl_cheb_eval_err((gsl_cheb_series const *)arg1,arg2,arg3,arg4); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res3)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg3))); } else { int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg4))); } else { int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_double, new_flags)); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_eval_n(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; size_t arg2 ; double arg3 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "cs",(char *) "order",(char *) "x", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_cheb_eval_n",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_cheb_eval_n" "', argument " "1"" of type '" "gsl_cheb_series const *""'"); } arg1 = (gsl_cheb_series *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_cheb_eval_n" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_cheb_eval_n" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); result = (double)gsl_cheb_eval_n((gsl_cheb_series const *)arg1,arg2,arg3); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_eval_n_err(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; size_t arg2 ; double arg3 ; double *arg4 = (double *) 0 ; double *arg5 = (double *) 0 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double temp4 ; int res4 = SWIG_TMPOBJ ; double temp5 ; int res5 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "cs",(char *) "order",(char *) "x", NULL }; int result; arg4 = &temp4; arg5 = &temp5; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_cheb_eval_n_err",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_cheb_eval_n_err" "', argument " "1"" of type '" "gsl_cheb_series const *""'"); } arg1 = (gsl_cheb_series *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_cheb_eval_n_err" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_cheb_eval_n_err" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); result = (int)gsl_cheb_eval_n_err((gsl_cheb_series const *)arg1,arg2,arg3,arg4,arg5); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg4))); } else { int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res5)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg5))); } else { int new_flags = SWIG_IsNewObj(res5) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg5), SWIGTYPE_p_double, new_flags)); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_calc_deriv(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; gsl_cheb_series *arg2 = (gsl_cheb_series *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "deriv",(char *) "cs", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_cheb_calc_deriv",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_cheb_calc_deriv" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_cheb_calc_deriv" "', argument " "2"" of type '" "gsl_cheb_series const *""'"); } arg2 = (gsl_cheb_series *)(argp2); result = (int)gsl_cheb_calc_deriv(arg1,(gsl_cheb_series const *)arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_cheb_calc_integ(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; gsl_cheb_series *arg2 = (gsl_cheb_series *) 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "integ",(char *) "cs", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_cheb_calc_integ",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_cheb_calc_integ" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res2)) { SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "gsl_cheb_calc_integ" "', argument " "2"" of type '" "gsl_cheb_series const *""'"); } arg2 = (gsl_cheb_series *)(argp2); result = (int)gsl_cheb_calc_integ(arg1,(gsl_cheb_series const *)arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_get_coefficients(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; PyObject *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_cheb_get_coefficients",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_get_coefficients" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); result = (PyObject *)pygsl_cheb_get_coefficients(arg1); resultobj = result; return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_set_coefficients(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "IN", NULL }; int result; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_cheb_set_coefficients",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_set_coefficients" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } result = (int)pygsl_cheb_set_coefficients(arg1,arg2); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_get_a(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_cheb_get_a",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_get_a" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); result = (double)pygsl_cheb_get_a(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_get_b(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_cheb_get_b",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_get_b" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); result = (double)pygsl_cheb_get_b(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_set_a(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "a", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_cheb_set_a",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_set_a" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_cheb_set_a" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_cheb_set_a(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_set_b(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "b", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_cheb_set_b",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_set_b" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_cheb_set_b" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_cheb_set_b(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_get_order_sp(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; size_t result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_cheb_get_order_sp",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_get_order_sp" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); result = (size_t)pygsl_cheb_get_order_sp(arg1); resultobj = SWIG_From_size_t((size_t)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_set_order_sp(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "sp", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_cheb_set_order_sp",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_set_order_sp" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_cheb_set_order_sp" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); pygsl_cheb_set_order_sp(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_get_f(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; double result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:pygsl_cheb_get_f",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_get_f" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); result = (double)pygsl_cheb_get_f(arg1); resultobj = SWIG_From_double((double)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_pygsl_cheb_set_f(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_cheb_series *arg1 = (gsl_cheb_series *) 0 ; double arg2 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "s",(char *) "f", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:pygsl_cheb_set_f",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_cheb_series, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pygsl_cheb_set_f" "', argument " "1"" of type '" "gsl_cheb_series *""'"); } arg1 = (gsl_cheb_series *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pygsl_cheb_set_f" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); pygsl_cheb_set_f(arg1,arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN int Swig_var_gsl_odeiv_step_rk2_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_rk2 is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_rk2_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_rk2), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_rk4_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_rk4 is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_rk4_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_rk4), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_rkf45_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_rkf45 is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_rkf45_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_rkf45), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_rkck_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_rkck is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_rkck_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_rkck), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_rk8pd_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_rk8pd is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_rk8pd_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_rk8pd), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_rk2imp_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_rk2imp is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_rk2imp_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_rk2imp), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_rk4imp_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_rk4imp is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_rk4imp_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_rk4imp), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_bsimp_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_bsimp is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_bsimp_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_bsimp), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_gear1_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_gear1 is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_gear1_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_gear1), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN int Swig_var_gsl_odeiv_step_gear2_set(PyObject *_val SWIGUNUSED) { SWIG_Error(SWIG_AttributeError,"Variable gsl_odeiv_step_gear2 is read-only."); return 1; } SWIGINTERN PyObject *Swig_var_gsl_odeiv_step_gear2_get(void) { PyObject *pyobj = 0; pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(gsl_odeiv_step_gear2), SWIGTYPE_p_gsl_odeiv_step_type, 0 ); return pyobj; } SWIGINTERN PyObject *_wrap_gsl_odeiv_step_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_step_type *arg1 = (gsl_odeiv_step_type *) 0 ; size_t arg2 ; void *argp1 = 0 ; int res1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "T",(char *) "dim", NULL }; gsl_odeiv_step *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_odeiv_step_alloc",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_step_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_step_alloc" "', argument " "1"" of type '" "gsl_odeiv_step_type const *""'"); } arg1 = (gsl_odeiv_step_type *)(argp1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_odeiv_step_alloc" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); result = (gsl_odeiv_step *)gsl_odeiv_step_alloc((gsl_odeiv_step_type const *)arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_odeiv_step, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_step_reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_step *arg1 = (gsl_odeiv_step *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_step_reset",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_step, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_step_reset" "', argument " "1"" of type '" "gsl_odeiv_step *""'"); } arg1 = (gsl_odeiv_step *)(argp1); result = (int)gsl_odeiv_step_reset(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_step_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_step *arg1 = (gsl_odeiv_step *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_step_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_step, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_step_free" "', argument " "1"" of type '" "gsl_odeiv_step *""'"); } arg1 = (gsl_odeiv_step *)(argp1); gsl_odeiv_step_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_step_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_step *arg1 = (gsl_odeiv_step *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *)"arg1", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_step_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_step, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_step_name" "', argument " "1"" of type '" "gsl_odeiv_step const *""'"); } arg1 = (gsl_odeiv_step *)(argp1); result = (char *)gsl_odeiv_step_name((gsl_odeiv_step const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_step_order(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_step *arg1 = (gsl_odeiv_step *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "s", NULL }; unsigned int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_step_order",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_step, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_step_order" "', argument " "1"" of type '" "gsl_odeiv_step const *""'"); } arg1 = (gsl_odeiv_step *)(argp1); result = (unsigned int)gsl_odeiv_step_order((gsl_odeiv_step const *)arg1); resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_control_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_control_type *arg1 = (gsl_odeiv_control_type *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "T", NULL }; gsl_odeiv_control *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_control_alloc",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_control_type, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_control_alloc" "', argument " "1"" of type '" "gsl_odeiv_control_type const *""'"); } arg1 = (gsl_odeiv_control_type *)(argp1); result = (gsl_odeiv_control *)gsl_odeiv_control_alloc((gsl_odeiv_control_type const *)arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_odeiv_control, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_control_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_control *arg1 = (gsl_odeiv_control *) 0 ; double arg2 ; double arg3 ; double arg4 ; double arg5 ; void *argp1 = 0 ; int res1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "c",(char *) "eps_abs",(char *) "eps_rel",(char *) "a_y",(char *) "a_dydt", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_odeiv_control_init",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_control, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_control_init" "', argument " "1"" of type '" "gsl_odeiv_control *""'"); } arg1 = (gsl_odeiv_control *)(argp1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_odeiv_control_init" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_odeiv_control_init" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_odeiv_control_init" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_odeiv_control_init" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); result = (int)gsl_odeiv_control_init(arg1,arg2,arg3,arg4,arg5); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_control_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_control *arg1 = (gsl_odeiv_control *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "c", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_control_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_control, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_control_free" "', argument " "1"" of type '" "gsl_odeiv_control *""'"); } arg1 = (gsl_odeiv_control *)(argp1); gsl_odeiv_control_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_control_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_control *arg1 = (gsl_odeiv_control *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "c", NULL }; char *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_control_name",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_control, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_control_name" "', argument " "1"" of type '" "gsl_odeiv_control const *""'"); } arg1 = (gsl_odeiv_control *)(argp1); result = (char *)gsl_odeiv_control_name((gsl_odeiv_control const *)arg1); resultobj = SWIG_FromCharPtr((const char *)result); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_control_standard_new(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double arg3 ; double arg4 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "eps_abs",(char *) "eps_rel",(char *) "a_y",(char *) "a_dydt", NULL }; gsl_odeiv_control *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_odeiv_control_standard_new",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_odeiv_control_standard_new" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_odeiv_control_standard_new" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_odeiv_control_standard_new" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_odeiv_control_standard_new" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); result = (gsl_odeiv_control *)gsl_odeiv_control_standard_new(arg1,arg2,arg3,arg4); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_odeiv_control, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_control_y_new(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "eps_abs",(char *) "eps_rel", NULL }; gsl_odeiv_control *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_odeiv_control_y_new",kwnames,&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_odeiv_control_y_new" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_odeiv_control_y_new" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (gsl_odeiv_control *)gsl_odeiv_control_y_new(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_odeiv_control, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_control_yp_new(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "eps_abs",(char *) "eps_rel", NULL }; gsl_odeiv_control *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_odeiv_control_yp_new",kwnames,&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_odeiv_control_yp_new" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_odeiv_control_yp_new" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); result = (gsl_odeiv_control *)gsl_odeiv_control_yp_new(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_odeiv_control, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_evolve_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; size_t arg1 ; size_t val1 ; int ecode1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "dim", NULL }; gsl_odeiv_evolve *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_evolve_alloc",kwnames,&obj0)) SWIG_fail; ecode1 = SWIG_AsVal_size_t(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_odeiv_evolve_alloc" "', argument " "1"" of type '" "size_t""'"); } arg1 = (size_t)(val1); result = (gsl_odeiv_evolve *)gsl_odeiv_evolve_alloc(arg1); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_odeiv_evolve, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_evolve_reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_evolve *arg1 = (gsl_odeiv_evolve *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *)"arg1", NULL }; int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_evolve_reset",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_evolve, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_evolve_reset" "', argument " "1"" of type '" "gsl_odeiv_evolve *""'"); } arg1 = (gsl_odeiv_evolve *)(argp1); result = (int)gsl_odeiv_evolve_reset(arg1); { resultobj = PyGSL_ERROR_FLAG_TO_PYINT(result); if (resultobj == NULL){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 48); goto fail; } } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_odeiv_evolve_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_odeiv_evolve *arg1 = (gsl_odeiv_evolve *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *)"arg1", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_odeiv_evolve_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_odeiv_evolve, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_odeiv_evolve_free" "', argument " "1"" of type '" "gsl_odeiv_evolve *""'"); } arg1 = (gsl_odeiv_evolve *)(argp1); gsl_odeiv_evolve_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_linear_alloc(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; size_t arg1 ; size_t arg2 ; size_t val1 ; int ecode1 = 0 ; size_t val2 ; int ecode2 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "n",(char *) "p", NULL }; gsl_multifit_linear_workspace *result = 0 ; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_multifit_linear_alloc",kwnames,&obj0,&obj1)) SWIG_fail; ecode1 = SWIG_AsVal_size_t(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_multifit_linear_alloc" "', argument " "1"" of type '" "size_t""'"); } arg1 = (size_t)(val1); ecode2 = SWIG_AsVal_size_t(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_multifit_linear_alloc" "', argument " "2"" of type '" "size_t""'"); } arg2 = (size_t)(val2); result = (gsl_multifit_linear_workspace *)gsl_multifit_linear_alloc(arg1,arg2); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_gsl_multifit_linear_workspace, 0 | 0 ); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_linear_free(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_multifit_linear_workspace *arg1 = (gsl_multifit_linear_workspace *) 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; char * kwnames[] = { (char *) "work", NULL }; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:gsl_multifit_linear_free",kwnames,&obj0)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_gsl_multifit_linear_workspace, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "gsl_multifit_linear_free" "', argument " "1"" of type '" "gsl_multifit_linear_workspace *""'"); } arg1 = (gsl_multifit_linear_workspace *)(argp1); gsl_multifit_linear_free(arg1); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_linear(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_matrix *arg1 = (gsl_matrix *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; gsl_matrix *arg4 = (gsl_matrix *) 0 ; double *arg5 = (double *) 0 ; gsl_multifit_linear_workspace *arg6 = (gsl_multifit_linear_workspace *) 0 ; double temp5 ; int res5 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "IN",(char *) "work_provide", NULL }; gsl_error_flag_drop result; PyArrayObject * _PyMatrix1 = NULL; TYPE_VIEW_gsl_matrix _matrix1; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; PyArrayObject * _PyMatrix4 = NULL; TYPE_VIEW_gsl_matrix _matrix4; PyGSL_array_index_t _work_provide_n_work_provide = -1; PyGSL_array_index_t _work_provide_p_work_provide = -1; /* All done in check as the workspace stores the information about the required size */ /* All done in check as the workspace stores the information about the required size */ arg5 = &temp5; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multifit_linear",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; { PyGSL_array_index_t stride; if(PyGSL_MATRIX_CONVERT(obj0, arg1, _PyMatrix1, _matrix1, PyGSL_INPUT_ARRAY, gsl_matrix, 1, &stride) != GSL_SUCCESS) goto fail; } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } { if ((SWIG_ConvertPtr(obj2, (void **) &arg6, SWIGTYPE_p_gsl_multifit_linear_workspace,1)) == -1){ goto fail; } _work_provide_n_work_provide = (int) arg6->n; _work_provide_p_work_provide = (int) arg6->p; } { PyGSL_array_index_t stride; _PyVector3 = (PyArrayObject *) PyGSL_New_Array(1, &_work_provide_p_work_provide, PyArray_DOUBLE); if(NULL == _PyVector3){ goto fail; } if(PyGSL_STRIDE_RECALC(_PyVector3->strides[0], sizeof(BASIS_TYPE(gsl_vector)), &stride) != GSL_SUCCESS) goto fail; _vector3 = TYPE_VIEW_ARRAY_STRIDES_gsl_vector((BASIS_C_TYPE(gsl_vector) *) _PyVector3->data, stride, _PyVector3->dimensions[0]); arg3 = (gsl_vector *) &(_vector3.vector); } { PyArrayObject * a_array; PyGSL_array_index_t stride_recalc=0, dimensions[2]; dimensions[0] = _work_provide_p_work_provide; dimensions[1] = _work_provide_p_work_provide; a_array = (PyArrayObject *) PyGSL_New_Array(2, dimensions, PyArray_DOUBLE); if(NULL == a_array){ goto fail; } _PyMatrix4 = a_array; if(PyGSL_STRIDE_RECALC(a_array->strides[0], sizeof(BASIS_TYPE(gsl_matrix)), &stride_recalc) != GSL_SUCCESS) goto fail; /* (BASIS_TYPE_gsl_matrix *) */ _matrix4 = TYPE_VIEW_ARRAY_gsl_matrix((BASIS_C_TYPE(gsl_matrix) *) a_array->data, a_array->dimensions[0], a_array->dimensions[1]); arg4 = (gsl_matrix *) &(_matrix4.matrix); } result = gsl_multifit_linear((gsl_matrix const *)arg1,(gsl_vector const *)arg2,arg3,arg4,arg5,arg6); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } { resultobj = SWIG_Python_AppendOutput(resultobj, (PyObject *) _PyVector3); _PyVector3 =NULL; } { resultobj = SWIG_Python_AppendOutput(resultobj, (PyObject *) _PyMatrix4); _PyMatrix4 =NULL; } if (SWIG_IsTmpObj(res5)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg5))); } else { int new_flags = SWIG_IsNewObj(res5) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg5), SWIGTYPE_p_double, new_flags)); } { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix4); _PyMatrix4 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix4); _PyMatrix4 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_linear_svd(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_matrix *arg1 = (gsl_matrix *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; double arg3 ; size_t *arg4 = (size_t *) 0 ; gsl_vector *arg5 = (gsl_vector *) 0 ; gsl_matrix *arg6 = (gsl_matrix *) 0 ; double *arg7 = (double *) 0 ; gsl_multifit_linear_workspace *arg8 = (gsl_multifit_linear_workspace *) 0 ; double val3 ; int ecode3 = 0 ; size_t temp4 ; int res4 = SWIG_TMPOBJ ; double temp7 ; int res7 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "IN",(char *) "TOL",(char *) "work_provide", NULL }; gsl_error_flag_drop result; PyArrayObject * _PyMatrix1 = NULL; TYPE_VIEW_gsl_matrix _matrix1; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; PyArrayObject * volatile _PyVector5 = NULL; TYPE_VIEW_gsl_vector _vector5; PyArrayObject * _PyMatrix6 = NULL; TYPE_VIEW_gsl_matrix _matrix6; PyGSL_array_index_t _work_provide_n_work_provide = -1; PyGSL_array_index_t _work_provide_p_work_provide = -1; arg4 = &temp4; /* All done in check as the workspace stores the information about the required size */ /* All done in check as the workspace stores the information about the required size */ arg7 = &temp7; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_multifit_linear_svd",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; { PyGSL_array_index_t stride; if(PyGSL_MATRIX_CONVERT(obj0, arg1, _PyMatrix1, _matrix1, PyGSL_INPUT_ARRAY, gsl_matrix, 1, &stride) != GSL_SUCCESS) goto fail; } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_multifit_linear_svd" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); { if ((SWIG_ConvertPtr(obj3, (void **) &arg8, SWIGTYPE_p_gsl_multifit_linear_workspace,1)) == -1){ goto fail; } _work_provide_n_work_provide = (int) arg8->n; _work_provide_p_work_provide = (int) arg8->p; } { PyGSL_array_index_t stride; _PyVector5 = (PyArrayObject *) PyGSL_New_Array(1, &_work_provide_p_work_provide, PyArray_DOUBLE); if(NULL == _PyVector5){ goto fail; } if(PyGSL_STRIDE_RECALC(_PyVector5->strides[0], sizeof(BASIS_TYPE(gsl_vector)), &stride) != GSL_SUCCESS) goto fail; _vector5 = TYPE_VIEW_ARRAY_STRIDES_gsl_vector((BASIS_C_TYPE(gsl_vector) *) _PyVector5->data, stride, _PyVector5->dimensions[0]); arg5 = (gsl_vector *) &(_vector5.vector); } { PyArrayObject * a_array; PyGSL_array_index_t stride_recalc=0, dimensions[2]; dimensions[0] = _work_provide_p_work_provide; dimensions[1] = _work_provide_p_work_provide; a_array = (PyArrayObject *) PyGSL_New_Array(2, dimensions, PyArray_DOUBLE); if(NULL == a_array){ goto fail; } _PyMatrix6 = a_array; if(PyGSL_STRIDE_RECALC(a_array->strides[0], sizeof(BASIS_TYPE(gsl_matrix)), &stride_recalc) != GSL_SUCCESS) goto fail; /* (BASIS_TYPE_gsl_matrix *) */ _matrix6 = TYPE_VIEW_ARRAY_gsl_matrix((BASIS_C_TYPE(gsl_matrix) *) a_array->data, a_array->dimensions[0], a_array->dimensions[1]); arg6 = (gsl_matrix *) &(_matrix6.matrix); } result = gsl_multifit_linear_svd((gsl_matrix const *)arg1,(gsl_vector const *)arg2,arg3,arg4,arg5,arg6,arg7,arg8); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_size_t((*arg4))); } else { int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_unsigned_int, new_flags)); } { resultobj = SWIG_Python_AppendOutput(resultobj, (PyObject *) _PyVector5); _PyVector5 =NULL; } { resultobj = SWIG_Python_AppendOutput(resultobj, (PyObject *) _PyMatrix6); _PyMatrix6 =NULL; } if (SWIG_IsTmpObj(res7)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg7))); } else { int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags)); } { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector5); _PyVector5 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix6); _PyMatrix6 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector5); _PyVector5 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix6); _PyMatrix6 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_wlinear(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_matrix *arg1 = (gsl_matrix *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; gsl_vector *arg4 = (gsl_vector *) 0 ; gsl_matrix *arg5 = (gsl_matrix *) 0 ; double *arg6 = (double *) 0 ; gsl_multifit_linear_workspace *arg7 = (gsl_multifit_linear_workspace *) 0 ; double temp6 ; int res6 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "IN",(char *) "IN",(char *) "work_provide", NULL }; gsl_error_flag_drop result; PyArrayObject * _PyMatrix1 = NULL; TYPE_VIEW_gsl_matrix _matrix1; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; PyArrayObject * volatile _PyVector4 = NULL; TYPE_VIEW_gsl_vector _vector4; PyArrayObject * _PyMatrix5 = NULL; TYPE_VIEW_gsl_matrix _matrix5; PyGSL_array_index_t _work_provide_n_work_provide = -1; PyGSL_array_index_t _work_provide_p_work_provide = -1; /* All done in check as the workspace stores the information about the required size */ /* All done in check as the workspace stores the information about the required size */ arg6 = &temp6; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:gsl_multifit_wlinear",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; { PyGSL_array_index_t stride; if(PyGSL_MATRIX_CONVERT(obj0, arg1, _PyMatrix1, _matrix1, PyGSL_INPUT_ARRAY, gsl_matrix, 1, &stride) != GSL_SUCCESS) goto fail; } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj2, arg3, _PyVector3, _vector3, PyGSL_INPUT_ARRAY, gsl_vector, 3, &stride) != GSL_SUCCESS){ goto fail; } } { if ((SWIG_ConvertPtr(obj3, (void **) &arg7, SWIGTYPE_p_gsl_multifit_linear_workspace,1)) == -1){ goto fail; } _work_provide_n_work_provide = (int) arg7->n; _work_provide_p_work_provide = (int) arg7->p; } { PyGSL_array_index_t stride; _PyVector4 = (PyArrayObject *) PyGSL_New_Array(1, &_work_provide_p_work_provide, PyArray_DOUBLE); if(NULL == _PyVector4){ goto fail; } if(PyGSL_STRIDE_RECALC(_PyVector4->strides[0], sizeof(BASIS_TYPE(gsl_vector)), &stride) != GSL_SUCCESS) goto fail; _vector4 = TYPE_VIEW_ARRAY_STRIDES_gsl_vector((BASIS_C_TYPE(gsl_vector) *) _PyVector4->data, stride, _PyVector4->dimensions[0]); arg4 = (gsl_vector *) &(_vector4.vector); } { PyArrayObject * a_array; PyGSL_array_index_t stride_recalc=0, dimensions[2]; dimensions[0] = _work_provide_p_work_provide; dimensions[1] = _work_provide_p_work_provide; a_array = (PyArrayObject *) PyGSL_New_Array(2, dimensions, PyArray_DOUBLE); if(NULL == a_array){ goto fail; } _PyMatrix5 = a_array; if(PyGSL_STRIDE_RECALC(a_array->strides[0], sizeof(BASIS_TYPE(gsl_matrix)), &stride_recalc) != GSL_SUCCESS) goto fail; /* (BASIS_TYPE_gsl_matrix *) */ _matrix5 = TYPE_VIEW_ARRAY_gsl_matrix((BASIS_C_TYPE(gsl_matrix) *) a_array->data, a_array->dimensions[0], a_array->dimensions[1]); arg5 = (gsl_matrix *) &(_matrix5.matrix); } result = gsl_multifit_wlinear((gsl_matrix const *)arg1,(gsl_vector const *)arg2,(gsl_vector const *)arg3,arg4,arg5,arg6,arg7); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } { resultobj = SWIG_Python_AppendOutput(resultobj, (PyObject *) _PyVector4); _PyVector4 =NULL; } { resultobj = SWIG_Python_AppendOutput(resultobj, (PyObject *) _PyMatrix5); _PyMatrix5 =NULL; } if (SWIG_IsTmpObj(res6)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg6))); } else { int new_flags = SWIG_IsNewObj(res6) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg6), SWIGTYPE_p_double, new_flags)); } { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector4); _PyVector4 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix5); _PyMatrix5 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector4); _PyVector4 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix5); _PyMatrix5 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_wlinear_svd(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_matrix *arg1 = (gsl_matrix *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; gsl_vector *arg3 = (gsl_vector *) 0 ; double arg4 ; size_t *arg5 = (size_t *) 0 ; gsl_vector *arg6 = (gsl_vector *) 0 ; gsl_matrix *arg7 = (gsl_matrix *) 0 ; double *arg8 = (double *) 0 ; gsl_multifit_linear_workspace *arg9 = (gsl_multifit_linear_workspace *) 0 ; double val4 ; int ecode4 = 0 ; size_t temp5 ; int res5 = SWIG_TMPOBJ ; double temp8 ; int res8 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "IN",(char *) "IN",(char *) "TOL",(char *) "work_provide", NULL }; gsl_error_flag_drop result; PyArrayObject * _PyMatrix1 = NULL; TYPE_VIEW_gsl_matrix _matrix1; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; PyArrayObject * volatile _PyVector3 = NULL; TYPE_VIEW_gsl_vector _vector3; PyArrayObject * volatile _PyVector6 = NULL; TYPE_VIEW_gsl_vector _vector6; PyArrayObject * _PyMatrix7 = NULL; TYPE_VIEW_gsl_matrix _matrix7; PyGSL_array_index_t _work_provide_n_work_provide = -1; PyGSL_array_index_t _work_provide_p_work_provide = -1; arg5 = &temp5; /* All done in check as the workspace stores the information about the required size */ /* All done in check as the workspace stores the information about the required size */ arg8 = &temp8; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:gsl_multifit_wlinear_svd",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; { PyGSL_array_index_t stride; if(PyGSL_MATRIX_CONVERT(obj0, arg1, _PyMatrix1, _matrix1, PyGSL_INPUT_ARRAY, gsl_matrix, 1, &stride) != GSL_SUCCESS) goto fail; } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj2, arg3, _PyVector3, _vector3, PyGSL_INPUT_ARRAY, gsl_vector, 3, &stride) != GSL_SUCCESS){ goto fail; } } ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_multifit_wlinear_svd" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); { if ((SWIG_ConvertPtr(obj4, (void **) &arg9, SWIGTYPE_p_gsl_multifit_linear_workspace,1)) == -1){ goto fail; } _work_provide_n_work_provide = (int) arg9->n; _work_provide_p_work_provide = (int) arg9->p; } { PyGSL_array_index_t stride; _PyVector6 = (PyArrayObject *) PyGSL_New_Array(1, &_work_provide_p_work_provide, PyArray_DOUBLE); if(NULL == _PyVector6){ goto fail; } if(PyGSL_STRIDE_RECALC(_PyVector6->strides[0], sizeof(BASIS_TYPE(gsl_vector)), &stride) != GSL_SUCCESS) goto fail; _vector6 = TYPE_VIEW_ARRAY_STRIDES_gsl_vector((BASIS_C_TYPE(gsl_vector) *) _PyVector6->data, stride, _PyVector6->dimensions[0]); arg6 = (gsl_vector *) &(_vector6.vector); } { PyArrayObject * a_array; PyGSL_array_index_t stride_recalc=0, dimensions[2]; dimensions[0] = _work_provide_p_work_provide; dimensions[1] = _work_provide_p_work_provide; a_array = (PyArrayObject *) PyGSL_New_Array(2, dimensions, PyArray_DOUBLE); if(NULL == a_array){ goto fail; } _PyMatrix7 = a_array; if(PyGSL_STRIDE_RECALC(a_array->strides[0], sizeof(BASIS_TYPE(gsl_matrix)), &stride_recalc) != GSL_SUCCESS) goto fail; /* (BASIS_TYPE_gsl_matrix *) */ _matrix7 = TYPE_VIEW_ARRAY_gsl_matrix((BASIS_C_TYPE(gsl_matrix) *) a_array->data, a_array->dimensions[0], a_array->dimensions[1]); arg7 = (gsl_matrix *) &(_matrix7.matrix); } result = gsl_multifit_wlinear_svd((gsl_matrix const *)arg1,(gsl_vector const *)arg2,(gsl_vector const *)arg3,arg4,arg5,arg6,arg7,arg8,arg9); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } if (SWIG_IsTmpObj(res5)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_size_t((*arg5))); } else { int new_flags = SWIG_IsNewObj(res5) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg5), SWIGTYPE_p_unsigned_int, new_flags)); } { resultobj = SWIG_Python_AppendOutput(resultobj, (PyObject *) _PyVector6); _PyVector6 =NULL; } { resultobj = SWIG_Python_AppendOutput(resultobj, (PyObject *) _PyMatrix7); _PyMatrix7 =NULL; } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector6); _PyVector6 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix7); _PyMatrix7 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector3); _PyVector3 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector6); _PyVector6 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix7); _PyMatrix7 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_linear_est(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_vector *arg1 = (gsl_vector *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; gsl_matrix *arg3 = (gsl_matrix *) 0 ; double *arg4 = (double *) 0 ; double *arg5 = (double *) 0 ; double temp4 ; int res4 = SWIG_TMPOBJ ; double temp5 ; int res5 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "IN",(char *) "IN", NULL }; gsl_error_flag_drop result; PyArrayObject * volatile _PyVector1 = NULL; TYPE_VIEW_gsl_vector _vector1; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; PyArrayObject * _PyMatrix3 = NULL; TYPE_VIEW_gsl_matrix _matrix3; arg4 = &temp4; arg5 = &temp5; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multifit_linear_est",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj0, arg1, _PyVector1, _vector1, PyGSL_INPUT_ARRAY, gsl_vector, 1, &stride) != GSL_SUCCESS){ goto fail; } } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } { PyGSL_array_index_t stride; if(PyGSL_MATRIX_CONVERT(obj2, arg3, _PyMatrix3, _matrix3, PyGSL_INPUT_ARRAY, gsl_matrix, 3, &stride) != GSL_SUCCESS) goto fail; } result = gsl_multifit_linear_est((gsl_vector const *)arg1,(gsl_vector const *)arg2,(gsl_matrix const *)arg3,arg4,arg5); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg4))); } else { int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res5)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg5))); } else { int new_flags = SWIG_IsNewObj(res5) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg5), SWIGTYPE_p_double, new_flags)); } { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix3); _PyMatrix3 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyVector1); _PyVector1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix3); _PyMatrix3 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_multifit_linear_est_matrix(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; gsl_matrix *arg1 = (gsl_matrix *) 0 ; gsl_vector *arg2 = (gsl_vector *) 0 ; gsl_matrix *arg3 = (gsl_matrix *) 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "IN",(char *) "IN",(char *) "IN", NULL }; PyObject *result = 0 ; PyArrayObject * _PyMatrix1 = NULL; TYPE_VIEW_gsl_matrix _matrix1; PyArrayObject * volatile _PyVector2 = NULL; TYPE_VIEW_gsl_vector _vector2; PyArrayObject * _PyMatrix3 = NULL; TYPE_VIEW_gsl_matrix _matrix3; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_multifit_linear_est_matrix",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; { PyGSL_array_index_t stride; if(PyGSL_MATRIX_CONVERT(obj0, arg1, _PyMatrix1, _matrix1, PyGSL_INPUT_ARRAY, gsl_matrix, 1, &stride) != GSL_SUCCESS) goto fail; } { PyGSL_array_index_t stride=0; if(PyGSL_VECTOR_CONVERT(obj1, arg2, _PyVector2, _vector2, PyGSL_INPUT_ARRAY, gsl_vector, 2, &stride) != GSL_SUCCESS){ goto fail; } } { PyGSL_array_index_t stride; if(PyGSL_MATRIX_CONVERT(obj2, arg3, _PyMatrix3, _matrix3, PyGSL_INPUT_ARRAY, gsl_matrix, 3, &stride) != GSL_SUCCESS) goto fail; } result = (PyObject *)gsl_multifit_linear_est_matrix((gsl_matrix const *)arg1,(gsl_vector const *)arg2,(gsl_matrix const *)arg3); resultobj = result; { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix3); _PyMatrix3 = NULL; FUNC_MESS_END(); } return resultobj; fail: { Py_XDECREF(_PyMatrix1); _PyMatrix1 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyVector2); _PyVector2 = NULL; FUNC_MESS_END(); } { Py_XDECREF(_PyMatrix3); _PyMatrix3 = NULL; FUNC_MESS_END(); } return NULL; } SWIGINTERN PyObject *_wrap_gsl_fit_linear(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double *arg1 = (double *) 0 ; size_t arg2 ; double *arg3 = (double *) 0 ; size_t arg4 ; size_t arg5 ; double *arg6 = (double *) 0 ; double *arg7 = (double *) 0 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; double *arg10 = (double *) 0 ; double *arg11 = (double *) 0 ; double temp6 ; int res6 = SWIG_TMPOBJ ; double temp7 ; int res7 = SWIG_TMPOBJ ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; double temp10 ; int res10 = SWIG_TMPOBJ ; double temp11 ; int res11 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "x",(char *) "y", NULL }; gsl_error_flag_drop result; PyArrayObject *_PyVector1 = NULL; size_t _PyVectorLengthx = 0; PyArrayObject *_PyVector3 = NULL; size_t _PyVectorLengthy = 0; { arg5 = 0; } arg6 = &temp6; arg7 = &temp7; arg8 = &temp8; arg9 = &temp9; arg10 = &temp10; arg11 = &temp11; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_fit_linear",kwnames,&obj0,&obj1)) SWIG_fail; { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'x' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector1 = PyGSL_vector_check(obj0, size, PyGSL_DARRAY_INPUT(1), &strides, NULL); if (_PyVector1 == NULL) goto fail; arg1 = (double *) (_PyVector1->data); arg2 = (size_t) strides; _PyVectorLengthx = (size_t) _PyVector1->dimensions[0]; } { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'y' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector3 = PyGSL_vector_check(obj1, size, PyGSL_DARRAY_INPUT(3), &strides, NULL); if (_PyVector3 == NULL) goto fail; arg3 = (double *) (_PyVector3->data); arg4 = (size_t) strides; _PyVectorLengthy = (size_t) _PyVector3->dimensions[0]; } { arg5 = _PyVectorLengthx; } result = gsl_fit_linear((double const *)arg1,arg2,(double const *)arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } { Py_XDECREF(_PyVector1); } { Py_XDECREF(_PyVector3); } if (SWIG_IsTmpObj(res6)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg6))); } else { int new_flags = SWIG_IsNewObj(res6) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg6), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res7)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg7))); } else { int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res10)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg10))); } else { int new_flags = SWIG_IsNewObj(res10) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg10), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res11)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg11))); } else { int new_flags = SWIG_IsNewObj(res11) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg11), SWIGTYPE_p_double, new_flags)); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_fit_wlinear(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double *arg1 = (double *) 0 ; size_t arg2 ; double *arg3 = (double *) 0 ; size_t arg4 ; double *arg5 = (double *) 0 ; size_t arg6 ; size_t arg7 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; double *arg10 = (double *) 0 ; double *arg11 = (double *) 0 ; double *arg12 = (double *) 0 ; double *arg13 = (double *) 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; double temp10 ; int res10 = SWIG_TMPOBJ ; double temp11 ; int res11 = SWIG_TMPOBJ ; double temp12 ; int res12 = SWIG_TMPOBJ ; double temp13 ; int res13 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "x",(char *) "w",(char *) "y", NULL }; gsl_error_flag_drop result; PyArrayObject *_PyVector1 = NULL; size_t _PyVectorLengthx = 0; PyArrayObject *_PyVector3 = NULL; size_t _PyVectorLengthw = 0; PyArrayObject *_PyVector5 = NULL; size_t _PyVectorLengthy = 0; { arg7 = 0; } arg8 = &temp8; arg9 = &temp9; arg10 = &temp10; arg11 = &temp11; arg12 = &temp12; arg13 = &temp13; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_fit_wlinear",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'x' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector1 = PyGSL_vector_check(obj0, size, PyGSL_DARRAY_INPUT(1), &strides, NULL); if (_PyVector1 == NULL) goto fail; arg1 = (double *) (_PyVector1->data); arg2 = (size_t) strides; _PyVectorLengthx = (size_t) _PyVector1->dimensions[0]; } { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'w' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector3 = PyGSL_vector_check(obj1, size, PyGSL_DARRAY_INPUT(3), &strides, NULL); if (_PyVector3 == NULL) goto fail; arg3 = (double *) (_PyVector3->data); arg4 = (size_t) strides; _PyVectorLengthw = (size_t) _PyVector3->dimensions[0]; } { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'y' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector5 = PyGSL_vector_check(obj2, size, PyGSL_DARRAY_INPUT(5), &strides, NULL); if (_PyVector5 == NULL) goto fail; arg5 = (double *) (_PyVector5->data); arg6 = (size_t) strides; _PyVectorLengthy = (size_t) _PyVector5->dimensions[0]; } { arg7 = _PyVectorLengthx; } result = gsl_fit_wlinear((double const *)arg1,arg2,(double const *)arg3,arg4,(double const *)arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } { Py_XDECREF(_PyVector1); } { Py_XDECREF(_PyVector3); } { Py_XDECREF(_PyVector5); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res10)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg10))); } else { int new_flags = SWIG_IsNewObj(res10) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg10), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res11)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg11))); } else { int new_flags = SWIG_IsNewObj(res11) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg11), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res12)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg12))); } else { int new_flags = SWIG_IsNewObj(res12) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg12), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res13)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg13))); } else { int new_flags = SWIG_IsNewObj(res13) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg13), SWIGTYPE_p_double, new_flags)); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_fit_linear_est(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double arg3 ; double arg4 ; double arg5 ; double arg6 ; double *arg7 = (double *) 0 ; double *arg8 = (double *) 0 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double val4 ; int ecode4 = 0 ; double val5 ; int ecode5 = 0 ; double val6 ; int ecode6 = 0 ; double temp7 ; int res7 = SWIG_TMPOBJ ; double temp8 ; int res8 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; PyObject * obj5 = 0 ; char * kwnames[] = { (char *) "x",(char *) "c0",(char *) "c1",(char *) "c00",(char *) "c01",(char *) "c11", NULL }; gsl_error_flag_drop result; arg7 = &temp7; arg8 = &temp8; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOO:gsl_fit_linear_est",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_fit_linear_est" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_fit_linear_est" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_fit_linear_est" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); ecode4 = SWIG_AsVal_double(obj3, &val4); if (!SWIG_IsOK(ecode4)) { SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "gsl_fit_linear_est" "', argument " "4"" of type '" "double""'"); } arg4 = (double)(val4); ecode5 = SWIG_AsVal_double(obj4, &val5); if (!SWIG_IsOK(ecode5)) { SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "gsl_fit_linear_est" "', argument " "5"" of type '" "double""'"); } arg5 = (double)(val5); ecode6 = SWIG_AsVal_double(obj5, &val6); if (!SWIG_IsOK(ecode6)) { SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "gsl_fit_linear_est" "', argument " "6"" of type '" "double""'"); } arg6 = (double)(val6); result = gsl_fit_linear_est(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } if (SWIG_IsTmpObj(res7)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg7))); } else { int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_fit_mul(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double *arg1 = (double *) 0 ; size_t arg2 ; double *arg3 = (double *) 0 ; size_t arg4 ; size_t arg5 ; double *arg6 = (double *) 0 ; double *arg7 = (double *) 0 ; double *arg8 = (double *) 0 ; double temp6 ; int res6 = SWIG_TMPOBJ ; double temp7 ; int res7 = SWIG_TMPOBJ ; double temp8 ; int res8 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; char * kwnames[] = { (char *) "x",(char *) "y", NULL }; gsl_error_flag_drop result; PyArrayObject *_PyVector1 = NULL; size_t _PyVectorLengthx = 0; PyArrayObject *_PyVector3 = NULL; size_t _PyVectorLengthy = 0; { arg5 = 0; } arg6 = &temp6; arg7 = &temp7; arg8 = &temp8; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:gsl_fit_mul",kwnames,&obj0,&obj1)) SWIG_fail; { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'x' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector1 = PyGSL_vector_check(obj0, size, PyGSL_DARRAY_INPUT(1), &strides, NULL); if (_PyVector1 == NULL) goto fail; arg1 = (double *) (_PyVector1->data); arg2 = (size_t) strides; _PyVectorLengthx = (size_t) _PyVector1->dimensions[0]; } { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'y' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector3 = PyGSL_vector_check(obj1, size, PyGSL_DARRAY_INPUT(3), &strides, NULL); if (_PyVector3 == NULL) goto fail; arg3 = (double *) (_PyVector3->data); arg4 = (size_t) strides; _PyVectorLengthy = (size_t) _PyVector3->dimensions[0]; } { arg5 = _PyVectorLengthx; } result = gsl_fit_mul((double const *)arg1,arg2,(double const *)arg3,arg4,arg5,arg6,arg7,arg8); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } { Py_XDECREF(_PyVector1); } { Py_XDECREF(_PyVector3); } if (SWIG_IsTmpObj(res6)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg6))); } else { int new_flags = SWIG_IsNewObj(res6) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg6), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res7)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg7))); } else { int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_fit_wmul(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double *arg1 = (double *) 0 ; size_t arg2 ; double *arg3 = (double *) 0 ; size_t arg4 ; double *arg5 = (double *) 0 ; size_t arg6 ; size_t arg7 ; double *arg8 = (double *) 0 ; double *arg9 = (double *) 0 ; double *arg10 = (double *) 0 ; double temp8 ; int res8 = SWIG_TMPOBJ ; double temp9 ; int res9 = SWIG_TMPOBJ ; double temp10 ; int res10 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "x",(char *) "w",(char *) "y", NULL }; gsl_error_flag_drop result; PyArrayObject *_PyVector1 = NULL; size_t _PyVectorLengthx = 0; PyArrayObject *_PyVector3 = NULL; size_t _PyVectorLengthw = 0; PyArrayObject *_PyVector5 = NULL; size_t _PyVectorLengthy = 0; { arg7 = 0; } arg8 = &temp8; arg9 = &temp9; arg10 = &temp10; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_fit_wmul",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'x' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector1 = PyGSL_vector_check(obj0, size, PyGSL_DARRAY_INPUT(1), &strides, NULL); if (_PyVector1 == NULL) goto fail; arg1 = (double *) (_PyVector1->data); arg2 = (size_t) strides; _PyVectorLengthx = (size_t) _PyVector1->dimensions[0]; } { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'w' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector3 = PyGSL_vector_check(obj1, size, PyGSL_DARRAY_INPUT(3), &strides, NULL); if (_PyVector3 == NULL) goto fail; arg3 = (double *) (_PyVector3->data); arg4 = (size_t) strides; _PyVectorLengthw = (size_t) _PyVector3->dimensions[0]; } { PyGSL_array_index_t strides, size; /* This should be a preprocessor directive. */ if ( 'y' == 'x' ) size = -1; else size = _PyVectorLengthx; _PyVector5 = PyGSL_vector_check(obj2, size, PyGSL_DARRAY_INPUT(5), &strides, NULL); if (_PyVector5 == NULL) goto fail; arg5 = (double *) (_PyVector5->data); arg6 = (size_t) strides; _PyVectorLengthy = (size_t) _PyVector5->dimensions[0]; } { arg7 = _PyVectorLengthx; } result = gsl_fit_wmul((double const *)arg1,arg2,(double const *)arg3,arg4,(double const *)arg5,arg6,arg7,arg8,arg9,arg10); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } { Py_XDECREF(_PyVector1); } { Py_XDECREF(_PyVector3); } { Py_XDECREF(_PyVector5); } if (SWIG_IsTmpObj(res8)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg8))); } else { int new_flags = SWIG_IsNewObj(res8) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg8), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res9)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg9))); } else { int new_flags = SWIG_IsNewObj(res9) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg9), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res10)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg10))); } else { int new_flags = SWIG_IsNewObj(res10) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg10), SWIGTYPE_p_double, new_flags)); } return resultobj; fail: return NULL; } SWIGINTERN PyObject *_wrap_gsl_fit_mul_est(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; double arg1 ; double arg2 ; double arg3 ; double *arg4 = (double *) 0 ; double *arg5 = (double *) 0 ; double val1 ; int ecode1 = 0 ; double val2 ; int ecode2 = 0 ; double val3 ; int ecode3 = 0 ; double temp4 ; int res4 = SWIG_TMPOBJ ; double temp5 ; int res5 = SWIG_TMPOBJ ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; char * kwnames[] = { (char *) "x",(char *) "c1",(char *) "c11", NULL }; gsl_error_flag_drop result; arg4 = &temp4; arg5 = &temp5; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:gsl_fit_mul_est",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; ecode1 = SWIG_AsVal_double(obj0, &val1); if (!SWIG_IsOK(ecode1)) { SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "gsl_fit_mul_est" "', argument " "1"" of type '" "double""'"); } arg1 = (double)(val1); ecode2 = SWIG_AsVal_double(obj1, &val2); if (!SWIG_IsOK(ecode2)) { SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "gsl_fit_mul_est" "', argument " "2"" of type '" "double""'"); } arg2 = (double)(val2); ecode3 = SWIG_AsVal_double(obj2, &val3); if (!SWIG_IsOK(ecode3)) { SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "gsl_fit_mul_est" "', argument " "3"" of type '" "double""'"); } arg3 = (double)(val3); result = gsl_fit_mul_est(arg1,arg2,arg3,arg4,arg5); { /* assert(result >= 0); assertion removed as PyGSL_error_flag can deal with negative numbers. */ if(GSL_FAILURE == PyGSL_ERROR_FLAG(result)){ PyGSL_add_traceback(pygsl_module_for_error_treatment, "typemaps/gsl_error_typemap.i", __FUNCTION__, 74); goto fail; } Py_INCREF(Py_None); resultobj = Py_None; } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg4))); } else { int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_double, new_flags)); } if (SWIG_IsTmpObj(res5)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_double((*arg5))); } else { int new_flags = SWIG_IsNewObj(res5) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg5), SWIGTYPE_p_double, new_flags)); } return resultobj; fail: return NULL; } static PyMethodDef SwigMethods[] = { { (char *)"gsl_function_init", (PyCFunction) _wrap_gsl_function_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_function_init_fdf", (PyCFunction) _wrap_gsl_function_init_fdf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_function_free", (PyCFunction) _wrap_gsl_function_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_function_free_fdf", (PyCFunction) _wrap_gsl_function_free_fdf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_function_init", (PyCFunction) _wrap_gsl_monte_function_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_function_free", (PyCFunction) _wrap_gsl_monte_function_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_plain_integrate", (PyCFunction) _wrap_gsl_monte_plain_integrate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_plain_alloc", (PyCFunction) _wrap_gsl_monte_plain_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_plain_init", (PyCFunction) _wrap_gsl_monte_plain_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_plain_free", (PyCFunction) _wrap_gsl_monte_plain_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_get_min_calls", (PyCFunction) _wrap_pygsl_monte_miser_get_min_calls, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_get_min_calls_per_bisection", (PyCFunction) _wrap_pygsl_monte_miser_get_min_calls_per_bisection, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_get_dither", (PyCFunction) _wrap_pygsl_monte_miser_get_dither, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_get_estimate_frac", (PyCFunction) _wrap_pygsl_monte_miser_get_estimate_frac, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_get_alpha", (PyCFunction) _wrap_pygsl_monte_miser_get_alpha, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_set_min_calls", (PyCFunction) _wrap_pygsl_monte_miser_set_min_calls, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_set_min_calls_per_bisection", (PyCFunction) _wrap_pygsl_monte_miser_set_min_calls_per_bisection, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_set_dither", (PyCFunction) _wrap_pygsl_monte_miser_set_dither, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_set_estimate_frac", (PyCFunction) _wrap_pygsl_monte_miser_set_estimate_frac, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_miser_set_alpha", (PyCFunction) _wrap_pygsl_monte_miser_set_alpha, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_miser_integrate", (PyCFunction) _wrap_gsl_monte_miser_integrate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_miser_alloc", (PyCFunction) _wrap_gsl_monte_miser_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_miser_init", (PyCFunction) _wrap_gsl_monte_miser_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_miser_free", (PyCFunction) _wrap_gsl_monte_miser_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_result", (PyCFunction) _wrap_pygsl_monte_vegas_get_result, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_sigma", (PyCFunction) _wrap_pygsl_monte_vegas_get_sigma, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_chisq", (PyCFunction) _wrap_pygsl_monte_vegas_get_chisq, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_alpha", (PyCFunction) _wrap_pygsl_monte_vegas_get_alpha, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_iterations", (PyCFunction) _wrap_pygsl_monte_vegas_get_iterations, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_stage", (PyCFunction) _wrap_pygsl_monte_vegas_get_stage, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_mode", (PyCFunction) _wrap_pygsl_monte_vegas_get_mode, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_verbose", (PyCFunction) _wrap_pygsl_monte_vegas_get_verbose, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_get_ostream", (PyCFunction) _wrap_pygsl_monte_vegas_get_ostream, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_result", (PyCFunction) _wrap_pygsl_monte_vegas_set_result, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_sigma", (PyCFunction) _wrap_pygsl_monte_vegas_set_sigma, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_chisq", (PyCFunction) _wrap_pygsl_monte_vegas_set_chisq, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_alpha", (PyCFunction) _wrap_pygsl_monte_vegas_set_alpha, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_iterations", (PyCFunction) _wrap_pygsl_monte_vegas_set_iterations, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_stage", (PyCFunction) _wrap_pygsl_monte_vegas_set_stage, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_mode", (PyCFunction) _wrap_pygsl_monte_vegas_set_mode, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_verbose", (PyCFunction) _wrap_pygsl_monte_vegas_set_verbose, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_monte_vegas_set_ostream", (PyCFunction) _wrap_pygsl_monte_vegas_set_ostream, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_vegas_integrate", (PyCFunction) _wrap_gsl_monte_vegas_integrate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_vegas_alloc", (PyCFunction) _wrap_gsl_monte_vegas_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_vegas_init", (PyCFunction) _wrap_gsl_monte_vegas_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_monte_vegas_free", (PyCFunction) _wrap_gsl_monte_vegas_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fsolver_alloc", (PyCFunction) _wrap_gsl_root_fsolver_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fsolver_free", (PyCFunction) _wrap_gsl_root_fsolver_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fdfsolver_alloc", (PyCFunction) _wrap_gsl_root_fdfsolver_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fdfsolver_free", (PyCFunction) _wrap_gsl_root_fdfsolver_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fsolver_set", (PyCFunction) _wrap_gsl_root_fsolver_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fdfsolver_set", (PyCFunction) _wrap_gsl_root_fdfsolver_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fsolver_name", (PyCFunction) _wrap_gsl_root_fsolver_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fdfsolver_name", (PyCFunction) _wrap_gsl_root_fdfsolver_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fsolver_iterate", (PyCFunction) _wrap_gsl_root_fsolver_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fdfsolver_iterate", (PyCFunction) _wrap_gsl_root_fdfsolver_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fsolver_root", (PyCFunction) _wrap_gsl_root_fsolver_root, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fdfsolver_root", (PyCFunction) _wrap_gsl_root_fdfsolver_root, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fsolver_x_lower", (PyCFunction) _wrap_gsl_root_fsolver_x_lower, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_fsolver_x_upper", (PyCFunction) _wrap_gsl_root_fsolver_x_upper, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_test_interval", (PyCFunction) _wrap_gsl_root_test_interval, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_test_delta", (PyCFunction) _wrap_gsl_root_test_delta, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_root_test_residual", (PyCFunction) _wrap_gsl_root_test_residual, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_alloc", (PyCFunction) _wrap_gsl_min_fminimizer_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_set", (PyCFunction) _wrap_gsl_min_fminimizer_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_set_with_values", (PyCFunction) _wrap_gsl_min_fminimizer_set_with_values, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_free", (PyCFunction) _wrap_gsl_min_fminimizer_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_name", (PyCFunction) _wrap_gsl_min_fminimizer_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_iterate", (PyCFunction) _wrap_gsl_min_fminimizer_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_minimum", (PyCFunction) _wrap_gsl_min_fminimizer_minimum, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_x_upper", (PyCFunction) _wrap_gsl_min_fminimizer_x_upper, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_fminimizer_x_lower", (PyCFunction) _wrap_gsl_min_fminimizer_x_lower, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_min_test_interval", (PyCFunction) _wrap_gsl_min_test_interval, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_function_init", (PyCFunction) _wrap_gsl_multiroot_function_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_function_init_fdf", (PyCFunction) _wrap_gsl_multiroot_function_init_fdf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_function_getf", (PyCFunction) _wrap_gsl_multiroot_function_getf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_function_fdf_getf", (PyCFunction) _wrap_gsl_multiroot_function_fdf_getf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_function_getx", (PyCFunction) _wrap_gsl_multiroot_function_getx, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_function_fdf_getx", (PyCFunction) _wrap_gsl_multiroot_function_fdf_getx, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_function_free", (PyCFunction) _wrap_gsl_multiroot_function_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_function_free_fdf", (PyCFunction) _wrap_gsl_multiroot_function_free_fdf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fsolver_alloc", (PyCFunction) _wrap_gsl_multiroot_fsolver_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fsolver_free", (PyCFunction) _wrap_gsl_multiroot_fsolver_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fsolver_set", (PyCFunction) _wrap_gsl_multiroot_fsolver_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fsolver_iterate", (PyCFunction) _wrap_gsl_multiroot_fsolver_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fsolver_name", (PyCFunction) _wrap_gsl_multiroot_fsolver_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fsolver_root", (PyCFunction) _wrap_gsl_multiroot_fsolver_root, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fdfsolver_alloc", (PyCFunction) _wrap_gsl_multiroot_fdfsolver_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fdfsolver_set", (PyCFunction) _wrap_gsl_multiroot_fdfsolver_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fdfsolver_iterate", (PyCFunction) _wrap_gsl_multiroot_fdfsolver_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fdfsolver_free", (PyCFunction) _wrap_gsl_multiroot_fdfsolver_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fdfsolver_name", (PyCFunction) _wrap_gsl_multiroot_fdfsolver_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_fdfsolver_root", (PyCFunction) _wrap_gsl_multiroot_fdfsolver_root, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_test_delta", (PyCFunction) _wrap_gsl_multiroot_test_delta, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multiroot_test_residual", (PyCFunction) _wrap_gsl_multiroot_test_residual, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_function_init", (PyCFunction) _wrap_gsl_multimin_function_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_function_init_fdf", (PyCFunction) _wrap_gsl_multimin_function_init_fdf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_function_free", (PyCFunction) _wrap_gsl_multimin_function_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_function_free_fdf", (PyCFunction) _wrap_gsl_multimin_function_free_fdf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_f", (PyCFunction) _wrap_gsl_multimin_fminimizer_f, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_alloc", (PyCFunction) _wrap_gsl_multimin_fminimizer_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_set", (PyCFunction) _wrap_gsl_multimin_fminimizer_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_free", (PyCFunction) _wrap_gsl_multimin_fminimizer_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_name", (PyCFunction) _wrap_gsl_multimin_fminimizer_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_iterate", (PyCFunction) _wrap_gsl_multimin_fminimizer_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_x", (PyCFunction) _wrap_gsl_multimin_fminimizer_x, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_minimum", (PyCFunction) _wrap_gsl_multimin_fminimizer_minimum, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fminimizer_size", (PyCFunction) _wrap_gsl_multimin_fminimizer_size, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_alloc", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_set", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_free", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_name", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_iterate", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_restart", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_restart, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_test_gradient", (PyCFunction) _wrap_gsl_multimin_test_gradient, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_test_size", (PyCFunction) _wrap_gsl_multimin_test_size, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_f", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_f, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_x", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_x, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_dx", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_dx, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_gradient", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_gradient, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multimin_fdfminimizer_minimum", (PyCFunction) _wrap_gsl_multimin_fdfminimizer_minimum, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_function_init", (PyCFunction) _wrap_gsl_multifit_function_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_function_init_fdf", (PyCFunction) _wrap_gsl_multifit_function_init_fdf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fsolver_getdx", (PyCFunction) _wrap_gsl_multifit_fsolver_getdx, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fsolver_getx", (PyCFunction) _wrap_gsl_multifit_fsolver_getx, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fsolver_getf", (PyCFunction) _wrap_gsl_multifit_fsolver_getf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_getdx", (PyCFunction) _wrap_gsl_multifit_fdfsolver_getdx, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_getx", (PyCFunction) _wrap_gsl_multifit_fdfsolver_getx, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_getf", (PyCFunction) _wrap_gsl_multifit_fdfsolver_getf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_getJ", (PyCFunction) _wrap_gsl_multifit_fdfsolver_getJ, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_function_free", (PyCFunction) _wrap_gsl_multifit_function_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_function_free_fdf", (PyCFunction) _wrap_gsl_multifit_function_free_fdf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_gradient", PyGSL_gsl_multifit_gradient, METH_VARARGS, NULL}, { (char *)"gsl_multifit_covar", PyGSL_gsl_multifit_covar, METH_VARARGS, NULL}, { (char *)"gsl_multifit_fsolver_alloc", (PyCFunction) _wrap_gsl_multifit_fsolver_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fsolver_free", (PyCFunction) _wrap_gsl_multifit_fsolver_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fsolver_set", (PyCFunction) _wrap_gsl_multifit_fsolver_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fsolver_iterate", (PyCFunction) _wrap_gsl_multifit_fsolver_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fsolver_name", (PyCFunction) _wrap_gsl_multifit_fsolver_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fsolver_position", (PyCFunction) _wrap_gsl_multifit_fsolver_position, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_alloc", (PyCFunction) _wrap_gsl_multifit_fdfsolver_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_set", (PyCFunction) _wrap_gsl_multifit_fdfsolver_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_iterate", (PyCFunction) _wrap_gsl_multifit_fdfsolver_iterate, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_free", (PyCFunction) _wrap_gsl_multifit_fdfsolver_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_name", (PyCFunction) _wrap_gsl_multifit_fdfsolver_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_fdfsolver_position", (PyCFunction) _wrap_gsl_multifit_fdfsolver_position, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_test_delta", (PyCFunction) _wrap_gsl_multifit_test_delta, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_test_gradient", (PyCFunction) _wrap_gsl_multifit_test_gradient, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_workspace_alloc", (PyCFunction) _wrap_gsl_integration_workspace_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_workspace_free", (PyCFunction) _wrap_gsl_integration_workspace_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_workspace_get_size", (PyCFunction) _wrap_gsl_integration_workspace_get_size, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qaws_table_alloc", (PyCFunction) _wrap_gsl_integration_qaws_table_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qaws_table_set", (PyCFunction) _wrap_gsl_integration_qaws_table_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qaws_table_free", (PyCFunction) _wrap_gsl_integration_qaws_table_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qawo_table_alloc", (PyCFunction) _wrap_gsl_integration_qawo_table_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qawo_table_set", (PyCFunction) _wrap_gsl_integration_qawo_table_set, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qawo_table_set_length", (PyCFunction) _wrap_gsl_integration_qawo_table_set_length, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qawo_table_free", (PyCFunction) _wrap_gsl_integration_qawo_table_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qng", (PyCFunction) _wrap_gsl_integration_qng, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qag", (PyCFunction) _wrap_gsl_integration_qag, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qagi", (PyCFunction) _wrap_gsl_integration_qagi, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qagiu", (PyCFunction) _wrap_gsl_integration_qagiu, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qagil", (PyCFunction) _wrap_gsl_integration_qagil, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qags", (PyCFunction) _wrap_gsl_integration_qags, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qagp", (PyCFunction) _wrap_gsl_integration_qagp, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qawc", (PyCFunction) _wrap_gsl_integration_qawc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qaws", (PyCFunction) _wrap_gsl_integration_qaws, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qawo", (PyCFunction) _wrap_gsl_integration_qawo, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_integration_qawf", (PyCFunction) _wrap_gsl_integration_qawf, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_alloc", (PyCFunction) _wrap_gsl_cheb_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_free", (PyCFunction) _wrap_gsl_cheb_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_init", (PyCFunction) _wrap_gsl_cheb_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_eval", (PyCFunction) _wrap_gsl_cheb_eval, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_eval_err", (PyCFunction) _wrap_gsl_cheb_eval_err, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_eval_n", (PyCFunction) _wrap_gsl_cheb_eval_n, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_eval_n_err", (PyCFunction) _wrap_gsl_cheb_eval_n_err, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_calc_deriv", (PyCFunction) _wrap_gsl_cheb_calc_deriv, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_cheb_calc_integ", (PyCFunction) _wrap_gsl_cheb_calc_integ, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_get_coefficients", (PyCFunction) _wrap_pygsl_cheb_get_coefficients, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_set_coefficients", (PyCFunction) _wrap_pygsl_cheb_set_coefficients, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_get_a", (PyCFunction) _wrap_pygsl_cheb_get_a, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_get_b", (PyCFunction) _wrap_pygsl_cheb_get_b, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_set_a", (PyCFunction) _wrap_pygsl_cheb_set_a, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_set_b", (PyCFunction) _wrap_pygsl_cheb_set_b, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_get_order_sp", (PyCFunction) _wrap_pygsl_cheb_get_order_sp, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_set_order_sp", (PyCFunction) _wrap_pygsl_cheb_set_order_sp, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_get_f", (PyCFunction) _wrap_pygsl_cheb_get_f, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"pygsl_cheb_set_f", (PyCFunction) _wrap_pygsl_cheb_set_f, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_step_alloc", (PyCFunction) _wrap_gsl_odeiv_step_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_step_reset", (PyCFunction) _wrap_gsl_odeiv_step_reset, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_step_free", (PyCFunction) _wrap_gsl_odeiv_step_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_step_name", (PyCFunction) _wrap_gsl_odeiv_step_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_step_order", (PyCFunction) _wrap_gsl_odeiv_step_order, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_step_apply", pygsl_odeiv_step_apply, METH_VARARGS, NULL}, { (char *)"gsl_odeiv_control_alloc", (PyCFunction) _wrap_gsl_odeiv_control_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_control_init", (PyCFunction) _wrap_gsl_odeiv_control_init, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_control_free", (PyCFunction) _wrap_gsl_odeiv_control_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_control_hadjust", pygsl_odeiv_control_hadjust, METH_VARARGS, NULL}, { (char *)"gsl_odeiv_control_name", (PyCFunction) _wrap_gsl_odeiv_control_name, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_control_standard_new", (PyCFunction) _wrap_gsl_odeiv_control_standard_new, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_control_y_new", (PyCFunction) _wrap_gsl_odeiv_control_y_new, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_control_yp_new", (PyCFunction) _wrap_gsl_odeiv_control_yp_new, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_evolve_alloc", (PyCFunction) _wrap_gsl_odeiv_evolve_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_evolve_reset", (PyCFunction) _wrap_gsl_odeiv_evolve_reset, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_evolve_free", (PyCFunction) _wrap_gsl_odeiv_evolve_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_odeiv_evolve_apply", pygsl_odeiv_evolve_apply, METH_VARARGS, NULL}, { (char *)"gsl_odeiv_evolve_apply_vector", pygsl_odeiv_evolve_apply_vector, METH_VARARGS, NULL}, { (char *)"gsl_multifit_linear_alloc", (PyCFunction) _wrap_gsl_multifit_linear_alloc, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_linear_free", (PyCFunction) _wrap_gsl_multifit_linear_free, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_linear", (PyCFunction) _wrap_gsl_multifit_linear, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_linear_svd", (PyCFunction) _wrap_gsl_multifit_linear_svd, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_wlinear", (PyCFunction) _wrap_gsl_multifit_wlinear, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_wlinear_svd", (PyCFunction) _wrap_gsl_multifit_wlinear_svd, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_linear_est", (PyCFunction) _wrap_gsl_multifit_linear_est, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_multifit_linear_est_matrix", (PyCFunction) _wrap_gsl_multifit_linear_est_matrix, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_fit_linear", (PyCFunction) _wrap_gsl_fit_linear, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_fit_wlinear", (PyCFunction) _wrap_gsl_fit_wlinear, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_fit_linear_est", (PyCFunction) _wrap_gsl_fit_linear_est, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_fit_mul", (PyCFunction) _wrap_gsl_fit_mul, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_fit_wmul", (PyCFunction) _wrap_gsl_fit_wmul, METH_VARARGS | METH_KEYWORDS, NULL}, { (char *)"gsl_fit_mul_est", (PyCFunction) _wrap_gsl_fit_mul_est, METH_VARARGS | METH_KEYWORDS, NULL}, { NULL, NULL, 0, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_FILE = {"_p_FILE", "FILE *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_cheb_series = {"_p_gsl_cheb_series", "gsl_cheb_series *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_function = {"_p_gsl_function", "gsl_function *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_function_fdf = {"_p_gsl_function_fdf", "gsl_function_fdf *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_integration_qawo_table = {"_p_gsl_integration_qawo_table", "gsl_integration_qawo_table *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_integration_qaws_table = {"_p_gsl_integration_qaws_table", "gsl_integration_qaws_table *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_integration_workspace = {"_p_gsl_integration_workspace", "gsl_integration_workspace *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_matrix = {"_p_gsl_matrix", "gsl_matrix *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_min_fminimizer = {"_p_gsl_min_fminimizer", "gsl_min_fminimizer *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_min_fminimizer_type = {"_p_gsl_min_fminimizer_type", "gsl_min_fminimizer_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_monte_function = {"_p_gsl_monte_function", "gsl_monte_function *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_monte_miser_state = {"_p_gsl_monte_miser_state", "gsl_monte_miser_state *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_monte_plain_state = {"_p_gsl_monte_plain_state", "gsl_monte_plain_state *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_monte_vegas_state = {"_p_gsl_monte_vegas_state", "gsl_monte_vegas_state *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multifit_fdfsolver = {"_p_gsl_multifit_fdfsolver", "gsl_multifit_fdfsolver *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multifit_fdfsolver_type = {"_p_gsl_multifit_fdfsolver_type", "gsl_multifit_fdfsolver_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multifit_fsolver = {"_p_gsl_multifit_fsolver", "gsl_multifit_fsolver *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multifit_fsolver_type = {"_p_gsl_multifit_fsolver_type", "gsl_multifit_fsolver_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multifit_function = {"_p_gsl_multifit_function", "gsl_multifit_function *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multifit_function_fdf = {"_p_gsl_multifit_function_fdf", "gsl_multifit_function_fdf *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multifit_linear_workspace = {"_p_gsl_multifit_linear_workspace", "gsl_multifit_linear_workspace *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multimin_fdfminimizer = {"_p_gsl_multimin_fdfminimizer", "gsl_multimin_fdfminimizer *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multimin_fdfminimizer_type = {"_p_gsl_multimin_fdfminimizer_type", "gsl_multimin_fdfminimizer_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multimin_fminimizer = {"_p_gsl_multimin_fminimizer", "gsl_multimin_fminimizer *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multimin_fminimizer_type = {"_p_gsl_multimin_fminimizer_type", "gsl_multimin_fminimizer_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multimin_function = {"_p_gsl_multimin_function", "gsl_multimin_function *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multimin_function_fdf = {"_p_gsl_multimin_function_fdf", "gsl_multimin_function_fdf *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multiroot_fdfsolver = {"_p_gsl_multiroot_fdfsolver", "gsl_multiroot_fdfsolver *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multiroot_fdfsolver_type = {"_p_gsl_multiroot_fdfsolver_type", "gsl_multiroot_fdfsolver_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multiroot_fsolver = {"_p_gsl_multiroot_fsolver", "gsl_multiroot_fsolver *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multiroot_fsolver_type = {"_p_gsl_multiroot_fsolver_type", "gsl_multiroot_fsolver_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multiroot_function = {"_p_gsl_multiroot_function", "gsl_multiroot_function *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_multiroot_function_fdf = {"_p_gsl_multiroot_function_fdf", "gsl_multiroot_function_fdf *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_odeiv_control = {"_p_gsl_odeiv_control", "gsl_odeiv_control *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_odeiv_control_type = {"_p_gsl_odeiv_control_type", "gsl_odeiv_control_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_odeiv_evolve = {"_p_gsl_odeiv_evolve", "gsl_odeiv_evolve *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_odeiv_step = {"_p_gsl_odeiv_step", "gsl_odeiv_step *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_odeiv_step_type = {"_p_gsl_odeiv_step_type", "gsl_odeiv_step_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_rng = {"_p_gsl_rng", "gsl_rng *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_root_fdfsolver = {"_p_gsl_root_fdfsolver", "gsl_root_fdfsolver *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_root_fdfsolver_type = {"_p_gsl_root_fdfsolver_type", "gsl_root_fdfsolver_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_root_fsolver = {"_p_gsl_root_fsolver", "gsl_root_fsolver *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_root_fsolver_type = {"_p_gsl_root_fsolver_type", "gsl_root_fsolver_type *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_gsl_vector = {"_p_gsl_vector", "gsl_multiroot_solver_data *|gsl_vector *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "size_t *|unsigned int *|gsl_mode_t *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_FILE, &_swigt__p_char, &_swigt__p_double, &_swigt__p_gsl_cheb_series, &_swigt__p_gsl_function, &_swigt__p_gsl_function_fdf, &_swigt__p_gsl_integration_qawo_table, &_swigt__p_gsl_integration_qaws_table, &_swigt__p_gsl_integration_workspace, &_swigt__p_gsl_matrix, &_swigt__p_gsl_min_fminimizer, &_swigt__p_gsl_min_fminimizer_type, &_swigt__p_gsl_monte_function, &_swigt__p_gsl_monte_miser_state, &_swigt__p_gsl_monte_plain_state, &_swigt__p_gsl_monte_vegas_state, &_swigt__p_gsl_multifit_fdfsolver, &_swigt__p_gsl_multifit_fdfsolver_type, &_swigt__p_gsl_multifit_fsolver, &_swigt__p_gsl_multifit_fsolver_type, &_swigt__p_gsl_multifit_function, &_swigt__p_gsl_multifit_function_fdf, &_swigt__p_gsl_multifit_linear_workspace, &_swigt__p_gsl_multimin_fdfminimizer, &_swigt__p_gsl_multimin_fdfminimizer_type, &_swigt__p_gsl_multimin_fminimizer, &_swigt__p_gsl_multimin_fminimizer_type, &_swigt__p_gsl_multimin_function, &_swigt__p_gsl_multimin_function_fdf, &_swigt__p_gsl_multiroot_fdfsolver, &_swigt__p_gsl_multiroot_fdfsolver_type, &_swigt__p_gsl_multiroot_fsolver, &_swigt__p_gsl_multiroot_fsolver_type, &_swigt__p_gsl_multiroot_function, &_swigt__p_gsl_multiroot_function_fdf, &_swigt__p_gsl_odeiv_control, &_swigt__p_gsl_odeiv_control_type, &_swigt__p_gsl_odeiv_evolve, &_swigt__p_gsl_odeiv_step, &_swigt__p_gsl_odeiv_step_type, &_swigt__p_gsl_rng, &_swigt__p_gsl_root_fdfsolver, &_swigt__p_gsl_root_fdfsolver_type, &_swigt__p_gsl_root_fsolver, &_swigt__p_gsl_root_fsolver_type, &_swigt__p_gsl_vector, &_swigt__p_unsigned_int, }; static swig_cast_info _swigc__p_FILE[] = { {&_swigt__p_FILE, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_cheb_series[] = { {&_swigt__p_gsl_cheb_series, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_function[] = { {&_swigt__p_gsl_function, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_function_fdf[] = { {&_swigt__p_gsl_function_fdf, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_integration_qawo_table[] = { {&_swigt__p_gsl_integration_qawo_table, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_integration_qaws_table[] = { {&_swigt__p_gsl_integration_qaws_table, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_integration_workspace[] = { {&_swigt__p_gsl_integration_workspace, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_matrix[] = { {&_swigt__p_gsl_matrix, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_min_fminimizer[] = { {&_swigt__p_gsl_min_fminimizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_min_fminimizer_type[] = { {&_swigt__p_gsl_min_fminimizer_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_monte_function[] = { {&_swigt__p_gsl_monte_function, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_monte_miser_state[] = { {&_swigt__p_gsl_monte_miser_state, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_monte_plain_state[] = { {&_swigt__p_gsl_monte_plain_state, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_monte_vegas_state[] = { {&_swigt__p_gsl_monte_vegas_state, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multifit_fdfsolver[] = { {&_swigt__p_gsl_multifit_fdfsolver, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multifit_fdfsolver_type[] = { {&_swigt__p_gsl_multifit_fdfsolver_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multifit_fsolver[] = { {&_swigt__p_gsl_multifit_fsolver, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multifit_fsolver_type[] = { {&_swigt__p_gsl_multifit_fsolver_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multifit_function[] = { {&_swigt__p_gsl_multifit_function, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multifit_function_fdf[] = { {&_swigt__p_gsl_multifit_function_fdf, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multifit_linear_workspace[] = { {&_swigt__p_gsl_multifit_linear_workspace, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multimin_fdfminimizer[] = { {&_swigt__p_gsl_multimin_fdfminimizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multimin_fdfminimizer_type[] = { {&_swigt__p_gsl_multimin_fdfminimizer_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multimin_fminimizer[] = { {&_swigt__p_gsl_multimin_fminimizer, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multimin_fminimizer_type[] = { {&_swigt__p_gsl_multimin_fminimizer_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multimin_function[] = { {&_swigt__p_gsl_multimin_function, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multimin_function_fdf[] = { {&_swigt__p_gsl_multimin_function_fdf, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multiroot_fdfsolver[] = { {&_swigt__p_gsl_multiroot_fdfsolver, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multiroot_fdfsolver_type[] = { {&_swigt__p_gsl_multiroot_fdfsolver_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multiroot_fsolver[] = { {&_swigt__p_gsl_multiroot_fsolver, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multiroot_fsolver_type[] = { {&_swigt__p_gsl_multiroot_fsolver_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multiroot_function[] = { {&_swigt__p_gsl_multiroot_function, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_multiroot_function_fdf[] = { {&_swigt__p_gsl_multiroot_function_fdf, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_odeiv_control[] = { {&_swigt__p_gsl_odeiv_control, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_odeiv_control_type[] = { {&_swigt__p_gsl_odeiv_control_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_odeiv_evolve[] = { {&_swigt__p_gsl_odeiv_evolve, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_odeiv_step[] = { {&_swigt__p_gsl_odeiv_step, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_odeiv_step_type[] = { {&_swigt__p_gsl_odeiv_step_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_rng[] = { {&_swigt__p_gsl_rng, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_root_fdfsolver[] = { {&_swigt__p_gsl_root_fdfsolver, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_root_fdfsolver_type[] = { {&_swigt__p_gsl_root_fdfsolver_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_root_fsolver[] = { {&_swigt__p_gsl_root_fsolver, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_root_fsolver_type[] = { {&_swigt__p_gsl_root_fsolver_type, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_gsl_vector[] = { {&_swigt__p_gsl_vector, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_FILE, _swigc__p_char, _swigc__p_double, _swigc__p_gsl_cheb_series, _swigc__p_gsl_function, _swigc__p_gsl_function_fdf, _swigc__p_gsl_integration_qawo_table, _swigc__p_gsl_integration_qaws_table, _swigc__p_gsl_integration_workspace, _swigc__p_gsl_matrix, _swigc__p_gsl_min_fminimizer, _swigc__p_gsl_min_fminimizer_type, _swigc__p_gsl_monte_function, _swigc__p_gsl_monte_miser_state, _swigc__p_gsl_monte_plain_state, _swigc__p_gsl_monte_vegas_state, _swigc__p_gsl_multifit_fdfsolver, _swigc__p_gsl_multifit_fdfsolver_type, _swigc__p_gsl_multifit_fsolver, _swigc__p_gsl_multifit_fsolver_type, _swigc__p_gsl_multifit_function, _swigc__p_gsl_multifit_function_fdf, _swigc__p_gsl_multifit_linear_workspace, _swigc__p_gsl_multimin_fdfminimizer, _swigc__p_gsl_multimin_fdfminimizer_type, _swigc__p_gsl_multimin_fminimizer, _swigc__p_gsl_multimin_fminimizer_type, _swigc__p_gsl_multimin_function, _swigc__p_gsl_multimin_function_fdf, _swigc__p_gsl_multiroot_fdfsolver, _swigc__p_gsl_multiroot_fdfsolver_type, _swigc__p_gsl_multiroot_fsolver, _swigc__p_gsl_multiroot_fsolver_type, _swigc__p_gsl_multiroot_function, _swigc__p_gsl_multiroot_function_fdf, _swigc__p_gsl_odeiv_control, _swigc__p_gsl_odeiv_control_type, _swigc__p_gsl_odeiv_evolve, _swigc__p_gsl_odeiv_step, _swigc__p_gsl_odeiv_step_type, _swigc__p_gsl_rng, _swigc__p_gsl_root_fdfsolver, _swigc__p_gsl_root_fdfsolver_type, _swigc__p_gsl_root_fsolver, _swigc__p_gsl_root_fsolver_type, _swigc__p_gsl_vector, _swigc__p_unsigned_int, }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { {0, 0, 0, 0.0, 0, 0}}; #ifdef __cplusplus } #endif /* ----------------------------------------------------------------------------- * Type initialization: * This problem is tough by the requirement that no dynamic * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back * to swig_type_info structures, we need some lookup code at initialization. * The idea is that swig generates all the structures that are needed. * The runtime then collects these partially filled structures. * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * * The generated swig_type_info structures are assigned staticly to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the * cast linked list. The cast data is initially stored in something like a * two-dimensional array. Each row corresponds to a type (there are the same * number of rows as there are in the swig_type_initial array). Each entry in * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that * swig_cast_info to the linked list (because the cast->type) pointer will * be correct. * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #if 0 } /* c-mode */ #endif #endif #if 0 #define SWIGRUNTIME_DEBUG #endif SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; int found, init; clientdata = clientdata; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { /* Initialize the swig_module */ swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; init = 1; } else { init = 0; } /* Try and load any already created modules */ module_head = SWIG_GetModule(clientdata); if (!module_head) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ found=0; iter=module_head; do { if (iter==&swig_module) { found=1; break; } iter=iter->next; } while (iter!= module_head); /* if the is found in the list, then all is done and we may leave */ if (found) return; /* otherwise we must add out module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } /* When multiple interpeters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ if (init == 0) return; /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ if (swig_module.next != &swig_module) { type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); } if (type) { /* Overwrite clientdata field */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found type %s\n", type->name); #endif if (swig_module.type_initial[i]->clientdata) { type->clientdata = swig_module.type_initial[i]->clientdata; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); #endif } } else { type = swig_module.type_initial[i]; } /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); #endif if (swig_module.next != &swig_module) { ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); #ifdef SWIGRUNTIME_DEBUG if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); #endif } if (ret) { if (type == swig_module.type_initial[i]) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: skip old type %s\n", ret->name); #endif cast->type = ret; ret = 0; } else { /* Check for casting already in the list */ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); #ifdef SWIGRUNTIME_DEBUG if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); #endif if (!ocast) ret = 0; } } if (!ret) { #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); #endif if (type->cast) { type->cast->prev = cast; cast->next = type->cast; } type->cast = cast; } cast++; } /* Set entry in modules->types array equal to the type */ swig_module.types[i] = type; } swig_module.types[i] = 0; #ifdef SWIGRUNTIME_DEBUG printf("**** SWIG_InitializeModule: Cast List ******\n"); for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; ++j; } printf("---- Total casts: %d\n",j); } printf("**** SWIG_InitializeModule: Cast List ******\n"); #endif } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ SWIGRUNTIME void SWIG_PropagateClientData(void) { size_t i; swig_cast_info *equiv; static int init_run = 0; if (init_run) return; init_run = 1; for (i = 0; i < swig_module.size; i++) { if (swig_module.types[i]->clientdata) { equiv = swig_module.types[i]->cast; while (equiv) { if (!equiv->converter) { if (equiv->type && !equiv->type->clientdata) SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); } equiv = equiv->next; } } } } #ifdef __cplusplus #if 0 { /* c-mode */ #endif } #endif #ifdef __cplusplus extern "C" { #endif /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(void); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; SWIGINTERN PyObject * swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { return PyString_FromString("<Swig global variables>"); } SWIGINTERN PyObject * swig_varlink_str(swig_varlinkobject *v) { PyObject *str = PyString_FromString("("); swig_globalvar *var; for (var = v->vars; var; var=var->next) { PyString_ConcatAndDel(&str,PyString_FromString(var->name)); if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); } PyString_ConcatAndDel(&str,PyString_FromString(")")); return str; } SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); fprintf(fp,"%s\n", PyString_AsString(str)); Py_DECREF(str); return 0; } SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; while (var) { swig_globalvar *n = var->next; free(var->name); free(var); var = n; } } SWIGINTERN PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { PyObject *res = NULL; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->get_attr)(); break; } var = var->next; } if (res == NULL && !PyErr_Occurred()) { PyErr_SetString(PyExc_NameError,"Unknown C global variable"); } return res; } SWIGINTERN int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { int res = 1; swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { res = (*var->set_attr)(p); break; } var = var->next; } if (res == 1 && !PyErr_Occurred()) { PyErr_SetString(PyExc_NameError,"Unknown C global variable"); } return res; } SWIGINTERN PyTypeObject* swig_varlink_type(void) { static char varlink__doc__[] = "Swig var link object"; static PyTypeObject varlink_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { PyObject_HEAD_INIT(NULL) 0, /* Number of items in variable part (ob_size) */ (char *)"swigvarlink", /* Type name (tp_name) */ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 0, /* Itemsize (tp_itemsize) */ (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ (printfunc) swig_varlink_print, /* Print (tp_print) */ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ (reprfunc)swig_varlink_str, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ varlink__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; varlink_type = tmp; varlink_type.ob_type = &PyType_Type; type_init = 1; } return &varlink_type; } /* Create a variable linking object for use later */ SWIGINTERN PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); if (result) { result->vars = 0; } return ((PyObject*) result); } SWIGINTERN void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { strncpy(gv->name,name,size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; } } v->vars = gv; } SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ SWIGINTERN void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { PyObject *obj = 0; size_t i; for (i = 0; constants[i].type; ++i) { switch(constants[i].type) { case SWIG_PY_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d, constants[i].name, obj); Py_DECREF(obj); } } } /* -----------------------------------------------------------------------------*/ /* Fix SwigMethods to carry the callback ptrs when needed */ /* -----------------------------------------------------------------------------*/ SWIGINTERN void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { size_t i; for (i = 0; methods[i].ml_name; ++i) { const char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; const char *name = c + 10; for (j = 0; const_table[j].type; ++j) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); if (ndoc) { char *buff = ndoc; void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; if (ptr) { strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } } } #ifdef __cplusplus } #endif /* -----------------------------------------------------------------------------* * Partial Init method * -----------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" #endif SWIGEXPORT void SWIG_init(void) { PyObject *m, *d; /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); m = Py_InitModule((char *) SWIG_name, SwigMethods); d = PyModule_GetDict(m); SWIG_InitializeModule(0); SWIG_InstallConstants(d,swig_const_table); pygsl_module_for_error_treatment = m; /* To use the numeric extension */ init_pygsl(); import_pygsl_rng(); SWIG_Python_SetConstant(d, "GSL_VEGAS_MODE_IMPORTANCE",SWIG_From_int((int)(GSL_VEGAS_MODE_IMPORTANCE))); SWIG_Python_SetConstant(d, "GSL_VEGAS_MODE_IMPORTANCE_ONLY",SWIG_From_int((int)(GSL_VEGAS_MODE_IMPORTANCE_ONLY))); SWIG_Python_SetConstant(d, "GSL_VEGAS_MODE_STRATIFIED",SWIG_From_int((int)(GSL_VEGAS_MODE_STRATIFIED))); PyDict_SetItemString(d,(char*)"cvar", SWIG_globals()); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_root_fsolver_bisection",Swig_var_gsl_root_fsolver_bisection_get, Swig_var_gsl_root_fsolver_bisection_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_root_fsolver_brent",Swig_var_gsl_root_fsolver_brent_get, Swig_var_gsl_root_fsolver_brent_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_root_fsolver_falsepos",Swig_var_gsl_root_fsolver_falsepos_get, Swig_var_gsl_root_fsolver_falsepos_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_root_fdfsolver_newton",Swig_var_gsl_root_fdfsolver_newton_get, Swig_var_gsl_root_fdfsolver_newton_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_root_fdfsolver_secant",Swig_var_gsl_root_fdfsolver_secant_get, Swig_var_gsl_root_fdfsolver_secant_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_root_fdfsolver_steffenson",Swig_var_gsl_root_fdfsolver_steffenson_get, Swig_var_gsl_root_fdfsolver_steffenson_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_min_fminimizer_goldensection",Swig_var_gsl_min_fminimizer_goldensection_get, Swig_var_gsl_min_fminimizer_goldensection_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_min_fminimizer_brent",Swig_var_gsl_min_fminimizer_brent_get, Swig_var_gsl_min_fminimizer_brent_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multiroot_fsolver_dnewton",Swig_var_gsl_multiroot_fsolver_dnewton_get, Swig_var_gsl_multiroot_fsolver_dnewton_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multiroot_fsolver_broyden",Swig_var_gsl_multiroot_fsolver_broyden_get, Swig_var_gsl_multiroot_fsolver_broyden_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multiroot_fsolver_hybrid",Swig_var_gsl_multiroot_fsolver_hybrid_get, Swig_var_gsl_multiroot_fsolver_hybrid_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multiroot_fsolver_hybrids",Swig_var_gsl_multiroot_fsolver_hybrids_get, Swig_var_gsl_multiroot_fsolver_hybrids_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multiroot_fdfsolver_newton",Swig_var_gsl_multiroot_fdfsolver_newton_get, Swig_var_gsl_multiroot_fdfsolver_newton_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multiroot_fdfsolver_gnewton",Swig_var_gsl_multiroot_fdfsolver_gnewton_get, Swig_var_gsl_multiroot_fdfsolver_gnewton_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multiroot_fdfsolver_hybridj",Swig_var_gsl_multiroot_fdfsolver_hybridj_get, Swig_var_gsl_multiroot_fdfsolver_hybridj_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multiroot_fdfsolver_hybridsj",Swig_var_gsl_multiroot_fdfsolver_hybridsj_get, Swig_var_gsl_multiroot_fdfsolver_hybridsj_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multimin_fdfminimizer_steepest_descent",Swig_var_gsl_multimin_fdfminimizer_steepest_descent_get, Swig_var_gsl_multimin_fdfminimizer_steepest_descent_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multimin_fdfminimizer_conjugate_pr",Swig_var_gsl_multimin_fdfminimizer_conjugate_pr_get, Swig_var_gsl_multimin_fdfminimizer_conjugate_pr_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multimin_fdfminimizer_conjugate_fr",Swig_var_gsl_multimin_fdfminimizer_conjugate_fr_get, Swig_var_gsl_multimin_fdfminimizer_conjugate_fr_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multimin_fdfminimizer_vector_bfgs",Swig_var_gsl_multimin_fdfminimizer_vector_bfgs_get, Swig_var_gsl_multimin_fdfminimizer_vector_bfgs_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multimin_fminimizer_nmsimplex",Swig_var_gsl_multimin_fminimizer_nmsimplex_get, Swig_var_gsl_multimin_fminimizer_nmsimplex_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multifit_fdfsolver_lmder",Swig_var_gsl_multifit_fdfsolver_lmder_get, Swig_var_gsl_multifit_fdfsolver_lmder_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_multifit_fdfsolver_lmsder",Swig_var_gsl_multifit_fdfsolver_lmsder_get, Swig_var_gsl_multifit_fdfsolver_lmsder_set); SWIG_Python_SetConstant(d, "GSL_INTEG_COSINE",SWIG_From_int((int)(GSL_INTEG_COSINE))); SWIG_Python_SetConstant(d, "GSL_INTEG_SINE",SWIG_From_int((int)(GSL_INTEG_SINE))); SWIG_Python_SetConstant(d, "GSL_INTEG_GAUSS15",SWIG_From_int((int)(GSL_INTEG_GAUSS15))); SWIG_Python_SetConstant(d, "GSL_INTEG_GAUSS21",SWIG_From_int((int)(GSL_INTEG_GAUSS21))); SWIG_Python_SetConstant(d, "GSL_INTEG_GAUSS31",SWIG_From_int((int)(GSL_INTEG_GAUSS31))); SWIG_Python_SetConstant(d, "GSL_INTEG_GAUSS41",SWIG_From_int((int)(GSL_INTEG_GAUSS41))); SWIG_Python_SetConstant(d, "GSL_INTEG_GAUSS51",SWIG_From_int((int)(GSL_INTEG_GAUSS51))); SWIG_Python_SetConstant(d, "GSL_INTEG_GAUSS61",SWIG_From_int((int)(GSL_INTEG_GAUSS61))); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_rk2",Swig_var_gsl_odeiv_step_rk2_get, Swig_var_gsl_odeiv_step_rk2_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_rk4",Swig_var_gsl_odeiv_step_rk4_get, Swig_var_gsl_odeiv_step_rk4_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_rkf45",Swig_var_gsl_odeiv_step_rkf45_get, Swig_var_gsl_odeiv_step_rkf45_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_rkck",Swig_var_gsl_odeiv_step_rkck_get, Swig_var_gsl_odeiv_step_rkck_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_rk8pd",Swig_var_gsl_odeiv_step_rk8pd_get, Swig_var_gsl_odeiv_step_rk8pd_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_rk2imp",Swig_var_gsl_odeiv_step_rk2imp_get, Swig_var_gsl_odeiv_step_rk2imp_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_rk4imp",Swig_var_gsl_odeiv_step_rk4imp_get, Swig_var_gsl_odeiv_step_rk4imp_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_bsimp",Swig_var_gsl_odeiv_step_bsimp_get, Swig_var_gsl_odeiv_step_bsimp_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_gear1",Swig_var_gsl_odeiv_step_gear1_get, Swig_var_gsl_odeiv_step_gear1_set); SWIG_addvarlink(SWIG_globals(),(char*)"gsl_odeiv_step_gear2",Swig_var_gsl_odeiv_step_gear2_get, Swig_var_gsl_odeiv_step_gear2_set); SWIG_Python_SetConstant(d, "gsl_odeiv_hadj_dec",SWIG_From_int((int)(GSL_ODEIV_HADJ_DEC))); SWIG_Python_SetConstant(d, "gsl_odeiv_hadj_inc",SWIG_From_int((int)(GSL_ODEIV_HADJ_INC))); SWIG_Python_SetConstant(d, "gsl_odeiv_hadj_nil",SWIG_From_int((int)(GSL_ODEIV_HADJ_NIL))); }
{ "alphanum_fraction": 0.6777020091, "avg_line_length": 34.0418096724, "ext": "c", "hexsha": "aeb9eb31d56e0e0ccdb7a2db46b1a29ae5318e8d", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-10-02T06:18:07.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-02T06:18:07.000Z", "max_forks_repo_head_hexsha": "457e7afb5cab424296dff95e1acf10ebf70d32a9", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "juhnowski/FishingRod", "max_forks_repo_path": "production/pygsl-0.9.5/swig_src/callback_wrap.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "457e7afb5cab424296dff95e1acf10ebf70d32a9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "juhnowski/FishingRod", "max_issues_repo_path": "production/pygsl-0.9.5/swig_src/callback_wrap.c", "max_line_length": 199, "max_stars_count": null, "max_stars_repo_head_hexsha": "457e7afb5cab424296dff95e1acf10ebf70d32a9", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "juhnowski/FishingRod", "max_stars_repo_path": "production/pygsl-0.9.5/swig_src/callback_wrap.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 176830, "size": 545520 }
/* rng/benchmark.c * * Copyright (C) 1996, 1997, 1998, 1999, 2000 James Theiler, Brian Gough * * 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 2 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <config.h> #include <time.h> #include <stdio.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_errno.h> void benchmark (const gsl_rng_type * T); #define N 1000000 int isum; double dsum; int main (void) { benchmark(gsl_rng_ranlux); benchmark(gsl_rng_ranlux389); benchmark(gsl_rng_ranlxs0); benchmark(gsl_rng_ranlxs1); benchmark(gsl_rng_ranlxs2); benchmark(gsl_rng_ranlxd1); benchmark(gsl_rng_ranlxd2); benchmark(gsl_rng_slatec); benchmark(gsl_rng_gfsr4); benchmark(gsl_rng_cmrg); benchmark(gsl_rng_minstd); benchmark(gsl_rng_mrg); benchmark(gsl_rng_mt19937); benchmark(gsl_rng_r250); benchmark(gsl_rng_ran0); benchmark(gsl_rng_ran1); benchmark(gsl_rng_ran2); benchmark(gsl_rng_ran3); benchmark(gsl_rng_rand48); benchmark(gsl_rng_rand); benchmark(gsl_rng_random8_bsd); benchmark(gsl_rng_random8_glibc2); benchmark(gsl_rng_random8_libc5); benchmark(gsl_rng_random128_bsd); benchmark(gsl_rng_random128_glibc2); benchmark(gsl_rng_random128_libc5); benchmark(gsl_rng_random256_bsd); benchmark(gsl_rng_random256_glibc2); benchmark(gsl_rng_random256_libc5); benchmark(gsl_rng_random32_bsd); benchmark(gsl_rng_random32_glibc2); benchmark(gsl_rng_random32_libc5); benchmark(gsl_rng_random64_bsd); benchmark(gsl_rng_random64_glibc2); benchmark(gsl_rng_random64_libc5); benchmark(gsl_rng_random_bsd); benchmark(gsl_rng_random_glibc2); benchmark(gsl_rng_random_libc5); benchmark(gsl_rng_randu); benchmark(gsl_rng_ranf); benchmark(gsl_rng_ranmar); benchmark(gsl_rng_taus); benchmark(gsl_rng_transputer); benchmark(gsl_rng_tt800); benchmark(gsl_rng_uni32); benchmark(gsl_rng_uni); benchmark(gsl_rng_vax); benchmark(gsl_rng_zuf); return 0; } void benchmark (const gsl_rng_type * T) { int start, end; int i = 0, d = 0 ; double t1, t2; gsl_rng *r = gsl_rng_alloc (T); start = clock (); do { int j; for (j = 0; j < N; j++) isum += gsl_rng_get (r); i += N; end = clock (); } while (end < start + CLOCKS_PER_SEC/10); t1 = (end - start) / (double) CLOCKS_PER_SEC; start = clock (); do { int j; for (j = 0; j < N; j++) dsum += gsl_rng_uniform (r); d += N; end = clock (); } while (end < start + CLOCKS_PER_SEC/10); t2 = (end - start) / (double) CLOCKS_PER_SEC; printf ("%6.0f k ints/sec, %6.0f k doubles/sec, %s\n", i / t1 / 1000.0, d / t2 / 1000.0, gsl_rng_name (r)); gsl_rng_free (r); }
{ "alphanum_fraction": 0.7131122604, "avg_line_length": 25.0916030534, "ext": "c", "hexsha": "1b81ca4005d8cad7b24d3653aaae311ec296a32a", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_forks_event_min_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ICML14MoMCompare/spectral-learn", "max_forks_repo_path": "code/em/treba/gsl-1.0/rng/benchmark.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ICML14MoMCompare/spectral-learn", "max_issues_repo_path": "code/em/treba/gsl-1.0/rng/benchmark.c", "max_line_length": 72, "max_stars_count": 14, "max_stars_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ICML14MoMCompare/spectral-learn", "max_stars_repo_path": "code/em/treba/gsl-1.0/rng/benchmark.c", "max_stars_repo_stars_event_max_datetime": "2021-06-10T11:31:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-12-18T18:09:25.000Z", "num_tokens": 1002, "size": 3287 }
/* ****************************************************************** ** ** OpenSees - Open System for Earthquake Engineering Simulation ** ** Pacific Earthquake Engineering Research Center ** ** ** ** ** ** (C) Copyright 1999, The Regents of the University of California ** ** All Rights Reserved. ** ** ** ** Commercial use of this program without express permission of the ** ** University of California, Berkeley, is strictly prohibited. See ** ** file 'COPYRIGHT' in main directory for information on usage and ** ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. ** ** ** ** Developed by: ** ** Frank McKenna (fmckenna@ce.berkeley.edu) ** ** Gregory L. Fenves (fenves@ce.berkeley.edu) ** ** Filip C. Filippou (filippou@ce.berkeley.edu) ** ** ** ** ****************************************************************** */ // $Revision: 1.2 $ // $Date: 2007-02-14 20:12:32 $ // $Source: /usr/local/cvs/OpenSees/SRC/system_of_eqn/linearSOE/petsc/ShadowPetscSOE.h,v $ // File: ~/system_of_eqn/linearSOE/petsc/ShadowPetscSOE.h // // Written: fmk & om // Created: 7/98 // Revision: A // // Description: This file contains the class definition for ShadowPetscSOE // ShadowPetscSOE is a subclass of LinearSOE. // What: "@(#) ShadowPetscSOE.h, revA" #ifndef ShadowPetscSOE_h #define ShadowPetscSOE_h #include <LinearSOE.h> #include <Vector.h> #include <PetscSOE.h> extern "C" { #include <petsc.h> } class PetscSolver; class ShadowPetscSOE : public LinearSOE { public: ShadowPetscSOE(PetscSolver &theSolver, int blockSize); ~ShadowPetscSOE(); int solve(void); int getNumEqn(void) const; int setSize(Graph &theGraph); int addA(const Matrix &, const ID &, double fact = 1.0); int addB(const Vector &, const ID &, double fact = 1.0); int setB(const Vector &, double fact = 1.0); void zeroA(void); void zeroB(void); const Vector &getX(void); const Vector &getB(void); double normRHS(void); void setX(int loc, double value); int setSolver(PetscSolver &newSolver); int sendSelf(int commitTag, Channel &theChannel); int recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker); protected: private: MPI_Comm theComm; // a comm for communicating to the ActorPetscSOE's // without using PETSC_COMM_WORLD PetscSOE theSOE; // the local portion of the SOE PetscSolver *theSolver; // created by the user int myRank; int numProcessors; int sendData[3]; void *sendBuffer; int blockSize; }; #endif
{ "alphanum_fraction": 0.4872781065, "avg_line_length": 32.8155339806, "ext": "h", "hexsha": "c96490fc998cbb65ca307c19a34bb058e93053d0", "lang": "C", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-01-19T07:29:37.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-21T03:11:11.000Z", "max_forks_repo_head_hexsha": "417c3be117992a108c6bbbcf5c9b63806b9362ab", "max_forks_repo_licenses": [ "TCL" ], "max_forks_repo_name": "steva44/OpenSees", "max_forks_repo_path": "SRC/system_of_eqn/linearSOE/petsc/ShadowPetscSOE.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "417c3be117992a108c6bbbcf5c9b63806b9362ab", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "TCL" ], "max_issues_repo_name": "steva44/OpenSees", "max_issues_repo_path": "SRC/system_of_eqn/linearSOE/petsc/ShadowPetscSOE.h", "max_line_length": 90, "max_stars_count": 8, "max_stars_repo_head_hexsha": "ccb350564df54f5c5ec3a079100effe261b46650", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kuanshi/ductile-fracture", "max_stars_repo_path": "OpenSees/SRC/system_of_eqn/linearSOE/petsc/ShadowPetscSOE.h", "max_stars_repo_stars_event_max_datetime": "2020-04-17T14:12:03.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-05T16:25:10.000Z", "num_tokens": 719, "size": 3380 }
/*** * Copyright 2020 The Katla Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef KATLA_MQTT_MESSAGE_H #define KATLA_MQTT_MESSAGE_H #include "outcome/outcome.hpp" #include <gsl/span> namespace katla { enum class MqttQos {AtMostOnce = 0, AtLeastOnce = 1, ExactlyOnce = 2}; struct MqttMessage { int messageId {}; std::string topic; gsl::span<std::byte> payload; MqttQos qos; bool retain; }; } // namespace katla #endif
{ "alphanum_fraction": 0.7244582043, "avg_line_length": 25.5, "ext": "h", "hexsha": "c3ad4d30c787051be672fd36c810d0171a6ba6d1", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-08-26T13:32:36.000Z", "max_forks_repo_forks_event_min_datetime": "2020-08-26T13:32:36.000Z", "max_forks_repo_head_hexsha": "aaaeb8baf041bba7259275beefc71c8452a16223", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "plok/katla", "max_forks_repo_path": "mqtt/mqtt-message.h", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aaaeb8baf041bba7259275beefc71c8452a16223", "max_issues_repo_issues_event_max_datetime": "2021-11-16T14:21:56.000Z", "max_issues_repo_issues_event_min_datetime": "2021-03-25T14:33:22.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "plok/katla", "max_issues_repo_path": "mqtt/mqtt-message.h", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "aaaeb8baf041bba7259275beefc71c8452a16223", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "plok/katla", "max_stars_repo_path": "mqtt/mqtt-message.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 241, "size": 969 }
#pragma once #include <gsl/multi_span> #include <droidCrypto/Defines.h> #include <droidCrypto/MatrixView.h> #include <cstring> namespace droidCrypto { enum class AllocType { Uninitialized, Zeroed }; template<typename T> class Matrix : public MatrixView<T> { uint64_t mCapacity = 0; public: Matrix() {} Matrix(uint64_t rows, uint64_t columns, AllocType t = AllocType::Zeroed) { resize(rows, columns, t); } Matrix(const MatrixView<T>& copy) : MatrixView<T>(new T[copy.size()], copy.bounds()[0], copy.stride()) , mCapacity(copy.size()) { memcpy(MatrixView<T>::mView.data(), copy.data(), copy.mView.size_bytes()); } Matrix(Matrix<T>&& copy) : MatrixView<T>(copy.data(), copy.bounds()[0], copy.stride()) , mCapacity(copy.mCapacity) { copy.mView = span<T>(); copy.mStride = 0; copy.mCapacity = 0; } ~Matrix() { delete[] MatrixView<T>::mView.data(); } const Matrix<T>& operator=(const Matrix<T>& copy) { resize(copy.rows(), copy.stride()); memcpy(MatrixView<T>::mView.data(), copy.data(), copy.mView.size_bytes()); return copy; } void resize(uint64_t rows, uint64_t columns, AllocType type = AllocType::Zeroed) { if (rows * columns > mCapacity) { mCapacity = rows * columns; auto old = MatrixView<T>::mView; if (type == AllocType::Zeroed) MatrixView<T>::mView = span<T>(new T[mCapacity](), mCapacity); else MatrixView<T>::mView = span<T>(new T[mCapacity], mCapacity); auto min = std::min<uint64_t>(old.size(), mCapacity) * sizeof(T); memcpy(MatrixView<T>::mView.data(), old.data(), min); delete[] old.data(); } else { auto newSize = rows * columns; if (newSize > MatrixView<T>::size() && type == AllocType::Zeroed) { memset(MatrixView<T>::data() + MatrixView<T>::size(), 0, newSize - MatrixView<T>::size()); } MatrixView<T>::mView = span<T>(MatrixView<T>::data(), newSize); } MatrixView<T>::mStride = columns; } // return the internal memory, stop managing its lifetime, and set the current container to null. T* release() { auto ret = MatrixView<T>::mView.data(); MatrixView<T>::mView = {}; mCapacity = 0; return ret; } }; }
{ "alphanum_fraction": 0.4759959142, "avg_line_length": 27.4485981308, "ext": "h", "hexsha": "0efd2138dbfacef4f855457b95b9f50256a85cf5", "lang": "C", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-31T05:40:21.000Z", "max_forks_repo_forks_event_min_datetime": "2019-10-11T08:23:26.000Z", "max_forks_repo_head_hexsha": "6458cab5add75d592861d9a1ee253cc07b3ab829", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "contact-discovery/mobile_psi_cpp", "max_forks_repo_path": "droidCrypto/Matrix.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "6458cab5add75d592861d9a1ee253cc07b3ab829", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "contact-discovery/mobile_psi_cpp", "max_issues_repo_path": "droidCrypto/Matrix.h", "max_line_length": 111, "max_stars_count": 14, "max_stars_repo_head_hexsha": "4c5f0f56142535ca0d3524c99781cfd0c07b9205", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CROSSINGTUD/mobile_psi_cpp", "max_stars_repo_path": "droidCrypto/Matrix.h", "max_stars_repo_stars_event_max_datetime": "2021-11-04T06:40:50.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-16T16:18:49.000Z", "num_tokens": 628, "size": 2937 }
#include <stdio.h> #include <gsl/gsl_blas.h> #include <gsl/gsl_linalg.h> #include <time.h> /* gsl_matrix_printf prints a matrix as a column vector. This function prints a matrix in block form. */ void pretty_print(const gsl_matrix * M) { // Get the dimension of the matrix. int rows = M->size1; int cols = M->size2; // Now print out the data in a square format. for(int i = 0; i < rows; i++){ for(int j = 0; j < cols; j++){ printf("%f ", gsl_matrix_get(M, i, j)); } printf("\n"); } printf("\n"); } int run_svd(const gsl_matrix * a) { // Need to transpose the input gsl_matrix *a_transpose = gsl_matrix_alloc(a->size2, a->size1); gsl_matrix_transpose_memcpy(a_transpose, a); printf("a_matrix'\n"); pretty_print(a_transpose); int m = a->size1; gsl_matrix * V = gsl_matrix_alloc(m, m); gsl_vector * S = gsl_vector_alloc(m); gsl_vector * work = gsl_vector_alloc(m); gsl_linalg_SV_decomp(a_transpose, V, S, work); printf("U\n"); pretty_print(V); printf("\n"); printf("V\n"); pretty_print(a_transpose); printf("\n"); printf("S\n"); gsl_vector_fprintf(stdout, S, "%g"); gsl_matrix_free(V); gsl_vector_free(S); gsl_vector_free(work); return 0; }
{ "alphanum_fraction": 0.6527436527, "avg_line_length": 23.9411764706, "ext": "c", "hexsha": "b52af305a0fc57384a5269cbe14a773991ca817c", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c1b9f0a0e72d7f92b9ce84aa111c063efcac1241", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "paul-reiners/getting-smaller", "max_forks_repo_path": "src/c/src/run_svd.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "c1b9f0a0e72d7f92b9ce84aa111c063efcac1241", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "paul-reiners/getting-smaller", "max_issues_repo_path": "src/c/src/run_svd.c", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "c1b9f0a0e72d7f92b9ce84aa111c063efcac1241", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "paul-reiners/getting-smaller", "max_stars_repo_path": "src/c/src/run_svd.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 365, "size": 1221 }
#ifndef DOG_H #define DOG_H /* from local library */ #include "colorhistogram.h" /* from OpenCV library */ #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp> /* from gsl library */ #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> /* from gflags library */ #include <gflags/gflags.h> // use console flag DECLARE_double(std); class Dog { public: Dog(); Dog(const int fw, const int fh, const cv::Rect &rect, cv::Mat *hist); void run(cv::Mat &frame, gsl_rng *rng); //bool operator<(const Dog &p) { return weight < p.weight; } /* coefficient for normalizing */ static const int LAMBDA; /* autoregressive dynamics parameters for transition model */ static const float A1; static const float A2; static const float B0; /* standard deviations for gaussian sampling in transition model */ static const double TRANS_X_STD; static const double TRANS_Y_STD; static const double TRANS_S_STD; int fw; int fh; float x0; float y0; float xp; float yp; float x; float y; float sp; float s; float width; float height; cv::Mat *hist; float weight; private: static ColorHistogram *pHist; float _likelihood(const cv::Mat &frame); float _histo_dist_sq(cv::Mat *h1, cv::Mat *h2); }; #endif
{ "alphanum_fraction": 0.66, "avg_line_length": 19.8529411765, "ext": "h", "hexsha": "c20764d1ba6a46d6329fc3f5de19eb3573ff3e57", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f87abdd895c81acfb24bb697bcfd226004d95dd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Redoblue/find-the-bombs", "max_forks_repo_path": "dog.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f87abdd895c81acfb24bb697bcfd226004d95dd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Redoblue/find-the-bombs", "max_issues_repo_path": "dog.h", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "9f87abdd895c81acfb24bb697bcfd226004d95dd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Redoblue/find-the-bombs", "max_stars_repo_path": "dog.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 349, "size": 1350 }
/* fft/gsl_fft_real_float.h * * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough * * 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 2 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __GSL_FFT_REAL_FLOAT_H__ #define __GSL_FFT_REAL_FLOAT_H__ #include <stddef.h> #include <gsl/gsl_math.h> #include <gsl/gsl_complex.h> #include <gsl/gsl_fft.h> #undef __BEGIN_DECLS #undef __END_DECLS #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECLS } #else # define __BEGIN_DECLS /* empty */ # define __END_DECLS /* empty */ #endif __BEGIN_DECLS int gsl_fft_real_float_radix2_transform (float data[], const size_t stride, const size_t n) ; typedef struct { size_t n; size_t nf; size_t factor[64]; gsl_complex_float *twiddle[64]; gsl_complex_float *trig; } gsl_fft_real_wavetable_float; typedef struct { size_t n; float *scratch; } gsl_fft_real_workspace_float; gsl_fft_real_wavetable_float * gsl_fft_real_wavetable_float_alloc (size_t n); void gsl_fft_real_wavetable_float_free (gsl_fft_real_wavetable_float * wavetable); gsl_fft_real_workspace_float * gsl_fft_real_workspace_float_alloc (size_t n); void gsl_fft_real_workspace_float_free (gsl_fft_real_workspace_float * workspace); int gsl_fft_real_float_transform (float data[], const size_t stride, const size_t n, const gsl_fft_real_wavetable_float * wavetable, gsl_fft_real_workspace_float * work); int gsl_fft_real_float_unpack (const float real_float_coefficient[], float complex_coefficient[], const size_t stride, const size_t n); __END_DECLS #endif /* __GSL_FFT_REAL_FLOAT_H__ */
{ "alphanum_fraction": 0.7423259836, "avg_line_length": 28.9125, "ext": "h", "hexsha": "a99cab5c12734f3803c52e79ac8665f6a7b402f1", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_forks_event_min_datetime": "2015-10-02T01:32:59.000Z", "max_forks_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ICML14MoMCompare/spectral-learn", "max_forks_repo_path": "code/em/treba/gsl-1.0/fft/gsl_fft_real_float.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ICML14MoMCompare/spectral-learn", "max_issues_repo_path": "code/em/treba/gsl-1.0/fft/gsl_fft_real_float.h", "max_line_length": 93, "max_stars_count": 14, "max_stars_repo_head_hexsha": "91e70bc88726ee680ec6e8cbc609977db3fdcff9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ICML14MoMCompare/spectral-learn", "max_stars_repo_path": "code/em/treba/gsl-1.0/fft/gsl_fft_real_float.h", "max_stars_repo_stars_event_max_datetime": "2021-06-10T11:31:28.000Z", "max_stars_repo_stars_event_min_datetime": "2015-12-18T18:09:25.000Z", "num_tokens": 575, "size": 2313 }
#include <stdio.h> #include <gsl/gsl_rng.h> int main (void) { const gsl_rng_type * T; gsl_rng * r; int i, n = 10; gsl_rng_env_setup(); T = gsl_rng_default; r = gsl_rng_alloc (T); for (i = 0; i < n; i++) { double u = gsl_rng_uniform (r); printf ("%.5f\n", u); } gsl_rng_free (r); return 0; }
{ "alphanum_fraction": 0.5459940653, "avg_line_length": 12.4814814815, "ext": "c", "hexsha": "ca4b2db2d522d4e911163b6e5662a9c10425924c", "lang": "C", "max_forks_count": 40, "max_forks_repo_forks_event_max_datetime": "2022-03-03T23:23:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-26T15:31:16.000Z", "max_forks_repo_head_hexsha": "1b4ee4c146f526ea6e2f4f8607df7e9687204a9e", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "Brian-ning/HMNE", "max_forks_repo_path": "Source/BaselineMethods/MNE/C++/gsl-2.4/doc/examples/rngunif.c", "max_issues_count": 12, "max_issues_repo_head_hexsha": "1b4ee4c146f526ea6e2f4f8607df7e9687204a9e", "max_issues_repo_issues_event_max_datetime": "2022-03-13T03:54:24.000Z", "max_issues_repo_issues_event_min_datetime": "2020-12-15T08:30:19.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "Brian-ning/HMNE", "max_issues_repo_path": "Source/BaselineMethods/MNE/C++/gsl-2.4/doc/examples/rngunif.c", "max_line_length": 37, "max_stars_count": 64, "max_stars_repo_head_hexsha": "d14edfb62795805c84a4280d67b50cca175b95af", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "manggoguy/parsec-modified", "max_stars_repo_path": "pkgs/libs/gsl/src/doc/examples/rngunif.c", "max_stars_repo_stars_event_max_datetime": "2022-03-24T13:26:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-06T00:30:56.000Z", "num_tokens": 118, "size": 337 }
#include <stdio.h> #include <gsl/gsl_sf_bessel.h> int main (void) { double x = 5.0; double expected = -0.17759677131433830434739701; double y = gsl_sf_bessel_J0 (x); printf ("J0(5.0) = %.18f\n", y); printf ("exact = %.18f\n", expected); return 0; }
{ "alphanum_fraction": 0.6231343284, "avg_line_length": 16.75, "ext": "c", "hexsha": "7c1a9b019178857ad47260648a562c86ea3da401", "lang": "C", "max_forks_count": 40, "max_forks_repo_forks_event_max_datetime": "2022-03-03T23:23:37.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-26T15:31:16.000Z", "max_forks_repo_head_hexsha": "1b4ee4c146f526ea6e2f4f8607df7e9687204a9e", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "Brian-ning/HMNE", "max_forks_repo_path": "Source/BaselineMethods/MNE/C++/gsl-2.4/doc/examples/specfun.c", "max_issues_count": 12, "max_issues_repo_head_hexsha": "1b4ee4c146f526ea6e2f4f8607df7e9687204a9e", "max_issues_repo_issues_event_max_datetime": "2022-03-13T03:54:24.000Z", "max_issues_repo_issues_event_min_datetime": "2020-12-15T08:30:19.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "Brian-ning/HMNE", "max_issues_repo_path": "Source/BaselineMethods/MNE/C++/gsl-2.4/doc/examples/specfun.c", "max_line_length": 50, "max_stars_count": 64, "max_stars_repo_head_hexsha": "d14edfb62795805c84a4280d67b50cca175b95af", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "manggoguy/parsec-modified", "max_stars_repo_path": "pkgs/libs/gsl/src/doc/examples/specfun.c", "max_stars_repo_stars_event_max_datetime": "2022-03-24T13:26:53.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-06T00:30:56.000Z", "num_tokens": 100, "size": 268 }
/* ODE: a program to get optime Runge-Kutta and multi-steps methods. Copyright 2011-2019, Javier Burguete Tolosa. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY Javier Burguete Tolosa ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Javier Burguete Tolosa OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * \file rk_2_2.c * \brief Source file to optimize Runge-Kutta 3 steps 2nd order methods. * \author Javier Burguete Tolosa. * \copyright Copyright 2011-2019. */ #define _GNU_SOURCE #include <string.h> #include <math.h> #include <libxml/parser.h> #include <glib.h> #include <libintl.h> #include <gsl/gsl_rng.h> #include "config.h" #include "utils.h" #include "optimize.h" #include "rk.h" #include "rk_2_2.h" #define DEBUG_RK_2_2 0 ///< macro to debug. /** * Function to obtain the coefficients of a 2 steps 2nd order Runge-Kutta * method. */ int rk_tb_2_2 (Optimize * optimize) ///< Optimize struct. { long double *tb, *r; #if DEBUG_RK_2_2 fprintf (stderr, "rk_tb_2_2: start\n"); #endif tb = optimize->coefficient; r = optimize->random_data; t2 (tb) = 1.L; t1 (tb) = r[0]; b21 (tb) = 0.5L / t1 (tb); rk_b_2 (tb); #if DEBUG_RK_2_2 rk_print_tb (optimize, "rk_tb_2_2", stderr); fprintf (stderr, "rk_tb_2_2: end\n"); #endif return 1; } /** * Function to obtain the coefficients of a 2 steps 2nd order, 3rd order in * equations depending only in time, Runge-Kutta method. */ int rk_tb_2_2t (Optimize * optimize) ///< Optimize struct. { long double *tb; #if DEBUG_RK_2_2 fprintf (stderr, "rk_tb_2_2t: start\n"); #endif tb = optimize->coefficient; t2 (tb) = 1.L; t1 (tb) = 2.L / 3.L; b21 (tb) = 0.5L / t1 (tb); rk_b_2 (tb); #if DEBUG_RK_2_2 rk_print_tb (optimize, "rk_tb_2_2t", stderr); fprintf (stderr, "rk_tb_2_2t: end\n"); #endif return 1; } /** * Function to obtain the coefficients of a 2 steps 1st-2nd order Runge-Kutta * pair. */ int rk_tb_2_2p (Optimize * optimize) ///< Optimize struct. { long double *tb; #if DEBUG_RK_2_2 fprintf (stderr, "rk_tb_2_2p: start\n"); #endif if (!rk_tb_2_2 (optimize)) return 0; tb = optimize->coefficient; e20 (tb) = 1.L; #if DEBUG_RK_2_2 rk_print_tb (optimize, "rk_tb_2_2p", stderr); fprintf (stderr, "rk_tb_2_2p: end\n"); #endif return 1; } /** * Function to obtain the coefficients of a 2 steps 1st-2nd order, 1st-3rd order * in equations depending only on time, Runge-Kutta pair. */ int rk_tb_2_2tp (Optimize * optimize) ///< Optimize struct. { long double *tb; #if DEBUG_RK_2_2 fprintf (stderr, "rk_tb_2_2tp: start\n"); #endif if (!rk_tb_2_2t (optimize)) return 0; tb = optimize->coefficient; e20 (tb) = 1.L; #if DEBUG_RK_2_2 rk_print_tb (optimize, "rk_tb_2_2tp", stderr); fprintf (stderr, "rk_tb_2_2tp: end\n"); #endif return 1; } /** * Function to calculate the objective function of a 2 steps 2nd order * Runge-Kutta method. * * \return objective function value. */ long double rk_objective_tb_2_2 (RK * rk) ///< RK struct. { long double *tb; long double o; #if DEBUG_RK_2_2 fprintf (stderr, "rk_objective_tb_2_2: start\n"); #endif tb = rk->tb->coefficient; if (b20 (tb) < 0.L) { o = 40.L - b20 (tb); goto end; } o = 30.L + fmaxl (1.L, t1 (tb)); if (rk->strong) { rk_bucle_ac (rk); o = fminl (o, *rk->ac0->optimal); } end: #if DEBUG_RK_2_2 fprintf (stderr, "rk_objective_tb_2_2: optimal=%Lg\n", o); fprintf (stderr, "rk_objective_tb_2_2: end\n"); #endif return o; } /** * Function to calculate the objective function of a 2 steps 2nd order, 3rd * order in equations depending only in time, Runge-Kutta method. * * \return objective function value. */ long double rk_objective_tb_2_2t (RK * rk) ///< RK struct. { long double o; #if DEBUG_RK_2_2 fprintf (stderr, "rk_objective_tb_2_2t: start\n"); #endif o = 31.L; if (rk->strong) { rk_bucle_ac (rk); o = fminl (o, *rk->ac0->optimal); } #if DEBUG_RK_2_2 fprintf (stderr, "rk_objective_tb_2_2t: optimal=%Lg\n", o); fprintf (stderr, "rk_objective_tb_2_2t: end\n"); #endif return o; }
{ "alphanum_fraction": 0.6931708261, "avg_line_length": 25.9748743719, "ext": "c", "hexsha": "ff34ebca611c33bbf842bfb10fdf245d06312d13", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "463b8402ed4aac140a4c4ca2295a69dcce98b061", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "jburguete/ode", "max_forks_repo_path": "rk_2_2.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "463b8402ed4aac140a4c4ca2295a69dcce98b061", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "jburguete/ode", "max_issues_repo_path": "rk_2_2.c", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "463b8402ed4aac140a4c4ca2295a69dcce98b061", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "jburguete/ode", "max_stars_repo_path": "rk_2_2.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1646, "size": 5169 }
#ifndef CWANNIER_SPINORBIT_H #define CWANNIER_SPINORBIT_H #include <stdlib.h> #include <stdio.h> #include <math.h> #include <gsl/gsl_complex.h> #include <gsl/gsl_complex_math.h> #include <gsl/gsl_matrix.h> #include "HTightBinding.h" typedef struct { gsl_complex val; int row; int col; } socElem; HTightBinding* HamiltonianWithSOC(double soc_strength, double theta, double phi, HTightBinding *Hrs_up, HTightBinding *Hrs_dn); void addSOCElems(gsl_matrix_complex *Hr_onsite, double soc_strength, double theta, double phi); gsl_matrix_complex* onSiteSOC_SpinZ(); void setWithHermitianConjugate(gsl_matrix_complex *M, int row, int col, gsl_complex val); gsl_matrix_complex* onSiteSOC(double theta, double phi); gsl_matrix_complex *RotationMatrix(double theta, double phi); #endif // CWANNIER_SPINORBIT_H
{ "alphanum_fraction": 0.7887667888, "avg_line_length": 27.3, "ext": "h", "hexsha": "b9cb57d66a4d4c4fa658348b9829b6cea25b1761", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "96b9719b098d3e2e7d6f4fa5b2c938aa460c5fb8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tflovorn/cwannier", "max_forks_repo_path": "SpinOrbit.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "96b9719b098d3e2e7d6f4fa5b2c938aa460c5fb8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tflovorn/cwannier", "max_issues_repo_path": "SpinOrbit.h", "max_line_length": 127, "max_stars_count": null, "max_stars_repo_head_hexsha": "96b9719b098d3e2e7d6f4fa5b2c938aa460c5fb8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tflovorn/cwannier", "max_stars_repo_path": "SpinOrbit.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 226, "size": 819 }
/* * Copyright (c) 1997-1999 Massachusetts Institute of Technology * * 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <stdlib.h> #include <fftw.h> #include "mex.h" /**************************************************************************/ /* MEX programs need to use special memory allocation routines, so we use the hooks provided by FFTW to ensure that MEX allocation is used: */ void *fftw_mex_malloc_hook(size_t n) { void *buf; buf = mxMalloc(n); /* Call this routine so that we can retain allocations and data between calls to the FFTW MEX: */ mexMakeMemoryPersistent(buf); return buf; } void fftw_mex_free_hook(void *buf) { mxFree(buf); } void install_fftw_hooks(void) { fftw_malloc_hook = fftw_mex_malloc_hook; fftw_free_hook = fftw_mex_free_hook; } /**************************************************************************/ /* We retain various information between calls to the FFTW MEX in order to maximize performance. (Reusing plans, data, and allocated blocks where possible.) This information is referenced by the following variables, which are initialized in the function initialize_fftw_mex_data. */ #define MAX_RANK 10 int first_call = 1; /* 1 if this is the first call to the FFTW MEX, and nothing has been initialized yet. 0 otherwise. */ /* Keep track of the array dimensions that stored data (below) is for. When these dimensions changed, we have to recompute the plans, work arrays, etc. */ int cur_rank = 0, /* rank of the array */ cur_dims[MAX_RANK], /* dimensions */ cur_N; /* product of the dimensions */ /* Work arrays. MATLAB stores complex numbers as separate real/imag. arrays, so we have to translate into our format before the FFT. In case allocation is slow, we retain these work arrays between calls so that they can be reused. */ fftw_complex *input_work = 0, *output_work = 0; /* The number of floating point operations required for the FFT. (Starting with FFTW 1.3, an exact count is computed by the planner.) This is used to update MATLAB's flops count. */ int fftw_mex_flops = 0, ifftw_mex_flops = 0; /* Plans. These are computed once and then reused as long as the dimensions of the array don't changed. At any point in time, at most two plans are cached: a forward and backwards plan, either for one- or multi-dimensional transforms. */ fftw_plan p = 0, ip = 0; fftwnd_plan pnd = 0, ipnd = 0; /**************************************************************************/ int compute_fftw_mex_flops(fftw_direction dir) { #ifdef FFTW_HAS_COUNT_PLAN_OPS /* this feature will be in FFTW 1.3 */ fftw_op_count ops; if (dir == FFTW_FORWARD) { if (cur_rank == 1) fftw_count_plan_ops(p,&ops); else fftwnd_count_plan_ops(pnd,&ops); } else { if (cur_rank == 1) fftw_count_plan_ops(ip,&ops); else fftwnd_count_plan_ops(ipnd,&ops); } return (ops.fp_additions + ops.fp_multiplications); #else return 0; #endif } /**************************************************************************/ /* The following functions destroy and/or initialize the data that FFTW-MEX caches between calls. */ void destroy_fftw_mex_data(void) { if (output_work != input_work) fftw_free(output_work); if (input_work) fftw_free(input_work); if (p) fftw_destroy_plan(p); if (pnd) fftwnd_destroy_plan(pnd); if (ip) fftw_destroy_plan(ip); if (ipnd) fftwnd_destroy_plan(ipnd); cur_rank = 0; input_work = output_work = 0; ip = p = 0; ipnd = pnd = 0; } /* This function is called when MATLAB exits or the MEX file is cleared, in which case we want to dispose of all data and free any allocated blocks. */ void fftw_mex_exit_function(void) { if (!first_call) { destroy_fftw_mex_data(); fftw_forget_wisdom(); first_call = 1; } } #define MAGIC(x) #x #define STRINGIZE(x) MAGIC(x) /* Initialize the cached data each time the MEX file is called. First, we check if we have previously computed plans and data for these array dimensions. Only if the dimensions have changed since the last call must we recompute the plans, etc. */ void initialize_fftw_mex_data(int rank, const int *dims, fftw_direction dir) { int new_plan = 0; if (first_call) { /* The following things need only be done once: */ install_fftw_hooks(); mexAtExit(fftw_mex_exit_function); first_call = 0; } if (rank == 1) { if (cur_rank != 1 || cur_dims[0] != dims[0]) { destroy_fftw_mex_data(); cur_rank = 1; cur_dims[0] = cur_N = dims[0]; input_work = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * cur_N); output_work = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * cur_N); new_plan = 1; } else if (dir == FFTW_FORWARD && !p || dir == FFTW_BACKWARD && !ip) new_plan = 1; if (new_plan) { if (dir == FFTW_FORWARD) { p = fftw_create_plan(cur_N,dir, FFTW_MEASURE | FFTW_USE_WISDOM); fftw_mex_flops = compute_fftw_mex_flops(dir); } else { ip = fftw_create_plan(cur_N,dir, FFTW_MEASURE | FFTW_USE_WISDOM); ifftw_mex_flops = compute_fftw_mex_flops(dir); } } } else { int same_dims = 1, dim; if (cur_rank == rank) for (dim = 0; dim < rank && same_dims; ++dim) same_dims = (cur_dims[dim] == dims[rank-1-dim]); else same_dims = 0; if (!same_dims) { if (rank > MAX_RANK) mexErrMsgTxt("Sorry, dimensionality > " STRINGIZE(MAX_RANK) " is not supported."); destroy_fftw_mex_data(); cur_rank = rank; cur_N = 1; for (dim = 0; dim < rank; ++dim) cur_N *= (cur_dims[dim] = dims[rank-1-dim]); input_work = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * cur_N); output_work = input_work; new_plan = 1; } else if (dir == FFTW_FORWARD && !pnd || dir == FFTW_BACKWARD && !ipnd) new_plan = 1; if (new_plan) { if (dir == FFTW_FORWARD) { pnd = fftwnd_create_plan(rank,cur_dims,dir, FFTW_IN_PLACE | FFTW_MEASURE | FFTW_USE_WISDOM); fftw_mex_flops = compute_fftw_mex_flops(dir); } else { ipnd = fftwnd_create_plan(rank,cur_dims,dir, FFTW_IN_PLACE | FFTW_MEASURE | FFTW_USE_WISDOM); ifftw_mex_flops = compute_fftw_mex_flops(dir); } } } } /**************************************************************************/ /* MATLAB stores complex numbers as separate arrays for real and imaginary parts. The following functions take the data in this format and pack it into a fftw_complex work array, or unpack it, respectively. The globals input_work and output_work are used as the arrays to pack to/unpack from.*/ void pack_input_work(double *input_re, double *input_im) { int i; if (input_im) for (i = 0; i < cur_N; ++i) { c_re(input_work[i]) = input_re[i]; c_im(input_work[i]) = input_im[i]; } else for (i = 0; i < cur_N; ++i) { c_re(input_work[i]) = input_re[i]; c_im(input_work[i]) = 0.0; } } void unpack_output_work(double *output_re, double *output_im) { int i; for (i = 0; i < cur_N; ++i) { output_re[i] = c_re(output_work[i]); output_im[i] = c_im(output_work[i]); } } /**************************************************************************/ /* The following function is called by MATLAB when the FFTW MEX is invoked from within the program. The rhs parameters are the list of arrays on the right-hand-side (rhs) of the MATLAB command--the arguments to FFTW. The lhs parameters are the list of arrays on the left-hand-side (lhs) of the MATLAB command--these are what the output(s) of FFTW are assigned to. The syntax for the FFTW call in MATLAB is fftw(array,sign), as described in fftw.m */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int rank; const int *dims; int m, n; /* Array is m x n, C-ordered */ fftw_direction dir; if (nrhs != 2) mexErrMsgTxt("Two input arguments are expected."); if (!mxIsDouble(prhs[0])) mexErrMsgTxt("First input must be a double precision matrix."); if (mxIsSparse(prhs[0])) mexErrMsgTxt("Sorry, sparse matrices are not currently supported."); if (mxGetM(prhs[1]) * mxGetN(prhs[1]) != 1) mexErrMsgTxt("Second input must be a scalar (+/- 1)."); if (mxGetScalar(prhs[1]) > 0.0) dir = FFTW_BACKWARD; else dir = FFTW_FORWARD; if ((rank = mxGetNumberOfDimensions(prhs[0])) == 2) { int dims2[2]; m = mxGetM(prhs[0]); n = mxGetN(prhs[0]); if (m == 1 || n == 1) { dims2[0] = m * n; initialize_fftw_mex_data(1,dims2,dir); } else { dims2[0] = m; dims2[1] = n; initialize_fftw_mex_data(2,dims2,dir); } } else initialize_fftw_mex_data(rank,dims = mxGetDimensions(prhs[0]),dir); pack_input_work(mxGetPr(prhs[0]),mxGetPi(prhs[0])); if (dir == FFTW_FORWARD) { if (cur_rank == 1) fftw(p,1, input_work,1,0, output_work,1,0); else fftwnd(pnd,1, input_work,1,0, 0,0,0); mexAddFlops(fftw_mex_flops); } else { if (cur_rank == 1) fftw(ip,1, input_work,1,0, output_work,1,0); else fftwnd(ipnd,1, input_work,1,0, 0,0,0); mexAddFlops(ifftw_mex_flops); } /* Create a matrix for the return argument. */ if (cur_rank <= 2) plhs[0] = mxCreateDoubleMatrix(m, n, mxCOMPLEX); else plhs[0] = mxCreateNumericArray(rank,dims, mxDOUBLE_CLASS,mxCOMPLEX); unpack_output_work(mxGetPr(plhs[0]),mxGetPi(plhs[0])); }
{ "alphanum_fraction": 0.6144453837, "avg_line_length": 28.392, "ext": "c", "hexsha": "df86c33e40e5e25f118765a4a791922f9b3642c9", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3361d1f18bf529958b78231fdcf139b1c1c1f232", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "albertsgrc/ftdock-opt", "max_forks_repo_path": "original/lib/fftw-2.1.3/matlab/fftw.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "3361d1f18bf529958b78231fdcf139b1c1c1f232", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "albertsgrc/ftdock-opt", "max_issues_repo_path": "original/lib/fftw-2.1.3/matlab/fftw.c", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "3361d1f18bf529958b78231fdcf139b1c1c1f232", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "albertsgrc/ftdock-opt", "max_stars_repo_path": "original/lib/fftw-2.1.3/matlab/fftw.c", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2873, "size": 10647 }
#ifndef __CAD_UTILC_HH__ #define __CAD_UTILC_HH__ /********************************* TRICK HEADER ******************************* PURPOSE: (CAD Utility functions C Version) LIBRARY DEPENDENCY: ((../src/cad_utility_c.c) (../src/global_constants.c)) *******************************************************************************/ #include <gsl/gsl_vector.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> #include <math.h> #include <assert.h> #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif /** Global constants **/ extern const double __FLATTENING; extern const double __SMAJOR_AXIS; extern const double __SMALL; extern const double __RAD; extern const double __GM; /** Functions **/ int cad_in_geo84(const double lon, const double lat , const double alt, const gsl_matrix *TEI, gsl_vector *SBII); int cad_tdi84(const double lon, const double lat, const double alt, const gsl_matrix *TEI, gsl_matrix *TDI); int cad_geo84_in(const gsl_vector *SBII, const gsl_matrix *TEI, double *lon, double *lat, double *alt); int cad_kepler(const gsl_vector *SBII, const gsl_vector *VBII, const double tgo , gsl_vector *SPII, gsl_vector *VPII); #ifdef __cplusplus } #endif #endif // __CAD_UTILC_HH__
{ "alphanum_fraction": 0.6408227848, "avg_line_length": 32.4102564103, "ext": "h", "hexsha": "c42c0f357482639e15ba2c94d5f3b9711e830c78", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-06-17T03:19:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-05-05T14:59:37.000Z", "max_forks_repo_head_hexsha": "e8552a5804184b30022d103d47c8728fb242b5bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "cihuang123/Next-simulation", "max_forks_repo_path": "models/cad/include/cad_utility_c.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "e8552a5804184b30022d103d47c8728fb242b5bc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "cihuang123/Next-simulation", "max_issues_repo_path": "models/cad/include/cad_utility_c.h", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "e8552a5804184b30022d103d47c8728fb242b5bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "cihuang123/Next-simulation", "max_stars_repo_path": "models/cad/include/cad_utility_c.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 308, "size": 1264 }
/* Copyright (C) 2002 M. Marques, A. Castro, A. Rubio, G. Bertsch 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 2, 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. $Id$ */ #ifndef _LIB_OCT_H #define _LIB_OCT_H #include <gsl/gsl_complex.h> int parse_init (char *file_out, int *mpiv_node); int parse_input (char *file_in); void parse_end (void); int parse_isdef (char *name); int parse_int (char *name, int def); double parse_double (char *name, double def); gsl_complex parse_complex(char *name, gsl_complex def); char *parse_string (char *name, char *def); /* Now comes stuff for the blocks */ typedef struct sym_block_line{ int n; char **fields; } sym_block_line; typedef struct sym_block{ int n; sym_block_line *lines; } sym_block; int parse_block (char *name, sym_block **blk); int parse_block_end (sym_block **blk); int parse_block_n (sym_block *blk); int parse_block_cols (sym_block *blk, int l); int parse_block_int (sym_block *blk, int l, int col, int *r); int parse_block_double (sym_block *blk, int l, int col, double *r); int parse_block_complex(sym_block *blk, int l, int col, gsl_complex *r); int parse_block_string (sym_block *blk, int l, int col, char **r); /* from parse_exp.c */ enum pr_type {PR_NONE,PR_CMPLX, PR_STR}; typedef struct parse_result{ union { gsl_complex c; char *s; } value; enum pr_type type; } parse_result; void parse_result_free(parse_result *t); int parse_exp(char *exp, parse_result *t); void parse_putsym_int(char *s, int i); void parse_putsym_double(char *s, double d); void parse_putsym_complex(char *s, gsl_complex c); #endif
{ "alphanum_fraction": 0.719205298, "avg_line_length": 29.8026315789, "ext": "h", "hexsha": "caedf842cb2bd14e3a55b845a4e85cc0add74ce4", "lang": "C", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "25cb84cf590276af9ce4617039ba3849e328594c", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "neelravi/octopus", "max_forks_repo_path": "liboct_parser/liboct_parser.h", "max_issues_count": null, "max_issues_repo_head_hexsha": "25cb84cf590276af9ce4617039ba3849e328594c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "neelravi/octopus", "max_issues_repo_path": "liboct_parser/liboct_parser.h", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "25cb84cf590276af9ce4617039ba3849e328594c", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "neelravi/octopus", "max_stars_repo_path": "liboct_parser/liboct_parser.h", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 590, "size": 2265 }
#include <stdlib.h> #include <stdio.h> #include <math.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_spline.h> #define N 8 int main (void) { int i; double xi, yi; double x[N] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; double y[N] = { 0.0, 0.0, 2.0, 0.0,-1.0,-2.0,-1.0, 0.0 }; printf ("#m=0,S=2\n"); for (i = 0; i < N; i++) { printf ("%g %g\n", x[i], y[i]); } printf ("#m=1,S=0\n"); { gsl_interp_accel *acc = gsl_interp_accel_alloc (); gsl_spline *spline = gsl_spline_alloc (gsl_interp_akima, N); gsl_spline_init (spline, x, y, N); for (xi = x[0]; xi < x[N-1]; xi += 0.01) { double yi = gsl_spline_eval (spline, xi, acc); printf ("%g %g\n", xi, yi); } gsl_spline_free (spline); gsl_interp_accel_free(acc); } }
{ "alphanum_fraction": 0.5310945274, "avg_line_length": 20.1, "ext": "c", "hexsha": "643236effa1ab406b542f64b22df97b4ea731a1c", "lang": "C", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-02-14T12:31:02.000Z", "max_forks_repo_forks_event_min_datetime": "2021-01-20T16:22:57.000Z", "max_forks_repo_head_hexsha": "df1bbf6bea0b87b8c7c9a99dce213fdc249118f2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "zzpwahaha/Chimera-Control-Trim", "max_forks_repo_path": "Chimera/3rd_Party/GSL_MSVC/interpolation/demo2.c", "max_issues_count": null, "max_issues_repo_head_hexsha": "df1bbf6bea0b87b8c7c9a99dce213fdc249118f2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "zzpwahaha/Chimera-Control-Trim", "max_issues_repo_path": "Chimera/3rd_Party/GSL_MSVC/interpolation/demo2.c", "max_line_length": 64, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df1bbf6bea0b87b8c7c9a99dce213fdc249118f2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "zzpwahaha/Chimera-Control-Trim", "max_stars_repo_path": "Chimera/3rd_Party/GSL_MSVC/interpolation/demo2.c", "max_stars_repo_stars_event_max_datetime": "2021-06-14T11:51:37.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-14T11:51:37.000Z", "num_tokens": 327, "size": 804 }
#ifndef CIMPLE_CIMPLE_AUXILIARY_FUNCTIONS_H #define CIMPLE_CIMPLE_AUXILIARY_FUNCTIONS_H /** * @brief Macro computes number of an array. * * Remark: It is defined as a Macro so that it can be used independently of the type of the array * e.g. int a[2]; =>N_ELEMS(a)=2 * polytope b[3]; =>N_ELEMS(a)=2 (this is an array of 3 polytopes that's why it is not "polytope*") */ #define N_ELEMS(x) (sizeof(x) / sizeof((x)[0])) #include <stdio.h> #include <string.h> #include <pthread.h> #include <stddef.h> #include <math.h> #include <stdbool.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> /** * @brief Generates random numbers with normal distribution * @param mu * @param sigma * @return */ double randn (double mu, double sigma); /** * @brief Timer simulating one time step in discrete control * @param arg * @return */ void * timer(void * arg); /** * @brief Breaks infinte loop in a pthread * @param mtx * @return */ int needQuit(pthread_mutex_t *mtx); #endif //CIMPLE_CIMPLE_AUXILIARY_FUNCTIONS_H
{ "alphanum_fraction": 0.6867239733, "avg_line_length": 22.7608695652, "ext": "h", "hexsha": "5709aa83f1dde0d888137b30e2e82fa7638b2b1a", "lang": "C", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-10-06T12:58:52.000Z", "max_forks_repo_forks_event_min_datetime": "2018-10-06T12:58:52.000Z", "max_forks_repo_head_hexsha": "56cf4d58a9d7e17b6f6aebe6de8d5a1231035671", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shaesaert/TuLiPXML", "max_forks_repo_path": "Interface/Cimple/cimple_auxiliary_functions.h", "max_issues_count": 2, "max_issues_repo_head_hexsha": "56cf4d58a9d7e17b6f6aebe6de8d5a1231035671", "max_issues_repo_issues_event_max_datetime": "2018-08-21T09:50:09.000Z", "max_issues_repo_issues_event_min_datetime": "2017-10-03T18:54:08.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shaesaert/TuLiPXML", "max_issues_repo_path": "Interface/Cimple/cimple_auxiliary_functions.h", "max_line_length": 104, "max_stars_count": 1, "max_stars_repo_head_hexsha": "56cf4d58a9d7e17b6f6aebe6de8d5a1231035671", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shaesaert/TuLiPXML", "max_stars_repo_path": "Interface/Cimple/cimple_auxiliary_functions.h", "max_stars_repo_stars_event_max_datetime": "2021-05-28T23:44:28.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-28T23:44:28.000Z", "num_tokens": 300, "size": 1047 }