I want to generate some matrices of order 3 with eigenvalues `1`

,`2`

, `-2`

.

```
mat[lis_List] :=
Module[{k},
While[Eigenvalues[k = RandomInteger[{1, 10}, {3, 3}]] != lis]; k]
Eigenvalues[#] & /@ Table[mat[{1, 2, -2}], 3]
```

But the above code has been running, how can I do to quickly generate a random matrix that meets the conditions?

```
Transpose[
EulerMatrix[{k = (2 π)/RandomInteger[{1, 5}], 0, 0}]] . {{1, 0,
0}, {0, 2, 0}, {0, 0, -1}} . EulerMatrix[{k, 0, 0}]
Eigenvalues[%]
```

I hope there are more and faster ways to accomplish this task.

**Note:** the elements of the obtained matrix should be all integers or rational numbers. If the rational matrix cannot be obtained, all elements of the matrix can be considered to use real numbers.