Adding rows of one matrix to columns of another matrix [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite
1












I'm thinking of an operation which is almost similar to the inner product of two matrices, except the elementwise product is replaced with a sum.



Suppose $A_m times n$ and $B_ntimes k$ are our two matrices, and the inner product would be:
$C$ such that $$ c_ij = sum_l=1^na_ilb_lj$$



Is there a way to do, in a vectorized manner,



$$ c_ij = sum_l=1^na_il + b_lj$$
?



Can this result be derived from other well-known matrix addition or product operations?







share|cite|improve this question











closed as off-topic by Alex Francisco, John Ma, amWhy, Xander Henderson, José Carlos Santos Jul 19 at 22:59


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Alex Francisco, amWhy, Xander Henderson
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    Welcome to MSE. Please read this text about how to ask a good question.
    – José Carlos Santos
    Jul 18 at 14:34










  • For what it's worth - I can sum one matrix row-wise and the other column wise, and then take their inner product. But I'm curious if there's a way that doesn't involve the column or row-wise sum.
    – Jaidev Deshpande
    Jul 18 at 15:14














up vote
0
down vote

favorite
1












I'm thinking of an operation which is almost similar to the inner product of two matrices, except the elementwise product is replaced with a sum.



Suppose $A_m times n$ and $B_ntimes k$ are our two matrices, and the inner product would be:
$C$ such that $$ c_ij = sum_l=1^na_ilb_lj$$



Is there a way to do, in a vectorized manner,



$$ c_ij = sum_l=1^na_il + b_lj$$
?



Can this result be derived from other well-known matrix addition or product operations?







share|cite|improve this question











closed as off-topic by Alex Francisco, John Ma, amWhy, Xander Henderson, José Carlos Santos Jul 19 at 22:59


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Alex Francisco, amWhy, Xander Henderson
If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    Welcome to MSE. Please read this text about how to ask a good question.
    – José Carlos Santos
    Jul 18 at 14:34










  • For what it's worth - I can sum one matrix row-wise and the other column wise, and then take their inner product. But I'm curious if there's a way that doesn't involve the column or row-wise sum.
    – Jaidev Deshpande
    Jul 18 at 15:14












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I'm thinking of an operation which is almost similar to the inner product of two matrices, except the elementwise product is replaced with a sum.



Suppose $A_m times n$ and $B_ntimes k$ are our two matrices, and the inner product would be:
$C$ such that $$ c_ij = sum_l=1^na_ilb_lj$$



Is there a way to do, in a vectorized manner,



$$ c_ij = sum_l=1^na_il + b_lj$$
?



Can this result be derived from other well-known matrix addition or product operations?







share|cite|improve this question











I'm thinking of an operation which is almost similar to the inner product of two matrices, except the elementwise product is replaced with a sum.



Suppose $A_m times n$ and $B_ntimes k$ are our two matrices, and the inner product would be:
$C$ such that $$ c_ij = sum_l=1^na_ilb_lj$$



Is there a way to do, in a vectorized manner,



$$ c_ij = sum_l=1^na_il + b_lj$$
?



Can this result be derived from other well-known matrix addition or product operations?









share|cite|improve this question










share|cite|improve this question




share|cite|improve this question









asked Jul 18 at 14:29









Jaidev Deshpande

1033




1033




closed as off-topic by Alex Francisco, John Ma, amWhy, Xander Henderson, José Carlos Santos Jul 19 at 22:59


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Alex Francisco, amWhy, Xander Henderson
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by Alex Francisco, John Ma, amWhy, Xander Henderson, José Carlos Santos Jul 19 at 22:59


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Alex Francisco, amWhy, Xander Henderson
If this question can be reworded to fit the rules in the help center, please edit the question.







  • 1




    Welcome to MSE. Please read this text about how to ask a good question.
    – José Carlos Santos
    Jul 18 at 14:34










  • For what it's worth - I can sum one matrix row-wise and the other column wise, and then take their inner product. But I'm curious if there's a way that doesn't involve the column or row-wise sum.
    – Jaidev Deshpande
    Jul 18 at 15:14












  • 1




    Welcome to MSE. Please read this text about how to ask a good question.
    – José Carlos Santos
    Jul 18 at 14:34










  • For what it's worth - I can sum one matrix row-wise and the other column wise, and then take their inner product. But I'm curious if there's a way that doesn't involve the column or row-wise sum.
    – Jaidev Deshpande
    Jul 18 at 15:14







1




1




Welcome to MSE. Please read this text about how to ask a good question.
– José Carlos Santos
Jul 18 at 14:34




Welcome to MSE. Please read this text about how to ask a good question.
– José Carlos Santos
Jul 18 at 14:34












For what it's worth - I can sum one matrix row-wise and the other column wise, and then take their inner product. But I'm curious if there's a way that doesn't involve the column or row-wise sum.
– Jaidev Deshpande
Jul 18 at 15:14




For what it's worth - I can sum one matrix row-wise and the other column wise, and then take their inner product. But I'm curious if there's a way that doesn't involve the column or row-wise sum.
– Jaidev Deshpande
Jul 18 at 15:14










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










You could write $C = Ax_nx_k^T + x_mx_n^TB$, where $x_n$ denotes the column vector of length $n$ with $x = (1,1,dots,1)^T$.






share|cite|improve this answer























  • I'm not sure I'm getting this right. That still maintains the size of A and B, so the RHS is not a valid matrix sum. Am I missing something?
    – Jaidev Deshpande
    Jul 18 at 15:10






  • 1




    @JaidevDeshpande see my latest edit
    – Omnomnomnom
    Jul 18 at 15:18










  • Thanks! That works.
    – Jaidev Deshpande
    Jul 18 at 15:23

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










You could write $C = Ax_nx_k^T + x_mx_n^TB$, where $x_n$ denotes the column vector of length $n$ with $x = (1,1,dots,1)^T$.






share|cite|improve this answer























  • I'm not sure I'm getting this right. That still maintains the size of A and B, so the RHS is not a valid matrix sum. Am I missing something?
    – Jaidev Deshpande
    Jul 18 at 15:10






  • 1




    @JaidevDeshpande see my latest edit
    – Omnomnomnom
    Jul 18 at 15:18










  • Thanks! That works.
    – Jaidev Deshpande
    Jul 18 at 15:23














up vote
2
down vote



accepted










You could write $C = Ax_nx_k^T + x_mx_n^TB$, where $x_n$ denotes the column vector of length $n$ with $x = (1,1,dots,1)^T$.






share|cite|improve this answer























  • I'm not sure I'm getting this right. That still maintains the size of A and B, so the RHS is not a valid matrix sum. Am I missing something?
    – Jaidev Deshpande
    Jul 18 at 15:10






  • 1




    @JaidevDeshpande see my latest edit
    – Omnomnomnom
    Jul 18 at 15:18










  • Thanks! That works.
    – Jaidev Deshpande
    Jul 18 at 15:23












up vote
2
down vote



accepted







up vote
2
down vote



accepted






You could write $C = Ax_nx_k^T + x_mx_n^TB$, where $x_n$ denotes the column vector of length $n$ with $x = (1,1,dots,1)^T$.






share|cite|improve this answer















You could write $C = Ax_nx_k^T + x_mx_n^TB$, where $x_n$ denotes the column vector of length $n$ with $x = (1,1,dots,1)^T$.







share|cite|improve this answer















share|cite|improve this answer



share|cite|improve this answer








edited Jul 18 at 15:18


























answered Jul 18 at 14:55









Omnomnomnom

121k784170




121k784170











  • I'm not sure I'm getting this right. That still maintains the size of A and B, so the RHS is not a valid matrix sum. Am I missing something?
    – Jaidev Deshpande
    Jul 18 at 15:10






  • 1




    @JaidevDeshpande see my latest edit
    – Omnomnomnom
    Jul 18 at 15:18










  • Thanks! That works.
    – Jaidev Deshpande
    Jul 18 at 15:23
















  • I'm not sure I'm getting this right. That still maintains the size of A and B, so the RHS is not a valid matrix sum. Am I missing something?
    – Jaidev Deshpande
    Jul 18 at 15:10






  • 1




    @JaidevDeshpande see my latest edit
    – Omnomnomnom
    Jul 18 at 15:18










  • Thanks! That works.
    – Jaidev Deshpande
    Jul 18 at 15:23















I'm not sure I'm getting this right. That still maintains the size of A and B, so the RHS is not a valid matrix sum. Am I missing something?
– Jaidev Deshpande
Jul 18 at 15:10




I'm not sure I'm getting this right. That still maintains the size of A and B, so the RHS is not a valid matrix sum. Am I missing something?
– Jaidev Deshpande
Jul 18 at 15:10




1




1




@JaidevDeshpande see my latest edit
– Omnomnomnom
Jul 18 at 15:18




@JaidevDeshpande see my latest edit
– Omnomnomnom
Jul 18 at 15:18












Thanks! That works.
– Jaidev Deshpande
Jul 18 at 15:23




Thanks! That works.
– Jaidev Deshpande
Jul 18 at 15:23


Comments

Popular posts from this blog

What is the equation of a 3D cone with generalised tilt?

Relationship between determinant of matrix and determinant of adjoint?

Color the edges and diagonals of a regular polygon