Questions tagged [gonum]
21 questions
6
votes
1 answer
How do I multiply a matrix with a vector in gonum?
I want to multiply a mat.Dense Matrix with a mat.VecDense Vector, but obviously mat.Dense nor mat.VecDens do not implement the Matrix interface or define a method to multiply a matrix with a vector. How would I do that?
user8725011
4
votes
2 answers
Gonum throws bad region panic when using an embedded struct
I am using gonum to perform a few linear algebra calculations. After extending the original mat.VecDense struct I am getting a "bad region: identical" panic when applying a method on itself. This error does not occur when I am using the original…

snufkin
- 43
- 3
4
votes
1 answer
Weighted sampling without replacement using gonum
I have a big array of items and another array of weights of the same size. I would like to sample without replacement from the first array based on the weights from the second array. Is there a way to do this using gonum?

alpaca
- 1,211
- 13
- 23
3
votes
0 answers
Cholesky factorization with gonum
I am trying to use the Go gonum/mat matrix library to find the Cholesky factorization of a matrix.
The goal is to get similar results to Matlab chol(). In Matlab chol(P_inno) outputs:
P_inno =…

Chrissy Heu
- 31
- 3
3
votes
3 answers
How can get the dimension of a matrix in go-lang?
Here is the piece of code:
package main
import (
"fmt"
"gonum.org/v1/gonum/mat"
)
func main() {
// Matrix and Vector
// Initialize a Matrix A
row1 := []float64{1,2,3}
row2 := []float64{4,5,6}
row3 := []float64{7,8,9}
row4 :=…

Md. Rezwanul Haque
- 2,882
- 7
- 28
- 45
2
votes
0 answers
Is there an equivalent of mat.Pow for CDense in Gonum?
given
a := mat.NewCDense(1,3, []complex128{
1, 1 + 2i, 0.2
})
I would like to compute the power of 2 of each element in the matrix. Is there a method for mat.CDense equivalent to mat.Pow for mat.Dense?

robotAstray
- 21
- 1
1
vote
1 answer
equivalent numpy.random.choice function in Golang
Basically what the title says is, is there any function / library in Golang that does numpy.random.choice?
What I want to do is, I want to shuffle a slice, based on the probability for each element.
The closest thing I got is the rand.Shuffle, but…

dzakyputra
- 682
- 4
- 16
1
vote
1 answer
How to use Golang's go mod dependency management behind proxy?
I am trying to set up a project with a gonum dependency and ran into the problem that we have a corporate proxy that blocks many destinations in the internet.
github.com is available over https.
gonum.org is not.
The gonum repository is hosted on…

Wilbert
- 7,251
- 6
- 51
- 91
1
vote
2 answers
Using Gonum for graph algorithms in Go
I am a new Go programmer, just finished the "A tour of Go" tutorial a couple days ago. I want to create a graph of a 150 x 120 size and then get all the edge nodes for each node and implement some graph search algorithms such as BFS and Dijkstra. I…

Evan Kim
- 769
- 2
- 8
- 26
1
vote
1 answer
Iterate over complex numbers
I need to iterate over the complex refractive index = n + ik
I made two floats.Span() filled with evenly spaced numbers, containing every n and k that I need to iterate over. How do I "mix" these two values now so I can make a for loop over every…

Aramus
- 47
- 8
1
vote
2 answers
How can I make a matrix with complex number entries with gonum/go?
As it is written in the title, how can I create an instance of a matrix with complex128? What is the complex equivalent of the following?
matrix := mat.NewDense(2, 2, []float64{0, 0, 0, 3})
how can I write something like this?
Matrix := …
user8002239
0
votes
0 answers
How to serialize gonum Dense matrix in protobuf?
I want to send a gonum Dense matrix in protobuf. However, I could not find a method to flatten the matrix to []float64. Is there a better way of doing this than retrieving the matrix values row by row.
I know serializing row by row works, but I am…

Ruomu
- 27
- 3
0
votes
1 answer
GO - panic: mat: zero length in matrix dimension
I run the code to train a neural network and I have a warning that the matrix is of zero length, I don't know what happens because I am using that matrix of zeros in the output variable of the neural network.
package main
import (
"errors"
…
0
votes
0 answers
Efficient Cumulative Product on Gorgonia Tensors in Go?
I'm trying to find the best way to fund the cumulative product of a Gorgonia Tensor. For example:
T := ts.New(ts.WithShape(3,4), ts.WithBacking(ts.Range(ts.Float32,1,13)))
for row := 1; row < 3; row++ {
for col :=0; col < 4; col++ {
…

TDM
- 11
- 3
0
votes
1 answer
How to deal with "import cycle not allowed" while trying to install gonum?
I'd like to use the gonum libraries for go in order to experiment with some neural network stuff but I cannot go past the install process...
I'm running the command found on the official gonum website :
go get -u -t gonum.org/v1/gonum/...
But it…

Vylly
- 13
- 3