diff --git a/include/cantera/equil/vcs_internal.h b/include/cantera/equil/vcs_internal.h index 14920a521..3228698e2 100644 --- a/include/cantera/equil/vcs_internal.h +++ b/include/cantera/equil/vcs_internal.h @@ -223,128 +223,6 @@ int vcsUtil_root1d(double xmin, double xmax, size_t itmax, VCS_FUNC_PTR func, */ double vcs_second(); -//! This define turns on using memset and memcpy. I have not run into -//! any systems where this is a problem. It's the fastest way to do -//! low lvl operations where applicable. There are alternative routines -//! available if this ever fails. -#define USE_MEMSET -#ifdef USE_MEMSET - -//! Zero a double vector -/*! - * @param vec_to vector of doubles - * @param length length of the vector to zero. - */ -inline void vcs_dzero(double* const vec_to, const size_t length) -{ - (void) memset((void*) vec_to, 0, length * sizeof(double)); -} - -//! Zero an int vector -/*! - * @param vec_to vector of ints - * @param length length of the vector to zero. - */ -inline void vcs_izero(int* const vec_to, const size_t length) -{ - (void) memset((void*) vec_to, 0, length * sizeof(int)); -} - -//! Copy a double vector -/*! - * @param vec_to Vector to copy into. This vector must be dimensioned - * at least as large as the vec_from vector. - * @param vec_from Vector to copy from - * @param length Number of doubles to copy. - */ -inline void vcs_dcopy(double* const vec_to, - const double* const vec_from, const size_t length) -{ - (void) memcpy((void*) vec_to, (const void*) vec_from, - (length) * sizeof(double)); -} - -//! Copy an int vector -/*! - * @param vec_to Vector to copy into. This vector must be dimensioned - * at least as large as the vec_from vector. - * @param vec_from Vector to copy from - * @param length Number of int to copy. - */ -inline void vcs_icopy(int* const vec_to, - const int* const vec_from, const size_t length) -{ - (void) memcpy((void*) vec_to, (const void*) vec_from, - (length) * sizeof(int)); -} - -//! Zero a std double vector -/*! - * @param vec_to vector of doubles - * @param length length of the vector to zero. - */ -inline void vcs_vdzero(std::vector &vec_to, const size_t length) -{ - (void) memset((void*)VCS_DATA_PTR(vec_to), 0, (length) * sizeof(double)); -} - -//! Zero a std int vector -/*! - * @param vec_to vector of ints - * @param length length of the vector to zero. - */ -inline void vcs_vizero(std::vector &vec_to, const size_t length) -{ - (void) memset((void*)VCS_DATA_PTR(vec_to), 0, (length) * sizeof(int)); -} - -//! Copy one std double vector into another -/*! - * This is an inlined function that uses memcpy. memcpy is probably - * the fastest way to do this. This routine requires the vectors to be - * previously dimensioned appropriately. No error checking is done. - * - * @param vec_to Vector to copy into. This vector must be dimensioned - * at least as large as the vec_from vector. - * @param vec_from Vector to copy from - * @param length Number of doubles to copy. - */ -inline void vcs_vdcopy(std::vector & vec_to, - const std::vector & vec_from, size_t length) -{ - (void) memcpy((void*)&(vec_to[0]), (const void*) &(vec_from[0]), - (length) * sizeof(double)); -} - -//! Copy one std integer vector into another -/*! - * This is an inlined function that uses memcpy. memcpy is probably - * the fastest way to do this. - * - * @param vec_to Vector to copy into. This vector must be dimensioned - * at least as large as the vec_from vector. - * @param vec_from Vector to copy from - * @param length Number of integers to copy. - */ -inline void vcs_vicopy(std::vector & vec_to, - const std::vector & vec_from, const int length) -{ - (void) memcpy((void*)&(vec_to[0]), (const void*) &(vec_from[0]), - (length) * sizeof(int)); -} -#else -extern void vcs_dzero(double* const, const int); -extern void vcs_izero(int* const , const int); -extern void vcs_dcopy(double* const, const double* const, const int); -extern void vcs_icopy(int* const, const int* const, const int); -extern void vcs_vdzero(std::vector &vvv, const int len = -1); -extern void vcs_vizero(std::vector &vvv, const int len = -1); -void vcs_vdcopy(std::vector &vec_to, - const std::vector vec_from, const int len = -1); -void vcs_vicopy(std::vector &vec_to, - const std::vector vec_from, const int len = -1); -#endif - //! determine the l2 norm of a vector of doubles /*! * @param vec vector of doubles diff --git a/src/equil/vcs_VolPhase.cpp b/src/equil/vcs_VolPhase.cpp index 15aeec0a7..d68a2949f 100644 --- a/src/equil/vcs_VolPhase.cpp +++ b/src/equil/vcs_VolPhase.cpp @@ -548,8 +548,7 @@ void vcs_VolPhase::setMolesFromVCS(const int stateCalc, */ if (stateCalc == VCS_STATECALC_OLD) { if (v_totalMoles > 0.0) { - vcs_dcopy(VCS_DATA_PTR(creationMoleNumbers_), VCS_DATA_PTR(Xmol_), m_numSpecies); - + creationMoleNumbers_ = Xmol_; } } @@ -794,7 +793,7 @@ void vcs_VolPhase::_updateLnActCoeffJac() * Revert to the base case Xmol_, v_totalMoles */ v_totalMoles = TMoles_base; - vcs_vdcopy(Xmol_, Xmol_Base, m_numSpecies); + Xmol_ = Xmol_Base; } /* * Go get base values for the activity coefficients. @@ -847,7 +846,7 @@ void vcs_VolPhase::setPtrThermoPhase(Cantera::ThermoPhase* tp_ptr) resize(VP_ID_, nsp, nelem, PhaseName.c_str()); } TP_ptr->getMoleFractions(VCS_DATA_PTR(Xmol_)); - vcs_dcopy(VCS_DATA_PTR(creationMoleNumbers_), VCS_DATA_PTR(Xmol_), m_numSpecies); + creationMoleNumbers_ = Xmol_; _updateMoleFractionDependencies(); /* @@ -897,7 +896,7 @@ double vcs_VolPhase::molefraction(size_t k) const void vcs_VolPhase::setCreationMoleNumbers(const double* const n_k, const std::vector &creationGlobalRxnNumbers) { - vcs_dcopy(VCS_DATA_PTR(creationMoleNumbers_), n_k, m_numSpecies); + creationMoleNumbers_.assign(n_k, n_k+m_numSpecies); for (size_t k = 0; k < m_numSpecies; k++) { creationGlobalRxnNumbers_[k] = creationGlobalRxnNumbers[k]; } diff --git a/src/equil/vcs_elem.cpp b/src/equil/vcs_elem.cpp index cd9935d3c..911895be0 100644 --- a/src/equil/vcs_elem.cpp +++ b/src/equil/vcs_elem.cpp @@ -110,8 +110,7 @@ int VCS_SOLVE::vcs_elcorr(double aa[], double x[]) int retn = 0; #ifdef DEBUG_MODE - std::vector ga_save(m_numElemConstraints, 0.0); - vcs_dcopy(VCS_DATA_PTR(ga_save), VCS_DATA_PTR(m_elemAbundances), m_numElemConstraints); + std::vector ga_save(m_elemAbundances); if (m_debug_print_lvl >= 2) { plogf(" --- vcsc_elcorr: Element abundances correction routine"); if (m_numElemConstraints != m_numComponents) { diff --git a/src/equil/vcs_inest.cpp b/src/equil/vcs_inest.cpp index 32dae0db9..5e915ae38 100644 --- a/src/equil/vcs_inest.cpp +++ b/src/equil/vcs_inest.cpp @@ -65,7 +65,7 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm, * Make sure all species have positive definite mole numbers * Set voltages to zero for now, until we figure out what to do */ - vcs_dzero(VCS_DATA_PTR(m_deltaMolNumSpecies), nspecies); + m_deltaMolNumSpecies.assign(m_deltaMolNumSpecies.size(), 0.0); for (size_t kspec = 0; kspec < nspecies; ++kspec) { if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { if (m_molNumSpecies_old[kspec] <= 0.0) { @@ -113,14 +113,13 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm, TMolesMultiphase += m_tPhaseMoles_new[iph]; } } - vcs_dcopy(VCS_DATA_PTR(m_molNumSpecies_new), VCS_DATA_PTR(m_molNumSpecies_old), nspecies); + m_molNumSpecies_new = m_molNumSpecies_old; for (size_t kspec = 0; kspec < m_numComponents; ++kspec) { if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_MOLNUM) { m_molNumSpecies_new[kspec] = 0.0; } } - vcs_dcopy(VCS_DATA_PTR(m_feSpecies_new), VCS_DATA_PTR(m_SSfeSpecies), - nspecies); + m_feSpecies_new = m_SSfeSpecies; for (size_t kspec = 0; kspec < m_numComponents; ++kspec) { if (m_speciesUnknownType[kspec] == VCS_SPECIES_TYPE_MOLNUM) { @@ -150,7 +149,7 @@ void VCS_SOLVE::vcs_inest(double* const aw, double* const sa, double* const sm, /* ********************************************************** */ double* xtphMax = VCS_DATA_PTR(m_TmpPhase); double* xtphMin = VCS_DATA_PTR(m_TmpPhase2); - vcs_dzero(VCS_DATA_PTR(m_deltaPhaseMoles), m_numPhases); + m_deltaPhaseMoles.assign(m_deltaPhaseMoles.size(), 0.0); for (size_t iph = 0; iph < m_numPhases; iph++) { xtphMax[iph] = log(m_tPhaseMoles_new[iph] * 1.0E32); xtphMin[iph] = log(m_tPhaseMoles_new[iph] * 1.0E-32); diff --git a/src/equil/vcs_phaseStability.cpp b/src/equil/vcs_phaseStability.cpp index f9d0a48b8..045f470e9 100644 --- a/src/equil/vcs_phaseStability.cpp +++ b/src/equil/vcs_phaseStability.cpp @@ -558,7 +558,7 @@ double VCS_SOLVE::vcs_phaseStabilityTest(const size_t iph) vector fracDelta_old(nsp, 0.0); vector fracDelta_raw(nsp, 0.0); vector creationGlobalRxnNumbers(nsp, npos); - vcs_dcopy(VCS_DATA_PTR(m_deltaGRxn_Deficient), VCS_DATA_PTR(m_deltaGRxn_old), m_numRxnRdc); + m_deltaGRxn_Deficient = m_deltaGRxn_old; vector m_feSpecies_Deficient(m_numComponents, 0.0); doublereal damp = 1.0; diff --git a/src/equil/vcs_prep.cpp b/src/equil/vcs_prep.cpp index c4858531a..9e2f1fd25 100644 --- a/src/equil/vcs_prep.cpp +++ b/src/equil/vcs_prep.cpp @@ -210,13 +210,13 @@ int VCS_SOLVE::vcs_prep() /* * Initialize various arrays in the data to zero */ - vcs_vdzero(m_feSpecies_old, m_numSpeciesTot); - vcs_vdzero(m_feSpecies_new, m_numSpeciesTot); - vcs_vdzero(m_molNumSpecies_new, m_numSpeciesTot); - vcs_dzero(&(m_deltaMolNumPhase(0,0)), m_numSpeciesTot * m_numPhases); + m_feSpecies_old.assign(m_feSpecies_old.size(), 0.0); + m_feSpecies_new.assign(m_feSpecies_new.size(), 0.0); + m_molNumSpecies_new.assign(m_molNumSpecies_new.size(), 0.0); + m_deltaMolNumPhase.zero(); m_phaseParticipation.zero(); - vcs_dzero(VCS_DATA_PTR(m_deltaPhaseMoles), m_numPhases); - vcs_dzero(VCS_DATA_PTR(m_tPhaseMoles_new), m_numPhases); + m_deltaPhaseMoles.assign(m_deltaPhaseMoles.size(), 0.0); + m_tPhaseMoles_new.assign(m_tPhaseMoles_new.size(), 0.0); /* * Calculate the total number of moles in all phases. */ diff --git a/src/equil/vcs_prob.cpp b/src/equil/vcs_prob.cpp index d362195ca..027650679 100644 --- a/src/equil/vcs_prob.cpp +++ b/src/equil/vcs_prob.cpp @@ -156,8 +156,8 @@ void VCS_PROB::resizeElements(size_t nel, int force) void VCS_PROB::set_gai() { + gai.assign(gai.size(), 0.0); double* ElemAbund = VCS_DATA_PTR(gai); - vcs_dzero(ElemAbund, ne); for (size_t j = 0; j < ne; j++) { for (size_t kspec = 0; kspec < nspecies; kspec++) { diff --git a/src/equil/vcs_rxnadj.cpp b/src/equil/vcs_rxnadj.cpp index 68a520d91..038505e1f 100644 --- a/src/equil/vcs_rxnadj.cpp +++ b/src/equil/vcs_rxnadj.cpp @@ -710,7 +710,7 @@ double VCS_SOLVE::vcs_line_search(const size_t irxn, const double dx_orig, char* return 0.0; } - vcs_dcopy(VCS_DATA_PTR(m_molNumSpecies_new), molNumBase, m_numSpeciesRdc); + m_molNumSpecies_new = m_molNumSpecies_old; double molSum = molNumBase[kspec]; m_molNumSpecies_new[kspec] = molNumBase[kspec] + dx_orig; for (size_t k = 0; k < m_numComponents; k++) { diff --git a/src/equil/vcs_solve.cpp b/src/equil/vcs_solve.cpp index 9ac0d61a4..3dc1a6243 100644 --- a/src/equil/vcs_solve.cpp +++ b/src/equil/vcs_solve.cpp @@ -460,12 +460,12 @@ int VCS_SOLVE::vcs_prob_specifyFully(const VCS_PROB* pub) /* * Copy over the species molecular weights */ - vcs_vdcopy(m_wtSpecies, pub->WtSpecies, nspecies); + m_wtSpecies = pub->WtSpecies; /* * Copy over the charges */ - vcs_vdcopy(m_chargeSpecies, pub->Charge, nspecies); + m_chargeSpecies = pub->Charge; /* * Malloc and Copy the VCS_SPECIES_THERMO structures @@ -484,8 +484,7 @@ int VCS_SOLVE::vcs_prob_specifyFully(const VCS_PROB* pub) /* * Copy the species unknown type */ - vcs_icopy(VCS_DATA_PTR(m_speciesUnknownType), - VCS_DATA_PTR(pub->SpeciesUnknownType), nspecies); + m_speciesUnknownType = pub->SpeciesUnknownType; /* * iest => Do we have an initial estimate of the species mole numbers ? @@ -496,10 +495,10 @@ int VCS_SOLVE::vcs_prob_specifyFully(const VCS_PROB* pub) * w[] -> Copy the equilibrium mole number estimate if it exists. */ if (pub->w.size() != 0) { - vcs_vdcopy(m_molNumSpecies_old, pub->w, nspecies); + m_molNumSpecies_old = pub->w; } else { m_doEstimateEquil = -1; - vcs_dzero(VCS_DATA_PTR(m_molNumSpecies_old), nspecies); + m_molNumSpecies_old.assign(m_molNumSpecies_old.size(), 0.0); } /* @@ -747,7 +746,7 @@ int VCS_SOLVE::vcs_prob_specifyFully(const VCS_PROB* pub) */ m_totalVol = pub->Vol; if (m_PMVolumeSpecies.size() != 0) { - vcs_dcopy(VCS_DATA_PTR(m_PMVolumeSpecies), VCS_DATA_PTR(pub->VolPM), nspecies); + m_PMVolumeSpecies = pub->VolPM; } /* diff --git a/src/equil/vcs_solve_TP.cpp b/src/equil/vcs_solve_TP.cpp index 505a72d7f..e596cf3f7 100644 --- a/src/equil/vcs_solve_TP.cpp +++ b/src/equil/vcs_solve_TP.cpp @@ -333,7 +333,7 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit) * Evaluate the final mole fractions * storing them in wt[] */ - vcs_vdzero(m_molNumSpecies_new, m_numSpeciesTot); + m_molNumSpecies_new.assign(m_molNumSpecies_new.size(), 0.0); for (size_t kspec = 0; kspec < m_numSpeciesTot; ++kspec) { if (m_SSPhase[kspec]) { m_molNumSpecies_new[kspec] = 1.0; @@ -467,18 +467,18 @@ void VCS_SOLVE::solve_tp_inner(size_t& iti, size_t& it1, /* * Copy the old solution into the new solution as an initial guess */ - vcs_dcopy(VCS_DATA_PTR(m_feSpecies_new), VCS_DATA_PTR(m_feSpecies_old), m_numSpeciesRdc); - vcs_dcopy(VCS_DATA_PTR(m_actCoeffSpecies_new), VCS_DATA_PTR(m_actCoeffSpecies_old), m_numSpeciesRdc); - vcs_dcopy(VCS_DATA_PTR(m_deltaGRxn_new), VCS_DATA_PTR(m_deltaGRxn_old), m_numRxnRdc); - vcs_dcopy(VCS_DATA_PTR(m_deltaGRxn_Deficient), VCS_DATA_PTR(m_deltaGRxn_old), m_numRxnRdc); - vcs_dcopy(VCS_DATA_PTR(m_tPhaseMoles_new), VCS_DATA_PTR(m_tPhaseMoles_old), m_numPhases); + m_feSpecies_new = m_feSpecies_old; + m_actCoeffSpecies_new = m_actCoeffSpecies_old; + m_deltaGRxn_new = m_deltaGRxn_old; + m_deltaGRxn_Deficient = m_deltaGRxn_old; + m_tPhaseMoles_new = m_tPhaseMoles_old; /* * Zero out the entire vector of updates. We sometimes would * query these values below, and we want to be sure that no * information is left from previous iterations. */ - vcs_dzero(VCS_DATA_PTR(m_deltaMolNumSpecies), m_numSpeciesTot); + m_deltaMolNumSpecies.assign(m_deltaMolNumSpecies.size(), 0.0); /*************************************************************************/ /************** DETERMINE IF DEAD PHASES POP INTO EXISTENCE **************/ @@ -527,7 +527,7 @@ void VCS_SOLVE::solve_tp_inner(size_t& iti, size_t& it1, /* * Zero out the net change in moles of multispecies phases */ - vcs_dzero(VCS_DATA_PTR(m_deltaPhaseMoles), m_numPhases); + m_deltaPhaseMoles.assign(m_deltaPhaseMoles.size(), 0.0); /* ********************************************************************** */ /* ***************** MAIN LOOP IN CALCULATION *************************** */ @@ -1280,13 +1280,11 @@ void VCS_SOLVE::solve_tp_inner(size_t& iti, size_t& it1, * loop. */ vcs_updateMolNumVolPhases(VCS_STATECALC_NEW); - vcs_dcopy(VCS_DATA_PTR(m_tPhaseMoles_old), VCS_DATA_PTR(m_tPhaseMoles_new), m_numPhases); - vcs_dcopy(VCS_DATA_PTR(m_molNumSpecies_old), VCS_DATA_PTR(m_molNumSpecies_new), - m_numSpeciesRdc); - vcs_dcopy(VCS_DATA_PTR(m_actCoeffSpecies_old), - VCS_DATA_PTR(m_actCoeffSpecies_new), m_numSpeciesRdc); - vcs_dcopy(VCS_DATA_PTR(m_deltaGRxn_old), VCS_DATA_PTR(m_deltaGRxn_new), m_numRxnRdc); - vcs_dcopy(VCS_DATA_PTR(m_feSpecies_old), VCS_DATA_PTR(m_feSpecies_new), m_numSpeciesRdc); + m_tPhaseMoles_old = m_tPhaseMoles_new; + m_molNumSpecies_old = m_molNumSpecies_new; + m_actCoeffSpecies_old = m_actCoeffSpecies_new; + m_deltaGRxn_old = m_deltaGRxn_new; + m_feSpecies_old = m_feSpecies_new; vcs_setFlagsVolPhases(true, VCS_STATECALC_OLD); /* @@ -2336,7 +2334,7 @@ size_t VCS_SOLVE::vcs_add_all_deleted() * We are relying here on a old saved value of m_actCoeffSpecies_old[kspec] * being sufficiently good. Note, we will recalculate everything at the end of the routine. */ - vcs_dcopy(VCS_DATA_PTR(m_molNumSpecies_new), VCS_DATA_PTR(m_molNumSpecies_old), m_numSpeciesTot); + m_molNumSpecies_new = m_molNumSpecies_old; for (int cits = 0; cits < 3; cits++) { for (size_t kspec = m_numSpeciesRdc; kspec < m_numSpeciesTot; ++kspec) { @@ -2499,8 +2497,7 @@ bool VCS_SOLVE::vcs_globStepDamp() /* **** ADJUST MOLE NUMBERS, CHEM. POT *************** */ /* *************************************************** */ if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { - vcs_dcopy(VCS_DATA_PTR(m_deltaGRxn_tmp), VCS_DATA_PTR(m_deltaGRxn_new), - m_numRxnRdc); + m_deltaGRxn_tmp = m_deltaGRxn_new; } dptr = VCS_DATA_PTR(m_molNumSpecies_new); @@ -2610,7 +2607,8 @@ int VCS_SOLVE::vcs_basopt(const bool doJustComponents, double aw[], double sa[], /* * Use a temporary work array for the mole numbers, aw[] */ - vcs_dcopy(aw, VCS_DATA_PTR(m_molNumSpecies_old), m_numSpeciesTot); + std::copy(m_molNumSpecies_old.begin(), + m_molNumSpecies_old.begin() + m_numSpeciesTot, aw); /* * Take out the Voltage unknowns from consideration */ @@ -3076,7 +3074,7 @@ L_END_LOOP: /* * Zero out the change of Phase Moles array */ - vcs_dzero(&m_deltaMolNumPhase(0,0), (NSPECIES0)*(NPHASE0)); + m_deltaMolNumPhase.zero(); m_phaseParticipation.zero(); /* * Loop over each reaction, creating the change in Phase Moles @@ -3486,7 +3484,7 @@ void VCS_SOLVE::vcs_dfe(const int stateCalc, } } } - vcs_dzero(tlogMoles, m_numPhases); + m_TmpPhase.assign(m_TmpPhase.size(), 0.0); for (size_t iph = 0; iph < m_numPhases; iph++) { if (tPhMoles_ptr[iph] > 0.0) { tlogMoles[iph] = log(tPhMoles_ptr[iph]); diff --git a/src/equil/vcs_solve_phaseStability.cpp b/src/equil/vcs_solve_phaseStability.cpp index b427f78d3..68f943c0d 100644 --- a/src/equil/vcs_solve_phaseStability.cpp +++ b/src/equil/vcs_solve_phaseStability.cpp @@ -170,7 +170,7 @@ int VCS_SOLVE::vcs_solve_phaseStability(const int iph, const int ifunc, if (printLvl > 3) { vcs_printDeltaG(VCS_STATECALC_OLD); } - vcs_dcopy(VCS_DATA_PTR(m_deltaGRxn_Deficient), VCS_DATA_PTR(m_deltaGRxn_old), m_numRxnRdc); + m_deltaGRxn_Deficient = m_deltaGRxn_old; funcVal = vcs_phaseStabilityTest(iph); if (funcVal > 0.0) { iStab = 1; diff --git a/src/equil/vcs_util.cpp b/src/equil/vcs_util.cpp index f0ac93736..99eef7689 100644 --- a/src/equil/vcs_util.cpp +++ b/src/equil/vcs_util.cpp @@ -15,52 +15,6 @@ using namespace std; namespace VCSnonideal { -#ifndef USE_MEMSET -void vcs_dzero(double* vector, int length) -{ - for (int i = 0; i < length; i++) { - vector[i] = 0.0; - } -} -#endif - -#ifndef USE_MEMSET -void vcs_izero(int* vector, int length) -{ - for (int i = 0; i < length; i++) { - vector[i] = 0; - } -} -#endif - -#ifndef USE_MEMSET -void vcs_dcopy(double* const vec_to, const double* const vec_from, int length) -{ - for (int i = 0; i < length; i++) { - vec_to[i] = vec_from[i]; - } -} -#endif - -#ifndef USE_MEMSET -void vcs_icopy(int* vec_to, int* vec_from, int length) -{ - for (int i = 0; i < length; i++) { - vec_to[i] = vec_from[i]; - } -} -#endif - -#ifndef USE_MEMSET -void vcs_vdzero(std::vector &vvv, int len) -{ - if (len < 0) { - std::fill(vvv.begin(), vvv.end(), 0.0); - } else { - std::fill_n(vvv.begin(), len, 0.0); - } -} -#endif double vcs_l2norm(const std::vector vec) { @@ -76,33 +30,6 @@ double vcs_l2norm(const std::vector vec) return std::sqrt(sum / len); } -#ifndef USE_MEMSET -void vcs_vizero(std::vector &vvv, int len) -{ - if (len < 0) { - std::fill(vvv.begin(), vvv.end(), 0.0); - } else { - std::fill_n(vvv.begin(), len, 0.0); - } -} -#endif - -#ifndef USE_MEMSET -void vcs_vdcopy(std::vector &vec_to, - const std::vector & vec_from, int length) -{ - std::copy(vec_from.begin(), vec_from.begin() + length, vec_to.begin()); -} -#endif - -#ifndef USE_MEMSET -void vcs_vicopy(std::vector &vec_to, - const std::vector & vec_from, int length) -{ - std::copy(vec_from.begin(), vec_from.begin() + length, vec_to.begin()); -} -#endif - size_t vcs_optMax(const double* x, const double* xSize, size_t j, size_t n) { size_t largest = j;