Skip to content

Instantly share code, notes, and snippets.

@marty1885
Last active August 18, 2017 07:57
Show Gist options
  • Save marty1885/fba41a4f2b58fc25f6b4524b5d741e41 to your computer and use it in GitHub Desktop.
Save marty1885/fba41a4f2b58fc25f6b4524b5d741e41 to your computer and use it in GitHub Desktop.
#include <xtensor/xarray.hpp>
#include <xtensor/xrandom.hpp>
#include <xtensor/xio.hpp>
#include <xtensor/xindexview.hpp>
#include <xtensor-blas/xlinalg.hpp>
#include <iostream>
using namespace std;
void s1()
{
cout << "\nscenario 1. ==========" << endl;
xt::xarray<float> x = {{0,1,1,1}};
x = xt::transpose(x);
cout << x << endl;
}
void s2()
{
cout << "\nscenario 2. ==========" << endl;
xt::xarray<float> tmp = {{0,1,1,1}};
xt::xarray<float> x = xt::transpose(tmp);
cout << x << endl;
}
void s3()
{
cout << "\nscenario 3. ==========" << endl;
xt::xarray<float> tmp = {{0,1,1,1}};
auto x = xt::transpose(tmp);
cout << x << endl;
}
void s4()
{
cout << "\nscenario 4. ==========" << endl;
auto x = xt::transpose(xt::xarray<float>({{0,1,1,1}}));
cout << x << endl;
}
void s5()
{
cout << "\nscenario 5. ==========" << endl;
auto x = xt::xarray<float>({{0,1,1,1}});
x = xt::transpose(x);
cout << x << endl;
}
int main()
{
s1();
s2();
s3();
s4();
s5();
}
@marty1885
Copy link
Author

marty1885 commented Aug 18, 2017

This program prints the following on my system.

scenario 1. ==========
{{ 0.},
 { 1.},
 { 1.},
 { 0.}}

scenario 2. ==========
{{ 0.000000e+00},
 { 1.000000e+00},
 { 1.000000e+00},
 { 4.563048e-41}}

scenario 3. ==========
{{ 0.},
 { 1.},
 { 1.},
 { 1.}}

scenario 4. ==========
{{ 0.},
 { 1.},
 { 1.},
 { 1.}}

scenario 5. ==========
{{ 0.000000e+00},
 { 1.000000e+00},
 { 1.000000e+00},
 { 4.563048e-41}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment