/[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 113 - (show annotations)
Mon Feb 28 07:06:33 2005 UTC (14 years, 1 month ago) by jgs
File MIME type: text/plain
File size: 2708 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[subpattern_row]=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) index[j++]=tmp;
61 }
62 }
63 /* create return value */
64 out=Finley_SystemMatrixPattern_alloc(new_n_rows,ptr,index);
65 if (Finley_ErrorCode!=NO_ERROR) {
66 MEMFREE(index);
67 MEMFREE(ptr);
68 }
69 }
70 }
71 return out;
72 }
73 /*
74 * $Log$
75 * Revision 1.2 2005/02/28 07:06:33 jgs
76 * *** empty log message ***
77 *
78 * Revision 1.1.2.1 2005/02/18 02:27:31 gross
79 * two function that will be used for a reimplementation of the ILU preconditioner
80 *
81 *
82 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26