1 |
/* $Id$ */ |
2 |
|
3 |
/**************************************************************/ |
4 |
|
5 |
/* Paso: SystemMatrixPatternPattern */ |
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 "Util.h" |
16 |
#include "SystemMatrixPattern.h" |
17 |
|
18 |
/**************************************************************/ |
19 |
|
20 |
/* creates SystemMatrixPattern */ |
21 |
|
22 |
Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_getSubpattern(Paso_SystemMatrixPattern* pattern, \ |
23 |
int new_n_rows, index_t* row_list,index_t* new_col_index) { |
24 |
Paso_SystemMatrixPattern*out=NULL; |
25 |
index_t *ptr=NULL,*index=NULL,k,j,subpattern_row,tmp; |
26 |
dim_t i; |
27 |
Paso_resetError(); |
28 |
|
29 |
ptr=MEMALLOC(new_n_rows+1,index_t); |
30 |
if (! Paso_checkPtr(ptr)) { |
31 |
#pragma omp parallel |
32 |
{ |
33 |
#pragma omp for private(i) schedule(static) |
34 |
for (i=0;i<new_n_rows+1;++i) ptr[i]=0; |
35 |
|
36 |
/* find the number column entries in each row */ |
37 |
#pragma omp for private(i,k,j,subpattern_row) schedule(static) |
38 |
for (i=0;i<new_n_rows;++i) { |
39 |
j=0; |
40 |
subpattern_row=row_list[i]; |
41 |
for (k=pattern->ptr[subpattern_row]-PTR_OFFSET;k<pattern->ptr[subpattern_row+1]-PTR_OFFSET;++k) |
42 |
if (new_col_index[pattern->index[k]-INDEX_OFFSET]>-1) j++; |
43 |
ptr[i]=j; |
44 |
} |
45 |
} |
46 |
/* accummulate ptr */ |
47 |
ptr[new_n_rows]=Paso_Util_cumsum(new_n_rows,ptr); |
48 |
index=MEMALLOC(ptr[new_n_rows],index_t); |
49 |
if (Paso_checkPtr(index)) { |
50 |
MEMFREE(ptr); |
51 |
} else { |
52 |
/* find the number column entries in each row */ |
53 |
#pragma omp parallel for private(i,k,j,subpattern_row,tmp) schedule(static) |
54 |
for (i=0;i<new_n_rows;++i) { |
55 |
j=ptr[i]; |
56 |
subpattern_row=row_list[i]; |
57 |
for (k=pattern->ptr[subpattern_row]-PTR_OFFSET;k<pattern->ptr[subpattern_row+1]-PTR_OFFSET;++k) { |
58 |
tmp=new_col_index[pattern->index[k]-INDEX_OFFSET]; |
59 |
if (tmp>-1) { |
60 |
index[j]=tmp; |
61 |
++j; |
62 |
} |
63 |
} |
64 |
} |
65 |
/* create return value */ |
66 |
out=Paso_SystemMatrixPattern_alloc(new_n_rows,ptr,index); |
67 |
if (! Paso_noError()) { |
68 |
MEMFREE(index); |
69 |
MEMFREE(ptr); |
70 |
} |
71 |
} |
72 |
} |
73 |
return out; |
74 |
} |
75 |
/* |
76 |
* $Log$ |
77 |
* Revision 1.2 2005/09/15 03:44:39 jgs |
78 |
* Merge of development branch dev-02 back to main trunk on 2005-09-15 |
79 |
* |
80 |
* Revision 1.1.2.1 2005/09/05 06:29:47 gross |
81 |
* These files have been extracted from finley to define a stand alone libray for iterative |
82 |
* linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but |
83 |
* has not been tested yet. |
84 |
* |
85 |
* |
86 |
*/ |