

Multiply each row of a matrix with its transpose
source link: https://www.codesd.com/item/multiply-each-row-of-a-matrix-with-its-transpose.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Multiply each row of a matrix with its transpose
The formula I have to translate to Octave/Matlab goes something like this:
\sum (v_i - m) (v_i - m)^T
I have a matrix, and I need to take each row, subtract m
from it and then multiply it with its own transpose. I wrote the inner part as a function:
function w = str(v, m)
y = v - m
w = y * transpose(y)
end
My matrix is like this
xx = [1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5]
Now I have no idea how to apply this function to each row in a matrix and then sum them up to a new matrix. Maybe someone can help me here.
EDIT: The result is not the dot product. I'm looking for v * v^T
, which has a matrix as result!
Probably you need this
X = bsxfun( @minus, A, m );
Y = X'* X;
Related Articles
How to multiply each row in a matrix by each column of the second matrix of Python?
Multiply the values of each row of the matrix with columnvector and sum rows
armadillo c ++: efficient and concise way to multiply each row of a matrix by a vector?
How to multiply each row by each row of another matlab element matrix?
Find the column index for the 1 in each row of a matrix
How to divide each row of a matrix by elements of a vector in R
How to apply a function to each row of a matrix (or a data frame) in R
How to repeat a calculation for each row of a matrix in R?
the fastest method to keep the first 2 values of each row in a matrix (or data.frame) in R
subtracting a constant vector from each row of a matrix in r
Count the sub-lines in each row of a matrix in Matlab?
Access each row of a matrix and apply to the function
A: How do I add a column with a randomly chosen value for each row in a matrix?
Multiply each column into a matrix per column in the vector
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK