1988
|
1 // Template array classes -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1996 John W. Eaton |
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
|
28 #ifdef HAVE_CONFIG_H |
|
29 #include <config.h> |
|
30 #endif |
|
31 |
|
32 #include <cassert> |
|
33 |
|
34 #include <iostream.h> |
|
35 |
|
36 #include "Array3.h" |
|
37 |
|
38 #if defined (HEAVYWEIGHT_INDEXING) |
|
39 #include "idx-vector.h" |
|
40 #include "Array3-idx.h" |
|
41 #endif |
|
42 |
|
43 #include "lo-error.h" |
|
44 |
|
45 // Three dimensional array class. |
|
46 |
|
47 template <class T> |
|
48 T& |
|
49 Array3<T>::checkelem (int i, int j, int k) |
|
50 { |
|
51 if (i < 0 || j < 0 || k < 0 || i >= d1 || j >= d2 || k >= d3) |
|
52 { |
|
53 (*current_liboctave_error_handler) ("range error"); |
|
54 static T foo; |
|
55 return foo; |
|
56 } |
|
57 return Array2<T>::elem (i, d1*k+j); |
|
58 } |
|
59 |
|
60 template <class T> |
|
61 T |
|
62 Array3<T>::elem (int i, int j, int k) const |
|
63 { |
|
64 return Array2<T>::elem (i, d2*k+j); |
|
65 } |
|
66 |
|
67 template <class T> |
|
68 T |
|
69 Array3<T>::checkelem (int i, int j, int k) const |
|
70 { |
|
71 if (i < 0 || j < 0 || k < 0 || i >= d1 || j >= d2 || k >= d3) |
|
72 { |
|
73 (*current_liboctave_error_handler) ("range error"); |
|
74 T foo; |
|
75 static T *bar = &foo; |
|
76 return foo; |
|
77 } |
|
78 return Array2<T>::elem (i, d1*k+j); |
|
79 } |
|
80 |
|
81 template <class T> |
|
82 T |
|
83 Array3<T>::operator () (int i, int j, int k) const |
|
84 { |
|
85 if (i < 0 || j < 0 || k < 0 || i >= d1 || j >= d2 || k >= d3) |
|
86 { |
|
87 (*current_liboctave_error_handler) ("range error"); |
|
88 T foo; |
|
89 static T *bar = &foo; |
|
90 return foo; |
|
91 } |
|
92 return Array2<T>::elem (i, d2*k+j); |
|
93 } |
|
94 |
|
95 template <class T> |
|
96 void |
|
97 Array3<T>::resize (int n, int m, int k) |
|
98 { |
|
99 assert (0); // XXX FIXME XXX |
|
100 } |
|
101 |
|
102 template <class T> |
|
103 void |
|
104 Array3<T>::resize (int n, int m, int k, const T& val) |
|
105 { |
|
106 assert (0); // XXX FIXME XXX |
|
107 } |
|
108 |
|
109 /* |
|
110 ;;; Local Variables: *** |
|
111 ;;; mode: C++ *** |
|
112 ;;; page-delimiter: "^/\\*" *** |
|
113 ;;; End: *** |
|
114 */ |