mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-06-17 06:47:06 +01:00
first implementation of HDF5 format
This commit is contained in:
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <LatAnalyze/AsciiFile.hpp>
|
||||
#include <LatAnalyze/Io.hpp>
|
||||
#include <LatAnalyze/RandGen.hpp>
|
||||
|
||||
using namespace std;
|
||||
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
|
||||
res[s](0, 0) = gen.gaussian(val, err);
|
||||
}
|
||||
}
|
||||
Io::save<DMatSample, AsciiFile>(res, outFileName);
|
||||
Io::save<DMatSample>(res, outFileName);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include <map>
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
#include <LatAnalyze/AsciiFile.hpp>
|
||||
#include <LatAnalyze/Dataset.hpp>
|
||||
#include <LatAnalyze/Io.hpp>
|
||||
|
||||
#ifndef DEF_NSAMPLE
|
||||
#define DEF_NSAMPLE 100
|
||||
@ -109,15 +109,30 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
for (unsigned int i = 0; i < dataFileName.size(); ++i)
|
||||
{
|
||||
AsciiFile dataFile;
|
||||
|
||||
std::unique_ptr<File> dataFile;
|
||||
|
||||
if (extension(dataFileName[i]) == "dat")
|
||||
{
|
||||
dataFile.reset(new AsciiFile);
|
||||
}
|
||||
else if (extension(dataFileName[i]) == "h5")
|
||||
{
|
||||
dataFile.reset(new Hdf5File);
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "error: '" << dataFileName[i];
|
||||
cerr << "' has an unknown extension" << endl;
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
cout << '\r' << ProgressBar(i + 1, dataFileName.size());
|
||||
dataFile.open(dataFileName[i], AsciiFile::Mode::read);
|
||||
dataFile->open(dataFileName[i], AsciiFile::Mode::read);
|
||||
for (const string &n: name)
|
||||
{
|
||||
data[n][i] = dataFile.read<DMat>(n);
|
||||
data[n][i] = dataFile->read<DMat>(n);
|
||||
}
|
||||
dataFile.close();
|
||||
dataFile->close();
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
@ -129,7 +144,7 @@ int main(int argc, char *argv[])
|
||||
cout << "-- resampling data..." << endl;
|
||||
if (!stateFileName.empty())
|
||||
{
|
||||
state = Io::load<RandGenState, AsciiFile>(stateFileName);
|
||||
state = Io::load<RandGenState>(stateFileName);
|
||||
}
|
||||
for (unsigned int i = 0; i < name.size(); ++i)
|
||||
{
|
||||
@ -142,8 +157,8 @@ int main(int argc, char *argv[])
|
||||
g.setState(state);
|
||||
}
|
||||
s = data[name[i]].bootstrapMean(nSample, g);
|
||||
Io::save<DMatSample, AsciiFile>(s, outDirName + "/" + outFileName,
|
||||
File::Mode::write, outFileName);
|
||||
Io::save<DMatSample>(s, outDirName + "/" + outFileName,
|
||||
File::Mode::write, outFileName);
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <iostream>
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
#include <LatAnalyze/AsciiFile.hpp>
|
||||
#include <LatAnalyze/Io.hpp>
|
||||
#include <LatAnalyze/CompiledFunction.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
@ -18,27 +18,32 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <LatAnalyze/AsciiFile.hpp>
|
||||
#include <LatAnalyze/Io.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace Latan;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
if ((argc < 2) || (argc > 3))
|
||||
{
|
||||
cerr << "usage: " << argv[0] << " <file>" << endl;
|
||||
cerr << "usage: " << argv[0] << " <file> [<copy>]" << endl;
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
string fileName = argv[1];
|
||||
|
||||
string fileName = argv[1], copy = (argc >= 3) ? argv[2] : "";
|
||||
|
||||
cout << "-- loading sample from '" << fileName << "'..." << endl;
|
||||
DMatSample s = Io::load<DMatSample, AsciiFile>(fileName);
|
||||
DMatSample s = Io::load<DMatSample>(fileName);
|
||||
string name = Io::getFirstName(fileName);
|
||||
cout << scientific;
|
||||
cout << "central value:\n" << s[central] << endl;
|
||||
cout << "standard deviation:\n" << s.variance().cwiseSqrt() << endl;
|
||||
if (!copy.empty())
|
||||
{
|
||||
Io::save(s, copy, File::Mode::write, name);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user