# How to combine/aggregate multiple Gram matrices to yield a one matrix by doing some desired matrix manipulations?

2 views (last 30 days)
hello_world on 23 Oct 2018
Edited: hello_world on 23 Oct 2018
Let,
X = [1, 2, 3, 4;
5, 6, 7, 8;
9, 10, 11, 12;
13, 14, 15, 16;
17, 18, 19, 20;
21, 22, 23, 24];
% Class labels
Y = [a; a; b; b; c; c];
G = X'*X; % Size of G would be 6 x 6
Binary combinations of above classes (i.e., 3 choose 2 == 3) are {a, b}, {b, c}, {c, a}.
Matrices corresponding to above binary combinations would be:
X1 =
[1, 2, 3, 4;
5, 6, 7, 8;
9, 10, 11, 12;
12, 14, 15, 16];
X2 =
9, 10, 11, 12;
13, 14, 15, 16;
17, 18, 19, 20;
21; 22, 23, 24];
X3 =
[17, 18, 19, 20;
21, 22, 23, 24;
1, 2, 3, 4;
5, 6, 7, 8;];
Gram matrices for X1, X2, X3 would be
G1 = X1'*X1; % size 4 x 4
G2 = X2'*X2; % size 4 x 4
G3 = X3'*X3; % size 4 x 4
Now suppose there is some z = [0.1, 0.2, 0.3];
____________________________________________________________________________
Questions:
I will like to multiple each Gram matrices by the elements of z, i.e.,
0.1 * G1;
0.2 * G2;
0.3 * G2;
and then combine them to give a Gram matrix equivalent to Gram matrix G which is of size 6 x 6.
So in other words, is there any way to multiple elements of Gram matrix G by the elements z such that
• 0.1 multiplies only those entries of G which correspond to the entries of Gram matrix G1
• 0.2 multiplies only those entries of G which correspond to the entries of Gram matrix G2
• 0.3 multiples only those entries of G which correspond to the entries of Gram matrix G3
I see two approaches to solve this problem:
1. Combine/Aggregate 0.1 * G1, 0.2 * G2, 0.3 * G3 (each of which are of size 4 x 4) to yield an output matrix of size 6 x 6 equivalent to Gram matrix G.
2. Directly multiple 0.1, 0.2, 0.3 with those elements of G which are corresponding to Gram matrices G1, G2, G3 respectively.
The first approach seems a lot of computation as it requires to compute three Gram matrices separately. Besides, the main problem here is that I do not know how to combine/aggregate those Gram matrices to yield one of size 6 x 6 as if it were obtained by original data matrix G = X'*X;
The second approach will take less computation, but again I do not know how to obtain the desired result.
One final note: Here, I took z with only three elements [0.1, 0.2, 0.3] because there are three classes {a, b, c}. So as a general solution, z contains as many elements as class numbers.