text:
#pragma once

#include <utility>
#include <initializer_list>
#include <exception>
#include <iostream>
#include <cmath>

#include <gsl/gsl_math.h>
#include <gsl/gsl_linalg.h>

#include "bits/matrix-view.h"
#include "utils/fcmp.h"
#include "vector.h"

namespace gsl_wrapper
{
  class Matrix
  {
  public:
    // Constructors and destructor
    Matrix(size_t i, size_t j);
    Matrix(size_t matrix_size);
    Matrix(std::initializer_list<std::initializer_list<double>> args);
    Matrix(const Vector &vec);

    Matrix(const Matrix &copy_from);
    Matrix(Matrix &&move_from);

    ~Matrix();

    // Member functions
    auto get_gsl_matrix() const -> gsl_matrix *;
    auto get_dimensions() const -> std::pair<size_t, size_t>;
    auto num_rows() const -> size_t;
    auto num_collumns() const -> size_t;

    // Operators
    auto operator=(const Matrix &copy_from) -> Matrix &;
    auto operator=(Matrix &&move_from) -> Matrix &;

    auto operator==(const Matrix &comparasion_matrix) const -> bool;
    auto operator!=(const Matrix &comparasion_matrix) const -> bool;

    auto operator[](const size_t index) const -> gsl_wrapper::bits::MatrixRow;
    auto operator*(const Matrix &mul) const -> Matrix;
    auto operator*(const double number) const -> Matrix;
    auto operator+(const Matrix &matrix) const -> Matrix;
    auto operator+(const double numer) const -> Matrix;

    // Friend declarations
    friend auto operator<<(std::ostream &stream, const Matrix &matrix) -> std::ostream &;
    friend auto operator*(const double number, const Matrix &matrix) -> Matrix;
    friend auto operator+(const double number, const Matrix &matrix) -> Matrix;

  private:
    gsl_matrix *m_matrixPtr;
    size_t m_numRows;
    size_t m_numCollumns;
  };

  inline Matrix::Matrix(size_t i, size_t j)
      : m_matrixPtr{gsl_matrix_calloc(i, j)}, m_numRows{i}, m_numCollumns{j}
  {
  }

  inline Matrix::Matrix(size_t matrix_size)
      : Matrix(matrix_size, matrix_size)
  {
  }

  inline Matrix::Matrix(std::initializer_list<std::initializer_list<double>> args)
      : m_matrixPtr{nullptr}, m_numCollumns{0}, m_numRows{0}
  {
    if (args.size() == 0)
      return;
    size_t num_rows = args.size();
    size_t num_collumns = (*args.begin()).size();

    // Setting object properties
    m_numCollumns = num_collumns;
    m_numRows = num_rows;
    m_matrixPtr = gsl_matrix_calloc(m_numRows, m_numCollumns);

    size_t row_iterator = 0;
    size_t collumn_iterator = 0;
    for (auto &&row : args)
    {
      if (row.size() != num_collumns)
        throw std::range_error{"Diffrent number of items in diffrent rows when creating matrix"};

      for (auto &&el : row)
      {
        (*this)[row_iterator][collumn_iterator++] = el;
      }
      collumn_iterator = 0;
      ++row_iterator;
    }
  }

  inline Matrix::Matrix(const Vector &vec)
      : m_matrixPtr{gsl_matrix_calloc(vec.size(), 1)},
        m_numCollumns{1},
        m_numRows{vec.size()}
  {
    for (size_t i = 0; i < m_numRows; i++)
    {
      (*this)[i][0] = vec[i];
    }
  }

  inline Matrix::Matrix(const Matrix &copy_from)
      : m_matrixPtr{gsl_matrix_calloc(copy_from.m_numRows, copy_from.m_numCollumns)},
        m_numRows{copy_from.m_numRows},
        m_numCollumns{copy_from.m_numCollumns}
  {
    gsl_matrix_memcpy(m_matrixPtr, copy_from.m_matrixPtr);
  }

  inline Matrix::Matrix(Matrix &&move_from)
      : m_matrixPtr{std::exchange(move_from.m_matrixPtr, nullptr)},
        m_numRows{std::exchange(move_from.m_numRows, 0)},
        m_numCollumns{std::exchange(move_from.m_numCollumns, 0)}
  {
  }

  inline Matrix::~Matrix()
  {
    gsl_matrix_free(m_matrixPtr);
  }

  inline auto Matrix::get_gsl_matrix() const -> gsl_matrix *
  {
    return m_matrixPtr;
  }

  inline auto Matrix::get_dimensions() const -> std::pair<size_t, size_t>
  {
    return {m_numRows, m_numCollumns};
  }

  inline auto Matrix::num_rows() const -> size_t
  {
    return m_numRows;
  }
  inline auto Matrix::num_collumns() const -> size_t
  {
    return m_numCollumns;
  }

  inline auto Matrix::operator=(const Matrix &copy_from) -> Matrix &
  {
    // Prevent self copy
    if (m_matrixPtr == copy_from.m_matrixPtr)
      return *this;

    gsl_matrix_free(m_matrixPtr);
    m_matrixPtr = gsl_matrix_calloc(copy_from.m_numRows, copy_from.m_numCollumns);
    gsl_matrix_memcpy(m_matrixPtr, copy_from.m_matrixPtr);

    m_numCollumns = copy_from.m_numCollumns;
    m_numRows = copy_from.m_numRows;

    return *this;
  }

  inline auto Matrix::operator=(Matrix &&move_from) -> Matrix &
  {
    // Prevent self move
    if (m_matrixPtr == move_from.m_matrixPtr)
      return *this;

    gsl_matrix_free(m_matrixPtr);
    m_matrixPtr = std::exchange(move_from.m_matrixPtr, nullptr);
    m_numRows = std::exchange(move_from.m_numRows, 0);
    m_numCollumns = std::exchange(move_from.m_numCollumns, 0);

    return *this;
  }

  inline auto Matrix::operator==(const Matrix &comparasion_matrix) const -> bool
  {

    if ((m_numCollumns != comparasion_matrix.m_numCollumns) || (m_numRows != comparasion_matrix.m_numRows))
      return false;

    for (size_t i = 0; i < m_numRows; i++)
    {
      for (size_t j = 0; j < m_numCollumns; j++)
      {
        bool test = ::gsl_wrapper::utils::equal((*this)[i][j], comparasion_matrix[i][j]);
        if (!test)
          return false;
      }
    }
    return true;
  }

  inline auto Matrix::operator!=(const Matrix &comparasion_matrix) const -> bool
  {
    return !(*this == comparasion_matrix);
  }

  inline auto Matrix::operator[](const size_t index) const -> gsl_wrapper::bits::MatrixRow
  {
    using bits::MatrixRow;
    gsl_vector_view view = gsl_matrix_row(m_matrixPtr, index);
    return MatrixRow(view);
  }

  inline auto Matrix::operator*(const Matrix &mul) const -> Matrix
  {
    // Check sizes
    if (m_numCollumns != mul.m_numRows)
      throw std::runtime_error{"Wrong matrix sizes!"};

    Matrix result(m_numRows, mul.m_numCollumns);
    gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, m_matrixPtr, mul.m_matrixPtr, 0.0, result.get_gsl_matrix());

    return result;
  }

  inline auto Matrix::operator*(const double number) const -> Matrix
  {
    Matrix result = *this;
    for (size_t i = 0; i < m_numRows; i++)
    {
      for (size_t j = 0; j < m_numCollumns; j++)
      {
        result[i][j] *= number;
      }
    }

    return result;
  }

  inline auto Matrix::operator+(const Matrix &matrix) const -> Matrix
  {
    if ((m_numCollumns != matrix.m_numCollumns) || (m_numRows != matrix.m_numRows))
      throw std::range_error{"Wrong matrix sizes when adding"};

    Matrix result = *this;
    gsl_matrix_add(result.m_matrixPtr, matrix.m_matrixPtr);

    return result;
  }

  inline auto Matrix::operator+(const double number) const -> Matrix
  {
    Matrix result = *this;
    for (size_t i = 0; i < m_numRows; i++)
    {
      for (size_t j = 0; j < m_numCollumns; j++)
      {
        result[i][j] += number;
      }
    }

    return result;
  }

  inline auto operator<<(std::ostream &stream, const Matrix &matrix) -> std::ostream &
  {
    for (size_t i = 0; i < matrix.m_numRows; i++)
    {
      for (size_t j = 0; j < matrix.m_numCollumns; j++)
      {
        stream << matrix[i][j] << " ";
      }
      stream << std::endl;
    }

    return stream;
  }

  inline auto operator*(const double number, const Matrix &matrix) -> Matrix
  {
    Matrix result = matrix;
    for (size_t i = 0; i < matrix.m_numRows; i++)
    {
      for (size_t j = 0; j < matrix.m_numCollumns; j++)
      {
        result[i][j] *= number;
      }
    }

    return result;
  }

  inline auto operator+(const double number, const Matrix &matrix) -> Matrix
  {
    Matrix result = matrix;
    for (size_t i = 0; i < matrix.m_numRows; i++)
    {
      for (size_t j = 0; j < matrix.m_numCollumns; j++)
      {
        result[i][j] += number;
      }
    }

    return result;
  }
}


text:
/* block/test.c
 *
 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 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 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 <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <gsl/gsl_block.h>
#include <gsl/gsl_ieee_utils.h>
#include <gsl/gsl_test.h>

int status = 0;

#ifndef DESC
#define DESC ""
#endif

#define N 1027

#define BASE_GSL_COMPLEX_LONG
#include "templates_on.h"
#include "test_complex_source.c"
#if HAVE_PRINTF_LONGDOUBLE
#include "test_complex_io.c"
#endif
#include "templates_off.h"
#undef  BASE_GSL_COMPLEX_LONG

#define BASE_GSL_COMPLEX
#include "templates_on.h"
#include "test_complex_source.c"
#include "test_complex_io.c"
#include "templates_off.h"
#undef  BASE_GSL_COMPLEX

#define BASE_GSL_COMPLEX_FLOAT
#include "templates_on.h"
#include "test_complex_source.c"
#include "test_complex_io.c"
#include "templates_off.h"
#undef  BASE_GSL_COMPLEX_FLOAT

#define BASE_LONG_DOUBLE
#include "templates_on.h"
#include "test_source.c"
#if HAVE_PRINTF_LONGDOUBLE
#include "test_io.c"
#endif
#include "templates_off.h"
#undef  BASE_LONG_DOUBLE

#define BASE_DOUBLE
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_DOUBLE

#define BASE_FLOAT
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_FLOAT

#define BASE_ULONG
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_ULONG

#define BASE_LONG
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_LONG

#define BASE_UINT
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_UINT

#define BASE_INT
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_INT

#define BASE_USHORT
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_USHORT

#define BASE_SHORT
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_SHORT

#define BASE_UCHAR
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_UCHAR

#define BASE_CHAR
#include "templates_on.h"
#include "test_source.c"
#include "test_io.c"
#include "templates_off.h"
#undef  BASE_CHAR

void my_error_handler (const char *reason, const char *file,
                       int line, int err);

int
main (void)
{
  gsl_ieee_env_setup ();

  test_func ();
  test_float_func ();
  test_long_double_func ();
  test_ulong_func ();
  test_long_func ();
  test_uint_func ();
  test_int_func ();
  test_ushort_func ();
  test_short_func ();
  test_uchar_func ();
  test_char_func ();
  test_complex_func ();
  test_complex_float_func ();
  test_complex_long_double_func ();

  test_text ();
  test_float_text ();
#if HAVE_PRINTF_LONGDOUBLE
  test_long_double_text ();
#endif
  test_ulong_text ();
  test_long_text ();
  test_uint_text ();
  test_int_text ();
  test_ushort_text ();
  test_short_text ();
  test_uchar_text ();
  test_char_text ();
  test_complex_text ();
  test_complex_float_text ();
#if HAVE_PRINTF_LONGDOUBLE
  test_complex_long_double_text ();
#endif

  test_binary ();
  test_float_binary ();
  test_long_double_binary ();
  test_ulong_binary ();
  test_long_binary ();
  test_uint_binary ();
  test_int_binary ();
  test_ushort_binary ();
  test_short_binary ();
  test_uchar_binary ();
  test_char_binary ();
  test_complex_binary ();
  test_complex_float_binary ();
  test_complex_long_double_binary ();

  gsl_set_error_handler (&my_error_handler);

  test_alloc_zero_length ();
  test_float_alloc_zero_length ();
  test_long_double_alloc_zero_length ();
  test_ulong_alloc_zero_length ();
  test_long_alloc_zero_length ();
  test_uint_alloc_zero_length ();
  test_int_alloc_zero_length ();
  test_ushort_alloc_zero_length ();
  test_short_alloc_zero_length ();
  test_uchar_alloc_zero_length ();
  test_char_alloc_zero_length ();
  test_complex_alloc_zero_length ();
  test_complex_float_alloc_zero_length ();
  test_complex_long_double_alloc_zero_length ();

  test_calloc_zero_length ();
  test_float_calloc_zero_length ();
  test_long_double_calloc_zero_length ();
  test_ulong_calloc_zero_length ();
  test_long_calloc_zero_length ();
  test_uint_calloc_zero_length ();
  test_int_calloc_zero_length ();
  test_ushort_calloc_zero_length ();
  test_short_calloc_zero_length ();
  test_uchar_calloc_zero_length ();
  test_char_calloc_zero_length ();
  test_complex_calloc_zero_length ();
  test_complex_float_calloc_zero_length ();
  test_complex_long_double_calloc_zero_length ();

  exit (gsl_test_summary ());
}

void
my_error_handler (const char *reason, const char *file, int line, int err)
{
  if (0)
    printf ("(caught [%s:%d: %s (%d)])\n", file, line, reason, err);
  status = 1;
}

ext: c

max_stars_repo_name: utdsimmons/ohpc

max_issues_repo_name: utdsimmons/ohpc

max_forks_repo_name: utdsimmons/ohpc


text:
#include <gsl/gsl_spline.h>
#include <galpy_potentials.h>
// interpSphericalPotential: 6 arguments: amp (not used here), rmin, rmax,
// M(<rmax), Phi0, Phimax
double interpSphericalPotentialrevaluate(double r,double t,
					 struct potentialArg * potentialArgs){
  double * args= potentialArgs->args;
  //Get args
  double rmin= *(args+1);
  double rmax= *(args+2);
  double Mmax= *(args+3);
  double Phi0= *(args+4);
  double Phimax= *(args+5);
  if ( r >= rmax ) {
    return -Mmax/r+Phimax;
  }
  else {
    return r < rmin ? 0. : \
      -gsl_spline_eval_integ(*potentialArgs->spline1d,
			     rmin,r,*potentialArgs->acc1d) + Phi0;
  }
}
double interpSphericalPotentialrforce(double r,double t,
				      struct potentialArg * potentialArgs){
  double * args= potentialArgs->args;
  //Get args
  double rmin= *(args+1);
  double rmax= *(args+2);
  double Mmax= *(args+3);
  if ( r >= rmax ) {
    return -Mmax/r/r;
  }
  else {
    return r < rmin ? 0. : gsl_spline_eval(*potentialArgs->spline1d,
					   r,*potentialArgs->acc1d);
  }
}
double interpSphericalPotentialr2deriv(double r,double t,
				       struct potentialArg * potentialArgs){
  double * args= potentialArgs->args;
  //Get args
  double rmin= *(args+1);
  double rmax= *(args+2);
  double Mmax= *(args+3);
  if ( r >= rmax ) {
    return -2. * Mmax / r / r / r;
  }
  else {
    return r < rmin ? 0. : -gsl_spline_eval_deriv(*potentialArgs->spline1d,
						  r,*potentialArgs->acc1d);
  }
}
double interpSphericalPotentialrdens(double r,double t,
				     struct potentialArg * potentialArgs){
  double * args= potentialArgs->args;
  //Get args
  double rmin= *(args+1);
  double rmax= *(args+2);
  if ( r >= rmax ) {
    return 0.;
  }
  else {
    return r < rmin ? 0. : M_1_PI / 4. \
      * ( interpSphericalPotentialr2deriv(r,t,potentialArgs)
	  - 2. * interpSphericalPotentialrforce(r,t,potentialArgs)/r);
  }
}

max_stars_repo_name: gusbeane/galpy

max_issues_repo_name: gusbeane/galpy

max_forks_repo_name: gusbeane/galpy


text:
#include "solver_intern.h"
#include <pygsl/general_helpers.h>
#include <pygsl/block_helpers.h>
#if 0
#include <pygsl/function_helpers.h>
#endif
#include <setjmp.h>
#include <gsl/gsl_math.h>
#include <pygsl/error_helpers.h>
#include <strings.h>
#include "solver_doc.ic"

PyObject * module = NULL;
const char *filename = __FILE__;

static int
PyGSL_solver_set_called(PyGSL_solver *self)
{
     FUNC_MESS_BEGIN();
     if(self->set_called == 1)
	  return GSL_SUCCESS;
     DEBUG_MESS(2, "self->set_called was %d", self->set_called);
     pygsl_error("The set() method must be called before using the other methods!",
	       filename, __LINE__, GSL_EINVAL);
     FUNC_MESS_END();
     return GSL_EINVAL;
}

static PyObject*
PyGSL_solver_restart(PyGSL_solver *self, PyObject *args)
{
     FUNC_MESS_BEGIN();
     if (PyGSL_SOLVER_SET_CALLED(self) != GSL_SUCCESS)
	  return NULL;

     if(self->mstatic->cmethods.restart == NULL)
	  PyGSL_ERROR_NULL("Can not restart a solver of this type!", GSL_ESANITY);
     self->mstatic->cmethods.restart(self->solver);
     Py_INCREF(Py_None);
     FUNC_MESS_END();
     return Py_None;
}

static PyObject*
PyGSL_solver_name(PyGSL_solver *self, PyObject *args)
{
     PyObject * tmp;
     const char * ctmp;
     FUNC_MESS_BEGIN();
     if(self->mstatic->cmethods.name == NULL)
	  PyGSL_ERROR_NULL("Can not restart a solver of this type!", GSL_ESANITY);
     ctmp = self->mstatic->cmethods.name(self->solver);
     tmp =  PyString_FromString(ctmp);
     FUNC_MESS_END();
     return tmp;
}

static PyObject*
PyGSL_solver_iterate(PyGSL_solver *self, PyObject *args)
{
     int tmp;
     FUNC_MESS_BEGIN();
     if (PyGSL_SOLVER_SET_CALLED(self) != GSL_SUCCESS)
	  return NULL;

     if(self->mstatic->cmethods.iterate == NULL)
	  PyGSL_ERROR_NULL("Can not restart a solver of this type!", GSL_ESANITY);

     assert(self->mstatic->cmethods.iterate);
     assert(self->solver);
     tmp = (self->mstatic->cmethods.iterate(self->solver));
     if(PyGSL_ERROR_FLAG(tmp) != GSL_SUCCESS)
	  return NULL;

     return PyInt_FromLong((long) tmp);
}

static void
PyGSL_solver_dealloc(PyGSL_solver * self)
{
     /* struct pygsl_array_cache * cache_ptr;
     int i, count;
     PyObject * ob;
     PyArrayObject *tmp;
     */
     FUNC_MESS_BEGIN();
     assert(self);
     assert(self->mstatic);

     if(self->mstatic->cmethods.free == NULL){
	  DEBUG_MESS(3, "Could not free solver @ %p. No free method specified!", self->solver);
     }else{
	  DEBUG_MESS(3, "Freeing a solver of type %s", self->mstatic->type_name);
	  if(self->solver != NULL){
	       self->mstatic->cmethods.free(self->solver);
	       self->solver = NULL;
	  }
     }

     Py_XDECREF(self->args);
     self->args = NULL;
     if(self->c_sys){
	  DEBUG_MESS(3, "Freeing c_sys @ %p", self->c_sys);
	  free(self->c_sys);
	  self->c_sys = NULL;
     }

     /*
      * remove the cached arrays
      */
     if(self->cache == NULL){
	  DEBUG_MESS(2, "No cache was used cache = %p", self->cache);
     }else{
#if 0
	  cache_ptr = self->cache;
	  for(i = 0; i< PyGSL_SOLVER_N_ARRAYS; ++i){
	       tmp =  cache_ptr[i].ref;
	       ob = (PyObject *) tmp;
	       if(ob == NULL){
		    break;
	       }
	       count =  ob->ob_refcnt;
	       if(count == 0){
		    DEBUG_MESS(3, "object[%d] @ %p has a zero reference count!"
			       " array should be deposed already and ptr set to zero!", i, ob);
	       }else if(count == 1){
		    /* no one referencing the array; good */
		    DEBUG_MESS(3, "Dereferencing  object[%d] @ %p", i, ob);
		    Py_DECREF(ob);
		    cache_ptr[i].ref = NULL;
	       }else if(count < 0){
		    DEBUG_MESS(2, "I found an array (object) at %p which had "
			       "a count [%d] smaller than zero", ob, count);

	       }else{
		    /* count > 1 */
		    fprintf(stderr, "In %s at %d array %d had %d refcouts.\n"
			    "This means you reference an array which was\n"
			    "passed to you while evaluating your callback.\n"
			    "This produces a memory leak!\n",
			    __FILE__, __LINE__, i, count);

	       }
	  } /* handeled cached objects */
	  fprintf(stderr, "Freed %d cached objects\n", i);
	  /* free the cache */
	  free(self->cache);
	  self->cache = NULL;
#endif

     } /* freeing cached objects */
     PyObject_Del(self);
     self = NULL;
     FUNC_MESS_END();

}

