# Reuse Eigen object

**URL:** https://discourse.julialang.org/t/reuse-eigen-object/71494
**Category:** General Usage
**Tags:** linearalgebra, memory-allocation, eigenvalues
**Created:** [November 15, 2021, 1:29pm UTC](https://discourse.julialang.org/t/reuse-eigen-object/71494 "2021-11-15T13:29:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Joris\_Pinkse](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joris_pinkse/32/216398_2.png) [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)
#### Post date: [November 15, 2021, 1:29pm UTC](https://discourse.julialang.org/t/reuse-eigen-object/71494/1 "2021-11-15T13:29:41Z")

</div>

If I do

```julia
using LinearAlgebra
A = randn(100,100)
B = A'*A
C = eigen(B)

```

then how could I avoid allocating more memory by the next call to `eigen` with a 100 by 100 symmetric matrix? In other words, how could I reuse C?

(I can see that Eigen is itself immutable, but its elements include a vector and matrix and I should be able to overwrite those.)

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [November 15, 2021, 2:34pm UTC](https://discourse.julialang.org/t/reuse-eigen-object/71494/2 "2021-11-15T14:34:17Z")

</div>

Check the docs for `eigen!`

---

<div class="post-metadata">

### Author: ![Joris\_Pinkse](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joris_pinkse/32/216398_2.png) [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)
#### Post date: [November 15, 2021, 2:35pm UTC](https://discourse.julialang.org/t/reuse-eigen-object/71494/3 "2021-11-15T14:35:58Z")

</div>

saw that.

---

<div class="post-metadata">

### Author: ![Joris\_Pinkse](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joris_pinkse/32/216398_2.png) [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)
#### Post date: [November 15, 2021, 5:43pm UTC](https://discourse.julialang.org/t/reuse-eigen-object/71494/4 "2021-11-15T17:43:16Z")

</div>

Ok, what I missed is that eigen!(A) does not change the type of A, so I can do C = eigen!(A), which still uses about two thirds of the memory of C = eigen(A). I can make that work.
