SgInfo Loop SymOps

The following template code shows how to loop all symops.

At first, nLoopInv is set using the Sg_nLoopInv macro. nLoopInv can take two values, 1 if the space group is acentric or there is an inversion operation off origin, or 2 if the space group is centric.

iModPositive(i, j) at the bottom is a very simple function which essentially returns i % j. However, if i % j is less than 0, iModPositive() will return i % j + j in order to make the result positive. In the present example iModPositive() ensures that the translation components of SMx will always be in the range [0...(STBF-1)].

This isn't too bad, is it?


#include <stdio.h>
#include <stdlib.h>

#include "sginfo.h"

static void LoopSymOps(const T_SgInfo *SgInfo)
{
  int           iList, f, i;
  int           nTrV, iTrV, nLoopInv, iLoopInv;
  const int     *TrV;
  T_RTMx        SMx;
  const T_RTMx  *lsmx;


  nLoopInv = Sg_nLoopInv(SgInfo);

  nTrV = SgInfo->LatticeInfo->nTrVector;
   TrV = SgInfo->LatticeInfo->TrVector;

  for (iTrV = 0; iTrV < nTrV; iTrV++, TrV += 3)
  {
    for (iLoopInv = 0; iLoopInv < nLoopInv; iLoopInv++)
    {
      if (iLoopInv == 0) f =  1;
      else               f = -1;

      lsmx = SgInfo->ListSeitzMx;

      for (iList = 0; iList < SgInfo->nList; iList++, lsmx++)
      {
        for (i = 0; i < 9; i++)
          SMx.s.R[i] =              f * lsmx->s.R[i];

        for (i = 0; i < 3; i++)
          SMx.s.T[i] = iModPositive(f * lsmx->s.T[i] + TrV[i], STBF);

        /* use SMx at this point
         */
      }
    }
  }
}

Ralf W. Grosse-Kunstleve <rwgk@cci.lbl.gov>