/[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 1388 - (show annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 8 months ago) by trankine
File MIME type: text/plain
File size: 3011 byte(s)
And get the *(&(*&(* name right
1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 /**************************************************************/
17
18 /* Paso: SystemMatrix */
19
20 /* returns a borrowed reference to the matrix normaliztion vector */
21
22 /* if the vector is in valid a new vector is calculate as the inverse */
23 /* of the sum of the absolute value in each row/column */
24
25 /**************************************************************/
26
27 /* Copyrights by ACcESS Australia 2005 */
28 /* Author: gross@access.edu.au */
29
30 /**************************************************************/
31
32 #include "Paso.h"
33 #include "SystemMatrix.h"
34
35 double* Paso_SystemMatrix_borrowNormalization(Paso_SystemMatrix* A) {
36 dim_t irow, nrow;
37 index_t irow_failed, irow_failed_local;
38 register double fac;
39 if (!A->normalizer_is_valid) {
40 if ((A->type & MATRIX_FORMAT_CSC) || (A->type & MATRIX_FORMAT_SYM) || (A->type & MATRIX_FORMAT_OFFSET1)) {
41 Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_borrowNormalization: No normalization available for compressed sparse column, symmetric storage scheme or index offset 1.");
42 } else {
43 if (Paso_checkPtr(A->normalizer)) {
44 Paso_setError(SYSTEM_ERROR,"Paso_SystemMatrix_borrowNormalization: no memory alloced for normalizer.");
45
46 } else {
47 nrow=A->mainBlock->numRows*A->row_block_size;
48 #pragma omp parallel for private(irow) schedule(static)
49 for (irow=0; irow<nrow ; ++irow) {
50 A->normalizer[irow]=0;
51 }
52 Paso_SparseMatrix_addAbsRow_CSR_OFFSET0(A->mainBlock,A->normalizer);
53 Paso_SparseMatrix_addAbsRow_CSR_OFFSET0(A->coupleBlock,A->normalizer);
54
55 #pragma omp parallel
56 {
57 irow_failed_local=-1;
58 #pragma omp for private(irow,fac) schedule(static)
59 for (irow=0; irow<nrow ; ++irow) {
60 fac=A->normalizer[irow];
61 if (ABS(fac)>0) {
62 A->normalizer[irow]=1./fac;
63 } else {
64 A->normalizer[irow]=1.;
65 irow_failed=irow;
66 }
67 }
68 #pragma omp critical
69 irow_failed=irow_failed_local;
70 }
71 if (irow_failed>=0) {
72 Paso_setError(ZERO_DIVISION_ERROR,"There is a row containing zero entries only.");
73 }
74 A->normalizer_is_valid=TRUE;
75 }
76 }
77 Paso_MPIInfo_noError(A->mpi_info );
78 }
79 return A->normalizer;
80 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26