Initial commit.

This commit is contained in:
2018-12-06 16:01:56 +01:00
parent 10867b60c2
commit 18eb3f6047
1011 changed files with 345688 additions and 10 deletions

View File

@@ -0,0 +1,118 @@
#ifndef BOOST_NUMERIC_BINDINGS_MUMPS_464_CMUMPS_C_HPP
#define BOOST_NUMERIC_BINDINGS_MUMPS_464_CMUMPS_C_HPP
/*
THIS FILE IS PART OF MUMPS VERSION 4.6.4
This Version was built on Thu Jan 11 13:32:35 2007
This version of MUMPS is provided to you free of charge. It is public
domain, based on public domain software developed during the Esprit IV
European project PARASOL (1996-1999) by CERFACS, ENSEEIHT-IRIT and RAL.
Since this first public domain version in 1999, the developments are
supported by the following institutions: CERFACS, ENSEEIHT-IRIT, and
INRIA.
Main contributors are Patrick Amestoy, Iain Duff, Abdou Guermouche,
Jacko Koster, Jean-Yves L'Excellent, and Stephane Pralet.
Up-to-date copies of the MUMPS package can be obtained
from the Web pages http://www.enseeiht.fr/apo/MUMPS/
or http://graal.ens-lyon.fr/MUMPS
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
User documentation of any code that uses this software can
include this complete notice. You can acknowledge (using
references [1], [2], and [3] the contribution of this package
in any scientific publication dependent upon the use of the
package. You shall use reasonable endeavours to notify
the authors of the package of this publication.
[1] P. R. Amestoy, I. S. Duff and J.-Y. L'Excellent,
Multifrontal parallel distributed symmetric and unsymmetric solvers,
in Comput. Methods in Appl. Mech. Eng., 184, 501-520 (2000).
[2] P. R. Amestoy, I. S. Duff, J. Koster and J.-Y. L'Excellent,
A fully asynchronous multifrontal solver using distributed dynamic
scheduling, SIAM Journal of Matrix Analysis and Applications,
Vol 23, No 1, pp 15-41 (2001).
[3] P. R. Amestoy and A. Guermouche and J.-Y. L'Excellent and
S. Pralet, Hybrid scheduling for the parallel solution of linear
systems. Parallel Computing Vol 32 (2), pp 136-156 (2006).
*/
/* $Id: cmumps_c.hpp 39206 2007-09-12 06:58:12Z karlmeerbergen $ */
/* Mostly written in march 2002 (JYL) */
// This file is modified by Karl Meerbergen for C++ users
/* Complex datatypes */
typedef struct {float r,i;} mumps_complex;
/* Next line defines CMUMPS_INT, CMUMPS_DOUBLE and CMUMPS_DOUBLE2 */
#include "cmumps_prec.h"
/*
* Definition of the (simplified)
* MUMPS C structure
*/
typedef struct
{
CMUMPS_INT sym, par, job;
CMUMPS_INT comm_fortran; /* Fortran communicator */
CMUMPS_INT icntl[40];
CMUMPS_DOUBLE2 cntl[5];
CMUMPS_INT n;
CMUMPS_INT nz_alloc; /* used in matlab interface to decide if
we free + malloc when we have large variation */
/* Assembled entry */
CMUMPS_INT nz; CMUMPS_INT *irn; CMUMPS_INT *jcn; CMUMPS_DOUBLE *a;
/* Distributed entry */
CMUMPS_INT nz_loc; CMUMPS_INT *irn_loc; CMUMPS_INT *jcn_loc; CMUMPS_DOUBLE *a_loc;
/* Element entry */
CMUMPS_INT nelt; CMUMPS_INT *eltptr; CMUMPS_INT *eltvar; CMUMPS_DOUBLE *a_elt;
/* Ordering, if given by user */
CMUMPS_INT *perm_in;
/* Orderings returned to user */
/* symmetric permutation */
CMUMPS_INT *sym_perm;
/* column permutation */
CMUMPS_INT *uns_perm;
/* Scaling (input only in this version) */
CMUMPS_DOUBLE *colsca; CMUMPS_DOUBLE *rowsca;
/* RHS, solution, ouptput data and statistics */
CMUMPS_DOUBLE *rhs, *rhs_sparse, *sol_loc;
CMUMPS_INT *irhs_sparse, *irhs_ptr, *isol_loc;
CMUMPS_INT nrhs, lrhs, nz_rhs, lsol_loc;
CMUMPS_INT schur_mloc, schur_nloc, schur_lld;
CMUMPS_INT mblock, nblock, nprow, npcol;
CMUMPS_INT info[40],infog[40];
CMUMPS_DOUBLE2 rinfo[20], rinfog[20];
/* Null space */
CMUMPS_INT deficiency; CMUMPS_DOUBLE * nullspace; CMUMPS_INT * mapping;
/* Schur */
CMUMPS_INT size_schur; CMUMPS_INT *listvar_schur; CMUMPS_DOUBLE *schur;
/* Internal parameters */
CMUMPS_INT instance_number;
/* For out-of-core */
char ooc_tmpdir[151];
char ooc_prefix[151];
} CMUMPS_STRUC_C;
extern "C" {
void cmumps_c(CMUMPS_STRUC_C * cmumps_par);
}
#endif

