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


C++ DblMatrix::Transpose方法代码示例

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


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

示例1: readModulatedUB

void LoadIsawUB::readModulatedUB(std::ifstream &in, DblMatrix &ub) {
  int ModDim = 0;
  Kernel::DblMatrix modub(3, 3);
  Kernel::DblMatrix ModVecErr(3, 3);
  int maxorder = 0;
  bool crossterm = false;
  std::string s;
  double val;
  s = getWord(in, true);
  if (!convert(s, val)) {
    readToEndOfLine(in, true);
    for (size_t row = 0; row < 3; row++) {
      for (size_t col = 0; col < 3; col++) {
        s = getWord(in, true);
        if (!convert(s, val))
          throw std::runtime_error(
              "The string '" + s +
              "' in the file was not understood as a number.");
        modub[row][col] = val;
      }
      readToEndOfLine(in, true);
      if (modub[row][0] != 0.0 || modub[row][1] != 0.0 || modub[row][2] != 0.0)
        ModDim++;
    }
  }

  readToEndOfLine(in, true);

  double latVals[6];
  for (double &latVal : latVals) {
    s = getWord(in, true);
    if (!convert(s, val))
      throw std::runtime_error("The string '" + s +
                               "' in the file was not understood as a number.");
    latVal = val;
  }

  if (ModDim > 0) {
    readToEndOfLine(in, true);
    readToEndOfLine(in, true);
    for (int i = 0; i < ModDim; i++) {
      readToEndOfLine(in, true);
      for (int j = 0; j < 4; j++)
        s = getWord(in, true);
      for (int j = 0; j < 3; j++) {
        s = getWord(in, true);
        if (!convert(s, val))
          throw std::runtime_error(
              "The string '" + s +
              "' in the file was not understood as a number.");
        ModVecErr[i][j] = val;
      }
      readToEndOfLine(in, true);
    }

    readToEndOfLine(in, true);
    for (int j = 0; j < 3; j++)
      s = getWord(in, true);
    if (!convert(s, val))
      throw std::runtime_error("The string '" + s +
                               "' in the file was not understood as a number.");
    maxorder = static_cast<int>(val);
    readToEndOfLine(in, true);
    for (int j = 0; j < 3; j++)
      s = getWord(in, true);
    bool valBool;
    if (!convert(s, valBool))
      throw std::runtime_error("The string '" + s +
                               "' in the file was not understood as a number.");
    crossterm = valBool;
  }
  // Adjust the UB by transposing
  ub = ub.Transpose();
  modub = modub.Transpose();

  /* The method in OrientedLattice gets both the lattice parameters and the U
   * matrix from the UB matrix.
   * This is compatible (same results) with the ISAW lattice parameters */
  OrientedLattice *latt = new OrientedLattice();
  latt->setUB(ub);
  latt->setError(latVals[0], latVals[1], latVals[2], latVals[3], latVals[4],
                 latVals[5]);
  latt->setModUB(modub);

  for (int i = 0; i < ModDim; i++)
    latt->setModerr(i, ModVecErr[i][0], ModVecErr[i][1], ModVecErr[i][2]);

  latt->setMaxOrder(maxorder);
  latt->setCrossTerm(crossterm);

  DblMatrix U = latt->getU();

  // Swap rows around to accound for IPNS convention
  DblMatrix U2 = U;
  // Swap rows around
  for (size_t r = 0; r < 3; r++) {
    U2[2][r] = U[0][r];
    U2[1][r] = U[2][r];
    U2[0][r] = U[1][r];
  }
//.........这里部分代码省略.........
开发者ID:mantidproject,项目名称:mantid,代码行数:101,代码来源:LoadIsawUB.cpp


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