GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ATLAS_wrapper_blas_level_1.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 2006
6 * soerengebbert <at> gmx <dot> de
7 *
8 * PURPOSE: blas level 1 like functions
9 * part of the gpde library
10 *
11 * COPYRIGHT: (C) 2000 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 <grass/gmath.h>
24 
25 #if defined(HAVE_ATLAS)
26 #include <cblas.h>
27 #endif
28 
29 
44 double G_math_ddot(double *x, double *y, int rows)
45 {
46 #if defined(HAVE_ATLAS)
47  return cblas_ddot(rows, x, 1, y, 1);
48 #else
49  double val;
50 
51  G_math_d_x_dot_y(x, y, &val, rows);
52  return val;
53 #endif
54 }
55 
56 
72 float G_math_sdsdot(float *x, float *y, float a, int rows)
73 {
74 #if defined(HAVE_ATLAS)
75  return cblas_sdsdot(rows, a, x, 1, y, 1);
76 #else
77  float val;
78 
79  G_math_f_x_dot_y(x, y, &val, rows);
80  return a + val;
81 #endif
82 }
83 
97 double G_math_dnrm2(double *x, int rows)
98 {
99 #if defined(HAVE_ATLAS)
100  return cblas_dnrm2(rows, x, 1);
101 #else
102  double val;
103 
104  G_math_d_euclid_norm(x, &val, rows);
105  return val;
106 #endif
107 }
108 
122 double G_math_dasum(double *x, int rows)
123 {
124 #if defined(HAVE_ATLAS)
125  return cblas_dasum(rows, x, 1);
126 #else
127  double val;
128 
129  G_math_d_asum_norm(x, &val, rows);
130  return val;
131 #endif
132 }
133 
147 double G_math_idamax(double *x, int rows)
148 {
149 #if defined(HAVE_ATLAS)
150  return cblas_idamax(rows, x, 1);
151 #else
152  double val;
153 
154  G_math_d_max_norm(x, &val, rows);
155  return val;
156 #endif
157 }
158 
172 void G_math_dscal(double *x, double a, int rows)
173 {
174 #if defined(HAVE_ATLAS)
175  cblas_dscal(rows, a, x, 1);
176 #else
177  G_math_d_ax_by(x, x, x, a, 0.0, rows);
178 #endif
179 
180  return;
181 }
182 
195 void G_math_dcopy(double *x, double *y, int rows)
196 {
197 #if defined(HAVE_ATLAS)
198  cblas_dcopy(rows, x, 1, y, 1);
199 #else
200  G_math_d_copy(x, y, rows);
201 #endif
202 
203  return;
204 }
205 
206 
224 void G_math_daxpy(double *x, double *y, double a, int rows)
225 {
226 #if defined(HAVE_ATLAS)
227  cblas_daxpy(rows, a, x, 1, y, 1);
228 #else
229  G_math_d_ax_by(x, y, y, a, 1.0, rows);
230 #endif
231 
232  return;
233 }
234 
235 /****************************************************************** */
236 
237 /********* F L O A T / S I N G L E P E P R E C I S I O N ******** */
238 
239 /****************************************************************** */
240 
255 float G_math_sdot(float *x, float *y, int rows)
256 {
257 #if defined(HAVE_ATLAS)
258  return cblas_sdot(rows, x, 1, y, 1);
259 #else
260  float val;
261 
262  G_math_f_x_dot_y(x, y, &val, rows);
263  return val;
264 #endif
265 }
266 
280 float G_math_snrm2(float *x, int rows)
281 {
282 #if defined(HAVE_ATLAS)
283  return cblas_snrm2(rows, x, 1);
284 #else
285  float val;
286 
287  G_math_f_euclid_norm(x, &val, rows);
288  return val;
289 #endif
290 }
291 
305 float G_math_sasum(float *x, int rows)
306 {
307 #if defined(HAVE_ATLAS)
308  return cblas_sasum(rows, x, 1);
309 #else
310  float val;
311 
312  G_math_f_asum_norm(x, &val, rows);
313  return val;
314 #endif
315 }
316 
330 float G_math_isamax(float *x, int rows)
331 {
332 #if defined(HAVE_ATLAS)
333  return cblas_isamax(rows, x, 1);
334 #else
335  float val;
336 
337  G_math_f_max_norm(x, &val, rows);
338  return val;
339 #endif
340 }
341 
355 void G_math_sscal(float *x, float a, int rows)
356 {
357 #if defined(HAVE_ATLAS)
358  cblas_sscal(rows, a, x, 1);
359 #else
360  G_math_f_ax_by(x, x, x, a, 0.0, rows);
361 #endif
362 
363  return;
364 }
365 
379 void G_math_scopy(float *x, float *y, int rows)
380 {
381 #if defined(HAVE_ATLAS)
382  cblas_scopy(rows, x, 1, y, 1);
383 #else
384  G_math_f_copy(x, y, rows);
385 #endif
386 
387  return;
388 }
389 
390 
408 void G_math_saxpy(float *x, float *y, float a, int rows)
409 {
410 #if defined(HAVE_ATLAS)
411  cblas_saxpy(rows, a, x, 1, y, 1);
412 #else
413  G_math_f_ax_by(x, y, y, a, 1.0, rows);
414 #endif
415 
416  return;
417 }
void G_math_f_x_dot_y(float *x, float *y, float *value, int rows)
Compute the dot product of vector x and y.
Definition: blas_level_1.c:263
void G_math_daxpy(double *x, double *y, double a, int rows)
Scale vector x with scalar a and add it to y.
void G_math_dcopy(double *x, double *y, int rows)
Copy vector x to vector y.
void G_math_dscal(double *x, double a, int rows)
Scale vector x with scalar a using the ATLAS routine cblas_dscal.
void G_math_f_ax_by(float *x, float *y, float *z, float a, float b, int rows)
Scales vectors x and y with the scalars a and b and adds them.
Definition: blas_level_1.c:391
void G_math_d_max_norm(double *x, double *value, int rows)
Compute the maximum norm of vector x.
Definition: blas_level_1.c:141
double G_math_dnrm2(double *x, int rows)
Compute the euclidean norm of vector x using the ATLAS routine cblas_dnrm2.
float G_math_sdsdot(float *x, float *y, float a, int rows)
Compute the dot product of vector x and y using the ATLAS routine cblas_sdsdot.
void G_math_d_x_dot_y(double *x, double *y, double *value, int rows)
Compute the dot product of vector x and y.
Definition: blas_level_1.c:47
void G_math_scopy(float *x, float *y, int rows)
Copy vector x to vector y.
double G_math_idamax(double *x, int rows)
Compute the maximum norm of vector x using the ATLAS routine cblas_idamax.
void G_math_f_copy(float *x, float *y, int rows)
Copy the vector x to y.
Definition: blas_level_1.c:454
int y
Definition: plot.c:34
void G_math_saxpy(float *x, float *y, float a, int rows)
Scale vector x with scalar a and add it to y.
void G_math_f_max_norm(float *x, float *value, int rows)
Compute the maximum norm of vector x.
Definition: blas_level_1.c:360
void G_math_f_asum_norm(float *x, float *value, int rows)
Compute the asum norm of vector x.
Definition: blas_level_1.c:327
float G_math_sasum(float *x, int rows)
Compute the absolute sum norm of vector x using the ATLAS routine cblas_dasum.
void G_math_d_euclid_norm(double *x, double *value, int rows)
Compute the euclid norm of vector x.
Definition: blas_level_1.c:79
double G_math_dasum(double *x, int rows)
Compute the absolute sum norm of vector x using the ATLAS routine cblas_dasum.
void G_math_d_copy(double *x, double *y, int rows)
Copy the vector x to y.
Definition: blas_level_1.c:236
void G_math_d_asum_norm(double *x, double *value, int rows)
Compute the asum norm of vector x.
Definition: blas_level_1.c:111
double G_math_ddot(double *x, double *y, int rows)
Compute the dot product of vector x and y using the ATLAS routine cblas_ddot.
void G_math_sscal(float *x, float a, int rows)
Scale vector x with scalar a using the ATLAS routine cblas_dscal.
float G_math_snrm2(float *x, int rows)
Compute the euclidean norm of vector x using the ATLAS routine cblas_dnrm2.
void G_math_f_euclid_norm(float *x, float *value, int rows)
Compute the euclid norm of vector x.
Definition: blas_level_1.c:295
void G_math_d_ax_by(double *x, double *y, double *z, double a, double b, int rows)
Scales vectors x and y with the scalars a and b and adds them.
Definition: blas_level_1.c:172
float G_math_isamax(float *x, int rows)
Compute the maximum norm of vector x using the ATLAS routine cblas_idamax.
float G_math_sdot(float *x, float *y, int rows)
Compute the dot product of vector x and y using the ATLAS routine cblas_sdot.