/[escript]/trunk/paso/src/SystemMatrix_getSubmatrix.c
ViewVC logotype

Contents of /trunk/paso/src/SystemMatrix_getSubmatrix.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 415 - (show annotations)
Wed Jan 4 05:37:33 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/plain
File size: 2949 byte(s)
a better way of representing the matrix format type is introduced. this is needed for the Paradiso and UMFPACK interface
1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* Paso: SystemMatrix */
6
7 /**************************************************************/
8
9 /* Copyrights by ACcESS Australia 2003, 2004,2005 */
10 /* Author: gross@access.edu.au */
11
12 /**************************************************************/
13
14 #include "Paso.h"
15 #include "SystemMatrix.h"
16 #include "Util.h"
17
18
19 /**************************************************************
20
21 returns the submatrix of A where rows are gathered by index row_list
22 and columns are selected by non-negative values of new_col_index.
23 if new_col_index[i]>-1 new_col_index[i] gives the column of i in
24 the returned submatrix
25
26 */
27
28
29 Paso_SystemMatrix* Paso_SystemMatrix_getSubmatrix(Paso_SystemMatrix* A,int n_row_sub,index_t* row_list,index_t* new_col_index){
30 Paso_SystemMatrixPattern* sub_pattern=NULL;
31 Paso_SystemMatrix* out=NULL;
32 index_t index_offset=(A->type & MATRIX_FORMAT_OFFSET1 ? 1:0);
33 Paso_resetError();
34 int i,k,tmp,m,subpattern_row;
35 int type=A->type;
36 if (A->type & MATRIX_FORMAT_CSC) {
37 Paso_setError(TYPE_ERROR,"gathering submatrices supports CSR matrix format only.");
38 } else {
39 sub_pattern=Paso_SystemMatrixPattern_getSubpattern(A->pattern,n_row_sub,row_list,new_col_index);
40 if (Paso_noError()) {
41 /* create the return object */
42 out=Paso_SystemMatrix_alloc(type,sub_pattern,A->row_block_size,A->col_block_size);
43 if (Paso_noError()) {
44 #pragma omp parallel for private(i,k,m,subpattern_row,tmp) schedule(static)
45 for (i=0;i<n_row_sub;++i) {
46 subpattern_row=row_list[i];
47 for (k=A->pattern->ptr[subpattern_row]-index_offset;k<A->pattern->ptr[subpattern_row+1]-index_offset;++k) {
48 tmp=new_col_index[A->pattern->index[k]-index_offset];
49 if (tmp>-1) {
50 for (m=out->pattern->ptr[i]-index_offset;m<out->pattern->ptr[i+1]-index_offset;++m) {
51 if (out->pattern->index[m]==tmp+index_offset) {
52 Paso_copyDouble(A->block_size,&(A->val[k*A->block_size]),&(out->val[m*A->block_size]));
53 break;
54 }
55 }
56 }
57 }
58 }
59 }
60 }
61 Paso_SystemMatrixPattern_dealloc(sub_pattern);
62 }
63 return out;
64 }
65 /*
66 * $Log$
67 * Revision 1.2 2005/09/15 03:44:39 jgs
68 * Merge of development branch dev-02 back to main trunk on 2005-09-15
69 *
70 * Revision 1.1.2.1 2005/09/05 06:29:48 gross
71 * These files have been extracted from finley to define a stand alone libray for iterative
72 * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
73 * has not been tested yet.
74 *
75 *
76 */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26