@@ -56,7 +56,7 @@ type cellRange struct {
5656// formulaArg is the argument of a formula or function.
5757type formulaArg struct {
5858 Value string
59- Matrix []string
59+ Matrix [][] string
6060}
6161
6262// formulaFuncs is the type of the formula functions.
@@ -172,8 +172,8 @@ func (f *File) evalInfixExp(sheet string, tokens []efp.Token) (efp.Token, error)
172172 }
173173 for idx , val := range result {
174174 arg := formulaArg {Value : val }
175- if idx < len ( matrix ) {
176- arg .Matrix = matrix [ idx ]
175+ if idx == 0 {
176+ arg .Matrix = matrix
177177 }
178178 argsList .PushBack (arg )
179179 }
@@ -1850,17 +1850,13 @@ func det(sqMtx [][]float64) float64 {
18501850//
18511851func (fn * formulaFuncs ) MDETERM (argsList * list.List ) (result string , err error ) {
18521852 var num float64
1853- var rows int
18541853 var numMtx = [][]float64 {}
1855- var strMtx = [][]string {}
1856- for arg := argsList .Front (); arg != nil ; arg = arg .Next () {
1857- if len (arg .Value .(formulaArg ).Matrix ) == 0 {
1858- break
1859- }
1860- strMtx = append (strMtx , arg .Value .(formulaArg ).Matrix )
1861- rows ++
1854+ var strMtx = argsList .Front ().Value .(formulaArg ).Matrix
1855+ if argsList .Len () < 1 {
1856+ return
18621857 }
1863- for _ , row := range strMtx {
1858+ var rows = len (strMtx )
1859+ for _ , row := range argsList .Front ().Value .(formulaArg ).Matrix {
18641860 if len (row ) != rows {
18651861 err = errors .New (formulaErrorVALUE )
18661862 return
@@ -2630,3 +2626,5 @@ func (fn *formulaFuncs) TRUNC(argsList *list.List) (result string, err error) {
26302626 result = fmt .Sprintf ("%g" , float64 (int (number * adjust ))/ adjust )
26312627 return
26322628}
2629+
2630+ // Statistical functions
0 commit comments