1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2008-2021 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 (octave_ov_flt_re_diag_h)
27 #define octave_ov_flt_re_diag_h 1
28 
29 #include "octave-config.h"
30 
31 #include "ov-base.h"
32 #include "ov-base-diag.h"
33 #include "ov-flt-re-mat.h"
34 #include "ov-typeinfo.h"
35 
36 // Real diagonal matrix values.
37 
38 class
39 OCTINTERP_API
40 octave_float_diag_matrix
41   : public octave_base_diag<FloatDiagMatrix, FloatMatrix>
42 {
43 public:
44 
octave_float_diag_matrix(void)45   octave_float_diag_matrix (void)
46     : octave_base_diag<FloatDiagMatrix, FloatMatrix> () { }
47 
octave_float_diag_matrix(const FloatDiagMatrix & m)48   octave_float_diag_matrix (const FloatDiagMatrix& m)
49     : octave_base_diag<FloatDiagMatrix, FloatMatrix> (m) { }
50 
octave_float_diag_matrix(const octave_float_diag_matrix & m)51   octave_float_diag_matrix (const octave_float_diag_matrix& m)
52     : octave_base_diag<FloatDiagMatrix, FloatMatrix> (m) { }
53 
54   ~octave_float_diag_matrix (void) = default;
55 
clone(void)56   octave_base_value * clone (void) const
57   { return new octave_float_diag_matrix (*this); }
empty_clone(void)58   octave_base_value * empty_clone (void) const
59   { return new octave_float_diag_matrix (); }
60 
61   type_conv_info numeric_conversion_function (void) const;
62 
63   octave_base_value * try_narrowing_conversion (void);
64 
builtin_type(void)65   builtin_type_t builtin_type (void) const { return btyp_float; }
66 
is_real_matrix(void)67   bool is_real_matrix (void) const { return true; }
68 
isreal(void)69   bool isreal (void) const { return true; }
70 
is_single_type(void)71   bool is_single_type (void) const { return true; }
72 
isfloat(void)73   bool isfloat (void) const { return true; }
74 
75   DiagMatrix diag_matrix_value (bool = false) const;
76 
77   FloatDiagMatrix float_diag_matrix_value (bool = false) const;
78 
79   ComplexDiagMatrix complex_diag_matrix_value (bool = false) const;
80 
81   FloatComplexDiagMatrix float_complex_diag_matrix_value (bool = false) const;
82 
83   octave_value as_double (void) const;
84   octave_value as_single (void) const;
85 
86   octave_value as_int8 (void) const;
87   octave_value as_int16 (void) const;
88   octave_value as_int32 (void) const;
89   octave_value as_int64 (void) const;
90 
91   octave_value as_uint8 (void) const;
92   octave_value as_uint16 (void) const;
93   octave_value as_uint32 (void) const;
94   octave_value as_uint64 (void) const;
95 
96   bool save_binary (std::ostream& os, bool save_as_floats);
97 
98   bool load_binary (std::istream& is, bool swap,
99                     octave::mach_info::float_format fmt);
100 
101   octave_value map (unary_mapper_t umap) const;
102 
103 private:
104 
105   bool chk_valid_scalar (const octave_value&,
106                          float&) const;
107 
108   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
109 };
110 
111 #endif
112