/[escript]/trunk/paso/src/SparseMatrix_invMain.cpp
ViewVC logotype

Contents of /trunk/paso/src/SparseMatrix_invMain.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4803 - (show annotations)
Wed Mar 26 06:52:28 2014 UTC (5 years, 10 months ago) by caltinay
File size: 3272 byte(s)
Removed obsolete wrappers for malloc and friends.
Paso_Pattern -> paso::Pattern

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 /****************************************************************************/
19
20 /* Paso: inverts the main diagonal of a SparseMatrix: */
21
22 /****************************************************************************/
23
24 /* Author: Lutz Gross, l.gross@uq.edu.au */
25
26 /****************************************************************************/
27
28 #include "Paso.h"
29 #include "SparseMatrix.h"
30 #include "Solver.h"
31 #include "BlockOps.h"
32 #include "PasoUtil.h"
33
34 namespace paso {
35
36 void SparseMatrix_invMain(const SparseMatrix* A_p, double* inv_diag, int* pivot)
37 {
38 index_t failed=0;
39 register double A11;
40 const dim_t n=A_p->numRows;
41 const dim_t n_block=A_p->row_block_size;
42 const dim_t m_block=A_p->col_block_size;
43 const dim_t block_size=A_p->block_size;
44 dim_t i;
45 register index_t iPtr;
46 index_t* main_ptr=Pattern_borrowMainDiagonalPointer(A_p->pattern);
47 /* check matrix is square */
48 if (m_block != n_block) {
49 Esys_setError(TYPE_ERROR, "SparseMatrix_invMain: square block size expected.");
50 }
51 if (Esys_noError()) {
52
53 if (n_block==1) {
54 #pragma omp parallel for private(i, iPtr, A11) schedule(static)
55 for (i = 0; i < n; i++) {
56 iPtr= main_ptr[i];
57 A11=A_p->val[iPtr];
58 if ( ABS(A11) > 0.) {
59 inv_diag[i]=1./A11;
60 } else {
61 failed=1;
62 }
63 }
64 } else if (n_block==2) {
65 #pragma omp parallel for private(i, iPtr) schedule(static)
66 for (i = 0; i < n; i++) {
67 iPtr= main_ptr[i];
68 Paso_BlockOps_invM_2(&inv_diag[i*4], &A_p->val[iPtr*4], &failed);
69 }
70 } else if (n_block==3) {
71 #pragma omp parallel for private(i, iPtr) schedule(static)
72 for (i = 0; i < n; i++) {
73 iPtr= main_ptr[i];
74 Paso_BlockOps_invM_3(&inv_diag[i*9], &A_p->val[iPtr*9], &failed);
75 }
76 } else {
77 #pragma omp parallel for private(i, iPtr) schedule(static)
78 for (i = 0; i < n; i++) {
79 iPtr= main_ptr[i];
80 Paso_BlockOps_Cpy_N(block_size, &inv_diag[i*block_size], &A_p->val[iPtr*block_size]);
81 Paso_BlockOps_invM_N(n_block, &inv_diag[i*block_size], &pivot[i*n_block], &failed);
82 }
83 }
84 }
85 if (failed > 0) {
86 Esys_setError(ZERO_DIVISION_ERROR, "SparseMatrix_invMain: non-regular main diagonal block.");
87 }
88 }
89 void SparseMatrix_applyBlockMatrix(const SparseMatrix* A_p,
90 double* block_diag,
91 int* pivot, double* x,
92 const double *b)
93 {
94 dim_t n=A_p->numRows;
95 dim_t n_block=A_p->row_block_size;
96 Paso_Copy(n_block*n, x,b);
97 Paso_BlockOps_solveAll(n_block,n,block_diag,pivot,x);
98 }
99
100 } // namespace paso
101

Properties

Name Value
svn:mergeinfo /branches/amg_from_3530/paso/src/SparseMatrix_invMain.cpp:3531-3826 /branches/lapack2681/paso/src/SparseMatrix_invMain.cpp:2682-2741 /branches/pasowrap/paso/src/SparseMatrix_invMain.cpp:3661-3674 /branches/py3_attempt2/paso/src/SparseMatrix_invMain.cpp:3871-3891 /branches/restext/paso/src/SparseMatrix_invMain.cpp:2610-2624 /branches/ripleygmg_from_3668/paso/src/SparseMatrix_invMain.cpp:3669-3791 /branches/stage3.0/paso/src/SparseMatrix_invMain.cpp:2569-2590 /branches/symbolic_from_3470/paso/src/SparseMatrix_invMain.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/paso/src/SparseMatrix_invMain.cpp:3517-3974 /release/3.0/paso/src/SparseMatrix_invMain.cpp:2591-2601 /trunk/paso/src/SparseMatrix_invMain.cpp:4257-4344 /trunk/ripley/test/python/paso/src/SparseMatrix_invMain.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26