Matrix optimization

I have 2 matrices, an A(77), a target matrix(307), the target matrix is known.

I create a matrix A (7*7) which allows me to find the target matrix in the following way:

1/ I take the last column of A, this column becomes the first row of my new matrix

2/ I take the squared of matrix A , the last column of A^2, this column becomes the second row of my new matrix

3/I take the cube of matrix A , the last column of A^3, this column becomes the third row of my
new matrix

So on and on, in other words

The first row of the target matrix has to be the last column of A

The 2nd row of the target matrix has to be the last column of A^2

The 3rd row of the target matrix has to be the last column of A^3

So up to 30.

In other words I must find matrix A which after the succession of operations described above gives the target matrix. How would you proceed?

Hi kkenmogne,

From a bit of Googling I found that the expm package has a matrix exponentiation function. With that in mind I think this does what you were asking for:


matrix_A <- matrix(1:49, nrow = 7, ncol = 7) # or whatever 7x7 matrix you want
list_of_matrix_exponents <- map(1:30, ~matrix_A %^% .)
list_of_last_columns <- map(list_of_matrix_exponents, ~.[, 7])
target_matrix <- t(matrix(unlist(list_of_last_columns), nrow = 7, ncol = 30))

Let me know if I misunderstood. I'd be interested to know about the application you're using this for; when I was reading this I originally thought you meant something to generate Vandermonde matrices, but that's not what this is.

Hope that helped,

The thing is that im trying to find A , to find the matrix A that will give me the target matrix (that i already know). So the goal is to find A not the target matrix

OK so the inverse process to the code I gave before. Do you have an algorithm in mind that you need to get an implementation for in R, or are you looking for an algorithm to find A? If it's the latter then that's more of a maths question and so this probably isn't the best place. Cheers,

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.