示例#1
0
const std::string IMDWorkspace::toString() const {
  std::ostringstream os;
  os << id() << "\n"
     << "Title: " + getTitle() << "\n";
  for (size_t i = 0; i < getNumDims(); i++) {
    const auto &dim = getDimension(i);
    os << "Dim " << i << ": (" << dim->getName() << ") " << dim->getMinimum()
       << " to " << dim->getMaximum() << " in " << dim->getNBins() << " bins";
    // Also show the dimension ID string, if different than name
    if (dim->getDimensionId() != dim->getName())
      os << ". Id=" << dim->getDimensionId();
    os << "\n";
  }
  if (hasOriginalWorkspace()) {
    os << "Binned from '" << getOriginalWorkspace()->getName();
  }
  os << "\n";
  if (this->getConvention() == "Crystallography")
    os << "Crystallography: kf-ki";
  else
    os << "Inelastic: ki-kf";
  os << "\n";

  return os.str();
}
示例#2
0
void HyperCube<T>::rotate1D(long d, long k)
{
  assert(d >=0 && d < getNumDims());

  // Make sure rotation amount is in the range [1,dimSize-1]
  k %= getDim(d);
  if (k == 0) return;
  if (k < 0) k += getDim(d);

  // A simple implementation with a temporary vector
  Vec<T> tmp(INIT_SIZE, getSize());
  for (long i=0; i<getSize(); i++) 
    tmp[addCoord(i, d, k)] = data[i];
  for (long i=0; i<getSize(); i++)
    data[i] = tmp[i];
}
示例#3
0
const std::string IMDWorkspace::toString() const {
  std::ostringstream os;
  os << id() << "\n"
     << "Title: " + getTitle() << "\n";
  for (size_t i = 0; i < getNumDims(); i++) {
    Geometry::IMDDimension_const_sptr dim = getDimension(i);
    os << "Dim " << i << ": (" << dim->getName() << ") " << dim->getMinimum()
       << " to " << dim->getMaximum() << " in " << dim->getNBins() << " bins";
    // Also show the dimension ID string, if different than name
    if (dim->getDimensionId() != dim->getName())
      os << ". Id=" << dim->getDimensionId();
    os << "\n";
  }
  if (hasOriginalWorkspace()) {
    os << "Binned from '" << getOriginalWorkspace()->getName();
  }
  os << "\n";
  return os.str();
}
示例#4
0
void HyperCube<T>::shift1D(long d, long k)
{
  assert(d >=0 && d < getNumDims());

  // Make sure rotation amount is in the range [1,dimSize-1]
  bool negative = (k<0);
  k %= getDim(d);
  if (k == 0) return;
  if (k < 0) k += getDim(d);

  if (negative) { // left shift, zeros at the end
    for (long i=getSize()-1; i>=0; i--) {
      long iPrime = addCoord(i, d, k);
      if (iPrime < i) data[iPrime] = data[i];
      else            data[iPrime] = T(); // empty
    }
  } else {        // right shift, zeros at the beginning
    for (long i=0; i<getSize(); i++) {
      long iPrime = addCoord(i, d, k);
      if (iPrime > i) data[iPrime] = data[i];
      else            data[iPrime] = T(); // empty
    }
  }
}