Class
NumCosmoMathModel
Description [src]
abstract class NumCosmoMath.Model : GObject.Object
{
/* No available fields */
}
Abstract class for a model: a vector of parameters with their descriptions.
A subclass declares, in its class initialization, scalar parameters
(ncm_model_class_set_sparam()) and vector parameters (ncm_model_class_set_vparam()),
which become the properties name and name-fit for a scalar, and name,
name-length and name-fit for a vector; the parameters are laid out scalars first,
then each vector (ncm_model_vparam_index()). Every parameter starts FIXED;
ncm_model_params_set_default_ftype() applies the fit types of the descriptions.
Submodels are attached at construction, through the slots declared with ncm_model_class_set_submodel().
A NcmReparam, once set (ncm_model_set_reparam()), defines the current parameters:
the ncm_model_param_() functions read and write them and the ncm_model_orig_param_()
functions the original ones, kept in step on every update. Every change of the
parameters increments the pkey (ncm_model_state_get_pkey()) that NcmModelCtrl
compares. Models are combined in an NcmMSet by their registered model id.
Functions
ncm_model_type_main_model
If model_type is a submodel returns the NcmModelID of its
main model, otherwise returns -1.
Instance methods
ncm_model_add_submodel
Attaches submodel to model. Submodels are construction-fixed: they are given while
model is being constructed, through its submodel slot properties. Attaching after
construction is deprecated, kept only for 0.27 compatibility and dropped in 1.0; do
not use it. Aborts when submodel already belongs to another host, when model
already has a submodel with the model id of submodel, and, on the deprecated path,
when model‘s class declares no slot for submodel‘s type. An override must chain up.
ncm_model_free
Atomically decrements the reference count of model by one. If the reference count drops to 0,
all memory allocated by model is released.
ncm_model_lstate_is_update
Check if the i-th lstate is updated.
The parameter i must be smaller than #NCM_MODEL_MAX_STATES.
ncm_model_main_model
If model is a submodel returns the NcmModelID of its
main model, otherwise returns -1.
ncm_model_orig_param_get
Gets the n-th original parameter of model using the original parametrization.
ncm_model_orig_param_index_from_name
Looks for the original parameter named param_name and sets i to its index, or to
G_MAXUINT when there is none.
ncm_model_orig_param_set
Sets the n-th original parameter of model using the original
parametrization to val.
ncm_model_orig_params_log_all
Logs all original parameters of model. That is if there is a reparametrization
set, it return the values of the original parameters.
ncm_model_orig_params_peek_vector
Peeks the original parameters vector. This functions is provided for reparametrization implementations and subclassing, do not use it in other contexts.
ncm_model_orig_params_update
Marks the parameters as changed (increments the pkey) and, under a reparametrization, computes the new parameters from the original ones.
ncm_model_orig_vparam_set_vector
Sets the original vector parameter n to val; aborts when the length of val is not
that of the vector parameter.
ncm_model_param_get_desc
Gets the description of the parameter param (found as in
ncm_model_param_index_from_name_full()), with the keys “name” and “symbol” (strings),
“scale”, “lower-bound”, “upper-bound”, “abstol” and “value” (doubles) and “fit” (boolean).
ncm_model_param_index_from_name
Looks for the parameter named param_name among the current parameters and sets i to
its index. A name of the reparametrization is found first; an original name is found
only when the reparametrization does not describe that parameter, and otherwise sets
NCM_MODEL_ERROR_PARAM_CHANGED.
ncm_model_param_index_from_name_full
Like ncm_model_param_index_from_name(), but also reaches into model‘s
attached submodels when the parameter is not found on model itself.
ncm_model_param_set0
Sets the n-th parameter of model to val. This function does not
update the model after setting the parameter. It is provided when
multiple parameters are set at once the model is updated only once.
ncm_model_params_update() must be called after setting all parameters.
ncm_model_param_set_desc
Sets, for the parameter param (found as in ncm_model_param_index_from_name_full()),
the entries of desc among “scale”, “lower-bound”, “upper-bound”, “abstol” and “value”
(doubles) and “fit” (boolean). Any other key, or a value of the wrong type, sets
error and stops; the entries applied before it stay applied.
ncm_model_params_copyto
Copies the parameters of model to model_dest; the two must be equal in the sense of ncm_model_is_equal().
ncm_model_params_log_all
Logs all parameters of model. It prints the values of the parameters
in the current reparametrization.
ncm_model_params_save_as_default
Saves the current parameters as the default values of their descriptions, with the same fallback as ncm_model_params_set_default().
ncm_model_params_set_all
Sets all parameters of model to the values passed as arguments.
The number of arguments must be equal to the number of parameters.
ncm_model_params_set_all_data
Sets all parameters of model to the values passed as arguments.
The size of the array must be equal to the number of parameters.
ncm_model_params_set_default
Sets every parameter to the default value of its description; a new parameter of a reparametrization without a description of its own takes the original’s.
ncm_model_params_set_model
Sets the parameters of model to those of model_src; the two must be equal in the
sense of ncm_model_is_equal().
ncm_model_params_set_vector
Sets all parameters of model to the values of v.
The size of v must be equal to the number of parameters.
ncm_model_params_update
Marks the parameters as changed (increments the pkey) and, under a reparametrization, computes the original parameters from the new ones.
ncm_model_peek_host
If submodel is currently attached as a submodel of some host NcmModel
(through ncm_model_add_submodel()), gets that host without increasing
its reference count. This is a pure function of submodel‘s own current
attachment state — it never reaches outside submodel itself.
ncm_model_set_reparam
Sets the reparametrization of model to reparam and computes its parameters from the
original ones. A reparametrization for another length is rebuilt at the model’s
length when it carries nothing but descriptions of existing parameters. It cannot be
removed: NULL does nothing on a model without one and aborts on a model with one.
ncm_model_set_vparam_len
Given a vector parameter index, sets the length of the n-th vector to len.
This function is provided for model implementations, do not use it in
other contexts. It will be removed in future versions.
ncm_model_vparam_array_len
Count the number of vector parameters of the model. Note that this function returns the number of vector parameters of the model, not the length of the vector parameters.
ncm_model_vparam_index
Given a vector parameter index and a component index, returns the index of the
i-th component of the n-th vector in the full parameter vector.
Properties
NumCosmoMath.Model:implementation
The implementation flags of the model class, see ncm_model_check_impl_flag().
NumCosmoMath.Model:sparam-array
The parameter descriptions that differ from the class ones, NcmSParam keyed by
parameter index. Each one is placed by its parameter name: a description of a
parameter declared with ncm_model_class_add_removed_param() is skipped, and one of
any other unknown parameter aborts.
Signals
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.
Class structure
struct NumCosmoMathModelClass {
void (* get_property) (
GObject* object,
guint prop_id,
GValue* value,
GParamSpec* pspec
);
void (* set_property) (
GObject* object,
guint prop_id,
const GValue* value,
GParamSpec* pspec
);
gboolean (* valid) (
NcmModel* model
);
}
No description available.
Class members
get_property: void (* get_property) ( GObject* object, guint prop_id, GValue* value, GParamSpec* pspec )No description available.
set_property: void (* set_property) ( GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec )No description available.
valid: gboolean (* valid) ( NcmModel* model )No description available.
Virtual methods
NumCosmoMath.ModelClass.add_submodel
Attaches submodel to model. Submodels are construction-fixed: they are given while
model is being constructed, through its submodel slot properties. Attaching after
construction is deprecated, kept only for 0.27 compatibility and dropped in 1.0; do
not use it. Aborts when submodel already belongs to another host, when model
already has a submodel with the model id of submodel, and, on the deprecated path,
when model‘s class declares no slot for submodel‘s type. An override must chain up.
Class methods
ncm_model_class_add_impl_flag
For the class initialization of a model: adds flag to the class’s
implementation flags.
ncm_model_class_add_impl_opts
For the class initialization of a model: adds the implementation options
opt1, … to the class’s implementation flags.
ncm_model_class_add_params
For the class initialization of a model: adds sparam_len scalar and vparam_len
vector parameters to those of the parent class and installs the property dispatchers
(see ncm_model_class_check_params_info()).
ncm_model_class_add_removed_param
Declares name as removed from the class: a stored description of it in
NcmModel:sparam-array is skipped. Subclasses inherit the declaration.
ncm_model_class_add_submodels
Class function to be used when implementing NcmModels. It declares that the
model has submodel_slot_len submodel slots, in addition to any inherited
from the parent class. Submodels can only be attached at construction time,
through the slots declared with ncm_model_class_set_submodel(). It must be
called after ncm_model_class_add_params().
ncm_model_class_check_params_info
For the end of the class initialization of a model: aborts when a declared parameter was not set, when the class replaced the property dispatchers installed by ncm_model_class_add_params(), or when it has properties of its own but no NcmModelClass set_property/get_property.
ncm_model_class_set_name_nick
Sets the name and nickname of the model class; a subclass replaces those it inherits.
ncm_model_class_set_sparam
Same as ncm_model_class_set_sparam_obj() with a NcmSParam built by ncm_sparam_new().
ncm_model_class_set_sparam_obj
Sets sparam as the scalar parameter sparam_id of the class and installs its
name and name-fit properties.
ncm_model_class_set_submodel
Sets the submodel_slot_id-th submodel slot of the model. The slot is
exposed as a construct-only, type-checked object property named name. The
submodel is therefore part of the model’s structure, fixed at construction.
ncm_model_class_set_vparam
Same as ncm_model_class_set_vparam_obj() with a NcmVParam built by ncm_vparam_full_new().
ncm_model_class_set_vparam_obj
Sets vparam as the vector parameter vparam_id of the class and installs its
name, name-length and name-fit properties.