/[escript]/trunk/esys2/finley/src/finleyC/System_getSubmatrix.c
ViewVC logotype

Contents of /trunk/esys2/finley/src/finleyC/System_getSubmatrix.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 115 - (show annotations)
Fri Mar 4 07:12:47 2005 UTC (14 years, 1 month ago) by jgs
File MIME type: text/plain
File size: 2604 byte(s)
*** empty log message ***

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* Finley: SystemMatrix */
6
7 /**************************************************************/
8
9 /* Copyrights by ACcESS Australia 2003, 2004,2005 */
10 /* Author: gross@access.edu.au */
11
12 /**************************************************************/
13
14 #include "Finley.h"
15 #include "System.h"
16 #include "Util.h"
17 #include "SystemPattern.h"
18
19
20 /**************************************************************
21
22 returns the submatrix of A where rows are gathered by index row_list
23 and columns are selected by non-negative values of new_col_index.
24 if new_col_index[i]>-1 new_col_index[i] gives the column of i in
25 the returned submatrix
26
27 */
28
29
30 Finley_SystemMatrix* Finley_SystemMatrix_getSubmatrix(Finley_SystemMatrix* A,int n_row_sub,maybelong* row_list,maybelong* new_col_index){
31 Finley_SystemMatrixPattern* sub_pattern=NULL;
32 Finley_SystemMatrix* out=NULL;
33 Finley_ErrorCode=NO_ERROR;
34 int i,k,tmp,m,subpattern_row;
35 int type=A->type;
36 if (type!=CSR) {
37 Finley_ErrorCode=TYPE_ERROR;
38 sprintf(Finley_ErrorMsg,"gathering submatrices supports CSR matrix format only.");
39 } else {
40 sub_pattern=Finley_SystemMatrixPattern_getSubpattern(A->pattern,n_row_sub,row_list,new_col_index);
41 if (Finley_ErrorCode==NO_ERROR) {
42 /* create the return object */
43 out=Finley_SystemMatrix_alloc(type,sub_pattern,A->row_block_size,A->col_block_size);
44 if (Finley_ErrorCode==NO_ERROR) {
45 #pragma omp parallel for private(i,k,m,subpattern_row,tmp) schedule(static)
46 for (i=0;i<n_row_sub;++i) {
47 subpattern_row=row_list[i];
48 for (k=A->pattern->ptr[subpattern_row]-PTR_OFFSET;k<A->pattern->ptr[subpattern_row+1]-PTR_OFFSET;++k) {
49 tmp=new_col_index[A->pattern->index[k]-INDEX_OFFSET];
50 if (tmp>-1) {
51 for (m=out->pattern->ptr[i]-PTR_OFFSET;m<out->pattern->ptr[i+1]-PTR_OFFSET;++m) {
52 if (out->pattern->index[m]==tmp+INDEX_OFFSET) {
53 Finley_copyDouble(A->block_size,&(A->val[k*A->block_size]),&(out->val[m*A->block_size]));
54 break;
55 }
56 }
57 }
58 }
59 }
60 } else {
61 Finley_SystemMatrixPattern_dealloc(sub_pattern);
62 }
63 }
64 }
65 return out;
66 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26