Skip to content
Snippets Groups Projects
Commit 6cf3485c authored by Carl Philipp Klemm's avatar Carl Philipp Klemm
Browse files

add pkgconfig support

parent ad95f25c
Branches main
No related tags found
No related merge requests found
...@@ -85,6 +85,13 @@ if(DEFINED EIS_FOUND) ...@@ -85,6 +85,13 @@ if(DEFINED EIS_FOUND)
endif(DEFINED TORCH_LIBRARIES) endif(DEFINED TORCH_LIBRARIES)
endif(DEFINED EIS_FOUND) endif(DEFINED EIS_FOUND)
if(DEFINED PKGCONFIG_FOUND)
configure_file(pkgconfig/libeisdrt_torch.pc.in pkgconfig/libeisdrt_torch.pc @ONLY)
configure_file(pkgconfig/libeisdrt.pc.in pkgconfig/libeisdrt.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libeisdrt_torch.pc DESTINATION lib/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libeisdrt.pc DESTINATION lib/pkgconfig)
endif(DEFINED PKGCONFIG_FOUND)
set(API_HEADERS_DIR eisdrt/) set(API_HEADERS_DIR eisdrt/)
set(API_HEADERS set(API_HEADERS
${API_HEADERS_DIR}/eigendrt.h ${API_HEADERS_DIR}/eigendrt.h
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
// //
#include "eisdrt/eigendrt.h" #include "eisdrt/eigendrt.h"
#include "eisdrt/types.h"
#include <stdexcept>
#ifdef USE_EISGEN #ifdef USE_EISGEN
#include "eisdrt/eisdrt.h" #include "eisdrt/eisdrt.h"
...@@ -117,17 +119,11 @@ public: ...@@ -117,17 +119,11 @@ public:
int64_t size = x.size(); int64_t size = x.size();
Eigen::Vector<fv, Eigen::Dynamic> xLeft = x.head(x.size()-1); Eigen::Vector<fv, Eigen::Dynamic> xLeft = x.head(x.size()-1);
std::cout<<"aMatrixReal:\n"<<aMatrixReal<<"\nxLeft:\n"<<xLeft<<"\nx:\n"<<x<<std::endl;
Eigen::Vector<fv, Eigen::Dynamic> t = aMatrixReal*xLeft; Eigen::Vector<fv, Eigen::Dynamic> t = aMatrixReal*xLeft;
std::cout<<"T1:\n"<<t<<std::endl;
t = t - impedanceSpectra.real(); t = t - impedanceSpectra.real();
std::cout<<"T2:\n"<<t<<std::endl;
t = t.array() + x[size-1]; t = t.array() + x[size-1];
std::cout<<"T3:\n"<<t<<std::endl;
t = t.array().pow(2); t = t.array().pow(2);
std::cout<<"T4:\n"<<t<<std::endl;
fv MSE_re = t.sum(); fv MSE_re = t.sum();
std::cout<<"T5:\n"<<MSE_re<<std::endl;
t = (aMatrixImag*xLeft - impedanceSpectra.imag()).array().pow(2); t = (aMatrixImag*xLeft - impedanceSpectra.imag()).array().pow(2);
fv MSE_im = t.sum(); fv MSE_im = t.sum();
...@@ -155,7 +151,6 @@ public: ...@@ -155,7 +151,6 @@ public:
fv operator()(Eigen::VectorX<fv>& x, Eigen::VectorX<fv>& grad) fv operator()(Eigen::VectorX<fv>& x, Eigen::VectorX<fv>& grad)
{ {
grad = getGrad(std::bind(&RtFunct::function, this, std::placeholders::_1), x, epsilon); grad = getGrad(std::bind(&RtFunct::function, this, std::placeholders::_1), x, epsilon);
std::cout<<"grad:\n"<<grad<<std::endl;
return function(x); return function(x);
} }
}; };
...@@ -187,14 +182,24 @@ Eigen::VectorX<fv> calcDrt(Eigen::VectorX<std::complex<fv>>& impedanceSpectra, E ...@@ -187,14 +182,24 @@ Eigen::VectorX<fv> calcDrt(Eigen::VectorX<std::complex<fv>>& impedanceSpectra, E
RtFunct<fv> funct(impedanceSpectra, aMatrixImag, aMatrixReal, 0.01, fp.step); RtFunct<fv> funct(impedanceSpectra, aMatrixImag, aMatrixReal, 0.01, fp.step);
Eigen::VectorX<fv> x = guesStartingPoint(omegaTensor, impedanceSpectra); Eigen::VectorX<fv> x = guesStartingPoint(omegaTensor, impedanceSpectra);
std::cout<<"StartingPoint\n"<<x<<std::endl;
Eigen::Matrix<fv, Eigen::Dynamic, 2> bounds = calcBounds(impedanceSpectra, x); Eigen::Matrix<fv, Eigen::Dynamic, 2> bounds = calcBounds(impedanceSpectra, x);
Eigen::VectorX<fv> lowerBounds = bounds.col(0); Eigen::VectorX<fv> lowerBounds = bounds.col(0);
Eigen::VectorX<fv> upperBounds = bounds.col(1); Eigen::VectorX<fv> upperBounds = bounds.col(1);
fv fx; fv fx;
try
{
fm.iterations = solver.minimize(funct, x, fx, lowerBounds, upperBounds); fm.iterations = solver.minimize(funct, x, fx, lowerBounds, upperBounds);
fm.fx = fx; fm.fx = fx;
}
catch(const std::invalid_argument& ex)
{
throw drt_errror(std::string(ex.what()));
}
catch(const std::runtime_error& ex)
{
throw drt_errror(std::string(ex.what()));
}
return x; return x;
} }
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
*/ */
#pragma once #pragma once
#include <exception>
#include <string>
/** /**
Types for use with all eisdrt apis Types for use with all eisdrt apis
...@@ -26,6 +28,22 @@ Types for use with all eisdrt apis ...@@ -26,6 +28,22 @@ Types for use with all eisdrt apis
* @{ * @{
*/ */
/**
* @brief Exception thrown if drt could not be calcualted
*/
class drt_errror: public std::exception
{
std::string whatStr;
public:
drt_errror(const std::string& whatIn): whatStr(whatIn)
{}
virtual const char* what() const noexcept override
{
return whatStr.c_str();
}
};
/** /**
* @brief Returned information on a fit * @brief Returned information on a fit
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment