blitzpp / blitz

Blitz++ Multi-Dimensional Array Library for C++
https://github.com/blitzpp/blitz/wiki
Other
406 stars 84 forks source link

bug when reducing over an array expression #11

Open floswald opened 8 years ago

floswald commented 8 years ago

this is an old bug http://sourceforge.net/p/blitz/bugs/17/ but I've run into this a week ago. I don't know if you just want to look at all the bugs in the sourceforge tracker or start a new list here. anyway, here goes.

#include <blitz/array.h>

using namespace blitz;
using namespace blitz::tensor;

#define EXPR a1(i, k) * a2(k, l) * a3(l, j)

int main()
{
  Array<float, 2> a1(2, 2), a2(2, 2), a3(2, 2);
  Array<float, 4> a4(2, 2, 2, 2);
  Array<float, 2> a5(2, 2), a6(2, 2);
  a1 = 1, 0, 0, 1;
  a2 = a1;
  a3 = a1;
  a4 = EXPR;
  a5 = sum(sum(a4  , l), k);  // this works
  a6 = sum(sum(EXPR, l), k);  // this fails, although it is semantically identical
  return 0;
}