Git Product home page Git Product logo

lapack's Introduction

Gonum LAPACK Build Status Coverage Status GoDoc

This repository is no longer maintained. Development has moved to https://github.com/gonum/gonum.

A collection of packages to provide LAPACK functionality for the Go programming language (http://golang.org). This provides a partial implementation in native go and a wrapper using cgo to a c-based implementation.

Installation

  go get github.com/gonum/lapack

Install OpenBLAS:

  git clone https://github.com/xianyi/OpenBLAS
  cd OpenBLAS
  make

Then install the lapack/cgo package:

  CGO_LDFLAGS="-L/path/to/OpenBLAS -lopenblas" go install github.com/gonum/lapack/cgo

For Windows you can download binary packages for OpenBLAS at http://sourceforge.net/projects/openblas/files/

If you want to use a different BLAS package such as the Intel MKL you can adjust the CGO_LDFLAGS variable:

  CGO_LDFLAGS="-lmkl_rt" go install github.com/gonum/lapack/cgo

Packages

lapack

Defines the LAPACK API based on http://www.netlib.org/lapack/lapacke.html

lapack/lapacke

Binding to a C implementation of the lapacke interface (e.g. OpenBLAS or intel MKL)

The linker flags (i.e. path to the BLAS library and library name) might have to be adapted.

The recommended (free) option for good performance on both linux and darwin is OpenBLAS.

Issues

If you find any bugs, feel free to file an issue on the github issue tracker for gonum/gonum or gonum/netlib for the CGO implementation if the bug exists in that reposity; no code changes will be made to this repository. Other discussions should be taken to the gonum-dev Google Group.

https://groups.google.com/forum/#!forum/gonum-dev

License

Please see github.com/gonum/license for general license information, contributors, authors, etc on the Gonum suite of packages.

lapack's People

Contributors

btracey avatar jonlawlor avatar kortschak avatar sbinet avatar vladimir-ch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lapack's Issues

cgo: tests for Dormbr and Dormlq comments though fixes in OpenBLAS merged

This is a complicated issue. The tests for Dormbr and Dormlq are commented out with reference to OpenBLAS issues and PRs. The issues have been closed and the PRs have been merged. This would suggest that these tests could and should be uncommented. I have just tried that, and they fail.

$ CGO_LDFLAGS="-L/usr/local -lopenblas" go test -run Dormlq
*** Error in `/tmp/go-build141511666/github.com/gonum/lapack/cgo/_test/cgo.test': free(): invalid next size (fast): 0x00000000028bb7b0 ***
[more]
$ CGO_LDFLAGS="-L/usr/local -lopenblas" go test -run Dormbr
 ** On entry to DORMBRP parameter number 13 had an illegal value
[more]

clapack: []int32 for lapack_int*?

  1. Why use int32, why not int?
  2. In case of iwork or ipiv parameters, they are arrays of int. However, in ?trexc, ifst and ilst are just single in/out integers, so using a slice for them seems inappropriate.

native,clapack: mark functions as internal when not part of lapack.Float64 or lapack.Complex128

All of clapack can be noted as not really for public consumption (though not in flux - essentially the same as the std syscall package).

Methods in native are present in many cases because they are dependencies for routines that are published in lapack.Float64. We can either unexport them in the short term (probably the correct answer for things like Ilaenv that have been noted as targets for removal) or just document them as internal.

lapack/native: add dggsvd3 implementation

dggsvd3 implements Generalised Singular Value Decomposition that has uses in signal processing and genomics.

  • dggsvd3
  • - dtgsja
  • -- dlapll
  • -- dlags2
  • - dggsvp3
  • -- dlapmt
  • -- dgeqp3
  • --- dlaqps
  • --- dlaqp2
  • -- dgerq2
  • -- dormr2
  • --- dgerqf (required for testing)

Lapack interface

How do we decide which of the lapack functions to include in the interface?
Should we just do it on a per need basis?

cgo: Dormqr comment not in sync with reality

The comment says:

// ... lwork == -1 will not run Dormqr but will instead write the minimum
// work necessary to work[0]. If len(work) < lwork, Dormqr will panic.

The code does:

        if lwork == -1 {
                 if left {
                         work[0] = float64(m)
                         return
                 }
                 work[0] = float64(n)
                 return
         }

         if left {
                 if lwork < n {
                         panic(badWork)
                 }
         } else {
                 if lwork < m {
                         panic(badWork)
                 }
         }

That is,

  1. Values put into work[0] and checked values of lwork seem to be swapped.
  2. len(work) < lwork is not checked.

native: Dggsvp3 incorrectly calculates range for A cleanup

If a test is run with m=3, p=3, n=5 the code at line 264 panics with a bounds check failure.

--- FAIL: TestDggsvp3 (0.00s)
panic: runtime error: slice bounds out of range [recovered]
	panic: runtime error: slice bounds out of range

goroutine 5 [running]:
testing.tRunner.func1(0xc4200724e0)
	/home/daniel/Development/go/src/testing/testing.go:622 +0x29d
panic(0x6a1fc0, 0x895c00)
	/home/daniel/Development/go/src/runtime/panic.go:489 +0x2cf
github.com/gonum/lapack/native.Implementation.Dggsvp3(0x515655, 0x3, 0x3, 0x5, 0xc420080980, 0xf, 0xf, 0x5, 0xc420080a80, 0xf, ...)
	/home/daniel/Development/src/github.com/gonum/lapack/native/dggsvp3.go:264 +0xcf0
github.com/gonum/lapack/native.(*Implementation).Dggsvp3(0x8b84e8, 0x515655, 0x3, 0x3, 0x5, 0xc420080980, 0xf, 0xf, 0x5, 0xc420080a80, ...)
	<autogenerated>:25 +0x28b
github.com/gonum/lapack/testlapack.Dggsvp3Test(0xc4200724e0, 0x857340, 0x8b84e8)
	/home/daniel/Development/src/github.com/gonum/lapack/testlapack/dggsvp3.go:109 +0xd20
github.com/gonum/lapack/native.TestDggsvp3(0xc4200724e0)
	/home/daniel/Development/src/github.com/gonum/lapack/native/lapack_test.go:116 +0x5b
testing.tRunner(0xc4200724e0, 0x6e5600)
	/home/daniel/Development/go/src/testing/testing.go:657 +0x96
created by testing.(*T).Run
	/home/daniel/Development/go/src/testing/testing.go:697 +0x2ca
FAIL	github.com/gonum/lapack/native	0.005s

native: bad computation of work matrix size in Dormqr

Dormqr computes the maximum number of columns of a work matrix nwxnb that fits into available workspace. If lwork is not long enough to hold the optimum block size nb, nb is reduced. The code however doesn't update ldwork, leaving it at the previous, unnecessarily large value. If the workspace is long enough to use the blocked code but not long enough to hold the nwxnb matrix, Dlarfb will panic later.

    ldwork := nb // nb is the optimal block size as returned from Ilaenv.
    if nb > 1 && nb < k {
        iws := nw * nb
        if lwork < iws {
            nb = lwork / nw
            // ldwork = nb // <--- Uncommenting fixes the issue.
            nbmin = max(2, impl.Ilaenv(2, "DORMQR", opts, m, n, k, -1))
        }
    }

Speaking of Dormqr, why is t allocated in Dormqr and not taken from work as in the reference LAPACK, @btracey ?

main.go example

Sorry if I'm out of place here, but can you refer me to a simple "main.go" that uses the lapack package you've contributed? It's really enticing, but I don't have anywhere to start (in go).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.