/[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 2159 - (show annotations)
Tue Dec 16 03:27:16 2008 UTC (10 years, 10 months ago) by artak
File MIME type: text/plain
File size: 3062 byte(s)
Numerous bags are fixed for loading MatrixMarket files.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
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 irow, nrow;
36 index_t irow_failed, irow_failed_local;
37 register 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,"Paso_SystemMatrix_borrowNormalization: No normalization available for compressed sparse column, symmetric storage scheme or index offset 1.");
41 } else {
42 if (Paso_checkPtr(A->normalizer)) {
43 Paso_setError(SYSTEM_ERROR,"Paso_SystemMatrix_borrowNormalization: no memory alloced for normalizer.");
44
45 } else {
46 nrow=A->mainBlock->numRows*A->row_block_size;
47 #pragma omp parallel for private(irow) schedule(static)
48 for (irow=0; irow<nrow ; ++irow) {
49 A->normalizer[irow]=0;
50 }
51 Paso_SparseMatrix_addAbsRow_CSR_OFFSET0(A->mainBlock,A->normalizer);
52 if(A->col_coupleBlock->pattern->ptr!=NULL) {
53 Paso_SparseMatrix_addAbsRow_CSR_OFFSET0(A->col_coupleBlock,A->normalizer);
54 }
55
56 #pragma omp parallel
57 {
58 irow_failed_local=-1;
59 #pragma omp for private(irow,fac) schedule(static)
60 for (irow=0; irow<nrow ; ++irow) {
61 fac=A->normalizer[irow];
62 if (ABS(fac)>0) {
63 A->normalizer[irow]=1./fac;
64 } else {
65 A->normalizer[irow]=1.;
66 irow_failed=irow;
67 }
68 }
69 #pragma omp critical
70 irow_failed=irow_failed_local;
71 }
72 if (irow_failed>=0) {
73 Paso_setError(ZERO_DIVISION_ERROR,"There is a row containing zero entries only.");
74 }
75 A->normalizer_is_valid=TRUE;
76 }
77 }
78 Paso_MPIInfo_noError(A->mpi_info );
79 }
80 return A->normalizer;
81 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26