Esempio n. 1
0
 internal FloatImp(DlibObject parent,
                   KernelBaseParameter kernelParameter,
                   NativeMethods.MatrixElementType elementType,
                   NativeMethods.SvmFunctionType functionType) :
     base(parent, kernelParameter, elementType, functionType)
 {
 }
Esempio n. 2
0
        internal NormalizedFunction(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new ArgumentException("Can not pass IntPtr.Zero", nameof(ptr));
            }

            var functionType = typeof(TFunction);
            var svmFunction  = functionType.GetGenericTypeDefinition();

            if (!FunctionTypesRepository.Types.TryGetValue(svmFunction, out var svmFunctionType))
            {
                throw new ArgumentException();
            }

            var kernelType = functionType.GenericTypeArguments[1].GetGenericTypeDefinition();

            if (!KernelTypesRepository.KernelTypes.TryGetValue(kernelType, out var svmKernelType))
            {
                throw new ArgumentException();
            }

            var elementType = functionType.GenericTypeArguments[0];

            if (!KernelTypesRepository.ElementTypes.TryGetValue(elementType, out var sampleType))
            {
                throw new ArgumentException();
            }

            this._Parameter       = new KernelBaseParameter(svmKernelType, sampleType, 0, 0);
            this._SvmFunctionType = svmFunctionType;
            this._Imp             = this.CreateImp(sampleType.ToNativeMatrixElementType());

            this.NativePtr = ptr;
        }
Esempio n. 3
0
        public NormalizedFunction()
        {
            var functionType = typeof(TFunction);
            var svmFunction  = functionType.GetGenericTypeDefinition();

            if (!FunctionTypesRepository.Types.TryGetValue(svmFunction, out var svmFunctionType))
            {
                throw new ArgumentException();
            }

            var kernelType = functionType.GenericTypeArguments[1].GetGenericTypeDefinition();

            if (!KernelTypesRepository.KernelTypes.TryGetValue(kernelType, out var svmKernelType))
            {
                throw new ArgumentException();
            }

            var elementType = functionType.GenericTypeArguments[0];

            if (!KernelTypesRepository.ElementTypes.TryGetValue(elementType, out var sampleType))
            {
                throw new ArgumentException();
            }

            this._Parameter       = new KernelBaseParameter(svmKernelType, sampleType, 0, 0);
            this._SvmFunctionType = svmFunctionType;
            this._Imp             = this.CreateImp(sampleType.ToNativeMatrixElementType());
            this.NativePtr        = NativeMethods.normalized_function_new(this._Parameter.KernelType.ToNativeKernelType(),
                                                                          this._Parameter.SampleType.ToNativeMatrixElementType(),
                                                                          this._Parameter.TemplateRows,
                                                                          this._Parameter.TemplateColumns,
                                                                          svmFunctionType);
        }
Esempio n. 4
0
 internal Imp(DlibObject parent,
              KernelBaseParameter kernelParameter,
              NativeMethods.MatrixElementType elementType,
              NativeMethods.SvmFunctionType functionType)
 {
     this.Parent          = parent ?? throw new ArgumentNullException(nameof(parent));
     this.KernelParameter = kernelParameter;
     this.ElementType     = elementType;
     this.FunctionType    = functionType;
 }