55 ,GenPermMatrixSlice *Q_R
58 ,GenPermMatrixSlice *Q_X
61 namespace GPMSIP = AbstractLinAlgPack::GenPermMatrixSliceIteratorPack;
69 typedef std::vector<long int> l_x_XR_t;
71 std::fill( l_x_XR.begin(), l_x_XR.end(), 0 );
73 bool i_x_fixed_is_sorted =
true;
77 for(
long int lX = 1; lX <= n_X; ++lX, ++i_x_X ) {
78 if( *i_x_X < 1 || *i_x_X > n ) {
79 std::ostringstream omsg;
81 <<
"initialize_Q_R_Q_X(...) : Error, "
82 <<
"i_x_fixed[" << (lX-1) <<
"] = "
83 << (*i_x_X) <<
" is out of bounds";
84 throw std::invalid_argument( omsg.str() );
86 const long int l = l_x_XR[*i_x_X-1];
88 std::ostringstream omsg;
90 <<
"initialize_Q_R_Q_X(...) : Error, "
91 <<
"Duplicate entries for i_x_fixed[" << (lX-1) <<
"] = "
92 << (*i_x_X) <<
" == i_x_fixed[" << (-l-1) <<
"]";
93 throw std::invalid_argument( omsg.str() );
95 l_x_XR[*i_x_X-1] = -lX;
96 if( *i_x_X < last_set )
97 i_x_fixed_is_sorted =
false;
104 for(
size_type lX = 1; lX <= n_X; ++lX, ++i_x_X ) {
105 l_x_XR[*i_x_X-1] = -lX;
106 if( *i_x_X < last_set )
107 i_x_fixed_is_sorted =
false;
112 bool i_x_free_is_sorted =
true;
113 if( i_x_free == NULL ) {
115 *l_x_XR_itr = &l_x_XR[0];
117 for(
size_type i = 1; i <= n; ++i, ++l_x_XR_itr ) {
118 if(*l_x_XR_itr == 0) {
129 for(
size_type lR = 1; lR <= n_R; ++lR, ++i_x_R ) {
130 if( *i_x_R < 1 || *i_x_R > n ) {
131 std::ostringstream omsg;
133 <<
"initialize_Q_R_Q_X(...) : Error, "
134 <<
"i_x_free[" << (lR-1) <<
"] = "
135 << (*i_x_R) <<
" is out of bounds";
136 throw std::invalid_argument( omsg.str() );
138 const long int l = l_x_XR[*i_x_R-1];
140 std::ostringstream omsg;
142 <<
"initialize_Q_R_Q_X(...) : Error, "
143 <<
"Duplicate entries for i_x_free[" << (lR-1) <<
"] = "
144 << (*i_x_R) <<
" == "
145 << (l < 0 ?
"i_x_fixed[" :
"i_x_free[")
146 << (l < 0 ? -l : l) <<
"]";
147 throw std::invalid_argument( omsg.str() );
149 l_x_XR[*i_x_R-1] = lR;
150 if( *i_x_R < last_set )
151 i_x_free_is_sorted =
false;
158 for(
size_type lR = 1; lR <= n_R; ++lR, ++i_x_R ) {
159 l_x_XR[*i_x_R-1] = lR;
160 if( *i_x_R < last_set )
161 i_x_free_is_sorted =
false;
169 if( i_x_free_is_sorted && Q_R_row_i == NULL && l_x_XR[n_R-1] == n_R ) {
173 Q_R->initialize(n,n_R,GenPermMatrixSlice::IDENTITY_MATRIX);
176 *l_x_X = &l_x_XR[n_R-1] + 1;
178 *row_i_itr = Q_X_row_i,
179 *col_j_itr = Q_X_col_j;
180 for(
size_type iX = n_R+1; iX <= n; ++iX, ++l_x_X, ++row_i_itr, ++col_j_itr ) {
182 *col_j_itr = -(*l_x_X);
187 ,Q_X_row_i,Q_X_col_j,test_setup);
193 if( n_X > 0 && Q_R_row_i == NULL )
194 throw std::invalid_argument(
195 "initialize_Q_R_Q_X(...) : Error, "
196 "Q_R_row_i != NULL since Q_R != [ I; 0 ]" );
200 *Q_R_row_i_itr = Q_R_row_i,
201 *Q_R_col_j_itr = Q_R_col_j,
202 *Q_X_row_i_itr = Q_X_row_i,
203 *Q_X_col_j_itr = Q_X_col_j;
204 for(
size_type i = 1; i <= n; ++i, ++l_x ) {
205 const long int l = *l_x;
208 *Q_R_row_i_itr++ = i;
209 *Q_R_col_j_itr++ = l;
212 *Q_X_row_i_itr++ = i;
213 *Q_X_col_j_itr++ = -l;
220 ,Q_R_row_i,Q_R_col_j,test_setup);
223 ,Q_X_row_i,Q_X_col_j,test_setup);
AbstractLinAlgPack::size_type size_type
void initialize_Q_R_Q_X(size_type n_R, size_type n_X, const size_type i_x_free[], const size_type i_x_fixed[], bool test_setup, size_type Q_R_row_i[], size_type Q_R_col_j[], GenPermMatrixSlice *Q_R, size_type Q_X_row_i[], size_type Q_X_col_j[], GenPermMatrixSlice *Q_X)
Initialize GenPermMatrixSlice mapping matrices for Q_R and Q_X.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)