static PyObject *
PyGSL_solver_type(PyGSL_solver * self, PyObject *unused)
{
     assert(self->mstatic->type_name);
     return PyString_FromString(self->mstatic->type_name);
}

static PyMethodDef solver_methods[] = {
     {"name",    (PyCFunction) PyGSL_solver_name,    METH_NOARGS, NULL},
     {"restart", (PyCFunction) PyGSL_solver_restart, METH_NOARGS, NULL},
     {"iterate", (PyCFunction) PyGSL_solver_iterate, METH_NOARGS, NULL},
     {"type",    (PyCFunction) PyGSL_solver_type,    METH_NOARGS, NULL},
     {NULL, NULL, 0, NULL}
};
static PyObject *
PyGSL_solver_getattr(PyGSL_solver * self, char * name)
{
     PyObject *tmp = NULL;
     FUNC_MESS_BEGIN();
     if(self->mstatic->pymethods)
	  tmp = Py_FindMethod(self->mstatic->pymethods, (PyObject *) self, name);
     if(tmp == NULL){
	  PyErr_Clear();
	  tmp = Py_FindMethod(solver_methods, (PyObject *) self, name);
     }
     FUNC_MESS_END();
     return tmp;
}

static PyTypeObject PyGSL_solver_pytype = {
  PyObject_HEAD_INIT(NULL)	 /* fix up the type slot in initcrng */
  0,				 /* ob_size */
  "PyGSL_solver",		 /* tp_name */
  sizeof(PyGSL_solver),	 /* tp_basicsize */
  0,				 /* tp_itemsize */

  /* standard methods */
  (destructor)  PyGSL_solver_dealloc, /* tp_dealloc  ref-count==0  */
  (printfunc)   0,		 /* tp_print    "print x"     */
  (getattrfunc) PyGSL_solver_getattr,/* tp_getattr  "x.attr"      */
  (setattrfunc) 0,		 /* tp_setattr  "x.attr=v"    */
  (cmpfunc)     0,		   /* tp_compare  "x > y"       */
  (reprfunc)    0,                 /* tp_repr     `x`, print x  */

  /* type categories */
  0,				/* tp_as_number   +,-,*,/,%,&,>>,pow...*/
  0,				/* tp_as_sequence +,[i],[i:j],len, ...*/
  0,				/* tp_as_mapping  [key], len, ...*/

  /* more methods */
  (hashfunc)     0,		/* tp_hash    "dict[x]" */
  (ternaryfunc)  0,      /* tp_call    "x()"     */
  (reprfunc)     0,             /* tp_str     "str(x)"  */
  (getattrofunc) 0,		/* tp_getattro */
  (setattrofunc) 0,		/* tp_setattro */
  0,				/* tp_as_buffer */
  0L,				/* tp_flags */
  (char *) PyGSL_solver_type_doc		/* tp_doc */
};

PyGSL_solver*
_PyGSL_solver_init(const struct _SolverStatic *mstatic)
{
     PyGSL_solver *solver_o=NULL;
     int line = -1;
     int i;

     FUNC_MESS_BEGIN();
     if(mstatic->n_cbs > PyGSL_SOLVER_NCBS_MAX){
	  line = __LINE__ - 1;
	  pygsl_error("More callbacks requested than possible!", __FILE__,
		    line, GSL_ESANITY);
	  goto fail;
     }
     solver_o =  (PyGSL_solver *) PyObject_NEW(PyGSL_solver, &PyGSL_solver_pytype);
     if(solver_o == NULL){
	  line = __LINE__ -1;
	  goto fail;
     }

     solver_o->args = NULL;
     solver_o->cache = NULL;
     solver_o->mstatic = NULL;
     solver_o->mstatic = mstatic;
     solver_o->solver = NULL;
     solver_o->c_sys = NULL;
     solver_o->set_called = 0;
     solver_o->isset = 0;

     for(i = 0; i < PyGSL_SOLVER_NCBS_MAX; ++i){
	  solver_o->cbs[i] = NULL;
     }

     for(i = 0; i < PyGSL_SOLVER_PB_ND_MAX; ++i){
	  solver_o->problem_dimensions[i] = -1;
     }

     DEBUG_MESS(3, "refcount = %d", solver_o->ob_refcnt);
     FUNC_MESS_END();
     return solver_o;
 fail:
     FUNC_MESS("Fail");
     PyGSL_add_traceback(module, __FILE__, __FUNCTION__, line);
     return NULL;
}

