Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. using namespace System;
  2.  
  3. void SetLowerBoundsWrapper(array<double>^ lb)
  4. {
  5. int n = lb->Length;
  6. std::vector<double> lower(n); //create a std::vector
  7. for(int i = 0; i<n ; i++)
  8. {
  9. lower[i] = lb[i]; //copy element-wise
  10. }
  11. _opt->set_lower_bounds(lower);
  12. }
  13.  
  14. #include <algorithm>
  15. #include <vector>
  16.  
  17. void SetLowerBoundsWrapper(array<double>^ lb)
  18. {
  19. std::vector<double> lower(lb->Length);
  20. {
  21. pin_ptr<double> pin(&lb[0]);
  22. double *first(pin), *last(pin + lb->Length);
  23. std::copy(first, last, lower.begin());
  24. }
  25. _opt->set_lower_bounds(lower);
  26. }
  27.  
  28. void SetLowerBoundsWrapper2(array<double>^ lb)
  29. {
  30. std::vector<double> lower(lb->Length);
  31. {
  32. pin_ptr<double> pin(&lb[0]);
  33. std::copy(
  34. static_cast<double*>(pin),
  35. static_cast<double*>(pin + lb->Length),
  36. lower.begin()
  37. );
  38. }
  39. _opt->set_lower_bounds(lower);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement