1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-04-05 09:35:54 +01:00

Utils: Added little utility to flatten 1x1 DMatSamples

This commit is contained in:
Matt Spraggs 2016-06-07 18:11:01 +01:00
parent 7e3ab34a31
commit 1f3a8c27a1
2 changed files with 36 additions and 0 deletions

View File

@ -9,6 +9,7 @@ endif
bin_PROGRAMS = \
latan_make_fake_sample\
latan_sample_combine \
latan_sample_flatten \
latan_sample_plot_corr\
latan_sample_read \
latan_resample
@ -21,6 +22,10 @@ latan_sample_combine_SOURCES = sample_combine.cpp
latan_sample_combine_CXXFLAGS = $(COM_CXXFLAGS)
latan_sample_combine_LDFLAGS = -L../lib/.libs -lLatAnalyze
latan_sample_flatten_SOURCES = sample_flatten.cpp
latan_sample_flatten_CXXFLAGS = $(COM_CXXFLAGS)
latan_sample_flatten_LDFLAGS = -L../lib/.libs -lLatAnalyze
latan_sample_plot_corr_SOURCES = sample_plot_corr.cpp
latan_sample_plot_corr_CXXFLAGS = $(COM_CXXFLAGS)
latan_sample_plot_corr_LDFLAGS = -L../lib/.libs -lLatAnalyze

31
utils/sample_flatten.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <iostream>
#include <string>
#include <LatAnalyze/Io.hpp>
#include <LatAnalyze/MatSample.hpp>
namespace La = Latan;
int main(int argc, char* argv[])
{
if (argc != 4) {
std::cout << "Usage: " << argv[0] << " <input filename> <output filename> <num samples>" << std::endl;
return -1;
}
std::string inFileName = argv[1];
std::string outFileName = argv[2];
auto nSamples = La::strTo<La::Index>(argv[3]);
La::DMatSample inputData(nSamples, 1, 1);
La::DSample outputData(nSamples);
inputData = La::Io::load<La::DMatSample>(inFileName);
FOR_STAT_ARRAY(inputData, s) {
outputData[s] = inputData[s](0, 0);
}
La::Io::save(outputData, outFileName);
}