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


C++ Array2D::nColumns方法代码示例

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


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

示例1: coeffs

ChebyshevRate::ChebyshevRate(double Tmin, double Tmax, double Pmin, double Pmax,
                             const Array2D& coeffs)
    : Tmin_(Tmin)
    , Tmax_(Tmax)
    , Pmin_(Pmin)
    , Pmax_(Pmax)
    , nP_(coeffs.nColumns())
    , nT_(coeffs.nRows())
    , chebCoeffs_(coeffs.nColumns() * coeffs.nRows(), 0.0)
    , dotProd_(coeffs.nRows())
{
    double logPmin = std::log10(Pmin);
    double logPmax = std::log10(Pmax);
    double TminInv = 1.0 / Tmin;
    double TmaxInv = 1.0 / Tmax;

    TrNum_ = - TminInv - TmaxInv;
    TrDen_ = 1.0 / (TmaxInv - TminInv);
    PrNum_ = - logPmin - logPmax;
    PrDen_ = 1.0 / (logPmax - logPmin);

    for (size_t t = 0; t < nT_; t++) {
        for (size_t p = 0; p < nP_; p++) {
            chebCoeffs_[nP_*t + p] = coeffs(t,p);
        }
    }
}
开发者ID:MrKingKong,项目名称:cantera,代码行数:27,代码来源:RxnRates.cpp

示例2: outputExcel

  /*
   * @param s          output stream 
   * @param title      plot title 
   * @param names      vector of variable names
   * @param data       N x M data array.
   *                        data(n,m) is the m^th value of the n^th variable.
   */
  void outputExcel(std::ostream &s, const std::string &title, 
		   const std::vector<std::string>& names,  
		   const Array2D& data) {
    int i,j;
    int npts = static_cast<int>(data.nColumns());
    int nv = static_cast<int>(data.nRows());
    s << title + "," << endl;
    for (i = 0; i < nv; i++) {
      s << names[i] << ",";
    }
    s << endl;
    for (i = 0; i < npts; i++) {
      for (j = 0; j < nv; j++) {
	s << data(j,i) << ",";
      }
      s << endl;
    }
  }
开发者ID:anujg1991,项目名称:cantera,代码行数:25,代码来源:plots.cpp

示例3: outputTEC

  /*
   * @param s        output stream 
   * @param title    plot title 
   * @param names    vector of variable names 
   * @param data      N x M data array. 
   *                 data(n,m) is the m^th value of the n^th variable.
   */
  void outputTEC(std::ostream &s, const std::string &title,
		 const std::vector<std::string>& names,  
		 const Array2D& data) {
    int i,j;
    int npts = static_cast<int>(data.nColumns());
    int nv = static_cast<int>(data.nRows());
    s << "TITLE     = \"" + title + "\"" << endl;
    s << "VARIABLES = " << endl;
    for (i = 0; i < nv; i++) {
      s << "\"" << names[i] << "\"" << endl;
    }
    s << "ZONE T=\"zone1\"" << endl;
    s << " I=" << npts << ",J=1,K=1,F=POINT" << endl;
    s << "DT=( ";
    for (i = 0; i < nv; i++) s << " SINGLE";
    s << " )" << endl;
    for (i = 0; i < npts; i++) {
      for (j = 0; j < nv; j++) {
	s << data(j,i) << " ";
      }
      s << endl;
    }
  }
开发者ID:anujg1991,项目名称:cantera,代码行数:30,代码来源:plots.cpp

示例4: getMatrixValues

void getMatrixValues(const XML_Node& node,
                     const std::vector<std::string>& keyStringRow,
                     const std::vector<std::string>& keyStringCol,
                     Array2D& retnValues, const bool convert,
                     const bool matrixSymmetric)
{
    if (keyStringRow.size() > retnValues.nRows()) {
        throw CanteraError("getMatrixValues",
                           "size of key1 greater than numrows");
    } else if (keyStringCol.size() > retnValues.nColumns()) {
        throw CanteraError("getMatrixValues",
                           "size of key2 greater than num cols");
    } else if (matrixSymmetric && retnValues.nRows() != retnValues.nColumns()) {
        throw CanteraError("getMatrixValues",
                           "nrow != ncol for a symmetric matrix");
    }

    /*
     * Get the attributes field, units, from the XML node
     * and determine the conversion factor, funit.
     */
    doublereal funit = 1.0;
    if (convert && node["units"] != "") {
        funit = toSI(node["units"]);
    }

    vector<string> v;
    getStringArray(node, v);
    for (size_t i = 0; i < v.size(); i++) {
        size_t icolon = v[i].find(":");
        if (icolon == string::npos) {
            throw CanteraError("getMatrixValues","Missing two colons ("
                               +v[i]+")");
        }
        string key1 = v[i].substr(0,icolon);
        string rmm = v[i].substr(icolon+1, v[i].size());

        icolon = rmm.find(":");
        if (icolon == string::npos) {
            throw CanteraError("getMatrixValues","Missing one colon ("
                               +v[i]+")");
        }

        size_t irow = find(keyStringRow.begin(), keyStringRow.end(), key1)
                      - keyStringRow.begin();
        if (irow == keyStringRow.size()) {
            throw CanteraError("getMatrixValues","Row not matched by string: "
                               + key1);
        }

        string key2 = rmm.substr(0,icolon);
        size_t icol = find(keyStringCol.begin(), keyStringCol.end(), key2)
                      - keyStringCol.begin();
        if (icol == keyStringCol.size()) {
            throw CanteraError("getMatrixValues","Col not matched by string: "
                               + key2);
        }
        double dval = fpValueCheck(rmm.substr(icolon+1, rmm.size())) * funit;
        /*
         * Finally, insert the value;
         */
        retnValues(irow, icol) = dval;
        if (matrixSymmetric) {
            retnValues(icol, irow) = dval;
        }
    }
}
开发者ID:iokto,项目名称:cantera,代码行数:67,代码来源:ctml.cpp


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