xref: /386bsd/usr/include/nonstd/gnu/g++/gen/AVec.hP (revision a2142627)
1// This may look like C code, but it is really -*- C++ -*-
2/*
3Copyright (C) 1988 Free Software Foundation
4    written by Doug Lea (dl@rocky.oswego.edu)
5
6This file is part of GNU CC.
7
8GNU CC is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY.  No author or distributor
10accepts responsibility to anyone for the consequences of using it
11or for whether it serves any particular purpose or works at all,
12unless he says so in writing.  Refer to the GNU CC General Public
13License for full details.
14
15Everyone is granted permission to copy, modify and redistribute
16GNU CC, but only under the conditions described in the
17GNU CC General Public License.   A copy of this license is
18supposed to have been given to you along with GNU CC so you
19can know your rights and responsibilities.  It should be in a
20file named COPYING.  Among other things, the copyright notice
21and this notice must be preserved on all copies.
22*/
23
24
25#ifndef _<T>AVec_h
26#ifdef __GNUG__
27#pragma once
28#pragma interface
29#endif
30#define _<T>AVec_h 1
31
32#include "<T>.Vec.h"
33
34class <T>AVec : public <T>Vec
35{
36protected:
37  void                  check_len(int l);
38  <T>*                  vec();
39                        <T>AVec(int l, <T>* d);
40  public:
41                        <T>AVec ();
42                        <T>AVec (int l);
43                        <T>AVec (int l, <T&> fill_value);
44                        <T>AVec (<T>AVec&);
45                        ~<T>AVec ();
46
47  <T>AVec&              operator =  (<T>AVec& a);
48  <T>AVec&              operator =  (<T&> fill_value);
49
50// vector by scalar -> vector operations
51
52  friend <T>AVec        operator +  (<T>AVec& a, <T&> b);
53  friend <T>AVec        operator -  (<T>AVec& a, <T&> b);
54  friend <T>AVec        operator *  (<T>AVec& a, <T&> b);
55  friend <T>AVec        operator /  (<T>AVec& a, <T&> b);
56
57  <T>AVec&              operator += (<T&> b);
58  <T>AVec&              operator -= (<T&> b);
59  <T>AVec&              operator *= (<T&> b);
60  <T>AVec&              operator /= (<T&> b);
61
62// vector by vector -> vector operations
63
64  friend <T>AVec        operator +  (<T>AVec& a, <T>AVec& b);
65  friend <T>AVec        operator -  (<T>AVec& a, <T>AVec& b);
66  <T>AVec&              operator += (<T>AVec& b);
67  <T>AVec&              operator -= (<T>AVec& b);
68
69  <T>AVec               operator - ();
70
71  friend <T>AVec        product(<T>AVec& a, <T>AVec& b);
72  <T>AVec&              product(<T>AVec& b);
73  friend <T>AVec        quotient(<T>AVec& a, <T>AVec& b);
74  <T>AVec&              quotient(<T>AVec& b);
75
76// vector -> scalar operations
77
78  friend <T>            operator * (<T>AVec& a, <T>AVec& b);
79
80  <T>                   sum();
81  <T>                   min();
82  <T>                   max();
83  <T>                   sumsq();
84
85// indexing
86
87  int                   min_index();
88  int                   max_index();
89
90// redundant but necesssary
91  friend <T>AVec        concat(<T>AVec& a, <T>AVec& b);
92  friend <T>AVec        map(<T>Mapper f, <T>AVec& a);
93  friend <T>AVec        merge(<T>AVec& a, <T>AVec& b, <T>Comparator f);
94  friend <T>AVec        combine(<T>Combiner f, <T>AVec& a, <T>AVec& b);
95  friend <T>AVec        reverse(<T>AVec& a);
96  <T>AVec               at(int from = 0, int n = -1);
97};
98
99#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
100
101inline <T>AVec::<T>AVec() {}
102inline <T>AVec::<T>AVec(int l) :<T>Vec(l) {}
103inline <T>AVec::<T>AVec(int l, <T&> fill_value) : <T>Vec (l, fill_value) {}
104inline <T>AVec::<T>AVec(<T>AVec& v) :(v) {}
105inline <T>AVec::<T>AVec(int l, <T>* d) :<T>Vec(l, d) {}
106inline <T>AVec::~<T>AVec() {}
107
108
109inline <T>* <T>AVec::vec()
110{
111  return s;
112}
113
114
115inline void <T>AVec::check_len(int l)
116{
117  if (l != len)
118    error("nonconformant vectors.");
119}
120
121
122#endif
123#endif
124