File: LocalLinearDiscrLastDimRegressionGeners.cpp

package info (click to toggle)
stopt 5.12%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,860 kB
  • sloc: cpp: 70,456; python: 5,950; makefile: 72; sh: 57
file content (64 lines) | stat: -rw-r--r-- 2,616 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <memory>
#include <geners/IOException.hh>
#include <geners/arrayIO.hh>
#include "StOpt/regression/LocalLinearDiscrLastDimRegressionGeners.h"
#include "StOpt/core/utils/eigenGeners.h"

using namespace StOpt;
using namespace std;

bool LocalLinearDiscrLastDimRegressionGeners::write(ostream &p_of, const wrapped_base &p_base,
        const bool p_dumpId) const
{
    // If necessary, write out the class id
    const bool status = p_dumpId ? wrappedClassId().write(p_of) : true;

    // Write the object data out
    if (status)
    {
        const wrapped_type &w = dynamic_cast<const wrapped_type &>(p_base);
        gs::write_pod(p_of, w.getBZeroDate());
        gs::write_item(p_of, w.getNbMesh());
        gs::write_item(p_of, w.getMesh());
        gs::write_item(p_of, w.getMesh1D());
        gs::write_item(p_of, w.getMeanX());
        gs::write_item(p_of, w.getEtypX());
        gs::write_item(p_of, w.getSvdMatrix());
        gs::write_pod(p_of, w.getBRotationAndRescale());
    }

    // Return "true" on success
    return status && !p_of.fail();
}

LocalLinearDiscrLastDimRegression *LocalLinearDiscrLastDimRegressionGeners::read(const gs::ClassId &p_id, istream &p_in) const
{
    // Validate the class id. You might want to implement
    // class versioning here.
    wrappedClassId().ensureSameId(p_id);

    // Read in the object data
    bool bZeroDate = 0;
    gs::read_pod(p_in, &bZeroDate);
    unique_ptr<Eigen::ArrayXi> nbMesh = gs::read_item< Eigen::ArrayXi>(p_in);
    unique_ptr<Eigen::Array< std::array< double, 2>, Eigen::Dynamic, Eigen::Dynamic > > mesh = gs::read_item< Eigen::Array< std::array< double, 2>, Eigen::Dynamic, Eigen::Dynamic > >(p_in);
    unique_ptr<vector< shared_ptr< Eigen::ArrayXd > > > mesh1D = gs::read_item<  vector< shared_ptr< Eigen::ArrayXd > > >(p_in);
    unique_ptr< Eigen::ArrayXd> meanX = gs::read_item<  Eigen::ArrayXd>(p_in);
    unique_ptr< Eigen::ArrayXd> etypX = gs::read_item<  Eigen::ArrayXd>(p_in);
    unique_ptr< Eigen::MatrixXd> svdMatrix = gs::read_item<  Eigen::MatrixXd>(p_in);
    bool bRotationAndRescale = false;
    gs::read_pod(p_in, &bRotationAndRescale);

    // Check that the stream is in a valid state
    if (p_in.fail()) throw gs::IOReadFailure("In BIO::read: input stream failure");

    // Return the object
    return new LocalLinearDiscrLastDimRegression(bZeroDate,  *nbMesh, *mesh, *mesh1D, *meanX, *etypX, *svdMatrix, bRotationAndRescale);
}

const gs::ClassId &LocalLinearDiscrLastDimRegressionGeners::wrappedClassId()
{
    static const gs::ClassId wrapId(gs::ClassId::makeId<wrapped_type>());
    return wrapId;
}