/[escript]/trunk/esys2/finley/src/finleyC/System_borrowNormalization.c
ViewVC logotype

Contents of /trunk/esys2/finley/src/finleyC/System_borrowNormalization.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 148 - (show annotations)
Tue Aug 23 01:24:31 2005 UTC (14 years, 7 months ago) by jgs
File MIME type: text/plain
File size: 3195 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-08-23

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* Finley: 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 "Finley.h"
20 #include "System.h"
21
22 double* Finley_SystemMatrix_borrowNormalization(Finley_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,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 Finley_ErrorCode=ZERO_DIVISION_ERROR;
49 sprintf(Finley_ErrorMsg,"Row %d contains zero entries only.",irow_failed);
50 }
51 break;
52 case CSC:
53 icol_failed=-1;
54 #pragma omp parallel for private(ic,icb,icol,fac,iptr,irb) schedule(static)
55 for (ic=0;ic< A->pattern->n_ptr;ic++) {
56 for (icb=0;icb< A->col_block_size;icb++) {
57 icol=icb+A->col_block_size*ic;
58 fac=0.;
59 for (iptr=A->pattern->ptr[ic]-PTR_OFFSET;iptr<A->pattern->ptr[ic+1]-PTR_OFFSET; iptr++) {
60 for (irb=0;irb< A->row_block_size;irb++)
61 fac+=ABS(A->val[iptr*A->block_size+irb+A->row_block_size*icb]);
62 }
63 if (fac>0) {
64 A->normalizer[icol]=1./fac;
65 } else {
66 A->normalizer[icol]=1.;
67 icol_failed=icol;
68 }
69 }
70 }
71 if (icol_failed>=0) {
72 Finley_ErrorCode=ZERO_DIVISION_ERROR;
73 sprintf(Finley_ErrorMsg,"Column %d contains zero entries only.",icol_failed);
74 }
75 break;
76 default:
77 Finley_ErrorCode=TYPE_ERROR;
78 sprintf(Finley_ErrorMsg,"Unknown matrix type.");
79 } /* switch A->type */
80 A->normalizer_is_valid=TRUE;
81 }
82 return A->normalizer;
83 }
84 /*
85 * $Log$
86 * Revision 1.2 2005/08/23 01:24:30 jgs
87 * Merge of development branch dev-02 back to main trunk on 2005-08-23
88 *
89 * Revision 1.1.2.1 2005/08/19 07:37:23 gross
90 * missing System_borrowNormalization.c
91 *
92 *
93 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26