-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathR1_Complexity.m
More file actions
63 lines (52 loc) · 2.86 KB
/
R1_Complexity.m
File metadata and controls
63 lines (52 loc) · 2.86 KB
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% @file R1_Complexity.m %
% @brief Complexity computation of the Rank 1 QR update %
% %
% I/O PARAMETERS: %
% @param[in] colStart The column no. starting from which, %
% the new columns were added %
% %
% @param[in] nRows Number of rows in the R matrix %
% @param[in] nNew Number of new columns added %
% @return COMPLEXITY structure with fields: %
% COMPS No. of comparisons %
% MULTS No. of multiplies %
% ADDS No. of additions %
% SQRT No. of square roots %
% %
% @author srijeshs %
% @date 11/12/2018 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function COMPLEXITY = R1_Complexity(colStart,nRows,nNew)
% Print interpretation of inputs
fprintf('\nExisting columns in the R matrix = %d\n',colStart-1);
% Initialization
COMPLEXITY.COMPS = 0; % No. of comparisions
COMPLEXITY.MULTS = 0; % No. of multiplies
COMPLEXITY.ADDS = 0; % No. of additions
COMPLEXITY.SQRT = 0; % No. of square roots
totalNewZeros = 0; % No. of new zeros we are going to introduce
% For each new column
for iCol = colStart:colStart+nNew-1
ZerosToAdd = nRows - iCol; % No. of zeros we need to introduce in this column
% For each new zero required in this column
for nZeros = 1:ZerosToAdd
% Givens Matrix generation start
COMPLEXITY.COMPS = COMPLEXITY.COMPS+1;
COMPLEXITY.MULTS = COMPLEXITY.MULTS+4;
COMPLEXITY.ADDS = COMPLEXITY.ADDS+1;
COMPLEXITY.SQRT = COMPLEXITY.SQRT+1;
% Givens Matrix generation end
% MAT_VECT_MULT 2x2 Givens * 2x1 Vectors start
nMULTS_MATVEC = (colStart + nNew - iCol) * 4;
nADDS_MATVEC = (colStart + nNew - iCol) * 2;
COMPLEXITY.MULTS = COMPLEXITY.MULTS + nMULTS_MATVEC;
COMPLEXITY.ADDS = COMPLEXITY.ADDS + nADDS_MATVEC;
% MAT_VECT_MULT 2x2 Givens * 2x1 Vectors end
totalNewZeros = totalNewZeros+1;
end % iCol
end % nZeros
% Print results
fprintf('A total of %d new columns were added\n%d new zero(s) introduced\n',nNew,totalNewZeros);
fprintf('New R''s dimensions = %dx%d',nRows,colStart+nNew-1);
end % function