Simple Eigenvalue Idea

I have a vector Nx1 with numbers that I want to be the eigenvalues of a matrix X which I am attempting to construct. Essentially, I want to take my Nx1 matrix and list the ith entry of this vector on the ith diagonal of this matrix. I have tried various matrix multiplications, but nothing seems to be working. Can someone help me out?

Cheers.

Note that I am attempting to do this in R.

Upvotes: 0

Views: 57

Answers (1)

amarchin
amarchin

Reputation: 2114

This chunk of code works for vectors

eigenvalues <- 1:10
matrix <- diag(eigenvalues)

This works for a matrix

eigenvalues <- matrix(1:10, ncol = 1)
matrix <- diag(eigenvalues[, 1])

Upvotes: 1

Related Questions