Exemple #1
0
        public KKMeans(KCentroid <TScalar, TKernel> kcentroid)
        {
            if (kcentroid == null)
            {
                throw new ArgumentNullException(nameof(kcentroid));
            }

            kcentroid.ThrowIfDisposed();

            this._KCentroid = kcentroid;
            var error = NativeMethods.kkmeans_new(this._KCentroid.Parameter.KernelType.ToNativeKernelType(),
                                                  this._KCentroid.Parameter.SampleType.ToNativeMatrixElementType(),
                                                  this._KCentroid.Parameter.TemplateRows,
                                                  this._KCentroid.Parameter.TemplateColumns,
                                                  kcentroid.NativePtr,
                                                  out var ret);

            switch (error)
            {
            case NativeMethods.ErrorType.MatrixElementTypeNotSupport:
                throw new ArgumentException($"{this._KCentroid.Parameter.SampleType} is not supported.");

            case NativeMethods.ErrorType.MatrixElementTemplateSizeNotSupport:
                throw new ArgumentException($"{nameof(this._KCentroid.Parameter.TemplateColumns)} or {nameof(this._KCentroid.Parameter.TemplateRows)} is not supported.");

            case NativeMethods.ErrorType.SvmKernelNotSupport:
                throw new ArgumentException($"{this._KCentroid.Parameter.KernelType} is not supported.");
            }

            this.NativePtr = ret;
        }
Exemple #2
0
        public void SetKCentroid(KCentroid <TScalar, TKernel> kcentroid)
        {
            if (kcentroid == null)
            {
                throw new ArgumentNullException(nameof(kcentroid));
            }

            kcentroid.ThrowIfDisposed();

            var ret = NativeMethods.kkmeans_set_kcentroid(this._KCentroid.Parameter.KernelType.ToNativeKernelType(),
                                                          this._KCentroid.Parameter.SampleType.ToNativeMatrixElementType(),
                                                          this._KCentroid.Parameter.TemplateRows,
                                                          this._KCentroid.Parameter.TemplateColumns,
                                                          this.NativePtr,
                                                          kcentroid.NativePtr);
        }