00001 #include "Writer.hpp" 00002 00003 #include <iostream> 00004 #include <fstream> 00005 #include <assert.h> 00006 00007 using namespace indii::ml::data; 00008 00009 namespace aux = indii::ml::aux; 00010 00011 Writer::Writer(std::ostream* out) : out(out), ownStream(false) { 00012 // 00013 } 00014 00015 Writer::Writer(const std::string file) : ownStream(true) { 00016 out = new std::ofstream(file.c_str()); 00017 } 00018 00019 Writer::~Writer() { 00020 if (ownStream) { 00021 static_cast<std::ofstream*>(out)->close(); 00022 delete out; 00023 } 00024 } 00025 00026 void Writer::writeLine(const double value) { 00027 write(value); 00028 writeLine(); 00029 } 00030 00031 void Writer::writeLine(const aux::vector& values) { 00032 write(values); 00033 writeLine(); 00034 } 00035 00036 void Writer::writeLine(const aux::matrix& values) { 00037 write(values); 00038 writeLine(); 00039 } 00040 00041 void Writer::writeLine(const aux::symmetric_matrix& values) { 00042 write(values); 00043 writeLine(); 00044 } 00045
1.5.3