33 #include <boost/archive/text_iarchive.hpp>
34 #include <boost/archive/text_oarchive.hpp>
36 #include <boost/archive/xml_iarchive.hpp>
37 #include <boost/archive/xml_oarchive.hpp>
40 using namespace Eigen;
65 int main(
int argc,
char* argv[]) {
74 std::cout <<
"t0 = " << t0 << std::endl;
75 for(
size_t row=0; row<N; row++) {
76 for(
size_t col=0; col<M; col++)
77 std::cout <<
" t0(" << row <<
"," << col <<
") = " << t0({row,col});
78 std::cout << std::endl;
88 double* data = t1.data();
90 std::cout <<
"t1 = " << t1 << std::endl;
93 t1.conservativeResize({N, M, K});
96 std::cout <<
"resized t1 = " << t1 << std::endl;
99 std::cout <<
"Printing elements one by one (getIndex): ";
100 for(
size_t k=0; k<K; k++)
101 for(
size_t m=0; m<M; m++)
102 for(
size_t n=0; n<N; n++) {
103 double d = t1({n,m,k});
104 std::cout << d <<
", ";
106 std::cout << std::endl;
108 std::cout <<
"Printing elements one by one: ";
109 for(
size_t k=0; k<t1.size(); k++){
111 std::cout << d <<
", ";
113 std::cout << std::endl;
117 t1.resize({4,4,4,4});
119 std::cout <<
"resized t1 = " << t1 << std::endl;
123 std::cout <<
"subtensor t2 = " << t2 << std::endl;
127 std::cout <<
"flattened t1 = " << t1 << std::endl;
129 std::cout <<
"flattened t2 = " << t2 << std::endl;
133 std::cout <<
" t1 concatenated with {t2,t2} = " << t1 << std::endl;
135 std::cout <<
" t1 resized to {3, 2} = " << t1 << std::endl;
139 std::cout <<
"matrix from tensor = \n" << mat << std::endl;
141 std::cout <<
"matrix *2 = \n" << mat << std::endl;
145 std::cout <<
"tensor from matrix = " << t4 << std::endl;
150 ten_ptr->enumerate();
151 std::cout <<
"Pointer to tensor = " << *ten_ptr << std::endl;
std::shared_ptr< mic::types::TensorXf > TensorXfPtr
Shared pointer to tensor of single precision floats (of dynamic size).
Contains definition of basic matrix datatypes derived from Eigen.
void concatenate(const Tensor &obj_)
Tensor< T > block(std::vector< std::vector< size_t > > ranges_)
int main(int argc, char *argv[])
Program for testing tensors/Eigen map.
Template class representing an nD (n-Dimensional) tensor. Tensor is row-major, i.e. first dimension is height (rows), second is width (cols), third is depth (channels) etc.
Template-typed Matrix of dynamic size. Uses OpenBLAS if found by CMAKE - overloaded, specializations of * operator for types: float, double.
Contains declaration of tensor types.