Skip to content

Commit

Permalink
memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Oct 25, 2024
1 parent f24a492 commit 0c5d106
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/swig/nlopt-python.i
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ __version__ = str(_nlopt.version_major())+'.'+str(_nlopt.version_minor())+'.'+st
{
npy_intp sz = $1.size();
$result = PyArray_SimpleNew(1, &sz, NPY_DOUBLE);
std::memcpy(array_data($result), $1.empty() ? NULL : &$1[0],
sizeof(double) * sz);
if (!$1.empty())
{
std::memcpy(array_data($result), &$1[0], sizeof(double) * sz);
}
}

//////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion test/cpp_functor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class LinearRegression {
LinearRegression(QuadraticForm quadratic_form_) :
quadratic_form(std::move(quadratic_form_)) {}

double operator()(unsigned n, const double* x, double* grad) const
double operator()(unsigned /*n*/, const double* x, double* grad) const
{
const double result = quadratic_form.compute_form(x);
if (!!grad) {
Expand Down

0 comments on commit 0c5d106

Please sign in to comment.