Reading and Writing Objects
Writing objects to files
writeToFile(string filename, T const& obj)
Opens a file with the name
filename
and writes the objectobj
to it. The type T of the object is deduced automatically.This function is defined in the file
itensor/util/readwrite.h
.Click to Show Example
Reading objects from files
readFromFile<T>(string filename) -> T
Opens a file with the name
filename
, read an object of typeT
, and return that object.This function is defined in the file
itensor/util/readwrite.h
.Click to Show ExamplereadFromFile(string filename, T & obj)
Opens a file with the name
filename
and read an object of typeT
to the variableobj
. The typeT
is automatically deduced.This function is defined in the file
itensor/util/readwrite.h
.Click to Show ExamplereadFromFile<T>(string filename, InitArgs&&... iargs) -> T
Opens a file with the name
filename
, read an object of typeT
, and return that object.This version of the
readFromFile
function takes an arbitrary number of additional arguments which are passed to the constructor of the type T before reading the object from the file. This can be useful for cases where you want to construct the class before its .read method is called. A key example is the MPS or IQMPS class which can optionally be constructed with a SiteSet before calling its .read method to read in its tensors.This function is defined in the file
itensor/util/readwrite.h
.Click to Show Example

