Mercurial > octave
annotate liboctave/operators/mk-ops.awk @ 29357:bbbe4dcc7200 stable
use the same comment style for copyright headers in .m files and shell scripts
In files that use '#' for comments, use '##' at the beginning of lines
in copyright headers.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 09:44:29 -0500 |
parents | bd51beb6205e |
children | 0a5b15007766 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 ## Copyright (C) 2003-2020 The Octave Project Developers |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
4 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
7 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
8 ## This file is part of Octave. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
9 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
13 ## (at your option) any later version. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
14 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
18 ## GNU General Public License for more details. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
19 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
23 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
7019 | 25 |
4544 | 26 BEGIN { |
27 declare_types = 0; | |
28 generate_ops = 0; | |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
29 op_class = ""; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
30 sparse = 0; |
4544 | 31 ntypes = 0; |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
32 make_inclusive_header = 0; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
33 make_header = 0; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
34 make_source = 0; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
35 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
36 if (build_file) |
4544 | 37 { |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
38 if (build_file == "mx-ops.h" || build_file == "smx-ops.h" || build_file == "vx-ops.h") |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
39 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
40 make_inclusive_header = 1; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
41 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
42 print "// DO NOT EDIT -- generated by mk-ops.awk"; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
43 tmp = build_file; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
44 prefix = substr (tmp, 1, index (tmp, "-")-1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
45 gsub (/[\.-]/, "_", tmp); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
46 printf ("#if ! defined (octave_%s)\n", tmp); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
47 printf ("#define octave_%s 1\n", tmp); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
48 print "#include \"octave-config.h\""; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
49 } |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
50 else |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
51 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
52 if (match (build_file, /\.h$/)) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
53 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
54 make_header = 1; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
55 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
56 tmp = substr (build_file, 1, length (build_file)-2); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
57 } |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
58 else if (match (build_file, /\.cc$/)) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
59 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
60 make_source = 1; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
61 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
62 tmp = substr (build_file, 1, length (build_file)-3); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
63 } |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
64 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
65 prefix = substr (tmp, 1, index (tmp, "-")-1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
66 tmp = substr (tmp, index (tmp, "-")+1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
67 lhs_arg = substr (tmp, 1, index (tmp, "-")-1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
68 rhs_arg = substr (tmp, index (tmp, "-")+1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
69 } |
4544 | 70 } |
71 } | |
4547 | 72 /^#/ { |
73 if ($2 == "types") | |
74 declare_types = 1; | |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
75 else if ($3 == "operators") |
4547 | 76 { |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
77 op_class = $2; |
4547 | 78 generate_ops = 1; |
79 declare_types = 0; | |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
80 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
81 if (op_class == "vector") |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
82 sparse = 0; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
83 else if (op_class == "full-matrix") |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
84 sparse = 0; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
85 else if (op_class == "sparse-matrix") |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
86 sparse = 1; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
87 else |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
88 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
89 printf ("unrecognized object type: %s", op_class); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
90 exit (1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
91 } |
4547 | 92 } |
93 next; | |
94 } { | |
4544 | 95 if (declare_types) |
96 { | |
97 ntypes++; | |
98 | |
25665
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
99 if (NF == 5 || NF == 6) |
4544 | 100 { |
25665
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
101 if (NF == 6) |
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
102 core_type[ntypes] = $6; |
6119 | 103 |
4544 | 104 fwd_decl_ok[ntypes] = $5 == "YES"; |
105 header[ntypes] = $4 == "NONE" ? "" : $4; | |
106 class[ntypes] = $3; | |
107 type[ntypes] = $2; | |
108 tag[ntypes] = $1; | |
109 rev_tag[$1] = ntypes; | |
110 } | |
111 else | |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
112 printf ("skipping line %d: %s\n", NR, $0); |
4544 | 113 } |
114 else if (generate_ops) | |
115 { | |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
116 if (NF >= 4 || (sparse && NF >= 5)) |
4544 | 117 { |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
118 n = 0; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
119 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
120 result_tag_1 = $(++n); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
121 if (sparse) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
122 result_tag_2 = $(++n); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
123 lhs_tag = $(++n); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
124 rhs_tag = $(++n); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
125 op_type = $(++n); |
4544 | 126 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
127 bin_ops = index (op_type, "B") != 0; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
128 cmp_ops = index (op_type, "C") != 0; |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
129 eqne_ops = index (op_type, "E") != 0; |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
130 bool_ops = index (op_type, "L") != 0; |
4544 | 131 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
132 k = 0 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
133 while (NF > n) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
134 bool_headers[k++] = $(++n); |
4544 | 135 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
136 cc_file = sprintf ("%s-%s-%s.cc", prefix, lhs_tag, rhs_tag); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
137 h_file = sprintf ("%s-%s-%s.h", prefix, lhs_tag, rhs_tag); |
4544 | 138 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
139 if (list_cc_files) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
140 { |
20327
0ce7d8303152
eliminate recursive make invocations in liboctave and libinterp directories
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
141 printf (" liboctave/operators/%s", cc_file); |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
142 next; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
143 } |
4544 | 144 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
145 if (list_h_files) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
146 { |
20327
0ce7d8303152
eliminate recursive make invocations in liboctave and libinterp directories
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
147 printf (" liboctave/operators/%s", h_file); |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
148 next; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
149 } |
4544 | 150 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
151 if (make_inclusive_header) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
152 { |
4547 | 153 printf ("#include \"%s\"\n", h_file); |
154 next; | |
155 } | |
4544 | 156 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
157 if (lhs_arg != lhs_tag || rhs_arg != rhs_tag) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
158 next; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
159 |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
160 h_guard = sprintf ("octave_%s_%s_%s_h", prefix, lhs_tag, rhs_tag); |
4544 | 161 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
162 result_num_1 = rev_tag[result_tag_1]; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
163 if (sparse) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
164 result_num_2 = rev_tag[result_tag_2]; |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
165 lhs_num = rev_tag[lhs_tag]; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
166 rhs_num = rev_tag[rhs_tag]; |
4544 | 167 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
168 result_type_1 = type[result_num_1]; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
169 if (sparse) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
170 result_type_2 = type[result_num_2]; |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
171 lhs_type = type[lhs_num]; |
4544 | 172 rhs_type = type[rhs_num]; |
173 | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
174 lhs_core_type = core_type[lhs_num]; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
175 rhs_core_type = core_type[rhs_num]; |
6119 | 176 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
177 result_header_1 = header[result_num_1]; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
178 if (sparse) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
179 result_header_2 = header[result_num_2]; |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
180 lhs_header = header[lhs_num]; |
4544 | 181 rhs_header = header[rhs_num]; |
182 | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
183 lhs_class = class[lhs_num]; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
184 rhs_class = class[rhs_num]; |
4544 | 185 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
186 if (make_header) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
9578
diff
changeset
|
187 { |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
188 print "// DO NOT EDIT -- generated by mk-ops.awk"; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
189 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
190 printf ("#if ! defined (%s)\n", h_guard); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
191 printf ("#define %s 1\n", h_guard); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
192 print "#include \"octave-config.h\""; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
193 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
194 if (result_header_1) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
195 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
196 if (result_fwd_decl_ok) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
197 printf ("class %s\n", result_type_1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
198 else |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
199 printf ("#include \"%s\"\n", result_header_1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
200 } |
4544 | 201 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
202 if (result_header_2 && ! (result_header_2 == result_header_1)) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
203 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
204 if (result_fwd_decl_ok) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
205 printf ("class %s\n", result_type_2); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
206 else |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
207 printf ("#include \"%s\"\n", result_header_2); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
208 } |
4544 | 209 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
210 if (lhs_header && ! (lhs_header == result_header_1 || lhs_header == result_header_2)) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
211 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
212 if (result_fwd_decl_ok) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
213 printf ("class %s\n", lhs_type); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
214 else |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
215 printf ("#include \"%s\"\n", lhs_header); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
216 } |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
217 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
218 if (rhs_header && ! (rhs_header == lhs_header || rhs_header == result_header_1 || rhs_header == result_header_2)) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
219 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
220 if (result_fwd_decl_ok) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
221 printf ("class %s\n", rhs_type); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
222 else |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
223 printf ("#include \"%s\"\n", rhs_header); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
224 } |
4964 | 225 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
226 if (sparse) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
227 { |
21784
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
228 lhs_is_sparse = 0; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
229 rhs_is_sparse = 0; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
230 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
231 xlhs_tag = "NONE"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
232 xrhs_tag = "NONE"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
233 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
234 if (lhs_tag == "sbm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
235 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
236 lhs_is_sparse = 1; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
237 xlhs_tag = "b"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
238 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
239 else if (lhs_tag == "scm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
240 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
241 lhs_is_sparse = 1; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
242 xlhs_tag = "cs"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
243 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
244 else if (lhs_tag == "sm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
245 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
246 lhs_is_sparse = 1; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
247 xlhs_tag = "s"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
248 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
249 else if (lhs_tag == "bm" || lhs_tag == "cm" || lhs_tag == "m") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
250 xlhs_tag = lhs_tag; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
251 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
252 if (rhs_tag == "sbm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
253 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
254 rhs_is_sparse = 1; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
255 xrhs_tag = "b"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
256 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
257 else if (rhs_tag == "scm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
258 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
259 rhs_is_sparse = 1; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
260 xrhs_tag = "cs"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
261 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
262 else if (rhs_tag == "sm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
263 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
264 rhs_is_sparse = 1; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
265 xrhs_tag = "s"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
266 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
267 else if (rhs_tag == "bm" || rhs_tag == "cm" || rhs_tag == "m") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
268 xrhs_tag = rhs_tag; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
269 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
270 same_types = ((xlhs_tag == "b" && xrhs_tag == "bm") || (xlhs_tag == "cs" && xrhs_tag == "cm") || (xlhs_tag == "s" && xrhs_tag == "m") || (xlhs_tag == "bm" && xrhs_tag == "b") || (xlhs_tag == "cm" && xrhs_tag == "cs") || (xlhs_tag == "m" && xrhs_tag == "s")); |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
271 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
272 if (! (same_types || (rhs_is_sparse && lhs_is_sparse) || xlhs_tag == "NONE" || xrhs_tag == "NONE")) |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
273 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
274 printf ("#include \"mx-%s-%s.h\"\n", xlhs_tag, xrhs_tag); |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
275 printf ("#include \"mx-%s-%s.h\"\n", xrhs_tag, xlhs_tag); |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
276 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
277 xxlhs_tag = xlhs_tag; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
278 xxrhs_tag = xrhs_tag; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
279 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
280 if (xxlhs_tag == "cs") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
281 xxlhs_tag = "cm"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
282 else if (xxlhs_tag == "s") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
283 xxlhs_tag = "m"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
284 else if (xxlhs_tag == "b") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
285 xxlhs_tag = "NONE"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
286 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
287 if (xxrhs_tag == "cs") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
288 xxrhs_tag = "cm"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
289 else if (xxrhs_tag == "s") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
290 xxrhs_tag = "m"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
291 else if (xxrhs_tag == "b") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
292 xxrhs_tag = "NONE"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
293 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
294 if (! (xxlhs_tag == "NONE" || xxrhs_tag == "NONE" || xxlhs_tag == xxrhs_tag)) |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
295 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
296 printf ("#include \"mx-%s-%s.h\"\n", xxlhs_tag, xxrhs_tag); |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
297 printf ("#include \"mx-%s-%s.h\"\n", xxrhs_tag, xxlhs_tag); |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
298 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
299 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
300 xxlhs_tag = xlhs_tag; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
301 xxrhs_tag = xrhs_tag; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
302 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
303 if (xxlhs_tag == "m") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
304 xxlhs_tag = "nda"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
305 else if (xxlhs_tag == "cm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
306 xxlhs_tag = "cnda"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
307 else if (xxlhs_tag == "bm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
308 xxlhs_tag = "NONE"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
309 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
310 if (xxrhs_tag == "m") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
311 xxrhs_tag = "nda"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
312 else if (xxrhs_tag == "cm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
313 xxrhs_tag = "cnda"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
314 else if (xxrhs_tag == "bm") |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
315 xxrhs_tag = "NONE"; |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
316 |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
317 if (! (xxlhs_tag == "NONE" || xxrhs_tag == "NONE")) |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
318 { |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
319 printf ("#include \"mx-%s-%s.h\"\n", xxlhs_tag, xxrhs_tag); |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
320 printf ("#include \"mx-%s-%s.h\"\n", xxrhs_tag, xxlhs_tag); |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
321 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
322 } |
d13883644981
avoid including mx-ops.h in every generated sparse ops file
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
323 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
324 printf ("#include \"Sparse-op-defs.h\"\n"); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
325 } |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
326 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
327 if (bin_ops) |
25662 | 328 emit_bin_op_decls(sparse, lhs_class, rhs_class, |
329 result_type_1, result_type_2, | |
330 lhs_type, rhs_type); | |
4964 | 331 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
332 if (cmp_ops) |
25662 | 333 emit_cmp_op_decls(sparse, lhs_class, rhs_class, |
334 lhs_type, rhs_type); | |
4544 | 335 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
336 if (eqne_ops) |
25662 | 337 emit_eqne_op_decls(sparse, lhs_class, rhs_class, |
338 lhs_type, rhs_type); | |
4544 | 339 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
340 if (bool_ops) |
25662 | 341 emit_bool_op_decls(sparse, lhs_class, rhs_class, |
342 lhs_type, rhs_type); | |
4544 | 343 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
344 print "#endif"; |
4544 | 345 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
346 exit (0); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
347 } |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
348 else if (make_source) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
349 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
350 print "// DO NOT EDIT -- generated by mk-ops.awk"; |
4544 | 351 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
352 print "#if defined (HAVE_CONFIG_H)"; |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21247
diff
changeset
|
353 print "# include \"config.h\""; |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
354 print "#endif"; |
4669 | 355 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
356 print "#include \"Array-util.h\""; |
4544 | 357 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
358 printf ("#include \"%s\"\n", h_file); |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
7019
diff
changeset
|
359 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
360 if (! sparse) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
361 printf ("#include \"mx-op-defs.h\"\n"); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
362 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
363 for (i in bool_headers) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
364 { |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
365 printf ("#include \"%s\"\n", bool_headers[i]); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
366 delete bool_headers[i]; |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
367 } |
4544 | 368 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
369 if (result_header_1) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
370 printf ("#include \"%s\"\n", result_header_1); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
371 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
372 if (result_header_2 && ! (result_header_2 == result_header_1)) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
373 printf ("#include \"%s\"\n", result_header_2); |
4544 | 374 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
375 if (lhs_header && ! (lhs_header == result_header_1 || lhs_header == result_header_2)) |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
376 printf ("#include \"%s\"\n", lhs_header); |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
377 |
25662 | 378 if (rhs_header && ! (rhs_header == lhs_header || rhs_header == result_header_1 || rhs_header == result_header_2)) |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
379 printf ("#include \"%s\"\n", rhs_header); |
4544 | 380 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
381 if (bin_ops) |
25662 | 382 emit_bin_ops(sparse, lhs_class, rhs_class, |
25663
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
383 result_type_1, result_type_2, lhs_type, rhs_type); |
4544 | 384 |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
385 if (cmp_ops) |
25665
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
386 emit_cmp_ops(sparse, lhs_class, rhs_class, lhs_type, rhs_type); |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
387 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
388 if (eqne_ops) |
25662 | 389 emit_eqne_ops(sparse, lhs_class, rhs_class, |
25665
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
390 lhs_type, rhs_type); |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
391 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
392 if (bool_ops) |
25662 | 393 emit_bool_ops(sparse, lhs_class, rhs_class, |
25663
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
394 lhs_type, rhs_type); |
21247
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
395 |
7be239ae42c8
merge sparse-mk-ops.awk and mk-ops.awk scripts
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
396 exit (0); |
4544 | 397 } |
398 } | |
399 else | |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
400 printf ("skipping line %d: %s\n", NR, $0); |
4544 | 401 } |
402 } | |
403 END { | |
404 if (make_inclusive_header) | |
405 print "#endif"; | |
4547 | 406 } |
25662 | 407 |
408 function emit_bin_op_decl (result_type, operator, lhs_type, rhs_type) | |
409 { | |
410 if (operator != "") | |
411 printf (" extern OCTAVE_API %s %s (const %s&, const %s&);\n", | |
412 result_type, operator, lhs_type, rhs_type); | |
413 } | |
414 | |
415 function emit_bin_op_decls_1 (result_type, lhs_type, rhs_type, | |
416 add_op, sub_op, mul_op, div_op) | |
417 { | |
418 emit_bin_op_decl(result_type, add_op, lhs_type, rhs_type); | |
419 emit_bin_op_decl(result_type, sub_op, lhs_type, rhs_type); | |
420 emit_bin_op_decl(result_type, mul_op, lhs_type, rhs_type); | |
421 emit_bin_op_decl(result_type, div_op, lhs_type, rhs_type); | |
422 } | |
423 | |
424 function emit_sparse_bin_op_decls (result_type_1, result_type_2, | |
425 lhs_type, rhs_type, | |
426 add_op, sub_op, mul_op, div_op) | |
427 { | |
428 emit_bin_op_decl(result_type_1, add_op, lhs_type, rhs_type); | |
429 emit_bin_op_decl(result_type_1, sub_op, lhs_type, rhs_type); | |
430 emit_bin_op_decl(result_type_2, mul_op, lhs_type, rhs_type); | |
431 emit_bin_op_decl(result_type_2, div_op, lhs_type, rhs_type); | |
432 } | |
433 | |
434 function emit_bin_op_decls (sparse, lhs_class, rhs_class, | |
435 result_type_1, result_type_2, | |
436 lhs_type, rhs_type) | |
437 { | |
438 if (sparse) | |
439 { | |
440 if ((lhs_class == "SM" && rhs_class == "S") \ | |
441 || (lhs_class == "S" && rhs_class == "SM")) | |
442 emit_sparse_bin_op_decls(result_type_1, result_type_2, | |
443 lhs_type, rhs_type, | |
444 "operator +", "operator -", | |
445 "operator *", "operator /"); | |
446 | |
447 else if ((lhs_class == "M" && rhs_class == "SM") \ | |
448 || (lhs_class == "SM" && rhs_class == "M") \ | |
449 || (lhs_class == "SM" && rhs_class == "SM")) | |
450 emit_sparse_bin_op_decls(result_type_1, result_type_2, | |
451 lhs_type, rhs_type, | |
452 "operator +", "operator -", | |
453 "product", "quotient"); | |
454 } | |
455 else | |
456 { | |
457 if ((lhs_class == "M" && rhs_class == "S") \ | |
458 || (lhs_class == "ND" && rhs_class == "S") \ | |
459 || (lhs_class == "S" \ | |
460 && (rhs_class == "M" || rhs_class == "ND" || rhs_class == "V")) \ | |
461 || (lhs_class == "V" && rhs_class == "S")) | |
462 emit_bin_op_decls_1(result_type_1, lhs_type, rhs_type, | |
463 "operator +", "operator -", | |
464 "operator *", "operator /"); | |
465 | |
466 else if ((lhs_class == "M" && rhs_class == "M") \ | |
467 || (lhs_class == "ND" && rhs_class == "ND") \ | |
468 || (lhs_class == "V" && rhs_class == "V")) | |
469 emit_bin_op_decls_1(result_type_1, lhs_type, rhs_type, | |
470 "operator +", "operator -", | |
471 "product", "quotient"); | |
472 | |
473 else if ((lhs_class == "DM" && rhs_class == "M") \ | |
474 || (lhs_class == "M" && rhs_class == "DM")) | |
475 emit_bin_op_decls_1(result_type_1, lhs_type, rhs_type, | |
476 "operator +", "operator -", "operator *", ""); | |
477 | |
478 else if (lhs_class == "DM" && rhs_class == "DM") | |
479 emit_bin_op_decls_1(result_type_1, lhs_type, rhs_type, | |
480 "operator +", "operator -", "product", ""); | |
481 | |
482 else if (lhs_class == "DM" && rhs_class == "S") | |
483 emit_bin_op_decls_1(result_type_1, lhs_type, rhs_type, | |
484 "", "", "operator *", "operator /"); | |
485 | |
486 else if ((lhs_class == "M" && rhs_class == "PM") \ | |
487 || (lhs_class == "PM" && rhs_class == "M") \ | |
488 || (lhs_class == "S" && rhs_class == "DM")) | |
489 emit_bin_op_decls_1(result_type_1, lhs_type, rhs_type, | |
490 "", "", "operator *", ""); | |
491 } | |
492 } | |
493 | |
494 function emit_cmp_op_decls_1(result_type, lhs_type, rhs_type) | |
495 { | |
496 emit_bin_op_decl(result_type, "mx_el_lt", lhs_type, rhs_type); | |
497 emit_bin_op_decl(result_type, "mx_el_le", lhs_type, rhs_type); | |
498 emit_bin_op_decl(result_type, "mx_el_ge", lhs_type, rhs_type); | |
499 emit_bin_op_decl(result_type, "mx_el_gt", lhs_type, rhs_type); | |
500 emit_bin_op_decl(result_type, "mx_el_eq", lhs_type, rhs_type); | |
501 emit_bin_op_decl(result_type, "mx_el_ne", lhs_type, rhs_type); | |
502 } | |
503 | |
504 function emit_cmp_op_decls (sparse, lhs_class, rhs_class, lhs_type, rhs_type) | |
505 { | |
506 if (sparse) | |
507 { | |
508 if ((lhs_class == "M" && rhs_class == "SM") \ | |
509 || (lhs_class == "SM" && (rhs_class == "M" || rhs_class == "S" || rhs_class == "SM")) \ | |
510 || (lhs_class == "S" && rhs_class == "SM")) | |
511 emit_cmp_op_decls_1("SparseBoolMatrix", lhs_type, rhs_type); | |
512 } | |
513 else | |
514 { | |
515 if ((lhs_class == "M" && rhs_class == "M") \ | |
516 || (lhs_class == "M" && rhs_class == "S") \ | |
517 || (lhs_class == "S" && rhs_class == "M")) | |
518 emit_cmp_op_decls_1("boolMatrix", lhs_type, rhs_type); | |
519 else if ((lhs_class == "ND" && rhs_class == "ND") \ | |
520 || (lhs_class == "ND" && rhs_class == "S") \ | |
521 || (lhs_class == "S" && rhs_class == "ND")) | |
522 emit_cmp_op_decls_1("boolNDArray", lhs_type, rhs_type); | |
523 } | |
524 } | |
525 | |
526 function emit_eqne_op_decls_1(result_type, lhs_type, rhs_type) | |
527 { | |
528 emit_bin_op_decl(result_type, "mx_el_eq", lhs_type, rhs_type); | |
529 emit_bin_op_decl(result_type, "mx_el_ne", lhs_type, rhs_type); | |
530 } | |
531 | |
532 function emit_eqne_op_decls (sparse, lhs_class, rhs_class, lhs_type, rhs_type) | |
533 { | |
534 if (sparse) | |
535 { | |
536 if ((lhs_class == "M" && rhs_class == "SM") \ | |
537 || (lhs_class == "SM" && rhs_class == "M")) | |
538 emit_eqne_op_decls_1("SparseBoolMatrix", lhs_type, rhs_type); | |
539 } | |
540 | |
541 ## No separate eqne ops for full-matrix or vector. | |
542 } | |
543 | |
544 function emit_bool_op_decls_1 (result_type, lhs_type, rhs_type) | |
545 { | |
546 emit_bin_op_decl(result_type, "mx_el_and", lhs_type, rhs_type); | |
547 emit_bin_op_decl(result_type, "mx_el_or", lhs_type, rhs_type); | |
548 } | |
549 | |
550 function emit_bool_op_decls_2 (result_type, lhs_type, rhs_type) | |
551 { | |
552 emit_bin_op_decl(result_type, "mx_el_not_and", lhs_type, rhs_type); | |
553 emit_bin_op_decl(result_type, "mx_el_not_or", lhs_type, rhs_type); | |
554 } | |
555 | |
556 function emit_bool_op_decls_3 (result_type, lhs_type, rhs_type) | |
557 { | |
558 emit_bin_op_decl(result_type, "mx_el_and_not", lhs_type, rhs_type); | |
559 emit_bin_op_decl(result_type, "mx_el_or_not", lhs_type, rhs_type); | |
560 } | |
561 | |
562 function emit_bool_op_decls (sparse, lhs_class, rhs_class, lhs_type, rhs_type) | |
563 { | |
564 if (sparse) | |
565 { | |
566 if ((lhs_class == "M" && rhs_class == "SM") \ | |
567 || (lhs_class == "SM" && (rhs_class == "M" || rhs_class == "S" || rhs_class == "SM")) \ | |
568 || (lhs_class == "S" && rhs_class == "SM")) | |
569 emit_bool_op_decls_1("SparseBoolMatrix", lhs_type, rhs_type); | |
570 } | |
571 else | |
572 { | |
573 if ((lhs_class == "M" && rhs_class == "M") \ | |
574 || (lhs_class == "M" && rhs_class == "S") \ | |
575 || (lhs_class == "S" && rhs_class == "M")) | |
576 emit_bool_op_decls_1("boolMatrix", lhs_type, rhs_type); | |
577 else if (lhs_class == "ND" && rhs_class == "S") | |
578 { | |
579 emit_bool_op_decls_1("boolNDArray", lhs_type, rhs_type); | |
580 emit_bool_op_decls_2("boolNDArray", lhs_type, rhs_type); | |
581 } | |
582 else if (lhs_class == "S" && rhs_class == "ND") | |
583 { | |
584 emit_bool_op_decls_1("boolNDArray", lhs_type, rhs_type); | |
585 emit_bool_op_decls_3("boolNDArray", lhs_type, rhs_type); | |
586 } | |
587 else if (lhs_class == "ND" && rhs_class == "ND") | |
588 { | |
589 emit_bool_op_decls_1("boolNDArray", lhs_type, rhs_type); | |
590 emit_bool_op_decls_2("boolNDArray", lhs_type, rhs_type); | |
591 emit_bool_op_decls_3("boolNDArray", lhs_type, rhs_type); | |
592 } | |
593 } | |
594 } | |
595 | |
596 function emit_sparse_bin_ops (lhs_class, rhs_class, result_type_1, | |
597 result_type_2, lhs_type, rhs_type) | |
598 { | |
599 printf ("SPARSE_%s%s_BIN_OPS (%s, %s, %s, %s)\n", | |
600 lhs_class, rhs_class, result_type_1, | |
601 result_type_2, lhs_type, rhs_type); | |
602 } | |
603 | |
604 function emit_dm_bin_ops (lhs_class, rhs_class, result_type_1, | |
25663
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
605 lhs_type, rhs_type) |
25662 | 606 { |
25663
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
607 printf ("%s%s_BIN_OPS (%s, %s, %s)\n", |
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
608 lhs_class, rhs_class, result_type_1, lhs_type, rhs_type); |
25662 | 609 } |
610 | |
611 function emit_mm_bin_op (result_t, op, lhs_t, rhs_t, fcn) | |
612 { | |
613 printf ("\n" \ | |
614 "%s\n" \ | |
615 "%s (const %s& m1, const %s& m2)\n" \ | |
616 "{\n" \ | |
617 " return do_mm_binary_op<%s::element_type, %s::element_type, %s::element_type> (m1, m2, %s, %s, %s, \"%s\");\n" \ | |
618 "}\n", | |
619 result_t, op, lhs_t, rhs_t, result_t, lhs_t, rhs_t, | |
620 fcn, fcn, fcn, op); | |
621 } | |
622 | |
623 function emit_mm_bin_ops (result_t, lhs_t, rhs_t) | |
624 { | |
625 emit_mm_bin_op(result_t, "operator +", lhs_t, rhs_t, "mx_inline_add"); | |
626 emit_mm_bin_op(result_t, "operator -", lhs_t, rhs_t, "mx_inline_sub"); | |
627 emit_mm_bin_op(result_t, "product", lhs_t, rhs_t, "mx_inline_mul"); | |
628 emit_mm_bin_op(result_t, "quotient", lhs_t, rhs_t, "mx_inline_div"); | |
629 } | |
630 | |
631 function emit_bin_ops (sparse, lhs_class, rhs_class, | |
25663
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
632 result_type_1, result_type_2, lhs_type, rhs_type) |
25662 | 633 { |
634 if (sparse) | |
635 emit_sparse_bin_ops(lhs_class, rhs_class, result_type_1, | |
636 result_type_2, lhs_type, rhs_type); | |
637 else if ((lhs_class == "DM" && rhs_class == "M") \ | |
638 || (lhs_class == "M" && rhs_class == "DM")) | |
639 emit_dm_bin_ops(lhs_class, rhs_class, result_type_1, | |
25663
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
640 lhs_type, rhs_type); |
25662 | 641 else if (lhs_class == "M" && rhs_class == "M") |
642 emit_mm_bin_ops(result_type_1, lhs_type, rhs_type); | |
643 else | |
644 printf ("%s%s_BIN_OPS (%s, %s, %s)\n", | |
645 lhs_class, rhs_class, result_type_1, lhs_type, rhs_type); | |
646 } | |
647 | |
25665
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
648 function emit_cmp_ops (sparse, lhs_class, rhs_class, lhs_type, rhs_type) |
25662 | 649 { |
650 if (sparse) | |
25665
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
651 printf ("SPARSE_%s%s_CMP_OPS (%s, %s)\n", |
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
652 lhs_class, rhs_class, lhs_type, rhs_type); |
25662 | 653 else |
654 printf ("%s%s_CMP_OPS (%s, %s)\n", | |
655 lhs_class, rhs_class, lhs_type, rhs_type); | |
656 } | |
657 | |
25665
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
658 function emit_eqne_ops (sparse, lhs_class, rhs_class, lhs_type, rhs_type) |
25662 | 659 { |
660 if (sparse) | |
25665
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
661 printf ("SPARSE_%s%s_EQNE_OPS (%s, %s)\n", |
dc073ccde64e
eliminate more zero args in macros and type definitions for operators
John W. Eaton <jwe@octave.org>
parents:
25664
diff
changeset
|
662 lhs_class, rhs_class, lhs_type, rhs_type); |
25662 | 663 |
664 ## No separate eqne ops for full-matrix or vector. | |
665 } | |
666 | |
25663
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
667 function emit_bool_ops (sparse, lhs_class, rhs_class, lhs_type, rhs_type) |
25662 | 668 { |
669 if (sparse) | |
25663
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
670 printf ("SPARSE_%s%s_BOOL_OPS (%s, %s)\n", |
2de707ae8de4
eliminate LHS_ZERO and RHS_ZERO args from sparse macros
John W. Eaton <jwe@octave.org>
parents:
25662
diff
changeset
|
671 lhs_class, rhs_class, lhs_type, rhs_type); |
25662 | 672 else |
673 printf ("%s%s_BOOL_OPS (%s, %s)\n", | |
674 lhs_class, rhs_class, lhs_type, rhs_type); | |
675 } |