/[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 155 - (show annotations)
Wed Nov 9 02:02:19 2005 UTC (13 years, 9 months ago) by jgs
File MIME type: text/plain
File size: 2855 byte(s)
move all directories from trunk/esys2 into trunk and remove esys2

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 Paso_resetError();
33 int i,k,tmp,m,subpattern_row;
34 int type=A->type;
35 if (type!=CSR) {
36 Paso_setError(TYPE_ERROR,"gathering submatrices supports CSR matrix format only.");
37 } else {
38 sub_pattern=Paso_SystemMatrixPattern_getSubpattern(A->pattern,n_row_sub,row_list,new_col_index);
39 if (Paso_noError()) {
40 /* create the return object */
41 out=Paso_SystemMatrix_alloc(type,sub_pattern,A->row_block_size,A->col_block_size);
42 if (Paso_noError()) {
43 #pragma omp parallel for private(i,k,m,subpattern_row,tmp) schedule(static)
44 for (i=0;i<n_row_sub;++i) {
45 subpattern_row=row_list[i];
46 for (k=A->pattern->ptr[subpattern_row]-PTR_OFFSET;k<A->pattern->ptr[subpattern_row+1]-PTR_OFFSET;++k) {
47 tmp=new_col_index[A->pattern->index[k]-INDEX_OFFSET];
48 if (tmp>-1) {
49 for (m=out->pattern->ptr[i]-PTR_OFFSET;m<out->pattern->ptr[i+1]-PTR_OFFSET;++m) {
50 if (out->pattern->index[m]==tmp+INDEX_OFFSET) {
51 Paso_copyDouble(A->block_size,&(A->val[k*A->block_size]),&(out->val[m*A->block_size]));
52 break;
53 }
54 }
55 }
56 }
57 }
58 }
59 }
60 Paso_SystemMatrixPattern_dealloc(sub_pattern);
61 }
62 return out;
63 }
64 /*
65 * $Log$
66 * Revision 1.2 2005/09/15 03:44:39 jgs
67 * Merge of development branch dev-02 back to main trunk on 2005-09-15
68 *
69 * Revision 1.1.2.1 2005/09/05 06:29:48 gross
70 * These files have been extracted from finley to define a stand alone libray for iterative
71 * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
72 * has not been tested yet.
73 *
74 *
75 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26