GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
ov-base-mat-inst.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2024-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include "ov-base-mat.cc"
31
32// instantiate template class with types that need to be exported from library
33
34template class OCTINTERP_API octave_base_matrix<boolNDArray>;
35template class OCTINTERP_API octave_base_matrix<charNDArray>;
36template class OCTINTERP_API octave_base_matrix<int8NDArray>;
37template class OCTINTERP_API octave_base_matrix<int16NDArray>;
38template class OCTINTERP_API octave_base_matrix<int32NDArray>;
39template class OCTINTERP_API octave_base_matrix<int64NDArray>;
40template class OCTINTERP_API octave_base_matrix<uint8NDArray>;
41template class OCTINTERP_API octave_base_matrix<uint16NDArray>;
42template class OCTINTERP_API octave_base_matrix<uint32NDArray>;
43template class OCTINTERP_API octave_base_matrix<uint64NDArray>;
44template class OCTINTERP_API octave_base_matrix<ComplexNDArray>;
45template class OCTINTERP_API octave_base_matrix<FloatComplexNDArray>;
46template class OCTINTERP_API octave_base_matrix<FloatNDArray>;
47template class OCTINTERP_API octave_base_matrix<NDArray>;
48
49
50// Cell is able to handle octave_value indexing by itself, so just forward
51// everything.
52
53template <>
56 bool resize_ok)
57{
58 return m_matrix.index (idx, resize_ok);
59}
60
61template <>
62void
64{
65 m_matrix.assign (idx, rhs);
66}
67
68template <>
69void
71 octave_value rhs)
72{
73 // FIXME: Really?
74 if (rhs.iscell ())
75 m_matrix.assign (idx, rhs.cell_value ());
76 else
77 m_matrix.assign (idx, Cell (rhs));
78}
79
80template <>
81void
83{
84 m_matrix.delete_elements (idx);
85}
86
87// FIXME: this list of specializations is becoming so long that we should
88// really ask whether octave_cell should inherit from octave_base_matrix at all.
89
90template <>
91std::string
94 octave_idx_type j) const
95{
96 octave_value val = m_matrix(i, j);
97
98 std::string tname = val.type_name ();
99 dim_vector dv = val.dims ();
100 std::string dimstr = dv.str ();
101 return "[" + dimstr + " " + tname + "]";
102}
103
104template <>
107{
108 if (n < m_matrix.numel ())
109 return Cell (m_matrix(n));
110 else
111 return octave_value ();
112}
113
114template <>
115bool
117 const octave_value& x)
118{
119 const octave_base_matrix<Cell> *xrep
120 = dynamic_cast<const octave_base_matrix<Cell> *> (&x.get_rep ());
121
122 bool retval = xrep && xrep->m_matrix.numel () == 1 && n < m_matrix.numel ();
123 if (retval)
124 m_matrix(n) = xrep->m_matrix(0);
125
126 return retval;
127}
128
129
130// FIXME: 2025-03-11: GCC emits the warning "type attributes ignored after type
131// is already defined/[-Wattributes]" for the following template class
132// instantiation. The clang compiler does not issue a warning. More
133// importantly Octave builds and runs correctly with "-fvisibility=hidden".
134// Therefore, this seems like a false positive that can be ignored. Multiple
135// attempts have been made to try and locate the prior definition, but without
136// success.
137#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC
138# pragma GCC diagnostic push
139# pragma GCC diagnostic ignored "-Wattributes"
140template class OCTINTERP_API octave_base_matrix<Cell>;
141# pragma GCC diagnostic pop
142#else
143template class OCTINTERP_API octave_base_matrix<Cell>;
144#endif
Definition Cell.h:41
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
std::string str(char sep='x') const
Definition dim-vector.cc:68
bool fast_elem_insert(octave_idx_type n, const octave_value &x)
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
void delete_elements(const octave_value_list &idx)
octave_value fast_elem_extract(octave_idx_type n) const
void assign(const octave_value_list &idx, const MT &rhs)
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
Cell cell_value() const
bool iscell() const
Definition ov.h:604
octave_value & assign(assign_op op, const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
std::string type_name() const
Definition ov.h:1360
dim_vector dims() const
Definition ov.h:541
F77_RET_T const F77_DBLE * x