Yes, this is possible: use DumpSave
. Warning: not cross-architecture friendly. For your example:
In[18]:= A = RandomReal[{-10, 10}, {1000, 1000}];
(* for demonstration, save the same matrix A to the variable B for double checking *)
B = A;
(* Dump the variable definition, which includes the variable name, to the file *)
In[20]:= DumpSave[FileNameJoin[{$TemporaryDirectory, "a.mx"}], A];
(* Clear the variable A and it's contents from Mathematica's memory.
Now, the only remnants of A are in the file "a.mx" and in the copied variable B *)
In[21]:= Clear[A]
(* Import and define the variable A again *)
Get[FileNameJoin[{$TemporaryDirectory, "a.mx"}]]
(* Check that our important definition of A matches what we defined at the beginning *)
In[23]:= A == B
Out[23]= True
You can now use A
as if you never quit MMA or cleared the variable. So, you can try to calculate the inverse (Inverse[A]
) or any other legal MMA calculation.
See also the following questions: