mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Implement exclusive scan option
This commit is contained in:
@@ -38,6 +38,30 @@ static void test_1d_scan()
|
||||
}
|
||||
}
|
||||
|
||||
template <int DataLayout, typename Type=float>
|
||||
static void test_1d_inclusive_scan()
|
||||
{
|
||||
int size = 50;
|
||||
Tensor<Type, 1, DataLayout> tensor(size);
|
||||
tensor.setRandom();
|
||||
Tensor<Type, 1, DataLayout> result = tensor.cumsum(0, true);
|
||||
|
||||
VERIFY_IS_EQUAL(tensor.dimension(0), result.dimension(0));
|
||||
|
||||
float accum = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
VERIFY_IS_EQUAL(result(i), accum);
|
||||
accum += tensor(i);
|
||||
}
|
||||
|
||||
accum = 1;
|
||||
result = tensor.cumprod(0, true);
|
||||
for (int i = 0; i < size; i++) {
|
||||
VERIFY_IS_EQUAL(result(i), accum);
|
||||
accum *= tensor(i);
|
||||
}
|
||||
}
|
||||
|
||||
template <int DataLayout, typename Type=float>
|
||||
static void test_4d_scan()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user