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

function[A] = read_csr( file_ptrA, file_indA, file_valA, dir_in )
%
% [A] = read_csr( file_ptrA, file_indA, file_valA  [, dir_in] )
%
% read in matrix in Compressed Sparse Row (CSR) storage
% encoded in 3 files e.g.  'ptrA', 'indA', 'valA'
%
% returns  matlab sparse matrix
%

dir = './';
if (nargin >= 4),
  dir = dir_in;
end;

has_slash = (dir(numel(dir)) == '/');
if (~has_slash),
  dir = strcat(dir,'/');
end;

ptrA = read_vec(strcat(dir,file_ptrA) );
indA = read_vec(strcat(dir,file_indA));
valA = read_vec(strcat(dir,file_valA) );

A = csr2sparse( ptrA, indA, valA );

end