1

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 Answers2

1

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

kortschak
  • 755
  • 5
  • 21
  • Main purpose of me is to make matrix multiplication with complex valued matrices. Would you recommend the blas package of gonum to do this as the methods accept complex128 slices or would you recommend another package in gonum which is more easily to handle? –  Jun 01 '18 at 09:42
  • If you are able to use cgo in your project, the [gonum.org/v1/netlib/blas/netlib](https://godoc.org/gonum.org/v1/netlib/blas/netlib) implementation provides complex BLAS. – kortschak Jun 02 '18 at 10:15
1

Now, Gonum supports complex matrices.

You can make one like this:

matrix := mat.NewCDense(2, 2, []complex128{0, 0, 0, 3i})
Marc Bacvanski
  • 1,458
  • 4
  • 17
  • 33