GNU Octave  9.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-2024 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 () = default;
61 
62  static bool instance_ok ();
63 
64  static void defaults ();
65 
66  static void tight ();
67 
68  static string_vector get_keys ();
69 
70  static ColumnVector get_vals ();
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 ();
79 
80  static void print_info (std::ostream& os, const std::string& prefix);
81 
82 private:
83 
84  ColumnVector m_params;
85 
86  string_vector m_keys;
87 
88  static sparse_params *s_instance;
89 
90  static void cleanup_instance ()
91  {
92  delete s_instance;
93  s_instance = nullptr;
94  }
95 
96  void do_defaults ();
97 
98  void do_tight ();
99 
100  string_vector do_get_keys () const { return m_keys; }
101 
102  ColumnVector do_get_vals () 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 ();
111 
112  void do_print_info (std::ostream& os, const std::string& prefix) const;
113 
114  void init_keys ();
115 };
116 
117 OCTAVE_END_NAMESPACE(octave)
118 
119 #endif
sparse_params(const sparse_params &)=default
~sparse_params()=default
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition: main.cc:55
#define OCTAVE_SPARSE_CONTROLS_SIZE
Definition: oct-spparms.h:38