libflame revision_anchor
Functions
FLA_Bsvd_find_submatrix.c File Reference

(r)

Functions

FLA_Error FLA_Bsvd_find_submatrix_ops (int mn_A, int ij_begin, float *buff_d, int inc_d, float *buff_e, int inc_e, int *ijTL, int *ijBR)
 
FLA_Error FLA_Bsvd_find_submatrix_opd (int mn_A, int ij_begin, double *buff_d, int inc_d, double *buff_e, int inc_e, int *ijTL, int *ijBR)
 

Function Documentation

◆ FLA_Bsvd_find_submatrix_opd()

FLA_Error FLA_Bsvd_find_submatrix_opd ( int  mn_A,
int  ij_begin,
double buff_d,
int  inc_d,
double buff_e,
int  inc_e,
int ijTL,
int ijBR 
)
79{
80 double rzero = bl1_d0();
81 int ij_tl;
82 int ij_br;
83
84 // Search for the first non-zero superdiagonal element starting at
85 // the index specified by ij_begin.
86 for ( ij_tl = ij_begin; ij_tl < mn_A - 1; ++ij_tl )
87 {
88 double* e1 = buff_e + (ij_tl )*inc_e;
89
90 // If we find a non-zero element, record it and break out of this
91 // loop.
92 if ( *e1 != rzero )
93 {
94#ifdef PRINTF
95 printf( "FLA_Bsvd_find_submatrix_opd: found non-zero superdiagonal element\n" );
96 printf( " e[%3d] = %22.19e\n", ij_tl, *e1 );
97#endif
98 *ijTL = ij_tl;
99 break;
100 }
101 }
102
103 // If ij_tl was incremented all the way up to mn_A - 1, then we didn't
104 // find any non-zeros.
105 if ( ij_tl == mn_A - 1 )
106 {
107#ifdef PRINTF
108 printf( "FLA_Bsvd_find_submatrix_opd: no submatrices found.\n" );
109#endif
110 return FLA_FAILURE;
111 }
112
113 // If we've gotten this far, then a non-zero superdiagonal element was
114 // found. Now we must walk the remaining portion of the superdiagonal
115 // to find the first zero element, or if one is not found, we simply
116 // use the last element of the superdiagonal.
117 for ( ij_br = ij_tl; ij_br < mn_A - 1; ++ij_br )
118 {
119 double* e1 = buff_e + (ij_br )*inc_e;
120
121 // If we find a zero element, record it and break out of this
122 // loop.
123 if ( *e1 == rzero )
124 {
125#ifdef PRINTF
126 printf( "FLA_Bsvd_find_submatrix_opd: found zero superdiagonal element\n" );
127 printf( " e[%3d] = %22.19e\n", ij_br, *e1 );
128#endif
129 break;
130 }
131 }
132
133 // If a zero element was found, then ij_br should hold the index of
134 // that element. If a zero element was not found, then ij_br should
135 // hold mn_A - 1. Either way, we save the value and return success.
136 *ijBR = ij_br;
137
138 return FLA_SUCCESS;
139}
int i
Definition bl1_axmyv2.c:145
double bl1_d0(void)
Definition bl1_constants.c:118

References bl1_d0(), and i.

Referenced by FLA_Bsvd_ext_opd_var1(), FLA_Bsvd_ext_opz_var1(), FLA_Bsvd_v_opd_var1(), FLA_Bsvd_v_opd_var2(), FLA_Bsvd_v_opz_var1(), and FLA_Bsvd_v_opz_var2().

◆ FLA_Bsvd_find_submatrix_ops()

FLA_Error FLA_Bsvd_find_submatrix_ops ( int  mn_A,
int  ij_begin,
float buff_d,
int  inc_d,
float buff_e,
int  inc_e,
int ijTL,
int ijBR 
)
20{
21 float rzero = bl1_s0();
22 int ij_tl;
23 int ij_br;
24
25 // Search for the first non-zero superdiagonal element starting at
26 // the index specified by ij_begin.
27 for ( ij_tl = ij_begin; ij_tl < mn_A - 1; ++ij_tl )
28 {
29 float* e1 = buff_e + (ij_tl )*inc_e;
30
31 // If we find a non-zero element, record it and break out of this
32 // loop.
33 if ( *e1 != rzero )
34 {
35 *ijTL = ij_tl;
36 break;
37 }
38 }
39
40 // If ij_tl was incremented all the way up to mn_A - 1, then we didn't
41 // find any non-zeros.
42 if ( ij_tl == mn_A - 1 )
43 {
44 return FLA_FAILURE;
45 }
46
47 // If we've gotten this far, then a non-zero superdiagonal element was
48 // found. Now we must walk the remaining portion of the superdiagonal
49 // to find the first zero element, or if one is not found, we simply
50 // use the last element of the superdiagonal.
51 for ( ij_br = ij_tl; ij_br < mn_A - 1; ++ij_br )
52 {
53 float* e1 = buff_e + (ij_br )*inc_e;
54
55 // If we find a zero element, record it and break out of this
56 // loop.
57 if ( *e1 == rzero )
58 {
59 break;
60 }
61 }
62
63 // If a zero element was found, then ij_br should hold the index of
64 // that element. If a zero element was not found, then ij_br should
65 // hold mn_A - 1. Either way, we save the value and return success.
66 *ijBR = ij_br;
67
68 return FLA_SUCCESS;
69}
float bl1_s0(void)
Definition bl1_constants.c:111

References bl1_s0(), and i.

Referenced by FLA_Bsvd_ext_opc_var1(), FLA_Bsvd_ext_ops_var1(), FLA_Bsvd_v_opc_var1(), and FLA_Bsvd_v_ops_var1().