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


C++ Vectors类代码示例

本文整理汇总了C++中Vectors的典型用法代码示例。如果您正苦于以下问题:C++ Vectors类的具体用法?C++ Vectors怎么用?C++ Vectors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: solutionNorms

bool NonlinearDriver::solutionNorms (const TimeDomain& time,
                                     double zero_tol, std::streamsize outPrec)
{
  if (msgLevel < 0 || solution.empty()) return true;

  const size_t nsd = model.getNoSpaceDim();

  size_t iMax[nsd];
  double dMax[nsd];
  double normL2 = model.solutionNorms(solution.front(),dMax,iMax);

  RealArray RF;
  bool haveReac = model.getCurrentReactions(RF,solution.front());

  Vectors gNorm;
  if (calcEn)
  {
    model.setMode(SIM::RECOVERY);
    model.setQuadratureRule(opt.nGauss[1]);
    if (!model.solutionNorms(time,solution,gNorm))
      gNorm.clear();
  }

  if (myPid > 0) return true;

  std::streamsize stdPrec = outPrec > 0 ? IFEM::cout.precision(outPrec) : 0;
  double old_tol = utl::zero_print_tol;
  utl::zero_print_tol = zero_tol;

  IFEM::cout <<"  Primary solution summary: L2-norm            : "
             << utl::trunc(normL2);

  for (unsigned char d = 0; d < nsd; d++)
    if (utl::trunc(dMax[d]) != 0.0)
      IFEM::cout <<"\n                            Max "<< char('X'+d)
                 <<"-displacement : "<< dMax[d] <<" node "<< iMax[d];

  if (haveReac)
  {
    IFEM::cout <<"\n  Total reaction forces: Sum(R) =";
    for (size_t i = 1; i < RF.size(); i++)
      IFEM::cout <<" "<< utl::trunc(RF[i]);
    if (utl::trunc(RF.front()) != 0.0)
      IFEM::cout <<"\n  displacement*reactions: (R,u) = "<< RF.front();
  }

  if (!gNorm.empty())
    this->printNorms(gNorm.front(),IFEM::cout);

  IFEM::cout << std::endl;
  utl::zero_print_tol = old_tol;
  if (stdPrec > 0) IFEM::cout.precision(stdPrec);
  return true;
}
开发者ID:OPM,项目名称:IFEM-Elasticity,代码行数:54,代码来源:NonlinearDriver.C

示例2: get_identifiers

  static boost::python::list
  get_identifiers(const Vectors& vec)
  {
    boost::python::list l;

    int nb_vec = vec.get_nb_vector();
    for (int v = 0; v < nb_vec; v++)
      {
        l.append(vec.get_identifier(v));
      }

    return l;
  }
开发者ID:jbdurand,项目名称:StructureAnalysis,代码行数:13,代码来源:export_vectors.cpp

示例3: check

 // check
 static bool
 check(Vectors& v)
 {
   StatError error;
   bool ret = v.check(error);
   return ret;
 }
开发者ID:jbdurand,项目名称:StructureAnalysis,代码行数:8,代码来源:export_vectors.cpp

示例4: assembleSystem

  virtual bool assembleSystem(const TimeDomain& time,
                              const Vectors& prevSol,
                              bool newLHSmatrix, bool)
  {
    const double M = 10.0;   // Mass of the oscillator
    const double K = 1000.0; // Stiffness of the oscillator
    const double F = 1.0;    // External load (constant)

    myEqSys->initialize(newLHSmatrix);

    bool ok;
    if (myProblem->getMode() == SIM::MASS_ONLY) {
      ElmMats elm;
      elm.resize(1,1); elm.redim(1);
      elm.A[0].fill(M); // Mass Matrix
      ok = myEqSys->assemble(&elm,1);
    }
    else {
      const double* intPrm = static_cast<Problem*>(myProblem)->getIntPrm();
      NewmarkMats elm(intPrm[0],intPrm[1],intPrm[2],intPrm[3]);
      elm.resize(3,1); elm.redim(1); elm.vec.resize(3);
      elm.setStepSize(time.dt,0);
      elm.A[1].fill(M); // Mass matrix
      elm.A[2].fill(K); // Stiffness matrix
      elm.b[0] = -K*prevSol.front(); // Elastic forces
      for (int i = 0; i < 3; i++) elm.vec[i] = prevSol[i];
      ok = myEqSys->assemble(&elm,1);
    }

    // Add in the external load
    ok &= mySam->assembleSystem(*myEqSys->getVector(),&F,1);

    return ok && myEqSys->finalize(newLHSmatrix);
  }
开发者ID:akva2,项目名称:IFEM,代码行数:34,代码来源:TestNewmark.C

示例5: main

int main(){
	Vectors<int>* newVector = new Vectors<int>(10,10,0);
	for (int i=0; i<10; ++i){
		for (int j=0; j<10; ++j){
			newVector->insert(i, j, 5);
		}
	}
	newVector->print();
	
	for (int i=0; i<10; ++i){
		for (int j=0; j<10; ++j){
			newVector->remove(i, j);
		}
	}
	newVector->print();
	delete newVector;
	return 0;
}
开发者ID:billymills,项目名称:sparse-array-api,代码行数:18,代码来源:vector_test.cpp

示例6: externalEnergy

double SIMLinElKL::externalEnergy (const Vectors& psol) const
{
  double energy = this->SIMbase::externalEnergy(psol);

  // External energy from the nodal point loads
  for (size_t i = 0; i < myLoads.size(); i++)
    energy += myLoads[i].pload * psol.front()(myLoads[i].inod);

  return energy;
}
开发者ID:OPM,项目名称:IFEM-Elasticity,代码行数:10,代码来源:SIMLinElKL.C

示例7: TEST

TEST(Vectors, Insert) {
	Vectors<int>* newInt = new Vectors<int>(10, 10, 0);
	newInt->insert(4,5,5);
	EXPECT_EQ(5, newInt->access(4,5));
	delete newInt;

	Vectors<std::string>* newString = new Vectors<std::string>(9, 18, "empty");
	newString->insert(4,5,"hello");
	EXPECT_EQ("hello", newString->access(4,5));
	delete newString;

	Vectors<double>* newDouble = new Vectors<double>(6, 7, 0.0);
	newDouble->insert(4,5,5.5);
	EXPECT_EQ(5.5, newDouble->access(4,5));
	delete newDouble;
}
开发者ID:billymills,项目名称:sparse-array-api,代码行数:16,代码来源:Sparse.cpp

示例8: select_step

  static bool
  select_step(Vectors &input, int variable, double step)
  {
    StatError error;
    bool ret;

    ret = input.select_step(error, variable, step);
    if (!ret)
      stat_tool::wrap_util::throw_error(error);
    return ret;
  }
开发者ID:jbdurand,项目名称:StructureAnalysis,代码行数:11,代码来源:export_vectors.cpp

示例9: file_ascii_data_write

  static void
  file_ascii_data_write(const Vectors& d, const char* path, bool exhaustive)
  {
    bool result = true;
    StatError error;

    result = d.ascii_data_write(error, path, exhaustive);
    if (!result)
      stat_tool::wrap_util::throw_error(error);

  }
开发者ID:jbdurand,项目名称:StructureAnalysis,代码行数:11,代码来源:export_vectors.cpp

示例10: ascii_data_write

  static std::string
  ascii_data_write(const Vectors& d, bool exhaustive)
  {
    std::stringstream s;
    std::string res;

    d.ascii_data_write(s, exhaustive);
    res = s.str();

    return res;

  }
开发者ID:jbdurand,项目名称:StructureAnalysis,代码行数:12,代码来源:export_vectors.cpp

示例11: rank_correlation_computation

 static string
 rank_correlation_computation(const Vectors& input, int icorrel_type, const string &filename)
 {
   StatError error;
   std::stringstream os;
   bool ret;
   correlation_type correl_type = correlation_type(icorrel_type);
   
   ret = input.rank_correlation_computation(error, os, correl_type, filename.c_str());
   //std::cout << os.str()<<endl;
   return os.str();
 }
开发者ID:jbdurand,项目名称:StructureAnalysis,代码行数:12,代码来源:export_vectors.cpp

示例12: externalEnergy

double SIMKLShell::externalEnergy (const Vectors& u,
                                   const TimeDomain& time) const
{
  double energy = this->SIMbase::externalEnergy(u,time);

  // External energy from the nodal point loads
  const int* madof = mySam->getMADOF();
  for (const PointLoad& load : myLoads)
    if (load.ldof.second > 0)
    {
      int idof = madof[load.ldof.first-1] + load.ldof.second-1;
      energy += (*load.p)(time.t) * u.front()(idof);
    }
    else if (load.ldof.second < 0) // This is an element point load
    {
      Vector v = this->SIMgeneric::getSolution(u.front(),load.xi,0,load.patch);
      if (-load.ldof.second <= (int)v.size())
        energy += (*load.p)(time.t) * v(-load.ldof.second);
    }

  return energy;
}
开发者ID:kmokstad,项目名称:IFEM-Elasticity,代码行数:22,代码来源:SIMKLShell.C

示例13: contingency_table

  static string
  contingency_table(const Vectors& v, int variable1, int variable2,
      const string& filename, int iformat)
  {
    StatError error;
    std::stringstream s;
    bool ret;
    output_format format = output_format(iformat);   
    
    ret = v.contingency_table(error, s, variable1, variable2, filename.c_str(),
        format);

    if (!ret)
      stat_tool::wrap_util::throw_error(error);

    return s.str();
  }
开发者ID:jbdurand,项目名称:StructureAnalysis,代码行数:17,代码来源:export_vectors.cpp

示例14: variance_analysis

  static string
  variance_analysis(const Vectors& v, int class_variable,
      int response_variable, int response_type, const string& filename,
      int iformat)
  {
    StatError error;
    std::stringstream s;
    bool ret;
    output_format format = output_format(iformat);

    ret = v.variance_analysis(error, s, class_variable, response_variable,
        response_type, filename.c_str(), format);

    if (!ret)
      stat_tool::wrap_util::throw_error(error);

    return s.str();
  }
开发者ID:jbdurand,项目名称:StructureAnalysis,代码行数:18,代码来源:export_vectors.cpp

示例15: refine

bool ASMunstruct::refine (const LR::RefineData& prm,
                          Vectors& sol, const char* fName)
{
  PROFILE2("ASMunstruct::refine()");

  if (!geo)
    return false;
  else if (shareFE && !prm.refShare)
  {
    nnod = geo->nBasisFunctions();
    return true;
  }

  // to pick up if LR splines get stuck while doing refinement,
  // print entry and exit point of this function

  double beta         = prm.options.size() > 0 ? prm.options[0]/100.0 : 0.10;
  int    multiplicity = prm.options.size() > 1 ? prm.options[1]       : 1;
  if (multiplicity > 1)
    for (int d = 0; d < geo->nVariate(); d++) {
      int p = geo->order(d) - 1;
      if (multiplicity > p) multiplicity = p;
    }

  enum refinementStrategy strat = LR_FULLSPAN;
  if (prm.options.size() > 2)
    switch (prm.options[2]) {
    case 1: strat = LR_MINSPAN; break;
    case 2: strat = LR_STRUCTURED_MESH; break;
    }

  bool linIndepTest   = prm.options.size() > 3 ? prm.options[3] != 0 : false;
  int  maxTjoints     = prm.options.size() > 4 ? prm.options[4]      : -1;
  int  maxAspectRatio = prm.options.size() > 5 ? prm.options[5]      : -1;
  bool closeGaps      = prm.options.size() > 6 ? prm.options[6] != 0 : false;

  char doRefine = 0;
  if (!prm.errors.empty())
    doRefine = 'E'; // Refine based on error indicators
  else if (!prm.elements.empty())
    doRefine = 'I'; // Refine the specified elements

  if (doRefine) {

    std::vector<int> nf(sol.size());
    for (size_t j = 0; j < sol.size(); j++)
      if (!(nf[j] = LR::extendControlPoints(geo,sol[j],this->getNoFields(1))))
        return false;

    // set refinement parameters
    if (maxTjoints > 0)
      geo->setMaxTjoints(maxTjoints);
    if (maxAspectRatio > 0)
      geo->setMaxAspectRatio((double)maxAspectRatio);
    geo->setCloseGaps(closeGaps);
    geo->setRefMultiplicity(multiplicity);
    geo->setRefStrat(strat);

    // do actual refinement
    if (doRefine == 'E')
      geo->refineByDimensionIncrease(prm.errors,beta);
    else if (strat == LR_STRUCTURED_MESH)
      geo->refineBasisFunction(prm.elements);
    else
      geo->refineElement(prm.elements);

    geo->generateIDs();
    nnod = geo->nBasisFunctions();

    for (int i = sol.size()-1; i >= 0; i--) {
      sol[i].resize(nf[i]*geo->nBasisFunctions());
      LR::contractControlPoints(geo,sol[i],nf[i]);
    }
  }

  if (fName)
  {
    char fullFileName[256];

    strcpy(fullFileName, "lrspline_");
    strcat(fullFileName, fName);
    std::ofstream lrOut(fullFileName);
    lrOut << *geo;
    lrOut.close();

    LR::LRSplineSurface* lr = dynamic_cast<LR::LRSplineSurface*>(geo);
    if (lr) {
      // open files for writing
      strcpy(fullFileName, "param_");
      strcat(fullFileName, fName);
      std::ofstream paramMeshFile(fullFileName);

      strcpy(fullFileName, "physical_");
      strcat(fullFileName, fName);
      std::ofstream physicalMeshFile(fullFileName);

      strcpy(fullFileName, "param_dot_");
      strcat(fullFileName, fName);
      std::ofstream paramDotMeshFile(fullFileName);

//.........这里部分代码省略.........
开发者ID:OPM,项目名称:IFEM,代码行数:101,代码来源:ASMLRSpline.C


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