annotate liboctave/MArray.h @ 10158:4c0cdbe0acca

remove Emacs local-variable settings from liboctave source files
author John W. Eaton <jwe@octave.org>
date Wed, 20 Jan 2010 19:04:35 -0500
parents ead4f9c82a9a
children 12884915a8e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1993
1b57120c997b [project @ 1996-03-03 01:16:15 by jwe]
jwe
parents: 1992
diff changeset
1 // Template array classes with like-type math ops
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
2 /*
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
3
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2002, 2003, 2004,
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8774
diff changeset
5 2005, 2006, 2007, 2008, 2009 John W. Eaton
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
6
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
7 This file is part of Octave.
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
8
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6708
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6708
diff changeset
12 option) any later version.
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
13
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
17 for more details.
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
18
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6708
diff changeset
20 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6708
diff changeset
21 <http://www.gnu.org/licenses/>.
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
22
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
23 */
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
24
382
e02d6b664394 [project @ 1994-03-09 21:08:03 by jwe]
jwe
parents: 237
diff changeset
25 #if !defined (octave_MArray_h)
e02d6b664394 [project @ 1994-03-09 21:08:03 by jwe]
jwe
parents: 237
diff changeset
26 #define octave_MArray_h 1
e02d6b664394 [project @ 1994-03-09 21:08:03 by jwe]
jwe
parents: 237
diff changeset
27
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
28 #include "Array.h"
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
29
3573
6ae6f1180e62 [project @ 2000-02-04 09:01:59 by jwe]
jwe
parents: 3504
diff changeset
30 // One dimensional array with math ops.
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 2847
diff changeset
31
3573
6ae6f1180e62 [project @ 2000-02-04 09:01:59 by jwe]
jwe
parents: 3504
diff changeset
32 // But first, some preprocessor abuse...
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 2847
diff changeset
33
8774
b756ce0002db split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
34 #include "MArray-decl.h"
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 2847
diff changeset
35
6708
0ce71beb1cf3 [project @ 2007-06-13 06:40:48 by jwe]
jwe
parents: 6508
diff changeset
36 MARRAY_OPS_FORWARD_DECLS (MArray, )
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
37
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
38 template <class T>
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
39 class
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
40 MArray : public Array<T>
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
41 {
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
42 protected:
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
43
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
44 MArray (T *d, octave_idx_type l) : Array<T> (d, l) { }
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
45
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
46 public:
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
47
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
48 MArray (void) : Array<T> () { }
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
49
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
50 explicit MArray (octave_idx_type n) : Array<T> (n) { }
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
51
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
52 MArray (octave_idx_type n, const T& val) : Array<T> (n, val) { }
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
53
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
54 MArray (const MArray<T>& a) : Array<T> (a) { }
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
55
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
56 // FIXME: kluge.
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
57 MArray (const Array<T>& a) : Array<T> (a, dim_vector (a.length ())) { }
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
58
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
59 MArray (const dim_vector& dv) : Array<T> (dv) { }
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
60
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1213
diff changeset
61 ~MArray (void) { }
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1213
diff changeset
62
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
63 MArray<T>& operator = (const MArray<T>& a)
1213
9689615b34f2 [project @ 1995-04-06 02:25:15 by jwe]
jwe
parents: 1011
diff changeset
64 {
9689615b34f2 [project @ 1995-04-06 02:25:15 by jwe]
jwe
parents: 1011
diff changeset
65 Array<T>::operator = (a);
9689615b34f2 [project @ 1995-04-06 02:25:15 by jwe]
jwe
parents: 1011
diff changeset
66 return *this;
9689615b34f2 [project @ 1995-04-06 02:25:15 by jwe]
jwe
parents: 1011
diff changeset
67 }
3573
6ae6f1180e62 [project @ 2000-02-04 09:01:59 by jwe]
jwe
parents: 3504
diff changeset
68
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
69 // FIXME: kluge again. This design really sucks.
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
70 void resize (octave_idx_type n, const T& val = Array<T>::resize_fill_value ())
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
71 { Array<T>::resize_fill (n, 1, val); }
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
72
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7503
diff changeset
73 MArray<T> transpose (void) const { return Array<T>::transpose (); }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7503
diff changeset
74 MArray<T> hermitian (T (*fcn) (const T&) = 0) const { return Array<T>::hermitian (fcn); }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7503
diff changeset
75
6508
184ab67c3bc1 [project @ 2007-04-07 00:43:09 by jwe]
jwe
parents: 5602
diff changeset
76 double norm (double p) const;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7503
diff changeset
77 float norm (float p) const;
5602
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
78
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
79 // FIXME: should go away.
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
80 template <class U>
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
81 MArray<U>
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
82 map (U (&fcn) (T)) const
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
83 { return Array<T>::template map<U> (fcn); }
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
84
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
85 template <class U>
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
86 MArray<U>
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
87 map (U (&fcn) (const T&)) const
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 9612
diff changeset
88 { return Array<T>::template map<U> (fcn); }
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
89
3573
6ae6f1180e62 [project @ 2000-02-04 09:01:59 by jwe]
jwe
parents: 3504
diff changeset
90 // Currently, the OPS functions don't need to be friends, but that
6ae6f1180e62 [project @ 2000-02-04 09:01:59 by jwe]
jwe
parents: 3504
diff changeset
91 // may change.
6ae6f1180e62 [project @ 2000-02-04 09:01:59 by jwe]
jwe
parents: 3504
diff changeset
92
3610
1222153daafb [project @ 2000-03-17 02:31:58 by jwe]
jwe
parents: 3585
diff changeset
93 // MARRAY_OPS_FRIEND_DECLS (MArray)
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
94 };
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
95
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
96 #endif