42 #include "AbstractLinAlgPack_rank_2_chol_update.hpp"
43 #include "DenseLinAlgPack_DMatrixAsTriSym.hpp"
44 #include "DenseLinAlgPack_DVectorClass.hpp"
45 #include "DenseLinAlgPack_DVectorOp.hpp"
46 #include "DenseLinAlgPack_AssertOp.hpp"
47 #include "DenseLinAlgPack_BLAS_Cpp.hpp"
49 void AbstractLinAlgPack::rank_2_chol_update(
52 ,
const DVectorSlice &v
54 ,DMatrixSliceTriEle *R
60 using BLAS_Cpp::upper;
61 using BLAS_Cpp::lower;
63 using DenseLinAlgPack::row;
64 using DenseLinAlgPack::col;
65 using DenseLinAlgPack::rot;
137 DenseLinAlgPack::Mp_M_assert_sizes( n, n,
no_trans, u->dim(), v.dim(),
no_trans );
140 opR_uplo = ( (R->uplo()==upper && R_trans==
no_trans) || (R->uplo()==lower && R_trans==
trans)
145 if( opR_uplo == lower ) {
162 for( ; k != last_i+di; k+=di )
163 if( (*u)(k) != 0.0 )
break;
164 if( k == last_i+di )
return;
169 {
for(
size_type i = k; i != last_i; i+=di ) {
173 rotg( &(*u)(i+di), &(*u)(i), &c, &s );
177 opR_row_idi = row(R->gms(),R_trans,i+di),
178 opR_row_i = row(R->gms(),R_trans,i);
179 if( opR_uplo == lower ) {
183 rot( c, s, &opR_row_idi(1 ,i ), &opR_row_i(1,i) );
184 rot( c, s, &opR_row_idi(i+1,i+1), &(*w)(i+wo,i+wo) );
190 rot( c, s, &opR_row_idi(i-1,i-1), &(*w)(i+wo,i+wo) );
191 rot( c, s, &opR_row_idi(i ,n ), &opR_row_i(i,n) );
197 Vp_StV( &row(R->gms(),R_trans,last_i), a * (*u)(last_i), v );
203 {
for(
size_type i = last_i; i != k; i-=di ) {
205 opR_row_i = row(R->gms(),R_trans,i),
206 opR_row_idi = row(R->gms(),R_trans,i-di);
208 &w_idiwo = (*w)(i-di+wo);
211 value_type &R_i_i = opR_row_i(i);
213 rotg( &R_i_i, &w_idiwo, &c, &s );
215 value_type scale = +1.0;
223 if( opR_uplo == lower ) {
227 rot( scale*c, scale*s, &opR_row_i(1,i-1), &opR_row_idi(1,i-1) );
233 rot( scale*c, scale*s, &opR_row_i(i+1,n), &opR_row_idi(i+1,n) );
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs