File: print_x.m

package info (click to toggle)
rocsolver 6.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 17,876 kB
  • sloc: cpp: 151,850; python: 2,275; sh: 875; objc: 642; ansic: 402; makefile: 71; xml: 26
file content (72 lines) | stat: -rw-r--r-- 1,679 bytes parent folder | download
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
% ********************************************************************
% Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
% ********************************************************************

function isok = print_x( matname, X )

%{
-----------------------------------------------------------
  This function prints into file the contents of full matrix M.

  isok = print_vec(matname, X)

  Inputs:
  matname     The name of the generated file
  X           The full matrix to be printed

  Outputs:
  isok        This will be -1 if any of the file operations failed

  The resulting file is created in the working directory.

  (This script is for internal use only. It is not part of
  rocSOLVER library interface and could change or be removed
  without any notice)
-----------------------------------------------------------
%}


[vec,msg] = fopen( matname , 'w');
isok = (vec >= 0);
if (!isok),
  error( sprintf('print_x: fopen returns %s', msg));
  return;
end;

m = size(X,1);
n = size(X,2);
for i=1:m,
  for j=1:n-1,
    istat = fprintf(vec,'%1.17g ',X(i,j));
    isok = (istat >= 0);
    if (!isok),
      error(sprintf('print_x: fprintf returns istat=%d',istat));
      return;
    end;
  end;

  istat = fprintf(vec,'%1.17g',X(i,n));
  isok = (istat >= 0);
  if (!isok),
    error(sprintf('print_x: fprintf returns istat=%d',istat));
    return;
  end;

  istat = fprintf(vec,'\n');
  isok = (istat >= 0);
  if (!isok),
    error(sprintf('print_x: fprintf returns istat=%d',istat));
    return;
  end;
end;

istat = fclose(vec);
isok = (istat == 0);
if (!isok),
  error(sprintf('print_x: fclose returns istat=%d',istat));
  return;
end;


end