Questions tagged [reduction]
481 questions
9
votes
1 answer
SSE reduction of float vector
How can I get sum elements (reduction) of float vector using sse intrinsics?
Simple serial code:
void(float *input, float &result, unsigned int NumElems)
{
result = 0;
for(auto i=0; i

gorill
- 1,623
- 3
- 20
- 29
8
votes
1 answer
Haskells Weak Head Normal Form
I've stumbled over some irritating things. I know that haskell works with weak head normal form (WHNF) and I know what this is. Typing the following code into ghci (I am using the command :sprint which reduces the expression to WHNF to my…

duepiert
- 83
- 4
8
votes
1 answer
Eta reduction in haskell
I tried for a long time to reduct this function in haskell, I want to express for example:
mySum x y = x + y
mySum x y = (+) x y
mySum x = (+) x
mySum = (+) -- it's Messi's goal!
My function it a little more complex, but I really can't do it, I…

developer_hatch
- 15,898
- 3
- 42
- 75
8
votes
1 answer
Openmp and reduction on std::vector?
I want to make this code parallel:
std::vector res(n,0);
std::vector vals(m);
std::vector indexes(m);
// fill indexes with values in range [0,n)
// fill vals and indexes
for(size_t i=0; i

justHelloWorld
- 6,478
- 8
- 58
- 138
8
votes
2 answers
Strategy for doing final reduction
I am trying to implement an OpenCL version for doing reduction of a array of float.
To achieve it, I took the following code snippet found on the web :
__kernel void sumGPU ( __global const double *input,
__global double…
user1773603
8
votes
3 answers
Reduce list on the fly in Haskell
Assume I have a function f which accepts some input and produce a number. Within the function f, a list is created according the input, which is then reduced (e.g. using foldl' g) to produce the final output number. Because the intermediate list is…

Causality
- 1,123
- 1
- 16
- 28
7
votes
1 answer
openCL reduction, and passing 2d array
Here is the loop I want to convert to openCL.
for(n=0; n < LargeNumber; ++n) {
for (n2=0; n2< SmallNumber; ++n2) {
A[n]+=B[n2][n];
}
Re+=A[n];
}
And here is…

MVTC
- 845
- 11
- 28
7
votes
4 answers
Java 8 Streams reduce remove duplicates keeping the most recent entry
I have a Java bean, like
class EmployeeContract {
Long id;
Date date;
getter/setter
}
If a have a long list of these, in which we have duplicates by id but with different date, such as:
1, 2015/07/07
1, 2018/07/08
2, 2015/07/08
2,…

Nestor Milyaev
- 5,845
- 2
- 35
- 51
7
votes
3 answers
Proof that Dominating Set is NP-Complete
here is the question. I am wondering if there is a clear and efficient proof:
Vertex Cover: input undirected G, integer k > 0. Is there a subset of
vertices S, |S|<=k, that covers all edges?
Dominating Set: input undirected G, integer k > 0. Is…

SecureFish
- 2,391
- 7
- 32
- 43
7
votes
5 answers
Python 2d array boolean reduction
I've got a 2D array comprised of boolean values (True,False). I'd like to consolidate the array to a 1D based on a logical function of the contents.
e.g.
Input:
[[True, True, False],
[False, False, False],
[True, True, True]]
Output (logical…

DnRng
- 167
- 2
- 8
6
votes
2 answers
Reducing a boolean expression
I am having an expression, suppose,
a = 1 && (b = 1 || b != 0 ) && (c >= 35 || d != 5) && (c >= 38 || d = 6)
I expect it to be reduced to,
a = 1 && b != 0 && (c >= 38 || d = 6)
Does anyone have any suggestions? Pointers to any algorithm?
Nota…

Adeel Ansari
- 39,541
- 12
- 93
- 133
6
votes
2 answers
Java convert hash to random string
I'm trying to develop a reduction function for use within a rainbow table generator.
The basic principle behind a reduction function is that it takes in a hash, performs some calculations, and returns a string of a certain length.
At the moment I'm…

Joshua Craven
- 179
- 1
- 6
6
votes
2 answers
r summarize_if with multiple conditions
I'm trying to reduce a df of observations to a single observation (single line).
I would like to summarize_if is numeric with the mean and if is string or factor with the mode. The code below doesn't work, but I hope it gives the idea.
Thanks!
#data…

fiodeno
- 77
- 8
6
votes
1 answer
Intel compiler (C++) issue with OpenMP reduction on std::vector
Since OpenMP 4.0, user-defined reduction is supported. So I defined the reduction on std::vector in C++ exactly from here. It works fine with GNU/5.4.0 and GNU/6.4.0, but it returns random values for the reduction with intel/2018.1.163.
This is the…

Abaris
- 181
- 1
- 10
6
votes
1 answer
Bank conflict in parallel reduction using interleaved addressing method
I was reading the presentation on Optimizing Parallel Reduction in CUDA by Mark Harris. Here is a slide I have problem in:
It says there is bank conflict problem in this method. But why? All threads are accessing two consecutive memory cell which…

Majid Azimi
- 5,575
- 13
- 64
- 113