static PyObject *
PyGSL_solver_dn_init(PyObject *self, PyObject *args, const solver_alloc_struct * alloc, int nd)
{
     PyGSL_solver *solver_o=NULL;
     int n1=1, n2=1;
     int line = -1;
     int flag=0;

     FUNC_MESS_BEGIN();
     assert(alloc);
     solver_o =  _PyGSL_solver_init(alloc->mstatic);
     if(solver_o == NULL){
	  line = __LINE__ - 2;
	  goto fail;
     }
     switch(nd){
     case 0: flag = 1; break;
     case 1: flag = PyArg_ParseTuple(args,"i", &n1); break;
     case 2: flag = PyArg_ParseTuple(args,"ii", &n1, &n2); break;
     case 3:
	  /* odeiv */
	  flag = 1; break;
     default:
	  line = __LINE__;
	  pygsl_error("Only 1 or two for number of problem_dimensions implemented!",
		    __FILE__, line, GSL_ESANITY);
	  goto fail;
     }
     if (0==flag){
	  /* Successful parsing of the arguments ?*/
	  line = __LINE__ - 1;
	  goto fail;
     }
     if (n1<=0) {
	  PyErr_SetString(PyExc_RuntimeError, "dimension 1 must be >0");
	  line = __LINE__ - 2;
	  goto fail;
     }
     if (n2<=0) {
	  PyErr_SetString(PyExc_RuntimeError, "dimension 2 must be >0");
	  line = __LINE__ - 2;
	  goto fail;
     }
     {
	  void *tmp = alloc->alloc;
	  switch(nd){
	  case 0:
	       solver_o->solver =  ((void_a_t)(tmp))(alloc->type);
	       break;
	  case 1:
	       solver_o->solver =  (void *) ((void_an_t) tmp)(alloc->type, n1);
	       break;
	  case 2:
	       DEBUG_MESS(3, "Allocating solver with N=%d, p=%d", n1, n2);
	       solver_o->solver =  (void *) ((void_anp_t) tmp)(alloc->type, n1, n2);
	       break;
	  case 3:
	       /* odeiv handles that itself */
	       break;
	  default:
	       pygsl_error("Only 0,1 or 2 for number of problem_dimensions implemented!",
			 __FILE__, __LINE__, GSL_ESANITY);
	       goto fail;
	  }
     }

     switch(nd){
     case 1:
     case 2:
	  if(solver_o->solver == NULL){
	       line = __LINE__ - 1;
	       goto fail;
	  }
	  break;
     default:
	  ;
     }
     switch(nd){
     case 1:
	  solver_o->problem_dimensions[0] = n1;
	  break;
     case 2:
	  solver_o->problem_dimensions[0] = n2;
	  solver_o->problem_dimensions[1] = n1;
	  break;
     default:
	  ;
     }

     solver_o->cache = (struct pygsl_array_cache *) calloc(PyGSL_SOLVER_N_ARRAYS, sizeof(struct pygsl_array_cache));
     if(solver_o->cache == NULL){
	  PyErr_NoMemory();
	  line = __LINE__ - 1;
	  goto fail;
     }

     FUNC_MESS_END();
     return (PyObject *) solver_o;
 fail:
     FUNC_MESS("Fail");
     DEBUG_MESS(3, "line was %d", line);
     PyGSL_add_traceback(module, __FILE__, __FUNCTION__, line);
     Py_XDECREF(solver_o);
     return NULL;
}

#if 0
static PyObject *
_PyGSL_solver_np_init(PyObject *self, PyObject *args, const solver_alloc_struct * alloc)
{
    FUNC_MESS_BEGIN();
    return PyGSL_solver_dn_init(self, args, alloc, 2);
    FUNC_MESS_END();
}

static PyObject *
PyGSL_solver_n_init(PyObject *self, PyObject *args, const solver_alloc_struct * alloc)
{
     FUNC_MESS_BEGIN();
     return PyGSL_solver_dn_init(self, args, alloc, 1);
     FUNC_MESS_END();
}

static PyObject *
_PyGSL_solver_1_init(PyObject *self, PyObject *args, const solver_alloc_struct * alloc)
{
     FUNC_MESS_BEGIN();
     return PyGSL_solver_dn_init(self, args, alloc, 0);
     FUNC_MESS_END();
}

#endif
static double
PyGSL_gsl_function(double x, void * params)
{
     PyGSL_solver *s;
     double result = GSL_NAN;
     int flag = GSL_EFAILED;

     FUNC_MESS_BEGIN();
     assert(params);
     assert(PyGSL_solver_check((PyObject *) params));
     s = (PyGSL_solver *) params;

     flag = PyGSL_function_wrap_helper(x, &result, NULL, s->cbs[0], s->args, __FUNCTION__);
     if(flag == GSL_SUCCESS){
	  FUNC_MESS_END();
	  return result;
     }
     FUNC_MESS("Fail");
     if(s->isset)
	  longjmp(s->buffer, flag);
     DEBUG_MESS(2, "Found an error of %d but could not jump!", flag);
     return GSL_NAN;
}

static double
PyGSL_gsl_function_df(double x, void * params)
{
     PyGSL_solver *s;
     double result = GSL_NAN;
     int flag = GSL_EFAILED;

     FUNC_MESS_BEGIN();
     assert(params);
     assert(PyGSL_solver_check((PyObject *) params));
     s = (PyGSL_solver *) params;

     flag = PyGSL_function_wrap_helper(x, &result, NULL, s->cbs[1], s->args, __FUNCTION__);
     if(flag == GSL_SUCCESS){
	  FUNC_MESS_END();
	  return result;
     }
     FUNC_MESS("Fail");
     if(s->isset)
	  longjmp(s->buffer, flag);
     DEBUG_MESS(2, "Found an error of %d but could not jump!", flag);
     return GSL_NAN;
}

static void
PyGSL_gsl_function_fdf(double x, void * params,  double *f, double *df)
{
     PyGSL_solver *s;
     int flag = GSL_EFAILED;

     FUNC_MESS_BEGIN();
     assert(params);
     assert(PyGSL_solver_check((PyObject *) params));
     s = (PyGSL_solver *) params;

     assert(s->cbs[2]);
     assert(PyCallable_Check(s->cbs[2]));
     flag = PyGSL_function_wrap_helper(x, f, df, s->cbs[2], s->args, __FUNCTION__);
     if(flag == GSL_SUCCESS){
	  FUNC_MESS_END();
	  return;
     }
     FUNC_MESS("Fail");
     if(s->isset)
	  longjmp(s->buffer, flag);
     DEBUG_MESS(2, "Found an error of %d but could not jump!", flag);
     *f = GSL_NAN;
     *df = GSL_NAN;
}

static PyObject*
PyGSL_solver_set_f(PyGSL_solver *self, PyObject *pyargs, PyObject *kw,
		    void *fptr, int isfdf)
{

     PyObject *f = NULL, *df = NULL, *fdf = NULL, *args = Py_None;
     int  flag=GSL_EFAILED;
     void *c_sys = NULL;
     gsl_function * f_sys = NULL;
     gsl_function_fdf * fdf_sys = NULL;
     double x0, lower=0, upper=0;

     static const char *f_kwlist[]   = {"f", "x0", "upper", "lower", "args", NULL};
     static const char *fdf_kwlist[] = {"f", "df", "fdf", "x0", "args", NULL};

     FUNC_MESS_BEGIN();
     assert(PyGSL_solver_check(self));
     if (self->solver == NULL) {
	  pygsl_error("Got a NULL Pointer of min.f",  filename, __LINE__ - 3, GSL_EFAULT);
	  return NULL;
     }

     assert(pyargs);
     /* arguments PyFunction, Parameters, start Vector, step Vector */

     if(isfdf == 0){
	  if (0==PyArg_ParseTupleAndKeywords(pyargs,kw,"OdddO", (char **)f_kwlist, &f,
					     &x0,&lower,&upper,&args))
	       return NULL;
     }else{
	  if (0==PyArg_ParseTupleAndKeywords(pyargs,kw,"OOOdO", (char **)fdf_kwlist, &f,&df,&fdf,
					     &x0,&args))
	       return NULL;
     }

     if(!PyCallable_Check(f)){
	  pygsl_error("First argument must be callable",  filename, __LINE__ - 3, GSL_EBADFUNC);
	  return NULL;
     }
     if(isfdf == 1){
	  if(!PyCallable_Check(df)){
	       pygsl_error("Second argument must be callable",  filename, __LINE__ - 3, GSL_EBADFUNC);
	       return NULL;
	  }
	  if(!PyCallable_Check(fdf)){
	       pygsl_error("Third argument must be callable",  filename, __LINE__ - 3, GSL_EBADFUNC);
	       return NULL;
	  }
     }
     if (self->c_sys != NULL) {
	  /* free the previous function and args */
	  c_sys = self->c_sys;
     } else {
	  /* allocate function space */
	  if(isfdf == 0)
	       c_sys=calloc(1, sizeof(gsl_function));
	  else
	       c_sys=calloc(1, sizeof(gsl_function_fdf));
	  if (c_sys == NULL) {
	       pygsl_error("Could not allocate the object for the minimizer function",
			 filename, __LINE__ - 3, GSL_ENOMEM);
	       goto fail;
	  }
     }
     DEBUG_MESS(3, "Everything allocated args = %p", args);
     /* add new function  and parameters */

     if(PyGSL_solver_func_set(self, args, f, df, fdf) != GSL_SUCCESS)
	  goto fail;

     /* initialize the function struct */
     if(isfdf == 0){
	  f_sys = c_sys;
	  f_sys->function=PyGSL_gsl_function;
	  f_sys->params=(void*)self;
     }else{
	  fdf_sys = c_sys;
	  fdf_sys->f=PyGSL_gsl_function;
	  fdf_sys->df=PyGSL_gsl_function_df;
	  fdf_sys->fdf=PyGSL_gsl_function_fdf;
	  fdf_sys->params=(void*)self;
     }
     DEBUG_MESS(3, "Setting jmp buffer isset = % d", self->isset);
     if((flag = setjmp(self->buffer)) == 0){
	  self->isset = 1;
	  if(isfdf == 0){
	       DEBUG_MESS(3, "Calling f isfdf = %d", isfdf);
	       flag = ((set_m_ddd_t) fptr)(self->solver, c_sys, x0, lower, upper);
	  }else{
	       DEBUG_MESS(3, "Calling fdf isfdf = %d", isfdf);
	       flag = ((set_m_d_t) fptr)(self->solver, c_sys, x0);
	  }
	  if(PyGSL_ERROR_FLAG(flag) != GSL_SUCCESS){
	       goto fail;
	  }
     } else {
	  goto fail;
     }
     DEBUG_MESS(4, "Set evaluated. flag = %d", flag);
     self->c_sys = c_sys;
     self->set_called = 1;

     self->isset = 0;
     Py_INCREF(Py_None);
     FUNC_MESS_END();
     return Py_None;

 fail:
     FUNC_MESS("Fail");
     PyGSL_ERROR_FLAG(flag);
     self->isset = 0;
     return NULL;

}

