SHOGUN  v3.2.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
Parameter.cpp
浏览该文件的文档.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2010 Soeren Sonnenburg
8  * Written (W) 2011-2013 Heiko Strathmann
9  * Copyright (C) 2010 Berlin Institute of Technology
10  */
11 
12 #include <string.h>
13 
14 #include <shogun/base/Parameter.h>
15 #include <shogun/base/class_list.h>
16 #include <shogun/lib/Hash.h>
17 #include <shogun/lib/memory.h>
18 #include <shogun/io/SGIO.h>
19 
20 using namespace shogun;
21 
22 
23 /* **************************************************************** */
24 /* Scalar wrappers */
25 
26 void
27 Parameter::add(bool* param, const char* name,
28  const char* description) {
29  TSGDataType type(CT_SCALAR, ST_NONE, PT_BOOL);
30  add_type(&type, param, name, description);
31 }
32 
33 void
34 Parameter::add(char* param, const char* name,
35  const char* description) {
36  TSGDataType type(CT_SCALAR, ST_NONE, PT_CHAR);
37  add_type(&type, param, name, description);
38 }
39 
40 void
41 Parameter::add(int8_t* param, const char* name,
42  const char* description) {
43  TSGDataType type(CT_SCALAR, ST_NONE, PT_INT8);
44  add_type(&type, param, name, description);
45 }
46 
47 void
48 Parameter::add(uint8_t* param, const char* name,
49  const char* description) {
50  TSGDataType type(CT_SCALAR, ST_NONE, PT_UINT8);
51  add_type(&type, param, name, description);
52 }
53 
54 void
55 Parameter::add(int16_t* param, const char* name,
56  const char* description) {
57  TSGDataType type(CT_SCALAR, ST_NONE, PT_INT16);
58  add_type(&type, param, name, description);
59 }
60 
61 void
62 Parameter::add(uint16_t* param, const char* name,
63  const char* description) {
64  TSGDataType type(CT_SCALAR, ST_NONE, PT_UINT16);
65  add_type(&type, param, name, description);
66 }
67 
68 void
69 Parameter::add(int32_t* param, const char* name,
70  const char* description) {
71  TSGDataType type(CT_SCALAR, ST_NONE, PT_INT32);
72  add_type(&type, param, name, description);
73 }
74 
75 void
76 Parameter::add(uint32_t* param, const char* name,
77  const char* description) {
78  TSGDataType type(CT_SCALAR, ST_NONE, PT_UINT32);
79  add_type(&type, param, name, description);
80 }
81 
82 void
83 Parameter::add(int64_t* param, const char* name,
84  const char* description) {
85  TSGDataType type(CT_SCALAR, ST_NONE, PT_INT64);
86  add_type(&type, param, name, description);
87 }
88 
89 void
90 Parameter::add(uint64_t* param, const char* name,
91  const char* description) {
92  TSGDataType type(CT_SCALAR, ST_NONE, PT_UINT64);
93  add_type(&type, param, name, description);
94 }
95 
96 void
97 Parameter::add(float32_t* param, const char* name,
98  const char* description) {
99  TSGDataType type(CT_SCALAR, ST_NONE, PT_FLOAT32);
100  add_type(&type, param, name, description);
101 }
102 
103 void
104 Parameter::add(float64_t* param, const char* name,
105  const char* description) {
106  TSGDataType type(CT_SCALAR, ST_NONE, PT_FLOAT64);
107  add_type(&type, param, name, description);
108 }
109 
110 void
111 Parameter::add(floatmax_t* param, const char* name,
112  const char* description) {
113  TSGDataType type(CT_SCALAR, ST_NONE, PT_FLOATMAX);
114  add_type(&type, param, name, description);
115 }
116 
117 void
118 Parameter::add(complex128_t* param, const char* name,
119  const char* description) {
120  TSGDataType type(CT_SCALAR, ST_NONE, PT_COMPLEX128);
121  add_type(&type, param, name, description);
122 }
123 
124 void
126  const char* name, const char* description) {
127  TSGDataType type(CT_SCALAR, ST_NONE, PT_SGOBJECT);
128  add_type(&type, param, name, description);
129 }
130 
131 void
132 Parameter::add(SGString<bool>* param, const char* name,
133  const char* description) {
134  TSGDataType type(CT_SCALAR, ST_STRING, PT_BOOL);
135  add_type(&type, param, name, description);
136 }
137 
138 void
139 Parameter::add(SGString<char>* param, const char* name,
140  const char* description) {
141  TSGDataType type(CT_SCALAR, ST_STRING, PT_CHAR);
142  add_type(&type, param, name, description);
143 }
144 
145 void
146 Parameter::add(SGString<int8_t>* param, const char* name,
147  const char* description) {
148  TSGDataType type(CT_SCALAR, ST_STRING, PT_INT8);
149  add_type(&type, param, name, description);
150 }
151 
152 void
153 Parameter::add(SGString<uint8_t>* param, const char* name,
154  const char* description) {
155  TSGDataType type(CT_SCALAR, ST_STRING, PT_UINT8);
156  add_type(&type, param, name, description);
157 }
158 
159 void
160 Parameter::add(SGString<int16_t>* param, const char* name,
161  const char* description) {
162  TSGDataType type(CT_SCALAR, ST_STRING, PT_INT16);
163  add_type(&type, param, name, description);
164 }
165 
166 void
167 Parameter::add(SGString<uint16_t>* param, const char* name,
168  const char* description) {
169  TSGDataType type(CT_SCALAR, ST_STRING, PT_UINT16);
170  add_type(&type, param, name, description);
171 }
172 
173 void
174 Parameter::add(SGString<int32_t>* param, const char* name,
175  const char* description) {
176  TSGDataType type(CT_SCALAR, ST_STRING, PT_INT32);
177  add_type(&type, param, name, description);
178 }
179 
180 void
181 Parameter::add(SGString<uint32_t>* param, const char* name,
182  const char* description) {
183  TSGDataType type(CT_SCALAR, ST_STRING, PT_UINT32);
184  add_type(&type, param, name, description);
185 }
186 
187 void
188 Parameter::add(SGString<int64_t>* param, const char* name,
189  const char* description) {
190  TSGDataType type(CT_SCALAR, ST_STRING, PT_INT64);
191  add_type(&type, param, name, description);
192 }
193 
194 void
195 Parameter::add(SGString<uint64_t>* param, const char* name,
196  const char* description) {
197  TSGDataType type(CT_SCALAR, ST_STRING, PT_UINT64);
198  add_type(&type, param, name, description);
199 }
200 
201 void
202 Parameter::add(SGString<float32_t>* param, const char* name,
203  const char* description) {
204  TSGDataType type(CT_SCALAR, ST_STRING, PT_FLOAT32);
205  add_type(&type, param, name, description);
206 }
207 
208 void
209 Parameter::add(SGString<float64_t>* param, const char* name,
210  const char* description) {
211  TSGDataType type(CT_SCALAR, ST_STRING, PT_FLOAT64);
212  add_type(&type, param, name, description);
213 }
214 
215 void
216 Parameter::add(SGString<floatmax_t>* param, const char* name,
217  const char* description) {
218  TSGDataType type(CT_SCALAR, ST_STRING, PT_FLOATMAX);
219  add_type(&type, param, name, description);
220 }
221 
222 void
223 Parameter::add(SGSparseVector<bool>* param, const char* name,
224  const char* description) {
225  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_BOOL);
226  add_type(&type, param, name, description);
227 }
228 
229 void
230 Parameter::add(SGSparseVector<char>* param, const char* name,
231  const char* description) {
232  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_CHAR);
233  add_type(&type, param, name, description);
234 }
235 
236 void
237 Parameter::add(SGSparseVector<int8_t>* param, const char* name,
238  const char* description) {
239  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_INT8);
240  add_type(&type, param, name, description);
241 }
242 
243 void
244 Parameter::add(SGSparseVector<uint8_t>* param, const char* name,
245  const char* description) {
246  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_UINT8);
247  add_type(&type, param, name, description);
248 }
249 
250 void
251 Parameter::add(SGSparseVector<int16_t>* param, const char* name,
252  const char* description) {
253  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_INT16);
254  add_type(&type, param, name, description);
255 }
256 
257 void
258 Parameter::add(SGSparseVector<uint16_t>* param, const char* name,
259  const char* description) {
260  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_UINT16);
261  add_type(&type, param, name, description);
262 }
263 
264 void
265 Parameter::add(SGSparseVector<int32_t>* param, const char* name,
266  const char* description) {
267  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_INT32);
268  add_type(&type, param, name, description);
269 }
270 
271 void
272 Parameter::add(SGSparseVector<uint32_t>* param, const char* name,
273  const char* description) {
274  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_UINT32);
275  add_type(&type, param, name, description);
276 }
277 
278 void
279 Parameter::add(SGSparseVector<int64_t>* param, const char* name,
280  const char* description) {
281  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_INT64);
282  add_type(&type, param, name, description);
283 }
284 
285 void
286 Parameter::add(SGSparseVector<uint64_t>* param, const char* name,
287  const char* description) {
288  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_UINT64);
289  add_type(&type, param, name, description);
290 }
291 
292 void
293 Parameter::add(SGSparseVector<float32_t>* param, const char* name,
294  const char* description) {
295  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_FLOAT32);
296  add_type(&type, param, name, description);
297 }
298 
299 void
300 Parameter::add(SGSparseVector<float64_t>* param, const char* name,
301  const char* description) {
302  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_FLOAT64);
303  add_type(&type, param, name, description);
304 }
305 
306 void
308  const char* description) {
309  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_FLOATMAX);
310  add_type(&type, param, name, description);
311 }
312 
313 void
315  const char* description) {
316  TSGDataType type(CT_SCALAR, ST_SPARSE, PT_COMPLEX128);
317  add_type(&type, param, name, description);
318 }
319 
320 /* **************************************************************** */
321 /* Vector wrappers */
322 
323 void
325  bool** param, index_t* length, const char* name,
326  const char* description) {
327  TSGDataType type(CT_VECTOR, ST_NONE, PT_BOOL, length);
328  add_type(&type, param, name, description);
329 }
330 
331 void
333  char** param, index_t* length, const char* name,
334  const char* description) {
335  TSGDataType type(CT_VECTOR, ST_NONE, PT_CHAR, length);
336  add_type(&type, param, name, description);
337 }
338 
339 void
341  int8_t** param, index_t* length, const char* name,
342  const char* description) {
343  TSGDataType type(CT_VECTOR, ST_NONE, PT_INT8, length);
344  add_type(&type, param, name, description);
345 }
346 
347 void
349  uint8_t** param, index_t* length, const char* name,
350  const char* description) {
351  TSGDataType type(CT_VECTOR, ST_NONE, PT_UINT8, length);
352  add_type(&type, param, name, description);
353 }
354 
355 void
357  int16_t** param, index_t* length, const char* name,
358  const char* description) {
359  TSGDataType type(CT_VECTOR, ST_NONE, PT_INT16, length);
360  add_type(&type, param, name, description);
361 }
362 
363 void
365  uint16_t** param, index_t* length, const char* name,
366  const char* description) {
367  TSGDataType type(CT_VECTOR, ST_NONE, PT_UINT16, length);
368  add_type(&type, param, name, description);
369 }
370 
371 void
373  int32_t** param, index_t* length, const char* name,
374  const char* description) {
375  TSGDataType type(CT_VECTOR, ST_NONE, PT_INT32, length);
376  add_type(&type, param, name, description);
377 }
378 
379 void
381  uint32_t** param, index_t* length, const char* name,
382  const char* description) {
383  TSGDataType type(CT_VECTOR, ST_NONE, PT_UINT32, length);
384  add_type(&type, param, name, description);
385 }
386 
387 void
389  int64_t** param, index_t* length, const char* name,
390  const char* description) {
391  TSGDataType type(CT_VECTOR, ST_NONE, PT_INT64, length);
392  add_type(&type, param, name, description);
393 }
394 
395 void
397  uint64_t** param, index_t* length, const char* name,
398  const char* description) {
399  TSGDataType type(CT_VECTOR, ST_NONE, PT_UINT64, length);
400  add_type(&type, param, name, description);
401 }
402 
403 void
405  float32_t** param, index_t* length, const char* name,
406  const char* description) {
407  TSGDataType type(CT_VECTOR, ST_NONE, PT_FLOAT32, length);
408  add_type(&type, param, name, description);
409 }
410 
411 void
413  float64_t** param, index_t* length, const char* name,
414  const char* description) {
415  TSGDataType type(CT_VECTOR, ST_NONE, PT_FLOAT64, length);
416  add_type(&type, param, name, description);
417 }
418 
419 void
421  floatmax_t** param, index_t* length, const char* name,
422  const char* description) {
423  TSGDataType type(CT_VECTOR, ST_NONE, PT_FLOATMAX, length);
424  add_type(&type, param, name, description);
425 }
426 
427 void
429  complex128_t** param, index_t* length, const char* name,
430  const char* description) {
431  TSGDataType type(CT_VECTOR, ST_NONE, PT_COMPLEX128, length);
432  add_type(&type, param, name, description);
433 }
434 
435 void
437  const char* name, const char* description) {
438  TSGDataType type(CT_VECTOR, ST_NONE, PT_SGOBJECT,
439  length);
440  add_type(&type, param, name, description);
441 }
442 
443 void
445  const char* name, const char* description) {
446  TSGDataType type(CT_VECTOR, ST_STRING, PT_BOOL, length);
447  add_type(&type, param, name, description);
448 }
449 
450 void
452  const char* name, const char* description) {
453  TSGDataType type(CT_VECTOR, ST_STRING, PT_CHAR, length);
454  add_type(&type, param, name, description);
455 }
456 
457 void
459  const char* name, const char* description) {
460  TSGDataType type(CT_VECTOR, ST_STRING, PT_INT8, length);
461  add_type(&type, param, name, description);
462 }
463 
464 void
466  const char* name, const char* description) {
467  TSGDataType type(CT_VECTOR, ST_STRING, PT_UINT8, length);
468  add_type(&type, param, name, description);
469 }
470 
471 void
473  const char* name, const char* description) {
474  TSGDataType type(CT_VECTOR, ST_STRING, PT_INT16, length);
475  add_type(&type, param, name, description);
476 }
477 
478 void
480  const char* name, const char* description) {
481  TSGDataType type(CT_VECTOR, ST_STRING, PT_UINT16, length);
482  add_type(&type, param, name, description);
483 }
484 
485 void
487  const char* name, const char* description) {
488  TSGDataType type(CT_VECTOR, ST_STRING, PT_INT32, length);
489  add_type(&type, param, name, description);
490 }
491 
492 void
494  const char* name, const char* description) {
495  TSGDataType type(CT_VECTOR, ST_STRING, PT_UINT32, length);
496  add_type(&type, param, name, description);
497 }
498 
499 void
501  const char* name, const char* description) {
502  TSGDataType type(CT_VECTOR, ST_STRING, PT_INT64, length);
503  add_type(&type, param, name, description);
504 }
505 
506 void
508  const char* name, const char* description) {
509  TSGDataType type(CT_VECTOR, ST_STRING, PT_UINT64, length);
510  add_type(&type, param, name, description);
511 }
512 
513 void
515  const char* name, const char* description) {
516  TSGDataType type(CT_VECTOR, ST_STRING, PT_FLOAT32, length);
517  add_type(&type, param, name, description);
518 }
519 
520 void
522  const char* name, const char* description) {
523  TSGDataType type(CT_VECTOR, ST_STRING, PT_FLOAT64, length);
524  add_type(&type, param, name, description);
525 }
526 
527 void
529  const char* name, const char* description) {
530  TSGDataType type(CT_VECTOR, ST_STRING, PT_FLOATMAX, length);
531  add_type(&type, param, name, description);
532 }
533 
534 void
536  const char* name, const char* description) {
537  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_BOOL, length);
538  add_type(&type, param, name, description);
539 }
540 
541 void
543  const char* name, const char* description) {
544  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_CHAR, length);
545  add_type(&type, param, name, description);
546 }
547 
548 void
550  const char* name, const char* description) {
551  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_INT8, length);
552  add_type(&type, param, name, description);
553 }
554 
555 void
557  const char* name, const char* description) {
558  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_UINT8, length);
559  add_type(&type, param, name, description);
560 }
561 
562 void
564  const char* name, const char* description) {
565  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_INT16, length);
566  add_type(&type, param, name, description);
567 }
568 
569 void
571  const char* name, const char* description) {
572  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_UINT16, length);
573  add_type(&type, param, name, description);
574 }
575 
576 void
578  const char* name, const char* description) {
579  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_INT32, length);
580  add_type(&type, param, name, description);
581 }
582 
583 void
585  const char* name, const char* description) {
586  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_UINT32, length);
587  add_type(&type, param, name, description);
588 }
589 
590 void
592  const char* name, const char* description) {
593  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_INT64, length);
594  add_type(&type, param, name, description);
595 }
596 
597 void
599  const char* name, const char* description) {
600  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_UINT64, length);
601  add_type(&type, param, name, description);
602 }
603 
604 void
606  const char* name, const char* description) {
607  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_FLOAT32, length);
608  add_type(&type, param, name, description);
609 }
610 
611 void
613  const char* name, const char* description) {
614  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_FLOAT64, length);
615  add_type(&type, param, name, description);
616 }
617 
618 void
620  const char* name, const char* description) {
621  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_FLOATMAX, length);
622  add_type(&type, param, name, description);
623 }
624 
625 void
627  const char* name, const char* description) {
628  TSGDataType type(CT_VECTOR, ST_SPARSE, PT_COMPLEX128, length);
629  add_type(&type, param, name, description);
630 }
631 
632 
633 
634 
635 void Parameter::add(SGVector<bool>* param, const char* name,
636  const char* description)
637 {
638  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_BOOL, &param->vlen);
639  add_type(&type, &param->vector, name, description);
640 }
641 
642 void Parameter::add(SGVector<char>* param, const char* name,
643  const char* description)
644 {
645  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_CHAR, &param->vlen);
646  add_type(&type, &param->vector, name, description);
647 }
648 
649 void Parameter::add(SGVector<int8_t>* param, const char* name,
650  const char* description)
651 {
652  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_INT8, &param->vlen);
653  add_type(&type, &param->vector, name, description);
654 }
655 
656 void Parameter::add(SGVector<uint8_t>* param, const char* name,
657  const char* description)
658 {
659  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_UINT8, &param->vlen);
660  add_type(&type, &param->vector, name, description);
661 }
662 
663 void Parameter::add(SGVector<int16_t>* param, const char* name,
664  const char* description)
665 {
666  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_INT16, &param->vlen);
667  add_type(&type, &param->vector, name, description);
668 }
669 
670 void Parameter::add(SGVector<uint16_t>* param, const char* name,
671  const char* description)
672 {
673  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_UINT16, &param->vlen);
674  add_type(&type, &param->vector, name, description);
675 }
676 
677 void Parameter::add(SGVector<int32_t>* param, const char* name,
678  const char* description)
679 {
680  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_INT32, &param->vlen);
681  add_type(&type, &param->vector, name, description);
682 }
683 
684 void Parameter::add(SGVector<uint32_t>* param, const char* name,
685  const char* description)
686 {
687  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_UINT32, &param->vlen);
688  add_type(&type, &param->vector, name, description);
689 }
690 
691 void Parameter::add(SGVector<int64_t>* param, const char* name,
692  const char* description)
693 {
694  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_INT64, &param->vlen);
695  add_type(&type, &param->vector, name, description);
696 }
697 
698 void Parameter::add(SGVector<uint64_t>* param, const char* name,
699  const char* description)
700 {
701  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_UINT64, &param->vlen);
702  add_type(&type, &param->vector, name, description);
703 }
704 
705 void Parameter::add(SGVector<float32_t>* param, const char* name,
706  const char* description)
707 {
708  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_FLOAT32, &param->vlen);
709  add_type(&type, &param->vector, name, description);
710 }
711 
712 void Parameter::add(SGVector<float64_t>* param, const char* name,
713  const char* description)
714 {
715  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_FLOAT64, &param->vlen);
716  add_type(&type, &param->vector, name, description);
717 }
718 
719 void Parameter::add(SGVector<floatmax_t>* param, const char* name,
720  const char* description)
721 {
722  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_FLOATMAX, &param->vlen);
723  add_type(&type, &param->vector, name, description);
724 }
725 
726 void Parameter::add(SGVector<complex128_t>* param, const char* name,
727  const char* description)
728 {
729  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_COMPLEX128, &param->vlen);
730  add_type(&type, &param->vector, name, description);
731 }
732 
733 void Parameter::add(SGVector<CSGObject*>* param, const char* name,
734  const char* description)
735 {
736  TSGDataType type(CT_SGVECTOR, ST_NONE, PT_SGOBJECT, &param->vlen);
737  add_type(&type, &param->vector, name, description);
738 }
739 
740 void Parameter::add(SGVector<SGString<bool> >* param, const char* name,
741  const char* description)
742 {
743  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_BOOL, &param->vlen);
744  add_type(&type, &param->vector, name, description);
745 }
746 
747 void Parameter::add(SGVector<SGString<char> >* param, const char* name,
748  const char* description)
749 {
750  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_CHAR, &param->vlen);
751  add_type(&type, &param->vector, name, description);
752 }
753 
755  const char* name, const char* description)
756 {
757  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_INT8, &param->vlen);
758  add_type(&type, &param->vector, name, description);
759 }
760 
762  const char* name, const char* description)
763 {
764  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_UINT8, &param->vlen);
765  add_type(&type, &param->vector, name, description);
766 }
767 
769  const char* name, const char* description)
770 {
771  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_INT16, &param->vlen);
772  add_type(&type, &param->vector, name, description);
773 }
774 
776  const char* name, const char* description)
777 {
778  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_UINT16, &param->vlen);
779  add_type(&type, &param->vector, name, description);
780 }
781 
783  const char* name, const char* description)
784 {
785  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_INT32, &param->vlen);
786  add_type(&type, &param->vector, name, description);
787 }
788 
790  const char* name, const char* description)
791 {
792  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_UINT32, &param->vlen);
793  add_type(&type, &param->vector, name, description);
794 }
795 
797  const char* name, const char* description)
798 {
799  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_INT64, &param->vlen);
800  add_type(&type, &param->vector, name, description);
801 }
802 
804  const char* name, const char* description)
805 {
806  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_UINT64, &param->vlen);
807  add_type(&type, &param->vector, name, description);
808 }
809 
811  const char* name, const char* description)
812 {
813  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_FLOAT32, &param->vlen);
814  add_type(&type, &param->vector, name, description);
815 }
816 
818  const char* name, const char* description)
819 {
820  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_FLOAT64, &param->vlen);
821  add_type(&type, &param->vector, name, description);
822 }
823 
825  const char* name, const char* description)
826 {
827  TSGDataType type(CT_SGVECTOR, ST_STRING, PT_FLOATMAX, &param->vlen);
828  add_type(&type, &param->vector, name, description);
829 }
830 
832  const char* name, const char* description)
833 {
834  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_BOOL, &param->vlen);
835  add_type(&type, &param->vector, name, description);
836 }
837 
839  const char* name, const char* description)
840 {
841  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_CHAR, &param->vlen);
842  add_type(&type, &param->vector, name, description);
843 }
844 
846  const char* name, const char* description)
847 {
848  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_INT8, &param->vlen);
849  add_type(&type, &param->vector, name, description);
850 }
851 
853  const char* name, const char* description)
854 {
855  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_UINT8, &param->vlen);
856  add_type(&type, &param->vector, name, description);
857 }
858 
860  const char* name, const char* description)
861 {
862  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_INT16, &param->vlen);
863  add_type(&type, &param->vector, name, description);
864 }
865 
867  const char* name, const char* description)
868 {
869  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_UINT16, &param->vlen);
870  add_type(&type, &param->vector, name, description);
871 }
872 
874  const char* name, const char* description)
875 {
876  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_INT32, &param->vlen);
877  add_type(&type, &param->vector, name, description);
878 }
879 
881  const char* name, const char* description)
882 {
883  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_UINT32, &param->vlen);
884  add_type(&type, &param->vector, name, description);
885 }
886 
888  const char* name, const char* description)
889 {
890  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_INT64, &param->vlen);
891  add_type(&type, &param->vector, name, description);
892 }
893 
895  const char* name, const char* description)
896 {
897  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_UINT64, &param->vlen);
898  add_type(&type, &param->vector, name, description);
899 }
900 
902  const char* name, const char* description)
903 {
904  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_FLOAT32, &param->vlen);
905  add_type(&type, &param->vector, name, description);
906 }
907 
909  const char* name, const char* description)
910 {
911  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_FLOAT64, &param->vlen);
912  add_type(&type, &param->vector, name, description);
913 }
914 
916  const char* name, const char* description)
917 {
918  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_FLOATMAX, &param->vlen);
919  add_type(&type, &param->vector, name, description);
920 }
921 
923  const char* name, const char* description)
924 {
925  TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_COMPLEX128, &param->vlen);
926  add_type(&type, &param->vector, name, description);
927 }
928 
929 /* **************************************************************** */
930 /* Matrix wrappers */
931 
932 void
934  bool** param, index_t* length_y, index_t* length_x,
935  const char* name, const char* description) {
936  TSGDataType type(CT_MATRIX, ST_NONE, PT_BOOL, length_y,
937  length_x);
938  add_type(&type, param, name, description);
939 }
940 
941 void
943  char** param, index_t* length_y, index_t* length_x,
944  const char* name, const char* description) {
945  TSGDataType type(CT_MATRIX, ST_NONE, PT_CHAR, length_y,
946  length_x);
947  add_type(&type, param, name, description);
948 }
949 
950 void
952  int8_t** param, index_t* length_y, index_t* length_x,
953  const char* name, const char* description) {
954  TSGDataType type(CT_MATRIX, ST_NONE, PT_INT8, length_y,
955  length_x);
956  add_type(&type, param, name, description);
957 }
958 
959 void
961  uint8_t** param, index_t* length_y, index_t* length_x,
962  const char* name, const char* description) {
963  TSGDataType type(CT_MATRIX, ST_NONE, PT_UINT8, length_y,
964  length_x);
965  add_type(&type, param, name, description);
966 }
967 
968 void
970  int16_t** param, index_t* length_y, index_t* length_x,
971  const char* name, const char* description) {
972  TSGDataType type(CT_MATRIX, ST_NONE, PT_INT16, length_y,
973  length_x);
974  add_type(&type, param, name, description);
975 }
976 
977 void
979  uint16_t** param, index_t* length_y, index_t* length_x,
980  const char* name, const char* description) {
981  TSGDataType type(CT_MATRIX, ST_NONE, PT_UINT16, length_y,
982  length_x);
983  add_type(&type, param, name, description);
984 }
985 
986 void
988  int32_t** param, index_t* length_y, index_t* length_x,
989  const char* name, const char* description) {
990  TSGDataType type(CT_MATRIX, ST_NONE, PT_INT32, length_y,
991  length_x);
992  add_type(&type, param, name, description);
993 }
994 
995 void
997  uint32_t** param, index_t* length_y, index_t* length_x,
998  const char* name, const char* description) {
999  TSGDataType type(CT_MATRIX, ST_NONE, PT_UINT32, length_y,
1000  length_x);
1001  add_type(&type, param, name, description);
1002 }
1003 
1004 void
1006  int64_t** param, index_t* length_y, index_t* length_x,
1007  const char* name, const char* description) {
1008  TSGDataType type(CT_MATRIX, ST_NONE, PT_INT64, length_y,
1009  length_x);
1010  add_type(&type, param, name, description);
1011 }
1012 
1013 void
1015  uint64_t** param, index_t* length_y, index_t* length_x,
1016  const char* name, const char* description) {
1017  TSGDataType type(CT_MATRIX, ST_NONE, PT_UINT64, length_y,
1018  length_x);
1019  add_type(&type, param, name, description);
1020 }
1021 
1022 void
1024  float32_t** param, index_t* length_y, index_t* length_x,
1025  const char* name, const char* description) {
1026  TSGDataType type(CT_MATRIX, ST_NONE, PT_FLOAT32, length_y,
1027  length_x);
1028  add_type(&type, param, name, description);
1029 }
1030 
1031 void
1033  float64_t** param, index_t* length_y, index_t* length_x,
1034  const char* name, const char* description) {
1035  TSGDataType type(CT_MATRIX, ST_NONE, PT_FLOAT64, length_y,
1036  length_x);
1037  add_type(&type, param, name, description);
1038 }
1039 
1040 void
1042  floatmax_t** param, index_t* length_y, index_t* length_x,
1043  const char* name, const char* description) {
1044  TSGDataType type(CT_MATRIX, ST_NONE, PT_FLOATMAX, length_y,
1045  length_x);
1046  add_type(&type, param, name, description);
1047 }
1048 
1049 void
1051  complex128_t** param, index_t* length_y, index_t* length_x,
1052  const char* name, const char* description) {
1053  TSGDataType type(CT_MATRIX, ST_NONE, PT_COMPLEX128, length_y,
1054  length_x);
1055  add_type(&type, param, name, description);
1056 }
1057 
1058 void
1060  CSGObject*** param, index_t* length_y, index_t* length_x,
1061  const char* name, const char* description) {
1062  TSGDataType type(CT_MATRIX, ST_NONE, PT_SGOBJECT,
1063  length_y, length_x);
1064  add_type(&type, param, name, description);
1065 }
1066 
1067 void
1069  index_t* length_y, index_t* length_x,
1070  const char* name, const char* description) {
1071  TSGDataType type(CT_MATRIX, ST_STRING, PT_BOOL, length_y,
1072  length_x);
1073  add_type(&type, param, name, description);
1074 }
1075 
1076 void
1078  index_t* length_y, index_t* length_x,
1079  const char* name, const char* description) {
1080  TSGDataType type(CT_MATRIX, ST_STRING, PT_CHAR, length_y,
1081  length_x);
1082  add_type(&type, param, name, description);
1083 }
1084 
1085 void
1087  index_t* length_y, index_t* length_x,
1088  const char* name, const char* description) {
1089  TSGDataType type(CT_MATRIX, ST_STRING, PT_INT8, length_y,
1090  length_x);
1091  add_type(&type, param, name, description);
1092 }
1093 
1094 void
1096  index_t* length_y, index_t* length_x,
1097  const char* name, const char* description) {
1098  TSGDataType type(CT_MATRIX, ST_STRING, PT_UINT8, length_y,
1099  length_x);
1100  add_type(&type, param, name, description);
1101 }
1102 
1103 void
1105  index_t* length_y, index_t* length_x,
1106  const char* name, const char* description) {
1107  TSGDataType type(CT_MATRIX, ST_STRING, PT_INT16, length_y,
1108  length_x);
1109  add_type(&type, param, name, description);
1110 }
1111 
1112 void
1114  index_t* length_y, index_t* length_x,
1115  const char* name, const char* description) {
1116  TSGDataType type(CT_MATRIX, ST_STRING, PT_UINT16, length_y,
1117  length_x);
1118  add_type(&type, param, name, description);
1119 }
1120 
1121 void
1123  index_t* length_y, index_t* length_x,
1124  const char* name, const char* description) {
1125  TSGDataType type(CT_MATRIX, ST_STRING, PT_INT32, length_y,
1126  length_x);
1127  add_type(&type, param, name, description);
1128 }
1129 
1130 void
1132  index_t* length_y, index_t* length_x,
1133  const char* name, const char* description) {
1134  TSGDataType type(CT_MATRIX, ST_STRING, PT_UINT32, length_y,
1135  length_x);
1136  add_type(&type, param, name, description);
1137 }
1138 
1139 void
1141  index_t* length_y, index_t* length_x,
1142  const char* name, const char* description) {
1143  TSGDataType type(CT_MATRIX, ST_STRING, PT_INT64, length_y,
1144  length_x);
1145  add_type(&type, param, name, description);
1146 }
1147 
1148 void
1150  index_t* length_y, index_t* length_x,
1151  const char* name, const char* description) {
1152  TSGDataType type(CT_MATRIX, ST_STRING, PT_UINT64, length_y,
1153  length_x);
1154  add_type(&type, param, name, description);
1155 }
1156 
1157 void
1159  index_t* length_y, index_t* length_x,
1160  const char* name, const char* description) {
1161  TSGDataType type(CT_MATRIX, ST_STRING, PT_FLOAT32, length_y,
1162  length_x);
1163  add_type(&type, param, name, description);
1164 }
1165 
1166 void
1168  index_t* length_y, index_t* length_x,
1169  const char* name, const char* description) {
1170  TSGDataType type(CT_MATRIX, ST_STRING, PT_FLOAT64, length_y,
1171  length_x);
1172  add_type(&type, param, name, description);
1173 }
1174 
1175 void
1177  index_t* length_y, index_t* length_x,
1178  const char* name, const char* description) {
1179  TSGDataType type(CT_MATRIX, ST_STRING, PT_FLOATMAX, length_y,
1180  length_x);
1181  add_type(&type, param, name, description);
1182 }
1183 
1184 void
1186  index_t* length_y, index_t* length_x,
1187  const char* name, const char* description) {
1188  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_BOOL, length_y,
1189  length_x);
1190  add_type(&type, param, name, description);
1191 }
1192 
1193 void
1195  index_t* length_y, index_t* length_x,
1196  const char* name, const char* description) {
1197  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_CHAR, length_y,
1198  length_x);
1199  add_type(&type, param, name, description);
1200 }
1201 
1202 void
1204  index_t* length_y, index_t* length_x,
1205  const char* name, const char* description) {
1206  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_INT8, length_y,
1207  length_x);
1208  add_type(&type, param, name, description);
1209 }
1210 
1211 void
1213  index_t* length_y, index_t* length_x,
1214  const char* name, const char* description) {
1215  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_UINT8, length_y,
1216  length_x);
1217  add_type(&type, param, name, description);
1218 }
1219 
1220 void
1222  index_t* length_y, index_t* length_x,
1223  const char* name, const char* description) {
1224  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_INT16, length_y,
1225  length_x);
1226  add_type(&type, param, name, description);
1227 }
1228 
1229 void
1231  index_t* length_y, index_t* length_x,
1232  const char* name, const char* description) {
1233  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_UINT16, length_y,
1234  length_x);
1235  add_type(&type, param, name, description);
1236 }
1237 
1238 void
1240  index_t* length_y, index_t* length_x,
1241  const char* name, const char* description) {
1242  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_INT32, length_y,
1243  length_x);
1244  add_type(&type, param, name, description);
1245 }
1246 
1247 void
1249  index_t* length_y, index_t* length_x,
1250  const char* name, const char* description) {
1251  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_UINT32, length_y,
1252  length_x);
1253  add_type(&type, param, name, description);
1254 }
1255 
1256 void
1258  index_t* length_y, index_t* length_x,
1259  const char* name, const char* description) {
1260  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_INT64, length_y,
1261  length_x);
1262  add_type(&type, param, name, description);
1263 }
1264 
1265 void
1267  index_t* length_y, index_t* length_x,
1268  const char* name, const char* description) {
1269  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_UINT64, length_y,
1270  length_x);
1271  add_type(&type, param, name, description);
1272 }
1273 
1274 void
1276  index_t* length_y, index_t* length_x,
1277  const char* name, const char* description) {
1278  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_FLOAT32, length_y,
1279  length_x);
1280  add_type(&type, param, name, description);
1281 }
1282 
1283 void
1285  index_t* length_y, index_t* length_x,
1286  const char* name, const char* description) {
1287  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_FLOAT64, length_y,
1288  length_x);
1289  add_type(&type, param, name, description);
1290 }
1291 
1292 void
1294  index_t* length_y, index_t* length_x,
1295  const char* name, const char* description) {
1296  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_FLOATMAX, length_y,
1297  length_x);
1298  add_type(&type, param, name, description);
1299 }
1300 
1301 void
1303  index_t* length_y, index_t* length_x,
1304  const char* name, const char* description) {
1305  TSGDataType type(CT_MATRIX, ST_SPARSE, PT_COMPLEX128, length_y,
1306  length_x);
1307  add_type(&type, param, name, description);
1308 }
1309 
1310 
1311 
1312 
1313 void Parameter::add(SGMatrix<bool>* param, const char* name,
1314  const char* description)
1315 {
1316  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_BOOL, &param->num_rows,
1317  &param->num_cols);
1318  add_type(&type, &param->matrix, name, description);
1319 }
1320 
1321 void Parameter::add(SGMatrix<char>* param, const char* name,
1322  const char* description)
1323 {
1324  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_CHAR, &param->num_rows,
1325  &param->num_cols);
1326  add_type(&type, &param->matrix, name, description);
1327 }
1328 
1329 void Parameter::add(SGMatrix<int8_t>* param, const char* name,
1330  const char* description)
1331 {
1332  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_INT8, &param->num_rows,
1333  &param->num_cols);
1334  add_type(&type, &param->matrix, name, description);
1335 }
1336 
1337 void Parameter::add(SGMatrix<uint8_t>* param, const char* name,
1338  const char* description)
1339 {
1340  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_UINT8, &param->num_rows,
1341  &param->num_cols);
1342  add_type(&type, &param->matrix, name, description);
1343 }
1344 
1345 void Parameter::add(SGMatrix<int16_t>* param, const char* name,
1346  const char* description)
1347 {
1348  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_INT16, &param->num_rows,
1349  &param->num_cols);
1350  add_type(&type, &param->matrix, name, description);
1351 }
1352 
1353 void Parameter::add(SGMatrix<uint16_t>* param, const char* name,
1354  const char* description)
1355 {
1356  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_UINT16, &param->num_rows,
1357  &param->num_cols);
1358  add_type(&type, &param->matrix, name, description);
1359 }
1360 
1361 void Parameter::add(SGMatrix<int32_t>* param, const char* name,
1362  const char* description)
1363 {
1364  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_INT32, &param->num_rows,
1365  &param->num_cols);
1366  add_type(&type, &param->matrix, name, description);
1367 }
1368 
1369 void Parameter::add(SGMatrix<uint32_t>* param, const char* name,
1370  const char* description)
1371 {
1372  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_UINT32, &param->num_rows,
1373  &param->num_cols);
1374  add_type(&type, &param->matrix, name, description);
1375 }
1376 
1377 void Parameter::add(SGMatrix<int64_t>* param, const char* name,
1378  const char* description)
1379 {
1380  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_INT64, &param->num_rows,
1381  &param->num_cols);
1382  add_type(&type, &param->matrix, name, description);
1383 }
1384 
1385 void Parameter::add(SGMatrix<uint64_t>* param, const char* name,
1386  const char* description)
1387 {
1388  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_UINT64, &param->num_rows,
1389  &param->num_cols);
1390  add_type(&type, &param->matrix, name, description);
1391 }
1392 
1393 void Parameter::add(SGMatrix<float32_t>* param, const char* name,
1394  const char* description)
1395 {
1396  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_FLOAT32, &param->num_rows,
1397  &param->num_cols);
1398  add_type(&type, &param->matrix, name, description);
1399 }
1400 
1401 void Parameter::add(SGMatrix<float64_t>* param, const char* name,
1402  const char* description)
1403 {
1404  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_FLOAT64, &param->num_rows,
1405  &param->num_cols);
1406  add_type(&type, &param->matrix, name, description);
1407 }
1408 
1409 void Parameter::add(SGMatrix<floatmax_t>* param, const char* name,
1410  const char* description)
1411 {
1412  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_FLOATMAX, &param->num_rows,
1413  &param->num_cols);
1414  add_type(&type, &param->matrix, name, description);
1415 }
1416 
1417 void Parameter::add(SGMatrix<complex128_t>* param, const char* name,
1418  const char* description)
1419 {
1420  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_COMPLEX128, &param->num_rows,
1421  &param->num_cols);
1422  add_type(&type, &param->matrix, name, description);
1423 }
1424 
1425 void Parameter::add(SGMatrix<CSGObject*>* param, const char* name,
1426  const char* description)
1427 {
1428  TSGDataType type(CT_SGMATRIX, ST_NONE, PT_SGOBJECT, &param->num_rows,
1429  &param->num_cols);
1430  add_type(&type, &param->matrix, name, description);
1431 }
1432 
1433 void Parameter::add(SGMatrix<SGString<bool> >* param, const char* name,
1434  const char* description)
1435 {
1436  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_BOOL, &param->num_rows,
1437  &param->num_cols);
1438  add_type(&type, &param->matrix, name, description);
1439 }
1440 
1441 void Parameter::add(SGMatrix<SGString<char> >* param, const char* name,
1442  const char* description)
1443 {
1444  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_CHAR, &param->num_rows,
1445  &param->num_cols);
1446  add_type(&type, &param->matrix, name, description);
1447 }
1448 
1450  const char* name, const char* description)
1451 {
1452  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_INT8, &param->num_rows,
1453  &param->num_cols);
1454  add_type(&type, &param->matrix, name, description);
1455 }
1456 
1458  const char* name, const char* description)
1459 {
1460  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_UINT8, &param->num_rows,
1461  &param->num_cols);
1462  add_type(&type, &param->matrix, name, description);
1463 }
1464 
1466  const char* name, const char* description)
1467 {
1468  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_INT16, &param->num_rows,
1469  &param->num_cols);
1470  add_type(&type, &param->matrix, name, description);
1471 }
1472 
1474  const char* name, const char* description)
1475 {
1476  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_UINT16, &param->num_rows,
1477  &param->num_cols);
1478  add_type(&type, &param->matrix, name, description);
1479 }
1480 
1482  const char* name, const char* description)
1483 {
1484  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_INT32, &param->num_rows,
1485  &param->num_cols);
1486  add_type(&type, &param->matrix, name, description);
1487 }
1488 
1490  const char* name, const char* description)
1491 {
1492  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_UINT32, &param->num_rows,
1493  &param->num_cols);
1494  add_type(&type, &param->matrix, name, description);
1495 }
1496 
1498  const char* name, const char* description)
1499 {
1500  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_INT64, &param->num_rows,
1501  &param->num_cols);
1502  add_type(&type, &param->matrix, name, description);
1503 }
1504 
1506  const char* name, const char* description)
1507 {
1508  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_UINT64, &param->num_rows,
1509  &param->num_cols);
1510  add_type(&type, &param->matrix, name, description);
1511 }
1512 
1514  const char* name, const char* description)
1515 {
1516  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_FLOAT32, &param->num_rows,
1517  &param->num_cols);
1518  add_type(&type, &param->matrix, name, description);
1519 }
1520 
1522  const char* name, const char* description)
1523 {
1524  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_FLOAT64, &param->num_rows,
1525  &param->num_cols);
1526  add_type(&type, &param->matrix, name, description);
1527 }
1528 
1530  const char* name, const char* description)
1531 {
1532  TSGDataType type(CT_SGMATRIX, ST_STRING, PT_FLOATMAX, &param->num_rows,
1533  &param->num_cols);
1534  add_type(&type, &param->matrix, name, description);
1535 }
1536 
1538  const char* name, const char* description)
1539 {
1540  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_BOOL, &param->num_rows,
1541  &param->num_cols);
1542  add_type(&type, &param->matrix, name, description);
1543 }
1544 
1546  const char* name, const char* description)
1547 {
1548  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_CHAR, &param->num_rows,
1549  &param->num_cols);
1550  add_type(&type, &param->matrix, name, description);
1551 }
1552 
1554  const char* name, const char* description)
1555 {
1556  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT8, &param->num_rows,
1557  &param->num_cols);
1558  add_type(&type, &param->matrix, name, description);
1559 }
1560 
1562  const char* name, const char* description)
1563 {
1564  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT8, &param->num_rows,
1565  &param->num_cols);
1566  add_type(&type, &param->matrix, name, description);
1567 }
1568 
1570  const char* name, const char* description)
1571 {
1572  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT16, &param->num_rows,
1573  &param->num_cols);
1574  add_type(&type, &param->matrix, name, description);
1575 }
1576 
1578  const char* name, const char* description)
1579 {
1580  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT16, &param->num_rows,
1581  &param->num_cols);
1582  add_type(&type, &param->matrix, name, description);
1583 }
1584 
1586  const char* name, const char* description)
1587 {
1588  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT32, &param->num_rows,
1589  &param->num_cols);
1590  add_type(&type, &param->matrix, name, description);
1591 }
1592 
1594  const char* name, const char* description)
1595 {
1596  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT32, &param->num_rows,
1597  &param->num_cols);
1598  add_type(&type, &param->matrix, name, description);
1599 }
1600 
1602  const char* name, const char* description)
1603 {
1604  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT64, &param->num_rows,
1605  &param->num_cols);
1606  add_type(&type, &param->matrix, name, description);
1607 }
1608 
1610  const char* name, const char* description)
1611 {
1612  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT64, &param->num_rows,
1613  &param->num_cols);
1614  add_type(&type, &param->matrix, name, description);
1615 }
1616 
1618  const char* name, const char* description)
1619 {
1620  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOAT32, &param->num_rows,
1621  &param->num_cols);
1622  add_type(&type, &param->matrix, name, description);
1623 }
1624 
1626  const char* name, const char* description)
1627 {
1628  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOAT64, &param->num_rows,
1629  &param->num_cols);
1630  add_type(&type, &param->matrix, name, description);
1631 }
1632 
1634  const char* name, const char* description)
1635 {
1636  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOATMAX, &param->num_rows,
1637  &param->num_cols);
1638  add_type(&type, &param->matrix, name, description);
1639 }
1640 
1642  const char* name, const char* description)
1643 {
1644  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_COMPLEX128, &param->num_rows,
1645  &param->num_cols);
1646  add_type(&type, &param->matrix, name, description);
1647 }
1648 
1650  const char* name, const char* description)
1651 {
1652  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_BOOL, &param->num_vectors,
1653  &param->num_features);
1654  add_type(&type, &param->sparse_matrix, name, description);
1655 }
1656 
1658  const char* name, const char* description)
1659 {
1660  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_CHAR, &param->num_vectors,
1661  &param->num_features);
1662  add_type(&type, &param->sparse_matrix, name, description);
1663 }
1664 
1666  const char* name, const char* description)
1667 {
1668  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT8, &param->num_vectors,
1669  &param->num_features);
1670  add_type(&type, &param->sparse_matrix, name, description);
1671 }
1672 
1674  const char* name, const char* description)
1675 {
1676  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT8, &param->num_vectors,
1677  &param->num_features);
1678  add_type(&type, &param->sparse_matrix, name, description);
1679 }
1680 
1682  const char* name, const char* description)
1683 {
1684  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT16, &param->num_vectors,
1685  &param->num_features);
1686  add_type(&type, &param->sparse_matrix, name, description);
1687 }
1688 
1690  const char* name, const char* description)
1691 {
1692  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT16, &param->num_vectors,
1693  &param->num_features);
1694  add_type(&type, &param->sparse_matrix, name, description);
1695 }
1696 
1698  const char* name, const char* description)
1699 {
1700  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT32, &param->num_vectors,
1701  &param->num_features);
1702  add_type(&type, &param->sparse_matrix, name, description);
1703 }
1704 
1706  const char* name, const char* description)
1707 {
1708  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT32, &param->num_vectors,
1709  &param->num_features);
1710  add_type(&type, &param->sparse_matrix, name, description);
1711 }
1712 
1714  const char* name, const char* description)
1715 {
1716  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT64, &param->num_vectors,
1717  &param->num_features);
1718  add_type(&type, &param->sparse_matrix, name, description);
1719 }
1720 
1722  const char* name, const char* description)
1723 {
1724  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT64, &param->num_vectors,
1725  &param->num_features);
1726  add_type(&type, &param->sparse_matrix, name, description);
1727 }
1728 
1730  const char* name, const char* description)
1731 {
1732  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOAT32, &param->num_vectors,
1733  &param->num_features);
1734  add_type(&type, &param->sparse_matrix, name, description);
1735 }
1736 
1738  const char* name, const char* description)
1739 {
1740  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOAT64, &param->num_vectors,
1741  &param->num_features);
1742  add_type(&type, &param->sparse_matrix, name, description);
1743 }
1744 
1746  const char* name, const char* description)
1747 {
1748  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOATMAX, &param->num_vectors,
1749  &param->num_features);
1750  add_type(&type, &param->sparse_matrix, name, description);
1751 }
1752 
1754  const char* name, const char* description)
1755 {
1756  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_COMPLEX128, &param->num_vectors,
1757  &param->num_features);
1758  add_type(&type, &param->sparse_matrix, name, description);
1759 }
1760 
1762  const char* name, const char* description)
1763 {
1764  TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_SGOBJECT, &param->num_vectors,
1765  &param->num_features);
1766  add_type(&type, &param->sparse_matrix, name, description);
1767 }
1768 
1769 /* **************************************************************** */
1770 /* End of wrappers */
1771 
1772 TParameter::TParameter(const TSGDataType* datatype, void* parameter,
1773  const char* name, const char* description)
1774  :m_datatype(*datatype)
1775 {
1776  m_parameter = parameter;
1777  m_name = get_strdup(name);
1778  m_description = get_strdup(description);
1779  m_delete_data=false;
1781 }
1782 
1784 {
1785 // SG_SDEBUG("entering ~TParameter for \"%s\"\n", m_name)
1786  SG_FREE(m_description);
1787  SG_FREE(m_name);
1788 
1789  /* possibly delete content, m_parameter variable */
1791  {
1792  SG_SDEBUG("deleting from scratch data\n")
1793 
1794  if (m_delete_data)
1795  {
1796  /* for non-scalar data, delete_cont does the job, rest is handled
1797  * below */
1798  SG_SDEBUG("deleting pure data\n")
1799  if (m_datatype.m_ctype!=CT_SCALAR)
1800  delete_cont();
1801 
1802  if (m_datatype.m_ctype==CT_SCALAR && m_datatype.m_ptype==PT_SGOBJECT)
1804  }
1805 
1806  /* free pointer/data */
1807  if (m_parameter)
1808  {
1809  SG_SDEBUG("freeing m_parameter pointer/data at %p\n", m_parameter)
1810  SG_FREE(m_parameter);
1811  }
1812 
1813  /* free lengths */
1814  if (m_datatype.m_length_x)
1815  SG_FREE(m_datatype.m_length_x);
1816 
1817  if (m_datatype.m_length_y)
1818  SG_FREE(m_datatype.m_length_y);
1819  }
1820 
1821 // SG_SDEBUG("leaving ~TParameter\n")
1822 }
1823 
1824 char*
1825 TParameter::new_prefix(const char* s1, const char* s2)
1826 {
1827  char* tmp = SG_MALLOC(char, strlen(s1)+strlen(s2)+2);
1828 
1829  sprintf(tmp, "%s%s/", s1, s2);
1830 
1831  return tmp;
1832 }
1833 
1834 void
1835 TParameter::print(const char* prefix)
1836 {
1837  string_t buf;
1839 
1840  SG_SPRINT("\n%s\n%35s %24s :%s\n", prefix, m_description == NULL
1841  || *m_description == '\0' ? "(Parameter)": m_description,
1842  m_name, buf);
1843 
1844  if (m_datatype.m_ptype == PT_SGOBJECT
1845  && m_datatype.m_stype == ST_NONE
1846  && m_datatype.m_ctype == CT_SCALAR
1847  && *(CSGObject**) m_parameter != NULL) {
1848  char* p = new_prefix(prefix, m_name);
1849  (*(CSGObject**) m_parameter)->print_serializable(p);
1850  delete p;
1851  }
1852 }
1853 
1854 void
1855 TParameter::delete_cont()
1856 {
1857  if (*(void**) m_parameter != NULL) {
1858  index_t old_length = m_datatype.m_length_y ? *m_datatype.m_length_y : 0;
1859  switch (m_datatype.m_ctype) {
1860  case CT_NDARRAY:
1862  break;
1863  case CT_MATRIX: case CT_SGMATRIX:
1864  old_length *= *m_datatype.m_length_x; break;
1865  case CT_SCALAR: case CT_VECTOR: case CT_SGVECTOR: break;
1866  case CT_UNDEFINED: default:
1867  SG_SERROR("Implementation error: undefined container type\n");
1868  break;
1869  }
1870 
1871  switch (m_datatype.m_stype) {
1872  case ST_NONE:
1873  switch (m_datatype.m_ptype) {
1874  case PT_BOOL:
1875  SG_FREE(*(bool**) m_parameter); break;
1876  case PT_CHAR:
1877  SG_FREE(*(char**) m_parameter); break;
1878  case PT_INT8:
1879  SG_FREE(*(int8_t**) m_parameter); break;
1880  case PT_UINT8:
1881  SG_FREE(*(uint8_t**) m_parameter); break;
1882  case PT_INT16:
1883  SG_FREE(*(int16_t**) m_parameter); break;
1884  case PT_UINT16:
1885  SG_FREE(*(uint16_t**) m_parameter); break;
1886  case PT_INT32:
1887  SG_FREE(*(int32_t**) m_parameter); break;
1888  case PT_UINT32:
1889  SG_FREE(*(uint32_t**) m_parameter); break;
1890  case PT_INT64:
1891  SG_FREE(*(int64_t**) m_parameter); break;
1892  case PT_UINT64:
1893  SG_FREE(*(uint64_t**) m_parameter); break;
1894  case PT_FLOAT32:
1895  SG_FREE(*(float32_t**) m_parameter); break;
1896  case PT_FLOAT64:
1897  SG_FREE(*(float64_t**) m_parameter); break;
1898  case PT_FLOATMAX:
1899  SG_FREE(*(floatmax_t**) m_parameter); break;
1900  case PT_COMPLEX128:
1901  SG_FREE(*(complex128_t**) m_parameter); break;
1902  case PT_SGOBJECT:
1903  {
1904  CSGObject** buf = *(CSGObject***) m_parameter;
1905 
1906  for (index_t i=0; i<old_length; i++)
1907  SG_UNREF(buf[i]);
1908 
1909  SG_FREE(buf);
1910  break;
1911  }
1912  case PT_UNDEFINED: default:
1913  SG_SERROR("Implementation error: undefined primitive type\n");
1914  break;
1915  }
1916  break;
1917  case ST_STRING:
1918  {
1919  for (index_t i=0; i<old_length; i++) {
1920  SGString<char>* buf = (SGString<char>*) (*(char**)
1922  if (buf->slen > 0) SG_FREE(buf->string);
1923  break;
1924  }
1925  }
1926 
1927  switch (m_datatype.m_ptype) {
1928  case PT_BOOL:
1929  SG_FREE(*(SGString<bool>**) m_parameter); break;
1930  case PT_CHAR:
1931  SG_FREE(*(SGString<char>**) m_parameter); break;
1932  case PT_INT8:
1933  SG_FREE(*(SGString<int8_t>**) m_parameter); break;
1934  case PT_UINT8:
1935  SG_FREE(*(SGString<uint8_t>**) m_parameter); break;
1936  case PT_INT16:
1937  SG_FREE(*(SGString<int16_t>**) m_parameter); break;
1938  case PT_UINT16:
1939  SG_FREE(*(SGString<uint16_t>**) m_parameter); break;
1940  case PT_INT32:
1941  SG_FREE(*(SGString<int32_t>**) m_parameter); break;
1942  case PT_UINT32:
1943  SG_FREE(*(SGString<uint32_t>**) m_parameter); break;
1944  case PT_INT64:
1945  SG_FREE(*(SGString<int64_t>**) m_parameter); break;
1946  case PT_UINT64:
1947  SG_FREE(*(SGString<uint64_t>**) m_parameter); break;
1948  case PT_FLOAT32:
1949  SG_FREE(*(SGString<float32_t>**) m_parameter); break;
1950  case PT_FLOAT64:
1951  SG_FREE(*(SGString<float64_t>**) m_parameter); break;
1952  case PT_FLOATMAX:
1953  SG_FREE(*(SGString<floatmax_t>**) m_parameter); break;
1954  case PT_COMPLEX128:
1955  SG_SERROR("TParameter::delete_cont(): Parameters of strings"
1956  " of complex128_t are not supported");
1957  break;
1958  case PT_SGOBJECT:
1959  SG_SERROR("TParameter::delete_cont(): Implementation "
1960  "error: Could not delete "
1961  "String<SGSerializable*>");
1962  break;
1963  case PT_UNDEFINED: default:
1964  SG_SERROR("Implementation error: undefined primitive type\n");
1965  break;
1966  }
1967  break;
1968  case ST_SPARSE:
1969  for (index_t i=0; i<old_length; i++) {
1970  SGSparseVector<char>* buf = (SGSparseVector<char>*) (*(char**)
1972  if (buf->num_feat_entries > 0) SG_FREE(buf->features);
1973  }
1974 
1975  switch (m_datatype.m_ptype) {
1976  case PT_BOOL:
1977  SG_FREE(*(SGSparseVector<bool>**) m_parameter); break;
1978  case PT_CHAR:
1979  SG_FREE(*(SGSparseVector<char>**) m_parameter); break;
1980  case PT_INT8:
1981  SG_FREE(*(SGSparseVector<int8_t>**) m_parameter); break;
1982  case PT_UINT8:
1983  SG_FREE(*(SGSparseVector<uint8_t>**) m_parameter); break;
1984  case PT_INT16:
1985  SG_FREE(*(SGSparseVector<int16_t>**) m_parameter); break;
1986  case PT_UINT16:
1987  SG_FREE(*(SGSparseVector<uint16_t>**) m_parameter); break;
1988  case PT_INT32:
1989  SG_FREE(*(SGSparseVector<int32_t>**) m_parameter); break;
1990  case PT_UINT32:
1991  SG_FREE(*(SGSparseVector<uint32_t>**) m_parameter); break;
1992  case PT_INT64:
1993  SG_FREE(*(SGSparseVector<int64_t>**) m_parameter); break;
1994  case PT_UINT64:
1995  SG_FREE(*(SGSparseVector<uint64_t>**) m_parameter); break;
1996  case PT_FLOAT32:
1997  SG_FREE(*(SGSparseVector<float32_t>**) m_parameter); break;
1998  case PT_FLOAT64:
1999  SG_FREE(*(SGSparseVector<float64_t>**) m_parameter); break;
2000  case PT_FLOATMAX:
2001  SG_FREE(*(SGSparseVector<floatmax_t>**) m_parameter); break;
2002  case PT_COMPLEX128:
2003  SG_FREE(*(SGSparseVector<complex128_t>**) m_parameter); break;
2004  case PT_SGOBJECT:
2005  SG_SERROR("TParameter::delete_cont(): Implementation "
2006  "error: Could not delete "
2007  "Sparse<SGSerializable*>");
2008  break;
2009  case PT_UNDEFINED: default:
2010  SG_SERROR("Implementation error: undefined primitive type\n");
2011  break;
2012  }
2013  break;
2014  case ST_UNDEFINED: default:
2015  SG_SERROR("Implementation error: undefined structure type\n");
2016  break;
2017  } /* switch (m_datatype.m_stype) */
2018  } /* if (*(void**) m_parameter != NULL) */
2019 
2020  *(void**) m_parameter = NULL;
2021 }
2022 
2023 void
2024 TParameter::new_cont(SGVector<index_t> dims)
2025 {
2026  char* s=SG_MALLOC(char, 200);
2027  m_datatype.to_string(s, 200);
2028  SG_SDEBUG("entering TParameter::new_cont for \"%s\" of type %s with",
2029  s, m_name ? m_name : "(nil)");
2030  SG_FREE(s);
2031  delete_cont();
2032 
2033  index_t new_length = dims.product();
2034  if (new_length == 0) return;
2035 
2036  switch (m_datatype.m_stype) {
2037  case ST_NONE:
2038  switch (m_datatype.m_ptype) {
2039  case PT_BOOL:
2040  *(bool**) m_parameter
2041  = SG_MALLOC(bool, new_length); break;
2042  case PT_CHAR:
2043  *(char**) m_parameter
2044  = SG_MALLOC(char, new_length); break;
2045  case PT_INT8:
2046  *(int8_t**) m_parameter
2047  = SG_MALLOC(int8_t, new_length); break;
2048  case PT_UINT8:
2049  *(uint8_t**) m_parameter
2050  = SG_MALLOC(uint8_t, new_length); break;
2051  case PT_INT16:
2052  *(int16_t**) m_parameter
2053  = SG_MALLOC(int16_t, new_length); break;
2054  case PT_UINT16:
2055  *(uint16_t**) m_parameter
2056  = SG_MALLOC(uint16_t, new_length); break;
2057  case PT_INT32:
2058  *(int32_t**) m_parameter
2059  = SG_MALLOC(int32_t, new_length); break;
2060  case PT_UINT32:
2061  *(uint32_t**) m_parameter
2062  = SG_MALLOC(uint32_t, new_length); break;
2063  case PT_INT64:
2064  *(int64_t**) m_parameter
2065  = SG_MALLOC(int64_t, new_length); break;
2066  case PT_UINT64:
2067  *(uint64_t**) m_parameter
2068  = SG_MALLOC(uint64_t, new_length); break;
2069  case PT_FLOAT32:
2070  *(float32_t**) m_parameter
2071  = SG_MALLOC(float32_t, new_length); break;
2072  case PT_FLOAT64:
2073  *(float64_t**) m_parameter
2074  = SG_MALLOC(float64_t, new_length); break;
2075  case PT_FLOATMAX:
2076  *(floatmax_t**) m_parameter
2077  = SG_MALLOC(floatmax_t, new_length); break;
2078  case PT_COMPLEX128:
2080  = SG_MALLOC(complex128_t, new_length); break;
2081  case PT_SGOBJECT:
2082  *(CSGObject***) m_parameter
2083  = SG_CALLOC(CSGObject*, new_length);
2084  break;
2085  case PT_UNDEFINED: default:
2086  SG_SERROR("Implementation error: undefined primitive type\n");
2087  break;
2088  }
2089  break;
2090  case ST_STRING:
2091  switch (m_datatype.m_ptype) {
2092  case PT_BOOL:
2094  = SG_MALLOC(SGString<bool>, new_length); break;
2095  case PT_CHAR:
2097  = SG_MALLOC(SGString<char>, new_length); break;
2098  case PT_INT8:
2100  = SG_MALLOC(SGString<int8_t>, new_length); break;
2101  case PT_UINT8:
2103  = SG_MALLOC(SGString<uint8_t>, new_length); break;
2104  case PT_INT16:
2106  = SG_MALLOC(SGString<int16_t>, new_length); break;
2107  case PT_UINT16:
2109  = SG_MALLOC(SGString<uint16_t>, new_length); break;
2110  case PT_INT32:
2112  = SG_MALLOC(SGString<int32_t>, new_length); break;
2113  case PT_UINT32:
2115  = SG_MALLOC(SGString<uint32_t>, new_length); break;
2116  case PT_INT64:
2118  = SG_MALLOC(SGString<int64_t>, new_length); break;
2119  case PT_UINT64:
2121  = SG_MALLOC(SGString<uint64_t>, new_length); break;
2122  case PT_FLOAT32:
2124  = SG_MALLOC(SGString<float32_t>, new_length); break;
2125  case PT_FLOAT64:
2127  = SG_MALLOC(SGString<float64_t>, new_length); break;
2128  case PT_FLOATMAX:
2130  = SG_MALLOC(SGString<floatmax_t>, new_length); break;
2131  case PT_COMPLEX128:
2132  SG_SERROR("TParameter::new_cont(): Implementation "
2133  "error: Could not allocate "
2134  "String<complex128>");
2135  break;
2136  case PT_SGOBJECT:
2137  SG_SERROR("TParameter::new_cont(): Implementation "
2138  "error: Could not allocate "
2139  "String<SGSerializable*>");
2140  break;
2141  case PT_UNDEFINED: default:
2142  SG_SERROR("Implementation error: undefined primitive type\n");
2143  break;
2144  }
2145  memset(*(void**) m_parameter, 0, new_length
2147  break;
2148  case ST_SPARSE:
2149  switch (m_datatype.m_ptype) {
2150  case PT_BOOL:
2152  = SG_MALLOC(SGSparseVector<bool>, new_length); break;
2153  case PT_CHAR:
2155  = SG_MALLOC(SGSparseVector<char>, new_length); break;
2156  case PT_INT8:
2158  = SG_MALLOC(SGSparseVector<int8_t>, new_length); break;
2159  case PT_UINT8:
2161  = SG_MALLOC(SGSparseVector<uint8_t>, new_length); break;
2162  case PT_INT16:
2164  = SG_MALLOC(SGSparseVector<int16_t>, new_length); break;
2165  case PT_UINT16:
2167  = SG_MALLOC(SGSparseVector<uint16_t>, new_length); break;
2168  case PT_INT32:
2170  = SG_MALLOC(SGSparseVector<int32_t>, new_length);
2171  break;
2172  case PT_UINT32:
2174  = SG_MALLOC(SGSparseVector<uint32_t>, new_length); break;
2175  case PT_INT64:
2177  = SG_MALLOC(SGSparseVector<int64_t>, new_length); break;
2178  case PT_UINT64:
2180  = SG_MALLOC(SGSparseVector<uint64_t>, new_length); break;
2181  case PT_FLOAT32:
2183  = SG_MALLOC(SGSparseVector<float32_t>, new_length); break;
2184  case PT_FLOAT64:
2186  = SG_MALLOC(SGSparseVector<float64_t>, new_length); break;
2187  case PT_FLOATMAX:
2189  = SG_MALLOC(SGSparseVector<floatmax_t>, new_length); break;
2190  case PT_COMPLEX128:
2192  = SG_MALLOC(SGSparseVector<complex128_t>, new_length); break;
2193  case PT_SGOBJECT:
2194  SG_SERROR("TParameter::new_cont(): Implementation "
2195  "error: Could not allocate "
2196  "Sparse<SGSerializable*>");
2197  break;
2198  case PT_UNDEFINED: default:
2199  SG_SERROR("Implementation error: undefined primitive type\n");
2200  break;
2201  }
2202  break;
2203  case ST_UNDEFINED: default:
2204  SG_SERROR("Implementation error: undefined structure type\n");
2205  break;
2206  } /* switch (m_datatype.m_stype) */
2207 
2208  s=SG_MALLOC(char, 200);
2209  m_datatype.to_string(s, 200);
2210  SG_SDEBUG("leaving TParameter::new_cont for \"%s\" of type %s\n",
2211  s, m_name ? m_name : "(nil)");
2212  SG_FREE(s);
2213 }
2214 
2215 bool
2216 TParameter::new_sgserial(CSGObject** param,
2217  EPrimitiveType generic,
2218  const char* sgserializable_name,
2219  const char* prefix)
2220 {
2221  if (*param != NULL)
2222  SG_UNREF(*param);
2223 
2224  *param = new_sgserializable(sgserializable_name, generic);
2225 
2226  if (*param == NULL) {
2227  string_t buf = {'\0'};
2228 
2229  if (generic != PT_NOT_GENERIC) {
2230  buf[0] = '<';
2231  TSGDataType::ptype_to_string(buf+1, generic,
2232  STRING_LEN - 3);
2233  strcat(buf, ">");
2234  }
2235 
2236  SG_SWARNING("TParameter::new_sgserial(): "
2237  "Class `C%s%s' was not listed during compiling Shogun"
2238  " :( ... Can not construct it for `%s%s'!",
2239  sgserializable_name, buf, prefix, m_name);
2240 
2241  return false;
2242  }
2243 
2244  SG_REF(*param);
2245  return true;
2246 }
2247 
2248 bool
2249 TParameter::save_ptype(CSerializableFile* file, const void* param,
2250  const char* prefix)
2251 {
2252  if (m_datatype.m_ptype == PT_SGOBJECT) {
2253  const char* sgserial_name = "";
2254  EPrimitiveType generic = PT_NOT_GENERIC;
2255 
2256  if (*(CSGObject**) param != NULL) {
2257  sgserial_name = (*(CSGObject**) param)->get_name();
2258  (*(CSGObject**) param)->is_generic(&generic);
2259  }
2260 
2261  if (!file->write_sgserializable_begin(
2262  &m_datatype, m_name, prefix, sgserial_name, generic))
2263  return false;
2264  if (*sgserial_name != '\0') {
2265  char* p = new_prefix(prefix, m_name);
2266  bool result = (*(CSGObject**) param)
2267  ->save_serializable(file, p);
2268  delete p;
2269  if (!result) return false;
2270  }
2271  if (!file->write_sgserializable_end(
2272  &m_datatype, m_name, prefix, sgserial_name, generic))
2273  return false;
2274  } else
2275  if (!file->write_scalar(&m_datatype, m_name, prefix,
2276  param)) return false;
2277 
2278  return true;
2279 }
2280 
2281 bool
2282 TParameter::load_ptype(CSerializableFile* file, void* param,
2283  const char* prefix)
2284 {
2285  if (m_datatype.m_ptype == PT_SGOBJECT) {
2286  string_t sgserial_name = {'\0'};
2287  EPrimitiveType generic = PT_NOT_GENERIC;
2288 
2289  if (!file->read_sgserializable_begin(
2290  &m_datatype, m_name, prefix, sgserial_name, &generic))
2291  return false;
2292  if (*sgserial_name != '\0') {
2293  if (!new_sgserial((CSGObject**) param, generic,
2294  sgserial_name, prefix))
2295  return false;
2296 
2297  char* p = new_prefix(prefix, m_name);
2298  bool result = (*(CSGObject**) param)
2299  ->load_serializable(file, p);
2300  delete p;
2301  if (!result) return false;
2302  }
2303  if (!file->read_sgserializable_end(
2304  &m_datatype, m_name, prefix, sgserial_name, generic))
2305  return false;
2306  } else
2307  if (!file->read_scalar(&m_datatype, m_name, prefix,
2308  param)) return false;
2309 
2310  return true;
2311 }
2312 
2313 bool
2314 TParameter::save_stype(CSerializableFile* file, const void* param,
2315  const char* prefix)
2316 {
2317  SGString<char>* str_ptr = (SGString<char>*) param;
2318  SGSparseVector<char>* spr_ptr = (SGSparseVector<char>*) param;
2319  index_t len_real;
2320 
2321  switch (m_datatype.m_stype) {
2322  case ST_NONE:
2323  if (!save_ptype(file, param, prefix)) return false;
2324  break;
2325  case ST_STRING:
2326  len_real = str_ptr->slen;
2327  if (str_ptr->string == NULL && len_real != 0) {
2328  SG_SWARNING("Inconsistency between data structure and "
2329  "len during saving string `%s%s'! Continuing"
2330  " with len=0.\n",
2331  prefix, m_name);
2332  len_real = 0;
2333  }
2334  if (!file->write_string_begin(
2335  &m_datatype, m_name, prefix, len_real)) return false;
2336  for (index_t i=0; i<len_real; i++) {
2337  if (!file->write_stringentry_begin(
2338  &m_datatype, m_name, prefix, i)) return false;
2339  if (!save_ptype(file, (char*) str_ptr->string
2340  + i *m_datatype.sizeof_ptype(), prefix))
2341  return false;
2342  if (!file->write_stringentry_end(
2343  &m_datatype, m_name, prefix, i)) return false;
2344  }
2345  if (!file->write_string_end(
2346  &m_datatype, m_name, prefix, len_real)) return false;
2347  break;
2348  case ST_SPARSE:
2349  len_real = spr_ptr->num_feat_entries;
2350  if (spr_ptr->features == NULL && len_real != 0) {
2351  SG_SWARNING("Inconsistency between data structure and "
2352  "len during saving sparse `%s%s'! Continuing"
2353  " with len=0.\n",
2354  prefix, m_name);
2355  len_real = 0;
2356  }
2357  if (!file->write_sparse_begin(
2358  &m_datatype, m_name, prefix, len_real)) return false;
2359  for (index_t i=0; i<len_real; i++) {
2361  ((char*) spr_ptr->features + i *TSGDataType
2363  if (!file->write_sparseentry_begin(
2364  &m_datatype, m_name, prefix, spr_ptr->features,
2365  cur->feat_index, i)) return false;
2366  if (!save_ptype(file, (char*) cur + TSGDataType
2367  ::offset_sparseentry(m_datatype.m_ptype),
2368  prefix)) return false;
2369  if (!file->write_sparseentry_end(
2370  &m_datatype, m_name, prefix, spr_ptr->features,
2371  cur->feat_index, i)) return false;
2372  }
2373  if (!file->write_sparse_end(
2374  &m_datatype, m_name, prefix, len_real)) return false;
2375  break;
2376  case ST_UNDEFINED: default:
2377  SG_SERROR("Implementation error: undefined structure type\n");
2378  break;
2379  }
2380 
2381  return true;
2382 }
2383 
2384 bool
2385 TParameter::load_stype(CSerializableFile* file, void* param,
2386  const char* prefix)
2387 {
2388  SGString<char>* str_ptr = (SGString<char>*) param;
2389  SGSparseVector<char>* spr_ptr = (SGSparseVector<char>*) param;
2390  index_t len_real = 0;
2391 
2392  switch (m_datatype.m_stype) {
2393  case ST_NONE:
2394  if (!load_ptype(file, param, prefix)) return false;
2395  break;
2396  case ST_STRING:
2397  if (!file->read_string_begin(
2398  &m_datatype, m_name, prefix, &len_real))
2399  return false;
2400  str_ptr->string = len_real > 0
2401  ? SG_MALLOC(char, len_real*m_datatype.sizeof_ptype()): NULL;
2402  for (index_t i=0; i<len_real; i++) {
2403  if (!file->read_stringentry_begin(
2404  &m_datatype, m_name, prefix, i)) return false;
2405  if (!load_ptype(file, (char*) str_ptr->string
2406  + i *m_datatype.sizeof_ptype(), prefix))
2407  return false;
2408  if (!file->read_stringentry_end(
2409  &m_datatype, m_name, prefix, i)) return false;
2410  }
2411  if (!file->read_string_end(
2412  &m_datatype, m_name, prefix, len_real))
2413  return false;
2414  str_ptr->slen = len_real;
2415  break;
2416  case ST_SPARSE:
2417  if (!file->read_sparse_begin(
2418  &m_datatype, m_name, prefix, &len_real)) return false;
2419  spr_ptr->features = len_real > 0? (SGSparseVectorEntry<char>*)
2420  SG_MALLOC(char, len_real *TSGDataType::sizeof_sparseentry(
2421  m_datatype.m_ptype)): NULL;
2422  for (index_t i=0; i<len_real; i++) {
2424  ((char*) spr_ptr->features + i *TSGDataType
2426  if (!file->read_sparseentry_begin(
2427  &m_datatype, m_name, prefix, spr_ptr->features,
2428  &cur->feat_index, i)) return false;
2429  if (!load_ptype(file, (char*) cur + TSGDataType
2430  ::offset_sparseentry(m_datatype.m_ptype),
2431  prefix)) return false;
2432  if (!file->read_sparseentry_end(
2433  &m_datatype, m_name, prefix, spr_ptr->features,
2434  &cur->feat_index, i)) return false;
2435  }
2436 
2437  if (!file->read_sparse_end(&m_datatype, m_name, prefix, len_real))
2438  return false;
2439 
2440  spr_ptr->num_feat_entries = len_real;
2441  break;
2442  case ST_UNDEFINED: default:
2443  SG_SERROR("Implementation error: undefined structure type\n");
2444  break;
2445  }
2446 
2447  return true;
2448 }
2449 
2451  uint32_t& hash, uint32_t& carry, uint32_t& total_length)
2452 {
2453 
2454  switch (m_datatype.m_ctype)
2455  {
2456  case CT_NDARRAY:
2458  break;
2459  case CT_SCALAR:
2460  {
2461  uint8_t* data = ((uint8_t*) m_parameter);
2462  uint32_t size = m_datatype.sizeof_stype();
2463  total_length += size;
2465  &hash, &carry, data, size);
2466  break;
2467  }
2468  case CT_VECTOR: case CT_MATRIX: case CT_SGVECTOR: case CT_SGMATRIX:
2469  {
2470  index_t len_real_y = 0, len_real_x = 0;
2471 
2472  if (m_datatype.m_length_y)
2473  len_real_y = *m_datatype.m_length_y;
2474 
2475  else
2476  len_real_y = 1;
2477 
2478  if (*(void**) m_parameter == NULL && len_real_y != 0)
2479  {
2480  SG_SWARNING("Inconsistency between data structure and "
2481  "len_y during hashing `%s'! Continuing with "
2482  "len_y=0.\n",
2483  m_name);
2484  len_real_y = 0;
2485  }
2486 
2487  switch (m_datatype.m_ctype)
2488  {
2489  case CT_NDARRAY:
2491  break;
2492  case CT_VECTOR: case CT_SGVECTOR:
2493  len_real_x = 1;
2494  break;
2495  case CT_MATRIX: case CT_SGMATRIX:
2496  len_real_x = *m_datatype.m_length_x;
2497 
2498  if (*(void**) m_parameter == NULL && len_real_x != 0)
2499  {
2500  SG_SWARNING("Inconsistency between data structure and "
2501  "len_x during hashing %s'! Continuing "
2502  "with len_x=0.\n",
2503  m_name);
2504  len_real_x = 0;
2505  }
2506 
2507  if (len_real_x *len_real_y == 0)
2508  len_real_x = len_real_y = 0;
2509 
2510  break;
2511 
2512  case CT_SCALAR: break;
2513  case CT_UNDEFINED: default:
2514  SG_SERROR("Implementation error: undefined container type\n");
2515  break;
2516  }
2517  uint32_t size = (len_real_x*len_real_y)*m_datatype.sizeof_stype();
2518 
2519  total_length += size;
2520 
2521  uint8_t* data = (*(uint8_t**) m_parameter);
2522 
2524  &hash, &carry, data, size);
2525  break;
2526  }
2527  case CT_UNDEFINED: default:
2528  SG_SERROR("Implementation error: undefined container type\n");
2529  break;
2530  }
2531 }
2532 
2533 bool
2535 {
2536  return m_datatype.get_num_elements() > 0;
2537 }
2538 
2539 bool
2540 TParameter::save(CSerializableFile* file, const char* prefix)
2541 {
2542  const int32_t buflen=100;
2543  char* buf=SG_MALLOC(char, buflen);
2544  m_datatype.to_string(buf, buflen);
2545  SG_SINFO("Saving parameter '%s' of type '%s'\n", m_name, buf)
2546  SG_FREE(buf);
2547 
2548  if (!file->write_type_begin(&m_datatype, m_name, prefix))
2549  return false;
2550 
2551  switch (m_datatype.m_ctype) {
2552  case CT_NDARRAY:
2554  break;
2555  case CT_SCALAR:
2556  if (!save_stype(file, m_parameter, prefix)) return false;
2557  break;
2558  case CT_VECTOR: case CT_MATRIX: case CT_SGVECTOR: case CT_SGMATRIX:
2559  {
2560  index_t len_real_y = 0, len_real_x = 0;
2561 
2562  len_real_y = *m_datatype.m_length_y;
2563  if (*(void**) m_parameter == NULL && len_real_y != 0) {
2564  SG_SWARNING("Inconsistency between data structure and "
2565  "len_y during saving `%s%s'! Continuing with "
2566  "len_y=0.\n",
2567  prefix, m_name);
2568  len_real_y = 0;
2569  }
2570 
2571  switch (m_datatype.m_ctype) {
2572  case CT_NDARRAY:
2574  break;
2575  case CT_VECTOR: case CT_SGVECTOR:
2576  len_real_x = 1;
2577  break;
2578  case CT_MATRIX: case CT_SGMATRIX:
2579  len_real_x = *m_datatype.m_length_x;
2580  if (*(void**) m_parameter == NULL && len_real_x != 0) {
2581  SG_SWARNING("Inconsistency between data structure and "
2582  "len_x during saving `%s%s'! Continuing "
2583  "with len_x=0.\n",
2584  prefix, m_name);
2585  len_real_x = 0;
2586  }
2587 
2588  if (len_real_x *len_real_y == 0)
2589  len_real_x = len_real_y = 0;
2590 
2591  break;
2592  case CT_SCALAR: break;
2593  case CT_UNDEFINED: default:
2594  SG_SERROR("Implementation error: undefined container type\n");
2595  break;
2596  }
2597 
2598  if (!file->write_cont_begin(&m_datatype, m_name, prefix,
2599  len_real_y, len_real_x))
2600  return false;
2601 
2602  /* ******************************************************** */
2603 
2604  for (index_t x=0; x<len_real_x; x++)
2605  for (index_t y=0; y<len_real_y; y++) {
2606  if (!file->write_item_begin(
2607  &m_datatype, m_name, prefix, y, x))
2608  return false;
2609 
2610  if (!save_stype(
2611  file, (*(char**) m_parameter)
2612  + (x*len_real_y + y)*m_datatype.sizeof_stype(),
2613  prefix)) return false;
2614  if (!file->write_item_end(
2615  &m_datatype, m_name, prefix, y, x))
2616  return false;
2617  }
2618 
2619  /* ******************************************************** */
2620 
2621  if (!file->write_cont_end(&m_datatype, m_name, prefix,
2622  len_real_y, len_real_x))
2623  return false;
2624 
2625  break;
2626  }
2627  case CT_UNDEFINED: default:
2628  SG_SERROR("Implementation error: undefined container type\n");
2629  break;
2630  }
2631 
2632  if (!file->write_type_end(&m_datatype, m_name, prefix))
2633  return false;
2634 
2635  return true;
2636 }
2637 
2638 bool
2639 TParameter::load(CSerializableFile* file, const char* prefix)
2640 {
2641  const int32_t buflen=100;
2642  char* buf=SG_MALLOC(char, buflen);
2643  m_datatype.to_string(buf, buflen);
2644  SG_SDEBUG("Loading parameter '%s' of type '%s'\n", m_name, buf)
2645  SG_FREE(buf);
2646 
2647  if (!file->read_type_begin(&m_datatype, m_name, prefix))
2648  return false;
2649 
2650  switch (m_datatype.m_ctype)
2651  {
2652  case CT_NDARRAY:
2654  break;
2655  case CT_SCALAR:
2656  if (!load_stype(file, m_parameter, prefix))
2657  return false;
2658  break;
2659 
2660  case CT_VECTOR: case CT_MATRIX: case CT_SGVECTOR: case CT_SGMATRIX:
2661  {
2662  SGVector<index_t> dims(2);
2663  dims.zero();
2664 
2665  if (!file->read_cont_begin(&m_datatype, m_name, prefix,
2666  &dims.vector[1], &dims.vector[0]))
2667  return false;
2668 
2669  switch (m_datatype.m_ctype)
2670  {
2671  case CT_NDARRAY:
2673  break;
2674  case CT_VECTOR: case CT_SGVECTOR:
2675  dims[0]=1;
2676  new_cont(dims);
2677  break;
2678  case CT_MATRIX: case CT_SGMATRIX:
2679  new_cont(dims);
2680  break;
2681  case CT_SCALAR:
2682  break;
2683  case CT_UNDEFINED: default:
2684  SG_SERROR("Implementation error: undefined container type\n");
2685  break;
2686  }
2687 
2688  for (index_t x=0; x<dims[0]; x++)
2689  {
2690  for (index_t y=0; y<dims[1]; y++)
2691  {
2692  if (!file->read_item_begin(
2693  &m_datatype, m_name, prefix, y, x))
2694  return false;
2695 
2696  if (!load_stype(
2697  file, (*(char**) m_parameter)
2698  + (x*dims[1] + y)*m_datatype.sizeof_stype(),
2699  prefix)) return false;
2700  if (!file->read_item_end(
2701  &m_datatype, m_name, prefix, y, x))
2702  return false;
2703  }
2704  }
2705 
2706  switch (m_datatype.m_ctype)
2707  {
2708  case CT_NDARRAY:
2710  break;
2711  case CT_VECTOR: case CT_SGVECTOR:
2712  *m_datatype.m_length_y = dims[1];
2713  break;
2714  case CT_MATRIX: case CT_SGMATRIX:
2715  *m_datatype.m_length_y = dims[1];
2716  *m_datatype.m_length_x = dims[0];
2717  break;
2718  case CT_SCALAR:
2719  break;
2720  case CT_UNDEFINED: default:
2721  SG_SERROR("Implementation error: undefined container type\n");
2722  break;
2723  }
2724 
2725  if (!file->read_cont_end(&m_datatype, m_name, prefix,
2726  dims[1], dims[0]))
2727  return false;
2728 
2729  break;
2730  }
2731  case CT_UNDEFINED: default:
2732  SG_SERROR("Implementation error: undefined container type\n");
2733  break;
2734  }
2735 
2736  if (!file->read_type_end(&m_datatype, m_name, prefix))
2737  return false;
2738 
2739  return true;
2740 }
2741 
2742 /*
2743  Initializing m_params(1) with small preallocation-size, because Parameter
2744  will be constructed several times for EACH SGObject instance.
2745  */
2746 Parameter::Parameter() : m_params(1)
2747 {
2748  SG_REF(sg_io);
2749 }
2750 
2752 {
2753  for (int32_t i=0; i<get_num_parameters(); i++)
2754  delete m_params.get_element(i);
2755 
2756  SG_UNREF(sg_io);
2757 }
2758 
2759 void
2760 Parameter::add_type(const TSGDataType* type, void* param,
2761  const char* name, const char* description)
2762 {
2763  if (name == NULL || *name == '\0')
2764  SG_SERROR("FATAL: Parameter::add_type(): `name' is empty!\n")
2765 
2766  for (size_t i=0; i<strlen(name); ++i)
2767  {
2768  if (!std::isalnum(name[i]) && name[i]!='_' && name[i]!='.')
2769  {
2770  SG_SERROR("Character %d of parameter with name \"%s\" is illegal "
2771  "(only alnum or underscore is allowed)\n",
2772  i, name);
2773  }
2774  }
2775 
2776  for (int32_t i=0; i<get_num_parameters(); i++)
2777  if (strcmp(m_params.get_element(i)->m_name, name) == 0)
2778  SG_SERROR("FATAL: Parameter::add_type(): "
2779  "Double parameter `%s'!\n", name);
2780 
2781  m_params.append_element(
2782  new TParameter(type, param, name, description)
2783  );
2784 }
2785 
2786 void
2787 Parameter::print(const char* prefix)
2788 {
2789  for (int32_t i=0; i<get_num_parameters(); i++)
2790  m_params.get_element(i)->print(prefix);
2791 }
2792 
2793 bool
2794 Parameter::save(CSerializableFile* file, const char* prefix)
2795 {
2796  for (int32_t i=0; i<get_num_parameters(); i++)
2797  {
2798  if (!m_params.get_element(i)->save(file, prefix))
2799  return false;
2800  }
2801 
2802  return true;
2803 }
2804 
2805 //bool
2806 //Parameter::load(CSerializableFile* file, const char* prefix)
2807 //{
2808 // for (int32_t i=0; i<get_num_parameters(); i++)
2809 // if (!m_params.get_element(i)->load(file, prefix))
2810 // return false;
2811 //
2812 // return true;
2813 //}
2814 
2816 {
2817  /* iterate over parameters in the given list */
2818  for (index_t i=0; i<params->get_num_parameters(); ++i)
2819  {
2820  TParameter* current=params->get_parameter(i);
2821  TSGDataType current_type=current->m_datatype;
2822 
2823  ASSERT(m_params.get_num_elements())
2824 
2825  /* search for own parameter with same name and check types if found */
2826  TParameter* own=NULL;
2827  for (index_t j=0; j<m_params.get_num_elements(); ++j)
2828  {
2829  own=m_params.get_element(j);
2830  if (!strcmp(own->m_name, current->m_name))
2831  {
2832  if (own->m_datatype==current_type)
2833  {
2834  own=m_params.get_element(j);
2835  break;
2836  }
2837  else
2838  {
2839  index_t l=200;
2840  char* given_type=SG_MALLOC(char, l);
2841  char* own_type=SG_MALLOC(char, l);
2842  current->m_datatype.to_string(given_type, l);
2843  own->m_datatype.to_string(own_type, l);
2844  SG_SERROR("given parameter \"%s\" has a different type (%s)"
2845  " than existing one (%s)\n", current->m_name,
2846  given_type, own_type);
2847  SG_FREE(given_type);
2848  SG_FREE(own_type);
2849  }
2850  }
2851  else
2852  own=NULL;
2853  }
2854 
2855  if (!own)
2856  {
2857  SG_SERROR("parameter with name %s does not exist\n",
2858  current->m_name);
2859  }
2860 
2861  /* check if parameter contained CSGobjects (update reference counts) */
2862  if (current_type.m_ptype==PT_SGOBJECT)
2863  {
2864  /* PT_SGOBJECT only occurs for ST_NONE */
2865  if (own->m_datatype.m_stype==ST_NONE)
2866  {
2867  if (own->m_datatype.m_ctype==CT_SCALAR)
2868  {
2869  CSGObject** to_unref=(CSGObject**) own->m_parameter;
2870  CSGObject** to_ref=(CSGObject**) current->m_parameter;
2871 
2872  if ((*to_ref)!=(*to_unref))
2873  {
2874  SG_REF((*to_ref));
2875  SG_UNREF((*to_unref));
2876  }
2877 
2878  }
2879  else
2880  {
2881  /* unref all SGObjects and reference the new ones */
2882  CSGObject*** to_unref=(CSGObject***) own->m_parameter;
2883  CSGObject*** to_ref=(CSGObject***) current->m_parameter;
2884 
2885  for (index_t j=0; j<own->m_datatype.get_num_elements(); ++j)
2886  {
2887  if ((*to_ref)[j]!=(*to_unref)[j])
2888  {
2889  SG_REF(((*to_ref)[j]));
2890  SG_UNREF(((*to_unref)[j]));
2891  }
2892  }
2893  }
2894  }
2895  else
2896  SG_SERROR("primitive type PT_SGOBJECT occurred with structure "
2897  "type other than ST_NONE");
2898  }
2899 
2900  /* construct pointers to the to be copied parameter data */
2901  void* dest=NULL;
2902  void* source=NULL;
2903  if (current_type.m_ctype==CT_SCALAR)
2904  {
2905  /* for scalar values, just copy content the pointer points to */
2906  dest=own->m_parameter;
2907  source=current->m_parameter;
2908 
2909  /* in case of CSGObject, pointers are not equal if CSGObjects are
2910  * equal, so check. For other values, the pointers are equal and
2911  * the not-copying is handled below before the memcpy call */
2912  if (own->m_datatype.m_ptype==PT_SGOBJECT)
2913  {
2914  if (*((CSGObject**)dest) == *((CSGObject**)source))
2915  {
2916  dest=NULL;
2917  source=NULL;
2918  }
2919  }
2920  }
2921  else
2922  {
2923  /* for matrices and vectors, sadly m_parameter has to be
2924  * de-referenced once, because a pointer to the array address is
2925  * saved, but the array address itself has to be copied.
2926  * consequently, for dereferencing, a type distinction is needed */
2927  switch (own->m_datatype.m_ptype)
2928  {
2929  case PT_FLOAT64:
2930  dest=*((float64_t**) own->m_parameter);
2931  source=*((float64_t**) current->m_parameter);
2932  break;
2933  case PT_SGOBJECT:
2934  dest=*((CSGObject**) own->m_parameter);
2935  source=*((CSGObject**) current->m_parameter);
2936  break;
2937  default:
2939  break;
2940  }
2941  }
2942 
2943  /* copy parameter data, size in memory is equal because of same type */
2944  if (dest!=source)
2945  memcpy(dest, source, own->m_datatype.get_size());
2946  }
2947 }
2948 
2950 {
2951  for (index_t i=0; i<params->get_num_parameters(); ++i)
2952  {
2953  TParameter* current=params->get_parameter(i);
2954  add_type(&(current->m_datatype), current->m_parameter, current->m_name,
2955  current->m_description);
2956  }
2957 }
2958 
2959 bool Parameter::contains_parameter(const char* name)
2960 {
2961  for (index_t i=0; i<m_params.get_num_elements(); ++i)
2962  {
2963  if (!strcmp(name, m_params[i]->m_name))
2964  return true;
2965  }
2966 
2967  return false;
2968 }
2969 
2970 bool TParameter::operator==(const TParameter& other) const
2971 {
2972  bool result=true;
2973  result&=!strcmp(m_name, other.m_name);
2974  return result;
2975 }
2976 
2977 bool TParameter::operator<(const TParameter& other) const
2978 {
2979  return strcmp(m_name, other.m_name)<0;
2980 }
2981 
2982 bool TParameter::operator>(const TParameter& other) const
2983 {
2984  return strcmp(m_name, other.m_name)>0;
2985 }
2986 
2988  bool new_cont_call)
2989 {
2990  SG_SDEBUG("entering TParameter::allocate_data_from_scratch of "
2991  "\"%s\"\n", m_name);
2992 
2993  /* set flag to delete all this stuff later on */
2995 
2996  /* length has to be allocated for matrices/vectors */
2997  switch (m_datatype.m_ctype)
2998  {
2999  case CT_VECTOR: case CT_SGVECTOR:
3000  m_datatype.m_length_y=SG_MALLOC(index_t, 1);
3001  *m_datatype.m_length_y=dims[1];
3002  break;
3003  case CT_MATRIX: case CT_SGMATRIX:
3004  m_datatype.m_length_x=SG_MALLOC(index_t, 1);
3005  m_datatype.m_length_y=SG_MALLOC(index_t, 1);
3006  *m_datatype.m_length_y=dims[1];
3007  *m_datatype.m_length_x=dims[0];
3008  break;
3009  case CT_SCALAR:
3010  m_datatype.m_length_x=NULL;
3011  m_datatype.m_length_y=NULL;
3012  break;
3013  case CT_NDARRAY:
3015  break;
3016  case CT_UNDEFINED: default:
3017  SG_SERROR("Implementation error: undefined container type\n");
3018  break;
3019  }
3020 
3021  /* check if there is no data loss */
3022  if (m_parameter)
3023  SG_SERROR("TParameter::allocate_data_from_scratch must not be called "
3024  "when the underlying TParameter instance already has data.\n");
3025 
3026  /* scalars are treated differently than vectors/matrices. memory has to
3027  * be allocated for the data itself */
3028  if (m_datatype.m_ctype==CT_SCALAR)
3029  {
3030  /* sgobjects are treated differently than the rest */
3031  if (m_datatype.m_ptype!=PT_SGOBJECT)
3032  {
3033  /* for non-sgobject allocate memory because normally they are on
3034  * stack and excluded in the TParameter data allocation.
3035  * Will be deleted by the TParameter destructor */
3036  m_parameter=SG_MALLOC(char, m_datatype.get_size());
3037  }
3038  else
3039  {
3040  /* for sgobjects, allocate memory for pointer and set to NULL
3041  * Will be deleted by the TParameter destructor */
3042  m_parameter=SG_MALLOC(CSGObject**, 1);
3043  *((CSGObject**)m_parameter)=NULL;
3044  }
3045  }
3046  else
3047  {
3048  /* allocate pointer for data pointer */
3049  void** data_p=SG_MALLOC(void*, 1);
3050  *data_p=NULL;
3051 
3052  /* allocate dummy data at the point the above pointer points to
3053  * will be freed by the delete_cont() method of TParameter.
3054  * This is needed because new_cont/delete_cont cannot handle
3055  * non-existing data. Set to NULL to avoid problems */
3056  if (new_cont_call)
3057  {
3058  *data_p=SG_MALLOC(void**, 1);
3059  **(void***)data_p=NULL;
3060  }
3061 
3062  m_parameter=data_p;
3063 
3064  /* perform one data allocation. This may be repeated and therefore
3065  * redundant if load() is called afterwards, however, if one wants
3066  * to write directly to the array data after this call, it is
3067  * necessary */
3068  if (new_cont_call)
3069  new_cont(dims);
3070  }
3071 
3072  SG_SDEBUG("leaving TParameter::allocate_data_from_scratch of "
3073  "\"%s\"\n", m_name);
3074 }
3075 
3077 {
3078  SG_SDEBUG("entering TParameter::copy_data for %s\n", m_name)
3079 
3080  /* assert that type is equal */
3084 
3085  /* first delete old data if non-scalar */
3086  if (m_datatype.m_ctype!=CT_SCALAR)
3087  delete_cont();
3088 
3089  /* then copy data in case of numeric scalars, or pointer to data else */
3090  if (m_datatype.m_ctype==CT_SCALAR && m_datatype.m_ptype!=PT_SGOBJECT)
3091  {
3092  /* just copy value behind pointer */
3093  SG_SDEBUG("Copying scalar data of size %d from %p to %p\n",
3095  memcpy(m_parameter, source->m_parameter,
3096  m_datatype.get_size());
3097  }
3098  else
3099  {
3100  /* if this is a sgobject, the old one has to be unrefed */
3101  if (m_datatype.m_ptype==PT_SGOBJECT)
3102  {
3103  if (m_datatype.m_ctype==CT_SCALAR)
3104  {
3106  }
3107  else
3108  {
3109  int32_t length=1;
3110  length*=m_datatype.m_length_x ? *m_datatype.m_length_x : 1;
3111  length*=m_datatype.m_length_y ? *m_datatype.m_length_y : 1;
3112 
3113  for (index_t j=0; j<length; ++j)
3114  {
3115  SG_UNREF(((CSGObject**)(m_parameter))[j]);
3116  }
3117  }
3118  }
3119 
3120  /* in this case, data is a pointer pointing to the actual
3121  * data, so copy pointer if non-NULL*/
3122  SG_SDEBUG("Copying non-scalar pointer %p\n", *((void**)source->m_parameter))
3123  *((void**)m_parameter)=*((void**)source->m_parameter);
3124  }
3125 
3126  /* copy lengths */
3127  if (source->m_datatype.m_length_x)
3129 
3130  if (source->m_datatype.m_length_y)
3132 
3133  SG_SDEBUG("leaving TParameter::copy_data for %s\n", m_name)
3134 }
3135 
3137 {
3138  SG_SDEBUG("entering TParameter::equals()\n");
3139 
3140  if (!other)
3141  {
3142  SG_SDEBUG("leaving TParameter::equals(): other parameter is NULL\n");
3143  return false;
3144  }
3145 
3146  if (strcmp(m_name, other->m_name))
3147  {
3148  SG_SDEBUG("leaving TParameter::equals(): name \"%s\" is different from"
3149  " other parameter's name \"%s\"\n", m_name, other->m_name);
3150  return false;
3151  }
3152 
3153  SG_SDEBUG("Comparing datatypes\n");
3154  if (!(m_datatype.equals(other->m_datatype)))
3155  {
3156  SG_SDEBUG("leaving TParameter::equals(): type of \"%s\" is different "
3157  "from other parameter's \"%s\" type\n", m_name, other->m_name);
3158  return false;
3159  }
3160 
3161  /* avoid comparing NULL */
3162  if (!m_parameter && !other->m_parameter)
3163  {
3164  SG_SDEBUG("leaving TParameter::equals(): both parameters are NULL\n");
3165  return true;
3166  }
3167 
3168  if ((!m_parameter && other->m_parameter) || (m_parameter && !other->m_parameter))
3169  {
3170  SG_SDEBUG("leaving TParameter::equals(): param1 is at %p while "
3171  "param2 is at %p\n", m_parameter, other->m_parameter);
3172  return false;
3173  }
3174 
3175  SG_SDEBUG("Comparing ctype\n");
3176  switch (m_datatype.m_ctype)
3177  {
3178  case CT_SCALAR:
3179  {
3180  SG_SDEBUG("CT_SCALAR\n");
3183  other->m_parameter,
3184  accuracy))
3185  {
3186  SG_SDEBUG("leaving TParameter::equals(): scalar data differs\n");
3187  return false;
3188  }
3189  break;
3190  }
3191  case CT_VECTOR: case CT_SGVECTOR:
3192  {
3193  SG_SDEBUG("CT_VECTOR or CT_SGVECTOR\n");
3194 
3195  /* x is number of processed bytes */
3196  index_t x=0;
3197  SG_SDEBUG("length_y: %d\n", *m_datatype.m_length_y)
3198  for (index_t i=0; i<*m_datatype.m_length_y; ++i)
3199  {
3200  SG_SDEBUG("comparing element %d which is %d bytes from start\n",
3201  i, x);
3202 
3203  void* pointer_a=&((*(char**)m_parameter)[x]);
3204  void* pointer_b=&((*(char**)other->m_parameter)[x]);
3205 
3207  m_datatype.m_ptype, pointer_a, pointer_b, accuracy))
3208  {
3209  SG_SDEBUG("leaving TParameter::equals(): vector element "
3210  "differs\n");
3211  return false;
3212  }
3213 
3214  x=x+(m_datatype.sizeof_stype());
3215  }
3216 
3217  break;
3218  }
3219  case CT_MATRIX: case CT_SGMATRIX:
3220  {
3221  SG_SDEBUG("CT_MATRIX or CT_SGMATRIX\n");
3222 
3223  /* x is number of processed bytes */
3224  index_t x=0;
3225  SG_SDEBUG("length_y: %d\n", *m_datatype.m_length_y)
3226  SG_SDEBUG("length_x: %d\n", *m_datatype.m_length_x)
3227  int64_t length=0;
3228 
3229  /* For ST_SPARSE, we just need to loop over the rows and compare_stype
3230  * does the comparison for one whole row vector at once. For ST_NONE,
3231  * however, we need to loop over all elements.
3232  */
3233  if (m_datatype.m_stype==ST_SPARSE)
3234  length=(*m_datatype.m_length_y);
3235  else
3236  length=(*m_datatype.m_length_y) * (*m_datatype.m_length_x);
3237 
3238  for (index_t i=0; i<length; ++i)
3239  {
3240  SG_SDEBUG("comparing element %d which is %d byes from start\n",
3241  i, x);
3242 
3243  void* pointer_a=&((*(char**)m_parameter)[x]);
3244  void* pointer_b=&((*(char**)other->m_parameter)[x]);
3245 
3247  m_datatype.m_ptype, pointer_a, pointer_b, accuracy))
3248  {
3249  SG_SDEBUG("leaving TParameter::equals(): vector element "
3250  "differs\n");
3251  return false;
3252  }
3253 
3254  /* For ST_SPARSE, the iteration is on the pointer of SGSparseVectors */
3255  if (m_datatype.m_stype==ST_SPARSE)
3256  x=x+(m_datatype.sizeof_stype());
3257  else
3258  x=x+(m_datatype.sizeof_stype());
3259  }
3260 
3261  break;
3262  }
3263  case CT_NDARRAY:
3264  {
3265  SG_SDEBUG("CT_NDARRAY\n");
3266  SG_SERROR("TParameter::equals(): Not yet implemented for "
3267  "CT_NDARRAY!\n");
3268  break;
3269  }
3270  case CT_UNDEFINED: default:
3271  SG_SERROR("Implementation error: undefined container type\n");
3272  break;
3273  }
3274 
3275  SG_SDEBUG("leaving TParameter::equals(): Parameters are equal\n");
3276  return true;
3277 }
3278 
3279 bool TParameter::compare_ptype(EPrimitiveType ptype, void* data1, void* data2,
3280  floatmax_t accuracy)
3281 {
3282  SG_SDEBUG("entering TParameter::compare_ptype()\n");
3283 
3284  if ((data1 && !data2) || (!data1 && data2))
3285  {
3286  SG_SINFO("leaving TParameter::compare_ptype(): data1 is at %p while "
3287  "data2 is at %p\n", data1, data2);
3288  return false;
3289  }
3290 
3292  if (!data1 && !data2)
3293  {
3294  SG_SDEBUG("leaving TParameter::compare_ptype(): both data are NULL\n");
3295  return true;
3296  }
3297 
3298  switch (ptype)
3299  {
3300  case PT_BOOL:
3301  {
3302  bool casted1=*((bool*)data1);
3303  bool casted2=*((bool*)data2);
3304 
3305  if (CMath::abs(casted1-casted2)>accuracy)
3306  {
3307  SG_SINFO("leaving TParameter::compare_ptype(): PT_BOOL: "
3308  "data1=%d, data2=%d\n", casted1, casted2);
3309  return false;
3310  }
3311  break;
3312  }
3313  case PT_CHAR:
3314  {
3315  char casted1=*((char*)data1);
3316  char casted2=*((char*)data2);
3317 
3318  if (CMath::abs(casted1-casted2)>accuracy)
3319  {
3320  SG_SINFO("leaving TParameter::compare_ptype(): PT_CHAR: "
3321  "data1=%c, data2=%c\n", casted1, casted2);
3322  return false;
3323  }
3324  break;
3325  }
3326  case PT_INT8:
3327  {
3328  int8_t casted1=*((int8_t*)data1);
3329  int8_t casted2=*((int8_t*)data2);
3330 
3331  if (CMath::abs(casted1-casted2)>accuracy)
3332  {
3333  SG_SINFO("leaving TParameter::compare_ptype(): PT_INT8: "
3334  "data1=%d, data2=%d\n", casted1, casted2);
3335  return false;
3336  }
3337  break;
3338  }
3339  case PT_UINT8:
3340  {
3341  uint8_t casted1=*((uint8_t*)data1);
3342  uint8_t casted2=*((uint8_t*)data2);
3343 
3344  if (CMath::abs(casted1-casted2)>accuracy)
3345  {
3346  SG_SINFO("leaving TParameter::compare_ptype(): PT_UINT8: "
3347  "data1=%d, data2=%d\n", casted1, casted2);
3348  return false;
3349  }
3350  break;
3351  }
3352  case PT_INT16:
3353  {
3354  int16_t casted1=*((int16_t*)data1);
3355  int16_t casted2=*((int16_t*)data2);
3356 
3357  if (CMath::abs(casted1-casted2)>accuracy)
3358  {
3359  SG_SINFO("leaving TParameter::compare_ptype(): PT_INT16: "
3360  "data1=%d, data2=%d\n", casted1, casted2);
3361  return false;
3362  }
3363  break;
3364  }
3365  case PT_UINT16:
3366  {
3367  uint16_t casted1=*((uint16_t*)data1);
3368  uint16_t casted2=*((uint16_t*)data2);
3369 
3370  if (CMath::abs(casted1-casted2)>accuracy)
3371  {
3372  SG_SINFO("leaving TParameter::compare_ptype(): PT_UINT16: "
3373  "data1=%d, data2=%d\n", casted1, casted2);
3374  return false;
3375  }
3376  break;
3377  }
3378  case PT_INT32:
3379  {
3380  int32_t casted1=*((int32_t*)data1);
3381  int32_t casted2=*((int32_t*)data2);
3382 
3383  if (CMath::abs(casted1-casted2)>accuracy)
3384  {
3385  SG_SINFO("leaving TParameter::compare_ptype(): PT_INT32: "
3386  "data1=%d, data2=%d\n", casted1, casted2);
3387  return false;
3388  }
3389  break;
3390  }
3391  case PT_UINT32:
3392  {
3393  uint32_t casted1=*((uint32_t*)data1);
3394  uint32_t casted2=*((uint32_t*)data2);
3395 
3396  if (CMath::abs(casted1-casted2)>accuracy)
3397  {
3398  SG_SINFO("leaving TParameter::compare_ptype(): PT_UINT32: "
3399  "data1=%d, data2=%d\n", casted1, casted2);
3400  return false;
3401  }
3402  break;
3403  }
3404  case PT_INT64:
3405  {
3406  int64_t casted1=*((int64_t*)data1);
3407  int64_t casted2=*((int64_t*)data2);
3408 
3409  if (CMath::abs(casted1-casted2)>accuracy)
3410  {
3411  SG_SINFO("leaving TParameter::compare_ptype(): PT_INT64: "
3412  "data1=%d, data2=%d\n", casted1, casted2);
3413  return false;
3414  }
3415  break;
3416  }
3417  case PT_UINT64:
3418  {
3419  uint64_t casted1=*((uint64_t*)data1);
3420  uint64_t casted2=*((uint64_t*)data2);
3421 
3422  if (CMath::abs(casted1-casted2)>accuracy)
3423  {
3424  SG_SINFO("leaving TParameter::compare_ptype(): PT_UINT64: "
3425  "data1=%d, data2=%d\n", casted1, casted2);
3426  return false;
3427  }
3428  break;
3429  }
3430  case PT_FLOAT32:
3431  {
3432  float32_t casted1=*((float32_t*)data1);
3433  float32_t casted2=*((float32_t*)data2);
3434 
3435  if (CMath::abs(casted1-casted2)>accuracy)
3436  {
3437  SG_SINFO("leaving TParameter::compare_ptype(): PT_FLOAT32: "
3438  "data1=%f, data2=%f\n", casted1, casted2);
3439  return false;
3440  }
3441  break;
3442  }
3443  case PT_FLOAT64:
3444  {
3445  float64_t casted1=*((float64_t*)data1);
3446  float64_t casted2=*((float64_t*)data2);
3447 
3448  if (CMath::abs(casted1-casted2)>accuracy)
3449  {
3450  SG_SINFO("leaving TParameter::compare_ptype(): PT_FLOAT64: "
3451  "data1=%f, data2=%f\n", casted1, casted2);
3452  return false;
3453  }
3454  break;
3455  }
3456  case PT_FLOATMAX:
3457  {
3458  floatmax_t casted1=*((floatmax_t*)data1);
3459  floatmax_t casted2=*((floatmax_t*)data2);
3460  if (CMath::abs(casted1-casted2)>accuracy)
3461  {
3462  SG_SINFO("leaving TParameter::compare_ptype(): PT_FLOATMAX: "
3463  "data1=%f, data2=%f\n", casted1, casted2);
3464  return false;
3465  }
3466  break;
3467  }
3468  case PT_COMPLEX128:
3469  {
3470  float64_t casted1_real=((complex128_t*)data1)->real();
3471  float64_t casted1_imag=((complex128_t*)data1)->imag();
3472  float64_t casted2_real=((complex128_t*)data2)->real();
3473  float64_t casted2_imag=((complex128_t*)data2)->imag();
3474  if (CMath::abs(casted1_real-casted2_real)>accuracy ||
3475  CMath::abs(casted1_imag-casted2_imag)>accuracy)
3476  {
3477  SG_SINFO("leaving TParameter::compare_ptype(): PT_COMPLEX128: "
3478  "data1=%f+i%f, data2=%f+i%f\n",
3479  casted1_real, casted1_imag,
3480  casted2_real, casted2_imag);
3481  return false;
3482  }
3483  break;
3484  }
3485  case PT_SGOBJECT:
3486  {
3487  CSGObject* casted1=*((CSGObject**)data1);
3488  CSGObject* casted2=*((CSGObject**)data2);
3489 
3490  /* important not to call methods on NULL */
3491  if (!casted1 && ! casted2)
3492  {
3493  SG_SDEBUG("leaving TParameter::compare_ptype(): SGObjects are equal\n");
3494  return true;
3495  }
3496 
3497  /* make sure to not call NULL methods */
3498  if (casted1)
3499  {
3500  if (!(casted1->equals(casted2, accuracy)))
3501  {
3502  SG_SINFO("leaving TParameter::compare_ptype(): PT_SGOBJECT "
3503  "equals returned false\n");
3504  return false;
3505  }
3506  }
3507  else
3508  {
3509  if (!(casted2->equals(casted1, accuracy)))
3510  {
3511  SG_SINFO("leaving TParameter::compare_ptype(): PT_SGOBJECT "
3512  "equals returned false\n");
3513  return false;
3514  }
3515 
3516  }
3517  break;
3518  }
3519  default:
3520  SG_SERROR("TParameter::compare_ptype(): Encountered unknown primitive"
3521  "-type: %d\n", ptype);
3522  break;
3523  }
3524 
3525  SG_SDEBUG("leaving TParameter::compare_ptype(): Data are equal\n");
3526  return true;
3527 }
3528 
3529 bool TParameter::copy_ptype(EPrimitiveType ptype, void* source, void* target)
3530 {
3531  SG_SDEBUG("entering TParameter::copy_ptype()\n");
3532 
3533  /* rather than using memcpy, use the cumbersome way here and cast all types.
3534  * This makes it so much easier to debug code.
3535  * Copy full stype if this is too slow */
3536  switch (ptype)
3537  {
3538  case PT_BOOL:
3539  {
3540  *((bool*)target)=*((bool*)source);
3541  SG_SDEBUG("after copy of ptype PT_BOOL: source %d, target %d\n",
3542  *((bool*)source), *((bool*)target));
3543  break;
3544  }
3545  case PT_CHAR:
3546  {
3547  *((char*)target)=*((char*)source);
3548  SG_SDEBUG("after copy of ptype PT_CHAR: source %c, target %c\n",
3549  *((char*)source), *((char*)target));
3550  break;
3551  }
3552  case PT_INT8:
3553  {
3554  *((int8_t*)target)=*((int8_t*)source);
3555  SG_SDEBUG("after copy of ptype PT_INT8: source %d, target %d\n",
3556  *((int8_t*)source), *((int8_t*)target));
3557  break;
3558  }
3559  case PT_UINT8:
3560  {
3561  *((uint8_t*)target)=*((uint8_t*)source);
3562  SG_SDEBUG("after copy of ptype PT_UINT8: source %d, target %d\n",
3563  *((uint8_t*)source), *((uint8_t*)target));
3564  break;
3565  }
3566  case PT_INT16:
3567  {
3568  *((int16_t*)target)=*((int16_t*)source);
3569  SG_SDEBUG("after copy of ptype PT_INT16: source %d, target %d\n",
3570  *((int16_t*)source), *((int16_t*)target));
3571  break;
3572  }
3573  case PT_UINT16:
3574  {
3575  *((uint16_t*)target)=*((uint16_t*)source);
3576  SG_SDEBUG("after copy of ptype PT_UINT16: source %d, target %d\n",
3577  *((uint16_t*)source), *((uint16_t*)target));
3578  break;
3579  }
3580  case PT_INT32:
3581  {
3582  *((int32_t*)target)=*((int32_t*)source);
3583  SG_SDEBUG("after copy of ptype PT_INT32: source %d, target %d\n",
3584  *((int32_t*)source), *((int32_t*)target));
3585  break;
3586  }
3587  case PT_UINT32:
3588  {
3589  *((uint32_t*)target)=*((uint32_t*)source);
3590  SG_SDEBUG("after copy of ptype PT_UINT32: source %d, target %d\n",
3591  *((uint32_t*)source), *((uint32_t*)target));
3592  break;
3593  }
3594  case PT_INT64:
3595  {
3596  *((int64_t*)target)=*((int64_t*)source);
3597  SG_SDEBUG("after copy of ptype PT_INT64: source %d, target %d\n",
3598  *((int64_t*)source), *((int64_t*)target));
3599  break;
3600  }
3601  case PT_UINT64:
3602  {
3603  *((uint64_t*)target)=*((uint64_t*)source);
3604  SG_SDEBUG("after copy of ptype PT_UINT64: source %d, target %d\n",
3605  *((uint64_t*)source), *((uint64_t*)target));
3606  break;
3607  }
3608  case PT_FLOAT32:
3609  {
3610  *((float32_t*)target)=*((float32_t*)source);
3611  SG_SDEBUG("after copy of ptype PT_FLOAT32: source %f, target %f\n",
3612  *((float32_t*)source), *((float32_t*)target));
3613  break;
3614  }
3615  case PT_FLOAT64:
3616  {
3617  *((float64_t*)target)=*((float64_t*)source);
3618  SG_SDEBUG("after copy of ptype PT_FLOAT64: source %f, target %f\n",
3619  *((float64_t*)source), *((float64_t*)target));
3620  break;
3621  }
3622  case PT_FLOATMAX:
3623  {
3624  *((floatmax_t*)target)=*((floatmax_t*)source);
3625  SG_SDEBUG("after copy of ptype PT_FLOATMAX: source %Lf, target %Lf\n",
3626  *((floatmax_t*)source), *((floatmax_t*)target));
3627  break;
3628  }
3629  case PT_COMPLEX128:
3630  {
3631  *((complex128_t*)target)=*((complex128_t*)source);
3632  SG_SDEBUG("after copy of ptype PT_COMPLEX128: "
3633  "source real %f, target real %f,"
3634  "source imag %f, target imag %f,"
3635  "\n",
3636  ((complex128_t*)source)->real(), ((complex128_t*)target)->real(),
3637  ((complex128_t*)source)->imag(), ((complex128_t*)target)->imag());
3638  break;
3639  }
3640  case PT_SGOBJECT:
3641  {
3642  CSGObject* casted1=*((CSGObject**)source);
3643  CSGObject* casted2=*((CSGObject**)target);
3644 
3645  /* important not to call methods on NULL */
3646  if (!casted1 && ! casted2)
3647  {
3648  SG_SDEBUG("leaving TParameter::copy_ptype(): Both SGObjects are NULL\n");
3649  return true;
3650  }
3651 
3652  /* make sure to not call NULL methods */
3653  if (casted1)
3654  {
3655  /* in case of overwriting old objects */
3656  SG_UNREF(*((CSGObject**)target));
3657  *((CSGObject**)target) = casted1->clone();
3658  }
3659 
3660  break;
3661  }
3662  default:
3663  SG_SERROR("TParameter::compare_ptype(): Encountered unknown primitive"
3664  "-type: %d\n", ptype);
3665  return false;
3666  break;
3667  }
3668 
3669  SG_SDEBUG("leaving TParameter::copy_ptype(): Copy successful\n");
3670  return true;
3671 }
3672 
3673 bool TParameter::compare_stype(EStructType stype, EPrimitiveType ptype,
3674  void* data1, void* data2, floatmax_t accuracy)
3675 {
3676  SG_SDEBUG("entering TParameter::compare_stype()\n");
3677 
3678  size_t size_ptype=TSGDataType::sizeof_ptype(ptype);
3679 
3680  /* Avoid comparing NULL */
3681  if (!data1 && !data2)
3682  {
3683  SG_SDEBUG("leaving TParameter::compare_stype(): both data are NULL\n");
3684  return true;
3685  }
3686 
3687  /* If one is NULL, data are not equal */
3688  if ((data1 && !data2) || (!data1 && data2))
3689  {
3690  SG_SINFO("leaving TParameter::compare_stype(): data1 is at %p while "
3691  "data2 is at %p\n", data1, data2);
3692  return false;
3693  }
3694 
3695  switch (stype)
3696  {
3697  case ST_NONE:
3698  {
3699  SG_SDEBUG("ST_NONE\n");
3700  return TParameter::compare_ptype(ptype, data1, data2, accuracy);
3701  break;
3702  }
3703  case ST_SPARSE:
3704  {
3705  SG_SDEBUG("ST_SPARSE\n");
3706  SGSparseVector<char>* spr_ptr1 = (SGSparseVector<char>*) data1;
3707  SGSparseVector<char>* spr_ptr2 = (SGSparseVector<char>*) data2;
3708 
3709  if (spr_ptr1->num_feat_entries != spr_ptr2->num_feat_entries)
3710  {
3711  SG_SINFO("leaving TParameter::compare_stype(): Length of "
3712  "sparse vector1 (%d) is different of vector 2 (%d)\n",
3713  spr_ptr1->num_feat_entries, spr_ptr2->num_feat_entries);
3714  return false;
3715  }
3716 
3717  SG_SDEBUG("Comparing sparse vectors\n");
3718  for (index_t i=0; i<spr_ptr1->num_feat_entries; ++i)
3719  {
3720  SG_SDEBUG("Comparing sparse entry %d at offset %d\n", i,
3722 
3724  ((char*) spr_ptr1->features + i*TSGDataType
3725  ::sizeof_sparseentry(ptype));
3727  ((char*) spr_ptr2->features + i*TSGDataType
3728  ::sizeof_sparseentry(ptype));
3729 
3730  /* sparse entries have an offset of the enty pointer depending
3731  * on type. Since I cast everything down to char, I need to remove
3732  * the char offset and add the offset of the ptype */
3733  index_t char_offset=TSGDataType::offset_sparseentry(PT_CHAR);
3734  index_t ptype_offset=TSGDataType::offset_sparseentry(ptype);
3735  void* pointer1=&(cur1->entry)-char_offset+ptype_offset;
3736  void* pointer2=&(cur2->entry)-char_offset+ptype_offset;
3737 
3738  if (!TParameter::compare_ptype(ptype, pointer1,
3739  pointer2, accuracy))
3740  {
3741  SG_SINFO("leaving TParameter::compare_stype(): Data of"
3742  " sparse vector element is different\n");
3743  return false;
3744  }
3745 
3746  /* also compare feature indices */
3747  if (cur2->feat_index!=cur1->feat_index)
3748  {
3749  SG_SINFO("leaving TParameter::compare_stype(): Feature "
3750  "index of sparse vector element is different. "
3751  "source: %d, target: %d\n",
3752  cur1->feat_index, cur2->feat_index);
3753  return false;
3754  }
3755  }
3756  break;
3757  }
3758  case ST_STRING:
3759  {
3760  SG_SDEBUG("ST_STRING\n");
3761  SGString<char>* str_ptr1 = (SGString<char>*) data1;
3762  SGString<char>* str_ptr2 = (SGString<char>*) data2;
3763 
3764  if (str_ptr1->slen != str_ptr2->slen)
3765  {
3766  SG_SINFO("leaving TParameter::compare_stype(): Length of "
3767  "string1 (%d) is different of string2 (%d)\n",
3768  str_ptr1->slen, str_ptr2->slen);
3769  return false;
3770  }
3771 
3772  SG_SDEBUG("Comparing strings\n");
3773  for (index_t i=0; i<str_ptr1->slen; ++i)
3774  {
3775  SG_SDEBUG("Comparing string element %d at offset %d\n", i,
3776  i*size_ptype);
3777  void* pointer1=str_ptr1->string+i*size_ptype;
3778  void* pointer2=str_ptr2->string+i*size_ptype;
3779 
3780  if (!TParameter::compare_ptype(ptype, pointer1,
3781  pointer2, accuracy))
3782  {
3783  SG_SINFO("leaving TParameter::compare_stype(): Data of"
3784  " string element is different\n");
3785  return false;
3786  }
3787  }
3788  break;
3789  }
3790  default:
3791  {
3792  SG_SERROR("TParameter::compare_stype(): Undefined struct type\n");
3793  break;
3794  }
3795  }
3796 
3797  SG_SDEBUG("leaving TParameter::compare_stype(): Data were equal\n");
3798  return true;
3799 }
3800 
3801 bool TParameter::copy_stype(EStructType stype, EPrimitiveType ptype,
3802  void* source, void* target)
3803 {
3804  SG_SDEBUG("entering TParameter::copy_stype()\n");
3805  size_t size_ptype=TSGDataType::sizeof_ptype(ptype);
3806 
3807  /* Heiko Strathmann: While I know that copying the stypes string and sparse
3808  * element wise is slower than doing the full things, it is way easier to
3809  * program and to debug since I already made sure that copy_ptype works as
3810  * intended. In addition, strings and vectors of SGObjects can be treated
3811  * recursively this way (we dont have cases for this currently, June 2013,
3812  * but they can be added without having to modify this code)
3813  *
3814  * Therefore, this code is very close to the the equals code for
3815  * stypes. If it turns out to be too slow (which I doubt), stypes can be
3816  * copied with memcpy over the full memory blocks */
3817 
3818  switch (stype)
3819  {
3820  case ST_NONE:
3821  {
3822  SG_SDEBUG("ST_NONE\n");
3823  return TParameter::copy_ptype(ptype, source, target);
3824  break;
3825  }
3826  case ST_STRING:
3827  {
3828  SG_SDEBUG("ST_STRING\n");
3829  SGString<char>* source_ptr = (SGString<char>*) source;
3830  SGString<char>* target_ptr = (SGString<char>*) target;
3831 
3832  if (source_ptr->slen != target_ptr->slen)
3833  {
3834  SG_SDEBUG("string lengths different (source: %d vs target: %d),"
3835  " freeing memory.\n", source_ptr->slen, target_ptr->slen);
3836 
3837  /* if string have different lengths, free data and make equal */
3838  SG_FREE(target_ptr->string);
3839  target_ptr->string=NULL;
3840  target_ptr->slen=0;
3841  }
3842 
3843  if (!target_ptr->string)
3844  {
3845  /* allocate memory if data is NULL */
3846  size_t num_bytes=source_ptr->slen * size_ptype;
3847 
3848  SG_SDEBUG("target string data NULL, allocating %d bytes.\n",
3849  num_bytes);
3850  target_ptr->string=SG_MALLOC(char, num_bytes);
3851  target_ptr->slen=source_ptr->slen;
3852  }
3853 
3854  SG_SDEBUG("Copying strings\n");
3855  for (index_t i=0; i<source_ptr->slen; ++i)
3856  {
3857  SG_SDEBUG("Copying string element %d at offset %d\n", i,
3858  i*size_ptype);
3859  void* pointer1=source_ptr->string+i*size_ptype;
3860  void* pointer2=target_ptr->string+i*size_ptype;
3861 
3862  if (!TParameter::copy_ptype(ptype, pointer1, pointer2))
3863  {
3864  SG_SDEBUG("leaving TParameter::copy_stype(): Copy of string"
3865  " element failed.\n");
3866  return false;
3867  }
3868  }
3869  break;
3870  }
3871  case ST_SPARSE:
3872  {
3873  SG_SDEBUG("ST_SPARSE\n");
3874  SGSparseVector<char>* source_ptr = (SGSparseVector<char>*) source;
3875  SGSparseVector<char>* target_ptr = (SGSparseVector<char>*) target;
3876 
3877  if (source_ptr->num_feat_entries != target_ptr->num_feat_entries)
3878  {
3879  SG_SDEBUG("sparse vector lengths different (source: %d vs target: %d),"
3880  " freeing memory.\n",
3881  source_ptr->num_feat_entries, target_ptr->num_feat_entries);
3882 
3883  /* if string have different lengths, free data and make equal */
3884  SG_FREE(target_ptr->features);
3885  target_ptr->features=NULL;
3886  target_ptr->num_feat_entries=0;
3887  }
3888 
3889  if (!target_ptr->features)
3890  {
3891  /* allocate memory if data is NULL */
3892  size_t num_bytes=source_ptr->num_feat_entries *
3894 
3895  SG_SDEBUG("target sparse data NULL, allocating %d bytes.\n",
3896  num_bytes);
3897  target_ptr->features=(SGSparseVectorEntry<char>*)SG_MALLOC(char, num_bytes);
3898  target_ptr->num_feat_entries=source_ptr->num_feat_entries;
3899  }
3900 
3901  SG_SDEBUG("Copying sparse vectors\n");
3902  for (index_t i=0; i<source_ptr->num_feat_entries; ++i)
3903  {
3904  SG_SDEBUG("Copying sparse entry %d at offset %d\n", i,
3906 
3908  ((char*) source_ptr->features + i*TSGDataType
3909  ::sizeof_sparseentry(ptype));
3911  ((char*) target_ptr->features + i*TSGDataType
3912  ::sizeof_sparseentry(ptype));
3913 
3914  /* sparse entries have an offset of the enty pointer depending
3915  * on type. Since I cast everything down to char, I need to remove
3916  * the char offset and add the offset of the ptype */
3917  index_t char_offset=TSGDataType::offset_sparseentry(PT_CHAR);
3918  index_t ptype_offset=TSGDataType::offset_sparseentry(ptype);
3919  void* pointer1=&(cur1->entry)-char_offset+ptype_offset;
3920  void* pointer2=&(cur2->entry)-char_offset+ptype_offset;
3921 
3922  if (!TParameter::copy_ptype(ptype, pointer1, pointer2))
3923  {
3924  SG_SDEBUG("leaving TParameter::copy_stype(): Copy of sparse"
3925  " vector element failed\n");
3926  return false;
3927  }
3928 
3929  /* afterwards, copy feature indices, wich are the data before
3930  * the avove offeet */
3931  cur2->feat_index=cur1->feat_index;
3932  }
3933  break;
3934  }
3935  default:
3936  {
3937  SG_SERROR("TParameter::copy_stype(): Undefined struct type\n");
3938  return false;
3939  break;
3940  }
3941  }
3942 
3943  SG_SDEBUG("leaving TParameter::copy_stype(): Copy successful\n");
3944  return true;
3945 }
3946 
3948 {
3949  SG_SDEBUG("entering TParameter::copy()\n");
3950 
3951  if (!target)
3952  {
3953  SG_SDEBUG("leaving TParameter::copy(): other parameter is NULL\n");
3954  return false;
3955  }
3956 
3957  if (!m_parameter)
3958  {
3959  SG_SDEBUG("leaving TParameter::copy(): m_parameter of source is NULL\n");
3960  return false;
3961  }
3962 
3963  if (!target->m_parameter)
3964  {
3965  SG_SDEBUG("leaving TParameter::copy(): m_parameter of target is NULL\n");
3966  return false;
3967  }
3968 
3969  if (strcmp(m_name, target->m_name))
3970  {
3971  SG_SDEBUG("leaving TParameter::copy(): name \"%s\" is different from"
3972  " target parameter's "
3973  "name \"%s\"\n", m_name, target->m_name);
3974  return false;
3975  }
3976 
3977  SG_SDEBUG("Comparing datatypes without length\n");
3979  {
3980  SG_SDEBUG("leaving TParameter::copy(): type of \"%s\" is different "
3981  "from target parameter's \"%s\" type\n", m_name, target->m_name);
3982  return false;
3983  }
3984 
3985  switch (m_datatype.m_ctype)
3986  {
3987  case CT_SCALAR:
3988  {
3989  SG_SDEBUG("CT_SCALAR\n");
3992  target->m_parameter))
3993  {
3994  SG_SDEBUG("leaving TParameter::copy(): scalar data copy error\n");
3995  return false;
3996  }
3997  break;
3998  }
3999  case CT_VECTOR: case CT_SGVECTOR:
4000  {
4001  SG_SDEBUG("CT_VECTOR or CT_SGVECTOR\n");
4002 
4003  /* if sizes are different or memory is not allocated, do that */
4004  if (!m_datatype.equals(target->m_datatype))
4005  {
4006  SG_SDEBUG("changing size of target vector and freeing memory\n");
4007  /* first case: different sizes, free target memory */
4008  SG_FREE(*(char**)target->m_parameter);
4009  *(char**)target->m_parameter=NULL;
4010 
4011  }
4012 
4013  /* check whether target m_parameter data contains NULL, if yes
4014  * create if the length is non-zero */
4015  if (*(char**)target->m_parameter==NULL && *m_datatype.m_length_y>0)
4016  {
4017  size_t num_bytes=*m_datatype.m_length_y * m_datatype.sizeof_stype();
4018  SG_SDEBUG("allocating %d bytes memory for target vector\n", num_bytes);
4019  *(char**)target->m_parameter=SG_MALLOC(char, num_bytes);
4020 
4021  /* use length of source */
4023  }
4024 
4025  /* now start actual copying, assume that sizes are equal and memory
4026  * is there */
4027  ASSERT(m_datatype.equals(target->m_datatype));
4028 
4029  /* x is number of processed bytes */
4030  index_t x=0;
4031  SG_SDEBUG("length_y: %d\n", *m_datatype.m_length_y)
4032  for (index_t i=0; i<*m_datatype.m_length_y; ++i)
4033  {
4034  SG_SDEBUG("copying element %d which is %d byes from start\n",
4035  i, x);
4036 
4037  void* pointer_a=&((*(char**)m_parameter)[x]);
4038  void* pointer_b=&((*(char**)target->m_parameter)[x]);
4039 
4041  m_datatype.m_ptype, pointer_a, pointer_b))
4042  {
4043  SG_SDEBUG("leaving TParameter::copy(): vector element "
4044  "copy error\n");
4045  return false;
4046  }
4047 
4048  x=x+(m_datatype.sizeof_ptype());
4049  }
4050 
4051  break;
4052  }
4053  case CT_MATRIX: case CT_SGMATRIX:
4054  {
4055  SG_SDEBUG("CT_MATRIX or CT_SGMATRIX\n");
4056 
4057  /* if sizes are different or memory is not allocated, do that */
4058  if (!m_datatype.equals(target->m_datatype))
4059  {
4060  SG_SDEBUG("changing size of target vector and freeing memory\n");
4061  /* first case: different sizes, free target memory */
4062  SG_FREE(*(char**)target->m_parameter);
4063  *(char**)target->m_parameter=NULL;
4064  }
4065 
4066  /* check whether target m_parameter data contains NULL, if yes, create */
4067  if (*(char**)target->m_parameter==NULL)
4068  {
4069  SG_SDEBUG("allocating memory for target vector\n");
4070  size_t num_bytes=0;
4071  /* for ST_SPARSE allocate only for a vector of m_length_y */
4072  if (m_datatype.m_stype==ST_SPARSE)
4074  else
4075  num_bytes=*m_datatype.m_length_y *
4077  *(char**)target->m_parameter=SG_MALLOC(char, num_bytes);
4078 
4079  /* use length of source */
4082 
4083  SG_SDEBUG("%d bytes are allocated\n", num_bytes);
4084  }
4085 
4086  /* now start actual copying, assume that sizes are equal and memory
4087  * is there */
4088  ASSERT(m_datatype.equals(target->m_datatype));
4089 
4090  /* x is number of processed bytes */
4091  index_t x=0;
4092  SG_SDEBUG("length_y: %d\n", *m_datatype.m_length_y)
4093  SG_SDEBUG("length_x: %d\n", *m_datatype.m_length_x)
4094  int64_t length=0;
4095  /* for ST_SPARSE allocate iterate over a vector of m_length_y */
4096  if (m_datatype.m_stype==ST_SPARSE)
4097  length=(*m_datatype.m_length_y);
4098  else
4099  length=(*m_datatype.m_length_y) * (*m_datatype.m_length_x);
4100  for (index_t i=0; i<length; ++i)
4101  {
4102  SG_SDEBUG("copying element %d which is %d byes from start\n",
4103  i, x);
4104 
4105  void* pointer_a=&((*(char**)m_parameter)[x]);
4106  void* pointer_b=&((*(char**)target->m_parameter)[x]);
4107 
4109  m_datatype.m_ptype, pointer_a, pointer_b))
4110  {
4111  SG_SDEBUG("leaving TParameter::copy(): vector element "
4112  "differs\n");
4113  return false;
4114  }
4115 
4116  /* For ST_SPARSE, the iteration is on the pointer of SGSparseVectors */
4117  if (m_datatype.m_stype==ST_SPARSE)
4118  x=x+(m_datatype.sizeof_stype());
4119  else
4120  x=x+(m_datatype.sizeof_ptype());
4121  }
4122 
4123  break;
4124  }
4125  case CT_NDARRAY:
4126  {
4127  SG_SDEBUG("CT_NDARRAY\n");
4128  SG_SERROR("TParameter::copy(): Not yet implemented for "
4129  "CT_NDARRAY!\n");
4130  break;
4131  }
4132  case CT_UNDEFINED: default:
4133  SG_SERROR("Implementation error: undefined container type\n");
4134  break;
4135  }
4136 
4137  SG_SDEBUG("leaving TParameter::copy(): Copy successful\n");
4138  return true;
4139 }
template class SGSparseMatrix
std::complex< float64_t > complex128_t
Definition: common.h:65
EStructType m_stype
Definition: DataType.h:72
int32_t index_t
Definition: common.h:60
virtual int32_t get_num_parameters()
Definition: Parameter.h:244
virtual CSGObject * clone()
Definition: SGObject.cpp:1273
static size_t offset_sparseentry(EPrimitiveType ptype)
Definition: DataType.cpp:307
#define SG_SWARNING(...)
Definition: SGIO.h:180
#define SG_UNREF(x)
Definition: SGRefObject.h:35
bool operator==(const TParameter &other) const
Definition: Parameter.cpp:2970
TParameter * get_parameter(int32_t idx)
Definition: Parameter.h:277
index_t * m_length_x
Definition: DataType.h:79
parameter struct
Definition: Parameter.h:26
SGSparseVector< T > * sparse_matrix
array of sparse vectors of size num_vectors
static bool compare_stype(EStructType stype, EPrimitiveType ptype, void *data1, void *data2, floatmax_t accuracy=0.0)
Definition: Parameter.cpp:3673
size_t sizeof_ptype() const
Definition: DataType.cpp:182
int64_t get_num_elements()
Definition: DataType.cpp:463
virtual void print(const char *prefix="")
Definition: Parameter.cpp:2787
#define SG_SNOTIMPLEMENTED
Definition: SGIO.h:200
static void ptype_to_string(char *dest, EPrimitiveType ptype, size_t n)
Definition: DataType.cpp:364
index_t num_vectors
total number of vectors
static bool compare_ptype(EPrimitiveType ptype, void *data1, void *data2, floatmax_t accuracy=0.0)
Definition: Parameter.cpp:3279
Datatypes that shogun supports.
Definition: DataType.h:67
bool operator<(const TParameter &other) const
Definition: Parameter.cpp:2977
template class SGSparseVector The assumtion is that the stored SGSparseVectorEntry* vector is orde...
shogun string
bool equals_without_length(TSGDataType other)
Definition: DataType.cpp:66
virtual void add_type(const TSGDataType *type, void *param, const char *name, const char *description)
Definition: Parameter.cpp:2760
bool save(CSerializableFile *file, const char *prefix="")
Definition: Parameter.cpp:2540
TParameter(const TSGDataType *datatype, void *parameter, const char *name, const char *description)
Definition: Parameter.cpp:1772
void add(bool *param, const char *name, const char *description="")
Definition: Parameter.cpp:27
TSGDataType m_datatype
Definition: Parameter.h:156
#define SG_SPRINT(...)
Definition: SGIO.h:182
DynArray< TParameter * > m_params
Definition: Parameter.h:2063
Parameter class.
Definition: Parameter.h:216
#define ASSERT(x)
Definition: SGIO.h:203
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:102
SGIO * sg_io
Definition: init.cpp:26
index_t slen
Definition: SGString.h:79
virtual bool equals(CSGObject *other, float64_t accuracy=0.0)
Definition: SGObject.cpp:1177
double float64_t
Definition: common.h:48
bool m_was_allocated_from_scratch
Definition: Parameter.h:175
static T product(T *vec, int32_t len)
return the product of the vectors elements
Definition: SGVector.h:522
long double floatmax_t
Definition: common.h:49
#define STRING_LEN
Definition: common.h:53
virtual bool save(CSerializableFile *file, const char *prefix="")
Definition: Parameter.cpp:2794
#define SG_REF(x)
Definition: SGRefObject.h:34
index_t num_features
total number of features
index_t num_rows
Definition: SGMatrix.h:301
size_t sizeof_stype() const
Definition: DataType.cpp:176
CSGObject * new_sgserializable(const char *sgserializable_name, EPrimitiveType generic)
index_t num_cols
Definition: SGMatrix.h:303
void print(const char *prefix)
Definition: Parameter.cpp:1835
static bool copy_ptype(EPrimitiveType ptype, void *source, void *target)
Definition: Parameter.cpp:3529
void get_incremental_hash(uint32_t &hash, uint32_t &carry, uint32_t &total_length)
Definition: Parameter.cpp:2450
index_t * m_length_y
Definition: DataType.h:77
void set_from_parameters(Parameter *params)
Definition: Parameter.cpp:2815
float float32_t
Definition: common.h:47
void to_string(char *dest, size_t n) const
Definition: DataType.cpp:144
shogun matrix
Definition: DenseFeatures.h:27
EContainerType m_ctype
Definition: DataType.h:70
bool contains_parameter(const char *name)
Definition: Parameter.cpp:2959
void add_vector(bool **param, index_t *length, const char *name, const char *description="")
Definition: Parameter.cpp:324
virtual ~Parameter()
Definition: Parameter.cpp:2751
static void IncrementalMurmurHash3(uint32_t *hash, uint32_t *carry, uint8_t *data, int32_t len)
Definition: Hash.cpp:370
bool load(CSerializableFile *file, const char *prefix="")
Definition: Parameter.cpp:2639
#define SG_SDEBUG(...)
Definition: SGIO.h:170
bool equals(TParameter *other, float64_t accuracy=0.0)
Definition: Parameter.cpp:3136
template class SGSparseVectorEntry
Definition: File.h:23
#define PT_NOT_GENERIC
Definition: DataType.h:20
#define SG_SERROR(...)
Definition: SGIO.h:181
void add_parameters(Parameter *params)
Definition: Parameter.cpp:2949
#define SG_SINFO(...)
Definition: SGIO.h:175
bool copy(TParameter *target)
Definition: Parameter.cpp:3947
bool equals(TSGDataType other)
Definition: DataType.cpp:94
void copy_data(const TParameter *source)
Definition: Parameter.cpp:3076
char * m_description
Definition: Parameter.h:162
char string_t[STRING_LEN]
Definition: common.h:55
EPrimitiveType m_ptype
Definition: DataType.h:74
void add_matrix(bool **param, index_t *length_y, index_t *length_x, const char *name, const char *description="")
Definition: Parameter.cpp:933
static size_t sizeof_sparseentry(EPrimitiveType ptype)
Definition: DataType.cpp:278
void allocate_data_from_scratch(SGVector< index_t > dims, bool new_cont_call=true)
Definition: Parameter.cpp:2987
index_t vlen
Definition: SGVector.h:706
static T abs(T a)
return the absolute value of a number
Definition: Math.h:179
static bool copy_stype(EStructType stype, EPrimitiveType ptype, void *source, void *target)
Definition: Parameter.cpp:3801
bool operator>(const TParameter &other) const
Definition: Parameter.cpp:2982
SGSparseVectorEntry< T > * features

SHOGUN Machine Learning Toolbox - Documentation