View File

@@ -0,0 +1,125 @@
#ifndef BOOST_NUMERIC_BINDINGS_MUMPS_464_DMUMPS_C_HPP
#define BOOST_NUMERIC_BINDINGS_MUMPS_464_DMUMPS_C_HPP
/*
THIS FILE IS PART OF MUMPS VERSION 4.6.4
This Version was built on Thu Jan 11 13:32:35 2007
This version of MUMPS is provided to you free of charge. It is public
domain, based on public domain software developed during the Esprit IV
European project PARASOL (1996-1999) by CERFACS, ENSEEIHT-IRIT and RAL.
Since this first public domain version in 1999, the developments are
supported by the following institutions: CERFACS, ENSEEIHT-IRIT, and
INRIA.
Main contributors are Patrick Amestoy, Iain Duff, Abdou Guermouche,
Jacko Koster, Jean-Yves L'Excellent, and Stephane Pralet.
Up-to-date copies of the MUMPS package can be obtained
from the Web pages http://www.enseeiht.fr/apo/MUMPS/
or http://graal.ens-lyon.fr/MUMPS
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
User documentation of any code that uses this software can
include this complete notice. You can acknowledge (using
references [1], [2], and [3] the contribution of this package
in any scientific publication dependent upon the use of the
package. You shall use reasonable endeavours to notify
the authors of the package of this publication.
[1] P. R. Amestoy, I. S. Duff and J.-Y. L'Excellent,
Multifrontal parallel distributed symmetric and unsymmetric solvers,
in Comput. Methods in Appl. Mech. Eng., 184, 501-520 (2000).
[2] P. R. Amestoy, I. S. Duff, J. Koster and J.-Y. L'Excellent,
A fully asynchronous multifrontal solver using distributed dynamic
scheduling, SIAM Journal of Matrix Analysis and Applications,
Vol 23, No 1, pp 15-41 (2001).
[3] P. R. Amestoy and A. Guermouche and J.-Y. L'Excellent and
S. Pralet, Hybrid scheduling for the parallel solution of linear
systems. Parallel Computing Vol 32 (2), pp 136-156 (2006).
*/
/* $Id: dmumps_c.hpp 39206 2007-09-12 06:58:12Z karlmeerbergen $ */
/* Mostly written in march 2002 (JYL) */
// This file is modified by Karl Meerbergen for C++ users
/* Complex datatypes */
/* Next line defines DMUMPS_INT, DMUMPS_DOUBLE and DMUMPS_DOUBLE2 */
#include "dmumps_prec.h"
/*
* Definition of the (simplified)
* MUMPS C structure
*/
typedef struct
{
DMUMPS_INT sym, par, job;
DMUMPS_INT comm_fortran; /* Fortran communicator */
DMUMPS_INT icntl[40];
DMUMPS_DOUBLE2 cntl[5];
DMUMPS_INT n;
DMUMPS_INT nz_alloc; /* used in matlab interface to decide if
we free + malloc when we have large variation */
/* Assembled entry */
DMUMPS_INT nz; DMUMPS_INT *irn; DMUMPS_INT *jcn; DMUMPS_DOUBLE *a;
/* Distributed entry */
DMUMPS_INT nz_loc; DMUMPS_INT *irn_loc; DMUMPS_INT *jcn_loc; DMUMPS_DOUBLE *a_loc;
/* Element entry */
DMUMPS_INT nelt; DMUMPS_INT *eltptr; DMUMPS_INT *eltvar; DMUMPS_DOUBLE *a_elt;
/* Ordering, if given by user */
DMUMPS_INT *perm_in;
/* Orderings returned to user */
/* symmetric permutation */
DMUMPS_INT *sym_perm;
/* column permutation */
DMUMPS_INT *uns_perm;
/* Scaling (input only in this version) */
DMUMPS_DOUBLE *colsca; DMUMPS_DOUBLE *rowsca;
/* RHS, solution, ouptput data and statistics */
DMUMPS_DOUBLE *rhs, *rhs_sparse, *sol_loc;
DMUMPS_INT *irhs_sparse, *irhs_ptr, *isol_loc;
DMUMPS_INT nrhs, lrhs, nz_rhs, lsol_loc;
DMUMPS_INT schur_mloc, schur_nloc, schur_lld;
DMUMPS_INT mblock, nblock, nprow, npcol;
DMUMPS_INT info[40],infog[40];
DMUMPS_DOUBLE2 rinfo[20], rinfog[20];
/* Null space */
DMUMPS_INT deficiency; DMUMPS_DOUBLE * nullspace; DMUMPS_INT * mapping;
/* Schur */
DMUMPS_INT size_schur; DMUMPS_INT *listvar_schur; DMUMPS_DOUBLE *schur;
/* Internal parameters */
DMUMPS_INT instance_number;
/* For out-of-core */
char ooc_tmpdir[151];
char ooc_prefix[151];
} DMUMPS_STRUC_C;
#define MUMPS_CALL
#if defined(_WIN32)
/*
* Next line May be needed depending on your Windows environment:
* #define MUMPS_CALL __stdcall
*/
#endif
extern "C" {
void dmumps_c(DMUMPS_STRUC_C * dmumps_par);
}
#endif

View File

@@ -0,0 +1,117 @@
#ifndef BOOST_NUMERIC_BINDINGS_MUMPS_464_SMUMPS_C_HPP
#define BOOST_NUMERIC_BINDINGS_MUMPS_464_SMUMPS_C_HPP
/*
THIS FILE IS PART OF MUMPS VERSION 4.6.4
This Version was built on Thu Jan 11 13:32:35 2007
This version of MUMPS is provided to you free of charge. It is public
domain, based on public domain software developed during the Esprit IV
European project PARASOL (1996-1999) by CERFACS, ENSEEIHT-IRIT and RAL.
Since this first public domain version in 1999, the developments are
supported by the following institutions: CERFACS, ENSEEIHT-IRIT, and
INRIA.
Main contributors are Patrick Amestoy, Iain Duff, Abdou Guermouche,
Jacko Koster, Jean-Yves L'Excellent, and Stephane Pralet.
Up-to-date copies of the MUMPS package can be obtained
from the Web pages http://www.enseeiht.fr/apo/MUMPS/
or http://graal.ens-lyon.fr/MUMPS
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
User documentation of any code that uses this software can
include this complete notice. You can acknowledge (using
references [1], [2], and [3] the contribution of this package
in any scientific publication dependent upon the use of the
package. You shall use reasonable endeavours to notify
the authors of the package of this publication.
[1] P. R. Amestoy, I. S. Duff and J.-Y. L'Excellent,
Multifrontal parallel distributed symmetric and unsymmetric solvers,
in Comput. Methods in Appl. Mech. Eng., 184, 501-520 (2000).
[2] P. R. Amestoy, I. S. Duff, J. Koster and J.-Y. L'Excellent,
A fully asynchronous multifrontal solver using distributed dynamic
scheduling, SIAM Journal of Matrix Analysis and Applications,
Vol 23, No 1, pp 15-41 (2001).
[3] P. R. Amestoy and A. Guermouche and J.-Y. L'Excellent and
S. Pralet, Hybrid scheduling for the parallel solution of linear
systems. Parallel Computing Vol 32 (2), pp 136-156 (2006).
*/
/* $Id: smumps_c.hpp 39206 2007-09-12 06:58:12Z karlmeerbergen $ */
/* Mostly written in march 2002 (JYL) */
// This file is modified by Karl Meerbergen for C++ users
/* Complex datatypes */
/* Next line defines SMUMPS_INT, SMUMPS_DOUBLE and SMUMPS_DOUBLE2 */
#include <smumps_prec.h>
/*
* Definition of the (simplified)
* MUMPS C structure
*/
typedef struct
{
SMUMPS_INT sym, par, job;
SMUMPS_INT comm_fortran; /* Fortran communicator */
SMUMPS_INT icntl[40];
SMUMPS_DOUBLE2 cntl[5];
SMUMPS_INT n;
SMUMPS_INT nz_alloc; /* used in matlab interface to decide if
we free + malloc when we have large variation */
/* Assembled entry */
SMUMPS_INT nz; SMUMPS_INT *irn; SMUMPS_INT *jcn; SMUMPS_DOUBLE *a;
/* Distributed entry */
SMUMPS_INT nz_loc; SMUMPS_INT *irn_loc; SMUMPS_INT *jcn_loc; SMUMPS_DOUBLE *a_loc;
/* Element entry */
SMUMPS_INT nelt; SMUMPS_INT *eltptr; SMUMPS_INT *eltvar; SMUMPS_DOUBLE *a_elt;
/* Ordering, if given by user */
SMUMPS_INT *perm_in;
/* Orderings returned to user */
/* symmetric permutation */
SMUMPS_INT *sym_perm;
/* column permutation */
SMUMPS_INT *uns_perm;
/* Scaling (input only in this version) */
SMUMPS_DOUBLE *colsca; SMUMPS_DOUBLE *rowsca;
/* RHS, solution, ouptput data and statistics */
SMUMPS_DOUBLE *rhs, *rhs_sparse, *sol_loc;
SMUMPS_INT *irhs_sparse, *irhs_ptr, *isol_loc;
SMUMPS_INT nrhs, lrhs, nz_rhs, lsol_loc;
SMUMPS_INT schur_mloc, schur_nloc, schur_lld;
SMUMPS_INT mblock, nblock, nprow, npcol;
SMUMPS_INT info[40],infog[40];
SMUMPS_DOUBLE2 rinfo[20], rinfog[20];
/* Null space */
SMUMPS_INT deficiency; SMUMPS_DOUBLE * nullspace; SMUMPS_INT * mapping;
/* Schur */
SMUMPS_INT size_schur; SMUMPS_INT *listvar_schur; SMUMPS_DOUBLE *schur;
/* Internal parameters */
SMUMPS_INT instance_number;
/* For out-of-core */
char ooc_tmpdir[151];
char ooc_prefix[151];
} SMUMPS_STRUC_C;
extern "C" {
void smumps_c(SMUMPS_STRUC_C * smumps_par);
}
#endif

