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


C++ ConstIterator::split方法代码示例

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


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

示例1: InvalidParameter

  Matrix<double> IsobaricQuantitationMethod::stringListToIsotopCorrectionMatrix_(const StringList& stringlist) const
  {
    // check the string list
    if (stringlist.size() != getNumberOfChannels())
    {
      throw Exception::InvalidParameter(__FILE__, __LINE__, __PRETTY_FUNCTION__, String("IsobaricQuantitationMethod: Invalid string representation of the isotope correction matrix. Expected ") + getNumberOfChannels() + " entries but got " + stringlist.size() + ".");
    }

    // create matrix to fill from stringlist
    Matrix<double> isotope_correction_matrix(getNumberOfChannels(), 4);

    // channel index
    Size channel_index = 0;

    // fill row-wise
    for (StringList::ConstIterator it = stringlist.begin(); it != stringlist.end(); ++it)
    {
      StringList corrections;
      it->split('/', corrections);
      if (corrections.size() != 4)
      {
        throw Exception::InvalidParameter(__FILE__, __LINE__, __PRETTY_FUNCTION__, "IsobaricQuantitationMethod: Invalid entry in string representation of the isotope correction matrx. Expected four correction values separated by '/', got: '" + *it + "'");
      }

      // overwrite line in Matrix with custom values
      isotope_correction_matrix.setValue(channel_index, 0, corrections[0].toDouble());
      isotope_correction_matrix.setValue(channel_index, 1, corrections[1].toDouble());
      isotope_correction_matrix.setValue(channel_index, 2, corrections[2].toDouble());
      isotope_correction_matrix.setValue(channel_index, 3, corrections[3].toDouble());

      // increment channel index
      ++channel_index;
    }

    // compute frequency matrix based on the deviation matrix
    Matrix<double> channel_frequency(getNumberOfChannels(), getNumberOfChannels());

    // matrix element i, j == what contributes channel i to the intensity of channel j
    for (Size contributing_channel = 0; contributing_channel < getNumberOfChannels(); ++contributing_channel)
    {
      for (Size target_channel = 0; target_channel < getNumberOfChannels(); ++target_channel)
      {
        // as the isotope_correction_matrix encodes what channel i contributes to theoretical -2/-1/+1/+2 channels
        // hence we check if the target_channel corresponds to the contributing_channel -2/-1/+1/+2
        // if yes, we assign the corresponding contribution
        // contribution to itself is handled separately
        if ((getChannelInformation()[contributing_channel].name - 2) == getChannelInformation()[target_channel].name)
        {
          channel_frequency.setValue(target_channel, contributing_channel, isotope_correction_matrix.getValue(contributing_channel, 0) / 100);
        }
        else if ((getChannelInformation()[contributing_channel].name - 1) == getChannelInformation()[target_channel].name)
        {
          channel_frequency.setValue(target_channel, contributing_channel, isotope_correction_matrix.getValue(contributing_channel, 1) / 100);
        }
        else if ((getChannelInformation()[contributing_channel].name + 1) == getChannelInformation()[target_channel].name)
        {
          channel_frequency.setValue(target_channel, contributing_channel, isotope_correction_matrix.getValue(contributing_channel, 2) / 100);
        }
        else if ((getChannelInformation()[contributing_channel].name + 2) == getChannelInformation()[target_channel].name)
        {
          channel_frequency.setValue(target_channel, contributing_channel, isotope_correction_matrix.getValue(contributing_channel, 3) / 100);
        }
        else if (target_channel == contributing_channel)
        {
          double self_contribution = 100.0;
          for (Size column_idx = 0; column_idx < 4; ++column_idx)
          {
            self_contribution -= isotope_correction_matrix.getValue(contributing_channel, column_idx);
          }
          channel_frequency.setValue(contributing_channel, contributing_channel, (self_contribution / 100));
        }
      }
    }

    return channel_frequency;
  }
开发者ID:aiche,项目名称:open-ms-mirror,代码行数:76,代码来源:IsobaricQuantitationMethod.C


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