30 EPrimitiveType ptype,
index_t* length)
37 EPrimitiveType ptype,
index_t* length_y,
48 bool ctype_equal=
false;
71 SG_SDEBUG(
"leaving TSGDataType::equals_without_length(): container types are "
78 SG_SDEBUG(
"leaving TSGDataType::equals_without_length(): struct types are "
85 SG_SDEBUG(
"leaving TSGDataType::equals_without_length(): primitive types are "
90 SG_SDEBUG(
"leaving TSGDataType::equals_without_length(): data types "
91 "without lengths are equal\n");
97 SG_SDEBUG(
"entering TSGDataType::equals()\n");
101 SG_SDEBUG(
"leaving TSGDataType::equals(): Data types without lengths "
108 SG_SDEBUG(
"leaving TSGDataType::equals(): length_y is at %p while "
117 SG_SDEBUG(
"leaving TSGDataType::equals(): length_y=%d while "
125 SG_SDEBUG(
"leaving TSGDataType::equals(): m_length_x is at %p while "
134 SG_SDEBUG(
"leaving TSGDataType::equals(): m_length_x=%d while "
140 SG_SDEBUG(
"leaving TSGDataType::equals(): datatypes are equal\n");
150 case CT_SCALAR: strncpy(p,
"", n);
break;
151 case CT_VECTOR: strncpy(p,
"Vector<", n);
break;
152 case CT_SGVECTOR: strncpy(p,
"SGVector<", n);
break;
153 case CT_MATRIX: strncpy(p,
"Matrix<", n);
break;
154 case CT_SGMATRIX: strncpy(p,
"SGMatrix<", n);
break;
155 case CT_NDARRAY: strncpy(p,
"N-Dimensional Array<", n);
break;
156 case CT_UNDEFINED:
default: strncpy(p,
"Undefined", n);
break;
161 size_t np = strlen(p);
166 case CT_SCALAR:
break;
171 case CT_NDARRAY: strcat(p,
">");
break;
172 case CT_UNDEFINED:
default:
break;
209 SG_SWARNING(
"TGSDataType::sizeof_stype(): Strings are"
210 " not supported for complex128_t\n");
213 SG_SWARNING(
"TGSDataType::sizeof_stype(): Strings are"
214 " not supported for SGObject\n");
216 case PT_UNDEFINED:
default:
217 SG_SERROR(
"Implementation error: undefined primitive type\n");
237 case PT_SGOBJECT:
return -1;
238 case PT_UNDEFINED:
default:
239 SG_SERROR(
"Implementation error: undefined primitive type\n");
243 case ST_UNDEFINED:
default:
244 SG_SERROR(
"Implementation error: undefined structure type\n");
255 case PT_BOOL:
return sizeof (bool);
256 case PT_CHAR:
return sizeof (char);
257 case PT_INT8:
return sizeof (int8_t);
258 case PT_UINT8:
return sizeof (uint8_t);
259 case PT_INT16:
return sizeof (int16_t);
260 case PT_UINT16:
return sizeof (uint16_t);
261 case PT_INT32:
return sizeof (int32_t);
262 case PT_UINT32:
return sizeof (uint32_t);
263 case PT_INT64:
return sizeof (int64_t);
264 case PT_UINT64:
return sizeof (uint64_t);
265 case PT_FLOAT32:
return sizeof (
float32_t);
266 case PT_FLOAT64:
return sizeof (
float64_t);
269 case PT_SGOBJECT:
return sizeof (
CSGObject*);
270 case PT_UNDEFINED:
default:
271 SG_SERROR(
"Implementation error: undefined primitive type\n");
296 case PT_SGOBJECT:
return -1;
297 case PT_UNDEFINED:
default:
298 SG_SERROR(
"Implementation error: undefined primitive type\n");
305 #define ENTRY_OFFSET(k, type) \
306 ((char*) &((SGSparseVectorEntry<type>*) (k))->entry - (char*) (k))
310 size_t result = -1;
void* x = &result;
316 case PT_UINT8: result =
ENTRY_OFFSET(x, uint8_t);
break;
317 case PT_INT16: result =
ENTRY_OFFSET(x, int16_t);
break;
318 case PT_UINT16: result =
ENTRY_OFFSET(x, uint16_t);
break;
319 case PT_INT32: result =
ENTRY_OFFSET(x, int32_t);
break;
320 case PT_UINT32: result =
ENTRY_OFFSET(x, uint32_t);
break;
321 case PT_INT64: result =
ENTRY_OFFSET(x, int64_t);
break;
322 case PT_UINT64: result =
ENTRY_OFFSET(x, uint64_t);
break;
327 case PT_SGOBJECT:
return -1;
328 case PT_UNDEFINED:
default:
329 SG_SERROR(
"Implementation error: undefined primitive type\n");
338 EPrimitiveType ptype,
size_t n)
343 case ST_NONE: strncpy(p,
"", n);
break;
344 case ST_STRING: strncpy(p,
"String<", n);
break;
345 case ST_SPARSE: strncpy(p,
"Sparse<", n);
break;
346 case ST_UNDEFINED:
default:
347 SG_SERROR(
"Implementation error: undefined structure type\n");
351 size_t np = strlen(p);
356 case ST_STRING:
case ST_SPARSE:
357 strcat(p,
">");
break;
358 case ST_UNDEFINED:
default:
359 SG_SERROR(
"Implementation error: undefined structure type\n");
371 case PT_BOOL: strncpy(p,
"bool", n);
break;
372 case PT_CHAR: strncpy(p,
"char", n);
break;
373 case PT_INT8: strncpy(p,
"int8", n);
break;
374 case PT_UINT8: strncpy(p,
"uint8", n);
break;
375 case PT_INT16: strncpy(p,
"int16", n);
break;
376 case PT_UINT16: strncpy(p,
"uint16", n);
break;
377 case PT_INT32: strncpy(p,
"int32", n);
break;
378 case PT_UINT32: strncpy(p,
"uint32", n);
break;
379 case PT_INT64: strncpy(p,
"int64", n);
break;
380 case PT_UINT64: strncpy(p,
"uint64", n);
break;
381 case PT_FLOAT32: strncpy(p,
"float32", n);
break;
382 case PT_FLOAT64: strncpy(p,
"float64", n);
break;
383 case PT_FLOATMAX: strncpy(p,
"floatmax", n);
break;
384 case PT_COMPLEX128: strncpy(p,
"complex128", n);
break;
385 case PT_SGOBJECT: strncpy(p,
"SGSerializable*", n);
break;
386 case PT_UNDEFINED:
default:
387 SG_SERROR(
"Implementation error: undefined primitive type\n");
395 if (strcmp(str,
"bool") == 0) {
396 *ptype = PT_BOOL;
return true; }
397 if (strcmp(str,
"char") == 0) {
398 *ptype = PT_CHAR;
return true; }
399 if (strcmp(str,
"int8") == 0) {
400 *ptype = PT_INT8;
return true; }
401 if (strcmp(str,
"uint8") == 0) {
402 *ptype = PT_UINT8;
return true; }
403 if (strcmp(str,
"int16") == 0) {
404 *ptype = PT_INT16;
return true; }
405 if (strcmp(str,
"uint16") == 0) {
406 *ptype = PT_UINT16;
return true; }
407 if (strcmp(str,
"int32") == 0) {
408 *ptype = PT_INT32;
return true; }
409 if (strcmp(str,
"uint32") == 0) {
410 *ptype = PT_UINT32;
return true; }
411 if (strcmp(str,
"int64") == 0) {
412 *ptype = PT_INT64;
return true; }
413 if (strcmp(str,
"uint64") == 0) {
414 *ptype = PT_UINT64;
return true; }
415 if (strcmp(str,
"float32") == 0) {
416 *ptype = PT_FLOAT32;
return true; }
417 if (strcmp(str,
"float64") == 0) {
418 *ptype = PT_FLOAT64;
return true; }
419 if (strcmp(str,
"floatmax") == 0) {
420 *ptype = PT_FLOATMAX;
return true; }
421 if (strcmp(str,
"complex128") == 0) {
422 *ptype = PT_COMPLEX128;
return true; }
423 if (strcmp(str,
"SGSerializable*") == 0) {
424 *ptype = PT_SGOBJECT;
return true; }
428 case PT_BOOL:
case PT_CHAR:
case PT_INT8:
case PT_UINT8:
429 case PT_INT16:
case PT_UINT16:
case PT_INT32:
case PT_UINT32:
430 case PT_INT64:
case PT_UINT64:
case PT_FLOAT32:
case PT_FLOAT64:
431 case PT_FLOATMAX:
case PT_COMPLEX128:
case PT_SGOBJECT:
break;
432 case PT_UNDEFINED:
default:
433 SG_SERROR(
"Implementation error: undefined primitive type\n");
456 case ST_UNDEFINED:
default:
457 SG_SERROR(
"Implementation error: undefined structure type\n");
470 case CT_VECTOR:
case CT_SGVECTOR:
473 case CT_MATRIX:
case CT_SGMATRIX:
477 case CT_UNDEFINED:
default:
478 SG_SERROR(
"Implementation error: undefined container type\n");
std::complex< float64_t > complex128_t
static bool string_to_ptype(EPrimitiveType *ptype, const char *str)
static size_t offset_sparseentry(EPrimitiveType ptype)
size_t sizeof_ptype() const
int64_t get_num_elements()
#define SG_SNOTIMPLEMENTED
static void ptype_to_string(char *dest, EPrimitiveType ptype, size_t n)
TSGDataType(EContainerType ctype, EStructType stype, EPrimitiveType ptype)
Datatypes that shogun supports.
bool equals_without_length(TSGDataType other)
Class SGObject is the base class of all shogun objects.
static void stype_to_string(char *dest, EStructType stype, EPrimitiveType ptype, size_t n)
size_t sizeof_stype() const
bool operator==(const TSGDataType &a)
void to_string(char *dest, size_t n) const
#define ENTRY_OFFSET(k, type)
all of classes and functions are contained in the shogun namespace
template class SGSparseVectorEntry
bool equals(TSGDataType other)
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry* vector is orde...
static size_t sizeof_sparseentry(EPrimitiveType ptype)