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