Skip to content
This repository was archived by the owner on Nov 24, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install:
- if [[ "$BLAS_LIB" == "OpenBLAS" ]]; then export CGO_LDFLAGS="-L/usr/lib -lopenblas"; fi
- go get github.com/gonum/blas
- go get github.com/gonum/matrix/mat64
- pushd clapack
- pushd cgo
- if [[ "$BLAS_LIB" == "OpenBLAS" ]]; then perl genLapack.pl -L/usr/lib -lopenblas; fi
- popd

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ Gonum LAPACK [![Build Status](https://travis-ci.org/gonum/lapack.svg)](https://
======

A collection of packages to provide LAPACK functionality for the Go programming
language (http://golang.org)

This is work in progress. Breaking changes are likely to happen.
language (http://golang.org). This provides a partial implementation in native go
and a wrapper using cgo to a c-based implementation.

## Installation

Expand Down
20 changes: 15 additions & 5 deletions clapack/genLapack.pl → cgo/genLapack.pl
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ package clapack
rowMajor order = 101 + iota
colMajor
)

func init() {
_ = lapack.Complex128(Lapack{})
_ = lapack.Float64(Lapack{})
}

func isZero(ret C.int) bool { return ret == 0 }

EOH

$/ = undef;
Expand Down Expand Up @@ -110,11 +112,18 @@ package clapack
"LAPACK_C_SELECT2" => "Select2Complex64",
"LAPACK_Z_SELECT1" => "Select1Complex128",
"LAPACK_Z_SELECT2" => "Select2Complex128",
"void" => ""
"void" => "",

"lapack_int_return_type" => "bool",
"lapack_int_return" => "isZero",
"float_return_type" => "float32",
"float_return" => "float32",
"double_return_type" => "float64",
"double_return" => "float64"
);

foreach my $line (@lines) {
process($line);
process($line);
}

close($golapack);
Expand Down Expand Up @@ -162,14 +171,15 @@ sub processProto {
$gofunc = ucfirst $func;
}

my $GoRet = $typeConv{$ret};
my $GoRet = $typeConv{$ret."_return"};
my $GoRetType = $typeConv{$ret."_return_type"};
my $complexType = $func;
$complexType =~ s/.*_[isd]?([zc]).*/$1/;
my ($params,$bp) = processParamToGo($func, $paramList, $complexType);
if ($params eq "") {
return
}
print $golapack "func (Lapack) ".$gofunc."(".$params.") ".$GoRet."{\n";
print $golapack "func (Lapack) ".$gofunc."(".$params.") ".$GoRetType."{\n";
print $golapack "\t";
if ($ret ne 'void') {
print $golapack "\n".$bp."\n"."return ".$GoRet."(";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
61 changes: 0 additions & 61 deletions dla/dla_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions dla/impl.go

This file was deleted.

40 changes: 0 additions & 40 deletions dla/qr.go

This file was deleted.

61 changes: 0 additions & 61 deletions dla/svd.go

This file was deleted.

21 changes: 5 additions & 16 deletions lapack.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package lapack

import (
"github.com/gonum/blas"
)
import "github.com/gonum/blas"

const None = 'N'

Expand All @@ -21,19 +19,10 @@ const (
Explicit (CompSV) = 'I'
)

// Float64 defines the float64 interface for the Lapack function. This interface
// contains the functions needed in the gonum suite.
type Float64 interface {
Dgeqrf(m, n int, a []float64, lda int, tau []float64) int
Dormqr(s blas.Side, t blas.Transpose, m, n, k int, a []float64, lda int, tau []float64, c []float64, ldc int) int
Dgesdd(job Job, m, n int, a []float64, lda int, s []float64, u []float64, ldu int, vt []float64, ldvt int) int
Dgebrd(m, n int, a []float64, lda int, d, e, tauq, taup []float64) int
Dbdsdc(uplo blas.Uplo, compq CompSV, n int, d, e []float64, u []float64, ldu int, vt []float64, ldvt int, q []float64, iq []int32) int
Dpotrf(ul blas.Uplo, n int, a []float64, lda int) (ok bool)
}

type Complex128 interface {
Float64

Zgeqrf(m, n int, a []complex128, lda int, tau []complex128) int
Zunmqr(s blas.Side, t blas.Transpose, m, n, k int, a []complex128, lda int, tau []complex128, c []complex128, ldc int) int
Zgesdd(job Job, m, n int, a []complex128, lda int, s []float64, u []complex128, ldu int, vt []complex128, ldvt int) int
Zgebrd(m, n int, a []complex128, lda int, d, e []float64, tauq, taup []complex128) int
}
type Complex128 interface{}
49 changes: 49 additions & 0 deletions lapack64/lapack64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright ©2015 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package lapack64 provides a set of convenient wrapper functions for LAPACK
// calls, as specified in the netlib standard (www.netlib.org).
//
// The native Go routines are used by default, and the Use function can be used
// to set an alternate implementation.
//
// If the type of matrix (General, Symmetric, etc.) is known and fixed, it is
// used in the wrapper signature. In many cases, however, the type of the matrix
// changes during the call to the routine, for example the matrix is symmetric on
// entry and is triangular on exit. In these cases the correct types should be checked
// in the documentation.
//
// The full set of Lapack functions is very large, and it is not clear that a
// full implementation is desirable, let alone feasible. Please open up an issue
// if there is a specific function you need and/or are willing to implement.
package lapack64

import (
"github.com/gonum/blas"
"github.com/gonum/blas/blas64"
"github.com/gonum/lapack"
"github.com/gonum/lapack/native"
)

var lapack64 lapack.Float64 = native.Implementation{}

// Use sets the LAPACK float64 implementation to be used by subsequent BLAS calls.
// The default implementation is native.Implementation.
func Use(l lapack.Float64) {
lapack64 = l
}

// Potrf computes the cholesky factorization of a.
// A = U^T * U if ul == blas.Upper
// A = L * L^T if ul == blas.Lower
// The underlying data between the input matrix and output matrix is shared.
func Potrf(a blas64.Symmetric) (t blas64.Triangular, ok bool) {
ok = lapack64.Dpotrf(a.Uplo, a.N, a.Data, a.Stride)
t.Uplo = a.Uplo
t.N = a.N
t.Data = a.Data
t.Stride = a.Stride
t.Diag = blas.NonUnit
return
}
Loading