mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 00:45:36 +00:00
Merge commit '82d020c82fb0a3ac8f1b56da8b3e00a0fff4716d' into develop
# Conflicts: # utils/Makefile.am
This commit is contained in:
commit
cbdb2fba6f
@ -8,6 +8,7 @@ endif
|
||||
|
||||
bin_PROGRAMS = \
|
||||
latan-sample-combine \
|
||||
latan-sample-element \
|
||||
latan-sample-fake \
|
||||
latan-sample-plot-corr\
|
||||
latan-sample-read \
|
||||
@ -17,6 +18,10 @@ latan_sample_combine_SOURCES = sample-combine.cpp
|
||||
latan_sample_combine_CXXFLAGS = $(COM_CXXFLAGS)
|
||||
latan_sample_combine_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_fake_SOURCES = sample-fake.cpp
|
||||
latan_sample_fake_CXXFLAGS = $(COM_CXXFLAGS)
|
||||
latan_sample_fake_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||
|
39
utils/sample-element.cpp
Normal file
39
utils/sample-element.cpp
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user