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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* Finley: SystemMatrixPatternPattern */
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 "Common.h"
16 #include "Util.h"
17 #include "SystemPattern.h"
18
19 /**************************************************************/
20
21 /* creates SystemMatrixPattern */
22
23 Finley_SystemMatrixPattern* Finley_SystemMatrixPattern_getSubpattern(Finley_SystemMatrixPattern* pattern, \
24 int new_n_rows, maybelong* row_list,maybelong* new_col_index) {
25 Finley_SystemMatrixPattern*out=NULL;
26 maybelong *ptr=NULL,*index=NULL;
27 maybelong i,k,j,subpattern_row,tmp;
28 Finley_ErrorCode=NO_ERROR;
29
30 ptr=MEMALLOC(new_n_rows+1,maybelong);
31 if (! Finley_checkPtr(ptr)) {
32 #pragma omp parallel
33 {
34 #pragma omp for private(i) schedule(static)
35 for (i=0;i<new_n_rows+1;++i) ptr[i]=0;
36
37 /* find the number column entries in each row */
38 #pragma omp for private(i,k,j,subpattern_row) schedule(static)
39 for (i=0;i<new_n_rows;++i) {
40 j=0;
41 subpattern_row=row_list[i];
42 for (k=pattern->ptr[subpattern_row]-PTR_OFFSET;k<pattern->ptr[subpattern_row+1]-PTR_OFFSET;++k)
43 if (new_col_index[pattern->index[k]-INDEX_OFFSET]>-1) j++;
44 ptr[i]=j;
45 }
46 }
47 /* accummulate ptr */
48 ptr[new_n_rows]=Finley_Util_cumsum(new_n_rows,ptr);
49 index=MEMALLOC(ptr[new_n_rows],maybelong);
50 if (Finley_checkPtr(index)) {
51 MEMFREE(ptr);
52 } else {
53 /* find the number column entries in each row */
54 #pragma omp parallel for private(i,k,j,subpattern_row,tmp) schedule(static)
55 for (i=0;i<new_n_rows;++i) {
56 j=ptr[i];
57 subpattern_row=row_list[i];
58 for (k=pattern->ptr[subpattern_row]-PTR_OFFSET;k<pattern->ptr[subpattern_row+1]-PTR_OFFSET;++k) {
59 tmp=new_col_index[pattern->index[k]-INDEX_OFFSET];
60 if (tmp>-1) {
61 index[j]=tmp;
62 ++j;
63 }
64 }
65 }
66 /* create return value */
67 out=Finley_SystemMatrixPattern_alloc(new_n_rows,ptr,index);
68 if (Finley_ErrorCode!=NO_ERROR) {
69 MEMFREE(index);
70 MEMFREE(ptr);
71 }
72 }
73 }
74 return out;
75 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26