/***********************************************************************
*                                                                      *
* 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"




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

	matrix_TYP **Mat, *X;
        int i, anz;

        extern char **FILENAMES;
        extern int FILEANZ;

	extern matrix_TYP **mget_mat ();
	extern matrix_TYP *solve_mat();
	extern void put_mat ();

        read_header(argc, argv);
        if(FILEANZ != 1)
        {
           printf("\n");
           printf("usage:  Solve 'file',\n");
           printf("where 'file' contains a set of matrices.\n");
           printf("\n");
           printf("Solves the linear equation A * X = 0\n");
           printf("for each matrix A in file.\n");
           printf("\n");
          if (is_option('h')){
             exit(0);
          }
          else{
             exit(31);
          }
        }
	Mat = mget_mat (FILENAMES[0], &anz);
        if(anz > 1)
          printf("#%d\n", anz);
        for(i=0;i<anz;i++)
        {
            X = solve_mat(Mat[i]);
            put_mat(X, NULL, "", 0);
            free_mat(X);
        }

   exit(0);
}
