How can I make a matrix with complex number entries with gonum/go?

460 Views Asked by At

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 :=  mat.NewDense(2, 2, []complex128{0, 0, 0, 3i})
2

There are 2 best solutions below

2
kortschak On

The Gonum mat package does not currently support complex128 values. It is something we are working on.

0
Marc Bacvanski On

Now, Gonum supports complex matrices.

You can make one like this:

matrix := mat.NewCDense(2, 2, []complex128{0, 0, 0, 3i})