// (A|I) -> (I|A')
769676
func (m matrix) gauss(n int) error {
	c := 2 * n // c: cols_num of m
	// main_diagonal(left_part) -> 1 & left_part -> upper_triangular
	for i := 0; i < n; i++ {
		// m[i*c+i]: element of main_diagonal(left_part)
		if m[i*c+i] == 0 { // swap until get a non-zero element
			for j := i + 1; j < n; j++ {
				if m[j*c+i] != 0 {
					m.swap(i, j, c)
					break
				}
			}
		}
		if m[i*c+i] == 0 { // all element in one col are zero
			return ErrSingularMatrix
		}
		// main_diagonal(left_part) -> 1
		if m[i*c+i] != 1 {
			e := m[i*c+i]
			s := inverseTbl[e] // s * e = 1
			for j := 0; j < c; j++ {
				m[i*c+j] = mulTbl[m[i*c+j]][s] // all element * s (in i row)
			}
		}
		// left_part -> upper_triangular
		for j := i + 1; j < n; j++ {
			if m[j*c+i] != 0 {
				s := m[j*c+i] // s ^ (s * m[i*c+i]) = 0, m[i*c+i] = 1
				for k := 0; k < c; k++ {
					m[j*c+k] ^= mulTbl[s][m[i*c+k]] // all element ^ (s * row_i[k]) (in j row)
				}
			}
		}
	}
	// element upper main_diagonal(left_part) -> 0
	for i := 0; i < n; i++ {
		for j := 0; j < i; j++ {
			if m[j*c+i] != 0 {
				s := m[j*c+i] // s ^ (s * m[i*c+i]) = 0, m[i*c+i] = 1
				for k := 0; k < c; k++ {
					m[j*c+k] ^= mulTbl[s][m[i*c+k]] // all element ^ (s * row_i[k]) (in j row)
				}
			}
		}
	}
	return nil
}
648006
func (primative *Primative) AsString() (string, error) {
	switch val := primative.value.(type) {
	case bool:
		strVal := "False"
		if val {
			strVal = "True"
		}
		return strVal, nil
	case float64:
		return strconv.FormatFloat(val, 10, -1, 64), nil
	case int64:
		return strconv.FormatInt(val, 10), nil
	case nil:
		return "Null", nil
	case string:
		return val, nil
	}

	msg := fmt.Sprintf("Could not convert value %s to type STRING", primative.value)
	return "", errors.New(msg)
}
1340543
func (s *State) T(matcher matcher.Matcher, next *State) *State {
	s.Transitions = append(s.Transitions, &Transition{Matcher: matcher, Next: next})
	return next
}
836395
func QuoteArray(s []string, sep string) string {
	quoted := make([]string, len(s))
	for i, value := range s {
		quoted[i] = strconv.Quote(value)
	}
	return strings.Join(quoted, sep)
}
548743
func iface2vstr(a interface{}) []string {
	r := []string{}
	switch a.(type) {
	case []interface{}:
		for _, item := range a.([]interface{}) {
			switch item.(type) {
			case string:
				r = append(r, item.(string))
			}
		}
	}
	return r
}
161998
func (u Uint8) If(fn func(uint8)) {
	if u.Present() {
		fn(*u.value)
	}
}
965779
func A(m map[string]interface{}) Args {
	args := make(Args, 0, len(m))
	for name, value := range m {
		args = append(args, Arg{name, value})
	}
	return args
}
699623
func atois(strs []string) ([]int, error) {
	var a []int
	for _, str := range strs {
		i, err := strconv.Atoi(str)
		if err != nil {
			return nil, err
		}
		a = append(a, i)
	}
	return a, nil
}
1166472
func IndexUint(a, b string) bool {
	ia, _ := strconv.ParseUint(a, 10, 64)
	ib, _ := strconv.ParseUint(b, 10, 64)
	return ia < ib
}
1327837
func (self FunctionCall) Argument(index int) Value {
	return valueOfArrayIndex(self.ArgumentList, index)
}
160608
func (this *token_iterator) skip_to_left_curly() bool {
	return this.skip_to_left(token.LBRACE, token.RBRACE)
}
1091220
func Sub(a, b *T) T {
	return T{a[0] - b[0], a[1] - b[1], a[2] - b[2]}
}
282403
func (b byString) Less(i, j int) bool {
	ithVal := b.Identifier(b.Data.Index(i).Interface())
	jthVal := b.Identifier(b.Data.Index(j).Interface())
	if ithVal == jthVal {
		return b.Indices[i] < b.Indices[j]
	}
	return ithVal < jthVal
}
1236809
func (p *DefaultWordTokenizer) IsAlpha(t *Token) bool {
	return t.reAlpha.MatchString(t.Tok)
}
270688
func init() {
	zeroArg = make([]reflect.Value, 0)
	zeroArgInterf = make([]interface{}, 0)
	trueInterf = true
	falseInterf = false
	nilInterf = nil
}
670258
func indirect(a interface{}) interface{} {
	if a == nil {
		return nil
	}
	if t := reflect.TypeOf(a); t.Kind() != reflect.Ptr {
		// Avoid creating a reflect.Value if it's not a pointer.
		return a
	}
	v := reflect.ValueOf(a)
	for v.Kind() == reflect.Ptr && !v.IsNil() {
		v = v.Elem()
	}
	return v.Interface()
}
871956
func (u uintSlice) Less(i, j int64) bool {
	return u[i] < u[j]
}