GRASS Programmer's Manual  6.5.svn(2014)-r66266
blas_level_3.c
Go to the documentation of this file.
1
2 /*****************************************************************************
3 *
4 * MODULE: Grass PDE Numerical Library
5 * AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2007
6 * soerengebbert <at> gmx <dot> de
7 *
8 * PURPOSE: linear equation system solvers
9 * part of the gpde library
10 *
11 * COPYRIGHT: (C) 2007 by the GRASS Development Team
12 *
13 * This program is free software under the GNU General Public
14 * License (>=v2). Read the file COPYING that comes with GRASS
15 * for details.
16 *
17 *****************************************************************************/
18
19 #include <math.h>
20 #include <unistd.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include "grass/gmath.h"
25 #include <grass/gis.h>
26
27
50 void G_math_d_aA_B(double **A, double **B, double a, double **C, int rows,
51  int cols)
52 {
53  int i, j;
54
55
56  /*If B is null, scale the matrix A with th scalar a */
57  if (B == NULL) {
58 #pragma omp for schedule (static) private(i, j)
59  for (i = rows - 1; i >= 0; i--)
60  for (j = cols - 1; j >= 0; j--)
61  C[i][j] = a * A[i][j];
62
63  return;
64  }
65
66  /*select special cases */
67  if (a == 1.0) {
68 #pragma omp for schedule (static) private(i, j)
69  for (i = rows - 1; i >= 0; i--)
70  for (j = cols - 1; j >= 0; j--)
71  C[i][j] = A[i][j] + B[i][j];
72  }
73  else if (a == -1.0) {
74 #pragma omp for schedule (static) private(i, j)
75  for (i = rows - 1; i >= 0; i--)
76  for (j = cols - 1; j >= 0; j--)
77  C[i][j] = B[i][j] - A[i][j];
78  }
79  else {
80 #pragma omp for schedule (static) private(i, j)
81  for (i = rows - 1; i >= 0; i--)
82  for (j = cols - 1; j >= 0; j--)
83  C[i][j] = a * A[i][j] + B[i][j];
84  }
85
86  return;
87 }
88
113 void G_math_f_aA_B(float **A, float **B, float a, float **C, int rows,
114  int cols)
115 {
116  int i, j;
117
118  /*If B is null, scale the matrix A with th scalar a */
119  if (B == NULL) {
120 #pragma omp for schedule (static) private(i, j)
121  for (i = rows - 1; i >= 0; i--)
122  for (j = cols - 1; j >= 0; j--)
123  C[i][j] = a * A[i][j];
124  return;
125  }
126
127  /*select special cases */
128  if (a == 1.0) {
129 #pragma omp for schedule (static) private(i, j)
130  for (i = rows - 1; i >= 0; i--)
131  for (j = cols - 1; j >= 0; j--)
132  C[i][j] = A[i][j] + B[i][j];
133  }
134  else if (a == -1.0) {
135 #pragma omp for schedule (static) private(i, j)
136  for (i = rows - 1; i >= 0; i--)
137  for (j = cols - 1; j >= 0; j--)
138  C[i][j] = B[i][j] - A[i][j];
139  }
140  else {
141 #pragma omp for schedule (static) private(i, j)
142  for (i = rows - 1; i >= 0; i--)
143  for (j = cols - 1; j >= 0; j--)
144  C[i][j] = a * A[i][j] + B[i][j];
145  }
146
147  return;
148 }
149
150
174 void G_math_d_AB(double **A, double **B, double **C, int rows_A,
175  int cols_A, int rows_B)
176 {
177  int i, j, k;
178
179 #pragma omp for schedule (static) private(i, j, k)
180  for (i = 0; i < rows_A; i++) {
181  for (j = 0; j < rows_B; j++) {
182  C[i][j] = 0.0;
183  for (k = cols_A - 1; k >= 0; k--) {
184  C[i][j] += A[i][k] * B[k][j];
185  }
186  }
187  }
188
189  return;
190 }
191
215 void G_math_f_AB(float **A, float **B, float **C, int rows_A,
216  int cols_A, int rows_B)
217 {
218  int i, j, k;
219
220 #pragma omp for schedule (static) private(i, j, k)
221  for (i = 0; i < rows_A; i++) {
222  for (j = 0; j < rows_B; j++) {
223  C[i][j] = 0.0;
224  for (k = cols_A - 1; k >= 0; k--) {
225  C[i][j] += A[i][k] * B[k][j];
226  }
227  }
228  }
229
230  return;
231 }
void G_math_f_aA_B(float **A, float **B, float a, float **C, int rows, int cols)
Add two matrices and scale matrix A with the scalar a.
Definition: blas_level_3.c:113
#define C
Definition: intr_char.c:17
void G_math_f_AB(float **A, float **B, float **C, int rows_A, int cols_A, int rows_B)
Matrix multiplication.
Definition: blas_level_3.c:215
return NULL
Definition: dbfopen.c:1394
void G_math_d_AB(double **A, double **B, double **C, int rows_A, int cols_A, int rows_B)
Matrix multiplication.
Definition: blas_level_3.c:174
tuple cols
void G_math_d_aA_B(double **A, double **B, double a, double **C, int rows, int cols)
Add two matrices and scale matrix A with the scalar a.
Definition: blas_level_3.c:50