-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreprocess_Factory.h
More file actions
67 lines (55 loc) · 2.99 KB
/
Preprocess_Factory.h
File metadata and controls
67 lines (55 loc) · 2.99 KB
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
65
66
67
//
// Created by simonepanzeri on 01/12/2021.
//
#ifndef DEV_FDAPDE_PREPROCESS_FACTORY_H
#define DEV_FDAPDE_PREPROCESS_FACTORY_H
#include "FdaPDE.h"
#include "Preprocess_Phase.h"
//template<typename T, typename... Args>
//std::unique_ptr<T> make_unique_time(Args&&... args)
//{
// return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
//}
//! @brief A Factory class: a class for the choice of the cross-validation method.
template<UInt ORDER, UInt mydim, UInt ndim>
class Preprocess_factory
{
public:
//! A method that builds a pointer to the right object for the cross-validation method choice, taking as parameters a string and others objects needed for constructor.
static std::unique_ptr<Preprocess<ORDER, mydim, ndim>>
createPreprocessSolver(const DataProblem<ORDER, mydim, ndim>& dp,
const FunctionalProblem<ORDER, mydim, ndim>& fp,
std::shared_ptr<MinimizationAlgorithm<ORDER, mydim, ndim>> ma, const std::string& p){
if(p=="RightCV")
return make_unique<RightCrossValidation<ORDER, mydim, ndim>>(dp, fp, ma);
else if(p=="SimplifiedCV")
return make_unique<SimplifiedCrossValidation<ORDER, mydim, ndim>>(dp, fp, ma);
else if(p=="NoCrossValidation")
return make_unique<NoCrossValidation<ORDER, mydim, ndim>>(dp, fp);
else
return make_unique<RightCrossValidation<ORDER, mydim, ndim>>(dp, fp, ma);
}
};
//! ####################################################################################################################
//! ######################################## SPACE-TIME PROBLEM ########################################################
//! ####################################################################################################################
//! @brief A Factory class: a class for the choice of the cross-validation method.
template<UInt ORDER, UInt mydim, UInt ndim>
class Preprocess_factory_time{
public:
//! A method that builds a pointer to the right object for the cross-validation method choice, taking as parameters a string and others objects needed for constructor.
static std::unique_ptr<Preprocess_time<ORDER, mydim, ndim>>
createPreprocessSolver(const DataProblem_time<ORDER, mydim, ndim>& dp,
const FunctionalProblem_time<ORDER, mydim, ndim>& fp,
std::shared_ptr<MinimizationAlgorithm_time<ORDER, mydim, ndim>> ma, const std::string& p){
if(p=="RightCV")
return make_unique_time<RightCrossValidation_time<ORDER, mydim, ndim>>(dp, fp, ma);
else if(p=="SimplifiedCV")
return make_unique_time<SimplifiedCrossValidation_time<ORDER, mydim, ndim>>(dp, fp, ma);
else if(p=="NoCrossValidation")
return make_unique_time<NoCrossValidation_time<ORDER, mydim, ndim>>(dp, fp);
else
return make_unique_time<RightCrossValidation_time<ORDER, mydim, ndim>>(dp, fp, ma);
}
};
#endif //DEV_FDAPDE_PREPROCESS_FACTORY_H