Mercurial > octave
comparison libinterp/octave-value/ov-base-scalar.h @ 33339:abdb846bafe8
Instantiate octave_base_matrix and octave_base_scalar template classes
* ov-base-mat-inst.cc: Add new file to explicitly instantiate template class
octave_base_matrix with types that need to be exported from liboctinterp.
* ov-base-scalar-inst.cc: Add new file to explicitly instantiate template class
octave_base_scalar with types that need to be exported from liboctinterp.
* ov-base-scalar-int-inst.cc: Add new file to explicitly instantiate template
classes octave_base_int_matrix and octave_base_int_scalar with types that need
to be exported from liboctinterp.
* ov-base-mat.h, ov-base-scalar.h: Use macro for template export. Mark all
member functions for export.
* ov-bool-mat.cc, ov-bool-mat.h, ov-bool.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc,
ov-ch-mat.h, ov-complex.cc, ov-complex.h, ov-cx-mat.cc, ov-cx-mat.h,
ov-float.cc, ov-float.h, ov-float-complex.cc, ov-float-complex.h,
ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-mat.cc, ov-flt-re-mat.h,
ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-intx.h, ov-re-mat.cc,
ov-re-mat.h, ov-scalar.cc, ov-scalar.h, ov-uint16.cc, ov-uint32.cc,
ov-uint64.cc, ov-uint8.cc: Instantiate template classes octave_base_matrix,
octave_base_scalar, octave_base_int_matrix, and octave_base_int_scalar only in
one compilation unit. Move extern template class declarations to headers.
* ov-base-int.cc: Remove includes that are not needed to prevent potentially
unpredicted template instantiations.
* ov-base-int.h: Add extern template declarations to avoid multiple
instantiations of template class in different compilation units. Add export
attributes to all member functions of template class.
* ov-base-int.h: Use export attributes for template classes that better work
cross-platform.
* ov-base.h: Add export attributes to undefined functions.
* ov-cell.cc: Move octave_base_matrix<cell> specializations to
ov-base-mat-inst.cc.
* libinterp/octave-value/module.mk: Add new files to build system.
See: https://octave.discourse.group/t/5211
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 21 Jan 2024 19:34:01 +0100 |
parents | 4b601ca024d5 |
children | c2dbaa9dca4f |
comparison
equal
deleted
inserted
replaced
33338:714c6d2e253e | 33339:abdb846bafe8 |
---|---|
48 { | 48 { |
49 public: | 49 public: |
50 | 50 |
51 typedef ST scalar_type; | 51 typedef ST scalar_type; |
52 | 52 |
53 octave_base_scalar () | 53 OCTINTERP_API octave_base_scalar () |
54 : octave_base_value (), scalar () { } | 54 : octave_base_value (), scalar () { } |
55 | 55 |
56 octave_base_scalar (const ST& s) | 56 OCTINTERP_API octave_base_scalar (const ST& s) |
57 : octave_base_value (), scalar (s) { } | 57 : octave_base_value (), scalar (s) { } |
58 | 58 |
59 octave_base_scalar (const octave_base_scalar& s) | 59 OCTINTERP_API octave_base_scalar (const octave_base_scalar& s) |
60 : octave_base_value (), scalar (s.scalar) { } | 60 : octave_base_value (), scalar (s.scalar) { } |
61 | 61 |
62 ~octave_base_scalar () = default; | 62 OCTINTERP_API ~octave_base_scalar () = default; |
63 | 63 |
64 octave_value squeeze () const { return scalar; } | 64 OCTINTERP_API octave_value squeeze () const { return scalar; } |
65 | 65 |
66 octave_value full_value () const { return scalar; } | 66 OCTINTERP_API octave_value full_value () const { return scalar; } |
67 | 67 |
68 // We don't need to override all three forms of subsref. The using | 68 // We don't need to override all three forms of subsref. The using |
69 // declaration will avoid warnings about partially-overloaded virtual | 69 // declaration will avoid warnings about partially-overloaded virtual |
70 // functions. | 70 // functions. |
71 using octave_base_value::subsref; | 71 using octave_base_value::subsref; |
72 | 72 |
73 OCTINTERP_API octave_value | 73 OCTINTERP_API octave_value |
74 subsref (const std::string& type, const std::list<octave_value_list>& idx); | 74 subsref (const std::string& type, const std::list<octave_value_list>& idx); |
75 | 75 |
76 octave_value_list subsref (const std::string& type, | 76 OCTINTERP_API octave_value_list |
77 const std::list<octave_value_list>& idx, int) | 77 subsref (const std::string& type, const std::list<octave_value_list>& idx, int) |
78 { return subsref (type, idx); } | 78 { return subsref (type, idx); } |
79 | 79 |
80 OCTINTERP_API octave_value | 80 OCTINTERP_API octave_value |
81 subsasgn (const std::string& type, const std::list<octave_value_list>& idx, | 81 subsasgn (const std::string& type, const std::list<octave_value_list>& idx, |
82 const octave_value& rhs); | 82 const octave_value& rhs); |
83 | 83 |
84 bool is_constant () const { return true; } | 84 OCTINTERP_API bool is_constant () const { return true; } |
85 | 85 |
86 bool is_defined () const { return true; } | 86 OCTINTERP_API bool is_defined () const { return true; } |
87 | 87 |
88 OCTINTERP_API dim_vector dims () const; | 88 OCTINTERP_API dim_vector dims () const; |
89 | 89 |
90 octave_idx_type numel () const { return 1; } | 90 OCTINTERP_API octave_idx_type numel () const { return 1; } |
91 | 91 |
92 int ndims () const { return 2; } | 92 OCTINTERP_API int ndims () const { return 2; } |
93 | 93 |
94 octave_idx_type nnz () const { return (scalar != ST () ? 1 : 0); } | 94 OCTINTERP_API octave_idx_type nnz () const { return (scalar != ST () ? 1 : 0); } |
95 | 95 |
96 OCTINTERP_API octave_value permute (const Array<int>&, bool = false) const; | 96 OCTINTERP_API octave_value permute (const Array<int>&, bool = false) const; |
97 | 97 |
98 OCTINTERP_API octave_value reshape (const dim_vector& new_dims) const; | 98 OCTINTERP_API octave_value reshape (const dim_vector& new_dims) const; |
99 | 99 |
100 std::size_t byte_size () const { return sizeof (ST); } | 100 OCTINTERP_API std::size_t byte_size () const { return sizeof (ST); } |
101 | 101 |
102 octave_value all (int = 0) const { return (scalar != ST ()); } | 102 OCTINTERP_API octave_value all (int = 0) const { return (scalar != ST ()); } |
103 | 103 |
104 octave_value any (int = 0) const { return (scalar != ST ()); } | 104 OCTINTERP_API octave_value any (int = 0) const { return (scalar != ST ()); } |
105 | 105 |
106 OCTINTERP_API octave_value diag (octave_idx_type k = 0) const; | 106 OCTINTERP_API octave_value diag (octave_idx_type k = 0) const; |
107 | 107 |
108 OCTINTERP_API octave_value diag (octave_idx_type m, octave_idx_type n) const; | 108 OCTINTERP_API octave_value diag (octave_idx_type m, octave_idx_type n) const; |
109 | 109 |
110 octave_value sort (octave_idx_type, sortmode) const | 110 OCTINTERP_API octave_value sort (octave_idx_type, sortmode) const |
111 { return octave_value (scalar); } | 111 { return octave_value (scalar); } |
112 octave_value sort (Array<octave_idx_type>& sidx, octave_idx_type, | 112 |
113 sortmode) const | 113 OCTINTERP_API octave_value |
114 sort (Array<octave_idx_type>& sidx, octave_idx_type, sortmode) const | |
114 { | 115 { |
115 sidx.resize (dim_vector (1, 1)); | 116 sidx.resize (dim_vector (1, 1)); |
116 sidx(0) = 0; | 117 sidx(0) = 0; |
117 return octave_value (scalar); | 118 return octave_value (scalar); |
118 } | 119 } |
119 | 120 |
120 sortmode issorted (sortmode mode = UNSORTED) const | 121 OCTINTERP_API sortmode issorted (sortmode mode = UNSORTED) const |
121 { return mode == UNSORTED ? ASCENDING : mode; } | 122 { return mode == UNSORTED ? ASCENDING : mode; } |
122 | 123 |
123 Array<octave_idx_type> sort_rows_idx (sortmode) const | 124 OCTINTERP_API Array<octave_idx_type> sort_rows_idx (sortmode) const |
124 { | 125 { |
125 return Array<octave_idx_type> (dim_vector (1, 1), | 126 return Array<octave_idx_type> (dim_vector (1, 1), |
126 static_cast<octave_idx_type> (0)); | 127 static_cast<octave_idx_type> (0)); |
127 } | 128 } |
128 | 129 |
129 sortmode is_sorted_rows (sortmode mode = UNSORTED) const | 130 OCTINTERP_API sortmode is_sorted_rows (sortmode mode = UNSORTED) const |
130 { return mode == UNSORTED ? ASCENDING : mode; } | 131 { return mode == UNSORTED ? ASCENDING : mode; } |
131 | 132 |
132 MatrixType matrix_type () const { return MatrixType::Diagonal; } | 133 OCTINTERP_API MatrixType matrix_type () const |
133 MatrixType matrix_type (const MatrixType&) const | 134 { return MatrixType::Diagonal; } |
135 | |
136 OCTINTERP_API MatrixType matrix_type (const MatrixType&) const | |
134 { return matrix_type (); } | 137 { return matrix_type (); } |
135 | 138 |
136 bool is_maybe_function () const { return false; } | 139 OCTINTERP_API bool is_maybe_function () const { return false; } |
137 | 140 |
138 bool is_scalar_type () const { return true; } | 141 OCTINTERP_API bool is_scalar_type () const { return true; } |
139 | 142 |
140 bool isnumeric () const { return true; } | 143 OCTINTERP_API bool isnumeric () const { return true; } |
141 | 144 |
142 OCTINTERP_API bool is_true () const; | 145 OCTINTERP_API bool is_true () const; |
143 | 146 |
144 OCTINTERP_API void print (std::ostream& os, bool pr_as_read_syntax = false); | 147 OCTINTERP_API void print (std::ostream& os, bool pr_as_read_syntax = false); |
145 | 148 |
157 edit_display (const float_display_format& fmt, | 160 edit_display (const float_display_format& fmt, |
158 octave_idx_type i, octave_idx_type j) const; | 161 octave_idx_type i, octave_idx_type j) const; |
159 | 162 |
160 // This function exists to support the MEX interface. | 163 // This function exists to support the MEX interface. |
161 // You should not use it anywhere else. | 164 // You should not use it anywhere else. |
162 const void * mex_get_data () const { return &scalar; } | 165 OCTINTERP_API const void * mex_get_data () const { return &scalar; } |
163 | 166 |
164 const ST& scalar_ref () const { return scalar; } | 167 OCTINTERP_API const ST& scalar_ref () const { return scalar; } |
165 | 168 |
166 ST& scalar_ref () { return scalar; } | 169 OCTINTERP_API ST& scalar_ref () { return scalar; } |
167 | 170 |
168 OCTINTERP_API octave_value fast_elem_extract (octave_idx_type n) const; | 171 OCTINTERP_API octave_value fast_elem_extract (octave_idx_type n) const; |
169 | 172 |
170 OCTINTERP_API bool | 173 OCTINTERP_API bool |
171 fast_elem_insert_self (void *where, builtin_type_t btyp) const; | 174 fast_elem_insert_self (void *where, builtin_type_t btyp) const; |