This test generates a program that declares the constant elements of an n*n Hilbert matrix, its inverse, and the constant elements of the explicit product of the two. The product should be the identity matrix; that check is also expressed as a constant expression. Type-checking verifies that the product is indeed the identity matrix by asserting the result of the identity check (using the assert built-in which is available for type-check tests). The test is run for n = 5. Other values can be tested via the -H flag, say: go test -run=Hilbert -H=100 The generated program can be written to a file for testing the constant arithmetic of a compiler: go test -out=test.go Because of the mathematically precise constant arithmetic of go/types, this test should always succeed and is only limited by the size of the matrix. It does run successfully from n = 0 to values larger than 100. The Hilbert matrix is famous for being ill-conditioned and thus exposes arithmetic imprecision very quickly. The gc compiler only produces a correct result for n = 0 (trivially), and n = 1 at the moment. R=adonovan, rsc CC=golang-dev https://golang.org/cl/35840043 |
||
|---|---|---|
| astutil | ||
| blog | ||
| call | ||
| cmd | ||
| dashboard | ||
| go | ||
| godoc | ||
| importer | ||
| oracle | ||
| playground | ||
| pointer | ||
| present | ||
| ssa | ||
| .hgignore | ||
| AUTHORS | ||
| CONTRIBUTORS | ||
| LICENSE | ||
| PATENTS | ||
| README | ||
| codereview.cfg | ||
README
This subrepository holds the source for various packages and tools that support the Go programming language. Some of the tools, godoc and vet for example, are included in binary Go distributions. Others, including the Go oracle and the test coverage tool, can be fetched with "go get". Packages include a type-checker for Go and an implementation of the Static Single Assignment form (SSA) representation for Go programs. To submit changes to this repository, see http://golang.org/doc/contribute.html.