skelterjohn / go.matrix Goto Github PK
View Code? Open in Web Editor NEWlinear algebra for go
License: Other
linear algebra for go
License: Other
When writing a tool to generate polynormials I have encountered a bug where the libary would crash in QR
and take the whole program with it.
You can find the code I used:
https://github.com/playgenhub/DataPlay/blob/master/tools/generatepolys/gen.go#L13
Here is the stack trace:
panic: runtime error: slice bounds out of range
goroutine 1 [running]:
github.com/skelterjohn/go%2ematrix.(*DenseMatrix).QR(0xc0801f6ae0, 0x1, 0xc0801f6bd0,0xc0801f6c30)
C:/Users/Ben Cox/src/github.com/skelterjohn/go.matrix/dense_decomp.go:177 +0x12bb
main.GetPolyResults(0xc0802bdf60, 0x2, 0x2, 0xc0802bdf70, 0x2, ...)
C:/Users/Ben Cox/Documents/datacon/tools/generatepolys/gen.go:35 +0x306
main.DoPoly(0xc0801a0140, 0x3f, 0xc0800d79c0, 0x12, 0xc0800af8c0, ...)
C:/Users/Ben Cox/Documents/datacon/tools/generatepolys/gen.go:116 +0x4dc
main.main()
C:/Users/Ben Cox/Documents/datacon/tools/generatepolys/gen.go:100 +0xb54
I put a trap into the library to capture the state before it crashed:
func (A *DenseMatrix) QR(debug bool) (Q, R *DenseMatrix) {
if debug {
b, _ := json.Marshal(A.elements)
fmt.Println(string(b))
}
And I got this back when the application would crash
[
1,
21669,
469545561,
1,
1447,
2093809
]
if it is any help the dataset that was shoved into it was:
transaction_number,ap_amount____
149149,27589.1
149166,30032
161184,1797250
161691,27066.7
169567,25706.4
161186,1134340
161756,90027
161188,132034
161190,693800
161180,222737
161665,26729
206584,30528
161696,29500.2
193463,92318
178295,304469
161192,2182670
184579,78657.1
161718,30097.2
The following generates an error.
_, err := matrix.ParseMatlab("[1 2; 3 4.4]")
The error states: strconv.ParseFloat: parsing ".": invalid syntax
. When I substitute the value 4.4
with an 4
it works as expected. I would expect that floating point values would be allowed.
Could please add some documentation to this library? With examples of use?
Hi John, this is an important repo for golang as it is the most complete native go matrix library. Others use cgo. I would be willing to take on this repo and give it some TLC. Thoughts? Feel free to check out my very active github profile.
Using go.matrix for OpenGL calls for example isn't possible without converting each underlying matrix to a float32 slice. It would be nice to see functionality added that allows the user to use this type.
When the row or col index is negative, such as A.Get(1, -2), an error occurred.
By checking your code, the minus "-" operation should be changed to "+" operation.
MakeDenseMatrix makes a new slice for A.elements, then loses it to the garbage collector by assigning the parameter elements. The intent isn't documented and seems ambiguous from the code. Maybe the make should be deleted, or maybe data should be copied from the parameter.
The .go files say
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
but there is no LICENSE file in the github repo. Could you add the LICENSE file?
I believe that the OneNorm and InfinityNorm functions are implemented incorrectly.
The OneNorm should be the sum of absolute values of the elements of the matrix.
The InfinityNorm should be the maximum absolute value of the elements of the matrix.
Also, it would be helpful to have a function that provides the log determinant, since the determinant will blow up for moderate or large matrix sizes.
I don't know if there's something clever I'm missing about ignoring errors when trying to chain matrix operations - but having the ability to do this:
Y := Z.MinusDense( H.TimesDense(X) )
Instead of this:
HX, err := H.TimesDense(X)
if err != nil {
return nil, error
}
Y, err = Z.MinusDense(HX)
if err != nil {
return nil, error
}
Would be terrific. I don't know if maybe having a different import for go.matrix that allowed for the matrix operations to be chained like this would make sense. I was gonna branch this and simply replace all return *DenseMatrix, error
with panic(err)
but seeing as this seems to be the most prominent matrix package for Go, I thought I would ask for your thoughts before going in that direction.
I have been benchmarking this library against the regular C libraries, and the regular libs are about 100x faster than go.matrix. Has anyone looked at where this discrepancy is coming from? Anyone using this, or another Go linear algebra lib, for machine learning or other compute intensive applications?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.