SHOGUN  v3.2.0
所有成员列表 | Public 成员函数 | 静态 Public 成员函数 | Public 属性
TParameter结构体 参考

详细描述

parameter struct

在文件 Parameter.h26 行定义.

Public 成员函数

 TParameter (const TSGDataType *datatype, void *parameter, const char *name, const char *description)
 
 ~TParameter ()
 
void print (const char *prefix)
 
bool save (CSerializableFile *file, const char *prefix="")
 
bool load (CSerializableFile *file, const char *prefix="")
 
void allocate_data_from_scratch (SGVector< index_t > dims, bool new_cont_call=true)
 
void copy_data (const TParameter *source)
 
bool equals (TParameter *other, float64_t accuracy=0.0)
 
bool copy (TParameter *target)
 
bool operator== (const TParameter &other) const
 
bool operator< (const TParameter &other) const
 
bool operator> (const TParameter &other) const
 
void get_incremental_hash (uint32_t &hash, uint32_t &carry, uint32_t &total_length)
 
bool is_valid ()
 

静态 Public 成员函数

static bool compare_ptype (EPrimitiveType ptype, void *data1, void *data2, floatmax_t accuracy=0.0)
 
static bool compare_stype (EStructType stype, EPrimitiveType ptype, void *data1, void *data2, floatmax_t accuracy=0.0)
 
static bool copy_ptype (EPrimitiveType ptype, void *source, void *target)
 
static bool copy_stype (EStructType stype, EPrimitiveType ptype, void *source, void *target)
 

Public 属性

TSGDataType m_datatype
 
void * m_parameter
 
char * m_name
 
char * m_description
 
bool m_delete_data
 
bool m_was_allocated_from_scratch
 

构造及析构函数说明

TParameter ( const TSGDataType datatype,
void *  parameter,
const char *  name,
const char *  description 
)
explicit

explicit constructor

参数
datatypedatatype
parameterpointer to parameter
namename of parameter
descriptiondescription of parameter

在文件 Parameter.cpp1772 行定义.

~TParameter ( )

destructor

在文件 Parameter.cpp1783 行定义.

成员函数说明

void allocate_data_from_scratch ( SGVector< index_t dims,
bool  new_cont_call = true 
)

Allocates data for this instance from scratch. This is one of the core methods in parameter migration. It is used if parameters have to be loaded from file without having a class instance to put the data into. Namely, the data length variables are allocated, for numeric scalars, the memory is allocated, for SG_OBJECT scalars, a pointer to an CSGObject is allocated, for non-scalars, the pointer to the data is allocated for non-scalars, the actual data is also allocated via cont_new()

参数
dimsdesired length of the data
new_cont_callwhether new_cont should be called, if false, only scalar non-sgobject data will be allocated (needed for migration)

在文件 Parameter.cpp2987 行定义.

bool compare_ptype ( EPrimitiveType  ptype,
void *  data1,
void *  data2,
floatmax_t  accuracy = 0.0 
)
static

Given two pointers to a scalar element of a given primitive-type, this method compares the values up to a given accuracy.

If the type of the data is SGObject, recursively calls equals on the object.

参数
ptypeprimitive type of both data
data1pointer 1
data2pointer 2
accuracyaccuracy to compare
返回
whether the data was equal

ensure that no NULL data are de-referenced

在文件 Parameter.cpp3279 行定义.

bool compare_stype ( EStructType  stype,
EPrimitiveType  ptype,
void *  data1,
void *  data2,
floatmax_t  accuracy = 0.0 
)
static

Given two pointers to a string element of a given primitive-type, this method compares the values up to a given accuracy.

If the type of the data is SGObject, recursively calls equals on the object.

参数
stypestring type of both data
ptypeprimitive type of both data
data1pointer 1
data2pointer 2
accuracyaccuracy to compare
返回
whether the data was equal

在文件 Parameter.cpp3673 行定义.

