GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-spparms.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1998-2023 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_oct_spparms_h)
27 #define octave_oct_spparms_h 1
28 
29 #include "octave-config.h"
30 
31 #include <iosfwd>
32 #include <string>
33 
34 #include "Array-fwd.h"
35 #include "str-vec.h"
36 #include "dColVector.h"
37 
38 #define OCTAVE_SPARSE_CONTROLS_SIZE 13
39 
41 
43 {
44 protected:
45 
47  : m_params (OCTAVE_SPARSE_CONTROLS_SIZE),
49  {
50  init_keys ();
51  do_defaults ();
52  }
53 
54 public:
55 
56  sparse_params (const sparse_params&) = default;
57 
58  sparse_params& operator = (const sparse_params&) = default;
59 
60  ~sparse_params (void) = default;
61 
62  static bool instance_ok (void);
63 
64  static void defaults (void);
65 
66  static void tight (void);
67 
68  static string_vector get_keys (void);
69 
70  static ColumnVector get_vals (void);
71 
72  static bool set_vals (const Array<double>& vals);
73 
74  static bool set_key (const std::string& key, const double& val);
75 
76  static double get_key (const std::string& key);
77 
78  static double get_bandden (void);
79 
80  static void print_info (std::ostream& os, const std::string& prefix);
81 
82 private:
83 
85 
87 
89 
90  static void cleanup_instance (void)
91  {
92  delete s_instance;
93  s_instance = nullptr;
94  }
95 
96  void do_defaults (void);
97 
98  void do_tight (void);
99 
100  string_vector do_get_keys (void) const { return m_keys; }
101 
102  ColumnVector do_get_vals (void) const { return m_params; }
103 
104  bool do_set_vals (const Array<double>& vals);
105 
106  bool do_set_key (const std::string& key, const double& val);
107 
108  double do_get_key (const std::string& key);
109 
110  double do_get_bandden (void);
111 
112  void do_print_info (std::ostream& os, const std::string& prefix) const;
113 
114  void init_keys (void);
115 };
116 
118 
119 #if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS)
120 OCTAVE_DEPRECATED (7, "use 'octave::sparse_params' instead")
121 typedef octave::sparse_params octave_sparse_params;
122 #endif
123 
124 #endif
OCTAVE_END_NAMESPACE(octave)
ColumnVector m_params
Definition: oct-spparms.h:84
ColumnVector do_get_vals(void) const
Definition: oct-spparms.h:102
static sparse_params * s_instance
Definition: oct-spparms.h:88
string_vector m_keys
Definition: oct-spparms.h:86
sparse_params(void)
Definition: oct-spparms.h:46
~sparse_params(void)=default
static void cleanup_instance(void)
Definition: oct-spparms.h:90
sparse_params(const sparse_params &)=default
string_vector do_get_keys(void) const
Definition: oct-spparms.h:100
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition: main.in.cc:55
#define OCTAVE_SPARSE_CONTROLS_SIZE
Definition: oct-spparms.h:38