libsvm-sys 3.24.0

FFI bindings to libsvm
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
/* automatically generated by rust-bindgen */

pub const LIBSVM_VERSION: u32 = 324;
extern "C" {
    pub static mut libsvm_version: ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct svm_node {
    pub index: ::std::os::raw::c_int,
    pub value: f64,
}
#[test]
fn bindgen_test_layout_svm_node() {
    assert_eq!(
        ::std::mem::size_of::<svm_node>(),
        16usize,
        concat!("Size of: ", stringify!(svm_node))
    );
    assert_eq!(
        ::std::mem::align_of::<svm_node>(),
        8usize,
        concat!("Alignment of ", stringify!(svm_node))
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_node>())).index as *const _ as usize },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_node),
            "::",
            stringify!(index)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_node>())).value as *const _ as usize },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_node),
            "::",
            stringify!(value)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct svm_problem {
    pub l: ::std::os::raw::c_int,
    pub y: *mut f64,
    pub x: *mut *mut svm_node,
}
#[test]
fn bindgen_test_layout_svm_problem() {
    assert_eq!(
        ::std::mem::size_of::<svm_problem>(),
        24usize,
        concat!("Size of: ", stringify!(svm_problem))
    );
    assert_eq!(
        ::std::mem::align_of::<svm_problem>(),
        8usize,
        concat!("Alignment of ", stringify!(svm_problem))
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_problem>())).l as *const _ as usize },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_problem),
            "::",
            stringify!(l)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_problem>())).y as *const _ as usize },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_problem),
            "::",
            stringify!(y)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_problem>())).x as *const _ as usize },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_problem),
            "::",
            stringify!(x)
        )
    );
}
pub const C_SVC: _bindgen_ty_1 = 0;
pub const NU_SVC: _bindgen_ty_1 = 1;
pub const ONE_CLASS: _bindgen_ty_1 = 2;
pub const EPSILON_SVR: _bindgen_ty_1 = 3;
pub const NU_SVR: _bindgen_ty_1 = 4;
pub type _bindgen_ty_1 = u32;
pub const LINEAR: _bindgen_ty_2 = 0;
pub const POLY: _bindgen_ty_2 = 1;
pub const RBF: _bindgen_ty_2 = 2;
pub const SIGMOID: _bindgen_ty_2 = 3;
pub const PRECOMPUTED: _bindgen_ty_2 = 4;
pub type _bindgen_ty_2 = u32;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct svm_parameter {
    pub svm_type: ::std::os::raw::c_int,
    pub kernel_type: ::std::os::raw::c_int,
    pub degree: ::std::os::raw::c_int,
    pub gamma: f64,
    pub coef0: f64,
    pub cache_size: f64,
    pub eps: f64,
    pub C: f64,
    pub nr_weight: ::std::os::raw::c_int,
    pub weight_label: *mut ::std::os::raw::c_int,
    pub weight: *mut f64,
    pub nu: f64,
    pub p: f64,
    pub shrinking: ::std::os::raw::c_int,
    pub probability: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_svm_parameter() {
    assert_eq!(
        ::std::mem::size_of::<svm_parameter>(),
        104usize,
        concat!("Size of: ", stringify!(svm_parameter))
    );
    assert_eq!(
        ::std::mem::align_of::<svm_parameter>(),
        8usize,
        concat!("Alignment of ", stringify!(svm_parameter))
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).svm_type as *const _ as usize },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(svm_type)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).kernel_type as *const _ as usize },
        4usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(kernel_type)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).degree as *const _ as usize },
        8usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(degree)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).gamma as *const _ as usize },
        16usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(gamma)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).coef0 as *const _ as usize },
        24usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(coef0)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).cache_size as *const _ as usize },
        32usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(cache_size)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).eps as *const _ as usize },
        40usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(eps)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).C as *const _ as usize },
        48usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(C)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).nr_weight as *const _ as usize },
        56usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(nr_weight)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).weight_label as *const _ as usize },
        64usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(weight_label)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).weight as *const _ as usize },
        72usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(weight)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).nu as *const _ as usize },
        80usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(nu)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).p as *const _ as usize },
        88usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(p)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).shrinking as *const _ as usize },
        96usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(shrinking)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_parameter>())).probability as *const _ as usize },
        100usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_parameter),
            "::",
            stringify!(probability)
        )
    );
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct svm_model {
    pub param: svm_parameter,
    pub nr_class: ::std::os::raw::c_int,
    pub l: ::std::os::raw::c_int,
    pub SV: *mut *mut svm_node,
    pub sv_coef: *mut *mut f64,
    pub rho: *mut f64,
    pub probA: *mut f64,
    pub probB: *mut f64,
    pub sv_indices: *mut ::std::os::raw::c_int,
    pub label: *mut ::std::os::raw::c_int,
    pub nSV: *mut ::std::os::raw::c_int,
    pub free_sv: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_svm_model() {
    assert_eq!(
        ::std::mem::size_of::<svm_model>(),
        184usize,
        concat!("Size of: ", stringify!(svm_model))
    );
    assert_eq!(
        ::std::mem::align_of::<svm_model>(),
        8usize,
        concat!("Alignment of ", stringify!(svm_model))
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).param as *const _ as usize },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(param)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).nr_class as *const _ as usize },
        104usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(nr_class)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).l as *const _ as usize },
        108usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(l)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).SV as *const _ as usize },
        112usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(SV)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).sv_coef as *const _ as usize },
        120usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(sv_coef)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).rho as *const _ as usize },
        128usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(rho)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).probA as *const _ as usize },
        136usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(probA)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).probB as *const _ as usize },
        144usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(probB)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).sv_indices as *const _ as usize },
        152usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(sv_indices)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).label as *const _ as usize },
        160usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(label)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).nSV as *const _ as usize },
        168usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(nSV)
        )
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<svm_model>())).free_sv as *const _ as usize },
        176usize,
        concat!(
            "Offset of field: ",
            stringify!(svm_model),
            "::",
            stringify!(free_sv)
        )
    );
}
extern "C" {
    pub fn svm_train(prob: *const svm_problem, param: *const svm_parameter) -> *mut svm_model;
}
extern "C" {
    pub fn svm_cross_validation(
        prob: *const svm_problem,
        param: *const svm_parameter,
        nr_fold: ::std::os::raw::c_int,
        target: *mut f64,
    );
}
extern "C" {
    pub fn svm_save_model(
        model_file_name: *const ::std::os::raw::c_char,
        model: *const svm_model,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn svm_load_model(model_file_name: *const ::std::os::raw::c_char) -> *mut svm_model;
}
extern "C" {
    pub fn svm_get_svm_type(model: *const svm_model) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn svm_get_nr_class(model: *const svm_model) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn svm_get_labels(model: *const svm_model, label: *mut ::std::os::raw::c_int);
}
extern "C" {
    pub fn svm_get_sv_indices(model: *const svm_model, sv_indices: *mut ::std::os::raw::c_int);
}
extern "C" {
    pub fn svm_get_nr_sv(model: *const svm_model) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn svm_get_svr_probability(model: *const svm_model) -> f64;
}
extern "C" {
    pub fn svm_predict_values(
        model: *const svm_model,
        x: *const svm_node,
        dec_values: *mut f64,
    ) -> f64;
}
extern "C" {
    pub fn svm_predict(model: *const svm_model, x: *const svm_node) -> f64;
}
extern "C" {
    pub fn svm_predict_probability(
        model: *const svm_model,
        x: *const svm_node,
        prob_estimates: *mut f64,
    ) -> f64;
}
extern "C" {
    pub fn svm_free_model_content(model_ptr: *mut svm_model);
}
extern "C" {
    pub fn svm_free_and_destroy_model(model_ptr_ptr: *mut *mut svm_model);
}
extern "C" {
    pub fn svm_destroy_param(param: *mut svm_parameter);
}
extern "C" {
    pub fn svm_check_parameter(
        prob: *const svm_problem,
        param: *const svm_parameter,
    ) -> *const ::std::os::raw::c_char;
}
extern "C" {
    pub fn svm_check_probability_model(model: *const svm_model) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn svm_set_print_string_function(
        print_func: ::std::option::Option<
            unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char),
        >,
    );
}