File: print_gvec.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 (51 lines) | stat: -rw-r--r-- 1,349 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
% ********************************************************************
% Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
% ********************************************************************

function isok = print_gvec( filename, A )
%
%  isok = print_gvec(filename, A)
%
%  This function prints into file the contents of full vector A.
%  Inputs:
%  filename    The name of the generated file
%  A           The full vector (column or row) to be printed
%
%  Outputs:
%  isok        This will be 0 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)

[fid,msg] = fopen(filename,'w');
isok_fid = (fid >= 0);
if (~isok_fid),
  error(sprintf('print_vec:fopen %s returns %s', ...
                           filename,   msg ));
  return;
end;

istat_rewind = frewind(fid);

nitems = prod(size(A));

is_integer = all( floor(A(:)) == A(:) );
if (is_integer),
  numbytes = fprintf(fid, ' %d', reshape(A(:),1,nitems) );
else
  numbytes = fprintf(fid, ' %25.20e', reshape(A(:),1,nitems) );
end;

numbytes = numbytes + fprintf(fid,'\n');
istat_close = fclose( fid );

isok = (istat_rewind >= 0) & (numbytes >= 0) & (istat_close >= 0);





end