<commit_before>//=======================================================================
// Copyright 2014-2015 <NAME>.
// Distributed under the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#include "Dual_Constraint_Group.hxx"
#include "../../../SDP.hxx"

void fill_from_dual_constraint_groups(
  const Vector &dualObjective, const Real &objectiveConst,
  const std::vector<Dual_Constraint_Group> &dualConstraintGroups, SDP &sdp);

Dual_Constraint_Group
dual_constraint_group_from_pol_vec_mat(const Polynomial_Vector_Matrix &m);

// Form an SDP from an affineObjective and a list of
// PolynomialVectorMatrices.  affineObjective is a vector of the form
// (f, b), where the objective function will be
//
//   f + y.b
//
// with y the dual decision variables.  polVectorMatrices are
// described in SDP.h.
//
void bootstrap(const Vector &affineObjective,
               const std::vector<Polynomial_Vector_Matrix> &polVectorMatrices,
               SDP &sdp)
{
  // Convert polVectorMatrices into Dual_Constraint_Group's
  std::vector<Dual_Constraint_Group> dualConstraintGroups;
  for(auto &m : polVectorMatrices)
    {
      dualConstraintGroups.push_back(
        dual_constraint_group_from_pol_vec_mat(m));
    }

  // Split affineObjective into objectiveConst f and dualObjective b
  Real objectiveConst = affineObjective[0];
  Vector dualObjective = affineObjective;
  dualObjective.erase(dualObjective.begin());

  fill_from_dual_constraint_groups(dualObjective, objectiveConst,
                                   dualConstraintGroups, sdp);
}<commit_msg>copy subsets of an array rather than the whole thing and then erase()<commit_after>//=======================================================================
// Copyright 2014-2015 <NAME>.
// Distributed under the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#include "Dual_Constraint_Group.hxx"
#include "../../../SDP.hxx"

void fill_from_dual_constraint_groups(
  const Vector &dualObjective, const Real &objectiveConst,
  const std::vector<Dual_Constraint_Group> &dualConstraintGroups, SDP &sdp);

Dual_Constraint_Group
dual_constraint_group_from_pol_vec_mat(const Polynomial_Vector_Matrix &m);

// Form an SDP from an affineObjective and a list of
// PolynomialVectorMatrices.  affineObjective is a vector of the form
// (f, b), where the objective function will be
//
//   f + y.b
//
// with y the dual decision variables.  polVectorMatrices are
// described in SDP.h.
//
void bootstrap(const Vector &affineObjective,
               const std::vector<Polynomial_Vector_Matrix> &polVectorMatrices,
               SDP &sdp)
{
  // Convert polVectorMatrices into Dual_Constraint_Group's
  std::vector<Dual_Constraint_Group> dualConstraintGroups;
  for(auto &m : polVectorMatrices)
    {
      dualConstraintGroups.push_back(
        dual_constraint_group_from_pol_vec_mat(m));
    }

  // Split affineObjective into objectiveConst f and dualObjective b
  auto affine(affineObjective.begin());
  assert(affine != affineObjective.end());
  Real objectiveConst(*affine);
  ++affine;
  Vector dualObjective(affine, affineObjective.end());

  fill_from_dual_constraint_groups(dualObjective, objectiveConst,
                                   dualConstraintGroups, sdp);
}
{'fraction_non_alphanumeric': 0.16963260619977039, 'fraction_numerical': 0.004879448909299655, 'mean_word_length': 4.3125, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2222593', 'n_tokens_mistral': 1029, 'n_tokens_neox': 960, 'n_words': 247}