1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00:00

Utils: Renamed sample_flatten.cpp to sample_element.cpp as suggested

This commit is contained in:
Matt Spraggs 2016-06-09 17:38:41 +01:00
parent 1f3a8c27a1
commit 82d020c82f
3 changed files with 43 additions and 35 deletions

View File

@ -9,7 +9,7 @@ endif
bin_PROGRAMS = \
latan_make_fake_sample\
latan_sample_combine \
latan_sample_flatten \
latan_sample_element \
latan_sample_plot_corr\
latan_sample_read \
latan_resample
@ -22,9 +22,9 @@ 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_element_SOURCES = sample_element.cpp
latan_sample_element_CXXFLAGS = $(COM_CXXFLAGS)
latan_sample_element_LDFLAGS = -L../lib/.libs -lLatAnalyze
latan_sample_plot_corr_SOURCES = sample_plot_corr.cpp
latan_sample_plot_corr_CXXFLAGS = $(COM_CXXFLAGS)

39
utils/sample_element.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <iostream>
#include <string>
#include <LatAnalyze/Io.hpp>
#include <LatAnalyze/MatSample.hpp>
int main(int argc, char* argv[])
{
using namespace std;
using namespace Latan;
if (argc != 4 and argc != 5) {
cout << "Usage: " << argv[0] << " <input filename> <row> <column> ";
cout << "[output filename]" << endl;
return -1;
}
string inFileName = argv[1];
auto row = strTo<Index>(argv[2]);
auto col = strTo<Index>(argv[3]);
string outFileName = (argc == 5) ? argv[4] : "";
auto inputData = Io::load<DMatSample>(inFileName);
cout << scientific;
cout << "central value:\n" << inputData[central](row, col) << endl;
cout << "standard deviation:\n";
cout << inputData.variance().cwiseSqrt()(row, col) << endl;
if (not outFileName.empty())
{
DSample outputData(inputData.size());
FOR_STAT_ARRAY(inputData, s) {
outputData[s] = inputData[s](row, col);
}
Io::save(outputData, outFileName);
}
}

View File

@ -1,31 +0,0 @@
#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);
}