#include <AbstractLinAlgPack_MatrixExtractSparseElements.hpp>
Inheritance diagram for AbstractLinAlgPack::MatrixExtractSparseElements:
Overridden from MatrixConvertToSparse | |
| index_type | num_nonzeros (EExtractRegion extract_region, EElementUniqueness element_uniqueness) const |
| | |
| void | coor_extract_nonzeros (EExtractRegion extract_region, EElementUniqueness element_uniqueness, const index_type len_Aval, value_type Aval[], const index_type len_Aij, index_type Arow[], index_type Acol[], const index_type row_offset, const index_type col_offset) const |
| | |
Public Member Functions | |
| virtual index_type | count_nonzeros (EElementUniqueness element_uniqueness, const index_type inv_row_perm[], const index_type inv_col_perm[], const Range1D &row_rng, const Range1D &col_rng, index_type dl, index_type du) const =0 |
| Returns the number of nonzeros in the banded submatrix of the permuted matrix. | |
| virtual void | coor_extract_nonzeros (EElementUniqueness element_uniqueness, const index_type inv_row_perm[], const index_type inv_col_perm[], const Range1D &row_rng, const Range1D &col_rng, index_type dl, index_type du, value_type alpha, const index_type len_Aval, value_type Aval[], const index_type len_Aij, index_type Arow[], index_type Acol[], const index_type row_offset=0, const index_type col_offset=0) const =0 |
| Extract elements in a coordinate data structure. | |
The formats supported are:
Coordiante:
Aval[k], Arow[k], Acol[k], k = 0..num_nonzeros(...)-1
Aval[k], Acol[k], k = 0..num_nonzeros(...)-1
Arow_start[j], j = 0..rows()-1
The idea is that given a matrix A, row and column permutations P and Q, a range of rows and columns (rl,ru) and (cl,cu) defining a square submatrix M and a range of lower and upper bands dl and du within the submatrix M, this interface is used to extract those nonzero elements.
In Matlab like terms we have:
let M = (P'*A*Q)(rl:ru,cl:cu)
This interface extracts nonzero elements from M within the banded region [dl,du] where d = 0 is the diagonal of M, d < 0 is below the diagonal and d > 0 is above the diagonal.
The following matrix is used in the documentation for the following extraction functions.
[ 1 6 9 ] 1
[ 4 10 ] 2
A = [ 5 ] 3
[ 2 7 11 ] 4
[ 3 8 12 ] 5
1 2 3 4
Note that above, A has:
A_nz == this->num_nonzeros(EXTRACT_FULL_MATRIX,ELEMENTS_FORCE_UNIQUE) == 12 A_up_nz = this->num_nonzeros(EXTRACT_UPPER_TRIANGULAR,ELEMENTS_FORCE_UNIQUE) == 6 A_lo_nz = this->num_nonzeros(EXTRACT_LOWER_TRIANGULAR,ELEMENTS_FORCE_UNIQUE) == 9
Definition at line 88 of file AbstractLinAlgPack_MatrixExtractSparseElements.hpp.
|
||||||||||||||||||||||||||||||||
|
Returns the number of nonzeros in the banded submatrix of the permuted matrix. Let B be the banded submatrix that is being specifed and let A be this full matrix object. Then the (dense) elemements of B are defined by:
/ 0 : for dl <= (j-i) <= du
B(i,j) = |
\ A(row_perm(i+rl-1),col_perm(j+cl-1)) : for (j-i) < dl || du < (j-i)
for i = 1..ru-rl+1, j = 1..cu-cl+1
rl = row_rng.lbound(), ru = row_rng.ubound(), cl = col_rng.lbound() and cu = col_rng.ubound().Preconditions:
To illustrate the behavior of this function consider the example matix A (see intro) in the following example: Define the permutations as:
row_perm = { 2, 4, 1, 3, 5 }
col_perm = { 3, 2, 1, 4 }
(P'*A*Q) would then be:
2 | 1 [ 4 10 ]
4 | 2 [ 7 2 11 ]
1 | 3 [ 6 1 9 ]
(P'*A*Q) = 3 | 4 [ 5 ]
5 | 5 [ 8 3 12 ]
1 2 3 4
- - - -
3 2 1 4
row_rng = [ rl, ru ] = [ 2, 5 ] col_rng = [ cl, cu ] = [ 2, 4 ]
4 | 1 [ 2 11 ]
(P'*A*Q)(r1:r2,cl:cu) = 1 | 2 [ 1 9 ]
3 | 3 [ 5 ]
1 2 3
- - -
2 1 4
dl = -1, du = 1
4 | 1 [ 4 x ]
B = 1 | 2 [ 1 9 ]
3 | 3 [ x ]
1 2 3
- - -
2 1 4
In summary, for the example A shown above we have: Input:
element_uniqueness = ELEMENTS_FORCE_UNIQUE
row_perm[] = { 2, 4, 1, 3, 5 }
col_perm[] = { 3, 2, 1, 4 }
row_rng = [ 2, 5 ]
col_rng = [ 2, 4 ]
dl = -1
du = +1
3 <- count_nonzeros(element_uniqueness,row_perm,col_perm,row_rng,col_rng,dl,du)
Implemented in AbstractLinAlgPack::MatrixSparseCOORSerial. |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Extract elements in a coordinate data structure. Let B be the scaled banded submatrix that is being specifed and let A be this matrix object. Then the elemements of B are defined by:
/ 0 : for dl <= (j-i) <= du
B(i,j) = |
\ alpha*A(row_perm(i+rl-1),col_perm(j+cl-1)) : for (j-i) < dl || du < (j-i)
for i = 1..ru-rl+1, j = 1..cu-cl+1
rl = row_rng.lbound(), ru = row_rng.ubound(), cl = col_rng.lbound() and cu = col_rng.ubound().
The client can extract the structure in
The input arguments passed to
To illustrate the behavior of this function consider the same example as outlined in the documentation for Input:
elements_uniqueness = ELEMENTS_FORCE_UNIQUE
row_perm = { 2, 4, 1, 3, 5 }
col_perm = { 3, 2, 1, 4 }
row_rng = [ 2, 5 ]
col_rng = [ 2, 4 ]
dl = -1
du = +1
alpha = 2.0
len_Aval = count_nonzeros(...) = 3
len_Aij = count_nonzeros(...) = 3
row_offset = 3
col_offset = 6
k A(i,j) B(i,j) Avar Arow Acol
- ------ ------ ---- ---- ----
1 4(4,1) 4(1,2) 8 4 8
2 1(1,1) 1(2,2) 2 5 8
3 9(1,5) 9(2,3) 18 5 9
Implemented in AbstractLinAlgPack::MatrixSparseCOORSerial. |
|
||||||||||||
|
Implements AbstractLinAlgPack::MatrixConvertToSparse. Definition at line 38 of file AbstractLinAlgPack_MatrixExtractSparseElements.cpp. |
|
||||||||||||||||||||||||||||||||||||||||
|
Implements AbstractLinAlgPack::MatrixConvertToSparse. Definition at line 49 of file AbstractLinAlgPack_MatrixExtractSparseElements.cpp. |
1.3.9.1