/[escript]/trunk/esys2/paso/src/SystemMatrix_borrowNormalization.c
ViewVC logotype

Annotation of /trunk/esys2/paso/src/SystemMatrix_borrowNormalization.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (hide annotations)
Thu Sep 15 03:44:45 2005 UTC (14 years, 5 months ago) by jgs
File MIME type: text/plain
File size: 3271 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-15

1 jgs 150 /* $Id$ */
2    
3     /**************************************************************/
4    
5     /* Paso: SystemMatrix */
6    
7     /* returns a borrowed reference to the matrix normaliztion vector */
8    
9     /* if the vector is in valid a new vector is calculate as the inverse */
10     /* of the sum of the absolute value in each row/column */
11    
12     /**************************************************************/
13    
14     /* Copyrights by ACcESS Australia 2005 */
15     /* Author: gross@access.edu.au */
16    
17     /**************************************************************/
18    
19     #include "Paso.h"
20     #include "SystemMatrix.h"
21    
22     double* Paso_SystemMatrix_borrowNormalization(Paso_SystemMatrix* A) {
23     dim_t ir,irow,ic,icb,icol,irb;
24     index_t iptr,icol_failed,irow_failed;
25     double fac;
26     if (!A->normalizer_is_valid) {
27     switch(A->type) {
28     case CSR:
29     irow_failed=-1;
30     #pragma omp parallel for private(ir,irb,irow,fac,iptr,icb) schedule(static)
31     for (ir=0;ir< A->pattern->n_ptr;ir++) {
32     for (irb=0;irb< A->row_block_size;irb++) {
33     irow=irb+A->row_block_size*ir;
34     fac=0.;
35     for (iptr=A->pattern->ptr[ir]-PTR_OFFSET;iptr<A->pattern->ptr[ir+1]-PTR_OFFSET; iptr++) {
36     for (icb=0;icb< A->col_block_size;icb++)
37     fac+=ABS(A->val[iptr*A->block_size+irb+A->row_block_size*icb]);
38     }
39     if (fac>0) {
40     A->normalizer[irow]=1./fac;
41     } else {
42     A->normalizer[irow]=1.;
43     irow_failed=irow;
44     }
45     }
46     }
47     if (irow_failed>=0) {
48     Paso_setError(ZERO_DIVISION_ERROR,"There is a row containing zero entries only.");
49     }
50     break;
51     case CSC:
52     icol_failed=-1;
53     #pragma omp parallel for private(ic,icb,icol,fac,iptr,irb) schedule(static)
54     for (ic=0;ic< A->pattern->n_ptr;ic++) {
55     for (icb=0;icb< A->col_block_size;icb++) {
56     icol=icb+A->col_block_size*ic;
57     fac=0.;
58     for (iptr=A->pattern->ptr[ic]-PTR_OFFSET;iptr<A->pattern->ptr[ic+1]-PTR_OFFSET; iptr++) {
59     for (irb=0;irb< A->row_block_size;irb++)
60     fac+=ABS(A->val[iptr*A->block_size+irb+A->row_block_size*icb]);
61     }
62     if (fac>0) {
63     A->normalizer[icol]=1./fac;
64     } else {
65     A->normalizer[icol]=1.;
66     icol_failed=icol;
67     }
68     }
69     }
70     if (icol_failed>=0) {
71     Paso_setError(ZERO_DIVISION_ERROR,"There is a column containing zero entries only.");
72     }
73     break;
74     default:
75     Paso_setError(TYPE_ERROR,"No normalization available for this matrix type.");
76     } /* switch A->type */
77     A->normalizer_is_valid=TRUE;
78     }
79     return A->normalizer;
80     }
81     /*
82     * $Log$
83     * Revision 1.2 2005/09/15 03:44:39 jgs
84     * Merge of development branch dev-02 back to main trunk on 2005-09-15
85     *
86     * Revision 1.1.2.1 2005/09/05 06:29:47 gross
87     * These files have been extracted from finley to define a stand alone libray for iterative
88     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
89     * has not been tested yet.
90     *
91     *
92     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26