当前位置: 首页>>代码示例>>C++>>正文


C++ vector_fp::resize方法代码示例

本文整理汇总了C++中vector_fp::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_fp::resize方法的具体用法?C++ vector_fp::resize怎么用?C++ vector_fp::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vector_fp的用法示例。


在下文中一共展示了vector_fp::resize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getMolecularWeights

void Phase::getMolecularWeights(vector_fp& weights) const
{
    const vector_fp& mw = molecularWeights();
    if (weights.size() < mw.size()) {
        weights.resize(mw.size());
    }
    copy(mw.begin(), mw.end(), weights.begin());
}
开发者ID:anujg1991,项目名称:cantera,代码行数:8,代码来源:Phase.cpp

示例2: saveState

void Phase::saveState(vector_fp& state) const
{
    state.resize(nSpecies() + 2);
    saveState(state.size(), &state[0]);
}
开发者ID:MrKingKong,项目名称:cantera,代码行数:5,代码来源:Phase.cpp

示例3: CK_SyntaxError

  /**
   *
   * Read species data from THERMO section records. 
   * 
   * @param names        List of species names (input).
   * @param species      Table of species objects holding data from records
   *                     in THERMO section (output). 
   * @param temp         Devault vector of temperature region boundaries
   *                     There are one more temperatures than there are
   *                     temperature regions.
   * @param allowExtThermoData   True if 'THERMO' specified, false if 
   *                             'THERMO ALL' specified.
   *
   * @return            True, if the THERMO section exists and the species
   *                    have all been successfully processed. False, if
   *                    the THERMO section doesn't exist or there were
   *                    additional problems.
   */
  bool CKParser::readNASA9ThermoSection(std::vector<string>& names, 
					speciesTable& species, vector_fp& temp, 
					int& optionFlag, std::ostream& log) {
    // String buffer for lines
    string s;
    vector<string> toks;
    string defaultDate="";
    int nreg = 2;
    int i;

    int nsp = static_cast<int>(names.size());

    // Comment string
    string comment;


    // if "THERMO ALL" specified, or if optionFlag is set to HasTempRange,
    // then the next line must be the default temperatures for the database.
    //
    //  This line will have nreg+2 tokens on it
    //    The last token is a date.
    if (0) {
      if (optionFlag == NoThermoDatabase || optionFlag == HasTempRange) {
	getCKLine(s, comment);
	getTokens(s, static_cast<int>(s.size()), toks);
	nreg = toks.size();
	if (nreg >= 1) {
	  temp.resize(nreg+1);
	  for (i = 0; i <= nreg; i++) {
	    temp[i] = de_atof(toks[i]);
	  }
	  defaultDate = toks[nreg+1];
	}
      
	if (verbose) {
	  log.flags(ios::showpoint | ios::fixed);
	  log.precision(2);
	  log << endl << " Default # of temperature regions: " << nreg << endl;
	  log << "          ";
	  for (i = 0; i <= nreg; i++) {
	    log << temp[i] << "  ";
	  }
	  log << endl;
	}
	checkNASA9Temps(log, temp);
      }
    }
    
    // Check to see that we expect to be reading a NASA9 formatted file
    if (!m_nasa9fmt) {
      throw CK_SyntaxError(log, 
			   "In NASA9 parser. However, we expect a different file format",
			   -1);
    }

    // now read in all species records that have names in list 'names'

    bool getAllSpecies = (nsp > 0 && match(names[0], "<ALL>"));
    if (getAllSpecies) names.clear();

    // Map between the number of times a species name appears in the database
    map<string, int> dup; // used to check for duplicate THERMO records
    bool already_read;

    while (1 > 0) {
      // If we don't have any more species to read, break
      if (nsp == 0) break;
      already_read = false;

      // Read a new species record from the section
      Species spec;
      readNASA9ThermoRecord(spec);

      // we signal the end of the section by putting <END> as a
      // species name. Break if you find the end of the section.
      if (spec.name == "<END>") {
	break;
      }
        
      // check for duplicate thermo data
      if (dup[spec.name] == 2) {
	log << "Warning: more than one THERMO record for "
//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:NASA9Parser.cpp

示例4: BasisOptimize

size_t BasisOptimize(int* usedZeroedSpecies, bool doFormRxn, MultiPhase* mphase,
                     std::vector<size_t>& orderVectorSpecies,
                     std::vector<size_t>& orderVectorElements,
                     vector_fp& formRxnMatrix)
{
    // Get the total number of elements defined in the multiphase object
    size_t ne = mphase->nElements();

    // Get the total number of species in the multiphase object
    size_t nspecies = mphase->nSpecies();

    // Perhaps, initialize the element ordering
    if (orderVectorElements.size() < ne) {
        orderVectorElements.resize(ne);
        iota(orderVectorElements.begin(), orderVectorElements.end(), 0);
    }

    // Perhaps, initialize the species ordering
    if (orderVectorSpecies.size() != nspecies) {
        orderVectorSpecies.resize(nspecies);
        iota(orderVectorSpecies.begin(), orderVectorSpecies.end(), 0);
    }

    if (BasisOptimize_print_lvl >= 1) {
        writelog("   ");
        writeline('-', 77);
        writelog("   --- Subroutine BASOPT called to ");
        writelog("calculate the number of components and ");
        writelog("evaluate the formation matrix\n");
        if (BasisOptimize_print_lvl > 0) {
            writelog("   ---\n");

            writelog("   ---      Formula Matrix used in BASOPT calculation\n");
            writelog("   ---      Species | Order | ");
            for (size_t j = 0; j < ne; j++) {
                size_t jj = orderVectorElements[j];
                writelog(" {:>4.4s}({:1d})", mphase->elementName(jj), j);
            }
            writelog("\n");
            for (size_t k = 0; k < nspecies; k++) {
                size_t kk = orderVectorSpecies[k];
                writelog("   --- {:>11.11s} |   {:4d} |",
                         mphase->speciesName(kk), k);
                for (size_t j = 0; j < ne; j++) {
                    size_t jj = orderVectorElements[j];
                    double num = mphase->nAtoms(kk,jj);
                    writelogf("%6.1g  ", num);
                }
                writelog("\n");
            }
            writelog("   --- \n");
        }
    }

    // Calculate the maximum value of the number of components possible. It's
    // equal to the minimum of the number of elements and the number of total
    // species.
    size_t nComponents = std::min(ne, nspecies);
    size_t nNonComponents = nspecies - nComponents;

    // Set this return variable to false
    *usedZeroedSpecies = false;

    // Create an array of mole numbers
    vector_fp molNum(nspecies,0.0);
    mphase->getMoles(molNum.data());

    // Other workspace
    vector_fp sm(ne*ne, 0.0);
    vector_fp ss(ne, 0.0);
    vector_fp sa(ne, 0.0);
    if (formRxnMatrix.size() < nspecies*ne) {
        formRxnMatrix.resize(nspecies*ne, 0.0);
    }

    // For debugging purposes keep an unmodified copy of the array.
    vector_fp molNumBase = molNum;
    double molSave = 0.0;
    size_t jr = 0;

    // Top of a loop of some sort based on the index JR. JR is the current
    // number of component species found.
    while (jr < nComponents) {
        // Top of another loop point based on finding a linearly independent
        // species
        size_t k = npos;
        while (true) {
            // Search the remaining part of the mole number vector, molNum for
            // the largest remaining species. Return its identity. kk is the raw
            // number. k is the orderVectorSpecies index.
            size_t kk = max_element(molNum.begin(), molNum.end()) - molNum.begin();
            size_t j;
            for (j = 0; j < nspecies; j++) {
                if (orderVectorSpecies[j] == kk) {
                    k = j;
                    break;
                }
            }
            if (j == nspecies) {
                throw CanteraError("BasisOptimize", "orderVectorSpecies contains an error");
//.........这里部分代码省略.........
开发者ID:MrKingKong,项目名称:cantera,代码行数:101,代码来源:BasisOptimize.cpp

示例5: getMolecularWeights

 /*
  * Copy the vector of molecular weights into vector weights.
  */
 void Phase::getMolecularWeights(vector_fp& weights) const {
   const array_fp& mw = Constituents::molecularWeights();
   if (weights.size() < mw.size()) weights.resize(mw.size());
   copy(mw.begin(), mw.end(), weights.begin());
 }
开发者ID:anujg1991,项目名称:cantera,代码行数:8,代码来源:Phase.cpp

示例6: BasisOptimize

/*
 * Choose the optimum basis for the calculations. This is done by
 * choosing the species with the largest mole fraction
 * not currently a linear combination of the previous components.
 * Then, calculate the stoichiometric coefficient matrix for that
 * basis.
 *
 * Calculates the identity of the component species in the mechanism.
 * Rearranges the solution data to put the component data at the
 * front of the species list.
 *
 * Then, calculates SC(J,I) the formation reactions for all noncomponent
 * species in the mechanism.
 *
 * Input
 * ---------
 * mphase          Pointer to the multiphase object. Contains the
 *                 species mole fractions, which are used to pick the
 *                 current optimal species component basis.
 * orderVectorElement
 *                 Order vector for the elements. The element rows
 *                 in the formula matrix are
 *                 rearranged according to this vector.
 * orderVectorSpecies
 *                 Order vector for the species. The species are
 *                 rearranged according to this formula. The first
 *                 nCompoments of this vector contain the calculated
 *                 species components on exit.
 * doFormRxn       If true, the routine calculates the formation
 *                 reaction matrix based on the calculated
 *                 component species. If false, this step is skipped.
 *
 * Output
 * ---------
 * usedZeroedSpecies = If true, then a species with a zero concentration
 *                     was used as a component. The problem may be
 *                     converged.
 * formRxnMatrix
 *
 * Return
 * --------------
 * returns the number of components.
 *
 *
 */
size_t Cantera::BasisOptimize(int* usedZeroedSpecies, bool doFormRxn,
                              MultiPhase* mphase, std::vector<size_t>& orderVectorSpecies,
                              std::vector<size_t>& orderVectorElements,
                              vector_fp& formRxnMatrix)
{

    size_t  j, jj, k=0, kk, l, i, jl, ml;
    bool lindep;
    std::string ename;
    std::string sname;
    /*
     * Get the total number of elements defined in the multiphase object
     */
    size_t ne = mphase->nElements();
    /*
     * Get the total number of species in the multiphase object
     */
    size_t nspecies = mphase->nSpecies();
    doublereal tmp;
    doublereal const USEDBEFORE = -1;

    /*
     * Perhaps, initialize the element ordering
     */
    if (orderVectorElements.size() < ne) {
        orderVectorElements.resize(ne);
        for (j = 0; j < ne; j++) {
            orderVectorElements[j] = j;
        }
    }

    /*
     * Perhaps, initialize the species ordering
     */
    if (orderVectorSpecies.size() != nspecies) {
        orderVectorSpecies.resize(nspecies);
        for (k = 0; k < nspecies; k++) {
            orderVectorSpecies[k] = k;
        }
    }

#ifdef DEBUG_MODE
    double molSave = 0.0;
    if (BasisOptimize_print_lvl >= 1) {
        writelog("   ");
        for (i=0; i<77; i++) {
            writelog("-");
        }
        writelog("\n");
        writelog("   --- Subroutine BASOPT called to ");
        writelog("calculate the number of components and ");
        writelog("evaluate the formation matrix\n");
        if (BasisOptimize_print_lvl > 0) {
            writelog("   ---\n");

//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:BasisOptimize.cpp


注:本文中的vector_fp::resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。