src/training/common/intfeaturemap.cpp
int IntFeatureMap::OffsetFeature(int index_feature, int dir) const {
  if (dir > 0 && dir <= kNumOffsetMaps) {
    return offset_plus_[dir - 1][index_feature];
  } else if (dir < 0 && -dir <= kNumOffsetMaps) {
    return offset_minus_[-dir - 1][index_feature];
  } else if (dir == 0) {
    return index_feature;
  } else {
    return -1;
  }
}
// Helper to return an offset index feature. In this context an offset
// feature with a dir of +/-1 is a feature of a similar direction,
// but shifted perpendicular to the direction of the feature. An offset
// feature with a dir of +/-2 is feature at the same position, but rotated
// by +/- one [compact] quantum. Returns the index of the generated offset
// feature, or -1 if it doesn't exist. Dir should be in
// [-kNumOffsetMaps, kNumOffsetMaps] to indicate the relative direction.
// A dir of 0 is an identity transformation.
// Both input and output are from the index(sparse) feature space, not
// the mapped/compact feature space, but the offset feature is the minimum
// distance moved from the input to guarantee that it maps to the next
// available quantum in the mapped/compact space.
Helper to return an offset index feature. In this context an offset
feature with a dir of +/-1 is a feature of a similar direction,
but shifted perpendicular to the direction of the feature. An offset
feature with a dir of +/-2 is feature at the same position, but rotated
by +/- one [compact] quantum. Returns the index of the generated offset
feature, or -1 if it doesn't exist. Dir should be in
[-kNumOffsetMaps, kNumOffsetMaps] to indicate the relative direction.
A dir of 0 is an identity transformation.
Both input and output are from the index(sparse) feature space, not
the mapped/compact feature space, but the offset feature is the minimum
distance moved from the input to guarantee that it maps to the next
available quantum in the mapped/compact space.
Helper to return an offset index feature . In this context an offset feature with a dir of + / - 1 is a feature of a similar direction but shifted perpendicular to the direction of the feature . An offset feature with a dir of + / - 2 is feature at the same position but rotated by + / - one [ compact ] quantum . Returns the index of the generated offset feature or - 1 if it doesn ' t exist . Dir should be in [ - kNumOffsetMaps kNumOffsetMaps ] to indicate the relative direction . A dir of 0 is an identity transformation . Both input and output are from the index ( sparse ) feature space not the mapped / compact feature space but the offset feature is the minimum distance moved from the input to guarantee that it maps to the next available quantum in the mapped / compact space .
int IntFeatureMap::OffsetFeature(int index_feature, int dir) const {
  if (dir > 0 && dir <= kNumOffsetMaps) {
    return offset_plus_[dir - 1][index_feature];
  } else if (dir < 0 && -dir <= kNumOffsetMaps) {
    return offset_minus_[-dir - 1][index_feature];
  } else if (dir == 0) {
    return index_feature;
  } else {
    return -1;
  }
}
int IntFeatureMap :: OffsetFeature ( int index_feature , int dir ) const { if ( dir > 0 && dir <= kNumOffsetMaps ) { return offset_plus_ [ dir - 1 ] [ index_feature ] ; } else if ( dir < 0 && - dir <= kNumOffsetMaps ) { return offset_minus_ [ - dir - 1 ] [ index_feature ] ; } else if ( dir == 0 ) { return index_feature ; } else { return -1 ; } }
Helper to return an offset index feature.
Helper to return an offset index feature .