Parameter.cpp

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2010 Soeren Sonnenburg
00008  * Written (W) 2011 Heiko Strathmann
00009  * Copyright (C) 2010 Berlin Institute of Technology
00010  */
00011 
00012 #include <shogun/base/Parameter.h>
00013 #include <shogun/base/class_list.h>
00014 
00015 using namespace shogun;
00016 
00017 extern IO* sg_io;
00018 
00019 /* **************************************************************** */
00020 /* Scalar wrappers  */
00021 
00022 void
00023 Parameter::add(bool* param, const char* name,
00024                const char* description) {
00025     TSGDataType type(CT_SCALAR, ST_NONE, PT_BOOL);
00026     add_type(&type, param, name, description);
00027 }
00028 
00029 void
00030 Parameter::add(char* param, const char* name,
00031                const char* description) {
00032     TSGDataType type(CT_SCALAR, ST_NONE, PT_CHAR);
00033     add_type(&type, param, name, description);
00034 }
00035 
00036 void
00037 Parameter::add(int8_t* param, const char* name,
00038                const char* description) {
00039     TSGDataType type(CT_SCALAR, ST_NONE, PT_INT8);
00040     add_type(&type, param, name, description);
00041 }
00042 
00043 void
00044 Parameter::add(uint8_t* param, const char* name,
00045                const char* description) {
00046     TSGDataType type(CT_SCALAR, ST_NONE, PT_UINT8);
00047     add_type(&type, param, name, description);
00048 }
00049 
00050 void
00051 Parameter::add(int16_t* param, const char* name,
00052                const char* description) {
00053     TSGDataType type(CT_SCALAR, ST_NONE, PT_INT16);
00054     add_type(&type, param, name, description);
00055 }
00056 
00057 void
00058 Parameter::add(uint16_t* param, const char* name,
00059                const char* description) {
00060     TSGDataType type(CT_SCALAR, ST_NONE, PT_UINT16);
00061     add_type(&type, param, name, description);
00062 }
00063 
00064 void
00065 Parameter::add(int32_t* param, const char* name,
00066                const char* description) {
00067     TSGDataType type(CT_SCALAR, ST_NONE, PT_INT32);
00068     add_type(&type, param, name, description);
00069 }
00070 
00071 void
00072 Parameter::add(uint32_t* param, const char* name,
00073                const char* description) {
00074     TSGDataType type(CT_SCALAR, ST_NONE, PT_UINT32);
00075     add_type(&type, param, name, description);
00076 }
00077 
00078 void
00079 Parameter::add(int64_t* param, const char* name,
00080                const char* description) {
00081     TSGDataType type(CT_SCALAR, ST_NONE, PT_INT64);
00082     add_type(&type, param, name, description);
00083 }
00084 
00085 void
00086 Parameter::add(uint64_t* param, const char* name,
00087                const char* description) {
00088     TSGDataType type(CT_SCALAR, ST_NONE, PT_UINT64);
00089     add_type(&type, param, name, description);
00090 }
00091 
00092 void
00093 Parameter::add(float32_t* param, const char* name,
00094                const char* description) {
00095     TSGDataType type(CT_SCALAR, ST_NONE, PT_FLOAT32);
00096     add_type(&type, param, name, description);
00097 }
00098 
00099 void
00100 Parameter::add(float64_t* param, const char* name,
00101                const char* description) {
00102     TSGDataType type(CT_SCALAR, ST_NONE, PT_FLOAT64);
00103     add_type(&type, param, name, description);
00104 }
00105 
00106 void
00107 Parameter::add(floatmax_t* param, const char* name,
00108                const char* description) {
00109     TSGDataType type(CT_SCALAR, ST_NONE, PT_FLOATMAX);
00110     add_type(&type, param, name, description);
00111 }
00112 
00113 void
00114 Parameter::add(CSGObject** param,
00115                const char* name, const char* description) {
00116     TSGDataType type(CT_SCALAR, ST_NONE, PT_SGOBJECT);
00117     add_type(&type, param, name, description);
00118 }
00119 
00120 void
00121 Parameter::add(SGString<bool>* param, const char* name,
00122                const char* description) {
00123     TSGDataType type(CT_SCALAR, ST_STRING, PT_BOOL);
00124     add_type(&type, param, name, description);
00125 }
00126 
00127 void
00128 Parameter::add(SGString<char>* param, const char* name,
00129                const char* description) {
00130     TSGDataType type(CT_SCALAR, ST_STRING, PT_CHAR);
00131     add_type(&type, param, name, description);
00132 }
00133 
00134 void
00135 Parameter::add(SGString<int8_t>* param, const char* name,
00136                const char* description) {
00137     TSGDataType type(CT_SCALAR, ST_STRING, PT_INT8);
00138     add_type(&type, param, name, description);
00139 }
00140 
00141 void
00142 Parameter::add(SGString<uint8_t>* param, const char* name,
00143                const char* description) {
00144     TSGDataType type(CT_SCALAR, ST_STRING, PT_UINT8);
00145     add_type(&type, param, name, description);
00146 }
00147 
00148 void
00149 Parameter::add(SGString<int16_t>* param, const char* name,
00150                const char* description) {
00151     TSGDataType type(CT_SCALAR, ST_STRING, PT_INT16);
00152     add_type(&type, param, name, description);
00153 }
00154 
00155 void
00156 Parameter::add(SGString<uint16_t>* param, const char* name,
00157                const char* description) {
00158     TSGDataType type(CT_SCALAR, ST_STRING, PT_UINT16);
00159     add_type(&type, param, name, description);
00160 }
00161 
00162 void
00163 Parameter::add(SGString<int32_t>* param, const char* name,
00164                const char* description) {
00165     TSGDataType type(CT_SCALAR, ST_STRING, PT_INT32);
00166     add_type(&type, param, name, description);
00167 }
00168 
00169 void
00170 Parameter::add(SGString<uint32_t>* param, const char* name,
00171                const char* description) {
00172     TSGDataType type(CT_SCALAR, ST_STRING, PT_UINT32);
00173     add_type(&type, param, name, description);
00174 }
00175 
00176 void
00177 Parameter::add(SGString<int64_t>* param, const char* name,
00178                const char* description) {
00179     TSGDataType type(CT_SCALAR, ST_STRING, PT_INT64);
00180     add_type(&type, param, name, description);
00181 }
00182 
00183 void
00184 Parameter::add(SGString<uint64_t>* param, const char* name,
00185                const char* description) {
00186     TSGDataType type(CT_SCALAR, ST_STRING, PT_UINT64);
00187     add_type(&type, param, name, description);
00188 }
00189 
00190 void
00191 Parameter::add(SGString<float32_t>* param, const char* name,
00192                const char* description) {
00193     TSGDataType type(CT_SCALAR, ST_STRING, PT_FLOAT32);
00194     add_type(&type, param, name, description);
00195 }
00196 
00197 void
00198 Parameter::add(SGString<float64_t>* param, const char* name,
00199                const char* description) {
00200     TSGDataType type(CT_SCALAR, ST_STRING, PT_FLOAT64);
00201     add_type(&type, param, name, description);
00202 }
00203 
00204 void
00205 Parameter::add(SGString<floatmax_t>* param, const char* name,
00206                const char* description) {
00207     TSGDataType type(CT_SCALAR, ST_STRING, PT_FLOATMAX);
00208     add_type(&type, param, name, description);
00209 }
00210 
00211 void
00212 Parameter::add(SGSparseVector<bool>* param, const char* name,
00213                const char* description) {
00214     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_BOOL);
00215     add_type(&type, param, name, description);
00216 }
00217 
00218 void
00219 Parameter::add(SGSparseVector<char>* param, const char* name,
00220                const char* description) {
00221     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_CHAR);
00222     add_type(&type, param, name, description);
00223 }
00224 
00225 void
00226 Parameter::add(SGSparseVector<int8_t>* param, const char* name,
00227                const char* description) {
00228     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_INT8);
00229     add_type(&type, param, name, description);
00230 }
00231 
00232 void
00233 Parameter::add(SGSparseVector<uint8_t>* param, const char* name,
00234                const char* description) {
00235     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_UINT8);
00236     add_type(&type, param, name, description);
00237 }
00238 
00239 void
00240 Parameter::add(SGSparseVector<int16_t>* param, const char* name,
00241                const char* description) {
00242     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_INT16);
00243     add_type(&type, param, name, description);
00244 }
00245 
00246 void
00247 Parameter::add(SGSparseVector<uint16_t>* param, const char* name,
00248                const char* description) {
00249     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_UINT16);
00250     add_type(&type, param, name, description);
00251 }
00252 
00253 void
00254 Parameter::add(SGSparseVector<int32_t>* param, const char* name,
00255                const char* description) {
00256     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_INT32);
00257     add_type(&type, param, name, description);
00258 }
00259 
00260 void
00261 Parameter::add(SGSparseVector<uint32_t>* param, const char* name,
00262                const char* description) {
00263     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_UINT32);
00264     add_type(&type, param, name, description);
00265 }
00266 
00267 void
00268 Parameter::add(SGSparseVector<int64_t>* param, const char* name,
00269                const char* description) {
00270     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_INT64);
00271     add_type(&type, param, name, description);
00272 }
00273 
00274 void
00275 Parameter::add(SGSparseVector<uint64_t>* param, const char* name,
00276                const char* description) {
00277     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_UINT64);
00278     add_type(&type, param, name, description);
00279 }
00280 
00281 void
00282 Parameter::add(SGSparseVector<float32_t>* param, const char* name,
00283                const char* description) {
00284     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_FLOAT32);
00285     add_type(&type, param, name, description);
00286 }
00287 
00288 void
00289 Parameter::add(SGSparseVector<float64_t>* param, const char* name,
00290                const char* description) {
00291     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_FLOAT64);
00292     add_type(&type, param, name, description);
00293 }
00294 
00295 void
00296 Parameter::add(SGSparseVector<floatmax_t>* param, const char* name,
00297                const char* description) {
00298     TSGDataType type(CT_SCALAR, ST_SPARSE, PT_FLOATMAX);
00299     add_type(&type, param, name, description);
00300 }
00301 
00302 /* **************************************************************** */
00303 /* Vector wrappers  */
00304 
00305 void
00306 Parameter::add_vector(
00307     bool** param, index_t* length, const char* name,
00308     const char* description) {
00309     TSGDataType type(CT_VECTOR, ST_NONE, PT_BOOL, length);
00310     add_type(&type, param, name, description);
00311 }
00312 
00313 void
00314 Parameter::add_vector(
00315     char** param, index_t* length, const char* name,
00316     const char* description) {
00317     TSGDataType type(CT_VECTOR, ST_NONE, PT_CHAR, length);
00318     add_type(&type, param, name, description);
00319 }
00320 
00321 void
00322 Parameter::add_vector(
00323     int8_t** param, index_t* length, const char* name,
00324     const char* description) {
00325     TSGDataType type(CT_VECTOR, ST_NONE, PT_INT8, length);
00326     add_type(&type, param, name, description);
00327 }
00328 
00329 void
00330 Parameter::add_vector(
00331     uint8_t** param, index_t* length, const char* name,
00332     const char* description) {
00333     TSGDataType type(CT_VECTOR, ST_NONE, PT_UINT8, length);
00334     add_type(&type, param, name, description);
00335 }
00336 
00337 void
00338 Parameter::add_vector(
00339     int16_t** param, index_t* length, const char* name,
00340     const char* description) {
00341     TSGDataType type(CT_VECTOR, ST_NONE, PT_INT16, length);
00342     add_type(&type, param, name, description);
00343 }
00344 
00345 void
00346 Parameter::add_vector(
00347     uint16_t** param, index_t* length, const char* name,
00348     const char* description) {
00349     TSGDataType type(CT_VECTOR, ST_NONE, PT_UINT16, length);
00350     add_type(&type, param, name, description);
00351 }
00352 
00353 void
00354 Parameter::add_vector(
00355     int32_t** param, index_t* length, const char* name,
00356     const char* description) {
00357     TSGDataType type(CT_VECTOR, ST_NONE, PT_INT32, length);
00358     add_type(&type, param, name, description);
00359 }
00360 
00361 void
00362 Parameter::add_vector(
00363     uint32_t** param, index_t* length, const char* name,
00364     const char* description) {
00365     TSGDataType type(CT_VECTOR, ST_NONE, PT_UINT32, length);
00366     add_type(&type, param, name, description);
00367 }
00368 
00369 void
00370 Parameter::add_vector(
00371     int64_t** param, index_t* length, const char* name,
00372     const char* description) {
00373     TSGDataType type(CT_VECTOR, ST_NONE, PT_INT64, length);
00374     add_type(&type, param, name, description);
00375 }
00376 
00377 void
00378 Parameter::add_vector(
00379     uint64_t** param, index_t* length, const char* name,
00380     const char* description) {
00381     TSGDataType type(CT_VECTOR, ST_NONE, PT_UINT64, length);
00382     add_type(&type, param, name, description);
00383 }
00384 
00385 void
00386 Parameter::add_vector(
00387     float32_t** param, index_t* length, const char* name,
00388     const char* description) {
00389     TSGDataType type(CT_VECTOR, ST_NONE, PT_FLOAT32, length);
00390     add_type(&type, param, name, description);
00391 }
00392 
00393 void
00394 Parameter::add_vector(
00395     float64_t** param, index_t* length, const char* name,
00396     const char* description) {
00397     TSGDataType type(CT_VECTOR, ST_NONE, PT_FLOAT64, length);
00398     add_type(&type, param, name, description);
00399 }
00400 
00401 void
00402 Parameter::add_vector(
00403     floatmax_t** param, index_t* length, const char* name,
00404     const char* description) {
00405     TSGDataType type(CT_VECTOR, ST_NONE, PT_FLOATMAX, length);
00406     add_type(&type, param, name, description);
00407 }
00408 
00409 void
00410 Parameter::add_vector(CSGObject*** param, index_t* length,
00411                        const char* name, const char* description) {
00412     TSGDataType type(CT_VECTOR, ST_NONE, PT_SGOBJECT,
00413                      length);
00414     add_type(&type, param, name, description);
00415 }
00416 
00417 void
00418 Parameter::add_vector(SGString<bool>** param, index_t* length,
00419                       const char* name, const char* description) {
00420     TSGDataType type(CT_VECTOR, ST_STRING, PT_BOOL, length);
00421     add_type(&type, param, name, description);
00422 }
00423 
00424 void
00425 Parameter::add_vector(SGString<char>** param, index_t* length,
00426                       const char* name, const char* description) {
00427     TSGDataType type(CT_VECTOR, ST_STRING, PT_CHAR, length);
00428     add_type(&type, param, name, description);
00429 }
00430 
00431 void
00432 Parameter::add_vector(SGString<int8_t>** param, index_t* length,
00433                       const char* name, const char* description) {
00434     TSGDataType type(CT_VECTOR, ST_STRING, PT_INT8, length);
00435     add_type(&type, param, name, description);
00436 }
00437 
00438 void
00439 Parameter::add_vector(SGString<uint8_t>** param, index_t* length,
00440                       const char* name, const char* description) {
00441     TSGDataType type(CT_VECTOR, ST_STRING, PT_UINT8, length);
00442     add_type(&type, param, name, description);
00443 }
00444 
00445 void
00446 Parameter::add_vector(SGString<int16_t>** param, index_t* length,
00447                       const char* name, const char* description) {
00448     TSGDataType type(CT_VECTOR, ST_STRING, PT_INT16, length);
00449     add_type(&type, param, name, description);
00450 }
00451 
00452 void
00453 Parameter::add_vector(SGString<uint16_t>** param, index_t* length,
00454                       const char* name, const char* description) {
00455     TSGDataType type(CT_VECTOR, ST_STRING, PT_UINT16, length);
00456     add_type(&type, param, name, description);
00457 }
00458 
00459 void
00460 Parameter::add_vector(SGString<int32_t>** param, index_t* length,
00461                       const char* name, const char* description) {
00462     TSGDataType type(CT_VECTOR, ST_STRING, PT_INT32, length);
00463     add_type(&type, param, name, description);
00464 }
00465 
00466 void
00467 Parameter::add_vector(SGString<uint32_t>** param, index_t* length,
00468                       const char* name, const char* description) {
00469     TSGDataType type(CT_VECTOR, ST_STRING, PT_UINT32, length);
00470     add_type(&type, param, name, description);
00471 }
00472 
00473 void
00474 Parameter::add_vector(SGString<int64_t>** param, index_t* length,
00475                       const char* name, const char* description) {
00476     TSGDataType type(CT_VECTOR, ST_STRING, PT_INT64, length);
00477     add_type(&type, param, name, description);
00478 }
00479 
00480 void
00481 Parameter::add_vector(SGString<uint64_t>** param, index_t* length,
00482                       const char* name, const char* description) {
00483     TSGDataType type(CT_VECTOR, ST_STRING, PT_UINT64, length);
00484     add_type(&type, param, name, description);
00485 }
00486 
00487 void
00488 Parameter::add_vector(SGString<float32_t>** param, index_t* length,
00489                       const char* name, const char* description) {
00490     TSGDataType type(CT_VECTOR, ST_STRING, PT_FLOAT32, length);
00491     add_type(&type, param, name, description);
00492 }
00493 
00494 void
00495 Parameter::add_vector(SGString<float64_t>** param, index_t* length,
00496                       const char* name, const char* description) {
00497     TSGDataType type(CT_VECTOR, ST_STRING, PT_FLOAT64, length);
00498     add_type(&type, param, name, description);
00499 }
00500 
00501 void
00502 Parameter::add_vector(SGString<floatmax_t>** param, index_t* length,
00503                       const char* name, const char* description) {
00504     TSGDataType type(CT_VECTOR, ST_STRING, PT_FLOATMAX, length);
00505     add_type(&type, param, name, description);
00506 }
00507 
00508 void
00509 Parameter::add_vector(SGSparseVector<bool>** param, index_t* length,
00510                       const char* name, const char* description) {
00511     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_BOOL, length);
00512     add_type(&type, param, name, description);
00513 }
00514 
00515 void
00516 Parameter::add_vector(SGSparseVector<char>** param, index_t* length,
00517                       const char* name, const char* description) {
00518     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_CHAR, length);
00519     add_type(&type, param, name, description);
00520 }
00521 
00522 void
00523 Parameter::add_vector(SGSparseVector<int8_t>** param, index_t* length,
00524                       const char* name, const char* description) {
00525     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_INT8, length);
00526     add_type(&type, param, name, description);
00527 }
00528 
00529 void
00530 Parameter::add_vector(SGSparseVector<uint8_t>** param, index_t* length,
00531                       const char* name, const char* description) {
00532     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_UINT8, length);
00533     add_type(&type, param, name, description);
00534 }
00535 
00536 void
00537 Parameter::add_vector(SGSparseVector<int16_t>** param, index_t* length,
00538                       const char* name, const char* description) {
00539     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_INT16, length);
00540     add_type(&type, param, name, description);
00541 }
00542 
00543 void
00544 Parameter::add_vector(SGSparseVector<uint16_t>** param, index_t* length,
00545                       const char* name, const char* description) {
00546     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_UINT16, length);
00547     add_type(&type, param, name, description);
00548 }
00549 
00550 void
00551 Parameter::add_vector(SGSparseVector<int32_t>** param, index_t* length,
00552                       const char* name, const char* description) {
00553     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_INT32, length);
00554     add_type(&type, param, name, description);
00555 }
00556 
00557 void
00558 Parameter::add_vector(SGSparseVector<uint32_t>** param, index_t* length,
00559                       const char* name, const char* description) {
00560     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_UINT32, length);
00561     add_type(&type, param, name, description);
00562 }
00563 
00564 void
00565 Parameter::add_vector(SGSparseVector<int64_t>** param, index_t* length,
00566                       const char* name, const char* description) {
00567     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_INT64, length);
00568     add_type(&type, param, name, description);
00569 }
00570 
00571 void
00572 Parameter::add_vector(SGSparseVector<uint64_t>** param, index_t* length,
00573                       const char* name, const char* description) {
00574     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_UINT64, length);
00575     add_type(&type, param, name, description);
00576 }
00577 
00578 void
00579 Parameter::add_vector(SGSparseVector<float32_t>** param, index_t* length,
00580                       const char* name, const char* description) {
00581     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_FLOAT32, length);
00582     add_type(&type, param, name, description);
00583 }
00584 
00585 void
00586 Parameter::add_vector(SGSparseVector<float64_t>** param, index_t* length,
00587                       const char* name, const char* description) {
00588     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_FLOAT64, length);
00589     add_type(&type, param, name, description);
00590 }
00591 
00592 void
00593 Parameter::add_vector(SGSparseVector<floatmax_t>** param, index_t* length,
00594                       const char* name, const char* description) {
00595     TSGDataType type(CT_VECTOR, ST_SPARSE, PT_FLOATMAX, length);
00596     add_type(&type, param, name, description);
00597 }
00598 
00599 
00600 
00601 
00602 void Parameter::add(SGVector<bool>* param, const char* name,
00603         const char* description)
00604 {
00605     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_BOOL, &param->vlen);
00606     add_type(&type, param, name, description);
00607 }
00608 
00609 void Parameter::add(SGVector<char>* param, const char* name,
00610         const char* description)
00611 {
00612     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_CHAR, &param->vlen);
00613     add_type(&type, param, name, description);
00614 }
00615 
00616 void Parameter::add(SGVector<int8_t>* param, const char* name,
00617         const char* description)
00618 {
00619     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_INT8, &param->vlen);
00620     add_type(&type, param, name, description);
00621 }
00622 
00623 void Parameter::add(SGVector<uint8_t>* param, const char* name,
00624         const char* description)
00625 {
00626     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_UINT8, &param->vlen);
00627     add_type(&type, param, name, description);
00628 }
00629 
00630 void Parameter::add(SGVector<int16_t>* param, const char* name,
00631         const char* description)
00632 {
00633     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_INT16, &param->vlen);
00634     add_type(&type, param, name, description);
00635 }
00636 
00637 void Parameter::add(SGVector<uint16_t>* param, const char* name,
00638         const char* description)
00639 {
00640     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_UINT16, &param->vlen);
00641     add_type(&type, param, name, description);
00642 }
00643 
00644 void Parameter::add(SGVector<int32_t>* param, const char* name,
00645         const char* description)
00646 {
00647     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_INT32, &param->vlen);
00648     add_type(&type, param, name, description);
00649 }
00650 
00651 void Parameter::add(SGVector<uint32_t>* param, const char* name,
00652         const char* description)
00653 {
00654     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_UINT32, &param->vlen);
00655     add_type(&type, param, name, description);
00656 }
00657 
00658 void Parameter::add(SGVector<int64_t>* param, const char* name,
00659         const char* description)
00660 {
00661     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_INT64, &param->vlen);
00662     add_type(&type, param, name, description);
00663 }
00664 
00665 void Parameter::add(SGVector<uint64_t>* param, const char* name,
00666         const char* description)
00667 {
00668     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_UINT64, &param->vlen);
00669     add_type(&type, param, name, description);
00670 }
00671 
00672 void Parameter::add(SGVector<float32_t>* param, const char* name,
00673         const char* description)
00674 {
00675     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_FLOAT32, &param->vlen);
00676     add_type(&type, param, name, description);
00677 }
00678 
00679 void Parameter::add(SGVector<float64_t>* param, const char* name,
00680         const char* description)
00681 {
00682     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_FLOAT64, &param->vlen);
00683     add_type(&type, param, name, description);
00684 }
00685 
00686 void Parameter::add(SGVector<floatmax_t>* param, const char* name,
00687         const char* description)
00688 {
00689     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_FLOATMAX, &param->vlen);
00690     add_type(&type, param, name, description);
00691 }
00692 
00693 void Parameter::add(SGVector<CSGObject*>* param, const char* name,
00694         const char* description)
00695 {
00696     TSGDataType type(CT_SGVECTOR, ST_NONE, PT_SGOBJECT, &param->vlen);
00697     add_type(&type, param, name, description);
00698 }
00699 
00700 void Parameter::add(SGVector<SGString<bool> >* param, const char* name,
00701         const char* description)
00702 {
00703     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_BOOL, &param->vlen);
00704     add_type(&type, param, name, description);
00705 }
00706 
00707 void Parameter::add(SGVector<SGString<char> >* param, const char* name,
00708         const char* description)
00709 {
00710     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_CHAR, &param->vlen);
00711     add_type(&type, param, name, description);
00712 }
00713 
00714 void Parameter::add(SGVector<SGString<int8_t> >* param,
00715         const char* name, const char* description)
00716 {
00717     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_INT8, &param->vlen);
00718     add_type(&type, param, name, description);
00719 }
00720 
00721 void Parameter::add(SGVector<SGString<uint8_t> >* param,
00722         const char* name, const char* description)
00723 {
00724     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_UINT8, &param->vlen);
00725     add_type(&type, param, name, description);
00726 }
00727 
00728 void Parameter::add(SGVector<SGString<int16_t> >* param,
00729         const char* name, const char* description)
00730 {
00731     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_INT16, &param->vlen);
00732     add_type(&type, param, name, description);
00733 }
00734 
00735 void Parameter::add(SGVector<SGString<uint16_t> >* param,
00736         const char* name, const char* description)
00737 {
00738     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_UINT16, &param->vlen);
00739     add_type(&type, param, name, description);
00740 }
00741 
00742 void Parameter::add(SGVector<SGString<int32_t> >* param,
00743         const char* name, const char* description)
00744 {
00745     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_INT32, &param->vlen);
00746     add_type(&type, param, name, description);
00747 }
00748 
00749 void Parameter::add(SGVector<SGString<uint32_t> >* param,
00750         const char* name, const char* description)
00751 {
00752     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_UINT32, &param->vlen);
00753     add_type(&type, param, name, description);
00754 }
00755 
00756 void Parameter::add(SGVector<SGString<int64_t> >* param,
00757         const char* name, const char* description)
00758 {
00759     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_INT64, &param->vlen);
00760     add_type(&type, param, name, description);
00761 }
00762 
00763 void Parameter::add(SGVector<SGString<uint64_t> >* param,
00764         const char* name, const char* description)
00765 {
00766     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_UINT64, &param->vlen);
00767     add_type(&type, param, name, description);
00768 }
00769 
00770 void Parameter::add(SGVector<SGString<float32_t> >* param,
00771         const char* name, const char* description)
00772 {
00773     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_FLOAT32, &param->vlen);
00774     add_type(&type, param, name, description);
00775 }
00776 
00777 void Parameter::add(SGVector<SGString<float64_t> >* param,
00778         const char* name, const char* description)
00779 {
00780     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_FLOAT64, &param->vlen);
00781     add_type(&type, param, name, description);
00782 }
00783 
00784 void Parameter::add(SGVector<SGString<floatmax_t> >* param,
00785         const char* name, const char* description)
00786 {
00787     TSGDataType type(CT_SGVECTOR, ST_STRING, PT_FLOATMAX, &param->vlen);
00788     add_type(&type, param, name, description);
00789 }
00790 
00791 void Parameter::add(SGVector<SGSparseVector<bool> >* param,
00792         const char* name, const char* description)
00793 {
00794     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_BOOL, &param->vlen);
00795     add_type(&type, param, name, description);
00796 }
00797 
00798 void Parameter::add(SGVector<SGSparseVector<char> >* param,
00799         const char* name, const char* description)
00800 {
00801     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_CHAR, &param->vlen);
00802     add_type(&type, param, name, description);
00803 }
00804 
00805 void Parameter::add(SGVector<SGSparseVector<int8_t> >* param,
00806         const char* name, const char* description)
00807 {
00808     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_INT8, &param->vlen);
00809     add_type(&type, param, name, description);
00810 }
00811 
00812 void Parameter::add(SGVector<SGSparseVector<uint8_t> >* param,
00813         const char* name, const char* description)
00814 {
00815     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_UINT8, &param->vlen);
00816     add_type(&type, param, name, description);
00817 }
00818 
00819 void Parameter::add(SGVector<SGSparseVector<int16_t> >* param,
00820         const char* name, const char* description)
00821 {
00822     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_INT16, &param->vlen);
00823     add_type(&type, param, name, description);
00824 }
00825 
00826 void Parameter::add(SGVector<SGSparseVector<uint16_t> >* param,
00827         const char* name, const char* description)
00828 {
00829     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_UINT16, &param->vlen);
00830     add_type(&type, param, name, description);
00831 }
00832 
00833 void Parameter::add(SGVector<SGSparseVector<int32_t> >* param,
00834         const char* name, const char* description)
00835 {
00836     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_INT32, &param->vlen);
00837     add_type(&type, param, name, description);
00838 }
00839 
00840 void Parameter::add(SGVector<SGSparseVector<uint32_t> >* param,
00841         const char* name, const char* description)
00842 {
00843     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_UINT32, &param->vlen);
00844     add_type(&type, param, name, description);
00845 }
00846 
00847 void Parameter::add(SGVector<SGSparseVector<int64_t> >* param,
00848         const char* name, const char* description)
00849 {
00850     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_INT64, &param->vlen);
00851     add_type(&type, param, name, description);
00852 }
00853 
00854 void Parameter::add(SGVector<SGSparseVector<uint64_t> >* param,
00855         const char* name, const char* description)
00856 {
00857     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_UINT64, &param->vlen);
00858     add_type(&type, param, name, description);
00859 }
00860 
00861 void Parameter::add(SGVector<SGSparseVector<float32_t> >* param,
00862         const char* name, const char* description)
00863 {
00864     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_FLOAT32, &param->vlen);
00865     add_type(&type, param, name, description);
00866 }
00867 
00868 void Parameter::add(SGVector<SGSparseVector<float64_t> >* param,
00869         const char* name, const char* description)
00870 {
00871     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_FLOAT64, &param->vlen);
00872     add_type(&type, param, name, description);
00873 }
00874 
00875 void Parameter::add(SGVector<SGSparseVector<floatmax_t> >* param,
00876         const char* name, const char* description)
00877 {
00878     TSGDataType type(CT_SGVECTOR, ST_SPARSE, PT_FLOATMAX, &param->vlen);
00879     add_type(&type, param, name, description);
00880 }
00881 
00882 /* **************************************************************** */
00883 /* Matrix wrappers  */
00884 
00885 void
00886 Parameter::add_matrix(
00887     bool** param, index_t* length_y, index_t* length_x,
00888     const char* name, const char* description) {
00889     TSGDataType type(CT_MATRIX, ST_NONE, PT_BOOL, length_y,
00890                      length_x);
00891     add_type(&type, param, name, description);
00892 }
00893 
00894 void
00895 Parameter::add_matrix(
00896     char** param, index_t* length_y, index_t* length_x,
00897     const char* name, const char* description) {
00898     TSGDataType type(CT_MATRIX, ST_NONE, PT_CHAR, length_y,
00899                      length_x);
00900     add_type(&type, param, name, description);
00901 }
00902 
00903 void
00904 Parameter::add_matrix(
00905     int8_t** param, index_t* length_y, index_t* length_x,
00906     const char* name, const char* description) {
00907     TSGDataType type(CT_MATRIX, ST_NONE, PT_INT8, length_y,
00908                      length_x);
00909     add_type(&type, param, name, description);
00910 }
00911 
00912 void
00913 Parameter::add_matrix(
00914     uint8_t** param, index_t* length_y, index_t* length_x,
00915     const char* name, const char* description) {
00916     TSGDataType type(CT_MATRIX, ST_NONE, PT_UINT8, length_y,
00917                      length_x);
00918     add_type(&type, param, name, description);
00919 }
00920 
00921 void
00922 Parameter::add_matrix(
00923     int16_t** param, index_t* length_y, index_t* length_x,
00924     const char* name, const char* description) {
00925     TSGDataType type(CT_MATRIX, ST_NONE, PT_INT16, length_y,
00926                      length_x);
00927     add_type(&type, param, name, description);
00928 }
00929 
00930 void
00931 Parameter::add_matrix(
00932     uint16_t** param, index_t* length_y, index_t* length_x,
00933     const char* name, const char* description) {
00934     TSGDataType type(CT_MATRIX, ST_NONE, PT_UINT16, length_y,
00935                      length_x);
00936     add_type(&type, param, name, description);
00937 }
00938 
00939 void
00940 Parameter::add_matrix(
00941     int32_t** param, index_t* length_y, index_t* length_x,
00942     const char* name, const char* description) {
00943     TSGDataType type(CT_MATRIX, ST_NONE, PT_INT32, length_y,
00944                      length_x);
00945     add_type(&type, param, name, description);
00946 }
00947 
00948 void
00949 Parameter::add_matrix(
00950     uint32_t** param, index_t* length_y, index_t* length_x,
00951     const char* name, const char* description) {
00952     TSGDataType type(CT_MATRIX, ST_NONE, PT_UINT32, length_y,
00953                      length_x);
00954     add_type(&type, param, name, description);
00955 }
00956 
00957 void
00958 Parameter::add_matrix(
00959     int64_t** param, index_t* length_y, index_t* length_x,
00960     const char* name, const char* description) {
00961     TSGDataType type(CT_MATRIX, ST_NONE, PT_INT64, length_y,
00962                      length_x);
00963     add_type(&type, param, name, description);
00964 }
00965 
00966 void
00967 Parameter::add_matrix(
00968     uint64_t** param, index_t* length_y, index_t* length_x,
00969     const char* name, const char* description) {
00970     TSGDataType type(CT_MATRIX, ST_NONE, PT_UINT64, length_y,
00971                      length_x);
00972     add_type(&type, param, name, description);
00973 }
00974 
00975 void
00976 Parameter::add_matrix(
00977     float32_t** param, index_t* length_y, index_t* length_x,
00978     const char* name, const char* description) {
00979     TSGDataType type(CT_MATRIX, ST_NONE, PT_FLOAT32, length_y,
00980                      length_x);
00981     add_type(&type, param, name, description);
00982 }
00983 
00984 void
00985 Parameter::add_matrix(
00986     float64_t** param, index_t* length_y, index_t* length_x,
00987     const char* name, const char* description) {
00988     TSGDataType type(CT_MATRIX, ST_NONE, PT_FLOAT64, length_y,
00989                      length_x);
00990     add_type(&type, param, name, description);
00991 }
00992 
00993 void
00994 Parameter::add_matrix(
00995     floatmax_t** param, index_t* length_y, index_t* length_x,
00996     const char* name, const char* description) {
00997     TSGDataType type(CT_MATRIX, ST_NONE, PT_FLOATMAX, length_y,
00998                      length_x);
00999     add_type(&type, param, name, description);
01000 }
01001 
01002 void
01003 Parameter::add_matrix(
01004     CSGObject*** param, index_t* length_y, index_t* length_x,
01005     const char* name, const char* description) {
01006     TSGDataType type(CT_MATRIX, ST_NONE, PT_SGOBJECT,
01007                      length_y, length_x);
01008     add_type(&type, param, name, description);
01009 }
01010 
01011 void
01012 Parameter::add_matrix(SGString<bool>** param,
01013                       index_t* length_y, index_t* length_x,
01014                       const char* name, const char* description) {
01015     TSGDataType type(CT_MATRIX, ST_STRING, PT_BOOL, length_y,
01016                      length_x);
01017     add_type(&type, param, name, description);
01018 }
01019 
01020 void
01021 Parameter::add_matrix(SGString<char>** param,
01022                       index_t* length_y, index_t* length_x,
01023                       const char* name, const char* description) {
01024     TSGDataType type(CT_MATRIX, ST_STRING, PT_CHAR, length_y,
01025                      length_x);
01026     add_type(&type, param, name, description);
01027 }
01028 
01029 void
01030 Parameter::add_matrix(SGString<int8_t>** param,
01031                       index_t* length_y, index_t* length_x,
01032                       const char* name, const char* description) {
01033     TSGDataType type(CT_MATRIX, ST_STRING, PT_INT8, length_y,
01034                      length_x);
01035     add_type(&type, param, name, description);
01036 }
01037 
01038 void
01039 Parameter::add_matrix(SGString<uint8_t>** param,
01040                       index_t* length_y, index_t* length_x,
01041                       const char* name, const char* description) {
01042     TSGDataType type(CT_MATRIX, ST_STRING, PT_UINT8, length_y,
01043                      length_x);
01044     add_type(&type, param, name, description);
01045 }
01046 
01047 void
01048 Parameter::add_matrix(SGString<int16_t>** param,
01049                       index_t* length_y, index_t* length_x,
01050                       const char* name, const char* description) {
01051     TSGDataType type(CT_MATRIX, ST_STRING, PT_INT16, length_y,
01052                      length_x);
01053     add_type(&type, param, name, description);
01054 }
01055 
01056 void
01057 Parameter::add_matrix(SGString<uint16_t>** param,
01058                       index_t* length_y, index_t* length_x,
01059                       const char* name, const char* description) {
01060     TSGDataType type(CT_MATRIX, ST_STRING, PT_UINT16, length_y,
01061                      length_x);
01062     add_type(&type, param, name, description);
01063 }
01064 
01065 void
01066 Parameter::add_matrix(SGString<int32_t>** param,
01067                       index_t* length_y, index_t* length_x,
01068                       const char* name, const char* description) {
01069     TSGDataType type(CT_MATRIX, ST_STRING, PT_INT32, length_y,
01070                      length_x);
01071     add_type(&type, param, name, description);
01072 }
01073 
01074 void
01075 Parameter::add_matrix(SGString<uint32_t>** param,
01076                       index_t* length_y, index_t* length_x,
01077                       const char* name, const char* description) {
01078     TSGDataType type(CT_MATRIX, ST_STRING, PT_UINT32, length_y,
01079                      length_x);
01080     add_type(&type, param, name, description);
01081 }
01082 
01083 void
01084 Parameter::add_matrix(SGString<int64_t>** param,
01085                       index_t* length_y, index_t* length_x,
01086                       const char* name, const char* description) {
01087     TSGDataType type(CT_MATRIX, ST_STRING, PT_INT64, length_y,
01088                      length_x);
01089     add_type(&type, param, name, description);
01090 }
01091 
01092 void
01093 Parameter::add_matrix(SGString<uint64_t>** param,
01094                       index_t* length_y, index_t* length_x,
01095                       const char* name, const char* description) {
01096     TSGDataType type(CT_MATRIX, ST_STRING, PT_UINT64, length_y,
01097                      length_x);
01098     add_type(&type, param, name, description);
01099 }
01100 
01101 void
01102 Parameter::add_matrix(SGString<float32_t>** param,
01103                       index_t* length_y, index_t* length_x,
01104                       const char* name, const char* description) {
01105     TSGDataType type(CT_MATRIX, ST_STRING, PT_FLOAT32, length_y,
01106                      length_x);
01107     add_type(&type, param, name, description);
01108 }
01109 
01110 void
01111 Parameter::add_matrix(SGString<float64_t>** param,
01112                       index_t* length_y, index_t* length_x,
01113                       const char* name, const char* description) {
01114     TSGDataType type(CT_MATRIX, ST_STRING, PT_FLOAT64, length_y,
01115                      length_x);
01116     add_type(&type, param, name, description);
01117 }
01118 
01119 void
01120 Parameter::add_matrix(SGString<floatmax_t>** param,
01121                       index_t* length_y, index_t* length_x,
01122                       const char* name, const char* description) {
01123     TSGDataType type(CT_MATRIX, ST_STRING, PT_FLOATMAX, length_y,
01124                      length_x);
01125     add_type(&type, param, name, description);
01126 }
01127 
01128 void
01129 Parameter::add_matrix(SGSparseVector<bool>** param,
01130                       index_t* length_y, index_t* length_x,
01131                       const char* name, const char* description) {
01132     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_BOOL, length_y,
01133                      length_x);
01134     add_type(&type, param, name, description);
01135 }
01136 
01137 void
01138 Parameter::add_matrix(SGSparseVector<char>** param,
01139                       index_t* length_y, index_t* length_x,
01140                       const char* name, const char* description) {
01141     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_CHAR, length_y,
01142                      length_x);
01143     add_type(&type, param, name, description);
01144 }
01145 
01146 void
01147 Parameter::add_matrix(SGSparseVector<int8_t>** param,
01148                       index_t* length_y, index_t* length_x,
01149                       const char* name, const char* description) {
01150     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_INT8, length_y,
01151                      length_x);
01152     add_type(&type, param, name, description);
01153 }
01154 
01155 void
01156 Parameter::add_matrix(SGSparseVector<uint8_t>** param,
01157                       index_t* length_y, index_t* length_x,
01158                       const char* name, const char* description) {
01159     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_UINT8, length_y,
01160                      length_x);
01161     add_type(&type, param, name, description);
01162 }
01163 
01164 void
01165 Parameter::add_matrix(SGSparseVector<int16_t>** param,
01166                       index_t* length_y, index_t* length_x,
01167                       const char* name, const char* description) {
01168     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_INT16, length_y,
01169                      length_x);
01170     add_type(&type, param, name, description);
01171 }
01172 
01173 void
01174 Parameter::add_matrix(SGSparseVector<uint16_t>** param,
01175                       index_t* length_y, index_t* length_x,
01176                       const char* name, const char* description) {
01177     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_UINT16, length_y,
01178                      length_x);
01179     add_type(&type, param, name, description);
01180 }
01181 
01182 void
01183 Parameter::add_matrix(SGSparseVector<int32_t>** param,
01184                       index_t* length_y, index_t* length_x,
01185                       const char* name, const char* description) {
01186     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_INT32, length_y,
01187                      length_x);
01188     add_type(&type, param, name, description);
01189 }
01190 
01191 void
01192 Parameter::add_matrix(SGSparseVector<uint32_t>** param,
01193                       index_t* length_y, index_t* length_x,
01194                       const char* name, const char* description) {
01195     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_UINT32, length_y,
01196                      length_x);
01197     add_type(&type, param, name, description);
01198 }
01199 
01200 void
01201 Parameter::add_matrix(SGSparseVector<int64_t>** param,
01202                       index_t* length_y, index_t* length_x,
01203                       const char* name, const char* description) {
01204     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_INT64, length_y,
01205                      length_x);
01206     add_type(&type, param, name, description);
01207 }
01208 
01209 void
01210 Parameter::add_matrix(SGSparseVector<uint64_t>** param,
01211                       index_t* length_y, index_t* length_x,
01212                       const char* name, const char* description) {
01213     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_UINT64, length_y,
01214                      length_x);
01215     add_type(&type, param, name, description);
01216 }
01217 
01218 void
01219 Parameter::add_matrix(SGSparseVector<float32_t>** param,
01220                       index_t* length_y, index_t* length_x,
01221                       const char* name, const char* description) {
01222     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_FLOAT32, length_y,
01223                      length_x);
01224     add_type(&type, param, name, description);
01225 }
01226 
01227 void
01228 Parameter::add_matrix(SGSparseVector<float64_t>** param,
01229                       index_t* length_y, index_t* length_x,
01230                       const char* name, const char* description) {
01231     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_FLOAT64, length_y,
01232                      length_x);
01233     add_type(&type, param, name, description);
01234 }
01235 
01236 void
01237 Parameter::add_matrix(SGSparseVector<floatmax_t>** param,
01238                       index_t* length_y, index_t* length_x,
01239                       const char* name, const char* description) {
01240     TSGDataType type(CT_MATRIX, ST_SPARSE, PT_FLOATMAX, length_y,
01241                      length_x);
01242     add_type(&type, param, name, description);
01243 }
01244 
01245 
01246 
01247 
01248 void Parameter::add(SGMatrix<bool>* param, const char* name,
01249         const char* description)
01250 {
01251     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_BOOL, &param->num_rows,
01252             &param->num_cols);
01253     add_type(&type, param, name, description);
01254 }
01255 
01256 void Parameter::add(SGMatrix<char>* param, const char* name,
01257         const char* description)
01258 {
01259     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_CHAR, &param->num_rows,
01260             &param->num_cols);
01261     add_type(&type, param, name, description);
01262 }
01263 
01264 void Parameter::add(SGMatrix<int8_t>* param, const char* name,
01265         const char* description)
01266 {
01267     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_INT8, &param->num_rows,
01268             &param->num_cols);
01269     add_type(&type, param, name, description);
01270 }
01271 
01272 void Parameter::add(SGMatrix<uint8_t>* param, const char* name,
01273         const char* description)
01274 {
01275     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_UINT8, &param->num_rows,
01276             &param->num_cols);
01277     add_type(&type, param, name, description);
01278 }
01279 
01280 void Parameter::add(SGMatrix<int16_t>* param, const char* name,
01281         const char* description)
01282 {
01283     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_INT16, &param->num_rows,
01284             &param->num_cols);
01285     add_type(&type, param, name, description);
01286 }
01287 
01288 void Parameter::add(SGMatrix<uint16_t>* param, const char* name,
01289         const char* description)
01290 {
01291     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_UINT16, &param->num_rows,
01292             &param->num_cols);
01293     add_type(&type, param, name, description);
01294 }
01295 
01296 void Parameter::add(SGMatrix<int32_t>* param, const char* name,
01297         const char* description)
01298 {
01299     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_INT32, &param->num_rows,
01300             &param->num_cols);
01301     add_type(&type, param, name, description);
01302 }
01303 
01304 void Parameter::add(SGMatrix<uint32_t>* param, const char* name,
01305         const char* description)
01306 {
01307     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_UINT32, &param->num_rows,
01308             &param->num_cols);
01309     add_type(&type, param, name, description);
01310 }
01311 
01312 void Parameter::add(SGMatrix<int64_t>* param, const char* name,
01313         const char* description)
01314 {
01315     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_INT64, &param->num_rows,
01316             &param->num_cols);
01317     add_type(&type, param, name, description);
01318 }
01319 
01320 void Parameter::add(SGMatrix<uint64_t>* param, const char* name,
01321         const char* description)
01322 {
01323     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_UINT64, &param->num_rows,
01324             &param->num_cols);
01325     add_type(&type, param, name, description);
01326 }
01327 
01328 void Parameter::add(SGMatrix<float32_t>* param, const char* name,
01329         const char* description)
01330 {
01331     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_FLOAT32, &param->num_rows,
01332             &param->num_cols);
01333     add_type(&type, param, name, description);
01334 }
01335 
01336 void Parameter::add(SGMatrix<float64_t>* param, const char* name,
01337         const char* description)
01338 {
01339     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_FLOAT64, &param->num_rows,
01340             &param->num_cols);
01341     add_type(&type, param, name, description);
01342 }
01343 
01344 void Parameter::add(SGMatrix<floatmax_t>* param, const char* name,
01345         const char* description)
01346 {
01347     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_FLOATMAX, &param->num_rows,
01348             &param->num_cols);
01349     add_type(&type, param, name, description);
01350 }
01351 
01352 void Parameter::add(SGMatrix<CSGObject*>* param, const char* name,
01353         const char* description)
01354 {
01355     TSGDataType type(CT_SGMATRIX, ST_NONE, PT_SGOBJECT, &param->num_rows,
01356             &param->num_cols);
01357     add_type(&type, param, name, description);
01358 }
01359 
01360 void Parameter::add(SGMatrix<SGString<bool> >* param, const char* name,
01361         const char* description)
01362 {
01363     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_BOOL, &param->num_rows,
01364             &param->num_cols);
01365     add_type(&type, param, name, description);
01366 }
01367 
01368 void Parameter::add(SGMatrix<SGString<char> >* param, const char* name,
01369         const char* description)
01370 {
01371     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_CHAR, &param->num_rows,
01372             &param->num_cols);
01373     add_type(&type, param, name, description);
01374 }
01375 
01376 void Parameter::add(SGMatrix<SGString<int8_t> >* param,
01377         const char* name, const char* description)
01378 {
01379     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_INT8, &param->num_rows,
01380             &param->num_cols);
01381     add_type(&type, param, name, description);
01382 }
01383 
01384 void Parameter::add(SGMatrix<SGString<uint8_t> >* param,
01385         const char* name, const char* description)
01386 {
01387     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_UINT8, &param->num_rows,
01388             &param->num_cols);
01389     add_type(&type, param, name, description);
01390 }
01391 
01392 void Parameter::add(SGMatrix<SGString<int16_t> >* param,
01393         const char* name, const char* description)
01394 {
01395     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_INT16, &param->num_rows,
01396             &param->num_cols);
01397     add_type(&type, param, name, description);
01398 }
01399 
01400 void Parameter::add(SGMatrix<SGString<uint16_t> >* param,
01401         const char* name, const char* description)
01402 {
01403     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_UINT16, &param->num_rows,
01404             &param->num_cols);
01405     add_type(&type, param, name, description);
01406 }
01407 
01408 void Parameter::add(SGMatrix<SGString<int32_t> >* param,
01409         const char* name, const char* description)
01410 {
01411     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_INT32, &param->num_rows,
01412             &param->num_cols);
01413     add_type(&type, param, name, description);
01414 }
01415 
01416 void Parameter::add(SGMatrix<SGString<uint32_t> >* param,
01417         const char* name, const char* description)
01418 {
01419     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_UINT32, &param->num_rows,
01420             &param->num_cols);
01421     add_type(&type, param, name, description);
01422 }
01423 
01424 void Parameter::add(SGMatrix<SGString<int64_t> >* param,
01425         const char* name, const char* description)
01426 {
01427     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_INT64, &param->num_rows,
01428             &param->num_cols);
01429     add_type(&type, param, name, description);
01430 }
01431 
01432 void Parameter::add(SGMatrix<SGString<uint64_t> >* param,
01433         const char* name, const char* description)
01434 {
01435     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_UINT64, &param->num_rows,
01436             &param->num_cols);
01437     add_type(&type, param, name, description);
01438 }
01439 
01440 void Parameter::add(SGMatrix<SGString<float32_t> >* param,
01441         const char* name, const char* description)
01442 {
01443     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_FLOAT32, &param->num_rows,
01444             &param->num_cols);
01445     add_type(&type, param, name, description);
01446 }
01447 
01448 void Parameter::add(SGMatrix<SGString<float64_t> >* param,
01449         const char* name, const char* description)
01450 {
01451     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_FLOAT64, &param->num_rows,
01452             &param->num_cols);
01453     add_type(&type, param, name, description);
01454 }
01455 
01456 void Parameter::add(SGMatrix<SGString<floatmax_t> >* param,
01457         const char* name, const char* description)
01458 {
01459     TSGDataType type(CT_SGMATRIX, ST_STRING, PT_FLOATMAX, &param->num_rows,
01460             &param->num_cols);
01461     add_type(&type, param, name, description);
01462 }
01463 
01464 void Parameter::add(SGMatrix<SGSparseVector<bool> >* param,
01465         const char* name, const char* description)
01466 {
01467     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_BOOL, &param->num_rows,
01468             &param->num_cols);
01469     add_type(&type, param, name, description);
01470 }
01471 
01472 void Parameter::add(SGMatrix<SGSparseVector<char> >* param,
01473         const char* name, const char* description)
01474 {
01475     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_CHAR, &param->num_rows,
01476             &param->num_cols);
01477     add_type(&type, param, name, description);
01478 }
01479 
01480 void Parameter::add(SGMatrix<SGSparseVector<int8_t> >* param,
01481         const char* name, const char* description)
01482 {
01483     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT8, &param->num_rows,
01484             &param->num_cols);
01485     add_type(&type, param, name, description);
01486 }
01487 
01488 void Parameter::add(SGMatrix<SGSparseVector<uint8_t> >* param,
01489         const char* name, const char* description)
01490 {
01491     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT8, &param->num_rows,
01492             &param->num_cols);
01493     add_type(&type, param, name, description);
01494 }
01495 
01496 void Parameter::add(SGMatrix<SGSparseVector<int16_t> >* param,
01497         const char* name, const char* description)
01498 {
01499     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT16, &param->num_rows,
01500             &param->num_cols);
01501     add_type(&type, param, name, description);
01502 }
01503 
01504 void Parameter::add(SGMatrix<SGSparseVector<uint16_t> >* param,
01505         const char* name, const char* description)
01506 {
01507     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT16, &param->num_rows,
01508             &param->num_cols);
01509     add_type(&type, param, name, description);
01510 }
01511 
01512 void Parameter::add(SGMatrix<SGSparseVector<int32_t> >* param,
01513         const char* name, const char* description)
01514 {
01515     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT32, &param->num_rows,
01516             &param->num_cols);
01517     add_type(&type, param, name, description);
01518 }
01519 
01520 void Parameter::add(SGMatrix<SGSparseVector<uint32_t> >* param,
01521         const char* name, const char* description)
01522 {
01523     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT32, &param->num_rows,
01524             &param->num_cols);
01525     add_type(&type, param, name, description);
01526 }
01527 
01528 void Parameter::add(SGMatrix<SGSparseVector<int64_t> >* param,
01529         const char* name, const char* description)
01530 {
01531     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_INT64, &param->num_rows,
01532             &param->num_cols);
01533     add_type(&type, param, name, description);
01534 }
01535 
01536 void Parameter::add(SGMatrix<SGSparseVector<uint64_t> >* param,
01537         const char* name, const char* description)
01538 {
01539     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_UINT64, &param->num_rows,
01540             &param->num_cols);
01541     add_type(&type, param, name, description);
01542 }
01543 
01544 void Parameter::add(SGMatrix<SGSparseVector<float32_t> >* param,
01545         const char* name, const char* description)
01546 {
01547     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOAT32, &param->num_rows,
01548             &param->num_cols);
01549     add_type(&type, param, name, description);
01550 }
01551 
01552 void Parameter::add(SGMatrix<SGSparseVector<float64_t> >* param,
01553         const char* name, const char* description)
01554 {
01555     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOAT64, &param->num_rows,
01556             &param->num_cols);
01557     add_type(&type, param, name, description);
01558 }
01559 
01560 void Parameter::add(SGMatrix<SGSparseVector<floatmax_t> >* param,
01561         const char* name, const char* description)
01562 {
01563     TSGDataType type(CT_SGMATRIX, ST_SPARSE, PT_FLOATMAX, &param->num_rows,
01564             &param->num_cols);
01565     add_type(&type, param, name, description);
01566 }
01567 /* **************************************************************** */
01568 /* End of wrappers  */
01569 
01570 TParameter::TParameter(const TSGDataType* datatype, void* parameter,
01571                        const char* name, const char* description)
01572     :m_datatype(*datatype)
01573 {
01574     m_parameter = parameter;
01575     m_name = strdup(name);
01576     m_description = strdup(description);
01577 }
01578 
01579 TParameter::~TParameter(void)
01580 {
01581     SG_FREE(m_description);
01582     SG_FREE(m_name);
01583 }
01584 
01585 char*
01586 TParameter::new_prefix(const char* s1, const char* s2)
01587 {
01588     char* tmp = SG_MALLOC(char, strlen(s1)+strlen(s2)+2);
01589 
01590     sprintf(tmp, "%s%s/", s1, s2);
01591 
01592     return tmp;
01593 }
01594 
01595 void
01596 TParameter::print(const char* prefix)
01597 {
01598     string_t buf;
01599     m_datatype.to_string(buf, STRING_LEN);
01600 
01601     SG_SPRINT("\n%s\n%35s %24s :%s\n", prefix, m_description == NULL
01602              || *m_description == '\0' ? "(Parameter)": m_description,
01603              m_name, buf);
01604 
01605     if (m_datatype.m_ptype == PT_SGOBJECT
01606         && m_datatype.m_stype == ST_NONE
01607         && m_datatype.m_ctype == CT_SCALAR
01608         && *(CSGObject**) m_parameter != NULL) {
01609         char* p = new_prefix(prefix, m_name);
01610         (*(CSGObject**) m_parameter)->print_serializable(p);
01611         delete p;
01612     }
01613 }
01614 
01615 void
01616 TParameter::delete_cont(void)
01617 {
01618     /* In the case, ctype is a struct (not array of a basic type)
01619      * data does not start at m_parameter, since the latter may have
01620      * methods so move start pointer to array of struct */
01621     void* data_start=m_parameter;
01622     switch(m_datatype.m_ctype)
01623     {
01624     case CT_SGVECTOR:
01625         data_start=&(((SGVector<void>*)m_parameter)->vector);
01626         break;
01627     case CT_SGMATRIX:
01628         data_start=&(((SGMatrix<void>*)m_parameter)->matrix);
01629         break;
01630     default:
01631         break;
01632     }
01633 
01634     if (*(void**) data_start != NULL) {
01635         index_t old_length = *m_datatype.m_length_y;
01636         switch (m_datatype.m_ctype) {
01637         case CT_NDARRAY:
01638             SG_SNOTIMPLEMENTED;
01639         case CT_MATRIX: case CT_SGMATRIX:
01640             old_length *= *m_datatype.m_length_x; break;
01641         case CT_SCALAR: case CT_VECTOR: case CT_SGVECTOR: break;
01642         }
01643 
01644 
01645         switch (m_datatype.m_stype) {
01646         case ST_NONE:
01647             switch (m_datatype.m_ptype) {
01648             case PT_BOOL:
01649                 SG_FREE(*(bool**) data_start); break;
01650             case PT_CHAR:
01651                 SG_FREE(*(char**) data_start); break;
01652             case PT_INT8:
01653                 SG_FREE(*(int8_t**) data_start); break;
01654             case PT_UINT8:
01655                 SG_FREE(*(uint8_t**) data_start); break;
01656             case PT_INT16:
01657                 SG_FREE(*(int16_t**) data_start); break;
01658             case PT_UINT16:
01659                 SG_FREE(*(uint16_t**) data_start); break;
01660             case PT_INT32:
01661                 SG_FREE(*(int32_t**) data_start); break;
01662             case PT_UINT32:
01663                 SG_FREE(*(uint32_t**) data_start); break;
01664             case PT_INT64:
01665                 SG_FREE(*(int64_t**) data_start); break;
01666             case PT_UINT64:
01667                 SG_FREE(*(uint64_t**) data_start); break;
01668             case PT_FLOAT32:
01669                 SG_FREE(*(float32_t**) data_start); break;
01670             case PT_FLOAT64:
01671                 SG_FREE(*(float64_t**) data_start); break;
01672             case PT_FLOATMAX:
01673                 SG_FREE(*(floatmax_t**) data_start); break;
01674             case PT_SGOBJECT:
01675                 CSGObject** buf =
01676                     *(CSGObject***) data_start;
01677                 for (index_t i=0; i<old_length; i++)
01678                     if (buf[i] != NULL) SG_UNREF(buf[i]);
01679                 delete buf;
01680                 break;
01681             }
01682             break;
01683         case ST_STRING:
01684             for (index_t i=0; i<old_length; i++) {
01685                 SGString<char>* buf = (SGString<char>*) (*(char**)
01686                         data_start + i *m_datatype.sizeof_stype());
01687                 if (buf->slen > 0) SG_FREE(buf->string);
01688             }
01689 
01690             switch (m_datatype.m_ptype) {
01691             case PT_BOOL:
01692                 SG_FREE(*(SGString<bool>**) data_start); break;
01693             case PT_CHAR:
01694                 SG_FREE(*(SGString<char>**) data_start); break;
01695             case PT_INT8:
01696                 SG_FREE(*(SGString<int8_t>**) data_start); break;
01697             case PT_UINT8:
01698                 SG_FREE(*(SGString<uint8_t>**) data_start); break;
01699             case PT_INT16:
01700                 SG_FREE(*(SGString<int16_t>**) data_start); break;
01701             case PT_UINT16:
01702                 SG_FREE(*(SGString<uint16_t>**) data_start); break;
01703             case PT_INT32:
01704                 SG_FREE(*(SGString<int32_t>**) data_start); break;
01705             case PT_UINT32:
01706                 SG_FREE(*(SGString<uint32_t>**) data_start); break;
01707             case PT_INT64:
01708                 SG_FREE(*(SGString<int64_t>**) data_start); break;
01709             case PT_UINT64:
01710                 SG_FREE(*(SGString<uint64_t>**) data_start); break;
01711             case PT_FLOAT32:
01712                 SG_FREE(*(SGString<float32_t>**) data_start); break;
01713             case PT_FLOAT64:
01714                 SG_FREE(*(SGString<float64_t>**) data_start); break;
01715             case PT_FLOATMAX:
01716                 SG_FREE(*(SGString<floatmax_t>**) data_start); break;
01717             case PT_SGOBJECT:
01718                 SG_SERROR("TParameter::delete_cont(): Implementation "
01719                          "error: Could not delete "
01720                          "String<SGSerializable*>");
01721                 break;
01722             }
01723             break;
01724         case ST_SPARSE:
01725             for (index_t i=0; i<old_length; i++) {
01726                 SGSparseVector<char>* buf = (SGSparseVector<char>*) (*(char**)
01727                         data_start + i *m_datatype.sizeof_stype());
01728                 if (buf->num_feat_entries > 0) SG_FREE(buf->features);
01729             }
01730 
01731             switch (m_datatype.m_ptype) {
01732             case PT_BOOL:
01733                 SG_FREE(*(SGSparseVector<bool>**) data_start); break;
01734             case PT_CHAR:
01735                 SG_FREE(*(SGSparseVector<char>**) data_start); break;
01736             case PT_INT8:
01737                 SG_FREE(*(SGSparseVector<int8_t>**) data_start); break;
01738             case PT_UINT8:
01739                 SG_FREE(*(SGSparseVector<uint8_t>**) data_start); break;
01740             case PT_INT16:
01741                 SG_FREE(*(SGSparseVector<int16_t>**) data_start); break;
01742             case PT_UINT16:
01743                 SG_FREE(*(SGSparseVector<uint16_t>**) data_start); break;
01744             case PT_INT32:
01745                 SG_FREE(*(SGSparseVector<int32_t>**) data_start); break;
01746             case PT_UINT32:
01747                 SG_FREE(*(SGSparseVector<uint32_t>**) data_start); break;
01748             case PT_INT64:
01749                 SG_FREE(*(SGSparseVector<int64_t>**) data_start); break;
01750             case PT_UINT64:
01751                 SG_FREE(*(SGSparseVector<uint64_t>**) data_start); break;
01752             case PT_FLOAT32:
01753                 SG_FREE(*(SGSparseVector<float32_t>**) data_start); break;
01754             case PT_FLOAT64:
01755                 SG_FREE(*(SGSparseVector<float64_t>**) data_start); break;
01756             case PT_FLOATMAX:
01757                 SG_FREE(*(SGSparseVector<floatmax_t>**) data_start); break;
01758             case PT_SGOBJECT:
01759                 SG_SERROR("TParameter::delete_cont(): Implementation "
01760                          "error: Could not delete "
01761                          "Sparse<SGSerializable*>");
01762                 break;
01763             }
01764             break;
01765         } /* switch (m_datatype.m_stype)  */
01766     } /* if (*(void**) data_start != NULL)  */
01767 
01768     *(void**) data_start = NULL;
01769 }
01770 
01771 void
01772 TParameter::new_cont(index_t new_len_y, index_t new_len_x)
01773 {
01774     delete_cont();
01775 
01776     index_t new_length = new_len_y*new_len_x;
01777     if (new_length == 0) return;
01778 
01779     /* In the case, ctype is a struct (not array of a basic type)
01780      * data does not start at m_parameter, since the latter may have
01781      * methods so move start pointer to array of struct */
01782     void* data_start=m_parameter;
01783     switch(m_datatype.m_ctype)
01784     {
01785     case CT_SGVECTOR:
01786         data_start=&(((SGVector<void>*)m_parameter)->vector);
01787         break;
01788     case CT_SGMATRIX:
01789         data_start=&(((SGMatrix<void>*)m_parameter)->matrix);
01790         break;
01791     default:
01792         break;
01793     }
01794 
01795     switch (m_datatype.m_stype) {
01796     case ST_NONE:
01797         switch (m_datatype.m_ptype) {
01798         case PT_BOOL:
01799             *(bool**) data_start
01800                 = SG_MALLOC(bool, new_length); break;
01801         case PT_CHAR:
01802             *(char**) data_start
01803                 = SG_MALLOC(char, new_length); break;
01804         case PT_INT8:
01805             *(int8_t**) data_start
01806                 = SG_MALLOC(int8_t, new_length); break;
01807         case PT_UINT8:
01808             *(uint8_t**) data_start
01809                 = SG_MALLOC(uint8_t, new_length); break;
01810         case PT_INT16:
01811             *(int16_t**) data_start
01812                 = SG_MALLOC(int16_t, new_length); break;
01813         case PT_UINT16:
01814             *(uint16_t**) data_start
01815                 = SG_MALLOC(uint16_t, new_length); break;
01816         case PT_INT32:
01817             *(int32_t**) data_start
01818                 = SG_MALLOC(int32_t, new_length); break;
01819         case PT_UINT32:
01820             *(uint32_t**) data_start
01821                 = SG_MALLOC(uint32_t, new_length); break;
01822         case PT_INT64:
01823             *(int64_t**) data_start
01824                 = SG_MALLOC(int64_t, new_length); break;
01825         case PT_UINT64:
01826             *(uint64_t**) data_start
01827                 = SG_MALLOC(uint64_t, new_length); break;
01828         case PT_FLOAT32:
01829             *(float32_t**) data_start
01830                 = SG_MALLOC(float32_t, new_length); break;
01831         case PT_FLOAT64:
01832             *(float64_t**) data_start
01833                 = SG_MALLOC(float64_t, new_length); break;
01834         case PT_FLOATMAX:
01835             *(floatmax_t**) data_start
01836                 = SG_MALLOC(floatmax_t, new_length); break;
01837         case PT_SGOBJECT:
01838             *(CSGObject***) data_start
01839                 = SG_CALLOC(CSGObject*, new_length);
01840             break;
01841         }
01842         break;
01843     case ST_STRING:
01844         switch (m_datatype.m_ptype) {
01845         case PT_BOOL:
01846             *(SGString<bool>**) data_start
01847                 = SG_MALLOC(SGString<bool>, new_length); break;
01848         case PT_CHAR:
01849             *(SGString<char>**) data_start
01850                 = SG_MALLOC(SGString<char>, new_length); break;
01851         case PT_INT8:
01852             *(SGString<int8_t>**) data_start
01853                 = SG_MALLOC(SGString<int8_t>, new_length); break;
01854         case PT_UINT8:
01855             *(SGString<uint8_t>**) data_start
01856                 = SG_MALLOC(SGString<uint8_t>, new_length); break;
01857         case PT_INT16:
01858             *(SGString<int16_t>**) data_start
01859                 = SG_MALLOC(SGString<int16_t>, new_length); break;
01860         case PT_UINT16:
01861             *(SGString<uint16_t>**) data_start
01862                 = SG_MALLOC(SGString<uint16_t>, new_length); break;
01863         case PT_INT32:
01864             *(SGString<int32_t>**) data_start
01865                 = SG_MALLOC(SGString<int32_t>, new_length); break;
01866         case PT_UINT32:
01867             *(SGString<uint32_t>**) data_start
01868                 = SG_MALLOC(SGString<uint32_t>, new_length); break;
01869         case PT_INT64:
01870             *(SGString<int64_t>**) data_start
01871                 = SG_MALLOC(SGString<int64_t>, new_length); break;
01872         case PT_UINT64:
01873             *(SGString<uint64_t>**) data_start
01874                 = SG_MALLOC(SGString<uint64_t>, new_length); break;
01875         case PT_FLOAT32:
01876             *(SGString<float32_t>**) data_start
01877                 = SG_MALLOC(SGString<float32_t>, new_length); break;
01878         case PT_FLOAT64:
01879             *(SGString<float64_t>**) data_start
01880                 = SG_MALLOC(SGString<float64_t>, new_length); break;
01881         case PT_FLOATMAX:
01882             *(SGString<floatmax_t>**) data_start
01883                 = SG_MALLOC(SGString<floatmax_t>, new_length); break;
01884         case PT_SGOBJECT:
01885             SG_SERROR("TParameter::new_cont(): Implementation "
01886                      "error: Could not allocate "
01887                      "String<SGSerializable*>");
01888             break;
01889         }
01890         memset(*(void**) data_start, 0, new_length
01891                *m_datatype.sizeof_stype());
01892         break;
01893     case ST_SPARSE:
01894         switch (m_datatype.m_ptype) {
01895         case PT_BOOL:
01896             *(SGSparseVector<bool>**) data_start
01897                 = SG_MALLOC(SGSparseVector<bool>, new_length); break;
01898         case PT_CHAR:
01899             *(SGSparseVector<char>**) data_start
01900                 = SG_MALLOC(SGSparseVector<char>, new_length); break;
01901         case PT_INT8:
01902             *(SGSparseVector<int8_t>**) data_start
01903                 = SG_MALLOC(SGSparseVector<int8_t>, new_length); break;
01904         case PT_UINT8:
01905             *(SGSparseVector<uint8_t>**) data_start
01906                 = SG_MALLOC(SGSparseVector<uint8_t>, new_length); break;
01907         case PT_INT16:
01908             *(SGSparseVector<int16_t>**) data_start
01909                 = SG_MALLOC(SGSparseVector<int16_t>, new_length); break;
01910         case PT_UINT16:
01911             *(SGSparseVector<uint16_t>**) data_start
01912                 = SG_MALLOC(SGSparseVector<uint16_t>, new_length); break;
01913         case PT_INT32:
01914             *(SGSparseVector<int32_t>**) data_start
01915                 = SG_MALLOC(SGSparseVector<int32_t>, new_length); break;
01916         case PT_UINT32:
01917             *(SGSparseVector<uint32_t>**) data_start
01918                 = SG_MALLOC(SGSparseVector<uint32_t>, new_length); break;
01919         case PT_INT64:
01920             *(SGSparseVector<int64_t>**) data_start
01921                 = SG_MALLOC(SGSparseVector<int64_t>, new_length); break;
01922         case PT_UINT64:
01923             *(SGSparseVector<uint64_t>**) data_start
01924                 = SG_MALLOC(SGSparseVector<uint64_t>, new_length); break;
01925         case PT_FLOAT32:
01926             *(SGSparseVector<float32_t>**) data_start
01927                 = SG_MALLOC(SGSparseVector<float32_t>, new_length); break;
01928         case PT_FLOAT64:
01929             *(SGSparseVector<float64_t>**) data_start
01930                 = SG_MALLOC(SGSparseVector<float64_t>, new_length); break;
01931         case PT_FLOATMAX:
01932             *(SGSparseVector<floatmax_t>**) data_start
01933                 = SG_MALLOC(SGSparseVector<floatmax_t>, new_length); break;
01934         case PT_SGOBJECT:
01935             SG_SERROR("TParameter::new_cont(): Implementation "
01936                      "error: Could not allocate "
01937                      "Sparse<SGSerializable*>");
01938             break;
01939         }
01940         memset(*(void**) data_start, 0, new_length
01941                *m_datatype.sizeof_stype());
01942         break;
01943     } /* switch (m_datatype.m_stype)  */
01944 }
01945 
01946 bool
01947 TParameter::new_sgserial(CSGObject** param,
01948                          EPrimitiveType generic,
01949                          const char* sgserializable_name,
01950                          const char* prefix)
01951 {
01952     if (*param != NULL)
01953         SG_UNREF(*param);
01954 
01955     *param = new_sgserializable(sgserializable_name, generic);
01956 
01957     if (*param == NULL) {
01958         string_t buf = {'\0'};
01959 
01960         if (generic != PT_NOT_GENERIC) {
01961             buf[0] = '<';
01962             TSGDataType::ptype_to_string(buf+1, generic,
01963                                          STRING_LEN - 3);
01964             strcat(buf, ">");
01965         }
01966 
01967         SG_SWARNING("TParameter::new_sgserial(): "
01968                    "Class `C%s%s' was not listed during compiling Shogun"
01969                    " :( ...  Can not construct it for `%s%s'!",
01970                    sgserializable_name, buf, prefix, m_name);
01971 
01972         return false;
01973     }
01974 
01975     SG_REF(*param);
01976     return true;
01977 }
01978 
01979 bool
01980 TParameter::save_ptype(CSerializableFile* file, const void* param,
01981                        const char* prefix)
01982 {
01983     if (m_datatype.m_ptype == PT_SGOBJECT) {
01984         const char* sgserial_name = "";
01985         EPrimitiveType generic = PT_NOT_GENERIC;
01986 
01987         if (*(CSGObject**) param != NULL) {
01988             sgserial_name = (*(CSGObject**) param)->get_name();
01989             (*(CSGObject**) param)->is_generic(&generic);
01990         }
01991 
01992         if (!file->write_sgserializable_begin(
01993                 &m_datatype, m_name, prefix, sgserial_name, generic))
01994             return false;
01995         if (*sgserial_name != '\0') {
01996             char* p = new_prefix(prefix, m_name);
01997             bool result = (*(CSGObject**) param)
01998                 ->save_serializable(file, p);
01999             delete p;
02000             if (!result) return false;
02001         }
02002         if (!file->write_sgserializable_end(
02003                 &m_datatype, m_name, prefix, sgserial_name, generic))
02004             return false;
02005     } else
02006         if (!file->write_scalar(&m_datatype, m_name, prefix,
02007                                 param)) return false;
02008 
02009     return true;
02010 }
02011 
02012 bool
02013 TParameter::load_ptype(CSerializableFile* file, void* param,
02014                        const char* prefix)
02015 {
02016     if (m_datatype.m_ptype == PT_SGOBJECT) {
02017         string_t sgserial_name = {'\0'};
02018         EPrimitiveType generic = PT_NOT_GENERIC;
02019 
02020         if (!file->read_sgserializable_begin(
02021                 &m_datatype, m_name, prefix, sgserial_name, &generic))
02022             return false;
02023         if (*sgserial_name != '\0') {
02024             if (!new_sgserial((CSGObject**) param, generic,
02025                               sgserial_name, prefix))
02026                 return false;
02027 
02028             char* p = new_prefix(prefix, m_name);
02029             bool result = (*(CSGObject**) param)
02030                 ->load_serializable(file, p);
02031             delete p;
02032             if (!result) return false;
02033         }
02034         if (!file->read_sgserializable_end(
02035                 &m_datatype, m_name, prefix, sgserial_name, generic))
02036             return false;
02037     } else
02038         if (!file->read_scalar(&m_datatype, m_name, prefix,
02039                                param)) return false;
02040 
02041     return true;
02042 }
02043 
02044 bool
02045 TParameter::save_stype(CSerializableFile* file, const void* param,
02046                        const char* prefix)
02047 {
02048     SGString<char>* str_ptr = (SGString<char>*) param;
02049     SGSparseVector<char>* spr_ptr = (SGSparseVector<char>*) param;
02050     index_t len_real;
02051 
02052     switch (m_datatype.m_stype) {
02053     case ST_NONE:
02054         if (!save_ptype(file, param, prefix)) return false;
02055         break;
02056     case ST_STRING:
02057         len_real = str_ptr->slen;
02058         if (str_ptr->string == NULL && len_real != 0) {
02059             SG_SWARNING("Inconsistency between data structure and "
02060                        "len during saving string `%s%s'!  Continuing"
02061                        " with len=0.\n",
02062                        prefix, m_name);
02063             len_real = 0;
02064         }
02065         if (!file->write_string_begin(
02066                 &m_datatype, m_name, prefix, len_real)) return false;
02067         for (index_t i=0; i<len_real; i++) {
02068             if (!file->write_stringentry_begin(
02069                     &m_datatype, m_name, prefix, i)) return false;
02070             if (!save_ptype(file, (char*) str_ptr->string
02071                             + i *m_datatype.sizeof_ptype(), prefix))
02072                 return false;
02073             if (!file->write_stringentry_end(
02074                     &m_datatype, m_name, prefix, i)) return false;
02075         }
02076         if (!file->write_string_end(
02077                 &m_datatype, m_name, prefix, len_real)) return false;
02078         break;
02079     case ST_SPARSE:
02080         len_real = spr_ptr->num_feat_entries;
02081         if (spr_ptr->features == NULL && len_real != 0) {
02082             SG_SWARNING("Inconsistency between data structure and "
02083                        "len during saving sparse `%s%s'!  Continuing"
02084                        " with len=0.\n",
02085                        prefix, m_name);
02086             len_real = 0;
02087         }
02088         if (!file->write_sparse_begin(
02089                 &m_datatype, m_name, prefix, spr_ptr->vec_index,
02090                 len_real)) return false;
02091         for (index_t i=0; i<len_real; i++) {
02092             SGSparseVectorEntry<char>* cur = (SGSparseVectorEntry<char>*)
02093                 ((char*) spr_ptr->features + i *TSGDataType
02094 				 ::sizeof_sparseentry(m_datatype.m_ptype));
02095             if (!file->write_sparseentry_begin(
02096                     &m_datatype, m_name, prefix, spr_ptr->features,
02097                     cur->feat_index, i)) return false;
02098             if (!save_ptype(file, (char*) cur + TSGDataType
02099                             ::offset_sparseentry(m_datatype.m_ptype),
02100                             prefix)) return false;
02101             if (!file->write_sparseentry_end(
02102                     &m_datatype, m_name, prefix, spr_ptr->features,
02103                     cur->feat_index, i)) return false;
02104         }
02105         if (!file->write_sparse_end(
02106                 &m_datatype, m_name, prefix, spr_ptr->vec_index,
02107                 len_real)) return false;
02108         break;
02109     }
02110 
02111     return true;
02112 }
02113 
02114 bool
02115 TParameter::load_stype(CSerializableFile* file, void* param,
02116                        const char* prefix)
02117 {
02118     SGString<char>* str_ptr = (SGString<char>*) param;
02119     SGSparseVector<char>* spr_ptr = (SGSparseVector<char>*) param;
02120     index_t len_real = 0;
02121 
02122     switch (m_datatype.m_stype) {
02123     case ST_NONE:
02124         if (!load_ptype(file, param, prefix)) return false;
02125         break;
02126     case ST_STRING:
02127         if (!file->read_string_begin(
02128                 &m_datatype, m_name, prefix, &len_real))
02129             return false;
02130         str_ptr->string = len_real > 0
02131             ? SG_MALLOC(char, len_real*m_datatype.sizeof_ptype()): NULL;
02132         for (index_t i=0; i<len_real; i++) {
02133             if (!file->read_stringentry_begin(
02134                     &m_datatype, m_name, prefix, i)) return false;
02135             if (!load_ptype(file, (char*) str_ptr->string
02136                             + i *m_datatype.sizeof_ptype(), prefix))
02137                 return false;
02138             if (!file->read_stringentry_end(
02139                     &m_datatype, m_name, prefix, i)) return false;
02140         }
02141         if (!file->read_string_end(
02142                 &m_datatype, m_name, prefix, len_real))
02143             return false;
02144         str_ptr->slen = len_real;
02145         break;
02146     case ST_SPARSE:
02147         if (!file->read_sparse_begin(
02148                 &m_datatype, m_name, prefix, &spr_ptr->vec_index,
02149                 &len_real)) return false;
02150         spr_ptr->features = len_real > 0? (SGSparseVectorEntry<char>*)
02151             SG_MALLOC(char, len_real *TSGDataType::sizeof_sparseentry(
02152                 m_datatype.m_ptype)): NULL;
02153         for (index_t i=0; i<len_real; i++) {
02154             SGSparseVectorEntry<char>* cur = (SGSparseVectorEntry<char>*)
02155                 ((char*) spr_ptr->features + i *TSGDataType
02156 				 ::sizeof_sparseentry(m_datatype.m_ptype));
02157             if (!file->read_sparseentry_begin(
02158                     &m_datatype, m_name, prefix, spr_ptr->features,
02159                     &cur->feat_index, i)) return false;
02160             if (!load_ptype(file, (char*) cur + TSGDataType
02161                             ::offset_sparseentry(m_datatype.m_ptype),
02162                             prefix)) return false;
02163             if (!file->read_sparseentry_end(
02164                     &m_datatype, m_name, prefix, spr_ptr->features,
02165                     &cur->feat_index, i)) return false;
02166         }
02167         if (!file->read_sparse_end(
02168                 &m_datatype, m_name, prefix, &spr_ptr->vec_index,
02169                 len_real)) return false;
02170         spr_ptr->num_feat_entries = len_real;
02171         break;
02172     }
02173 
02174     return true;
02175 }
02176 
02177 bool
02178 TParameter::save(CSerializableFile* file, const char* prefix)
02179 {
02180     const int32_t buflen=100;
02181     char* buf=SG_MALLOC(char, buflen);
02182     m_datatype.to_string(buf, buflen);
02183     SG_SDEBUG("Saving parameter '%s' of type '%s'\n", m_name, buf);
02184     SG_FREE(buf);
02185 
02186     if (!file->write_type_begin(&m_datatype, m_name, prefix))
02187         return false;
02188 
02189     switch (m_datatype.m_ctype) {
02190     case CT_NDARRAY:
02191         SG_SNOTIMPLEMENTED;
02192     case CT_SCALAR:
02193         if (!save_stype(file, m_parameter, prefix)) return false;
02194         break;
02195     case CT_VECTOR: case CT_MATRIX: case CT_SGVECTOR: case CT_SGMATRIX:
02196         index_t len_real_y = 0, len_real_x = 0;
02197 
02198         len_real_y = *m_datatype.m_length_y;
02199         if (*(void**) m_parameter == NULL && len_real_y != 0) {
02200             SG_SWARNING("Inconsistency between data structure and "
02201                        "len_y during saving `%s%s'!  Continuing with "
02202                        "len_y=0.\n",
02203                        prefix, m_name);
02204             len_real_y = 0;
02205         }
02206 
02207         switch (m_datatype.m_ctype) {
02208         case CT_NDARRAY:
02209             SG_SNOTIMPLEMENTED;
02210             break;
02211         case CT_VECTOR: case CT_SGVECTOR:
02212             len_real_x = 1;
02213             break;
02214         case CT_MATRIX: case CT_SGMATRIX:
02215             len_real_x = *m_datatype.m_length_x;
02216             if (*(void**) m_parameter == NULL && len_real_x != 0) {
02217                 SG_SWARNING("Inconsistency between data structure and "
02218                            "len_x during saving `%s%s'!  Continuing "
02219                            "with len_x=0.\n",
02220                            prefix, m_name);
02221                 len_real_x = 0;
02222             }
02223 
02224             if (len_real_x *len_real_y == 0)
02225                 len_real_x = len_real_y = 0;
02226 
02227             break;
02228         case CT_SCALAR: break;
02229         }
02230 
02231         if (!file->write_cont_begin(&m_datatype, m_name, prefix,
02232                                     len_real_y, len_real_x))
02233             return false;
02234 
02235         /* ******************************************************** */
02236 
02237         for (index_t x=0; x<len_real_x; x++)
02238             for (index_t y=0; y<len_real_y; y++) {
02239                 if (!file->write_item_begin(
02240                         &m_datatype, m_name, prefix, y, x))
02241                     return false;
02242 
02243                 /* In the case, ctype is a struct (not array of a basic type)
02244                  * data does not start at m_parameter, since the latter may have
02245                  * methods so move start pointer to array of struct */
02246                 void* data_start=m_parameter;
02247                 switch(m_datatype.m_ctype)
02248                 {
02249                 case CT_SGVECTOR:
02250                     data_start=&(((SGVector<void>*)m_parameter)->vector);
02251                     break;
02252                 case CT_SGMATRIX:
02253                     data_start=&(((SGMatrix<void>*)m_parameter)->matrix);
02254                     break;
02255                 default:
02256                     break;
02257                 }
02258 
02259                 if (!save_stype(
02260                         file, (*(char**) data_start)
02261                         + (x*len_real_y + y)*m_datatype.sizeof_stype(),
02262                         prefix)) return false;
02263                 if (!file->write_item_end(
02264                         &m_datatype, m_name, prefix, y, x))
02265                     return false;
02266             }
02267 
02268         /* ******************************************************** */
02269 
02270         if (!file->write_cont_end(&m_datatype, m_name, prefix,
02271                                   len_real_y, len_real_x))
02272             return false;
02273 
02274         break;
02275     }
02276 
02277     if (!file->write_type_end(&m_datatype, m_name, prefix))
02278         return false;
02279 
02280     return true;
02281 }
02282 
02283 bool
02284 TParameter::load(CSerializableFile* file, const char* prefix)
02285 {
02286     const int32_t buflen=100;
02287     char* buf=SG_MALLOC(char, buflen);
02288     m_datatype.to_string(buf, buflen);
02289     SG_SDEBUG("Loading parameter '%s' of type '%s'\n", m_name, buf);
02290     SG_FREE(buf);
02291 
02292     if (!file->read_type_begin(&m_datatype, m_name, prefix))
02293         return false;
02294 
02295     switch (m_datatype.m_ctype)
02296     {
02297         case CT_NDARRAY:
02298             SG_SNOTIMPLEMENTED;
02299         case CT_SCALAR:
02300             if (!load_stype(file, m_parameter, prefix))
02301                 return false;
02302             break;
02303 
02304         case CT_VECTOR: case CT_MATRIX: case CT_SGVECTOR: case CT_SGMATRIX:
02305             index_t len_read_y = 0, len_read_x = 0;
02306 
02307             if (!file->read_cont_begin(&m_datatype, m_name, prefix,
02308                         &len_read_y, &len_read_x))
02309                 return false;
02310 
02311             switch (m_datatype.m_ctype)
02312             {
02313                 case CT_NDARRAY:
02314                     SG_SNOTIMPLEMENTED;
02315                 case CT_VECTOR: case CT_SGVECTOR:
02316                     len_read_x = 1;
02317                     new_cont(len_read_y, len_read_x);
02318                     break;
02319                 case CT_MATRIX: case CT_SGMATRIX:
02320                     new_cont(len_read_y, len_read_x);
02321                     break;
02322                 case CT_SCALAR:
02323                     break;
02324             }
02325 
02326             for (index_t x=0; x<len_read_x; x++)
02327             {
02328                 for (index_t y=0; y<len_read_y; y++)
02329                 {
02330                     if (!file->read_item_begin(
02331                                 &m_datatype, m_name, prefix, y, x))
02332                         return false;
02333 
02334                     /* In the case, ctype is a struct (not array of a basic type)
02335                      * data does not start at m_parameter, since the latter may
02336                      * have methods so move start pointer to array of struct */
02337                     void* data_start=m_parameter;
02338                     switch(m_datatype.m_ctype)
02339                     {
02340                     case CT_SGVECTOR:
02341                         data_start=&(((SGVector<void>*)m_parameter)->vector);
02342                         break;
02343                     case CT_SGMATRIX:
02344                         data_start=&(((SGMatrix<void>*)m_parameter)->matrix);
02345                         break;
02346                     default:
02347                         break;
02348                     }
02349 
02350                     if (!load_stype(
02351                                 file, (*(char**) data_start)
02352                                 + (x*len_read_y + y)*m_datatype.sizeof_stype(),
02353                                 prefix)) return false;
02354                     if (!file->read_item_end(
02355                                 &m_datatype, m_name, prefix, y, x))
02356                         return false;
02357                 }
02358             }
02359 
02360             switch (m_datatype.m_ctype)
02361             {
02362                 case CT_NDARRAY:
02363                     SG_SNOTIMPLEMENTED;
02364                 case CT_VECTOR: case CT_SGVECTOR:
02365                     *m_datatype.m_length_y = len_read_y;
02366                     break;
02367                 case CT_MATRIX: case CT_SGMATRIX:
02368                     *m_datatype.m_length_y = len_read_y;
02369                     *m_datatype.m_length_x = len_read_x;
02370                     break;
02371                 case CT_SCALAR:
02372                     break;
02373             }
02374 
02375             if (!file->read_cont_end(&m_datatype, m_name, prefix,
02376                         len_read_y, len_read_x))
02377                 return false;
02378 
02379             break;
02380     }
02381 
02382     if (!file->read_type_end(&m_datatype, m_name, prefix))
02383         return false;
02384 
02385     return true;
02386 }
02387 
02388 Parameter::Parameter(void)
02389 {
02390     SG_REF(sg_io);
02391 }
02392 
02393 Parameter::~Parameter(void)
02394 {
02395     for (int32_t i=0; i<get_num_parameters(); i++)
02396         delete m_params.get_element(i);
02397 
02398     SG_UNREF(sg_io);
02399 }
02400 
02401 void
02402 Parameter::add_type(const TSGDataType* type, void* param,
02403                      const char* name, const char* description)
02404 {
02405     if (name == NULL || *name == '\0')
02406         SG_SERROR("FATAL: Parameter::add_type(): `name' is empty!");
02407 
02408     for (int32_t i=0; i<get_num_parameters(); i++)
02409         if (strcmp(m_params.get_element(i)->m_name, name) == 0)
02410             SG_SERROR("FATAL: Parameter::add_type(): "
02411                      "Double parameter `%s'!", name);
02412 
02413     m_params.append_element(
02414         new TParameter(type, param, name, description)
02415         );
02416 }
02417 
02418 void
02419 Parameter::print(const char* prefix)
02420 {
02421     for (int32_t i=0; i<get_num_parameters(); i++)
02422         m_params.get_element(i)->print(prefix);
02423 }
02424 
02425 bool
02426 Parameter::save(CSerializableFile* file, const char* prefix)
02427 {
02428     for (int32_t i=0; i<get_num_parameters(); i++)
02429     {
02430         if (!m_params.get_element(i)->save(file, prefix))
02431             return false;
02432     }
02433 
02434     return true;
02435 }
02436 
02437 bool
02438 Parameter::load(CSerializableFile* file, const char* prefix)
02439 {
02440     for (int32_t i=0; i<get_num_parameters(); i++)
02441         if (!m_params.get_element(i)->load(file, prefix))
02442             return false;
02443 
02444     return true;
02445 }
02446 
02447 void Parameter::set_from_parameters(Parameter* params)
02448 {
02449     /* iterate over parameters in the given list */
02450     for (index_t i=0; i<params->get_num_parameters(); ++i)
02451     {
02452         TParameter* current=params->get_parameter(i);
02453         TSGDataType current_type=current->m_datatype;
02454 
02455         ASSERT(m_params.get_num_elements());
02456 
02457         /* search for own parameter with same name and check types if found */
02458         TParameter* own=NULL;
02459         for (index_t j=0; j<m_params.get_num_elements(); ++j)
02460         {
02461             own=m_params.get_element(j);
02462             if (!strcmp(own->m_name, current->m_name))
02463             {
02464                 if (own->m_datatype==current_type)
02465                 {
02466                     own=m_params.get_element(j);
02467                     break;
02468                 }
02469                 else
02470                 {
02471                     SG_SERROR("given parameter name %s has a different type"
02472                             " than existing one\n", current->m_name);
02473                 }
02474             }
02475             else
02476                 own=NULL;
02477         }
02478 
02479         if (!own)
02480         {
02481             SG_SERROR("parameter with name %s does not exist\n",
02482                     current->m_name);
02483         }
02484 
02485         /* check if parameter contained CSGobjects (update reference counts) */
02486         if (current_type.m_ptype==PT_SGOBJECT)
02487         {
02488             /* PT_SGOBJECT only occurs for ST_NONE */
02489             if (own->m_datatype.m_stype==ST_NONE)
02490             {
02491                 if (own->m_datatype.m_ctype==CT_SCALAR)
02492                 {
02493                     CSGObject** to_unref=(CSGObject**) own->m_parameter;
02494                     CSGObject** to_ref=(CSGObject**) current->m_parameter;
02495 
02496                     if ((*to_ref)!=(*to_unref))
02497                     {
02498                         SG_REF((*to_ref));
02499                         SG_UNREF((*to_unref));
02500                     }
02501 
02502                 }
02503                 else
02504                 {
02505                     /* unref all SGObjects and reference the new ones */
02506                     CSGObject*** to_unref=(CSGObject***) own->m_parameter;
02507                     CSGObject*** to_ref=(CSGObject***) current->m_parameter;
02508 
02509                     for (index_t j=0; j<own->m_datatype.get_num_elements(); ++j)
02510                     {
02511                         if ((*to_ref)[j]!=(*to_unref)[j])
02512                         {
02513                             SG_REF(((*to_ref)[j]));
02514                             SG_UNREF(((*to_unref)[j]));
02515                         }
02516                     }
02517                 }
02518             }
02519             else
02520                 SG_SERROR("primitive type PT_SGOBJECT occurred with structure "
02521                         "type other than ST_NONE");
02522         }
02523 
02524         /* construct pointers to the to be copied parameter data */
02525         void* dest=NULL;
02526         void* source=NULL;
02527         if (current_type.m_ctype==CT_SCALAR)
02528         {
02529             /* for scalar values, just copy content the pointer points to */
02530             dest=own->m_parameter;
02531             source=current->m_parameter;
02532 
02533             /* in case of CSGObject, pointers are not equal if CSGObjects are
02534              * equal, so check. For other values, the pointers are equal and
02535              * the not-copying is handled below before the memcpy call */
02536             if (own->m_datatype.m_ptype==PT_SGOBJECT)
02537             {
02538                 if (*((CSGObject**)dest) == *((CSGObject**)source))
02539                 {
02540                     dest=NULL;
02541                     source=NULL;
02542                 }
02543             }
02544         }
02545         else
02546         {
02547             /* for matrices and vectors, sadly m_parameter has to be
02548              * de-referenced once, because a pointer to the array address is
02549              * saved, but the array address itself has to be copied.
02550              * consequently, for dereferencing, a type distinction is needed */
02551             switch (own->m_datatype.m_ptype)
02552             {
02553             case PT_FLOAT64:
02554                 dest=*((float64_t**) own->m_parameter);
02555                 source=*((float64_t**) current->m_parameter);
02556                 break;
02557             case PT_SGOBJECT:
02558                 dest=*((CSGObject**) own->m_parameter);
02559                 source=*((CSGObject**) current->m_parameter);
02560                 break;
02561             default:
02562                 SG_SNOTIMPLEMENTED;
02563                 break;
02564             }
02565         }
02566 
02567         /* copy parameter data, size in memory is equal because of same type */
02568         if (dest!=source)
02569             memcpy(dest, source, own->m_datatype.get_size());
02570     }
02571 }
02572 
02573 void Parameter::add_parameters(Parameter* params)
02574 {
02575     for (index_t i=0; i<params->get_num_parameters(); ++i)
02576     {
02577         TParameter* current=params->get_parameter(i);
02578         add_type(&(current->m_datatype), current->m_parameter, current->m_name,
02579                 current->m_description);
02580     }
02581 }
02582 
02583 bool Parameter::contains_parameter(const char* name)
02584 {
02585     for (index_t i=0; i<m_params.get_num_elements(); ++i)
02586     {
02587         if (!strcmp(name, m_params[i]->m_name))
02588             return true;
02589     }
02590 
02591     return false;
02592 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation