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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4829 - (show annotations)
Thu Apr 3 04:02:53 2014 UTC (5 years, 5 months ago) by caltinay
File size: 6456 byte(s)
checkpointing some SparseMatrix cleanup.

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: SparseMatrix
21
22 Nullify rows and columns in the matrix
23
24 The rows and columns are marked by positive values in
25 mask_row and mask_col. Values on the main diagonal
26 which are marked to set to zero by both mask_row and
27 mask_col are set to main_diagonal_value
28 */
29
30 /****************************************************************************/
31
32 /* Author: Lutz Gross, l.gross@uq.edu.au */
33
34 /****************************************************************************/
35
36 #include "Paso.h"
37 #include "SparseMatrix.h"
38
39 namespace paso {
40
41 void SparseMatrix::nullifyRowsAndCols_CSC_BLK1(const double* mask_row,
42 const double* mask_col,
43 double main_diagonal_value)
44 {
45 const index_t index_offset=(type & MATRIX_FORMAT_OFFSET1 ? 1:0);
46 #pragma omp parallel for
47 for (index_t icol=0; icol < pattern->numOutput; icol++) {
48 #pragma ivdep
49 for (index_t iptr=pattern->ptr[icol]-index_offset; iptr < pattern->ptr[icol+1]-index_offset; iptr++) {
50 const index_t irow = pattern->index[iptr]-index_offset;
51 if (mask_col[icol]>0. || mask_row[irow]>0.) {
52 val[iptr] = (irow==icol ? main_diagonal_value : 0);
53 }
54 }
55 }
56 }
57
58 void SparseMatrix::nullifyRowsAndCols_CSR_BLK1(const double* mask_row,
59 const double* mask_col,
60 double main_diagonal_value)
61 {
62 const index_t index_offset=(type & MATRIX_FORMAT_OFFSET1 ? 1:0);
63 #pragma omp parallel for
64 for (index_t irow=0; irow < pattern->numOutput; irow++) {
65 #pragma ivdep
66 for (index_t iptr=pattern->ptr[irow]-index_offset; iptr < pattern->ptr[irow+1]-index_offset; iptr++) {
67 const index_t icol = pattern->index[iptr]-index_offset;
68 if (mask_col[icol]>0. || mask_row[irow]>0.) {
69 val[iptr] = (irow==icol ? main_diagonal_value : 0);
70 }
71 }
72 }
73 }
74
75 void SparseMatrix::nullifyRowsAndCols_CSC(const double* mask_row,
76 const double* mask_col,
77 double main_diagonal_value)
78 {
79 const index_t index_offset=(type & MATRIX_FORMAT_OFFSET1 ? 1:0);
80 #pragma omp parallel for
81 for (index_t ic=0; ic < pattern->numOutput; ic++) {
82 for (index_t iptr=pattern->ptr[ic]-index_offset; iptr < pattern->ptr[ic+1]-index_offset; iptr++) {
83 for (index_t irb=0; irb < row_block_size; irb++) {
84 const index_t irow=irb+row_block_size*(pattern->index[iptr]-index_offset);
85 #pragma ivdep
86 for (index_t icb=0; icb < col_block_size; icb++) {
87 const index_t icol=icb+col_block_size*ic;
88 if (mask_col[icol]>0. || mask_row[irow]>0.) {
89 const index_t l=iptr*block_size+irb+row_block_size*icb;
90 val[l] = (irow==icol ? main_diagonal_value : 0);
91 }
92 }
93 }
94 }
95 }
96 }
97
98 void SparseMatrix::nullifyRowsAndCols_CSR(const double* mask_row,
99 const double* mask_col,
100 double main_diagonal_value)
101 {
102 const index_t index_offset=(type & MATRIX_FORMAT_OFFSET1 ? 1:0);
103 #pragma omp parallel for
104 for (index_t ir=0; ir < pattern->numOutput; ir++) {
105 for (index_t iptr=pattern->ptr[ir]-index_offset; iptr < pattern->ptr[ir+1]-index_offset; iptr++) {
106 for (index_t irb=0; irb < row_block_size; irb++) {
107 const index_t irow=irb+row_block_size*ir;
108 #pragma ivdep
109 for (index_t icb=0; icb < col_block_size; icb++) {
110 const index_t icol=icb+col_block_size*(pattern->index[iptr]-index_offset);
111 if (mask_col[icol]>0. || mask_row[irow]>0.) {
112 const index_t l=iptr*block_size+irb+row_block_size*icb;
113 val[l] = (irow==icol ? main_diagonal_value : 0);
114 }
115 }
116 }
117 }
118 }
119 }
120
121 void SparseMatrix::nullifyRows_CSR_BLK1(const double* mask_row,
122 double main_diagonal_value)
123 {
124 const index_t index_offset=(type & MATRIX_FORMAT_OFFSET1 ? 1:0);
125 #pragma omp parallel for
126 for (index_t irow=0; irow < pattern->numOutput; irow++) {
127 if (mask_row[irow]>0.) {
128 #pragma ivdep
129 for (index_t iptr=pattern->ptr[irow]-index_offset; iptr < pattern->ptr[irow+1]-index_offset; iptr++) {
130 const index_t icol = pattern->index[iptr]-index_offset;
131 val[iptr] = (irow==icol ? main_diagonal_value : 0);
132 }
133 }
134 }
135 }
136
137 void SparseMatrix::nullifyRows_CSR(const double* mask_row,
138 double main_diagonal_value)
139 {
140 const index_t index_offset=(type & MATRIX_FORMAT_OFFSET1 ? 1:0);
141 #pragma omp parallel for
142 for (index_t ir=0; ir < pattern->numOutput; ir++) {
143 for (index_t iptr=pattern->ptr[ir]-index_offset; iptr < pattern->ptr[ir+1]-index_offset; iptr++) {
144 for (index_t irb=0; irb < row_block_size; irb++) {
145 const index_t irow = irb+row_block_size*ir;
146 if (mask_row[irow]>0.) {
147 #pragma ivdep
148 for (index_t icb=0; icb < col_block_size; icb++) {
149 const index_t icol=icb+col_block_size*(pattern->index[iptr]-index_offset);
150 const index_t l=iptr*block_size+irb+row_block_size*icb;
151 val[l] = (irow==icol ? main_diagonal_value : 0);
152 }
153 }
154 }
155 }
156 }
157 }
158
159 } // namespace paso
160

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26