0
votes

For a specific problem, I need to design the resizing of a matrix process using multiplication of matrices alone. Given a matrix of A of dimensions (a*b,1) where a and b are integers, I need to find a way to resize A to dimensions (a,b) like this:

M*A*N = resize(A,a,b)

where dim(M) = (a,a*b) and dim(N) = (1,b). It doesn't have to be two matrices but I don't think it is possible any other way.

1
You mean you can't use reshape? That's a strange limitation. Why not?shoelzer
shoelzer, it's an optimization problem. So I need to somehow linearize this. So I need to represent stuff as vectors and matrices and do some manipulation.sprajagopal
Sounds like an XY problem to me...Could you post what and how you're trying to optimize?Rody Oldenhuis
@RodyOldenhuis Ha ha...:). No, I don't think there is a better solution to the actual problem.sprajagopal
@SPRajagopal: Surely you can remove all the irrelevant details and write a minimal working example? We can only really help and tell if you've simply overlooked a programming technique if you post what you try to do (without the specifics)...Rody Oldenhuis

1 Answers

3
votes

If you can't use reshape or vec2mat, you need to do your manipulation for each element of A separately.

There is no such M and N that you are searching for.

Suppose:

resh_A = M*A*N;

Let's study one row of this equation. Assume one row of M*A :

temp_i = M(i, :) * A;

Since M(i, :) is 1 x a*b and A is a*b x 1; temp_i whould be a 1 x 1 matrix.

Now temp_i * N should result in the ith row of your result (or resh_A). Thus resh_A will look like:

(note N is 1 x b)

   temp_1 * N % row1
   temp_2 * N % row2
   temp_3 * N % row3
   ...

which is not a general matrix (it's a matrix with rank 1).