View File

@@ -0,0 +1,118 @@
#ifndef BOOST_NUMERIC_BINDINGS_MUMPS_464_ZMUMPS_C_HPP
#define BOOST_NUMERIC_BINDINGS_MUMPS_464_ZMUMPS_C_HPP
/*
THIS FILE IS PART OF MUMPS VERSION 4.6.4
This Version was built on Thu Jan 11 13:32:35 2007
This version of MUMPS is provided to you free of charge. It is public
domain, based on public domain software developed during the Esprit IV
European project PARASOL (1996-1999) by CERFACS, ENSEEIHT-IRIT and RAL.
Since this first public domain version in 1999, the developments are
supported by the following institutions: CERFACS, ENSEEIHT-IRIT, and
INRIA.
Main contributors are Patrick Amestoy, Iain Duff, Abdou Guermouche,
Jacko Koster, Jean-Yves L'Excellent, and Stephane Pralet.
Up-to-date copies of the MUMPS package can be obtained
from the Web pages http://www.enseeiht.fr/apo/MUMPS/
or http://graal.ens-lyon.fr/MUMPS
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
User documentation of any code that uses this software can
include this complete notice. You can acknowledge (using
references [1], [2], and [3] the contribution of this package
in any scientific publication dependent upon the use of the
package. You shall use reasonable endeavours to notify
the authors of the package of this publication.
[1] P. R. Amestoy, I. S. Duff and J.-Y. L'Excellent,
Multifrontal parallel distributed symmetric and unsymmetric solvers,
in Comput. Methods in Appl. Mech. Eng., 184, 501-520 (2000).
[2] P. R. Amestoy, I. S. Duff, J. Koster and J.-Y. L'Excellent,
A fully asynchronous multifrontal solver using distributed dynamic
scheduling, SIAM Journal of Matrix Analysis and Applications,
Vol 23, No 1, pp 15-41 (2001).
[3] P. R. Amestoy and A. Guermouche and J.-Y. L'Excellent and
S. Pralet, Hybrid scheduling for the parallel solution of linear
systems. Parallel Computing Vol 32 (2), pp 136-156 (2006).
*/
/* $Id: zmumps_c.hpp 39206 2007-09-12 06:58:12Z karlmeerbergen $ */
/* Mostly written in march 2002 (JYL) */
// This file is modified by Karl Meerbergen for C++ users
/* Complex datatypes */
typedef struct {double r,i;} mumps_double_complex;
/* Next line defines ZMUMPS_INT, ZMUMPS_DOUBLE and ZMUMPS_DOUBLE2 */
#include "zmumps_prec.h"
/*
* Definition of the (simplified)
* MUMPS C structure
*/
typedef struct
{
ZMUMPS_INT sym, par, job;
ZMUMPS_INT comm_fortran; /* Fortran communicator */
ZMUMPS_INT icntl[40];
ZMUMPS_DOUBLE2 cntl[5];
ZMUMPS_INT n;
ZMUMPS_INT nz_alloc; /* used in matlab interface to decide if
we free + malloc when we have large variation */
/* Assembled entry */
ZMUMPS_INT nz; ZMUMPS_INT *irn; ZMUMPS_INT *jcn; ZMUMPS_DOUBLE *a;
/* Distributed entry */
ZMUMPS_INT nz_loc; ZMUMPS_INT *irn_loc; ZMUMPS_INT *jcn_loc; ZMUMPS_DOUBLE *a_loc;
/* Element entry */
ZMUMPS_INT nelt; ZMUMPS_INT *eltptr; ZMUMPS_INT *eltvar; ZMUMPS_DOUBLE *a_elt;
/* Ordering, if given by user */
ZMUMPS_INT *perm_in;
/* Orderings returned to user */
/* symmetric permutation */
ZMUMPS_INT *sym_perm;
/* column permutation */
ZMUMPS_INT *uns_perm;
/* Scaling (input only in this version) */
ZMUMPS_DOUBLE *colsca; ZMUMPS_DOUBLE *rowsca;
/* RHS, solution, ouptput data and statistics */
ZMUMPS_DOUBLE *rhs, *rhs_sparse, *sol_loc;
ZMUMPS_INT *irhs_sparse, *irhs_ptr, *isol_loc;
ZMUMPS_INT nrhs, lrhs, nz_rhs, lsol_loc;
ZMUMPS_INT schur_mloc, schur_nloc, schur_lld;
ZMUMPS_INT mblock, nblock, nprow, npcol;
ZMUMPS_INT info[40],infog[40];
ZMUMPS_DOUBLE2 rinfo[20], rinfog[20];
/* Null space */
ZMUMPS_INT deficiency; ZMUMPS_DOUBLE * nullspace; ZMUMPS_INT * mapping;
/* Schur */
ZMUMPS_INT size_schur; ZMUMPS_INT *listvar_schur; ZMUMPS_DOUBLE *schur;
/* Internal parameters */
ZMUMPS_INT instance_number;
/* For out-of-core */
char ooc_tmpdir[151];
char ooc_prefix[151];
} ZMUMPS_STRUC_C;
extern "C" {
void zmumps_c(ZMUMPS_STRUC_C * zmumps_par);
}
#endif

