]>
Commit | Line | Data |
---|---|---|
6de9cd9a DN |
1 | /* Implementation of the DOT_PRODUCT intrinsic |
2 | Copyright 2002 Free Software Foundation, Inc. | |
3 | Contributed by Paul Brook <paul@nowt.org> | |
4 | ||
5 | This file is part of the GNU Fortran 95 runtime library (libgfor). | |
6 | ||
7 | Libgfortran is free software; you can redistribute it and/or | |
8 | modify it under the terms of the GNU Lesser General Public | |
9 | License as published by the Free Software Foundation; either | |
10 | version 2.1 of the License, or (at your option) any later version. | |
11 | ||
12 | Libgfortran is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public | |
18 | License along with libgfor; see the file COPYING.LIB. If not, | |
19 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "config.h" | |
23 | #include <stdlib.h> | |
24 | #include <assert.h> | |
25 | #include "libgfortran.h" | |
26 | ||
7f68c75f RH |
27 | extern GFC_LOGICAL_4 dot_product_l4 (gfc_array_l4 *, gfc_array_l4 *); |
28 | export_proto(dot_product_l4); | |
7d7b8bfe | 29 | |
6de9cd9a | 30 | GFC_LOGICAL_4 |
7f68c75f | 31 | dot_product_l4 (gfc_array_l4 * a, gfc_array_l4 * b) |
6de9cd9a DN |
32 | { |
33 | GFC_LOGICAL_4 *pa; | |
34 | GFC_LOGICAL_4 *pb; | |
35 | index_type count; | |
36 | index_type astride; | |
37 | index_type bstride; | |
38 | ||
39 | assert (GFC_DESCRIPTOR_RANK (a) == 1 | |
40 | && GFC_DESCRIPTOR_RANK (b) == 1); | |
41 | ||
42 | if (a->dim[0].stride == 0) | |
43 | a->dim[0].stride = 1; | |
44 | if (b->dim[0].stride == 0) | |
45 | b->dim[0].stride = 1; | |
46 | ||
47 | astride = a->dim[0].stride; | |
48 | bstride = b->dim[0].stride; | |
49 | count = a->dim[0].ubound + 1 - a->dim[0].lbound; | |
50 | ||
51 | pa = a->data; | |
52 | if (GFC_DESCRIPTOR_SIZE (a) != 4) | |
53 | { | |
54 | assert (GFC_DESCRIPTOR_SIZE (a) == 8); | |
55 | pa = GFOR_POINTER_L8_TO_L4 (pa); | |
56 | astride <<= 1; | |
57 | } | |
58 | pb = b->data; | |
59 | if (GFC_DESCRIPTOR_SIZE (b) != 4) | |
60 | { | |
61 | assert (GFC_DESCRIPTOR_SIZE (b) == 8); | |
62 | pb = GFOR_POINTER_L8_TO_L4 (pb); | |
63 | bstride <<= 1; | |
64 | } | |
65 | ||
66 | while (count--) | |
67 | { | |
68 | if (*pa && *pb) | |
69 | return 1; | |
70 | ||
71 | pa += astride; | |
72 | pb += bstride; | |
73 | } | |
74 | ||
75 | return 0; | |
76 | } |