I want to consider a two-dimensional real array of numbers. I got to the point where the contents of the file are stored in the data line, but I don’t know how to create a two-dimensional array of real numbers based on this: Here’s the code:
package main import ( "fmt" //"gonum.org/v1/gonum/mat" "io" "os" "strconv" ) func main() { file, err := os.Open("matrix") if err != nil{ fmt.Println(err) os.Exit(1) } defer file.Close() data := make([]byte, 64) for{ n, err := file.Read(data) if err == io.EOF{ break } fmt.Print(string(data[:n])) } } Content of the matrix file:
5.482 0.358 0.237 0.409 0.416 0.580 4.953 0.467 0.028 0.464 0.319 0.372 8.935 0.520 0.979 0.043 0.459 0.319 4.778 0.126