View File

@@ -0,0 +1,14 @@
//
// Copyright Karl Meerbergen 2007
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_NUMERIC_BINDINGS_MUMPS_MUMPS_DRIVER_HPP
#define BOOST_NUMERIC_BINDINGS_MUMPS_MUMPS_DRIVER_HPP
#include <boost/numeric/bindings/mumps/mumps_driver_4_8_0.hpp>
#endif

View File

@@ -0,0 +1,264 @@
//
// Copyright Karl Meerbergen 2007
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_NUMERIC_BINDINGS_MUMPS_MUMPS_DRIVER_4_6_4_HPP
#define BOOST_NUMERIC_BINDINGS_MUMPS_MUMPS_DRIVER_4_6_4_HPP
#include <boost/numeric/bindings/mumps/4.6.4/smumps_c.hpp>
#include <boost/numeric/bindings/mumps/4.6.4/cmumps_c.hpp>
#include <boost/numeric/bindings/mumps/4.6.4/dmumps_c.hpp>
#include <boost/numeric/bindings/mumps/4.6.4/zmumps_c.hpp>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/data_order.hpp>
#include <boost/numeric/bindings/index_base.hpp>
#include <boost/static_assert.hpp>
#include <complex>
#include <cassert>
//
// This file contains a C++ driver for MUMPS
//
// The templated class mumps<M> is a wrapper for the corresponding C struct.
// The class contains constructor and destructor that call mumps with JOB=-1 and JOB=-2
// respectively.
//
// The function driver() calls MUMPS. The user must set the parameters of the data manually.
//
// The following functions are very helpful in this respect, since they extract pointer and size
// data using the Boost Bindings.
//
// void matrix_integer_data() : to set the integer data of the matrix.
// void matrix_value_data() : to set the values of the matrix.
// void rhs_sol_value_data() : to set the right-hand side and solution vectors in the case of a dense solution vector.
//
namespace boost { namespace numeric { namespace bindings { namespace mumps {
namespace detail {
//
// Type and Driver
//
template <class T>
struct mumps_type {
} ;
template <class T>
struct mumps_call {
} ;
template <class T>
struct mumps_internal_value_type {
typedef T type ;
} ;
//
// Specialization for float
//
template <>
struct mumps_type< float > {
typedef SMUMPS_STRUC_C type ;
} ;
template <>
struct mumps_call< float > {
void operator() ( SMUMPS_STRUC_C& struc ) const {
smumps_c( &struc ) ;
}
} ;
//
// Specialization for double
//
template <>
struct mumps_type< double > {
typedef DMUMPS_STRUC_C type ;
} ;
template <>
struct mumps_call< double > {
void operator() ( DMUMPS_STRUC_C& struc ) const {
dmumps_c( &struc ) ;
}
} ;
//
// Specialization for complex<float>
//
template <>
struct mumps_type< std::complex< float > > {
typedef CMUMPS_STRUC_C type ;
} ;
template <>
struct mumps_call< std::complex< float > > {
void operator() ( CMUMPS_STRUC_C& struc ) const {
cmumps_c( &struc ) ;
}
} ;
template <>
struct mumps_internal_value_type< std::complex<float> > {
typedef mumps_complex type ;
} ;
//
// Specialization for complex<double>
//
template <>
struct mumps_type< std::complex< double > > {
typedef ZMUMPS_STRUC_C type ;
} ;
template <>
struct mumps_call< std::complex< double > > {
void operator() ( ZMUMPS_STRUC_C& struc ) const {
zmumps_c( &struc ) ;
}
} ;
template <>
struct mumps_internal_value_type< std::complex<double> > {
typedef mumps_double_complex type ;
} ;
//
// Symmetry map
//
template <class T>
struct mumps_sym {
} ;
template <>
struct mumps_sym< bindings::tag::symmetric > {
static int const value = 2 ;
} ;
template <>
struct mumps_sym< bindings::tag::general > {
static int const value = 0 ;
} ;
//
// Get index pointers
//
template <typename M>
void indices( bindings::tag::row_major, int*& rows, int*& cols, M const& m ) {
rows = const_cast<int*>( bindings::begin_index_major( m ) ) ;
cols = const_cast<int*>( bindings::begin_index_minor( m ) ) ;
}
template <typename M>
void indices( bindings::tag::column_major, int*& rows, int*& cols, M const& m ) {
cols = const_cast<int*>( bindings::begin_index_major( m ) ) ;
rows = const_cast<int*>( bindings::begin_index_minor( m ) ) ;
}
// Pointer Cast
float* cast_2_mumps( float* p ) { return p ; }
double* cast_2_mumps( double* p ) { return p ; }
mumps_double_complex* cast_2_mumps( std::complex<double>* p ) { return reinterpret_cast<mumps_double_complex*>( p ) ; }
mumps_complex* cast_2_mumps( std::complex<float>* p ) { return reinterpret_cast<mumps_complex*>( p ) ; }
} // namespace detail
//
// Generic MUMPS data for any value_type
//
template <typename M>
struct mumps
: detail::mumps_type< typename bindings::value_type<M>::type >::type
{
typedef typename bindings::value_type<M>::type value_type ;
typedef typename detail::mumps_type< typename bindings::value_type<M>::type >::type c_struct_type ;
//
// Initialize MUMPS solver
// Pass a communicator (comm=-987654 means choose default)
// Pass 'par': default = 1: host is involved in factorization
//
mumps( int comm_fortran=-987654, int par=1 )
{
this->job = -1 ;
this->par = par ;
this->comm_fortran = comm_fortran ;
this->sym = detail::mumps_sym< typename bindings::detail::property_at<M, tag::matrix_type >::type >::value ;
detail::mumps_call<value_type>() ( *this ) ;
}
// Destroy the solver
~mumps() {
this->job = -2 ;
detail::mumps_call<value_type>() ( *this ) ;
}
} ;
//
// Copy the matrix integer data (matrix order, structure) to the MUMPS struct
//
template <typename M>
void matrix_integer_data( mumps<M>& data, M& m ) {
typedef typename bindings::result_of::index_base<M>::type index_b ;
BOOST_STATIC_ASSERT(index_b::value == 1) ;
data.n = bindings::size_row( m ) ;
assert( bindings::size_column( m ) == data.n ) ;
data.nz = bindings::end_value( m ) - bindings::begin_value( m ) ;
detail::indices( bindings::data_order(m), data.irn, data.jcn, m ) ;
data.nz_loc = bindings::end_value( m ) - bindings::begin_value( m ) ;
detail::indices( bindings::data_order(m), data.irn_loc, data.jcn_loc, m ) ;
} // matrix_integer_data()
//
// Copy the values pointer to the MUMPS struct
//
template <typename M>
void matrix_value_data( mumps<M>& data, M& m ) {
data.a = detail::cast_2_mumps( bindings::begin_value( m ) ) ;
data.a_loc = detail::cast_2_mumps( bindings::begin_value( m ) ) ;
} // matrix_value_data()
//
// Copy the right-hand side / solution pointer to the MUMPS struct
// in case of a dense undistributed right-hand side and solution.
//
template <typename M, typename X>
void rhs_sol_value_data( mumps<M>& data, X& x ) {
data.rhs = detail::cast_2_mumps( bindings::begin_value( x ) ) ;
data.nrhs = bindings::size_column( x ) ;
data.lrhs = bindings::stride_major( x ) ;
} // matrix_rhs_sol_value_data()
//
// Call the MUMPS driver for the given MUMPS struct.
//
template <typename M>
int driver( mumps<M>& data ) {
assert( data.job>=1 ? data.irn!=0 : true ) ;
assert( data.job>=1 ? data.jcn!=0 : true ) ;
assert( data.job>=2 ? data.a!=0 : true ) ;
assert( data.job>=3 ? data.rhs!=0 : true ) ;
detail::mumps_call<typename M::value_type>() ( static_cast<typename mumps<M>::c_struct_type&>( data ) ) ;
return data.info[0] ;
} // driver()
} } } } // namespace boost::numeric::bindings::mumps
#endif

