46 #ifdef TEUCHOS_DEBUG // Debug only!
47 bool DenseLinAlgPack::PermVecMat_print =
false;
55 inline void i_assert_perm_size(
size_t size1,
size_t size2)
57 #ifdef LINALGPACK_CHECK_RHS_SIZES
59 throw std::length_error(
"The size of the permutation vector is not correct");
67 throw std::length_error(
"DenseLinAlgPack::identity_perm(): perm must be sized");
69 for(
size_type i = 1; i <= perm->size(); ++i)
74 inv_perm->resize(perm.size());
75 for(
size_type i = 1; i <= perm.size(); ++i)
76 (*inv_perm)(perm(i)) = i;
81 i_assert_perm_size(vs->
dim(),perm.size());
84 v_itr_end = tmp_v.end();
87 for(; v_itr != v_itr_end; ++v_itr, ++perm_itr)
88 *v_itr = (*vs)(*perm_itr);
96 i_assert_perm_size(x.
dim(),perm.size());
97 i_assert_perm_size(y->
dim(),perm.size());
100 perm_itr = perm.
begin();
104 while(y_itr != y_end)
105 *y_itr++ = x(*perm_itr++);
110 i_assert_perm_size(y.
dim(),perm.size());
111 i_assert_perm_size(x->
dim(),perm.size());
113 if( PermVecMat_print ) {
115 <<
"enter inv_perm_ele(y,perm,x):\n"
118 <<
"perm =\n" << perm
126 perm_itr = perm.
begin();
127 while(y_itr != y_end)
128 (*x)(*perm_itr++) = *y_itr++;
130 if( PermVecMat_print ) {
132 <<
"inv_perm_ele(y,perm,x):\n"
135 <<
"exit inv_perm_ele(...) ...\n";
142 i_assert_perm_size(gms->
rows(),row_perm.size());
146 for(i = 1; i <=
rows; ++i)
147 tmp_gm.row(i) = gms->
row(row_perm(i));
154 i_assert_perm_size(gms->
cols(),col_perm.size());
158 for(i = 1; i <=
cols; ++i)
159 tmp_gm.col(i) = gms->
col(col_perm(i));
167 i_assert_perm_size(gms->
rows(),row_perm.size());
168 i_assert_perm_size(gms->
cols(),col_perm.size());
172 for(i = 1; i <=
rows; ++i)
173 tmp_gm.row(i) = gms->
row(row_perm(i));
175 for(i = 1; i <=
cols; ++i)
176 gms->
col(i) = tmp_gm.col(col_perm(i));
const value_type * const_iterator
Teuchos::Ordinal size_type
Typedef for the size type of elements that are used by the library.
size_type dim() const
Returns the number of elements of the VectorSliceTmpl.
DenseLinAlgPack::size_type size_type
void perm_rows(const IVector &row_perm, DMatrixSlice *gms)
Permute a GenMatrixSlices rows.
size_type cols() const
Return the number of columns.
void inv_perm(const IVector &perm, IVector *inv_perm)
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
void perm_cols(const IVector &col_perm, DMatrixSlice *gms)
Permute a GenMatrixSlices columns.
C++ Standard Library compatable iterator class for accesing nonunit stride arrays of data...
void perm_rows_cols(const IVector &row_perm, const IVector &col_perm, DMatrixSlice *gms)
Permute a GenMatrixSlices rows and columns.
iterator begin()
STL iterator.
void identity_perm(IVector *perm)
size_type rows() const
Return the number of rows.
void inv_perm_ele(const DVectorSlice &y, const IVector &perm, DVectorSlice *x)
Perform x = P'*y.
DVectorSlice col(size_type j)
Return DVectorSlice object representing the jth column (1-based; 1,2,..,#this->cols()#, or throw std::out_of_range)
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
void perm_ele(const IVector &perm, DVectorSlice *vs)
Permute a DVectorSlice in place.
DVectorSlice row(size_type i)
Return DVectorSlice object representing the ith row (1-based; 1,2,..,#this->rows()#, or throw std::out_of_range)