Mercurial > hg > octave-nkf
annotate liboctave/intNDArray.h @ 7904:1fddd9b8e862
Fix nil_rep reference counting in gl-render.cc::vertex_data internal class
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 09 Jul 2008 10:59:29 -0400 |
parents | 36594d5bbe13 |
children | 1dce30ab0e72 |
rev | line source |
---|---|
4902 | 1 /* |
2 | |
7017 | 3 Copyright (C) 2004, 2005, 2006, 2007 John W. Eaton |
4902 | 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. | |
4902 | 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/>. | |
4902 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_intNDArray_h) | |
24 #define octave_intNDArray_h 1 | |
25 | |
26 #include "MArrayN.h" | |
27 #include "boolNDArray.h" | |
28 | |
29 template <class T> | |
30 class | |
31 intNDArray : public MArrayN<T> | |
32 { | |
33 public: | |
5992 | 34 |
35 typedef T elt_type; | |
4902 | 36 |
37 intNDArray (void) : MArrayN<T> () { } | |
38 | |
39 intNDArray (T val) : MArrayN<T> (dim_vector (1, 1), val) { } | |
40 | |
41 intNDArray (const dim_vector& dv) : MArrayN<T> (dv) { } | |
42 | |
43 intNDArray (const dim_vector& dv, T val) | |
44 : MArrayN<T> (dv, val) { } | |
45 | |
46 template <class U> | |
47 explicit intNDArray (const Array<U>& a) : MArrayN<T> (a) { } | |
48 | |
49 template <class U> | |
50 explicit intNDArray (const ArrayN<U>& a) : MArrayN<T> (a) { } | |
51 | |
52 template <class U> | |
53 intNDArray (const MArrayN<U>& a) : MArrayN<T> (a) { } | |
54 | |
55 template <class U> | |
56 intNDArray (const intNDArray<U>& a) : MArrayN<T> (a) { } | |
57 | |
58 intNDArray& operator = (const intNDArray<T>& a) | |
59 { | |
60 MArrayN<T>::operator = (a); | |
61 return *this; | |
62 } | |
63 | |
64 boolNDArray operator ! (void) const; | |
65 | |
5943 | 66 bool any_element_not_one_or_zero (void) const; |
67 | |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
68 intNDArray diag (octave_idx_type k = 0) const; |
6979 | 69 |
5775 | 70 // FIXME -- this is not quite the right thing. |
4902 | 71 |
72 boolNDArray all (int dim = -1) const; | |
73 boolNDArray any (int dim = -1) const; | |
74 | |
7189 | 75 intNDArray max (int dim = 0) const; |
76 intNDArray max (ArrayN<octave_idx_type>& index, int dim = 0) const; | |
77 intNDArray min (int dim = 0) const; | |
78 intNDArray min (ArrayN<octave_idx_type>& index, int dim = 0) const; | |
79 | |
7113 | 80 intNDArray sum (int dim) const; |
81 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7189
diff
changeset
|
82 intNDArray abs (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7189
diff
changeset
|
83 intNDArray signum (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7189
diff
changeset
|
84 |
4902 | 85 intNDArray squeeze (void) const |
86 { return intNDArray<T> (MArrayN<T>::squeeze ()); } | |
87 | |
88 intNDArray transpose (void) const | |
89 { return intNDArray<T> (MArrayN<T>::transpose ()); } | |
90 | |
5275 | 91 intNDArray concat (const intNDArray<T>& rb, const Array<octave_idx_type>& ra_idx); |
5073 | 92 |
5275 | 93 intNDArray& insert (const intNDArray<T>& a, octave_idx_type r, octave_idx_type c); |
94 intNDArray& insert (const intNDArray<T>& a, const Array<octave_idx_type>& ra_idx); | |
4915 | 95 |
5275 | 96 static void increment_index (Array<octave_idx_type>& ra_idx, |
4902 | 97 const dim_vector& dimensions, |
98 int start_dimension = 0); | |
99 | |
5275 | 100 static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx, |
4902 | 101 const dim_vector& dimensions); |
102 | |
103 static T resize_fill_value (void) { return 0; } | |
104 | |
105 protected: | |
106 | |
107 intNDArray (T *d, dim_vector& dv) : MArrayN<T> (d, dv) { } | |
108 }; | |
109 | |
110 // i/o | |
111 | |
112 template <class T> | |
113 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a); | |
114 | |
115 template <class T> | |
116 std::istream& operator >> (std::istream& is, intNDArray<T>& a); | |
117 | |
118 #endif | |
119 | |
120 /* | |
121 ;;; Local Variables: *** | |
122 ;;; mode: C++ *** | |
123 ;;; End: *** | |
124 */ |