0
Completed

use save and load

Hector 9 years ago updated by Pavel Holoborodko 9 years ago 1

how to use the command save and load the data mp ?

more precisely as save sets of objects containing mp elements, then load them ?,

or such as saving array mp text and then load ?

+1
Completed

1. The usual commands save/load works with "mp" variables:

A = mp(rand(100));
B = A;

save('A.mat','A')
clear A;

load('A.mat','A');
norm(A-B,1)
ans =     
     0

Use them if you intend to load/save matrices on the same computer using the same version of MATLAB/toolbox.


2. If you want to transfer mp-matrices from one computer to another, it is better to convert it to text.

Toolbox provides two special commands for file I/O with preserving accuracy and cross-platforms compatibility:


mp.Digits(34);
A = mp(rand(25));

mp.write(A,'matrix.txt');  % Write mp-matrix to the text file
B = mp.read('matrix.txt'); % Read it back

norm(A-B,1) % check accuracy - difference should be 0
0

Linearize n-diminsional array before saving: mp.write(A(:),'matrix.txt')