Commit | Line | Data |
---|---|---|
e87b4ac1 PR |
1 | // This may look like C code, but it is really -*- C++ -*- |
2 | /* | |
3 | Copyright (C) 1988 Free Software Foundation | |
4 | written by Doug Lea (dl@rocky.oswego.edu) | |
5 | ||
6 | This file is part of the GNU C++ Library. This library is free | |
7 | software; you can redistribute it and/or modify it under the terms of | |
8 | the GNU Library General Public License as published by the Free | |
9 | Software Foundation; either version 2 of the License, or (at your | |
10 | option) any later version. This library is distributed in the hope | |
11 | that it will be useful, but WITHOUT ANY WARRANTY; without even the | |
12 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
13 | PURPOSE. See the GNU Library General Public License for more details. | |
14 | You should have received a copy of the GNU Library General Public | |
15 | License along with this library; if not, write to the Free Software | |
16 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
17 | */ | |
18 | ||
19 | ||
20 | #ifndef _<T>AVec_h | |
21 | #ifdef __GNUG__ | |
22 | #pragma interface | |
23 | #endif | |
24 | #define _<T>AVec_h 1 | |
25 | ||
26 | #include "<T>.Vec.h" | |
27 | ||
28 | class <T>AVec : public <T>Vec | |
29 | { | |
30 | protected: | |
31 | void check_len(int l); | |
32 | <T>* vec(); | |
33 | <T>AVec(int l, <T>* d); | |
34 | public: | |
35 | <T>AVec (); | |
36 | <T>AVec (int l); | |
37 | <T>AVec (int l, <T&> fill_value); | |
38 | <T>AVec (<T>AVec&); | |
39 | ~<T>AVec (); | |
40 | ||
41 | <T>AVec& operator = (<T>AVec& a); | |
42 | <T>AVec& operator = (<T&> fill_value); | |
43 | ||
44 | // vector by scalar -> vector operations | |
45 | ||
46 | friend <T>AVec operator + (<T>AVec& a, <T&> b); | |
47 | friend <T>AVec operator - (<T>AVec& a, <T&> b); | |
48 | friend <T>AVec operator * (<T>AVec& a, <T&> b); | |
49 | friend <T>AVec operator / (<T>AVec& a, <T&> b); | |
50 | ||
51 | <T>AVec& operator += (<T&> b); | |
52 | <T>AVec& operator -= (<T&> b); | |
53 | <T>AVec& operator *= (<T&> b); | |
54 | <T>AVec& operator /= (<T&> b); | |
55 | ||
56 | // vector by vector -> vector operations | |
57 | ||
58 | friend <T>AVec operator + (<T>AVec& a, <T>AVec& b); | |
59 | friend <T>AVec operator - (<T>AVec& a, <T>AVec& b); | |
60 | <T>AVec& operator += (<T>AVec& b); | |
61 | <T>AVec& operator -= (<T>AVec& b); | |
62 | ||
63 | <T>AVec operator - (); | |
64 | ||
65 | friend <T>AVec product(<T>AVec& a, <T>AVec& b); | |
66 | <T>AVec& product(<T>AVec& b); | |
67 | friend <T>AVec quotient(<T>AVec& a, <T>AVec& b); | |
68 | <T>AVec& quotient(<T>AVec& b); | |
69 | ||
70 | // vector -> scalar operations | |
71 | ||
72 | friend <T> operator * (<T>AVec& a, <T>AVec& b); | |
73 | ||
74 | <T> sum(); | |
75 | <T> min(); | |
76 | <T> max(); | |
77 | <T> sumsq(); | |
78 | ||
79 | // indexing | |
80 | ||
81 | int min_index(); | |
82 | int max_index(); | |
83 | ||
84 | // redundant but necesssary | |
85 | friend <T>AVec concat(<T>AVec& a, <T>AVec& b); | |
86 | friend <T>AVec map(<T>Mapper f, <T>AVec& a); | |
87 | friend <T>AVec merge(<T>AVec& a, <T>AVec& b, <T>Comparator f); | |
88 | friend <T>AVec combine(<T>Combiner f, <T>AVec& a, <T>AVec& b); | |
89 | friend <T>AVec reverse(<T>AVec& a); | |
90 | <T>AVec at(int from = 0, int n = -1); | |
91 | }; | |
92 | ||
93 | inline <T>AVec::<T>AVec() {} | |
94 | inline <T>AVec::<T>AVec(int l) :<T>Vec(l) {} | |
95 | inline <T>AVec::<T>AVec(int l, <T&> fill_value) : <T>Vec (l, fill_value) {} | |
96 | inline <T>AVec::<T>AVec(<T>AVec& v) :<T>Vec(v) {} | |
97 | inline <T>AVec::<T>AVec(int l, <T>* d) :<T>Vec(l, d) {} | |
98 | inline <T>AVec::~<T>AVec() {} | |
99 | ||
100 | ||
101 | inline <T>* <T>AVec::vec() | |
102 | { | |
103 | return s; | |
104 | } | |
105 | ||
106 | ||
107 | inline void <T>AVec::check_len(int l) | |
108 | { | |
109 | if (l != len) | |
110 | error("nonconformant vectors."); | |
111 | } | |
112 | ||
113 | #endif |