/*
 * Set the solver
 */
PyGSL_API_EXTERN PyObject *
PyGSL_solver_n_set(PyGSL_solver *self, PyObject *pyargs, PyObject *kw,
		    const struct pygsl_solver_n_set * info)
{
     int n, flag=GSL_EFAILED;
     PyGSL_array_index_t stride;

     PyObject *args=Py_None, *f=NULL, *df=NULL, *fdf=NULL, *x;
     PyArrayObject * xa = NULL;
     gsl_vector_view gsl_x;
     void *c_sys;
     int line = -1;
     static const char *f_kwlist[]   = {"f", "x0", "args", NULL};
     static const char *fdf_kwlist[] = {"f", "df", "fdf", "x0", "args", NULL};

     FUNC_MESS_BEGIN();
     assert(PyGSL_solver_check(self));
     if (self->solver == NULL) {
	  pygsl_error("solver ==  NULL at solver_n_set", filename, __LINE__ - 3, GSL_EFAULT);
	  return NULL;
     }

     /* arguments PyFunction, Parameters, start Vector, step Vector */
     if(info->is_fdf == 0){
	  if (0==PyArg_ParseTupleAndKeywords(pyargs, kw, "OO|O", (char **)f_kwlist,
					     &f, &x, &args))
	       return NULL;
     } else {
	  if (0==PyArg_ParseTupleAndKeywords(pyargs, kw, "OOOO|O", (char **)fdf_kwlist,
					     &f, &df, &fdf, &x, &args))
	       return NULL;
     }

     n=self->problem_dimensions[0];
     DEBUG_MESS(3, "len(x) should be %d", n);
     xa  = PyGSL_vector_check(x, n, PyGSL_DARRAY_INPUT(2), &stride, NULL);
     if (xa == NULL){
	  line = __LINE__ - 2;
	  goto fail;
     }
     gsl_x = gsl_vector_view_array_with_stride((double *)(xa->data), stride,
					       xa->dimensions[0]);

     if (self->c_sys != NULL) {
	  c_sys = self->c_sys;
     } else {
	  c_sys=info->c_sys;
     }

     if(PyGSL_solver_func_set(self, args, f, df, fdf) != GSL_SUCCESS){
	  line = __LINE__ - 1;
	  goto fail;
     }
     if((flag = setjmp(self->buffer)) == 0){
	  self->isset = 1;
	  flag = info->set(self->solver, c_sys, &gsl_x.vector);
	  if((PyGSL_ERROR_FLAG(flag)) != GSL_SUCCESS){
	  line = __LINE__ - 2;
	       goto fail;
	  }
     }else{
	  line = __LINE__ - 9;
	  goto fail;
     }
     self->c_sys = c_sys;
     self->isset = 0;
     Py_DECREF(xa);
     self->set_called = 1;

     Py_INCREF(Py_None);
     FUNC_MESS_END();
     return Py_None;

 fail:
     PyGSL_add_traceback(module, __FILE__, __FUNCTION__, line);
     self->isset = 0;
     self->set_called = 0;
     Py_XDECREF(xa);
     return NULL;

}

static PyObject*
PyGSL_solver_ret_size_t(PyGSL_solver *self, PyObject *args,
			size_t_m_t func)
{
     size_t result;
     FUNC_MESS_BEGIN();
     assert(PyGSL_solver_check(self));
     result=func(self->solver);
     FUNC_MESS_END();
     return (PyObject *) PyLong_FromLong((long)result);
}

static PyObject*
PyGSL_solver_ret_int(PyGSL_solver *self, PyObject *args,
			int_m_t func)
{
     int result;
     FUNC_MESS_BEGIN();
     assert(PyGSL_solver_check(self));
     result=func(self->solver);
     FUNC_MESS_END();
     return (PyObject *) PyLong_FromLong((long)result);
}

static PyObject*
PyGSL_solver_ret_double(PyGSL_solver *self, PyObject *args,
			double_m_t func)
{
     double result;
     FUNC_MESS_BEGIN();
     assert(PyGSL_solver_check(self));
     result=func(self->solver);
     FUNC_MESS_END();
     return (PyObject *) PyFloat_FromDouble(result);
}

static PyObject*
PyGSL_solver_ret_vec(PyGSL_solver *self, PyObject *args,
		     ret_vec func)
{
     gsl_vector *result;
     FUNC_MESS_BEGIN();
     assert(PyGSL_solver_check(self));
     result=func(self->solver);
     if(result == NULL)
	  PyGSL_ERROR_NULL("Could not retrive vector ...", GSL_ESANITY);
     FUNC_MESS_END();
     return (PyObject *) PyGSL_copy_gslvector_to_pyarray(result);
}

/*
 * evaluates a C function taking an vector and a double as input and returning a status.
 */
static PyObject*
PyGSL_solver_vd_i(PyObject * self, PyObject *args, int_f_vd_t func)
{
     PyObject *g=NULL;
     PyArrayObject *ga=NULL;
     gsl_vector_view gradient;

     double epsabs;
     int flag = GSL_EFAILED;
     PyGSL_array_index_t stride_recalc=-1;

     FUNC_MESS_BEGIN();
     if (0==PyArg_ParseTuple(args,"Od", &g, &epsabs))
	  return NULL;

     ga  = PyGSL_vector_check(g, -1, PyGSL_DARRAY_INPUT(1), &stride_recalc, NULL);
     if (ga == NULL){
	  PyGSL_add_traceback(module, filename, __FUNCTION__, __LINE__ - 1);
	  return NULL;
     }
     gradient = gsl_vector_view_array_with_stride((double *)(ga->data), stride_recalc,
						  ga->dimensions[0]);
     flag = func(&gradient.vector, epsabs);
     FUNC_MESS_END();
     return PyGSL_ERROR_FLAG_TO_PYINT(flag);

}

static PyObject *
PyGSL_solver_vvdd_i(PyObject * self, PyObject * args, int_f_vvdd_t func)
{
     int flag;
     int line = -1;
     double epsabs, epsrel;
     PyObject *dx_o, *x_o;
     PyArrayObject *dx_a = NULL, *x_a = NULL;
     gsl_vector_view x, dx;
     PyGSL_array_index_t dimension, stride;

     FUNC_MESS_BEGIN();
     if(!PyArg_ParseTuple(args, "OOdd", &dx_o, &x_o, &epsabs, &epsrel))
	  return NULL;

     dx_a = PyGSL_vector_check(dx_o, -1, PyGSL_DARRAY_INPUT(1), &stride, NULL);
     if(dx_a == NULL){
	  line = __LINE__ - 4;
	  goto fail;
     }
     dx = gsl_vector_view_array_with_stride((double *)(dx_a->data), stride, dx_a->dimensions[0]);

     dimension = dx_a->dimensions[0];
     x_a = PyGSL_vector_check(x_o, dimension, PyGSL_DARRAY_CINPUT(2), &stride,  NULL);
     if(x_a == NULL){
	  line = __LINE__ - 4;
	  goto fail;
     }
     x = gsl_vector_view_array_with_stride((double *)(x_a->data), stride, x_a->dimensions[0]);
     flag = func(&(dx.vector), &(x.vector), epsabs, epsrel);
     Py_DECREF(x_a);
     Py_DECREF(dx_a);
     FUNC_MESS_END();
     return PyGSL_ERROR_FLAG_TO_PYINT(flag);

 fail:
     PyGSL_add_traceback(module, __FILE__, __FUNCTION__, line);
     Py_XDECREF(dx_a);
     Py_XDECREF(x_a);
     return NULL;
}

PyGSL_API_EXTERN int
PyGSL_Callable_Check(PyObject *f, const char * myname)
{
     FUNC_MESS_BEGIN();
     if(!PyCallable_Check(f)){
	  char str[256];
	  snprintf(str, 254, "Callback named %s is not callable!", myname);
	  PyGSL_ERROR(str, GSL_EINVAL);
     }
     FUNC_MESS_END();
     return GSL_SUCCESS;
}

PyGSL_API_EXTERN int
PyGSL_solver_func_set(PyGSL_solver *self, PyObject *args, PyObject *f,
		       PyObject *df, PyObject *fdf)
{
     int flag = GSL_EFAILED;
     if(df){
	  if(!fdf)
	       PyGSL_ERROR("If df is given, fdf must be given as well!", GSL_ESANITY);
	  Py_XDECREF(self->cbs[1]);
	  Py_XDECREF(self->cbs[2]);
	  self->cbs[1] = NULL;
	  self->cbs[2] = NULL;
     }
     Py_XDECREF(self->args);
     Py_XDECREF(self->cbs[0]);
     self->args = NULL;
     self->cbs[0] = NULL;

     DEBUG_MESS(3, "args = %p", (void *) args);
     self->args=args; Py_XINCREF(args);
     assert(f);
     if((flag = PyGSL_CALLABLE_CHECK(f, "f")) != GSL_SUCCESS)
	  return flag;
     self->cbs[0] = f; Py_INCREF(f);
     if(df){
	  assert(fdf);
	  if((flag = PyGSL_CALLABLE_CHECK(df, "df")) != GSL_SUCCESS)
	       return flag;
	  if((flag = PyGSL_CALLABLE_CHECK(fdf, "fdf")) != GSL_SUCCESS)
	       return flag;
	  self->cbs[1]=df;   Py_INCREF(df);
	  self->cbs[2]=fdf;  Py_INCREF(fdf);
     }
     return GSL_SUCCESS;
}

static PyObject *
PyGSL_solver_GetSet(PyObject *self, PyObject *args, void * address, enum PyGSL_GETSET_typemode mode)
{
     PyObject *ret=NULL, *input=NULL;
     unsigned long ultmp;
     int flag;

     if (!PyArg_ParseTuple(args, "|O", &input))
	  return NULL;

     if(input){
	  switch(mode){
	  case PyGSL_MODE_DOUBLE:
	       flag = PyGSL_PYFLOAT_TO_DOUBLE(input, (double *) address, NULL);
	       break;
	  case PyGSL_MODE_INT:
	       flag = PyGSL_PYINT_TO_INT(input, (int *) address, NULL);
	       break;
	  case PyGSL_MODE_SIZE_T:
	       flag = PyGSL_PYLONG_TO_ULONG(input, &ultmp, NULL);
	       *((size_t *) address) = ultmp;
	       break;
	  default:
	       PyGSL_ERROR_NULL("Unknown mode",GSL_ESANITY);
	  }
	  if(PyGSL_ERROR_FLAG(flag) != GSL_SUCCESS)
	       return NULL;

	  Py_INCREF(Py_None);
	  ret = Py_None;
	  return ret;
     }

     switch(mode){
     case PyGSL_MODE_DOUBLE:
	  ret = PyFloat_FromDouble(*((double *) address));
	  break;
     case PyGSL_MODE_INT:
	  ret = PyInt_FromLong(((long) *((int *) address)));
	  break;
     case PyGSL_MODE_SIZE_T:
	  ret = PyLong_FromUnsignedLong(((unsigned long) *((size_t *) address)));
	  break;
     default:
	  PyGSL_ERROR_NULL("Unknown mode",GSL_ESANITY);
     }
     return ret;
}

#ifdef ONEFILE

#include "chars.c"
#include "function_helpers2.c"
/*

#include "function_helpers.c"
#include "integrate.c"
#include "odeiv.c"
#include "roots.c"
#include "minimize.c"
#include "multifit_nlin.c"
#include "multimin.c"
#include "multiroot.c"
*/
#endif /* ONEFILE */

static PyMethodDef solverMethods[] = {
     {NULL, NULL, 0, NULL}
};

void
init_api(void)
{
     FUNC_MESS_BEGIN();
     PyGSL_API[PyGSL_solver_type_NUM            ] = (void *) &PyGSL_solver_pytype     ;
     PyGSL_API[PyGSL_solver_ret_int_NUM         ] = (void *) &PyGSL_solver_ret_int    ;
     PyGSL_API[PyGSL_solver_ret_double_NUM      ] = (void *) &PyGSL_solver_ret_double ;
     PyGSL_API[PyGSL_solver_ret_size_t_NUM      ] = (void *) &PyGSL_solver_ret_size_t ;
     PyGSL_API[PyGSL_solver_ret_vec_NUM         ] = (void *) &PyGSL_solver_ret_vec    ;
     PyGSL_API[PyGSL_solver_dn_init_NUM         ] = (void *) &PyGSL_solver_dn_init    ;
     PyGSL_API[PyGSL_solver_vd_i_NUM            ] = (void *) &PyGSL_solver_vd_i       ;
     PyGSL_API[PyGSL_solver_vvdd_i_NUM          ] = (void *) &PyGSL_solver_vvdd_i     ;
     PyGSL_API[PyGSL_Callable_Check_NUM         ] = (void *) &PyGSL_Callable_Check    ;
     PyGSL_API[PyGSL_solver_func_set_NUM        ] = (void *) &PyGSL_solver_func_set   ;
     PyGSL_API[PyGSL_function_wrap_OnOn_On_NUM  ] = (void *) &PyGSL_function_wrap_OnOn_On;
     PyGSL_API[PyGSL_function_wrap_On_O_NUM     ] = (void *) &PyGSL_function_wrap_On_O;
     PyGSL_API[PyGSL_function_wrap_Op_On_NUM    ] = (void *) &PyGSL_function_wrap_Op_On;
     PyGSL_API[PyGSL_function_wrap_Op_Opn_NUM   ] = (void *) &PyGSL_function_wrap_Op_Opn;
     PyGSL_API[PyGSL_function_wrap_Op_On_Opn_NUM] = (void *) &PyGSL_function_wrap_Op_On_Opn;
     PyGSL_API[PyGSL_solver_n_set_NUM           ] = (void *) &PyGSL_solver_n_set      ;
     PyGSL_API[PyGSL_solver_set_f_NUM           ] = (void *) &PyGSL_solver_set_f      ;
     PyGSL_API[PyGSL_solver_getset_NUM          ] = (void *) &PyGSL_solver_GetSet     ;
     FUNC_MESS_END();
}

void
initsolver(void)
{
  PyObject* m, *dict, *item;

  FUNC_MESS_BEGIN();
  m=Py_InitModule("solver", solverMethods);
  init_pygsl();

  /* init multimin type */
  PyGSL_solver_pytype.ob_type  = &PyType_Type;

  init_api();

  module = m;

  Py_INCREF((PyObject*)&PyGSL_solver_pytype);

  dict = PyModule_GetDict(m);
  if(!dict)
       goto fail;

  if (!(item = PyString_FromString((char*)PyGSL_solver_module_doc))){
       PyErr_SetString(PyExc_ImportError,
		       "I could not generate module doc string!");
       goto fail;
  }
  if (PyDict_SetItemString(dict, "__doc__", item) != 0){
       PyErr_SetString(PyExc_ImportError,
		       "I could not init doc string!");
       goto fail;
  }
  FUNC_MESS_END();

 fail:
  FUNC_MESS("FAIL");
  return;

}

max_stars_repo_name: juhnowski/FishingRod

max_issues_repo_name: juhnowski/FishingRod

max_forks_repo_name: juhnowski/FishingRod


text:
#include "cimple_c_from_py.h"
#include "setoper.h"
#include "cimple_safe_mode.h"
#include <cdd.h>
#include <gsl/gsl_matrix.h>

int main(){

    dd_set_global_constants();
    // Initialize state:
    system_dynamics *s_dyn;
    cost_function *f_cost;
    discrete_dynamics *d_dyn;
    current_state *now;

    system_alloc(&now, &s_dyn, &f_cost, &d_dyn);
    system_init(now, s_dyn, f_cost, d_dyn);

    double sec = 2;
    ACT(4, now, d_dyn, s_dyn, f_cost, sec);

    system_dynamics_free(s_dyn);
    discrete_dynamics_free(d_dyn);
    cost_function_free(f_cost);
    state_free(now);

    dd_free_global_constants();
    return 0;
}

max_stars_repo_name: shaesaert/TuLiPXML

max_issues_repo_name: shaesaert/TuLiPXML

max_forks_repo_name: shaesaert/TuLiPXML


text:
/* ******************************************************************************
 *
 *
 * This program and the accompanying materials are made available under the
 * terms of the Apache License, Version 2.0 which is available at
 * https://www.apache.org/licenses/LICENSE-2.0.
 *
 *  See the NOTICE file distributed with this work for additional
 *  information regarding copyright ownership.
 * 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.
 *
 * SPDX-License-Identifier: Apache-2.0
 ******************************************************************************/

//
// Created by agibsonccc on 1/26/16.
//

#ifndef NATIVEOPERATIONS_CBLAS_H
#define NATIVEOPERATIONS_CBLAS_H

#ifndef __STANDALONE_BUILD__
#include "config.h"
#endif

#ifdef __MKL_CBLAS_H__
// CBLAS from MKL is already included
#define CBLAS_H
#endif

#ifdef HAVE_OPENBLAS
// include CBLAS from OpenBLAS
#ifdef __GNUC__
#include_next <cblas.h>
#else
#include <cblas.h>
#endif
#define CBLAS_H
#endif

#ifndef CBLAS_H

