4511
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
4513
|
23 #if !defined (octave_NDArray_h) |
|
24 #define octave_NDArray_h 1 |
4511
|
25 |
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include "MArrayN.h" |
4513
|
31 #include "dMatrix.h" |
4511
|
32 |
|
33 #include "mx-defs.h" |
|
34 #include "mx-op-defs.h" |
|
35 |
|
36 #include "data-conv.h" |
|
37 #include "mach-info.h" |
|
38 |
4513
|
39 class |
|
40 NDArray : public MArrayN<double> |
4511
|
41 { |
4513
|
42 public: |
4511
|
43 |
|
44 NDArray (void) : MArrayN<double> () { } |
|
45 |
4543
|
46 NDArray (const dim_vector& dims) : MArrayN<double> (dims) { } |
4511
|
47 |
4543
|
48 NDArray (const dim_vector& dims, double val) |
|
49 : MArrayN<double> (dims, val) { } |
4511
|
50 |
4513
|
51 NDArray (const NDArray& a) : MArrayN<double> (a) { } |
|
52 |
|
53 NDArray (const Matrix& a) : MArrayN<double> (a) { } |
4511
|
54 |
|
55 NDArray (const MArrayN<double>& a) : MArrayN<double> (a) { } |
|
56 |
|
57 NDArray (const ArrayN<double>& a) : MArrayN<double> (a) { } |
|
58 |
4543
|
59 explicit NDArray (const boolNDArray& a); |
|
60 |
|
61 explicit NDArray (const charNDArray& a); |
|
62 |
4511
|
63 NDArray& operator = (const NDArray& a) |
|
64 { |
|
65 MArrayN<double>::operator = (a); |
|
66 return *this; |
|
67 } |
|
68 |
4543
|
69 // unary operations |
|
70 |
|
71 boolNDArray operator ! (void) const; |
|
72 |
4513
|
73 // XXX FIXME XXX -- this is not quite the right thing. |
|
74 |
4556
|
75 boolNDArray all (int dim = -1) const; |
|
76 boolNDArray any (int dim = -1) const; |
4513
|
77 |
|
78 Matrix matrix_value (void) const; |
|
79 |
4532
|
80 NDArray squeeze (void) const { return ArrayN<double>::squeeze (); } |
|
81 |
|
82 static void increment_index (Array<int>& ra_idx, |
|
83 const dim_vector& dimensions, |
|
84 int start_dimension = 0); |
|
85 |
4556
|
86 static int compute_index (Array<int>& ra_idx, |
|
87 const dim_vector& dimensions); |
|
88 |
4511
|
89 // i/o |
|
90 |
|
91 // friend std::ostream& operator << (std::ostream& os, const NDArray& a); |
|
92 // friend std::istream& operator >> (std::istream& is, NDArray& a); |
|
93 |
|
94 static double resize_fill_value (void) { return 0; } |
|
95 |
|
96 bool any_element_is_negative (bool = false) const; |
|
97 bool all_integers (double& max_val, double& min_val) const; |
|
98 |
4513
|
99 private: |
4511
|
100 |
4513
|
101 NDArray (double *d, dim_vector& dims) : MArrayN<double> (d, dims) { } |
4511
|
102 }; |
|
103 |
4543
|
104 NDS_CMP_OP_DECLS (NDArray, double) |
|
105 NDS_BOOL_OP_DECLS (NDArray, double) |
|
106 |
|
107 SND_CMP_OP_DECLS (double, NDArray) |
|
108 SND_BOOL_OP_DECLS (double, NDArray) |
|
109 |
|
110 NDND_CMP_OP_DECLS (NDArray, NDArray) |
|
111 NDND_BOOL_OP_DECLS (NDArray, NDArray) |
|
112 |
4511
|
113 MARRAY_FORWARD_DEFS (MArrayN, NDArray, double) |
|
114 |
|
115 #endif |
4513
|
116 |
|
117 /* |
|
118 ;;; Local Variables: *** |
|
119 ;;; mode: C++ *** |
|
120 ;;; End: *** |
|
121 */ |