Questions tagged [elementwise-operations]
204 questions
0
votes
1 answer
How can I do an element-wise sum of several arrays in Java inside a stream?
I want to stream a list of objects, each of which contain a series of integers of the same size. Then I want to do an element-wise sum of all the lists, reulting into a single list of the same size. It should be something like…

Rayamon
- 304
- 3
- 10
0
votes
1 answer
Numpy Value Error: Elementwise Operations on Meshgrid
Given my code below:
import numpy as np
nx, ny, nz = (50, 50, 50)
x = np.linspace(1, 2, nx)
y = np.linspace(2, 3, ny)
z = np.linspace(0, 1, nz)
xg, yg, zg = np.meshgrid(x, y, z)
def fun(x, y, z, a, b, c):
r = np.array([x, y, z])
r0 =…

Sterling Butters
- 1,024
- 3
- 20
- 41
0
votes
0 answers
Jacobian of theano scan creates named copies of symbolic variables, resulting in wrongly assigned inputs and UnusedInputError
I have a model in which rates of a random (Poisson) process are distributed according to a function p_nu(gamma,delta,nu_max). With pymc3/theano I want to obtain the posterior distribution of gamma,delta,nu_max when observing N_AP events (N_AP being…

wollex
- 3
- 3
0
votes
1 answer
Element-wise multidimension matrix multiplication with broadcasting in python
Is there a efficient (numpy function) way to do element-wise matrix multiplication of two different-sized arrays that will broadcast into a new array. e.g.,
a = np.arange(24).reshape((2,12)) #gives a 2x12 array
b = np.arange(36).reshape((3,12))…

bigwillis234
- 25
- 3
0
votes
0 answers
NP Array Comparison elementwise and specific conditions
I would like to ask a question for a numpy array below.
I have a dataset, which has 50 rows and 15 columns and I created a numpy array as such:
I want to compare rows with each other (except than itself), then found the number of rows which…

Dinc Kirikci
- 47
- 6
0
votes
1 answer
Numpy Array Comparison (Python)
I would like to ask a question for a numpy array below.
I have a dataset, which has 50 rows and 15 columns and I created a numpy array as such:
x=x.to_numpy()
I want to compare rows with each other (except than itself), then found the number of…

Dinc Kirikci
- 47
- 6
0
votes
1 answer
Element-wise comparison of numpy arrays (Python)
I would like to ask a question for a numpy array below.
I have a dataset, which has 50 rows and 15 columns and I created a numpy array as such:
x=x.to_numpy()
My aim is compare each row with other rows(elementwise and except itself) and find…

Dinc Kirikci
- 47
- 6
0
votes
1 answer
Multiply matrix by vector rowwise (sweep)
Does STAN provide a method for multiplying each row of a matrix by a vector, elementwise? i.e. if I had a matrix:
[1,2,3,
4,5,6]
and a vector:
[2,4,6]
the desired result would be a second matrix:
[2,8,18,
8,15,36]
I'm sure I can do this as a…

Canadian_Marine
- 479
- 1
- 4
- 10
0
votes
0 answers
Elementwise subtraction of tensor values in one list
I have a list tensor_list containing tensors in the form of matrices. Some of the matrices have a different shape (e.g. torch.Size([512, 784]) and torch.Size([10, 512])). I want to subtract each element from the element of the successor and store…

Alice
- 1
- 1
0
votes
1 answer
a 2d numpy array element-wise raised to the power of another 2d array
I need to raise a large 2d numpy array element-wise to the power of another 2d array with the same dimensions. I tried to use numba to improve the speed. Is there an efficient implementation using numpy built-in functions instead of numba?
import…

Jayyu
- 319
- 2
- 10
0
votes
3 answers
How to find max values from multiple list and the corresponding list it came from
So I have n arrays which I want to do a element-wise comparisent and find the max value with python. A good solution I found here is:
np.maximum.reduce([a,b,c]).
But I would like to have another list with tuples corresponding to the max value and…

hero
- 1
- 1
0
votes
2 answers
Removing DC component for matrix in chuncks in octave
I'm new to octave and if this as been asked and answered then I'm sorry but I have no idea what the phrase is for what I'm looking for.
I trying to remove the DC component from a large matrix, but in chunks as I need to do calculations on each…

Robert
- 37
- 3
0
votes
1 answer
Error using Eigen: Perform element-wise multiplication between a vector and matrix
I am trying to perform an element-wise multiplication of a row vector with matrix. In MATLAB this would be simply done by the "dot" operator or:
deriv = 1i * k .* fk;
where k is row vector and fk is a matrix.
Now in C++ I have this code:
static…

Jamie
- 365
- 2
- 5
- 13
0
votes
1 answer
vectorized way to multiply and add specific axes in numpy array (convolutional layer backprop)
I was wondering how it would be possible to vectorize the following quadruple for-loops (this is t do with backprop in a convolutional layer).
W = np.ones((2, 2, 3, 8)) # just a toy example
dW = np.zeros(W.shape)
dZ = np.ones((10, 4, 4, 8))*2
# get…

jackewiebohne
- 23
- 5
0
votes
1 answer
Numpy - Calculate element wise mean for a 1D array
I found multible questions with similar titles but they didn't match with my case.
I have a np.array with offset values and I want the mean value for index from all previous values.
My first approach was with a for loop, but with huge arrays it is…

Tom Müller
- 5
- 1