Skip to content
Snippets Groups Projects
Unverified Commit 8109446d authored by Tobias Leibner's avatar Tobias Leibner Committed by GitHub
Browse files

Merge pull request #85 from dune-community/tmp_branch

[lpsolve] fix wrapper
parents 4c01c87d 7f0bd64d
No related branches found
No related tags found
No related merge requests found
......@@ -556,6 +556,46 @@ void dtrsm(const int layout,
}
void dtrsv(const int layout,
const int uplo,
const int transa,
const int diag,
const int n,
const double* a,
const int lda,
double* x,
const int incx)
{
#if HAVE_MKL || HAVE_CBLAS
cblas_dtrsv(static_cast<CBLAS_LAYOUT>(layout),
static_cast<CBLAS_UPLO>(uplo),
static_cast<CBLAS_TRANSPOSE>(transa),
static_cast<CBLAS_DIAG>(diag),
n,
a,
lda,
x,
incx);
#ifndef NDEBUG
for (int ii = 0; ii < n; ++ii)
if (std::isnan(x[ii]) || std::isinf(x[ii]))
DUNE_THROW(Dune::MathError, "Triangular solve using cblas_dtrsv failed!");
#endif
#else
DUNE_UNUSED_PARAMETER(layout);
DUNE_UNUSED_PARAMETER(uplo);
DUNE_UNUSED_PARAMETER(transa);
DUNE_UNUSED_PARAMETER(diag);
DUNE_UNUSED_PARAMETER(n);
DUNE_UNUSED_PARAMETER(a);
DUNE_UNUSED_PARAMETER(lda);
DUNE_UNUSED_PARAMETER(x);
DUNE_UNUSED_PARAMETER(incx);
DUNE_THROW(Exceptions::dependency_missing, "You are missing CBLAS or the intel mkl, check available() first!");
#endif
}
void ztrsm(const int layout,
const int side,
const int uplo,
......@@ -606,6 +646,47 @@ void ztrsm(const int layout,
}
void ztrsv(const int layout,
const int uplo,
const int transa,
const int diag,
const int n,
const void* a,
const int lda,
void* x,
const int incx)
{
#if HAVE_MKL || HAVE_CBLAS
cblas_ztrsv(static_cast<CBLAS_LAYOUT>(layout),
static_cast<CBLAS_UPLO>(uplo),
static_cast<CBLAS_TRANSPOSE>(transa),
static_cast<CBLAS_DIAG>(diag),
n,
a,
lda,
x,
incx);
#ifndef NDEBUG
for (int ii = 0; ii < n; ++ii)
if (std::isnan(std::abs(static_cast<std::complex<double>*>(x)[ii]))
|| std::isinf(std::abs(static_cast<std::complex<double>*>(x)[ii])))
DUNE_THROW(Dune::MathError, "Triangular solve using cblas_ztrsv failed!");
#endif
#else
DUNE_UNUSED_PARAMETER(layout);
DUNE_UNUSED_PARAMETER(uplo);
DUNE_UNUSED_PARAMETER(transa);
DUNE_UNUSED_PARAMETER(diag);
DUNE_UNUSED_PARAMETER(n);
DUNE_UNUSED_PARAMETER(a);
DUNE_UNUSED_PARAMETER(lda);
DUNE_UNUSED_PARAMETER(x);
DUNE_UNUSED_PARAMETER(incx);
DUNE_THROW(Exceptions::dependency_missing, "You are missing CBLAS or the intel mkl, check available() first!");
#endif
}
} // namespace Blas
} // namespace Common
} // namespace XT
......
......@@ -281,6 +281,19 @@ void dtrsm(const int layout,
double* b,
const int ldb);
/**
* \brief Wrapper around cblas_dtrsv
* \sa cblas_dtrsv
*/
void dtrsv(const int layout,
const int uplo,
const int transa,
const int diag,
const int n,
const double* a,
const int lda,
double* x,
const int incx);
/**
* \brief Wrapper around cblas_ztrsm
......@@ -299,6 +312,20 @@ void ztrsm(const int layout,
void* b,
const int ldb);
/**
* \brief Wrapper around cblas_ztrsv
* \sa cblas_ztrsv
*/
void ztrsv(const int layout,
const int uplo,
const int transa,
const int diag,
const int n,
const void* a,
const int lda,
void* x,
const int incx);
} // namespace Blas
} // namespace Common
......
......@@ -23,6 +23,13 @@
#include "lpsolve.hh"
#if not(HAVE_LPSOLVE)
struct _lprec
{
};
#endif
namespace Dune {
namespace XT {
namespace Common {
......@@ -30,36 +37,39 @@ namespace lp_solve {
#if HAVE_LPSOLVE
struct LinearProgram
LinearProgram::LinearProgram(int rows, int cols)
: lp_(::make_lp(rows, cols))
{
LinearProgram(int rows, int cols)
: lp_(::make_lp(rows, cols))
{
if (!lp_)
DUNE_THROW(Dune::MathError, "Couldn't construct linear program");
}
~LinearProgram()
{
::delete_lp(lp_);
}
lprec* data()
{
return lp_;
}
private:
lprec* lp_;
};
if (!lp_)
DUNE_THROW(Dune::MathError, "Couldn't construct linear program");
}
LinearProgram::~LinearProgram()
{
::delete_lp(lp_);
}
lprec* LinearProgram::data()
{
return lp_;
}
#else // HAVE_LPSOLVE
struct LinearProgram
LinearProgram::LinearProgram(int /*rows*/, int /*cols*/)
{
LinearProgram(int /*rows*/, int /*cols*/)
{
DUNE_THROW(Exceptions::dependency_missing, "You are missing lp_solve, check available() first!");
}
};
DUNE_THROW(Exceptions::dependency_missing, "You are missing lp_solve, check available() first!");
}
LinearProgram::~LinearProgram()
{
DUNE_THROW(Exceptions::dependency_missing, "You are missing lp_solve, check available() first!");
}
lprec* LinearProgram::data()
{
DUNE_THROW(Exceptions::dependency_missing, "You are missing lp_solve, check available() first!");
return new lprec();
}
#endif // HAVE_LPSOLVE
bool available()
......
......@@ -17,14 +17,25 @@
#include <complex>
#include <memory>
// forward declaration
typedef struct _lprec lprec;
namespace Dune {
namespace XT {
namespace Common {
namespace lp_solve {
// forward declaration
struct LinearProgram;
struct LinearProgram
{
LinearProgram(int rows, int cols);
~LinearProgram();
lprec* data();
private:
lprec* lp_;
};
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment