/*
  Synopsis: outputs information about the strong real forms of G.

  Explanation: the inverse image in \X of a class of weak real forms of G is
  of the form Z.\X(z), where z is an admissible value for x^2 for a strong real
  form of that class; so there is associated to the class of weak real forms
  a coset (1+\delta)(Z).z in Z^\delta. All the various \X(z) for all possible
  choices of z are isomorphic by Z-translation. Therefore it is enough to
  describe the combinatorial structure of one of them, for each class of weak
  real forms. This is a finite problem in all cases.

  We output the orbits of W_im in X(z), which correspond to the various strong
  real forms; we label them with the corresponding weak real form.
*/
std::ostream& printStrongReal(std::ostream& strm,
                              InnerClass& G_C,
                              const output::FormNumberMap& rfi,
                              size_t cn)
{
    const CartanClass& cc = G_C.cartan(cn);
    const RealFormNbrList& rfl = G_C.realFormLabels(cn);

    size_t n = cc.numRealFormClasses();

    if (n>1)
        strm << "there are " << n << " real form classes:\n" << std::endl;

    for (cartanclass::square_class csc=0; csc<n; ++csc)
    {
        // print information about the square of real forms, in center
        {
            RealFormNbr wrf=cc.fiber().realFormPartition().classRep(csc);
            RealFormNbr fund_wrf= rfl[wrf]; // lift weak real form to |fund|
            cartanclass::square_class f_csc=G_C.xi_square(fund_wrf);

            // having the square class number of the fundamental fiber, get grading
            RatCoweight coch = some_coch(G_C,f_csc);
            Grading base_grading = grading_of_simples(G_C,coch);

            RatWeight z (G_C.rank());
            for (Grading::iterator it=base_grading.begin(); it(); ++it)
                z += G_C.rootDatum().fundamental_coweight(*it);

            Ratvec_Numer_t& zn = z.numerator();
            for (size_t i=0; i<z.size(); ++i)
                zn[i]=arithmetic::remainder(zn[i],z.denominator());
            strm << "class #" << f_csc
                 << ", possible square: exp(2i\\pi(" << z << "))" << std::endl;
        }

        const Partition& pi = cc.fiber_partition(csc);

        unsigned long c = 0;

        for (Partition::iterator i(pi); i(); ++i,++c)
        {
            std::ostringstream os;
            RealFormNbr rf = rfl[cc.toWeakReal(c,csc)];
            os << "real form #" << rfi.out(rf) << ": ";
            basic_io::seqPrint(os,i->first,i->second,",","[","]")
                    << " (" << i->second - i->first << ")" << std::endl;
            ioutils::foldLine(strm,os.str(),"",",");
        }

        if (n>1)
            strm << std::endl;
    }

    return strm;
}
bool is_central(const WeightList& alpha, const TorusElement& t)
{
  RatWeight rw = t.as_Qmod2Z();
  arithmetic::Numer_t d = 2*rw.denominator();
  for (weyl::Generator s=0; s<alpha.size(); ++s)
    if (alpha[s].dot(rw.numerator())%d != 0) // see if division is exact
      return false;

  return true;
}