outer.C 511 B

123456789101112131415161718192021222324252627282930
  1. // Daniel Llorens - 2015
  2. // Adapted from blitz++/examples/outer.cpp
  3. #include "ra/ra-operators.H"
  4. using std::cout; using std::endl; using std::flush;
  5. int main()
  6. {
  7. ra::Owned<float,1> x { 1, 2, 3, 4 }, y { 1, 0, 0, 1 };
  8. ra::Owned<float,2> A({4,4}, 99.);
  9. x = { 1, 2, 3, 4 };
  10. y = { 1, 0, 0, 1 };
  11. ra::TensorIndex<0> i;
  12. ra::TensorIndex<1> j;
  13. A = x(i) * y(j);
  14. cout << A << endl;
  15. // [ra] an alternative
  16. cout << from(std::multiplies<float>(), x, y) << endl;
  17. return 0;
  18. }