Files
cioverlap/matrix2bin.cc

66 lines
1.7 KiB
C++

/*
Copyright (C) 2008 Jiri Pittner <jiri.pittner@jh-inst.cas.cz> or <jiri@pittnerovi.com>
This program 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 <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#define EPSPRINT .05
#include "la.h"
#include "fourindex.h"
#include "nonclass.h"
#include "basic.h"
using namespace std;
using namespace LA;
int main(int argc, char **argv)
{
sigtraceback(SIGSEGV,1);
sigtraceback(SIGABRT,1);
sigtraceback(SIGBUS,1);
sigtraceback(SIGFPE,1);
cout.setf(ios::fixed);
cout.precision(12);
bool dim=false;
++argv;
bool orcaformat=false;
//options can be given in any order: repeat until no option is recognized
for(char **argv0=NULL; argv0!=argv;)
{
argv0=argv;
if(argc>1 && !strcmp(*argv,"--orca")) {orcaformat=true; --argc; ++argv;}
if(argc>2 && !strcmp(*argv,"-d")) {dim=true; --argc; ++argv;}
}
NRMat<double> a;
cin>>a;
int f=open(*argv,O_CREAT|O_TRUNC|O_WRONLY,0666);
if(f<0) {cerr<<"Cannot open "<<*argv<<endl; laerror("cannot open file");}
a.put(f,dim,false,orcaformat);
close(f);
}