Top |
guint64 | implementation | Read |
char * | name | Read |
char * | nick | Read |
GArray * | params-types | Read |
NcmReparam * | reparam | Read / Write |
guint | scalar-params-len | Read |
NcmObjDictInt * | sparam-array | Read / Write |
NcmObjArray * | submodel-array | Read / Write |
guint | vector-params-len | Read |
#define | NCM_TYPE_MODEL |
typedef | NcmModelID |
struct | NcmModelClass |
#define | NCM_MODEL_MAX_STATES |
#define | NCM_MODEL_CLASS_IMPL_ALL |
NcmModel |
GObject ╰── NcmModel ├── NcClusterMass ├── NcClusterRedshift ├── NcClusterPseudoCounts ├── NcHaloDensityProfile ├── NcHICosmo ├── NcHICosmoQSplineContPrior ├── NcHIPrim ├── NcHIReion ├── NcPlanckFI ├── NcReducedShearCalib ├── NcReducedShearClusterMass ├── NcSNIADistCov ├── NcWLSurfaceMassDensity ├── NcXcorLimberKernel ├── NcmModelFunnel ├── NcmModelMVND ╰── NcmModelRosenbrock
The NcmModel abstract class represents a general model. This object serves for two general objectives. First, all the numerical properties (doubles), i.e., parameters, are implemented by the class functions described below, this allows the implementation of a general statistical analyses based on these models. Second, each child of NcmModel can register itself as a model type. This allows multiples models types to be used simultaneously.
gdouble (*NcmModelVFunc2) (NcmModel *model
,const guint n
,const gdouble x
,const gdouble y
);
void ncm_model_class_add_params (NcmModelClass *model_class
,guint sparam_len
,guint vparam_len
,guint nonparam_prop_len
);
Class function to be used when implementing NcmModels, it defines the number of scalar and vector parameters and the number of properties of the model.
void ncm_model_class_set_name_nick (NcmModelClass *model_class
,const gchar *name
,const gchar *nick
);
Attributes name
and nick
, respectively, as the name and nickname of the model.
void ncm_model_class_set_sparam_obj (NcmModelClass *model_class
,guint sparam_id
,NcmSParam *sparam
);
Sets the sparam
as the sparam_id
-th scalar parameter of the model.
void ncm_model_class_set_vparam_obj (NcmModelClass *model_class
,guint vparam_id
,NcmVParam *vparam
);
Sets the vparam
as the vparam_id
-th vector parameter of the model.
void ncm_model_class_set_sparam (NcmModelClass *model_class
,guint sparam_id
,const gchar *symbol
,const gchar *name
,gdouble lower_bound
,gdouble upper_bound
,gdouble scale
,gdouble abstol
,gdouble default_value
,NcmParamType ppt
);
Helper function to set a scalar parameter. It creates a NcmSParam object
and calls ncm_model_class_set_sparam_obj()
.
void ncm_model_class_set_vparam (NcmModelClass *model_class
,guint vparam_id
,guint default_length
,const gchar *symbol
,const gchar *name
,gdouble lower_bound
,gdouble upper_bound
,gdouble scale
,gdouble abstol
,gdouble default_value
,NcmParamType ppt
);
Helper function to set a vector parameter. It creates a NcmVParam object
and calls ncm_model_class_set_vparam_obj()
.
model_class |
||
vparam_id |
id of the vector parameter |
|
default_length |
default length of the vector parameter |
|
symbol |
symbol of the vector parameter |
|
name |
name of the vector parameter |
|
lower_bound |
parameter lower bound |
|
upper_bound |
parameter upper bound |
|
scale |
parameter scale |
|
abstol |
parameter absolute tolerance |
|
default_value |
default value |
|
ppt |
void
ncm_model_class_check_params_info (NcmModelClass *model_class
);
Class function to be used when implementing NcmModels, it checks if the parameters information is correctly set. It must be called after all parameters are set during the class initialization.
void ncm_model_class_add_impl_opts (NcmModelClass *model_class
,gint opt1
,...
);
Class function to be used when implementing NcmModels, it defines the implementation options of the model.
[skip]
void ncm_model_class_add_impl_flag (NcmModelClass *model_class
,guint64 flag
);
Class function to be used when implementing NcmModels, it defines the implementation flags of the model.
[skip]
NcmModel * ncm_model_dup (NcmModel *model
,NcmSerialize *ser
);
Duplicates model
by serializing and deserializing it.
NcmModel *
ncm_model_ref (NcmModel *model
);
Increments the reference count of model
by one.
void
ncm_model_free (NcmModel *model
);
Atomically decrements the reference count of model
by one. If the reference count drops to 0,
all memory allocated by model
is released.
void
ncm_model_clear (NcmModel **model
);
Atomically decrements the reference count of model
by one. If the reference count drops to 0,
all memory allocated by model
is released. Set pointer to NULL.
void ncm_model_set_reparam (NcmModel *model
,NcmReparam *reparam
);
Sets the reparametrization of model
to reparam
.
gboolean ncm_model_is_equal (NcmModel *model1
,NcmModel *model2
);
Compares if model1 and model2 are the same, with same dimension and reparametrization.
NcmModelID
ncm_model_id_by_type (GType model_type
);
Gets the model id of a model type. It is an error to call this function with a type that is not a subclass of NcmModel.
gboolean ncm_model_check_impl_flag (NcmModel *model
,guint64 impl
);
Checks if the model implements the impl
flag.
gboolean ncm_model_check_impl_opt (NcmModel *model
,gint opt
);
Checks if the model implements the opt
option.
gboolean ncm_model_check_impl_opts (NcmModel *model
,gint opt1
,...
);
Checks if the model implements all the opt1
, opt2
, ... options.
The last argument must be -1.
model |
a NcmModel |
|
opt1 |
first implementation option |
|
... |
implementation options, must end with -1 |
guint
ncm_model_len (NcmModel *model
);
Count the total number of parameters of the model.
gboolean
ncm_model_state_is_update (NcmModel *model
);
Check if the model is updated.
void
ncm_model_state_set_update (NcmModel *model
);
Set the model as updated.
gboolean ncm_model_lstate_is_update (NcmModel *model
,guint i
);
Check if the i
-th lstate is updated.
The parameter i
must be smaller than NCM_MODEL_MAX_STATES.
void ncm_model_lstate_set_update (NcmModel *model
,guint i
);
Sets the i
-th lstate as updated. The parameter i
must be smaller than
NCM_MODEL_MAX_STATES.
void
ncm_model_state_mark_outdated (NcmModel *model
);
Set the model as outdated.
guint64
ncm_model_state_get_pkey (NcmModel *model
);
Get the current pkey of the model.
guint
ncm_model_sparam_len (NcmModel *model
);
Count the number of scalar parameters of the model.
guint
ncm_model_vparam_array_len (NcmModel *model
);
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.
void ncm_model_set_vparam_len (NcmModel *model
,guint n
,guint 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.
guint ncm_model_vparam_index (NcmModel *model
,guint n
,guint i
);
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.
guint ncm_model_vparam_len (NcmModel *model
,guint n
);
Given a vector parameter index, returns the length of the n
-th vector.
NcmReparam *
ncm_model_peek_reparam (NcmModel *model
);
Peeks the current reparametrization of model
.
gboolean
ncm_model_params_finite (NcmModel *model
);
Check if all parameters are finite.
gboolean ncm_model_param_finite (NcmModel *model
,guint i
);
Check if the i
-th parameter is finite.
void
ncm_model_params_update (NcmModel *model
);
Force the parameters to the update its internal flags and update the original parameters if necessary.
void
ncm_model_orig_params_update (NcmModel *model
);
Update the new parameters. It causes an error to call this function with a model without reparametrization.
NcmVector *
ncm_model_orig_params_peek_vector (NcmModel *model
);
Peeks the original parameters vector. This functions is provided for reparametrization implementations and subclassing, do not use it in other contexts.
The returned vector is the original parameters vector, that is, the parameters
before the reparametrization. It is guaranteed that the returned vector is
always the same and will stay valid until the model is destroyed.
The vector also always have stride 1, so it is safe to call ncm_vector_fast_get()
.
void
ncm_model_orig_params_log_all (NcmModel *model
);
Logs all original parameters of model
. That is if there is a reparametrization
set, it return the values of the original parameters.
void ncm_model_param_set (NcmModel *model
,guint n
,gdouble val
);
Sets the n
-th parameter of model
to val
.
void ncm_model_param_set0 (NcmModel *model
,guint n
,gdouble val
);
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.
void ncm_model_param_set_default (NcmModel *model
,guint n
);
Sets the n
-th parameter of model
to its default value.
void ncm_model_orig_param_set (NcmModel *model
,guint n
,gdouble val
);
Sets the n
-th original parameter of model
using the original
parametrization to val
.
void ncm_model_orig_vparam_set (NcmModel *model
,guint n
,guint i
,gdouble val
);
void ncm_model_orig_vparam_set_vector (NcmModel *model
,guint n
,NcmVector *val
);
Sets the n
-th vector parameter of model
to val
.
The size of val
must be equal to the length of the n
-th vector parameter.
gdouble ncm_model_param_get (NcmModel *model
,guint n
);
Gets the n
-th parameter of model
.
gdouble ncm_model_orig_param_get (NcmModel *model
,guint n
);
Gets the n
-th original parameter of model
using the original
parametrization.
NcmVector * ncm_model_orig_vparam_get_vector (NcmModel *model
,guint n
);
Gets the n
-th vector parameter of model
.
void ncm_model_params_copyto (NcmModel *model
,NcmModel *model_dest
);
Copies the parameters of model
to model_dest
.
void
ncm_model_params_set_default (NcmModel *model
);
Sets the models parameters to their default values.
void
ncm_model_params_save_as_default (NcmModel *model
);
Saves the current parameters as the default values.
void ncm_model_params_set_all (NcmModel *model
,...
);
Sets all parameters of model
to the values passed as arguments.
The number of arguments must be equal to the number of parameters.
void ncm_model_params_set_all_data (NcmModel *model
,gdouble *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.
void ncm_model_params_set_vector (NcmModel *model
,NcmVector *v
);
Sets all parameters of model
to the values of v
.
The size of v
must be equal to the number of parameters.
void ncm_model_params_set_model (NcmModel *model
,NcmModel *model_src
);
Sets all parameters of model
to the values of model_src
.
void ncm_model_params_print_all (NcmModel *model
,FILE *out
);
Prints all parameters of model
to out
.
[skip]
void
ncm_model_params_log_all (NcmModel *model
);
Logs all parameters of model
. It prints the values of the parameters
in the current reparametrization.
NcmVector *
ncm_model_params_get_all (NcmModel *model
);
Creates a NcmVector with all parameters of model
.
gboolean
ncm_model_params_valid (NcmModel *model
);
Check whenever the parameters are valid.
gboolean
ncm_model_params_valid_bounds (NcmModel *model
);
Check whenever the parameters respect the bounds.
gboolean ncm_model_orig_param_index_from_name (NcmModel *model
,const gchar *param_name
,guint *i
);
Looks for parameter named param_name
in the original parameters of model
and puts its index in i
and returns TRUE if found.
gboolean ncm_model_param_index_from_name (NcmModel *model
,const gchar *param_name
,guint *i
);
Looks for parameter named param_name
in model
and puts its index in i
and returns TRUE if found.
const gchar * ncm_model_orig_param_symbol (NcmModel *model
,guint n
);
GPtrArray *
ncm_model_param_names (NcmModel *model
);
Gets an array containing the parameters names.
void ncm_model_param_set_by_name (NcmModel *model
,const gchar *param_name
,gdouble val
);
Sets the parameter value val
by param_name
.
void ncm_model_orig_param_set_by_name (NcmModel *model
,const gchar *param_name
,gdouble val
);
Sets the parameter value val
by param_name
.
gdouble ncm_model_param_get_by_name (NcmModel *model
,const gchar *param_name
);
Gets the parameter value by param_name
.
gdouble ncm_model_orig_param_get_by_name (NcmModel *model
,const gchar *param_name
);
Gets the original parameter value by param_name
.
gdouble ncm_model_orig_param_get_scale (NcmModel *model
,guint n
);
Gets the scale of the original n
-th parameter.
gdouble ncm_model_orig_param_get_lower_bound (NcmModel *model
,guint n
);
Gets the lower bound of the original n
-th parameter.
gdouble ncm_model_orig_param_get_upper_bound (NcmModel *model
,guint n
);
Gets the upper bound of the original n
-th parameter.
gdouble ncm_model_orig_param_get_abstol (NcmModel *model
,guint n
);
Gets the absolute tolerance of the original n
-th parameter.
gdouble ncm_model_param_get_scale (NcmModel *model
,guint n
);
Gets the scale of the n
-th parameter.
gdouble ncm_model_param_get_lower_bound (NcmModel *model
,guint n
);
Gets the lower bound of the n
-th parameter.
gdouble ncm_model_param_get_upper_bound (NcmModel *model
,guint n
);
Gets the upper bound of the n
-th parameter.
gdouble ncm_model_param_get_abstol (NcmModel *model
,guint n
);
Gets the absolute tolerance of the n
-th parameter.
NcmParamType ncm_model_param_get_ftype (NcmModel *model
,guint n
);
Gets the fitting type of the n
-th parameter.
void ncm_model_param_set_scale (NcmModel *model
,guint n
,const gdouble scale
);
Sets scale
as the scale of the n
-th parameter.
void ncm_model_param_set_lower_bound (NcmModel *model
,guint n
,const gdouble lb
);
Sets lb
as the lower-bound value of the n
-th parameter.
void ncm_model_param_set_upper_bound (NcmModel *model
,guint n
,const gdouble ub
);
Sets ub
as the lower-bound value of the n
-th parameter.
void ncm_model_param_set_abstol (NcmModel *model
,guint n
,const gdouble abstol
);
Sets abstol
as the absolute tolerance of the n
-th parameter.
void ncm_model_param_set_ftype (NcmModel *model
,guint n
,const NcmParamType ptype
);
Sets ptype
as NcmParamType of the n
-th parameter.
void
ncm_model_params_set_default_ftype (NcmModel *model
);
Sets all parameters NcmParamType to their default values.
gboolean
ncm_model_is_submodel (NcmModel *model
);
Tests if model
is a submodel of other model class.
NcmModelID
ncm_model_main_model (NcmModel *model
);
If model
is a submodel returns the NcmModelID of its
main model, otherwise returns -1.
void ncm_model_add_submodel (NcmModel *model
,NcmModel *submodel
);
Adds the submodel
to the model
submodels.
[virtual add_submodel]
guint
ncm_model_get_submodel_len (NcmModel *model
);
Gets the number of submodels set in model
.
NcmModel * ncm_model_peek_submodel (NcmModel *model
,guint i
);
Gets the i
-th submodel.
NcmModel * ncm_model_peek_submodel_by_mid (NcmModel *model
,NcmModelID mid
);
Gets the submodel if type NcmModelID mid
.
gint ncm_model_peek_submodel_pos_by_mid (NcmModel *model
,NcmModelID mid
);
Gets the submodel type NcmModelID mid
position.
gboolean
ncm_model_type_is_submodel (GType model_type
);
Tests if model_type
is a submodel of other model class.
NcmModelID
ncm_model_type_main_model (GType model_type
);
If model_type
is a submodel returns the NcmModelID of its
main model, otherwise returns -1.
gdouble ncm_model___getitem__ (NcmModel *model
,gchar *param
,GError **err
);
Gets the parameter by name.
void ncm_model___setitem__ (NcmModel *model
,gchar *param
,gdouble val
,GError **err
);
Sets the parameter by name.
#define NCM_MODEL_2OPT2IMPL(opt1, opt2) (NCM_MODEL_OPT2IMPL (opt1) | NCM_MODEL_OPT2IMPL (opt2))
#define NCM_MODEL_3OPT2IMPL(opt1, opt2, opt3) (NCM_MODEL_2OPT2IMPL (opt1, opt2) | NCM_MODEL_OPT2IMPL (opt3))
#define NCM_MODEL_4OPT2IMPL(opt1, opt2, opt3, opt4) (NCM_MODEL_2OPT2IMPL (opt1, opt2) | NCM_MODEL_2OPT2IMPL (opt3, opt4))
“implementation”
property“implementation” guint64
Bitwise specification of functions implementation.
Owner: NcmModel
Flags: Read
Default value: 0
“reparam”
property“reparam” NcmReparam *
Model reparametrization.
Owner: NcmModel
Flags: Read / Write
“scalar-params-len”
property“scalar-params-len” guint
Number of scalar parameters.
Owner: NcmModel
Flags: Read
Default value: 0
“sparam-array”
property“sparam-array” NcmObjDictInt *
NcmModel array of NcmSParam.
Owner: NcmModel
Flags: Read / Write
“submodel-array”
property“submodel-array” NcmObjArray *
NcmModel array of submodels.
Owner: NcmModel
Flags: Read / Write
“vector-params-len”
property“vector-params-len” guint
Number of vector parameters.
Owner: NcmModel
Flags: Read
Default value: 0