+
Skip to content

nickng/abelian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

abelian Build Status GoDoc

Implementation of integer-based torsion-free Abelian Group in Go.

Usage

go get github.com/nickng/abelian

Example: creating a group

// This example shows how to create an Integer-pair abelian group.
s := set.NewIntTuple(2) // tuple size set to 2
g := abelian.New(s, s.Add)

// The following g.Op is the + operation for pairs,
// hence the output is (1,2) + (2,3) = (3,5)
//
output := g.Op(s.Tuple(1, 2), s.Tuple(2, 3))
fmt.Println("Group:", g.String())
fmt.Println(output)

// prints out (3,5)

Example: enumerating a finite subset

// This example shows how to enumerate a 2D-interval.
s := set.NewIntTuple(2)
g := abelian.New(s, s.Add)

// The given Set s implements
// - LessEqual(x, y Elem) bool
// - Interval(lo, hi Elem) Enumerable
subset := g.Set.(prop.PartialOrdered).Interval(s.Tuple(1, 1), s.Tuple(2, 2))
for i, tuple := range subset.Slice() {
    fmt.Println(tuple)
}

// prints out (1,1) (1,2) (2,1) (2,2)

More examples can be found in GoDoc.

License

abelian is licensed under the Apache License

About

Integer based abelian group implementation for Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载