/[escript]/trunk/paso/src/SystemMatrixPattern_getSubpattern.c
ViewVC logotype

Annotation of /trunk/paso/src/SystemMatrixPattern_getSubpattern.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 971 - (hide annotations)
Wed Feb 14 04:40:49 2007 UTC (13 years, 1 month ago) by ksteube
File MIME type: text/plain
File size: 3602 byte(s)
Had to undo commit to new MPI branch. The changes went into the original and
not the branch. The files committed here are exactly the same as revision 969.


1 jgs 150 /* $Id$ */
2    
3 dhawcroft 631 /*
4     ********************************************************************************
5 dhawcroft 633 * Copyright 2006 by ACcESS MNRF *
6 dhawcroft 631 * *
7     * http://www.access.edu.au *
8     * Primary Business: Queensland, Australia *
9     * Licensed under the Open Software License version 3.0 *
10     * http://www.opensource.org/licenses/osl-3.0.php *
11     ********************************************************************************
12     */
13    
14 jgs 150 /**************************************************************/
15    
16     /* Paso: SystemMatrixPatternPattern */
17    
18     /**************************************************************/
19    
20     /* Copyrights by ACcESS Australia 2003, 2004, 2005 */
21     /* Author: gross@access.edu.au */
22    
23     /**************************************************************/
24    
25     #include "Paso.h"
26 jgs 483 #include "PasoUtil.h"
27 jgs 150 #include "SystemMatrixPattern.h"
28    
29     /**************************************************************/
30    
31     /* creates SystemMatrixPattern */
32    
33     Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_getSubpattern(Paso_SystemMatrixPattern* pattern, \
34     int new_n_rows, index_t* row_list,index_t* new_col_index) {
35 gross 415 index_t index_offset=(pattern->type & PATTERN_FORMAT_OFFSET1 ? 1:0);
36 jgs 150 Paso_SystemMatrixPattern*out=NULL;
37     index_t *ptr=NULL,*index=NULL,k,j,subpattern_row,tmp;
38     dim_t i;
39     Paso_resetError();
40    
41     ptr=MEMALLOC(new_n_rows+1,index_t);
42     if (! Paso_checkPtr(ptr)) {
43     #pragma omp parallel
44     {
45     #pragma omp for private(i) schedule(static)
46     for (i=0;i<new_n_rows+1;++i) ptr[i]=0;
47    
48     /* find the number column entries in each row */
49     #pragma omp for private(i,k,j,subpattern_row) schedule(static)
50     for (i=0;i<new_n_rows;++i) {
51     j=0;
52     subpattern_row=row_list[i];
53 gross 415 for (k=pattern->ptr[subpattern_row]-index_offset;k<pattern->ptr[subpattern_row+1]-index_offset;++k)
54     if (new_col_index[pattern->index[k]-index_offset]>-1) j++;
55 jgs 150 ptr[i]=j;
56     }
57     }
58     /* accummulate ptr */
59     ptr[new_n_rows]=Paso_Util_cumsum(new_n_rows,ptr);
60     index=MEMALLOC(ptr[new_n_rows],index_t);
61     if (Paso_checkPtr(index)) {
62     MEMFREE(ptr);
63     } else {
64     /* find the number column entries in each row */
65     #pragma omp parallel for private(i,k,j,subpattern_row,tmp) schedule(static)
66     for (i=0;i<new_n_rows;++i) {
67     j=ptr[i];
68     subpattern_row=row_list[i];
69 gross 415 for (k=pattern->ptr[subpattern_row]-index_offset;k<pattern->ptr[subpattern_row+1]-index_offset;++k) {
70     tmp=new_col_index[pattern->index[k]-index_offset];
71 jgs 150 if (tmp>-1) {
72     index[j]=tmp;
73     ++j;
74     }
75     }
76     }
77     /* create return value */
78 ksteube 971 out=Paso_SystemMatrixPattern_alloc(pattern->type,new_n_rows,ptr,index);
79 jgs 150 if (! Paso_noError()) {
80     MEMFREE(index);
81     MEMFREE(ptr);
82     }
83     }
84     }
85     return out;
86     }
87     /*
88     * $Log$
89     * Revision 1.2 2005/09/15 03:44:39 jgs
90     * Merge of development branch dev-02 back to main trunk on 2005-09-15
91     *
92     * Revision 1.1.2.1 2005/09/05 06:29:47 gross
93     * These files have been extracted from finley to define a stand alone libray for iterative
94     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
95     * has not been tested yet.
96     *
97     *
98     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26