View File

@@ -0,0 +1,271 @@
//
// Copyright Karl Meerbergen 2008
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_NUMERIC_BINDINGS_MUMPS_MUMPS_DRIVER_4_8_0_HPP
#define BOOST_NUMERIC_BINDINGS_MUMPS_MUMPS_DRIVER_4_8_0_HPP
#include <smumps_c.h>
#include <cmumps_c.h>
#include <dmumps_c.h>
#include <zmumps_c.h>
#include <boost/numeric/bindings/value_type.hpp>
#include <boost/numeric/bindings/begin.hpp>
#include <boost/numeric/bindings/size.hpp>
#include <boost/numeric/bindings/data_order.hpp>
#include <boost/numeric/bindings/index_base.hpp>
#include <boost/static_assert.hpp>
#include <complex>
#include <cassert>
//
// This file contains a C++ driver for MUMPS
//
// The templated class mumps<M> is a wrapper for the corresponding C struct.
// The class contains constructor and destructor that call mumps with JOB=-1 and JOB=-2
// respectively.
//
// The function driver() calls MUMPS. The user must set the parameters of the data manually.
//
// The following functions are very helpful in this respect, since they extract pointer and size
// data using the Boost Bindings.
//
// void matrix_integer_data() : to set the integer data of the matrix.
// void matrix_value_data() : to set the values of the matrix.
// void rhs_sol_value_data() : to set the right-hand side and solution vectors in the case of a dense solution vector.
//
namespace boost { namespace numeric { namespace bindings { namespace mumps {
namespace detail {
//
// Type and Driver
//
template <class T>
struct mumps_type {
} ;
template <class T>
struct mumps_call {
} ;
template <class T>
struct mumps_internal_value_type {
typedef T type ;
} ;
//
// Specialization for float
//
template <>
struct mumps_type< float > {
typedef SMUMPS_STRUC_C type ;
} ;
template <>
struct mumps_call< float > {
void operator() ( SMUMPS_STRUC_C& struc ) const {
smumps_c( &struc ) ;
}
} ;
//
// Specialization for double
//
template <>
struct mumps_type< double > {
typedef DMUMPS_STRUC_C type ;
} ;
template <>
struct mumps_call< double > {
void operator() ( DMUMPS_STRUC_C& struc ) const {
dmumps_c( &struc ) ;
}
} ;
//
// Specialization for complex<float>
//
template <>
struct mumps_type< std::complex< float > > {
typedef CMUMPS_STRUC_C type ;
} ;
template <>
struct mumps_call< std::complex< float > > {
void operator() ( CMUMPS_STRUC_C& struc ) const {
cmumps_c( &struc ) ;
}
} ;
template <>
struct mumps_internal_value_type< std::complex<float> > {
typedef mumps_complex type ;
} ;
//
// Specialization for complex<double>
//
template <>
struct mumps_type< std::complex< double > > {
typedef ZMUMPS_STRUC_C type ;
} ;
template <>
struct mumps_call< std::complex< double > > {
void operator() ( ZMUMPS_STRUC_C& struc ) const {
zmumps_c( &struc ) ;
}
} ;
template <>
struct mumps_internal_value_type< std::complex<double> > {
typedef mumps_double_complex type ;
} ;
//
// Symmetry map
//
template <class T>
struct mumps_sym {
} ;
template <>
struct mumps_sym< bindings::tag::symmetric > {
static int const value = 2 ;
} ;
template <>
struct mumps_sym< bindings::tag::general > {
static int const value = 0 ;
} ;
//
// Get index pointers
//
template <typename M>
void indices( bindings::tag::row_major, int*& rows, int*& cols, M const& m ) {
rows = const_cast<int*>( bindings::begin_index_major( m ) ) ;
cols = const_cast<int*>( bindings::begin_index_minor( m ) ) ;
}
template <typename M>
void indices( bindings::tag::column_major, int*& rows, int*& cols, M const& m ) {
cols = const_cast<int*>( bindings::begin_index_major( m ) ) ;
rows = const_cast<int*>( bindings::begin_index_minor( m ) ) ;
}
// Pointer Cast
float* cast_2_mumps( float* p ) { return p ; }
double* cast_2_mumps( double* p ) { return p ; }
mumps_double_complex* cast_2_mumps( std::complex<double>* p ) { return reinterpret_cast<mumps_double_complex*>( p ) ; }
mumps_complex* cast_2_mumps( std::complex<float>* p ) { return reinterpret_cast<mumps_complex*>( p ) ; }
} // namespace detail
//
// Generic MUMPS data for any value_type
//
template <typename M>
class mumps
: public detail::mumps_type< typename bindings::value_type<M>::type >::type
{
public:
typedef typename bindings::value_type<M>::type value_type ;
typedef typename detail::mumps_type< typename bindings::value_type<M>::type >::type c_struct_type ;
//
// Initialize MUMPS solver
// Pass a communicator (comm=-987654 means choose default)
// Pass 'par': default = 1: host is involved in factorization
//
mumps( int comm_fortran=-987654, int par=1 )
{
this->job = -1 ;
this->par = par ;
this->comm_fortran = comm_fortran ;
this->sym = detail::mumps_sym< typename bindings::detail::property_at<M, tag::matrix_type >::type >::value ;
detail::mumps_call<value_type>() ( *this ) ;
}
// Destroy the solver
~mumps() {
this->job = -2 ;
detail::mumps_call<value_type>() ( *this ) ;
}
private:
// Disable assignment and Copy Constructor
mumps& operator=( mumps const& that ) { return *this ; }
mumps( mumps const& that ) {}
} ;
//
// Copy the matrix integer data (matrix order, structure) to the MUMPS struct
//
template <typename M>
void matrix_integer_data( mumps<M>& data, M& m ) {
typedef typename bindings::result_of::index_base<M>::type index_b ;
BOOST_STATIC_ASSERT(index_b::value == 1) ;
data.n = bindings::size_row( m ) ;
assert( bindings::size_column( m ) == data.n ) ;
data.nz = bindings::end_value( m ) - bindings::begin_value( m ) ;
detail::indices( bindings::data_order(m), data.irn, data.jcn, m ) ;
data.nz_loc = bindings::end_value( m ) - bindings::begin_value( m ) ;
detail::indices( bindings::data_order(m), data.irn_loc, data.jcn_loc, m ) ;
} // matrix_integer_data()
//
// Copy the values pointer to the MUMPS struct
//
template <typename M>
void matrix_value_data( mumps<M>& data, M& m ) {
data.a = detail::cast_2_mumps( bindings::begin_value( m ) ) ;
data.a_loc = detail::cast_2_mumps( bindings::begin_value( m ) ) ;
} // matrix_value_data()
//
// Copy the right-hand side / solution pointer to the MUMPS struct
// in case of a dense undistributed right-hand side and solution.
//
template <typename M, typename X>
void rhs_sol_value_data( mumps<M>& data, X& x ) {
data.rhs = detail::cast_2_mumps( bindings::begin_value( x ) ) ;
data.nrhs = bindings::size_column( x ) ;
data.lrhs = bindings::stride_major( x ) ;
} // matrix_rhs_sol_value_data()
//
// Call the MUMPS driver for the given MUMPS struct.
//
template <typename M>
int driver( mumps<M>& data ) {
assert( data.job>=1 ? data.irn!=0 : true ) ;
assert( data.job>=1 ? data.jcn!=0 : true ) ;
assert( data.job>=2 ? data.a!=0 : true ) ;
assert( data.job==3 || data.job==5 ? data.rhs!=0 : true ) ;
detail::mumps_call<typename M::value_type>() ( static_cast<typename mumps<M>::c_struct_type&>( data ) ) ;
return data.info[0] ;
} // driver()
} } } } // namespace boost::numeric::bindings::mumps
#endif