annotate liboctave/so-array.h @ 6469:a848b846cb3a ss-2-9-10

[project @ 2007-03-27 18:42:11 by jwe]
author jwe
date Tue, 27 Mar 2007 18:42:11 +0000
parents 143b556ce725
children 0ce71beb1cf3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
1 /*
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
2
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 2003 John W. Eaton
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
4
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
6
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
10 later version.
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
11
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
15 for more details.
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
16
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5275
diff changeset
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5275
diff changeset
20 02110-1301, USA.
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
21
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
22 */
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
23
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
24 #if !defined (octave_streamoff_array_h)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
25 #define octave_streamoff_array_h 1
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
26
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
27 #include <iostream>
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
28
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
29 #include "ArrayN.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
30 #include "mx-op-defs.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
31
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
32 class boolNDArray;
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
33
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
34 // Stream offsets.
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
35
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5602
diff changeset
36 class OCTAVE_API streamoff_array : public ArrayN<std::streamoff>
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
37 {
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
38 public:
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
39
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
40 streamoff_array (void) : ArrayN<std::streamoff> () { }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
41
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
42 streamoff_array (const dim_vector& dv,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
43 const std::streamoff& val = resize_fill_value ())
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
44 : ArrayN<std::streamoff> (dv, val) { }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
45
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
46 streamoff_array (const ArrayN<std::streamoff>& sa)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
47 : ArrayN<std::streamoff> (sa) { }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
48
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
49 streamoff_array (const streamoff_array& sa)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
50 : ArrayN<std::streamoff> (sa) { }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
51
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
52 ~streamoff_array (void) { }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
53
4655
c8829691db47 [project @ 2003-11-24 21:24:37 by jwe]
jwe
parents: 4647
diff changeset
54 streamoff_array& operator = (const streamoff_array& sa)
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
55 {
4655
c8829691db47 [project @ 2003-11-24 21:24:37 by jwe]
jwe
parents: 4647
diff changeset
56 if (this != &sa)
c8829691db47 [project @ 2003-11-24 21:24:37 by jwe]
jwe
parents: 4647
diff changeset
57 ArrayN<std::streamoff>::operator = (sa);
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
58
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
59 return *this;
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
60 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
61
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
62 streamoff_array squeeze (void) const
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
63 { return ArrayN<std::streamoff>::squeeze (); }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
64
5602
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
65 octave_idx_type nnz (void) const
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
66 {
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
67 octave_idx_type retval = 0;
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
68
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
69 const std::streamoff *d = this->data ();
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
70
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
71 octave_idx_type nel = this->numel ();
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
72
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
73 for (octave_idx_type i = 0; i < nel; i++)
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
74 {
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
75 if (d[i])
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
76 retval++;
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
77 }
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
78
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
79 return retval;
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
80 }
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
81
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
82 boolNDArray all (int dim = -1) const;
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
83 boolNDArray any (int dim = -1) const;
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
84
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
85 static octave_idx_type compute_index (Array<int>& ra_idx,
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
86 const dim_vector& dimensions);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
87
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
88 static std::streamoff resize_fill_value (void) { return 0; }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
89 };
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
90
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5602
diff changeset
91 OCTAVE_API streamoff_array& operator += (streamoff_array& l, const std::streamoff& r);
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5602
diff changeset
92 OCTAVE_API streamoff_array& operator -= (streamoff_array& l, const std::streamoff& r);
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
93
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5602
diff changeset
94 OCTAVE_API streamoff_array& operator += (streamoff_array& l, const streamoff_array& r);
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5602
diff changeset
95 OCTAVE_API streamoff_array& operator -= (streamoff_array& l, const streamoff_array& r);
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
96
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
97 NDCMP_OP_DECL (mx_el_eq, std::streamoff, streamoff_array);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
98 NDCMP_OP_DECL (mx_el_ne, std::streamoff, streamoff_array);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
99
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
100 NDCMP_OP_DECL (mx_el_eq, streamoff_array, std::streamoff);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
101 NDCMP_OP_DECL (mx_el_ne, streamoff_array, std::streamoff);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
102
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
103 NDCMP_OP_DECL (mx_el_eq, streamoff_array, streamoff_array);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
104 NDCMP_OP_DECL (mx_el_ne, streamoff_array, streamoff_array);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
105
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
106 BIN_OP_DECL (streamoff_array, operator +, streamoff_array, streamoff_array);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
107 BIN_OP_DECL (streamoff_array, operator -, streamoff_array, streamoff_array);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
108
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
109 BIN_OP_DECL (streamoff_array, operator +, streamoff_array, std::streamoff);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
110 BIN_OP_DECL (streamoff_array, operator -, streamoff_array, std::streamoff);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
111
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
112 BIN_OP_DECL (streamoff_array, operator +, std::streamoff, streamoff_array);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
113 BIN_OP_DECL (streamoff_array, operator -, std::streamoff, streamoff_array);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
114
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
115 #endif
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
116
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
117 /*
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
118 ;;; Local Variables: ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
119 ;;; mode: C++ ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
120 ;;; End: ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
121 */