outer.C 523 B

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