4647
|
1 /* |
|
2 |
|
3 Copyright (C) 2003 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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
4647
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_streamoff_array_h) |
|
25 #define octave_streamoff_array_h 1 |
|
26 |
|
27 #include <iostream> |
|
28 |
|
29 #include "ArrayN.h" |
|
30 #include "mx-op-defs.h" |
|
31 |
|
32 class boolNDArray; |
|
33 |
|
34 // Stream offsets. |
|
35 |
6108
|
36 class OCTAVE_API streamoff_array : public ArrayN<std::streamoff> |
4647
|
37 { |
|
38 public: |
|
39 |
|
40 streamoff_array (void) : ArrayN<std::streamoff> () { } |
|
41 |
|
42 streamoff_array (const dim_vector& dv, |
|
43 const std::streamoff& val = resize_fill_value ()) |
|
44 : ArrayN<std::streamoff> (dv, val) { } |
|
45 |
|
46 streamoff_array (const ArrayN<std::streamoff>& sa) |
|
47 : ArrayN<std::streamoff> (sa) { } |
|
48 |
|
49 streamoff_array (const streamoff_array& sa) |
|
50 : ArrayN<std::streamoff> (sa) { } |
|
51 |
|
52 ~streamoff_array (void) { } |
|
53 |
4655
|
54 streamoff_array& operator = (const streamoff_array& sa) |
4647
|
55 { |
4655
|
56 if (this != &sa) |
|
57 ArrayN<std::streamoff>::operator = (sa); |
4647
|
58 |
|
59 return *this; |
|
60 } |
|
61 |
|
62 streamoff_array squeeze (void) const |
|
63 { return ArrayN<std::streamoff>::squeeze (); } |
|
64 |
5602
|
65 octave_idx_type nnz (void) const |
|
66 { |
|
67 octave_idx_type retval = 0; |
|
68 |
|
69 const std::streamoff *d = this->data (); |
|
70 |
|
71 octave_idx_type nel = this->numel (); |
|
72 |
|
73 for (octave_idx_type i = 0; i < nel; i++) |
|
74 { |
|
75 if (d[i]) |
|
76 retval++; |
|
77 } |
|
78 |
|
79 return retval; |
|
80 } |
|
81 |
4647
|
82 boolNDArray all (int dim = -1) const; |
|
83 boolNDArray any (int dim = -1) const; |
|
84 |
6867
|
85 static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx, |
4647
|
86 const dim_vector& dimensions); |
|
87 |
|
88 static std::streamoff resize_fill_value (void) { return 0; } |
|
89 }; |
|
90 |
6108
|
91 OCTAVE_API streamoff_array& operator += (streamoff_array& l, const std::streamoff& r); |
|
92 OCTAVE_API streamoff_array& operator -= (streamoff_array& l, const std::streamoff& r); |
4647
|
93 |
6108
|
94 OCTAVE_API streamoff_array& operator += (streamoff_array& l, const streamoff_array& r); |
|
95 OCTAVE_API streamoff_array& operator -= (streamoff_array& l, const streamoff_array& r); |
4647
|
96 |
6708
|
97 NDCMP_OP_DECL (mx_el_eq, std::streamoff, streamoff_array, OCTAVE_API); |
|
98 NDCMP_OP_DECL (mx_el_ne, std::streamoff, streamoff_array, OCTAVE_API); |
4647
|
99 |
6708
|
100 NDCMP_OP_DECL (mx_el_eq, streamoff_array, std::streamoff, OCTAVE_API); |
|
101 NDCMP_OP_DECL (mx_el_ne, streamoff_array, std::streamoff, OCTAVE_API); |
4647
|
102 |
6708
|
103 NDCMP_OP_DECL (mx_el_eq, streamoff_array, streamoff_array, OCTAVE_API); |
|
104 NDCMP_OP_DECL (mx_el_ne, streamoff_array, streamoff_array, OCTAVE_API); |
4647
|
105 |
6708
|
106 BIN_OP_DECL (streamoff_array, operator +, streamoff_array, streamoff_array, OCTAVE_API); |
|
107 BIN_OP_DECL (streamoff_array, operator -, streamoff_array, streamoff_array, OCTAVE_API); |
4647
|
108 |
6708
|
109 BIN_OP_DECL (streamoff_array, operator +, streamoff_array, std::streamoff, OCTAVE_API); |
|
110 BIN_OP_DECL (streamoff_array, operator -, streamoff_array, std::streamoff, OCTAVE_API); |
4647
|
111 |
6708
|
112 BIN_OP_DECL (streamoff_array, operator +, std::streamoff, streamoff_array, OCTAVE_API); |
|
113 BIN_OP_DECL (streamoff_array, operator -, std::streamoff, streamoff_array, OCTAVE_API); |
4647
|
114 |
|
115 #endif |
|
116 |
|
117 /* |
|
118 ;;; Local Variables: *** |
|
119 ;;; mode: C++ *** |
|
120 ;;; End: *** |
|
121 */ |