forked from ebattenberg/nmf-cuda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix_export.m
More file actions
43 lines (24 loc) · 707 Bytes
/
matrix_export.m
File metadata and controls
43 lines (24 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
%% write test matrices to binary files
% values are store in column-major order
% nmf: X = W*H
% target X matrix
X = [1 2 3; 4 5 6; 7 8 9];
% initial W matrix
W = [1 2; 3 4; 5 6; 7 8];
% initial H matrix
H = [1 2 3; 4 5 6];
fid = fopen([path 'X.bin'],'w');
fwrite(fid,size(X),'int');
count = fwrite(fid,X(:),'float');
fprintf('wrote file with %u elements\n',count)
fclose(fid);
fid = fopen([path 'W.bin'],'w');
fwrite(fid,size(W),'int');
count = fwrite(fid,W(:),'float');
fprintf('wrote file with %u elements\n',count)
fclose(fid);
fid = fopen([path 'H.bin'],'w');
fwrite(fid,size(H),'int');
count = fwrite(fid,H(:),'float');
fprintf('wrote file with %u elements\n',count)
fclose(fid);