#ifdef __cplusplus
extern "C" {
#endif
#ifndef CBLAS_ENUM_DEFINED_H
#define CBLAS_ENUM_DEFINED_H
enum CBLAS_ORDER { CblasRowMajor = 101, CblasColMajor = 102 };
enum CBLAS_TRANSPOSE { CblasNoTrans = 111, CblasTrans = 112, CblasConjTrans = 113, AtlasConj = 114 };
enum CBLAS_UPLO { CblasUpper = 121, CblasLower = 122 };
enum CBLAS_DIAG { CblasNonUnit = 131, CblasUnit = 132 };
enum CBLAS_SIDE { CblasLeft = 141, CblasRight = 142 };
#endif

#ifndef CBLAS_ENUM_ONLY
#define CBLAS_H
#define CBLAS_INDEX int

int cblas_errprn(int ierr, int info, char *form, ...);
void cblas_xerbla(int p, char *rout, char *form, ...);

#ifdef __MKL
void MKL_Set_Num_Threads(int num);
int MKL_Domain_Set_Num_Threads(int num, int domain);
int MKL_Set_Num_Threads_Local(int num);
#elif __OPENBLAS
void openblas_set_num_threads(int num);
#else
// do nothing
#endif

/*
 * ===========================================================================
 * Prototypes for level 1 BLAS functions (complex are recast as routines)
 * ===========================================================================
 */
float cblas_sdsdot(int N, float alpha, float *X, int incX, float *Y, int incY);
double cblas_dsdot(int N, float *X, int incX, float *Y, int incY);
float cblas_sdot(int N, float *X, int incX, float *Y, int incY);
double cblas_ddot(int N, double *X, int incX, double *Y, int incY);
/*
 * Functions having prefixes Z and C only
 */
void cblas_cdotu_sub(int N, void *X, int incX, void *Y, int incY, void *dotu);
void cblas_cdotc_sub(int N, void *X, int incX, void *Y, int incY, void *dotc);

void cblas_zdotu_sub(int N, void *X, int incX, void *Y, int incY, void *dotu);
void cblas_zdotc_sub(int N, void *X, int incX, void *Y, int incY, void *dotc);

/*
 * Functions having prefixes S D SC DZ
 */
float cblas_snrm2(int N, float *X, int incX);
float cblas_sasum(int N, float *X, int incX);

double cblas_dnrm2(int N, double *X, int incX);
double cblas_dasum(int N, double *X, int incX);

float cblas_scnrm2(int N, void *X, int incX);
float cblas_scasum(int N, void *X, int incX);

double cblas_dznrm2(int N, void *X, int incX);
double cblas_dzasum(int N, void *X, int incX);

/*
 * Functions having standard 4 prefixes (S D C Z)
 */
CBLAS_INDEX cblas_isamax(int N, float *X, int incX);
CBLAS_INDEX cblas_idamax(int N, double *X, int incX);
CBLAS_INDEX cblas_icamax(int N, void *X, int incX);
CBLAS_INDEX cblas_izamax(int N, void *X, int incX);

/*
 * ===========================================================================
 * Prototypes for level 1 BLAS routines
 * ===========================================================================
 */

/*
 * Routines with standard 4 prefixes (s, d, c, z)
 */
void cblas_sswap(int N, float *X, int incX, float *Y, int incY);
void cblas_scopy(int N, float *X, int incX, float *Y, int incY);
void cblas_saxpy(int N, float alpha, float *X, int incX, float *Y, int incY);
void catlas_saxpby(int N, float alpha, float *X, int incX, float beta, float *Y, int incY);
void catlas_sset(int N, float alpha, float *X, int incX);

void cblas_dswap(int N, double *X, int incX, double *Y, int incY);
void cblas_dcopy(int N, double *X, int incX, double *Y, int incY);
void cblas_daxpy(int N, double alpha, double *X, int incX, double *Y, int incY);
void catlas_daxpby(int N, double alpha, double *X, int incX, double beta, double *Y, int incY);
void catlas_dset(int N, double alpha, double *X, int incX);

void cblas_cswap(int N, void *X, int incX, void *Y, int incY);
void cblas_ccopy(int N, void *X, int incX, void *Y, int incY);
void cblas_caxpy(int N, void *alpha, void *X, int incX, void *Y, int incY);
void catlas_caxpby(int N, void *alpha, void *X, int incX, void *beta, void *Y, int incY);
void catlas_cset(int N, void *alpha, void *X, int incX);

void cblas_zswap(int N, void *X, int incX, void *Y, int incY);
void cblas_zcopy(int N, void *X, int incX, void *Y, int incY);
void cblas_zaxpy(int N, void *alpha, void *X, int incX, void *Y, int incY);
void catlas_zaxpby(int N, void *alpha, void *X, int incX, void *beta, void *Y, int incY);
void catlas_zset(int N, void *alpha, void *X, int incX);

/*
 * Routines with S and D prefix only
 */
void cblas_srotg(float *a, float *b, float *c, float *s);
void cblas_srotmg(float *d1, float *d2, float *b1, float b2, float *P);
void cblas_srot(int N, float *X, int incX, float *Y, int incY, float c, float s);
void cblas_srotm(int N, float *X, int incX, float *Y, int incY, float *P);

void cblas_drotg(double *a, double *b, double *c, double *s);
void cblas_drotmg(double *d1, double *d2, double *b1, double b2, double *P);
void cblas_drot(int N, double *X, int incX, double *Y, int incY, double c, double s);
void cblas_drotm(int N, double *X, int incX, double *Y, int incY, double *P);

/*
 * Routines with S D C Z CS and ZD prefixes
 */
void cblas_sscal(int N, float alpha, float *X, int incX);
void cblas_dscal(int N, double alpha, double *X, int incX);
void cblas_cscal(int N, void *alpha, void *X, int incX);
void cblas_zscal(int N, void *alpha, void *X, int incX);
void cblas_csscal(int N, float alpha, void *X, int incX);
void cblas_zdscal(int N, double alpha, void *X, int incX);

/*
 * Extra reference routines provided by ATLAS, but not mandated by the standard
 */
void cblas_crotg(void *a, void *b, void *c, void *s);
void cblas_zrotg(void *a, void *b, void *c, void *s);
void cblas_csrot(int N, void *X, int incX, void *Y, int incY, float c, float s);
void cblas_zdrot(int N, void *X, int incX, void *Y, int incY, double c, double s);

/*
 * ===========================================================================
 * Prototypes for level 2 BLAS
 * ===========================================================================
 */

/*
 * Routines with standard 4 prefixes (S, D, C, Z)
 */
void cblas_sgemv(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, int M, int N, float alpha, float *A, int lda,
                 float *X, int incX, float beta, float *Y, int incY);
void cblas_sgbmv(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, int M, int N, int KL, int KU, float alpha,
                 float *A, int lda, float *X, int incX, float beta, float *Y, int incY);
void cblas_strmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 float *A, int lda, float *X, int incX);
void cblas_stbmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 int K, float *A, int lda, float *X, int incX);
void cblas_stpmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 float *Ap, float *X, int incX);
void cblas_strsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 float *A, int lda, float *X, int incX);
void cblas_stbsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 int K, float *A, int lda, float *X, int incX);
void cblas_stpsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 float *Ap, float *X, int incX);

void cblas_dgemv(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, int M, int N, double alpha, double *A, int lda,
                 double *X, int incX, double beta, double *Y, int incY);
void cblas_dgbmv(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, int M, int N, int KL, int KU, double alpha,
                 double *A, int lda, double *X, int incX, double beta, double *Y, int incY);
void cblas_dtrmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 double *A, int lda, double *X, int incX);
void cblas_dtbmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 int K, double *A, int lda, double *X, int incX);
void cblas_dtpmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 double *Ap, double *X, int incX);
void cblas_dtrsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 double *A, int lda, double *X, int incX);
void cblas_dtbsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 int K, double *A, int lda, double *X, int incX);
void cblas_dtpsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 double *Ap, double *X, int incX);

void cblas_cgemv(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, int M, int N, void *alpha, void *A, int lda,
                 void *X, int incX, void *beta, void *Y, int incY);
void cblas_cgbmv(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, int M, int N, int KL, int KU, void *alpha,
                 void *A, int lda, void *X, int incX, void *beta, void *Y, int incY);
void cblas_ctrmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 void *A, int lda, void *X, int incX);
void cblas_ctbmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 int K, void *A, int lda, void *X, int incX);
void cblas_ctpmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 void *Ap, void *X, int incX);
void cblas_ctrsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 void *A, int lda, void *X, int incX);
void cblas_ctbsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 int K, void *A, int lda, void *X, int incX);
void cblas_ctpsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 void *Ap, void *X, int incX);

void cblas_zgemv(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, int M, int N, void *alpha, void *A, int lda,
                 void *X, int incX, void *beta, void *Y, int incY);
void cblas_zgbmv(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, int M, int N, int KL, int KU, void *alpha,
                 void *A, int lda, void *X, int incX, void *beta, void *Y, int incY);
void cblas_ztrmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 void *A, int lda, void *X, int incX);
void cblas_ztbmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 int K, void *A, int lda, void *X, int incX);
void cblas_ztpmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 void *Ap, void *X, int incX);
void cblas_ztrsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 void *A, int lda, void *X, int incX);
void cblas_ztbsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 int K, void *A, int lda, void *X, int incX);
void cblas_ztpsv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA, enum CBLAS_DIAG Diag, int N,
                 void *Ap, void *X, int incX);

/*
 * Routines with S and D prefixes only
 */
void cblas_ssymv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, float alpha, float *A, int lda, float *X,
                 int incX, float beta, float *Y, int incY);
void cblas_ssbmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, int K, float alpha, float *A, int lda, float *X,
                 int incX, float beta, float *Y, int incY);
void cblas_sspmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, float alpha, float *Ap, float *X, int incX,
                 float beta, float *Y, int incY);
void cblas_sger(enum CBLAS_ORDER Order, int M, int N, float alpha, float *X, int incX, float *Y, int incY, float *A,
                int lda);
void cblas_ssyr(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, float alpha, float *X, int incX, float *A,
                int lda);
void cblas_sspr(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, float alpha, float *X, int incX, float *Ap);
void cblas_ssyr2(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, float alpha, float *X, int incX, float *Y,
                 int incY, float *A, int lda);
void cblas_sspr2(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, float alpha, float *X, int incX, float *Y,
                 int incY, float *A);

void cblas_dsymv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, double alpha, double *A, int lda, double *X,
                 int incX, double beta, double *Y, int incY);
void cblas_dsbmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, int K, double alpha, double *A, int lda,
                 double *X, int incX, double beta, double *Y, int incY);
void cblas_dspmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, double alpha, double *Ap, double *X, int incX,
                 double beta, double *Y, int incY);
void cblas_dger(enum CBLAS_ORDER Order, int M, int N, double alpha, double *X, int incX, double *Y, int incY, double *A,
                int lda);
void cblas_dsyr(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, double alpha, double *X, int incX, double *A,
                int lda);
void cblas_dspr(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, double alpha, double *X, int incX, double *Ap);
void cblas_dsyr2(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, double alpha, double *X, int incX, double *Y,
                 int incY, double *A, int lda);
void cblas_dspr2(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, double alpha, double *X, int incX, double *Y,
                 int incY, double *A);

/*
 * Routines with C and Z prefixes only
 */
void cblas_chemv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, void *alpha, void *A, int lda, void *X, int incX,
                 void *beta, void *Y, int incY);
void cblas_chbmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, int K, void *alpha, void *A, int lda, void *X,
                 int incX, void *beta, void *Y, int incY);
void cblas_chpmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, void *alpha, void *Ap, void *X, int incX,
                 void *beta, void *Y, int incY);
void cblas_cgeru(enum CBLAS_ORDER Order, int M, int N, void *alpha, void *X, int incX, void *Y, int incY, void *A,
                 int lda);
void cblas_cgerc(enum CBLAS_ORDER Order, int M, int N, void *alpha, void *X, int incX, void *Y, int incY, void *A,
                 int lda);
void cblas_cher(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, float alpha, void *X, int incX, void *A, int lda);
void cblas_chpr(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, float alpha, void *X, int incX, void *A);
void cblas_cher2(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, void *alpha, void *X, int incX, void *Y, int incY,
                 void *A, int lda);
void cblas_chpr2(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, void *alpha, void *X, int incX, void *Y, int incY,
                 void *Ap);

void cblas_zhemv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, void *alpha, void *A, int lda, void *X, int incX,
                 void *beta, void *Y, int incY);
void cblas_zhbmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, int K, void *alpha, void *A, int lda, void *X,
                 int incX, void *beta, void *Y, int incY);
void cblas_zhpmv(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, void *alpha, void *Ap, void *X, int incX,
                 void *beta, void *Y, int incY);
void cblas_zgeru(enum CBLAS_ORDER Order, int M, int N, void *alpha, void *X, int incX, void *Y, int incY, void *A,
                 int lda);
void cblas_zgerc(enum CBLAS_ORDER Order, int M, int N, void *alpha, void *X, int incX, void *Y, int incY, void *A,
                 int lda);
void cblas_zher(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, double alpha, void *X, int incX, void *A, int lda);
void cblas_zhpr(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, double alpha, void *X, int incX, void *A);
void cblas_zher2(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, void *alpha, void *X, int incX, void *Y, int incY,
                 void *A, int lda);
void cblas_zhpr2(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, int N, void *alpha, void *X, int incX, void *Y, int incY,
                 void *Ap);

/*
 * ===========================================================================
 * Prototypes for level 3 BLAS
 * ===========================================================================
 */

/*
 * Routines with standard 4 prefixes (S, D, C, Z)
 */
void cblas_sgemm(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANSPOSE TransB, int M, int N, int K,
                 float alpha, float *A, int lda, float *B, int ldb, float beta, float *C, int ldc);
void cblas_ssymm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, int M, int N, float alpha,
                 float *A, int lda, float *B, int ldb, float beta, float *C, int ldc);
void cblas_ssyrk(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, float alpha,
                 float *A, int lda, float beta, float *C, int ldc);
void cblas_ssyr2k(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, float alpha,
                  float *A, int lda, float *B, int ldb, float beta, float *C, int ldc);
void cblas_strmm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA,
                 enum CBLAS_DIAG Diag, int M, int N, float alpha, float *A, int lda, float *B, int ldb);
void cblas_strsm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA,
                 enum CBLAS_DIAG Diag, int M, int N, float alpha, float *A, int lda, float *B, int ldb);

void cblas_dgemm(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANSPOSE TransB, int M, int N, int K,
                 double alpha, double *A, int lda, double *B, int ldb, double beta, double *C, int ldc);
void cblas_dsymm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, int M, int N, double alpha,
                 double *A, int lda, double *B, int ldb, double beta, double *C, int ldc);
void cblas_dsyrk(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, double alpha,
                 double *A, int lda, double beta, double *C, int ldc);
void cblas_dsyr2k(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, double alpha,
                  double *A, int lda, double *B, int ldb, double beta, double *C, int ldc);
void cblas_dtrmm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA,
                 enum CBLAS_DIAG Diag, int M, int N, double alpha, double *A, int lda, double *B, int ldb);
void cblas_dtrsm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA,
                 enum CBLAS_DIAG Diag, int M, int N, double alpha, double *A, int lda, double *B, int ldb);

void cblas_cgemm(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANSPOSE TransB, int M, int N, int K,
                 void *alpha, void *A, int lda, void *B, int ldb, void *beta, void *C, int ldc);
void cblas_csymm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, int M, int N, void *alpha, void *A,
                 int lda, void *B, int ldb, void *beta, void *C, int ldc);
void cblas_csyrk(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, void *alpha,
                 void *A, int lda, void *beta, void *C, int ldc);
void cblas_csyr2k(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, void *alpha,
                  void *A, int lda, void *B, int ldb, void *beta, void *C, int ldc);
void cblas_ctrmm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA,
                 enum CBLAS_DIAG Diag, int M, int N, void *alpha, void *A, int lda, void *B, int ldb);
void cblas_ctrsm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA,
                 enum CBLAS_DIAG Diag, int M, int N, void *alpha, void *A, int lda, void *B, int ldb);

void cblas_zgemm(enum CBLAS_ORDER Order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANSPOSE TransB, int M, int N, int K,
                 void *alpha, void *A, int lda, void *B, int ldb, void *beta, void *C, int ldc);
void cblas_zsymm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, int M, int N, void *alpha, void *A,
                 int lda, void *B, int ldb, void *beta, void *C, int ldc);
void cblas_zsyrk(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, void *alpha,
                 void *A, int lda, void *beta, void *C, int ldc);
void cblas_zsyr2k(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, void *alpha,
                  void *A, int lda, void *B, int ldb, void *beta, void *C, int ldc);
void cblas_ztrmm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA,
                 enum CBLAS_DIAG Diag, int M, int N, void *alpha, void *A, int lda, void *B, int ldb);
void cblas_ztrsm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE TransA,
                 enum CBLAS_DIAG Diag, int M, int N, void *alpha, void *A, int lda, void *B, int ldb);

/*
 * Routines with prefixes C and Z only
 */
void cblas_chemm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, int M, int N, void *alpha, void *A,
                 int lda, void *B, int ldb, void *beta, void *C, int ldc);
void cblas_cherk(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, float alpha,
                 void *A, int lda, float beta, void *C, int ldc);
void cblas_cher2k(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, void *alpha,
                  void *A, int lda, void *B, int ldb, float beta, void *C, int ldc);
void cblas_zhemm(enum CBLAS_ORDER Order, enum CBLAS_SIDE Side, enum CBLAS_UPLO Uplo, int M, int N, void *alpha, void *A,
                 int lda, void *B, int ldb, void *beta, void *C, int ldc);
void cblas_zherk(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, double alpha,
                 void *A, int lda, double beta, void *C, int ldc);
void cblas_zher2k(enum CBLAS_ORDER Order, enum CBLAS_UPLO Uplo, enum CBLAS_TRANSPOSE Trans, int N, int K, void *alpha,
                  void *A, int lda, void *B, int ldb, double beta, void *C, int ldc);

int cblas_errprn(int ierr, int info, char *form, ...);
#ifdef __cplusplus
}
#endif
#endif /* end #ifdef CBLAS_ENUM_ONLY */
#endif
#endif  // NATIVEOPERATIONS_CBLAS_H

ext: h