/***********************************************************************
*                                                                      *
* This file is part of CARAT.                                          *
* Copyright (C) 2015  Tilman Schulz                                    *
*                                                                      *
* CARAT is free software: you can redistribute it and/or modify        *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or    *
* (at your option) any later version.                                  *
*                                                                      *
* This program is distributed in the hope that it will be useful,      *
* but WITHOUT ANY WARRANTY; without even the implied warranty of       *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
* GNU General Public License for more details.                         *
*                                                                      *
* You should have received a copy of the GNU General Public License    *
* along with this program.  If not, see <http://www.gnu.org/licenses/> *
*                                                                      *
***********************************************************************/
#include"typedef.h"
#include"getput.h"
#include"matrix.h"
#include"bravais.h"

int INFO_LEVEL;

main (int argc, char *argv[])
{

   matrix_TYP **T,
               *X;
   bravais_TYP *G, *B;
   int anz;


   read_header(argc, argv);
   if(FILEANZ != 2)
   {
      printf("Usage: Conj_bravais 'file1' 'file2' [-i] \n");
      printf("\n");
      printf("file1: bravais_TYP containing the group G.\n");
      printf("file2: matrix_TYP containing a single matrix T.\n");
      printf("\n");
      printf("The program calculates TGT^{-1} and transforms all relevant\n");
      printf("data of G. The result is a bravais_TYP, that is written to\n");
      printf("standart output.\n");
      printf("\n");
      printf("Options:\n");
      printf(" -i     : Transform the group by T^{-1} G T.\n");
      printf("\n");
      if (is_option('h')){
         exit(0);
      }
      else{
         exit(31);
      }
   }
   G = get_bravais(FILENAMES[0]);
   T = mget_mat (FILENAMES[1], &anz);
   rat2kgv(T[0]);

   if (is_option('i')){
      X = mat_inv(T[0]);
      free_mat(T[0]);
      T[0] = X;
   }

   B = konj_bravais(G, T[0]);
   put_bravais(B, NULL, "konjugated bravais group");

   exit(0);
}
