From 1d089cbd48aff28cac00a95932037c64b95aed06 Mon Sep 17 00:00:00 2001 From: wangfeng Date: Mon, 6 Feb 2023 15:22:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- algorithms/avx2/bool.go | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 algorithms/avx2/bool.go diff --git a/algorithms/avx2/bool.go b/algorithms/avx2/bool.go deleted file mode 100644 index c603649..0000000 --- a/algorithms/avx2/bool.go +++ /dev/null @@ -1,7 +0,0 @@ -package avx2 - -import "github.com/viterin/vek" - -func ToBool(x []float64) []bool { - return vek.ToBool(x) -} -- Gitee From 360fc5f42ac10ec8e031e63fff8d565afe4374ac Mon Sep 17 00:00:00 2001 From: wangfeng Date: Mon, 6 Feb 2023 15:44:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?#I6CYPG=20=E5=AE=9E=E7=8E=B0IF,=20IFF,=20IF?= =?UTF-8?q?N=E4=B8=89=E4=B8=AA=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- formula/if.go | 25 +++++++++++++++++++++++++ formula/if_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 formula/if.go create mode 100644 formula/if_test.go diff --git a/formula/if.go b/formula/if.go new file mode 100644 index 0000000..df67e92 --- /dev/null +++ b/formula/if.go @@ -0,0 +1,25 @@ +package formula + +import ( + "gitee.com/quant1x/pandas" + "gitee.com/quant1x/pandas/stat" +) + +// IF 序列布尔判断 return=A if S==True else B +func IF(S, A, B pandas.Series) pandas.Series { + return IFF(S, A, B) +} + +// IFF 序列布尔判断 return=A if S==True else B +func IFF(S, A, B pandas.Series) pandas.Series { + s := S.Float() + a := A.Float() + b := B.Float() + ret := stat.Where(s, a, b) + return pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", ret) +} + +// IFN 序列布尔判断 return=A if S==False else B +func IFN(S, A, B pandas.Series) pandas.Series { + return IFF(S, B, A) +} diff --git a/formula/if_test.go b/formula/if_test.go new file mode 100644 index 0000000..b45acf2 --- /dev/null +++ b/formula/if_test.go @@ -0,0 +1,28 @@ +package formula + +import ( + "fmt" + "gitee.com/quant1x/pandas" + "testing" +) + +func TestIF(t *testing.T) { + S := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{1, 1, 1}) + A := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{11, 12, 13}) + B := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{21, 22, 23}) + fmt.Println(IF(S, A, B)) +} + +func TestIFF(t *testing.T) { + S := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{1, 1, 1}) + A := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{11, 12, 13}) + B := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{21, 22, 23}) + fmt.Println(IFF(S, A, B)) +} + +func TestIFN(t *testing.T) { + S := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{1, 0, 1}) + A := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{11, 12, 13}) + B := pandas.NewSeries(pandas.SERIES_TYPE_FLOAT32, "", []float32{21, 22, 23}) + fmt.Println(IFN(S, A, B)) +} -- Gitee