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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 633 - (hide annotations)
Thu Mar 23 05:37:00 2006 UTC (13 years, 11 months ago) by dhawcroft
File MIME type: text/plain
File size: 3599 byte(s)


1 jgs 150 /* $Id$ */
2    
3 dhawcroft 631
4     /*
5     ********************************************************************************
6 dhawcroft 633 * Copyright 2006 by ACcESS MNRF *
7 dhawcroft 631 * *
8     * http://www.access.edu.au *
9     * Primary Business: Queensland, Australia *
10     * Licensed under the Open Software License version 3.0 *
11     * http://www.opensource.org/licenses/osl-3.0.php *
12     ********************************************************************************
13     */
14    
15 jgs 150 /**************************************************************/
16    
17     /* Paso: SystemMatrix */
18    
19     /**************************************************************/
20    
21     /* Copyrights by ACcESS Australia 2003, 2004,2005 */
22     /* Author: gross@access.edu.au */
23    
24     /**************************************************************/
25    
26     #include "Paso.h"
27     #include "SystemMatrix.h"
28 jgs 483 #include "PasoUtil.h"
29 jgs 150
30    
31     /**************************************************************
32    
33     returns the submatrix of A where rows are gathered by index row_list
34     and columns are selected by non-negative values of new_col_index.
35     if new_col_index[i]>-1 new_col_index[i] gives the column of i in
36     the returned submatrix
37    
38     */
39    
40    
41     Paso_SystemMatrix* Paso_SystemMatrix_getSubmatrix(Paso_SystemMatrix* A,int n_row_sub,index_t* row_list,index_t* new_col_index){
42     Paso_SystemMatrixPattern* sub_pattern=NULL;
43     Paso_SystemMatrix* out=NULL;
44 gross 415 index_t index_offset=(A->type & MATRIX_FORMAT_OFFSET1 ? 1:0);
45 jgs 150 Paso_resetError();
46     int i,k,tmp,m,subpattern_row;
47     int type=A->type;
48 gross 415 if (A->type & MATRIX_FORMAT_CSC) {
49 jgs 150 Paso_setError(TYPE_ERROR,"gathering submatrices supports CSR matrix format only.");
50     } else {
51     sub_pattern=Paso_SystemMatrixPattern_getSubpattern(A->pattern,n_row_sub,row_list,new_col_index);
52     if (Paso_noError()) {
53     /* create the return object */
54     out=Paso_SystemMatrix_alloc(type,sub_pattern,A->row_block_size,A->col_block_size);
55     if (Paso_noError()) {
56     #pragma omp parallel for private(i,k,m,subpattern_row,tmp) schedule(static)
57     for (i=0;i<n_row_sub;++i) {
58     subpattern_row=row_list[i];
59 gross 415 for (k=A->pattern->ptr[subpattern_row]-index_offset;k<A->pattern->ptr[subpattern_row+1]-index_offset;++k) {
60     tmp=new_col_index[A->pattern->index[k]-index_offset];
61 jgs 150 if (tmp>-1) {
62 gross 415 for (m=out->pattern->ptr[i]-index_offset;m<out->pattern->ptr[i+1]-index_offset;++m) {
63     if (out->pattern->index[m]==tmp+index_offset) {
64 jgs 150 Paso_copyDouble(A->block_size,&(A->val[k*A->block_size]),&(out->val[m*A->block_size]));
65     break;
66     }
67     }
68     }
69     }
70     }
71     }
72     }
73     Paso_SystemMatrixPattern_dealloc(sub_pattern);
74     }
75     return out;
76     }
77     /*
78     * $Log$
79     * Revision 1.2 2005/09/15 03:44:39 jgs
80     * Merge of development branch dev-02 back to main trunk on 2005-09-15
81     *
82     * Revision 1.1.2.1 2005/09/05 06:29:48 gross
83     * These files have been extracted from finley to define a stand alone libray for iterative
84     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
85     * has not been tested yet.
86     *
87     *
88     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26