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

function A=fixmat(B,diagval)

%{
-------------------------------------------------------------
	This function sets all diagonal entries of B to 'diagval'
	without changing the number of nonzero entries in the
	corresponding columns of the matrix.

	A = fixmat(B, diagval)

	inputs:
	B 			the original matrix (sparse matrix)
	diagval		the value for the diagonal entries

	outputs:
	A  			the modified resulting matrix (sparse matrix)

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


n = size(B,1);
A=full(B);

for j=1:n,
	if (A(j,j) == 0),
		for i=1:n,
			if (A(i,j) != 0),
				A(i,j) = 0;
				break;
			end;
		end;
	end;
	A(j,j)=diagval;
end;

A=sparse(A);

end