Questions tagged [vector-multiplication]
46 questions
10
votes
2 answers
Vectorized multiplication: Multiply two vectors in Julia, element-wise
I decided to dive into Julia and hitting the wall; fast.
I am trying to replicate a simple operation, which would like as follows in python numpy
a = numpy.array([1,2,3])
b = numpy.array([1,2,3])
a*b
[output]: [1,4,9]
In other words "[1,4,9]" is…

dmeu
- 3,842
- 5
- 27
- 43
7
votes
3 answers
Convert values of a tensor in TensorFlow to regular Javascript array
I used the outerProduct function in the TensorFlow.js framework on two 1D arrays (a,b), but I am finding it difficult to get the values of the resulting tensor in the regular javascript format.
Even after using .dataSync and Array.from(), I am…

Isaac
- 396
- 3
- 13
3
votes
1 answer
Why am I getting two different answers with quaternion-vector multiplication
I am trying to multiply a quaternion with a vector following the formula q * v * q_conjugate(q) I found in this thread. When I run the following code in Python, I get an output that looks correct. However, when I run the code again I get another…

Frederik Petri
- 451
- 8
- 24
3
votes
2 answers
Is numpy.multiply always equivalent to the * operator?
The numpy.multiply documentation says:
Equivalent to x1 * x2 in terms of array broadcasting.
Is np.multiply(x1, x2) different to x1 * x2 in any circumstance?
Where would I find the implementations of each?
Note: An analogous question exists for…

Tom Hale
- 40,825
- 36
- 187
- 242
3
votes
0 answers
Vector Multiplication using GPU on python
I'm trying to do vector multiplication using numba vectorize. But instead of having two lists containing int or float type, i have two lists containing objects. I want to do multiplication of the attributes contained in these objects. ie. ob1.attr *…

SunshineAndLove
- 41
- 5
3
votes
1 answer
MATLAB: element-wise multiplication of two matrices over one index?
I'm trying to figure out if there's a native way of obtaining a certain kind of element-wise product of two matrices in Matlab.
The product that I'm looking for takes two matrices, A and B say, and returns there product C, whose elements are given…

Kris
- 22,079
- 3
- 30
- 35
2
votes
1 answer
Multiply rows of matrix by vector elementwise in pytorch?
I would like to do the below but using PyTorch.
The below example and description is from this post.
I have a numeric matrix with 25 columns and 23 rows, and a vector of
length 25. How can I multiply each row of the matrix by the vector
without…

avgJoe
- 832
- 7
- 24
2
votes
1 answer
Return double from vector multiplication with Armadillo C++
Do you know why I cannot store in a double the result from a vector multiplication ?
double A = rowvec({1,3,4})*vec({5,6,7});
It gives "no suitable conversion function from "const arma::Glue"... to "const double" exists.
Still that matrix vector…
user6581106
2
votes
1 answer
Matrix-Vector and Matrix-Matrix multiplication using SSE
I need to write matrix-vector and matrix-matrix multiplication functions but I cannot wrap my head around SSE commands.
The dimensions of matrices and vectors are always multiples of 4.
I managed to write the vector-vector multiplication function…

Denis Yakovenko
- 3,241
- 6
- 48
- 82
2
votes
2 answers
Multiplying numbers in a list (coordinate-wise) without using mapcar in Lisp
I'm having trouble with the output of my code, I think it's when I'm checking conditions for the null of my lists.
The question I am trying to complete is: Write a function vecmul that will take as inputs two simple lists of numbers. vecmul should…

DLR
- 187
- 3
- 15
1
vote
1 answer
How to execute the cross multiplication in unittest
I have the following class
from math import sqrt
class Vector:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __eq__(self, other): # v == w
return self.x == other.x and self.y == other.y and…

12666727b9
- 1,133
- 1
- 8
- 22
1
vote
1 answer
Create a long list where each element of one list is repeated/ multiplied by a value from another dataframe
I have run into a bit of a conundrum that I can't find any obvious answers to on stack overflow, so wondered if I could please pick the expertise hive mind!
I basically have a list of providers, which I have grouped by region to get the number of…

KatChristiansen
- 11
- 1
1
vote
2 answers
Vector math arithmetic operations in jq
I'd like to perform vector math operations on a json array that stores numbers. In short how can we achieve one to one arithmetic operations by using jq?
I tried something with 'map' filter however could not achieved what I expect.
jq…

Hüseyin
- 17
- 4
1
vote
5 answers
Multiplying 2 arrays into a 3rd blank array range VBA(Excel)
Dim i As Integer, q As Integer
Dim rng As Range
Dim my_array1elm
Dim my_array2elm
Dim x As Long
Sub Yoo()
Range("B1").Select
For i = 1 To 12
ActiveCell.Value = i
ActiveCell.Offset(0, 1).Select
Next
Range("A2").Select
For q = 1 To 12
…

robin hood
- 11
- 1
1
vote
1 answer
Python pair-wise multiplication using broadcasting on the first dimension
I have one-hot vector of shape 1 * n
v= [0.0, 1.0, 0.0] for n = 3
and a matrix of shape n * m * r as( m and r can be any number but the first dimention is as n)
m = [[[1,2,3,],[4,5,6]], [[5,6,7],[7,8,9]], [[2,4,7],[1,8,9]]]
I want to multiple a *…

Mahmood
- 15
- 4