annotate liboctave/so-array.cc @ 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 ace8d8d26933
children 83619ae96c1d
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 #ifdef HAVE_CONFIG_H
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
25 #include <config.h>
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
26 #endif
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
27
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
28 #include <iostream>
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
29
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
30 #include "ArrayN.h"
4648
dca0236ad77c [project @ 2003-11-23 19:36:33 by jwe]
jwe
parents: 4647
diff changeset
31 #include "Array-util.h"
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5307
diff changeset
32 // 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
33 // their gripe_nonconformant function decls.
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
34 #include "MArray.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
35 #include "MArray2.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
36 #include "MArrayN.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
37 #include "MArray-defs.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
38 #include "boolMatrix.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
39 #include "boolNDArray.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
40 #include "mx-op-defs.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
41 #include "so-array.h"
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
42
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
43 boolNDArray
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
44 streamoff_array::all (int dim) const
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 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
47 }
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 boolNDArray
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
50 streamoff_array::any (int dim) const
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 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
53 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
54
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
55 streamoff_array&
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
56 operator += (streamoff_array& a, const std::streamoff& s)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
57 {
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
58 DO_VS_OP2 (std::streamoff, a, +=, s)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
59 return a;
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&
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
63 operator -= (streamoff_array& a, const std::streamoff& s)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
64 {
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
65 DO_VS_OP2 (std::streamoff, a, -=, s);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
66 return a;
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
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
69 streamoff_array&
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
70 operator += (streamoff_array& a, const streamoff_array& b)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
71 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
72 octave_idx_type l = a.length ();
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
73 if (l > 0)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
74 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
75 octave_idx_type bl = b.length ();
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
76 if (l != bl)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
77 gripe_nonconformant ("operator +=", l, bl);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
78 else
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
79 DO_VV_OP2 (std::streamoff, a, +=, b);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
80 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
81 return a;
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
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
84 streamoff_array&
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
85 operator -= (streamoff_array& a, const streamoff_array& b)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
86 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
87 octave_idx_type l = a.length ();
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
88 if (l > 0)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
89 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
90 octave_idx_type bl = b.length ();
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
91 if (l != bl)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
92 gripe_nonconformant ("operator -=", l, bl);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
93 else
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
94 DO_VV_OP2 (std::streamoff, a, -=, b);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
95 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
96 return a;
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
97 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
98
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
99 octave_idx_type
4647
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
100 streamoff_array::compute_index (Array<int>& ra_idx,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
101 const dim_vector& dimensions)
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 return ::compute_index (ra_idx, dimensions);
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
104 }
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
105
4835
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
106 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
107 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
108
4835
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
109 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
110 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
111
4835
66645e416d55 [project @ 2004-03-11 20:06:36 by jwe]
jwe
parents: 4648
diff changeset
112 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
113 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
114
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
115 NDND_BIN_OP (streamoff_array, operator +,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
116 streamoff_array, streamoff_array, mx_inline_add)
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 NDND_BIN_OP (streamoff_array, operator -,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
119 streamoff_array, streamoff_array, mx_inline_subtract)
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
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
122 NDS_BIN_OP (streamoff_array, operator +,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
123 streamoff_array, std::streamoff, mx_inline_add)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
124
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
125 NDS_BIN_OP (streamoff_array, operator -,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
126 streamoff_array, std::streamoff, mx_inline_subtract)
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
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
129 SND_BIN_OP (streamoff_array, operator +,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
130 std::streamoff, streamoff_array, mx_inline_add)
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
131
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
132 SND_BIN_OP (streamoff_array, operator -,
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
133 std::streamoff, streamoff_array, mx_inline_subtract)
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 /*
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
136 ;;; Local Variables: ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
137 ;;; mode: C++ ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
138 ;;; End: ***
6d26997e1fc3 [project @ 2003-11-23 18:18:58 by jwe]
jwe
parents:
diff changeset
139 */