bool copy ( TParameter target)

copy this to parameter target

参数
targetwhere this should be copied to

在文件 Parameter.cpp3947 行定义.

void copy_data ( const TParameter source)

Given another TParameter instance (with same type, except for lengths) all its data is copied to the current one. This means in case of numeric scalars that the value is copied and in SG_OBJECT scalars and any arrays that the pointer to the data is copied. The old data is overwritten. Old SG_OBJECTS are SG_UNREF'ed and the new ones are SG_REF'ed.

参数
sourcesource TParameter instance to copy from

在文件 Parameter.cpp3076 行定义.

bool copy_ptype ( EPrimitiveType  ptype,
void *  source,
void *  target 
)
static

copy primitive type from source to target

参数
ptypethe primitive type
sourcefrom where to copy
targetwhere to copy to

在文件 Parameter.cpp3529 行定义.

bool copy_stype ( EStructType  stype,
EPrimitiveType  ptype,
void *  source,
void *  target 
)
static

copy structured type from source to target

参数
stypethe structured type
ptypethe primitive type that the structured objects use
sourcefrom where to copy
targetwhere to copy to

在文件 Parameter.cpp3801 行定义.

bool equals ( TParameter other,
float64_t  accuracy = 0.0 
)

Numerically this instance with another instance. Compares recursively in case of non-numerical parameters

参数
otherother instance to compare with
accuracyaccuracy for numerical comparison
返回
true if given parameter instance is equal, false otherwise

在文件 Parameter.cpp3136 行定义.

void get_incremental_hash ( uint32_t &  hash,
uint32_t &  carry,
uint32_t &  total_length 
)

Incrementally get a hash from parameter value

参数
hashcurrent hash value
carryvalue for incremental murmur hashing
total_lengthbyte length of parameters. Function will add byte length to received value

在文件 Parameter.cpp2450 行定义.

bool is_valid ( )

test if parameter can be validly accessed, e.g., in case of a list/vector/matrix of objects the list/vector/matrix has non-zero length

在文件 Parameter.cpp2534 行定义.

bool load ( CSerializableFile file,
const char *  prefix = "" 
)

load from serializable file

参数
filesource file
prefixprefix

在文件 Parameter.cpp2639 行定义.

bool operator< ( const TParameter other) const

operator for comparison (by string m_name)

在文件 Parameter.cpp2977 行定义.

bool operator== ( const TParameter other) const

operator for comparison, (by string m_name)

在文件 Parameter.cpp2970 行定义.

bool operator> ( const TParameter other) const

operator for comparison (by string m_name)

在文件 Parameter.cpp2982 行定义.

void print ( const char *  prefix)

print with prefix

参数
prefixprefix to print

在文件 Parameter.cpp1835 行定义.

bool save ( CSerializableFile file,
const char *  prefix = "" 
)

save to serializable file

参数
filedestination file
prefixprefix

在文件 Parameter.cpp2540 行定义.

类成员变量说明

TSGDataType m_datatype

type of parameter

在文件 Parameter.h156 行定义.

bool m_delete_data

if this is set true, the data, m_parameter points to, m_parameter itself, and possible lengths of the type will be deleted in destructor. This is needed because in data migration, TParameter instances are created from scratch without having a class instance and allocated data has to ne deleted in this case. The only way to set this is via an alternate constructor, false by default

在文件 Parameter.h171 行定义.

char* m_description

description of parameter

在文件 Parameter.h162 行定义.

char* m_name

name of parameter

在文件 Parameter.h160 行定义.

void* m_parameter

pointer to parameter

在文件 Parameter.h158 行定义.

bool m_was_allocated_from_scratch
返回
true if data was not allocated by a class which registered its parameter, but from scratch using allocate_data_from_scratch

在文件 Parameter.h175 行定义.


该结构体的文档由以下文件生成:

SHOGUN Machine Learning Toolbox - Documentation