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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26