def __call__( self, row ):

    assert Frontend.__call__( self, row ) is row;

    val = 0;
    for (i,row_i) in enumerate( row ):
      if row_i == 1:
        val |= (1<<i);

    row_ = [];

    for cluster in self._state:
      mask = 0;
      for dim in cluster:
        mask |= (1<<dim);
      row_.append( val & mask );

    return row_;
  def __call__( self, row ):

    assert Frontend.__call__( self, row ) is row;

    row_ = [];

    for cluster in self._state:

      val = 0.0;

      for dim in cluster:
        if dim > 0:
          val += row[dim];
        else:
          assert dim < 0;
          val -= row[dim];

      val /= len(cluster);

      row_.append( val );

    return row_;