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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4803 - (show annotations)
Wed Mar 26 06:52:28 2014 UTC (5 years, 9 months ago) by caltinay
File size: 3257 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
21 /* Paso: Pattern */
22
23 /****************************************************************************/
24
25 /* Author: Lutz Gross, l.gross@uq.edu.au */
26
27 /****************************************************************************/
28
29 #include "Paso.h"
30 #include "Pattern.h"
31
32 namespace paso {
33
34 // computes the pattern coming from a matrix-matrix multiplication
35
36 Pattern* Pattern_multiply(int type, Pattern* A, Pattern* B)
37 {
38 Paso_IndexListArray* index_list = Paso_IndexListArray_alloc(A->numOutput);
39
40 #pragma omp parallel for schedule(static)
41 for (dim_t i = 0; i < A->numOutput; i++) {
42 for (index_t iptrA = A->ptr[i]; iptrA < A->ptr[i+1]; ++iptrA) {
43 const dim_t j = A->index[iptrA];
44 for (index_t iptrB = B->ptr[j]; iptrB < B->ptr[j+1]; ++iptrB) {
45 const dim_t k = B->index[iptrB];
46 Paso_IndexListArray_insertIndex(index_list, i, k);
47 }
48 }
49 }
50 Pattern* out=Pattern_fromIndexListArray(0, index_list, 0, B->numInput, 0);
51
52 Paso_IndexListArray_free(index_list);
53 return out;
54 }
55
56 /*
57 * Computes the pattern of C = A binary operation B for CSR matrices A,B
58 *
59 * Note: we do not check whether A_ij(op)B_ij=0
60 *
61 */
62 Pattern* Pattern_binop(int type, Pattern* A, Pattern* B)
63 {
64 Paso_IndexListArray* index_list = Paso_IndexListArray_alloc(A->numOutput);
65
66 #pragma omp parallel for schedule(static)
67 for (dim_t i = 0; i < B->numOutput; i++) {
68 index_t iptrA = A->ptr[i];
69 index_t iptrB = B->ptr[i];
70
71 while (iptrA < A->ptr[i+1] && iptrB < B->ptr[i+1]) {
72 const dim_t j = A->index[iptrA];
73 const dim_t k = B->index[iptrB];
74 if (j < k) {
75 Paso_IndexListArray_insertIndex(index_list, i, j);
76 iptrA++;
77 } else if (j > k) {
78 Paso_IndexListArray_insertIndex(index_list, i, k);
79 iptrB++;
80 } else { // (j == k)
81 Paso_IndexListArray_insertIndex(index_list, i, j);
82 iptrB++;
83 iptrA++;
84 }
85 }
86 while(iptrA < A->ptr[i+1]) {
87 const dim_t j = A->index[iptrA];
88 Paso_IndexListArray_insertIndex(index_list, i, j);
89 iptrA++;
90 }
91 while(iptrB < B->ptr[i+1]) {
92 const dim_t k = B->index[iptrB];
93 Paso_IndexListArray_insertIndex(index_list, i, k);
94 iptrB++;
95 }
96 }
97
98 Pattern* out=Pattern_fromIndexListArray(0, index_list, 0, A->numInput, 0);
99
100 Paso_IndexListArray_free(index_list);
101 return out;
102 }
103
104 } // namespace paso
105

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26