mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
Building igl statically and moving to the dep scripts
Fixing dep build script on Windows and removing some warnings. Use bundled igl by default. Not building with the dependency scripts if not explicitly stated. This way, it will stay in Fix the libigl patch to include C source files in header only mode.
This commit is contained in:
36
src/libigl/igl/random_search.cpp
Normal file
36
src/libigl/igl/random_search.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "random_search.h"
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
template <
|
||||
typename Scalar,
|
||||
typename DerivedX,
|
||||
typename DerivedLB,
|
||||
typename DerivedUB>
|
||||
IGL_INLINE Scalar igl::random_search(
|
||||
const std::function< Scalar (DerivedX &) > f,
|
||||
const Eigen::MatrixBase<DerivedLB> & LB,
|
||||
const Eigen::MatrixBase<DerivedUB> & UB,
|
||||
const int iters,
|
||||
DerivedX & X)
|
||||
{
|
||||
Scalar min_f = std::numeric_limits<Scalar>::max();
|
||||
const int dim = LB.size();
|
||||
assert(UB.size() == dim && "UB should match LB size");
|
||||
for(int iter = 0;iter<iters;iter++)
|
||||
{
|
||||
const DerivedX R = DerivedX::Random(dim).array()*0.5+0.5;
|
||||
DerivedX Xr = LB.array() + R.array()*(UB-LB).array();
|
||||
const Scalar fr = f(Xr);
|
||||
if(fr<min_f)
|
||||
{
|
||||
min_f = fr;
|
||||
X = Xr;
|
||||
}
|
||||
}
|
||||
return min_f;
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
template float igl::random_search<float, Eigen::Matrix<float, 1, -1, 1, 1, -1>, Eigen::Matrix<float, 1, -1, 1, 1, -1>, Eigen::Matrix<float, 1, -1, 1, 1, -1> >(std::function<float (Eigen::Matrix<float, 1, -1, 1, 1, -1>&)>, Eigen::MatrixBase<Eigen::Matrix<float, 1, -1, 1, 1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<float, 1, -1, 1, 1, -1> > const&, int, Eigen::Matrix<float, 1, -1, 1, 1, -1>&);
|
||||
#endif
|
||||
Reference in New Issue
Block a user