4904
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 John W. Eaton |
|
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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #include <cstdlib> |
|
24 |
|
25 #include <iostream> |
|
26 #include <string> |
|
27 |
|
28 #include "mx-base.h" |
|
29 #include "oct-alloc.h" |
|
30 #include "so-array.h" |
|
31 #include "str-vec.h" |
|
32 |
|
33 #include "error.h" |
|
34 #include "ov-base.h" |
|
35 #include "ov-base-int.h" |
|
36 #include "ov-typeinfo.h" |
|
37 |
|
38 class |
|
39 OCTAVE_VALUE_INT_MATRIX_T |
|
40 : public octave_base_int_matrix<OCTAVE_INT_NDARRAY_T> |
|
41 { |
|
42 public: |
|
43 |
|
44 OCTAVE_VALUE_INT_MATRIX_T (void) |
|
45 : octave_base_int_matrix<OCTAVE_INT_NDARRAY_T> () { } |
|
46 |
|
47 OCTAVE_VALUE_INT_MATRIX_T (const OCTAVE_INT_NDARRAY_T& nda) |
|
48 : octave_base_int_matrix<OCTAVE_INT_NDARRAY_T> (nda) { } |
|
49 |
|
50 ~OCTAVE_VALUE_INT_MATRIX_T (void) { } |
|
51 |
|
52 octave_value * |
|
53 clone (void) const |
|
54 { return new OCTAVE_VALUE_INT_MATRIX_T (*this); } |
|
55 |
|
56 octave_value * |
|
57 empty_clone (void) const |
|
58 { return new OCTAVE_VALUE_INT_MATRIX_T (); } |
|
59 |
|
60 OCTAVE_INT_NDARRAY_T |
4910
|
61 OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION (void) const |
4904
|
62 { return matrix; } |
|
63 |
4915
|
64 NDArray |
|
65 array_value (bool = false) const |
|
66 { |
|
67 NDArray retval (matrix.dims ()); |
|
68 int nel = matrix.numel (); |
|
69 for (int i = 0; i < nel; i++) |
|
70 retval (i) = double (matrix(i)); |
|
71 return retval; |
|
72 } |
|
73 |
4938
|
74 idx_vector index_vector (void) const { return idx_vector (matrix); } |
|
75 |
4904
|
76 private: |
|
77 |
|
78 DECLARE_OCTAVE_ALLOCATOR |
|
79 |
|
80 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
|
81 }; |
|
82 |
|
83 class |
|
84 OCTAVE_VALUE_INT_SCALAR_T |
|
85 : public octave_base_int_scalar<OCTAVE_INT_T> |
|
86 { |
|
87 public: |
|
88 |
|
89 OCTAVE_VALUE_INT_SCALAR_T (void) |
|
90 : octave_base_int_scalar<OCTAVE_INT_T> () { } |
|
91 |
|
92 OCTAVE_VALUE_INT_SCALAR_T (const OCTAVE_INT_T& nda) |
|
93 : octave_base_int_scalar<OCTAVE_INT_T> (nda) { } |
|
94 |
|
95 ~OCTAVE_VALUE_INT_SCALAR_T (void) { } |
|
96 |
|
97 octave_value * |
|
98 clone (void) const |
|
99 { return new OCTAVE_VALUE_INT_SCALAR_T (*this); } |
|
100 |
|
101 octave_value * |
|
102 empty_clone (void) const |
|
103 { return new OCTAVE_VALUE_INT_SCALAR_T (); } |
|
104 |
|
105 OCTAVE_INT_T |
4910
|
106 OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION (void) const |
4904
|
107 { return scalar; } |
|
108 |
|
109 OCTAVE_INT_NDARRAY_T |
4910
|
110 OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION (void) const |
|
111 { return OCTAVE_INT_NDARRAY_T (dim_vector (1, 1), scalar); } |
4904
|
112 |
4915
|
113 octave_value resize (const dim_vector& dv) const |
|
114 { OCTAVE_INT_NDARRAY_T retval (dv); if (dv.numel()) retval(0) = scalar; return retval; } |
|
115 |
|
116 NDArray |
|
117 array_value (bool = false) const |
|
118 { |
|
119 NDArray retval (dim_vector (1,1)); |
|
120 retval (0) = double (scalar); |
|
121 return retval; |
|
122 } |
|
123 |
4938
|
124 idx_vector index_vector (void) const { return idx_vector (scalar); } |
|
125 |
4904
|
126 private: |
|
127 |
|
128 DECLARE_OCTAVE_ALLOCATOR |
|
129 |
|
130 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
|
131 }; |
|
132 |
|
133 /* |
|
134 ;;; Local Variables: *** |
|
135 ;;; mode: C++ *** |
|
136 ;;; End: *** |
|
137 */ |