Пример #1
0
/***
uInt STMolecules::addEntry( Double restfreq, const String& name,
                            const String& formattedname )
{

  Table result =
    table_( near(table_.col("RESTFREQUENCY"), restfreq) );
  uInt resultid = 0;
  if ( result.nrow() > 0) {
    ROScalarColumn<uInt> c(result, "ID");
    c.get(0, resultid);
  } else {
    uInt rno = table_.nrow();
    table_.addRow();
    // get last assigned _id and increment
    if ( rno > 0 ) {
      idCol_.get(rno-1, resultid);
      resultid++;
    }
    restfreqCol_.put(rno, restfreq);
    nameCol_.put(rno, name);
    formattednameCol_.put(rno, formattedname);
    idCol_.put(rno, resultid);
  }
  return resultid;
}
***/
uInt STMolecules::addEntry( Vector<Double> restfreq, const Vector<String>& name,
                            const Vector<String>& formattedname )
{
// How to handle this...?
  Table result =
    table_( nelements(table_.col("RESTFREQUENCY")) == uInt (restfreq.size()) && 
            all(table_.col("RESTFREQUENCY")== restfreq), 1 );
  uInt resultid = 0;
  if ( result.nrow() > 0) {
    ROScalarColumn<uInt> c(result, "ID");
    c.get(0, resultid);
  } else {
    uInt rno = table_.nrow();
    table_.addRow();
    // get last assigned _id and increment
    if ( rno > 0 ) {
      idCol_.get(rno-1, resultid);
      resultid++;
    }
    restfreqCol_.put(rno, restfreq);
    nameCol_.put(rno, name);
    formattednameCol_.put(rno, formattedname);
    idCol_.put(rno, resultid);
  }
  return resultid;
}
double ompl::tools::DynamicTimeWarp::calcDTWDistance(const og::PathGeometric &path1, const og::PathGeometric &path2 ) const
{
    // Get lengths
    std::size_t n = path1.getStateCount();
    std::size_t m = path2.getStateCount();
    std::size_t nrows = table_.size1(), ncols = table_.size2();

    // Intialize table
    if (nrows <= n || ncols <= m)
    {
        table_.resize(n + 1, m + 1, false);
        for (std::size_t i = nrows; i <= n; ++i)
            table_(i, 0) = std::numeric_limits<double>::infinity();
        for (std::size_t i = ncols; i <= m; ++i)
            table_(0, i) = std::numeric_limits<double>::infinity();
    }

    // Do calculations
    double cost;
    for (std::size_t i = 1; i <= n; ++i)
        for (std::size_t j = 1; j <= m; ++j)
        {
            cost = si_->distance(path1.getState(i - 1), path2.getState(j - 1));
            table_(i, j) = cost + min3(table_(i - 1, j),
                                       table_(i, j - 1),
                                       table_(i - 1, j - 1));
        }

    return table_(n, m);
}
Пример #3
0
std::vector< double > asap::STMolecules::getRestFrequency( uInt id ) const
{
  std::vector<double> out;
  Table t = table_(table_.col("ID") == Int(id), 1 );
  if (t.nrow() == 0 ) {
    throw(AipsError("STMolecules::getRestFrequency - id out of range"));
  }
  ROTableRow row(t);
  const TableRecord& rec = row.get(0);
  //return double(rec.asDouble("RESTFREQUENCY"));
  Vector<Double> rfs = rec.asArrayDouble("RESTFREQUENCY");
  rfs.tovector(out);
  return out;
}
Пример #4
0
/***
void STMolecules::getEntry( Double& restfreq, String& name,
                            String& formattedname, uInt id ) const
{
  Table t = table_(table_.col("ID") == Int(id) );
  if (t.nrow() == 0 ) {
    throw(AipsError("STMolecules::getEntry - id out of range"));
  }
  ROTableRow row(t);
  // get first row - there should only be one matching id

  const TableRecord& rec = row.get(0);
  restfreq = rec.asDouble("RESTFREQUENCY");
  name = rec.asString("NAME");
  formattedname = rec.asString("FORMATTEDNAME");
}
***/
void STMolecules::getEntry( Vector<Double>& restfreq, Vector<String>& name,
                            Vector<String>& formattedname, uInt id ) const
{
  Table t = table_(table_.col("ID") == Int(id), 1 );
  if (t.nrow() == 0 ) {
    throw(AipsError("STMolecules::getEntry - id out of range"));
  }
  ROTableRow row(t);
  // get first row - there should only be one matching id

  const TableRecord& rec = row.get(0);
  //restfreq = rec.asDouble("RESTFREQUENCY");
  restfreq = rec.asArrayDouble("RESTFREQUENCY");
  //name = rec.asString("NAME");
  name = rec.asArrayString("NAME");
  //formattedname = rec.asString("FORMATTEDNAME");
  formattedname = rec.asArrayString("FORMATTEDNAME");
}
ompl::tools::DynamicTimeWarp::DynamicTimeWarp(const base::SpaceInformationPtr &si)
    : si_(si), table_(1, 1)
{
    table_(0, 0) = 0.;
}