annotate liboctave/so-array.cc @ 7016:93c65f2a5668

[project @ 2007-10-12 06:40:56 by jwe]
author jwe
date Fri, 12 Oct 2007 06:41:26 +0000
parents 83619ae96c1d
children a1dbe9d80eee
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
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6867
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6867
diff changeset
10 option) any later version.
4647
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
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6867
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6867
diff changeset
19 <http://www.gnu.org/licenses/>.
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
20
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 #ifdef HAVE_CONFIG_H
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
25 #endif
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"
4648
dca0236ad77c [project @ 2003-11-23 19:36:33 by jwe]
jwe
parents: 4647
diff changeset
30 #include "Array-util.h"
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5307
diff changeset
31 // FIXME -- we are including the MArray{,2,N}.h files just for
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
32 // their gripe_nonconformant function decls.
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
33 #include "MArray.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
34 #include "MArray2.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
35 #include "MArrayN.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
36 #include "MArray-defs.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
37 #include "boolMatrix.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
38 #include "boolNDArray.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
39 #include "mx-op-defs.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
40 #include "so-array.h"
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 boolNDArray
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
43 streamoff_array::all (int dim) const
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
44 {
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
45 MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (MX_ND_ALL_EXPR), true);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
46 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
47
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
48 boolNDArray
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
49 streamoff_array::any (int dim) const
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
50 {
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
51 MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (MX_ND_ANY_EXPR), false);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
52 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
53
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
54 streamoff_array&
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
55 operator += (streamoff_array& a, const std::streamoff& s)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
56 {
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
57 DO_VS_OP2 (std::streamoff, a, +=, s)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
58 return a;
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
59 }
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 streamoff_array&
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
62 operator -= (streamoff_array& a, const std::streamoff& s)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
63 {
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
64 DO_VS_OP2 (std::streamoff, a, -=, s);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
65 return a;
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
66 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
67
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
68 streamoff_array&
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
69 operator += (streamoff_array& a, const streamoff_array& b)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
70 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
71 octave_idx_type l = a.length ();
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
72 if (l > 0)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
73 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
74 octave_idx_type bl = b.length ();
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
75 if (l != bl)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
76 gripe_nonconformant ("operator +=", l, bl);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
77 else
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
78 DO_VV_OP2 (std::streamoff, a, +=, b);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
79 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
80 return a;
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
81 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
82
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
83 streamoff_array&
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
84 operator -= (streamoff_array& a, const streamoff_array& b)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
85 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
86 octave_idx_type l = a.length ();
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
87 if (l > 0)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
88 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
89 octave_idx_type bl = b.length ();
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
90 if (l != bl)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
91 gripe_nonconformant ("operator -=", l, bl);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
92 else
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
93 DO_VV_OP2 (std::streamoff, a, -=, b);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
94 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
95 return a;
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
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
98 octave_idx_type
6867
83619ae96c1d [project @ 2007-09-06 12:08:44 by dbateman]
dbateman
parents: 5775
diff changeset
99 streamoff_array::compute_index (Array<octave_idx_type>& ra_idx,
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
100 const dim_vector& dimensions)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
101 {
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
102 return ::compute_index (ra_idx, dimensions);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
103 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
104
4835
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
105 SND_CMP_OP (mx_el_eq, ==, std::streamoff, , streamoff_array, )
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
106 SND_CMP_OP (mx_el_ne, !=, std::streamoff, , streamoff_array, )
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
107
4835
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
108 NDS_CMP_OP (mx_el_eq, ==, streamoff_array, , std::streamoff, )
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
109 NDS_CMP_OP (mx_el_ne, !=, streamoff_array, , std::streamoff, )
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
110
4835
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
111 NDND_CMP_OP (mx_el_eq, ==, streamoff_array, , streamoff_array, )
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
112 NDND_CMP_OP (mx_el_ne, !=, streamoff_array, , streamoff_array, )
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
113
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
114 NDND_BIN_OP (streamoff_array, operator +,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
115 streamoff_array, streamoff_array, mx_inline_add)
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 NDND_BIN_OP (streamoff_array, operator -,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
118 streamoff_array, streamoff_array, mx_inline_subtract)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
119
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
120
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
121 NDS_BIN_OP (streamoff_array, operator +,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
122 streamoff_array, std::streamoff, mx_inline_add)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
123
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
124 NDS_BIN_OP (streamoff_array, operator -,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
125 streamoff_array, std::streamoff, mx_inline_subtract)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
126
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
127
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
128 SND_BIN_OP (streamoff_array, operator +,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
129 std::streamoff, streamoff_array, mx_inline_add)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
130
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
131 SND_BIN_OP (streamoff_array, operator -,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
132 std::streamoff, streamoff_array, mx_inline_subtract)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
133
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
134 /*
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
135 ;;; Local Variables: ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
136 ;;; mode: C++ ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
137 ;;; End: ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
138 */