Cosan
1.0
Data Analytics Library
template2.cpp
Go to the documentation of this file.
1
#include <iostream>
2
#include <vector>
3
#include <type_traits>
4
#include <numeric>
5
#include <string>
6
#include <gsl/gsl>
7
#include <concepts>
8
#include <
cosan/data/CosanData.h
>
9
// // Maybe useful to restricted to only CosanBO class.
10
// template <class T, class U>
11
// concept Derived = std::is_base_of<U, T>::value;
12
13
// // Useful for Metric, Model, Splittor class.
14
// template <class T, class U>
15
// concept Derived = std::is_base_of<U, T>::value;
16
17
// template<Derived<Base> T>
18
// void f(T); // T is constrained by Derived<T, Base>
19
20
template
<
typename
NumericType>
21
concept
Numeric
= std::is_arithmetic<NumericType>::value ;
22
23
// template<Numeric T>
24
template
<
typename
NumericType
,
25
typename
=
typename
std::enable_if<std::is_arithmetic<NumericType>::value,
NumericType
>::type>
26
void
f
(
NumericType
a){
27
std::cout<<a<<std::endl;
28
29
}
30
// template<typename T> using Ref = T&;
31
// template<typename T> concept C =
32
// requires {
33
// typename T::inner; // required nested member name
34
// typename S<T>; // required class template specialization
35
// typename Ref<T>; // required alias template substitution
36
// };
37
38
// template <class T, class U> using CommonType = std::common_type_t<T, U>;
39
// template <class T, class U> concept Common =
40
// requires (T&& t, U&& u) {
41
// typename CommonType<T, U>; // CommonType<T, U> is valid and names a type
42
// { CommonType<T, U>{std::forward<T>(t)} };
43
// { CommonType<T, U>{std::forward<U>(u)} };
44
// };
45
46
47
int
main
(){
48
f<std::string>(3);
49
int
50
Cosan::CosanMatrix<double>
M(5,4);
51
return
0;
52
}
53
54
// template<typename T1>
55
// class A{
56
// T1 a;
57
// template<class T2,
58
// std::enable_if_t<std::is_same_v<std::decay_t<T2>,std::vector<T1>>,bool> = true>
59
// void foo(T2 && a){
60
// // stuff
61
// }
62
63
// }
64
65
// int main(){
66
// return 0;
67
// }
68
69
// #include <iostream>
70
// #include <vector>
71
// #include <type_traits>
72
// #include <Eigen/dense>
73
74
// template<class T,
75
// std::enable_if_t<std::is_same_v<std::decay_t<T>,Eigen::MatrixXd>,bool> = true>
76
// void foo(T && a){
77
// std::cout<<"Hello"<<std::endl;
78
// }
79
// int main(){
80
// Eigen::MatrixXd a;
81
// a.resize(3,3);
82
// a<<1,2,3,
83
// 4,5,6,
84
// 7,8,9;
85
// std::cout<<a(std::vector<int>({0,2}),Eigen::all)<<std::endl;
86
// foo(a(std::vector<int>({0,2}),Eigen::all));
87
88
// return 0;
89
// }
CosanData.h
NumericType
double NumericType
Definition:
onehotencodingTest.cpp:20
Cosan::CosanMatrix
Eigen::Matrix< NumericType, Eigen::Dynamic, Eigen::Dynamic > CosanMatrix
Definition:
CosanBO.h:37
f
void f(NumericType a)
Definition:
template2.cpp:26
Numeric
concept Numeric
Definition:
template2.cpp:21
main
int main()
Definition:
template2.cpp:47
test
template2.cpp
Generated by
1.8.20