# Questions tagged [reduction]

The reduction tag has no usage guidance.

454
questions

**1**

vote

**0**answers

11 views

### Multi-valued model checking (reduction method)

Is there any model checking tool already used with examples for multi-valued model checking using the reduction method from multi-valued to classical model checking?
Regards

**2**

votes

**1**answer

44 views

### Make a reduction with OpenMP to compute the final summed value of an element of matrix

I have the following double loop where I compute the element of matrix Fisher_M[FX][FY].
I tried to optimize it by putting a OMP pragma #pragma omp parallel for schedule(dynamic, num_threads) but gain ...

**0**

votes

**1**answer

66 views

### CUDA array reduction optimisation

I have two arrays x (of size N ~1-100 millions) and a (greatly smaller Na ~1000-10000) and I want to use x to define a as
for(int j = 0; j < N; j++) {
float i = floor( x[j] / da); // in ...

**0**

votes

**1**answer

26 views

### How to import ReductionV2 in tensorflow?

I want to import the method ReductionV2 in tensorflow but I cannot find the source. I'm looking for this method:
losses_utils.ReductionV2.AUTO
But when I try to import it I get:
ModuleNotFoundError: ...

**-1**

votes

**1**answer

69 views

### Grid size in phase #4 of Harris' reduction optimization

I am learning about unrolling loops to optimize kernel computation.
This is a code snippet from the book Professional CUDA C Programming:
if (idx + 4 * blockDim.x <= n)
{
int a1 = g_idata[idx];
...

**-2**

votes

**1**answer

54 views

### How to understand the stride size for parallel reduction when doing multiple add?

I am learning Mark Harris's implementation of Optimizing Parallel Reduction.
I am confused by these several lines on page 32:
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x*(blockSize*2) +...

**0**

votes

**0**answers

31 views

### How Can I Find Peak Values of Defined Areas from Spectrogram Data using numpy?

I have spectrogram data from an audio analysis which looks like this:
On one axis I have frequencies in Hz and in the other times in seconds. I added the grid over the map to show the actual data ...

**1**

vote

**1**answer

114 views

### Vulkan compute shader for parallel sum reduction

I want to implement this algorithm
https://dournac.org/info/gpu_sum_reduction
in Vulkan's compute shader. In OpenCL it would be easy because I can explicitly declare
what buffers are __local and which ...

**0**

votes

**0**answers

16 views

### Feature Selection Using Eigen-values

Dear Respected stackflowrs: I would like to know if anyone can answer my question and tell me where the mistake is. Let suppose I have a dataset with n features and k samples. And let the feature ...

**4**

votes

**1**answer

116 views

### Why OpenMP reduction is slower than MPI on share memory structure?

I have tried to test OpenMP and MPI parallel implementation for inner products of two vectors (element values are computed on the fly) and find out that OpenMP is slower than MPI.
The MPI code I am ...

**-1**

votes

**1**answer

76 views

### CUDA reduce non-contiguous sub-arrays

I am writing a function for a library which accepts a large array (in GPU memory) of a power-of-2 number of elements. This function must sum non-contiguous sub-arrays (of equal length, also a power-of-...

**0**

votes

**3**answers

76 views

### OpenMP reduce array without thread-local copies

I wish to OpenMP reduce a large array into a smaller dynamic array. For example, where
large[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
// OpenMP reduce length-3 sublists of large, to produce:
small[] = {3, 6,...

**0**

votes

**1**answer

36 views

### Cuda min warp reduction produces race condition

I am somewhat confused, I have used the warp reduction as outlined by the online tutorial for quite a while now and it never caused problems. These are the snippets:
while (r < total_rotations){
...

**1**

vote

**1**answer

88 views

### Why does reduce operator does not work the way I expect it to?

I am trying to solve Euler 18 in Dyalog APL, and I am not able to understand why my solution does not work.
The problem is as follow:
By starting at the top of the triangle below and moving to ...

**1**

vote

**0**answers

39 views

### Map subset sum with negative numbers

The subset sum problem is defined as following:
Given a set of positive integers s₁,...,sₙ, is there a subset A of {1,...,n} such that the sum over A gives the positive integer T?
I know that the ...

**0**

votes

**0**answers

41 views

### How to efficiently reduce a Collection of items where all permutations of possible combinations have to be checked?

Let's say you're given this interface:
public interface Item {
boolean canCombine(Item other);
Item combine(Item other);
Two items can be combined and reduced into a single item if Item....

**2**

votes

**2**answers

180 views

### Reducing the max value and saving its index

int v[10] = {2,9,1,3,5,7,1,2,0,0};
int maximo = 0;
int b = 0;
int i;
#pragma omp parallel for shared(v) private(i) reduction(max:maximo)
for(i = 0; i< 10; i++){
if (v[i] > maximo)
...

**0**

votes

**1**answer

65 views

### CUDA sum to the right

I am trying to implement sum reduction using CUDA, however I want the reduction to be to the right not to the left..
I wrote the below code, but I am not sure why it is not working
__global__ void ...

**0**

votes

**1**answer

87 views

### Numpy reduce array to a given shape

I am trying to write a function that reduces a numpy ndarray to a given shape, which effectively "unbroadcasts" the array. For example, using add as the universal function, i want the ...

**-1**

votes

**1**answer

42 views

### Is ((f f) (g g)) reduced differently in AOR and NOR?

How is ((f f) (g g)) reduced in both applicative order reduction and normal order reduction? do both reduce the statement in the same way?

**0**

votes

**1**answer

117 views

### MPI_Reduce C/C++ - Signal: Segmentation Fault (11)

I don't understand well how the MPI_Reduce works with array.
I need to do an element wise sum.
To test the MPI_Reduce function I wrote this simple code and it works:
double a[4] = {0,1,2,(double)...

**0**

votes

**0**answers

14 views

### Define a new reduction operator in Magma

The title more or less says it all, I would like to define a new reduction operator (see the doc here), but I can't find any example of if. If anyone knows any, it would be great !
As a side note, I ...

**1**

vote

**1**answer

74 views

### "Reduction" from the complement of the universal language (L_u) to the language of nonempty-language Turing machines (L_ne)

I have a question from the domain of theoretical computer science.
The so-called universal language, L_u, is composed of pairs (M, w) such that w \in L(M). The language L_ne consists of machines M (...

**1**

vote

**1**answer

30 views

### Extract information from multiple columns at different positions using R [duplicate]

I have a dataframe with approx. 26,000 entries. The dataframe has one ID column with IDs separated by ";" and multiple value columns also separated by ";". It looks something like ...

**2**

votes

**2**answers

120 views

### An efficient way to perform an all reduction in MPI of a value based on another variable?

As an example, lets say I have
int a = ...;
int b = ...;
int c;
where a is the result of some complex local calculation and b is some metric for the quality of a.
I'd like to send the best value of a ...

**3**

votes

**2**answers

716 views

### Array reduction with OpenMP leads to "user defined reduction not found for"

I'm doing a scholar work and I have to obtain the histogram from a IMAGE.
All is going well, but when I tried to make the code parallel with the OpenMP, the compiler returns me this error: user ...

**0**

votes

**2**answers

78 views

### How to change a property of an object in Vue?

I try to modify data in Vue for chartjs.
The basic datas are purchase orders with supplier_id and supplier_name
I like to know, how many orders each supplier has:
methods: {
render(...

**-1**

votes

**1**answer

22 views

### Classifying NP Completeness and Hardness

Choose the correct statement(s):
(A) If X is an NP-complete problem, then X is an NP problem
(B) If X is an NP-complete problem, then X is an NP-hard
(C) Let X be an NP-complete problem. If X can ...

**2**

votes

**2**answers

97 views

### Collectors.reducing method is updating the same identity when used as downstream for Collectors.partitionBy

I have a class similar to the below MyObject.
public class MyObject {
private String key; // not unique. multiple objects can have the same key.
private boolean isPermanent;
private double ...

**0**

votes

**2**answers

39 views

### Determining time complexity of solution by reductions

Suppose that you found a solution to the A problem and are trying to get some idea of its complexity. You solve A by calling your B sub-routine a total of n^2 times and also doing a constant amount of ...

**5**

votes

**1**answer

65 views

### Reduction operator using user-defined function error

The raku webpage says that extra bracket should be used for user-defined functions within reduction operator: https://docs.raku.org/language/operators#Reduction_metaoperators
However, I am getting ...

**5**

votes

**1**answer

48 views

### Clean way to loop over a masked list in Julia

In Julia, I have a list of neighbors of a location stored in all_neighbors[loc]. This allows me to quickly loop over these neighbors conveniently with the syntax for neighbor in all_neighbors[loc]. ...

**1**

vote

**1**answer

88 views

### OpenACC reduction clause with max()

I am learning OpenACC and came across the code bellow for the Jacobi iteration, provided by NVidia. From my understanding, reduction(max:err) creates a private err variable for each loop iteration, ...

**0**

votes

**0**answers

55 views

### How to perform a reduction and FFT using metal?

My data analysis software is written mostly using OpenCL. My code implements a larger number of reductions and Fast Fourier Transforms (FFTs). Now that Apple has abandoned OpenCL and wants us to use ...

**0**

votes

**0**answers

235 views

### reduction from ALLtm to Etm

I am trying to understand why this "proof" of Etm undecidability is wrong.
ALLtm={ < M >|M is a TM, L(M)=∑*}
ETM={< M >|M is a TM, L(M)=∅}
We know that ALLTM is undecidable, lets ...

**1**

vote

**0**answers

254 views

### Reduction - Subset sum problem to path sum problem

I am trying to reduce the decision subset sum problem to decision path sum problem but I can not see the relation between them.
The subset sum problem is about deciding if there is a subset in the set ...

**1**

vote

**1**answer

176 views

### How to apply just one beta-reduction to λy.(λx.λy.yx)yz?

I am not understanding how to reach the correct answer, which is λy.(λw.wy)z
Renaming is allowed only if necessary, and from the answer it is obvious renaming was used.

**1**

vote

**1**answer

194 views

### NP-Complete problems to Partition Problem reductions

According to Wikipedia, Partition Problem (PP) is NP-Complete (NPC) problem with existing pseudo-polynomial time dynamic programming (DP) solution. If a problem is NPC any NP problem can be reduced to ...

**0**

votes

**3**answers

69 views

### Reduce an associative array to randomised pairs of unique values

I am trying to reduce an associative array to pairs of unique values, whereby the keys are letters to be paired and the values are their count()s.
Each pair cannot contain the same letter twice such ...

**1**

vote

**3**answers

176 views

### How to print list vertically using recursion?

I want to print this list vertically recursively:
Example:
print_list(['hi', [22,45], 'dog', 21])
Expected:
hi
[22, 45]
dog
21
Here is my code:
def print_list(n_list):
if len(n_list) == 0:
...

**4**

votes

**2**answers

145 views

### Binary Array Reduce Map to Rectangles in C#

Given the following c# array:
const bool X = true, _ = false;
bool[,] array = new bool[,] {
{ X, X, X, X, _, X, X, X, _, _ },
{ _, _, _, _, _, X, X, X, X, _ },
{ X, X, ...

**0**

votes

**1**answer

78 views

### what is the class of the combination of two problems which one of them is NP-Complete problem?

I have an optimization problem with a minimization cost function and two constraints to meet. Without considering one of the constraints, I can reduce the optimization problem to an NP-Complete ...

**1**

vote

**0**answers

174 views

### problem with !$OMP PARALLEL in fortran & segmentation fault

I'm fairly new to fortran and very new to openmp. I have inherited a fortran code from a colleague, and I'm requested to parallelize it using openmp. The code was originally translated from matlab, ...

**1**

vote

**1**answer

53 views

### Does R use applicative order reduction?

I came across this example from an R tutorial recently and I found this syntax really odd because it hints towards normal order reduction where arguments are wrapped / delayed. In applicative order ...

**0**

votes

**2**answers

58 views

### Lambda reduction

I'm having trouble understanding how to reduce lambda terms to normal form. could someone help me to understand how to reduce this lambda expression? I don't know exactly where to start.
(λx. ( λa. (...

**0**

votes

**1**answer

118 views

### Computing remainder of polynomial division

Does the following code implement modular reduction of the polynomial multiplication of f•g modulo xp−x−1? As we know, to get the modular reduction, we first multiply the polynomials f and g, then ...

**0**

votes

**1**answer

100 views

### OpenMP: Is array reduction always needed for updating an array in parallel?

I am quite new to OpenMP. I have the following simple loop that I want to run in parallel with OpenMP:
double rij[3];
double r;
#ifdef _OPENMP
#pragma omp parallel for private(rij,r)
#endif
for (int ...

**0**

votes

**1**answer

552 views

### Reduction columns are not working for group by expression in oracle

I tried to concat two columns and using group by expression, but it is not work. how can I grouped multiple columns in oracle. first_name and last_name are reduction data.
SELECT employee_id,
...

**0**

votes

**1**answer

220 views

### How to do tuple reduction in thrust (also return a tuple)?

Say I have a tuple consisting of two thrust::device_vector. I want the output to be a tuple consisting of two scalars, which are the sum of two vectors respectively. For example,
input tuple ...

**0**

votes

**0**answers

311 views

### Reduce SAT <=p Independent Set

I am a bit confused. I know how to reduce 3-SAT to IS. An example of transforming 3-SAT to IS graph would be create a graph representing each clause of the 3-SAT and then joining the x and !x and then ...