File: print_as_csr.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 (26 lines) | stat: -rw-r--r-- 817 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
% ********************************************************************
% Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
% ********************************************************************
`
function isok = print_as_csr( A, name )
%
% isok = print_as_csr( A, name )
%
% print sparse matrix A as
% Compressed Sparse Row (CSR) sparse matrix storage format
% with the pointers, column indices and numerical values split into 3 files
%
% For example,
% isok = print_as_csr(T,'T')
%
% will generate files 'ptrT', 'indT', 'valT'
%
% isok will be 0 (false) if there are errors

[Ap,Ai,Ax] = sparse2csr(A);
isok_Ap = print_gvec( sprintf('ptr%s',name), Ap );
isok_Ai = print_gvec( sprintf('ind%s',name), Ai );
isok_Ax = print_gvec( sprintf('val%s',name), Ax );
isok = isok_Ap & isok_Ai & isok_Ax;

end