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

Contents of /trunk/paso/src/SystemMatrix_borrowNormalization.c

Parent Directory Parent Directory | Revision Log Revision Log


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


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26