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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3005 - (show annotations)
Thu Apr 22 05:59:31 2010 UTC (9 years, 6 months ago) by gross
File MIME type: text/plain
File size: 3485 byte(s)
early call of setPreconditioner in FCT solver removed.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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: SparseMatrix: adds the row entries to an array */
18
19 /***************************************************************************/
20
21 /* Author: l.gross@uq.edu.au */
22
23 /**************************************************************/
24
25 #include "Paso.h"
26 #include "SparseMatrix.h"
27
28 void Paso_SparseMatrix_addRow_CSR_OFFSET0(Paso_SparseMatrix* A, double* array) {
29 dim_t ir,irow,icb,irb;
30 index_t iptr;
31 register double fac;
32 #pragma omp parallel for private(ir,irb,irow,fac,iptr,icb) schedule(static)
33 for (ir=0;ir< A->pattern->numOutput;ir++) {
34 for (irb=0;irb< A->row_block_size;irb++) {
35 irow=irb+A->row_block_size*ir;
36 fac=0.;
37 for (iptr=A->pattern->ptr[ir];iptr<A->pattern->ptr[ir+1]; iptr++) {
38 for (icb=0;icb< A->col_block_size;icb++)
39 fac+=A->val[iptr*A->block_size+irb+A->row_block_size*icb];
40
41 }
42 array[irow]+=fac;
43 }
44 }
45 }
46 void Paso_SparseMatrix_copyBlockToMainDiagonal(Paso_SparseMatrix * A_p, const double* in)
47 {
48 index_t ir;
49 const dim_t n = A_p->pattern->numOutput;
50 const dim_t nblk = A_p->block_size;
51 const size_t nblk_size=sizeof(double)*nblk ;
52 const index_t* main_ptr=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p);
53 #pragma omp parallel for private(ir) schedule(static)
54 for (ir=0;ir< n;ir++) {
55 memcpy((void *)(&(A_p->val[main_ptr[ir]*nblk])), (void *)( &in[nblk*ir] ), nblk_size);
56 }
57
58 }
59 void Paso_SparseMatrix_copyBlockFromMainDiagonal(Paso_SparseMatrix * A_p, double* out)
60 {
61 index_t ir;
62 const dim_t n = A_p->pattern->numOutput;
63 const dim_t nblk =A_p->block_size;
64 const size_t nblk_size=sizeof(double)*nblk ;
65 const index_t* main_ptr=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p);
66 #pragma omp parallel for private(ir) schedule(static)
67 for (ir=0;ir< n;ir++) {
68 memcpy((void *)( &out[nblk*ir] ), (void *)(&(A_p->val[main_ptr[ir]*nblk])), nblk_size);
69 }
70 }
71
72 void Paso_SparseMatrix_copyFromMainDiagonal(Paso_SparseMatrix * A_p, double* out)
73 {
74 index_t ir, ib;
75 const dim_t n = A_p->pattern->numOutput;
76 const dim_t nblk = A_p->block_size;
77 const dim_t blk = MIN(A_p->row_block_size, A_p->col_block_size);
78 const index_t* main_ptr=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p);
79 #pragma omp parallel for private(ir,ib) schedule(static)
80 for (ir=0;ir< n;ir++) {
81 for (ib=0;ib<blk; ib++) {
82 out[ir*blk+ib] = A_p->val[main_ptr[ir]*nblk+ib+A_p->row_block_size*ib];
83 }
84 }
85
86 }
87
88 void Paso_SparseMatrix_copyToMainDiagonal(Paso_SparseMatrix * A_p, const double* in)
89 {
90 index_t ir, ib;
91 const dim_t n = A_p->pattern->numOutput;
92 const dim_t nblk = A_p->block_size;
93 const dim_t blk = MIN(A_p->row_block_size, A_p->col_block_size);
94 const index_t* main_ptr=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p);
95 #pragma omp parallel for private(ir,ib) schedule(static)
96 for (ir=0;ir< n;ir++) {
97 for (ib=0;ib<blk; ib++) {
98 A_p->val[main_ptr[ir]*nblk+ib+A_p->row_block_size*ib] = in[ir*blk+ib];
99 }
100 }
101
102 }

  ViewVC Help
Powered by ViewVC 1.1.26