internal unsafe Parameter(NativeMethods.svm_parameter *param) { this.C = param->C; this.CacheSize = param->cache_size; this.Coef0 = param->coef0; this.Degree = param->degree; this.Epsilon = param->eps; this.Gamma = param->gamma; this.KernelType = (KernelType)param->kernel_type; this.LengthOfWeight = param->nr_weight; this.Nu = param->nu; this.P = param->p; this.Probability = param->probability == NativeMethods.True; this.SvmType = (SvmType)param->svm_type; this.Shrinking = param->shrinking == NativeMethods.True; if (this.LengthOfWeight > 0) { var darray = new double[this.LengthOfWeight]; Marshal.Copy((IntPtr)param->weight, darray, 0, this.LengthOfWeight); this.Weight = darray; var iarray = new int[this.LengthOfWeight]; Marshal.Copy((IntPtr)param->weight_label, iarray, 0, this.LengthOfWeight); this.WeightLabel = iarray; } else { this.Weight = null; this.WeightLabel = null; } }
internal static unsafe void Free(NativeMethods.svm_parameter *parameter) { if ((IntPtr)parameter->weight != IntPtr.Zero) { NativeMethods.free((IntPtr)parameter->weight); } if ((IntPtr)parameter->weight_label != IntPtr.Zero) { NativeMethods.free((IntPtr)parameter->weight_label); } parameter->weight = (double *)IntPtr.Zero; parameter->weight_label = (int *)IntPtr.Zero; }