You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
569 B
24 lines
569 B
#include <iostream>
|
|
#include <unsupported/Eigen/CXX11/Tensor>
|
|
#include <Eigen/Dense>
|
|
#include <Eigen/Eigen>
|
|
using Eigen::Tensor;
|
|
using Tensor3f= Tensor<float,3>;
|
|
|
|
void print_tensor(const Tensor3f & t3){
|
|
for(int k=0;k<t3.dimension(2);++k){
|
|
std::cout<<t3.chip(k,2)<<std::endl;
|
|
std::cout<<std::endl;
|
|
}
|
|
}
|
|
int main() {
|
|
Tensor3f a(2,2,3);
|
|
a.setValues({{{1, 2, 3}, {6, 5, 4}},{{11, 12, 13}, {16, 15, 14}}});
|
|
print_tensor(a);
|
|
float *p=a.data();
|
|
for(int i=0;i<a.size();++i){
|
|
std::cout<<*p++<<std::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|