# Matrix multiplication in two files

**URL:** <https://root-forum.cern.ch/t/matrix-multiplication-in-two-files/51730>\
**Category:** Newbie\
**Created:** [September 27, 2022, 4:24pm UTC](https://root-forum.cern.ch/t/matrix-multiplication-in-two-files/51730 "2022-09-27T16:24:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![RENATO\_QUAGLIANI](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/renato_quagliani/32/19496_2.png) [@RENATO\_QUAGLIANI](https://root-forum.cern.ch/u/RENATO_QUAGLIANI)\
**Post date:** [September 27, 2022, 6:04pm UTC](https://root-forum.cern.ch/t/matrix-multiplication-in-two-files/51730/2 "2022-09-27T18:04:34Z")

</div>

I might be wrong , but since TMatrix inherits from TObject, you can write it to a TFile and retrieve it back.  
Have you tried to write the object to a TFile and check you can get it back when reading the file?

```auto
import ROOT as r
fOut = r.TFile("test_save.root","RECREATE")
rows = 5
cols = 6
matrix = r.TMatrixD(5, 6)
matrix[0][1] = 1
matrix.Print()
fOut.WriteObject( matrix,"mymatrix")
fOut.Close()
fIn = r.TFile("test_save.root")
matrixRead = fIn.Get("mymatrix")
matrixRead.Print()
fIn.Close()

```

Tried on a notebook and there is no problem to write a matrix to a file and read it back

---

_[View the full topic](https://root-forum.cern.ch/t/matrix-multiplication-in-two-files/51730)._
