public unsafe override double Sum(double[] src1) { double[] sum = new double[1]; VSLSS_Initial(src1, CurrentVSLStage.Sum); VSLNative.vsldSSEditTask(vslssHandle, VSLNative.VSLSS_EditTaskParam.VSL_SS_ED_SUM, sum); VSLNative.vsldSSCompute(vslssHandle, VSLNative.VSLSS_ComputeRoutine.VSL_SS_SUM, VSLNative.VSLSS_Method.VSL_SS_METHOD_FAST); return(sum[0]); }
public unsafe override double Mean(double[] src) { double[] mean = new double[1]; VSLSS_Initial(src, CurrentVSLStage.Mean); VSLNative.vsldSSEditTask(vslssHandle, VSLNative.VSLSS_EditTaskParam.VSL_SS_ED_MEAN, mean); VSLNative.vsldSSCompute(vslssHandle, VSLNative.VSLSS_ComputeRoutine.VSL_SS_MEAN, VSLNative.VSLSS_Method.VSL_SS_METHOD_FAST); return(mean[0]); }
public unsafe override void FindMaxMin(double[] src, out double maxValue, out double minValue, out int maxIdx, out int minIdx) { double[] max = new double[1]; double[] min = new double[1]; VSLSS_Initial(src, CurrentVSLStage.Max); VSLSS_Initial(src, CurrentVSLStage.Min); VSLNative.vsldSSEditTask(vslssHandle, VSLNative.VSLSS_EditTaskParam.VSL_SS_ED_MAX, max); VSLNative.vsldSSEditTask(vslssHandle, VSLNative.VSLSS_EditTaskParam.VSL_SS_ED_MIN, min); VSLNative.vsldSSCompute(vslssHandle, VSLNative.VSLSS_ComputeRoutine.VSL_SS_MAX | VSLNative.VSLSS_ComputeRoutine.VSL_SS_MIN, VSLNative.VSLSS_Method.VSL_SS_METHOD_FAST); maxValue = max[0]; minValue = min[0]; maxIdx = src.ToList().FindIndex(x => x == max[0]); minIdx = src.ToList().FindIndex(x => x == min[0]); }
public unsafe override double Skewness(double[] src) { double[] mean = new double[1]; double[] r2m = new double[1]; double[] c2m = new double[1]; double[] r3m = new double[1]; double[] c3m = new double[1]; double[] r4m = new double[1]; double[] c4m = new double[1]; double[] skewness = new double[1]; Estimates est = Estimates.VSL_SS_SKEWNESS | Estimates.VSL_SS_MEAN | Estimates.VSL_SS_2R_MOM | Estimates.VSL_SS_3R_MOM | Estimates.VSL_SS_4R_MOM; VSLSS_Initial(src, CurrentVSLStage.Skewness); VSLNative.vsldSSEditTask(vslssHandle, VSLNative.VSLSS_EditTaskParam.VSL_SS_ED_SKEWNESS, skewness); VSLNative.vsldSSEditMoments(vslssHandle, mean, r2m, r3m, r4m, c2m, c3m, c4m); VSLNative.vsldSSCompute(vslssHandle, est, VSLNative.VSLSS_Method.VSL_SS_METHOD_FAST); return(skewness[0]); }
private unsafe void VSLSS_Initial(double[] src, CurrentVSLStage stage) { if (dataBuffer.Length != src.Length || currentMethod != stage) { dataBuffer = new double[src.Length]; dim_n = src.Length; Buffer.BlockCopy(src, 0, dataBuffer, 0, src.Length * sizeof(double)); fixed(double *ptr = dataBuffer) { fixed(int *p = new int[] { 1 }, n = new int[] { dim_n }, xStorage = new int[] { (int)storage }) { VSLNative.vsldSSNewTask(ref vslssHandle, p, n, xStorage, ptr); } } currentMethod = stage; } else { Buffer.BlockCopy(src, 0, dataBuffer, 0, src.Length * sizeof(double)); } }